Skip to content

Commit 41c586f

Browse files
authored
Patch elasticsearch.bat for 6.2 versions (#3226)
This commit patches the elasticsearch.bat file for 6.2 versions to include the fix in PR elastic/elasticsearch#29086
1 parent 79caff0 commit 41c586f

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

src/Tests/Framework/Configuration/Versions/ElasticsearchVersion.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ public static ElasticsearchVersion Create(string version, ElasticsearchVersionRe
4040
: new ElasticsearchVersion(version, resolver);
4141
}
4242

43+
public static implicit operator ElasticsearchVersion(string version) => string.IsNullOrWhiteSpace(version)
44+
? null
45+
: Create(version);
46+
4347
internal ElasticsearchVersion(string version, ElasticsearchVersionResolver resolver)
4448
: base(TranslateConfigVersion(version, resolver))
4549
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System.IO;
2+
using Tests.Framework.ManagedElasticsearch.Nodes;
3+
using Tests.Framework.Versions;
4+
5+
namespace Tests.Framework.ManagedElasticsearch.Tasks.InstallationTasks
6+
{
7+
/// <summary>
8+
/// Fixes https://github.com/elastic/elasticsearch/issues/29057
9+
/// </summary>
10+
public class EnsureElasticsearchBatWorksAcrossDrives : InstallationTaskBase
11+
{
12+
private readonly ElasticsearchVersion _sixTwoZero = "6.2.0";
13+
private readonly ElasticsearchVersion _sixThreeZero = "6.3.0";
14+
15+
public override void Run(NodeConfiguration config, NodeFileSystem fileSystem)
16+
{
17+
if (config.ElasticsearchVersion < _sixTwoZero || config.ElasticsearchVersion >= _sixThreeZero)
18+
return;
19+
20+
var batFile = Path.Combine(fileSystem.ElasticsearchHome, "bin", "elasticsearch.bat");
21+
var contents = File.ReadAllLines(batFile);
22+
for (var i = 0; i < contents.Length; i++)
23+
{
24+
if (contents[i] == "cd \"%ES_HOME%\"")
25+
{
26+
contents[i] = "cd /d \"%ES_HOME%\"";
27+
break;
28+
}
29+
}
30+
31+
File.WriteAllLines(batFile, contents);
32+
}
33+
}
34+
}

src/Tests/Framework/ManagedElasticsearch/Tasks/NodeTaskRunner.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public NodeTaskRunner(NodeConfiguration nodeConfiguration)
2929
new EnsureJavaHomeEnvironmentVariableIsSet(),
3030
new DownloadCurrentElasticsearchDistribution(),
3131
new UnzipCurrentElasticsearchDistribution(),
32+
new EnsureElasticsearchBatWorksAcrossDrives(),
3233
new CreateEasyRunBatFile(),
3334
new InstallPlugins(),
3435
new WriteAnalysisFiles(),
@@ -41,6 +42,7 @@ public NodeTaskRunner(NodeConfiguration nodeConfiguration)
4142
{
4243
new CreateEasyRunClusterBatFile()
4344
};
45+
4446
private static IEnumerable<AfterNodeStoppedTaskBase> NodeStoppedTasks { get; } = new List<AfterNodeStoppedTaskBase>
4547
{
4648
new CleanUpDirectoriesAfterNodeStopped()

0 commit comments

Comments
 (0)