Skip to content

Commit c8f2b38

Browse files
authored
Bump testing abstraction and fix cluster run command (#5330)
1 parent c5bdafb commit c8f2b38

File tree

8 files changed

+20
-12
lines changed

8 files changed

+20
-12
lines changed

build/scripts/Paths.fs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ module Paths =
1818

1919
let InplaceBuildOutput project tfm =
2020
sprintf "src/%s/bin/Release/%s" project tfm
21+
let InplaceBuildTestOutput project tfm =
22+
sprintf "tests/%s/bin/Release/%s" project tfm
2123
let MagicDocumentationFile =
2224
"src/Elasticsearch.Net/obj/Release/netstandard2.1/Elasticsearch.Net.csprojAssemblyReference.cache"
2325

build/scripts/ReposTooling.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module ReposTooling =
1515
let clusterName = Option.defaultValue "" <| match args.CommandArguments with | Cluster c -> Some c.Name | _ -> None
1616
let clusterVersion = Option.defaultValue "" <|match args.CommandArguments with | Cluster c -> c.Version | _ -> None
1717

18-
let testsProjectDirectory = Path.Combine(Path.GetFullPath(Paths.Output("Tests.ClusterLauncher")), "net5.0")
18+
let testsProjectDirectory = Path.GetFullPath(Paths.InplaceBuildTestOutput "Tests.ClusterLauncher" "net5.0")
1919
let tempDir = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
2020

2121
printfn "%s" testsProjectDirectory

build/scripts/scripts.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<PackageReference Include="FSharp.Core" Version="5.0.0" />
3939

4040
<PackageReference Include="Bullseye" Version="3.3.0" />
41-
<PackageReference Include="Elastic.Elasticsearch.Managed" Version="0.1.0-canary.0.244" />
41+
<PackageReference Include="Elastic.Elasticsearch.Managed" Version="0.2.5" />
4242

4343
<PackageReference Include="Fake.Core.Environment" Version="5.15.0" />
4444
<PackageReference Include="Fake.Core.SemVer" Version="5.15.0" />

nuget.config

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<packageSources>
4-
<add key="Elastic Abstractions CI" value="https://ci.appveyor.com/nuget/elasticsearch-net-abstractions" />
54
<add key="Versioned Clients" value="https://ci.appveyor.com/nuget/elasticsearch-net" />
65
</packageSources>
76
</configuration>

tests/Tests.ClusterLauncher/ClusterLaunchProgram.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ public static int Main(string[] arguments)
3838
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("NEST_YAML_FILE")))
3939
{
4040
// build always sets previous argument, assume we are running from the IDE or dotnet run
41-
var yamlFile = TestConfiguration.LocateTestYamlFile();
42-
Environment.SetEnvironmentVariable("NEST_YAML_FILE", yamlFile, EnvironmentVariableTarget.Process);
41+
var yamlFile = TestConfiguration.LocateTestYamlFile();
42+
Environment.SetEnvironmentVariable("NEST_YAML_FILE", yamlFile, EnvironmentVariableTarget.Process);
4343
}
4444

4545
// if version is passed this will take precedence over the version in the yaml file
@@ -61,12 +61,19 @@ public static int Main(string[] arguments)
6161
AppDomain.CurrentDomain.ProcessExit += (s, ev) => Instance?.Dispose();
6262
Console.CancelKeyPress += (s, ev) => Instance?.Dispose();
6363

64-
if (!TryStartClientTestClusterBaseImplementation(cluster) && !TryStartXPackClusterImplementation(cluster))
64+
try
6565
{
66+
if (TryStartClientTestClusterBaseImplementation(cluster) || TryStartXPackClusterImplementation(cluster)) return 0;
67+
6668
Console.Error.WriteLine($"Could not create an instance of '{cluster.FullName}");
6769
return 1;
6870
}
69-
return 0;
71+
catch (Exception e)
72+
{
73+
Console.WriteLine(e);
74+
Instance?.Dispose();
75+
throw;
76+
}
7077
}
7178

7279
private static bool TryStartXPackClusterImplementation(Type cluster)
@@ -91,7 +98,7 @@ private static bool TryStartClientTestClusterBaseImplementation(Type cluster)
9198
private static bool Run(ICluster<EphemeralClusterConfiguration> instance)
9299
{
93100
TestConfiguration.Instance.DumpConfiguration();
94-
instance.Start();
101+
using var start = instance.Start();
95102
if (!instance.Started)
96103
{
97104
Console.Error.WriteLine($"Failed to start cluster: '{instance.GetType().FullName}");
@@ -118,7 +125,7 @@ private static Type[] GetClusters()
118125

119126
return types
120127
.Where(t => t.Implements(typeof(IEphemeralCluster)))
121-
.Where(t=> !t.IsAbstract)
128+
.Where(t => !t.IsAbstract)
122129
.ToArray();
123130
}
124131
}

tests/Tests.Configuration/Tests.Configuration.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
<TargetFramework>netstandard2.0</TargetFramework>
44
</PropertyGroup>
55
<ItemGroup>
6-
<PackageReference Include="Elastic.Elasticsearch.Managed" Version="0.1.0-canary.0.244" />
6+
<PackageReference Include="Elastic.Elasticsearch.Managed" Version="0.2.5" />
77
</ItemGroup>
88
</Project>

tests/Tests.Core/Tests.Core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
<PackageReference Include="xunit" Version="2.3.1" />
1818
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
19-
<PackageReference Include="Elastic.Elasticsearch.Xunit" Version="0.1.0-canary.0.244" />
19+
<PackageReference Include="Elastic.Elasticsearch.Xunit" Version="0.2.5" />
2020

2121
<PackageReference Include="Nullean.VsTest.Pretty.TestLogger" Version="0.3.0" />
2222
<PackageReference Include="coverlet.collector" Version="1.1.0" />

tests/Tests.Domain/Tests.Domain.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</ItemGroup>
1212
<ItemGroup>
1313
<PackageReference Include="Bogus" Version="22.1.2" />
14-
<PackageReference Include="Elastic.Elasticsearch.Managed" Version="0.1.0-canary.0.244" />
14+
<PackageReference Include="Elastic.Elasticsearch.Managed" Version="0.2.5" />
1515
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
1616
<ProjectReference Include="$(SolutionRoot)\tests\Tests.Configuration\Tests.Configuration.csproj" />
1717
</ItemGroup>

0 commit comments

Comments
 (0)