Skip to content

Commit 4f7c075

Browse files
committed
build integrate <version> now accepts a third parameter <clusterfilter> which allows you to run specific cluster integration test more easily e.g build integrate 5.0.1 xpack
1 parent 86093a7 commit 4f7c075

File tree

11 files changed

+39
-23
lines changed

11 files changed

+39
-23
lines changed

build.bat

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ REM build
44
REM build build [skiptests]
55
REM build release [version] [skiptests]
66
REM build version [version] [skiptests]
7-
REM build integrate [elasticsearch_versions] [skiptests]
7+
REM build integrate [elasticsearch_versions] [clustername]
88
REM build canary [apikey] [feed] [skiptests]
99

1010
REM - elasticsearch_versions can be multiple separated with a semi-colon ';'
@@ -24,7 +24,8 @@ SET ESVERSIONS=
2424
SET SKIPTESTS=0
2525
SET APIKEY=
2626
SET APIKEYPROVIDED="<empty>"
27-
SET FEED="elasticsearch-net"
27+
SET FEED="elasticsearch-net"
28+
SET NEST_INTEGRATION_CLUSTER=
2829

2930
IF /I "%1"=="skiptests" (
3031
set SKIPTESTS="1"
@@ -46,8 +47,7 @@ IF /I "%1"=="release" (
4647

4748
IF /I "%1%"=="integrate" (
4849
IF NOT [%2]==[] (set ESVERSIONS="%2")
49-
IF /I "%3"=="skiptests" (set SKIPTESTS=1)
50-
IF /I "%2"=="skiptests" (set SKIPTESTS=1)
50+
IF NOT [%3]==[] (set NEST_INTEGRATION_CLUSTER="%3")
5151
)
5252

5353
IF /I "%1%"=="canary" (
@@ -61,5 +61,5 @@ IF /I "%1%"=="canary" (
6161
IF /I "%2"=="skiptests" (set SKIPTESTS=1)
6262
)
6363

64-
ECHO starting build using target=%TARGET% version=%VERSION% esversions=%ESVERSIONS% skiptests=%SKIPTESTS% apiKey=%APIKEYPROVIDED% feed=%FEED%
65-
"packages\build\FAKE\tools\Fake.exe" "build\\scripts\\Targets.fsx" "target=%TARGET%" "version=%VERSION%" "esversions=%ESVERSIONS%" "skiptests=%SKIPTESTS%" "apiKey=%APIKEY%" "feed=%FEED%"
64+
ECHO starting build using target=%TARGET% version=%VERSION% esversions=%ESVERSIONS% skiptests=%SKIPTESTS% apiKey=%APIKEYPROVIDED% feed=%FEED% escluster=%NEST_INTEGRATION_CLUSTER%
65+
"packages\build\FAKE\tools\Fake.exe" "build\\scripts\\Targets.fsx" "target=%TARGET%" "version=%VERSION%" "esversions=%ESVERSIONS%" "skiptests=%SKIPTESTS%" "apiKey=%APIKEY%" "feed=%FEED%" "escluster=%NEST_INTEGRATION_CLUSTER%"

build/scripts/Targets.fsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Target "TestForever" <| fun _ -> Tests.RunUnitTestsForever()
3535

3636
Target "QuickTest" <| fun _ -> Tests.RunUnitTests()
3737

38-
Target "Integrate" <| fun _ -> Tests.RunIntegrationTests() (getBuildParamOrDefault "esversions" "")
38+
Target "Integrate" <| fun _ -> Tests.RunIntegrationTests() (getBuildParamOrDefault "esversions" "") (getBuildParamOrDefault "escluster" "")
3939

4040
Target "Profile" <| fun _ -> Profiler.Run()
4141

build/scripts/Testing.fsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,13 @@ module Tests =
3737
testProjectJson "all"
3838

3939

40-
let RunIntegrationTests() commaSeparatedEsVersions =
40+
let RunIntegrationTests() commaSeparatedEsVersions clusterFilter =
4141
let esVersions =
4242
match commaSeparatedEsVersions with
4343
| "" -> failwith "when running integrate you have to pass a comma separated list of elasticsearch versions to test"
4444
| _ -> commaSeparatedEsVersions.Split ',' |> Array.toList
4545

4646
for esVersion in esVersions do
47+
setProcessEnvironVar "NEST_INTEGRATION_CLUSTER" clusterFilter
4748
setProcessEnvironVar "NEST_INTEGRATION_VERSION" esVersion
4849
testDesktopClr "all"

src/Tests/Framework/Configuration/EnvironmentConfiguration.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,18 @@ public class EnvironmentConfiguration : TestConfigurationBase
1212
public override bool TestAgainstAlreadyRunningElasticsearch { get; protected set; } = false;
1313
public override bool ForceReseed { get; protected set; } = true;
1414
public override ElasticsearchVersion ElasticsearchVersion { get; protected set; } = new ElasticsearchVersion("5.0.0");
15-
public override TestMode Mode { get; protected set; } = TestMode.Unit;
16-
15+
public override TestMode Mode { get; protected set; } = TestMode.Unit;
16+
public override string ClusterFilter { get; protected set; }
17+
1718
public EnvironmentConfiguration()
1819
{
1920
//if env var NEST_INTEGRATION_VERSION is set assume integration mode
2021
//used by the build script FAKE
2122
var version = Environment.GetEnvironmentVariable("NEST_INTEGRATION_VERSION");
22-
if (!string.IsNullOrEmpty(version)) Mode = TestMode.Integration;
23+
if (!string.IsNullOrEmpty(version)) Mode = TestMode.Integration;
2324

2425
this.ElasticsearchVersion = new ElasticsearchVersion(string.IsNullOrWhiteSpace(version) ? "5.0.0" : version);
26+
this.ClusterFilter = Environment.GetEnvironmentVariable("NEST_INTEGRATION_CLUSTER");
2527
}
2628
}
2729
}

src/Tests/Framework/Configuration/ITestConfiguration.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ namespace Tests.Framework.Configuration
1010
public interface ITestConfiguration
1111
{
1212
TestMode Mode { get; }
13-
ElasticsearchVersion ElasticsearchVersion { get; }
13+
ElasticsearchVersion ElasticsearchVersion { get; }
14+
string ClusterFilter { get; }
1415
bool ForceReseed { get; }
1516
bool TestAgainstAlreadyRunningElasticsearch { get; }
1617

src/Tests/Framework/Configuration/NodeConfiguration.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Linq;
23
using Tests.Framework.Configuration;
34
using Tests.Framework.Versions;
@@ -11,21 +12,23 @@ public class NodeConfiguration : ITestConfiguration
1112
public bool ForceReseed { get; }
1213
public bool TestAgainstAlreadyRunningElasticsearch { get; }
1314
public bool RunIntegrationTests { get; }
14-
public bool RunUnitTests { get; }
15+
public bool RunUnitTests { get; }
16+
public string ClusterFilter { get; }
1517

1618
public string TypeOfCluster { get; set; }
1719
public ElasticsearchPlugin[] RequiredPlugins { get; set; } = { };
1820

19-
public bool ShieldEnabled => this.RequiredPlugins.Contains(ElasticsearchPlugin.XPack);
20-
21+
public bool ShieldEnabled => this.RequiredPlugins.Contains(ElasticsearchPlugin.XPack);
22+
2123
public NodeConfiguration(ITestConfiguration configuration)
2224
{
2325
this.Mode = configuration.Mode;
2426
this.ElasticsearchVersion = configuration.ElasticsearchVersion;
2527
this.ForceReseed = configuration.ForceReseed;
2628
this.TestAgainstAlreadyRunningElasticsearch = configuration.TestAgainstAlreadyRunningElasticsearch;
2729
this.RunIntegrationTests = configuration.RunIntegrationTests;
28-
this.RunUnitTests = configuration.RunUnitTests;
30+
this.RunUnitTests = configuration.RunUnitTests;
31+
this.ClusterFilter = configuration.ClusterFilter;
2932
}
3033
}
3134
}

src/Tests/Framework/Configuration/TestConfigurationBase.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ public abstract class TestConfigurationBase : ITestConfiguration
1212
public abstract bool TestAgainstAlreadyRunningElasticsearch { get; protected set; }
1313
public abstract ElasticsearchVersion ElasticsearchVersion { get; protected set; }
1414
public abstract bool ForceReseed { get; protected set; }
15-
public abstract TestMode Mode { get; protected set; }
15+
public abstract TestMode Mode { get; protected set; }
16+
public abstract string ClusterFilter { get; protected set; }
1617

1718
public virtual bool RunIntegrationTests => Mode == TestMode.Mixed || Mode == TestMode.Integration;
1819
public virtual bool RunUnitTests => Mode == TestMode.Mixed || Mode == TestMode.Unit;

src/Tests/Framework/Configuration/YamlConfiguration.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ public class YamlConfiguration : TestConfigurationBase
1010
public override bool TestAgainstAlreadyRunningElasticsearch { get; protected set; } = true;
1111
public override ElasticsearchVersion ElasticsearchVersion { get; protected set; }
1212
public override bool ForceReseed { get; protected set; } = true;
13-
public override TestMode Mode { get; protected set; } = TestMode.Unit;
14-
13+
public override TestMode Mode { get; protected set; } = TestMode.Unit;
14+
public override string ClusterFilter { get; protected set; }
1515

1616
public YamlConfiguration(string configurationFile)
1717
{
@@ -25,6 +25,7 @@ public YamlConfiguration(string configurationFile)
2525
this.ElasticsearchVersion = new ElasticsearchVersion(config["elasticsearch_version"]);
2626
this.ForceReseed = bool.Parse(config["force_reseed"]);
2727
this.TestAgainstAlreadyRunningElasticsearch = bool.Parse(config["test_against_already_running_elasticsearch"]);
28+
this.ClusterFilter = config["cluster_filter"];
2829
}
2930

3031
private static string ConfigName(string configLine) => Parse(configLine, 0);

src/Tests/Framework/Xunit/TestAssemblyRunner.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,19 @@ orderby g.Count() descending
6464

6565
var summaries = new ConcurrentBag<RunSummary>();
6666
var clusterTotals = new Dictionary<string, Stopwatch>();
67+
var clusterFilter = TestClient.Configuration.ClusterFilter;
6768
foreach (var group in grouped)
6869
{
69-
//if (group.Key?.GetType() != typeof(WritableCluster)) continue;
7070
var type = group.Key?.GetType();
7171
var clusterName = type?.Name.Replace("Cluster", "") ?? "UNKNOWN";
72+
73+
if (!string.IsNullOrWhiteSpace(clusterFilter) && !string.Equals(clusterName, clusterFilter, StringComparison.InvariantCultureIgnoreCase))
74+
continue;
75+
7276
var dop = group.Key != null && group.Key.MaxConcurrency > 0
7377
? group.Key.MaxConcurrency
7478
: defaultMaxConcurrency;
7579

76-
//if (type != typeof(ReadOnlyCluster)) continue;
77-
7880
clusterTotals.Add(clusterName, Stopwatch.StartNew());
7981

8082
//We group over each cluster group and execute test classes pertaining to that cluster

src/Tests/Framework/Xunit/TestFramework.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Reflection;
33
using Tests.Framework;
4+
using Tests.Framework.Configuration;
45
using Xunit.Abstractions;
56
using Xunit.Sdk;
67

@@ -19,7 +20,9 @@ protected override ITestFrameworkExecutor CreateExecutor(AssemblyName assemblyNa
1920
Console.WriteLine($" - {nameof(config.TestAgainstAlreadyRunningElasticsearch)}: {config.TestAgainstAlreadyRunningElasticsearch}");
2021
Console.WriteLine($" - {nameof(config.ElasticsearchVersion)}: {config.ElasticsearchVersion}");
2122
Console.WriteLine($" - {nameof(config.ForceReseed)}: {config.ForceReseed}");
22-
Console.WriteLine($" - {nameof(config.Mode)}: {config.Mode.ToString()}");
23+
Console.WriteLine($" - {nameof(config.Mode)}: {config.Mode.ToString()}");
24+
if (config.Mode == TestMode.Integration)
25+
Console.WriteLine($" - {nameof(config.ClusterFilter)}: {config.ClusterFilter}");
2326
Console.WriteLine($" - {nameof(config.RunIntegrationTests)}: {config.RunIntegrationTests}");
2427
Console.WriteLine($" - {nameof(config.RunUnitTests)}: {config.RunUnitTests}");
2528

src/Tests/tests.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ mode: i
33
# the elasticsearch version that should be started
44
# Can be a snapshot version of sonatype or "latest" to get the latest snapshot of sonatype
55
elasticsearch_version: 5.0.1
6+
# cluster filter allows you to only run the integration tests of a particular cluster (cluster suffix not needed)
7+
cluster_filter:
68
# whether we want to forcefully reseed on the node, if you are starting the tests with a node already running
79
force_reseed: true
810
# do not spawn nodes as part of the test setup if we find a node is already running

0 commit comments

Comments
 (0)