Skip to content

Commit dc2afc0

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
Conflicts: src/Tests/Framework/Configuration/EnvironmentConfiguration.cs src/Tests/Framework/Configuration/ITestConfiguration.cs src/Tests/Framework/Configuration/NodeConfiguration.cs src/Tests/Framework/Configuration/TestConfigurationBase.cs src/Tests/Framework/Configuration/YamlConfiguration.cs src/Tests/Framework/Xunit/TestAssemblyRunner.cs src/Tests/tests.yaml
1 parent ec24028 commit dc2afc0

File tree

10 files changed

+28
-14
lines changed

10 files changed

+28
-14
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
@@ -29,7 +29,7 @@ Target "Test" <| fun _ -> Tests.RunUnitTests()
2929

3030
Target "QuickTest" <| fun _ -> Tests.RunUnitTests()
3131

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

3434
Target "Profile" <| fun _ -> Profiler.Run()
3535

build/scripts/Testing.fsx

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

2929

30-
let RunIntegrationTests() commaSeparatedEsVersions =
30+
let RunIntegrationTests() commaSeparatedEsVersions clusterFilter =
3131
let esVersions =
3232
match commaSeparatedEsVersions with
3333
| "" -> failwith "when running integrate you have to pass a comma separated list of elasticsearch versions to test"
3434
| _ -> commaSeparatedEsVersions.Split ',' |> Array.toList
3535

3636
for esVersion in esVersions do
37+
setProcessEnvironVar "NEST_INTEGRATION_CLUSTER" clusterFilter
3738
setProcessEnvironVar "NEST_INTEGRATION_VERSION" esVersion
3839
testDesktopClr "all"

src/Tests/Framework/Configuration/EnvironmentConfiguration.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public class EnvironmentConfiguration : TestConfigurationBase
1212
public override bool ForceReseed { get; protected set; } = true;
1313
public override string ElasticsearchVersion { get; protected set; }
1414
public override TestMode Mode { get; protected set; } = TestMode.Unit;
15+
public override string ClusterFilter { get; protected set; }
1516

1617
public EnvironmentConfiguration()
1718
{
@@ -20,6 +21,7 @@ public EnvironmentConfiguration()
2021
this.ElasticsearchVersion = Environment.GetEnvironmentVariable("NEST_INTEGRATION_VERSION");
2122
if (!string.IsNullOrEmpty(ElasticsearchVersion))
2223
Mode = TestMode.Integration;
24+
this.ClusterFilter = Environment.GetEnvironmentVariable("NEST_INTEGRATION_CLUSTER");
2325
}
2426
}
2527
}

src/Tests/Framework/Configuration/ITestConfiguration.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public interface ITestConfiguration
1010
{
1111
TestMode Mode { get; }
1212
string ElasticsearchVersion { get; }
13+
string ClusterFilter { get; }
1314
bool ForceReseed { get; }
1415
bool DoNotSpawnIfAlreadyRunning { get; }
1516

src/Tests/Framework/Configuration/TestConfigurationBase.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public abstract class TestConfigurationBase : ITestConfiguration
1212
public abstract string ElasticsearchVersion { get; protected set; }
1313
public abstract bool ForceReseed { get; protected set; }
1414
public abstract TestMode Mode { get; protected set; }
15+
public abstract string ClusterFilter { get; protected set; }
1516

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

src/Tests/Framework/Configuration/YamlConfiguration.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class YamlConfiguration : TestConfigurationBase
1010
public override string ElasticsearchVersion { get; protected set; } = "2.0.0";
1111
public override bool ForceReseed { get; protected set; } = true;
1212
public override TestMode Mode { get; protected set; } = TestMode.Unit;
13-
13+
public override string ClusterFilter { get; protected set; }
1414

1515
public YamlConfiguration(string configurationFile)
1616
{
@@ -24,6 +24,7 @@ public YamlConfiguration(string configurationFile)
2424
this.ElasticsearchVersion = config["elasticsearch_version"];
2525
this.ForceReseed = bool.Parse(config["force_reseed"]);
2626
this.DoNotSpawnIfAlreadyRunning = bool.Parse(config["do_not_spawn"]);
27+
this.ClusterFilter = config["cluster_filter"];
2728
}
2829

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

src/Tests/Framework/Xunit/TestAssemblyRunner.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,18 @@ 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
{
6970
var type = group.Key?.GetType();
7071
var clusterName = type?.Name.Replace("Cluster", "") ?? "UNKNOWN";
71-
var dop = group.Key != null && group.Key.MaxConcurrency > 0
72-
? group.Key.MaxConcurrency
73-
: defaultMaxConcurrency;
7472

75-
//if (type != typeof(ReadOnlyCluster)) continue;
73+
if (!string.IsNullOrWhiteSpace(clusterFilter) && !string.Equals(clusterName, clusterFilter, StringComparison.InvariantCultureIgnoreCase))
74+
continue;
75+
76+
var dop = group.Key != null && group.Key.MaxConcurrency > 0
77+
? group.Key.MaxConcurrency
78+
: defaultMaxConcurrency;
7679

7780
clusterTotals.Add(clusterName, Stopwatch.StartNew());
7881

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.DoNotSpawnIfAlreadyRunning)}: {config.DoNotSpawnIfAlreadyRunning}");
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
@@ -2,6 +2,8 @@
22
mode: m
33
# the elasticsearch version that should be started
44
elasticsearch_version: 2.4.1
5+
# cluster filter allows you to only run the integration tests of a particular cluster (cluster suffix not needed)
6+
cluster_filter:
57
# whether we want to forcefully reseed on the node, if you are starting the tests with a node already running
68
force_reseed: true
79
# do not spawn nodes as part of the test setup but rely on a manually started es node being up

0 commit comments

Comments
 (0)