Skip to content

Commit ba37577

Browse files
committed
move to xunit v3 for transport integration tests
1 parent 14e898d commit ba37577

File tree

12 files changed

+62
-96
lines changed

12 files changed

+62
-96
lines changed

tests/Elastic.Elasticsearch.IntegrationTests/Elastic.Elasticsearch.IntegrationTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<PrivateAssets>all</PrivateAssets>
1414
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1515
</PackageReference>
16-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
16+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
1717
<PackageReference Include="xunit" Version="2.9.3" />
1818
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
1919
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

tests/Elastic.Transport.IntegrationTests/Elastic.Transport.IntegrationTests.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
<PrivateAssets>all</PrivateAssets>
1313
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1414
</PackageReference>
15-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
16-
<PackageReference Include="Nullean.Xunit.Partitions" Version="0.10.0" />
17-
<PackageReference Include="xunit" Version="2.9.3" />
18-
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
15+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
16+
<PackageReference Include="xunit.v3" Version="3.2.0" />
17+
<PackageReference Include="xunit.v3.extensibility.core" Version="3.2.0" />
18+
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
1919
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2020
<PrivateAssets>all</PrivateAssets>
2121
</PackageReference>

tests/Elastic.Transport.IntegrationTests/Http/ApiCompatibilityHeaderTests.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@
1313

1414
namespace Elastic.Transport.IntegrationTests.Http;
1515

16-
public class ApiCompatibilityHeaderTests : AssemblyServerTestsBase
16+
public class ApiCompatibilityHeaderTests(TestServerFixture instance) : AssemblyServerTestsBase(instance)
1717
{
18-
public ApiCompatibilityHeaderTests(TransportTestServer instance) : base(instance) { }
19-
2018
[Fact]
2119
public async Task AddsExpectedVendorInformationForRestApiCompaitbility()
2220
{
@@ -38,7 +36,7 @@ public async Task AddsExpectedVendorInformationForRestApiCompaitbility()
3836
var config = new TransportConfiguration(nodePool, requestInvoker, productRegistration: new ElasticsearchProductRegistration(typeof(Clients.Elasticsearch.ElasticsearchClient)));
3937
var transport = new DistributedTransport(config);
4038

41-
var response = await transport.PostAsync<StringResponse>("/metaheader", PostData.String("{}"));
39+
var response = await transport.PostAsync<StringResponse>("/metaheader", PostData.String("{}"), cancellationToken: TestContext.Current.CancellationToken);
4240
}
4341
}
4442

tests/Elastic.Transport.IntegrationTests/Http/TransferEncodingChunckedTests.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class ChunkedController : ControllerBase
2323

2424
public class NonParallelCollection { }
2525
[CollectionDefinition(nameof(NonParallelCollection), DisableParallelization = true)]
26-
public class TransferEncodingChunkedTests(TransportTestServer instance) : AssemblyServerTestsBase(instance)
26+
public class TransferEncodingChunkedTests(TestServerFixture instance) : AssemblyServerTestsBase(instance)
2727
{
2828
private const string BodyString = "{\"query\":{\"match_all\":{}}}";
2929
private static readonly PostData Body = PostData.String(BodyString);
@@ -46,8 +46,7 @@ private ITransport Setup(
4646

4747
config = disableAutomaticProxyDetection.HasValue
4848
? config with { DisableAutomaticProxyDetection = disableAutomaticProxyDetection.Value }
49-
//make sure we the requests in debugging proxy
50-
: TransportTestServer.RerouteToProxyIfNeeded(config);
49+
: config;
5150

5251
return new DistributedTransport(config);
5352
}

tests/Elastic.Transport.IntegrationTests/OpenTelemetry/OpenTelemetryTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class OpenTelemetryTests : AssemblyServerTestsBase
2626
internal const string Cluster = "e9106fc68e3044f0b1475b04bf4ffd5f";
2727
internal const string Instance = "instance-0000000001";
2828

29-
public OpenTelemetryTests(TransportTestServer instance) : base(instance) { }
29+
public OpenTelemetryTests(TestServerFixture instance) : base(instance) { }
3030

3131
[Fact]
3232
public async Task ElasticsearchTagsShouldBeSet_WhenUsingTheElasticsearchRegistration()
@@ -57,7 +57,7 @@ public async Task ElasticsearchTagsShouldBeSet_WhenUsingTheElasticsearchRegistra
5757
};
5858
ActivitySource.AddActivityListener(listener);
5959

60-
_ = await transport.GetAsync<VoidResponse>("/opentelemetry");
60+
_ = await transport.GetAsync<VoidResponse>("/opentelemetry", cancellationToken: TestContext.Current.CancellationToken);
6161

6262
mre.WaitOne(TimeSpan.FromSeconds(1)).Should().BeTrue();
6363

tests/Elastic.Transport.IntegrationTests/Plumbing/AssemblyServerTestsBase.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,23 @@
22
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
33
// See the LICENSE file in the project root for more information
44

5-
using Nullean.Xunit.Partitions.Sdk;
5+
using Elastic.Transport.IntegrationTests.Plumbing;
6+
using Elastic.Transport.IntegrationTests.Plumbing.Examples;
67
using Xunit;
78

9+
[assembly: CaptureConsole, AssemblyFixture(typeof(TestServerFixture))]
10+
[assembly: AssemblyFixture(typeof(BufferedServerFixture))]
11+
812
namespace Elastic.Transport.IntegrationTests.Plumbing
913
{
1014
public class AssemblyServerTestsBase<TServer>(TServer instance)
11-
: IPartitionFixture<TServer>, IClassFixture<TServer> where TServer : class, HttpTransportTestServer, IPartitionLifetime
15+
: IClassFixture<TServer> where TServer : class, IHttpTransportTestServer
1216
{
1317
protected TServer Server { get; } = instance;
1418

1519
protected ITransport RequestHandler => Server.DefaultRequestHandler;
1620
}
1721

18-
public class AssemblyServerTestsBase(TransportTestServer instance)
19-
: AssemblyServerTestsBase<TransportTestServer>(instance);
22+
public class AssemblyServerTestsBase(TestServerFixture instance)
23+
: AssemblyServerTestsBase<TestServerFixture>(instance);
2024
}

tests/Elastic.Transport.IntegrationTests/Plumbing/ClassServerTestsBase.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
namespace Elastic.Transport.IntegrationTests.Plumbing
88
{
9-
public class ClassServerTestsBase<TServer>(TServer instance) : IClassFixture<TServer> where TServer : class, HttpTransportTestServer
9+
public class ClassServerTestsBase<TServer>(TServer instance)
10+
where TServer : class, IHttpTransportTestServer
1011
{
1112
protected TServer Server { get; } = instance;
1213

tests/Elastic.Transport.IntegrationTests/Plumbing/Examples/ControllerIntegrationTests.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,13 @@ namespace Elastic.Transport.IntegrationTests.Plumbing.Examples
1919
/// Tests that the test framework loads a controller and the exposed transport can talk to its endpoints.
2020
/// Tests runs against a server that started up once and its server instance shared among many test classes
2121
/// </summary>
22-
public class ControllerIntegrationTests : AssemblyServerTestsBase
22+
public class ControllerIntegrationTests(BufferedServerFixture instance)
23+
: AssemblyServerTestsBase<BufferedServerFixture>(instance)
2324
{
24-
public ControllerIntegrationTests(TransportTestServer instance) : base(instance) { }
25-
2625
[Fact]
2726
public async Task CanCallIntoController()
2827
{
29-
var response = await RequestHandler.GetAsync<StringResponse>("/dummy/20");
28+
var response = await RequestHandler.GetAsync<StringResponse>("/dummy/20", cancellationToken: TestContext.Current.CancellationToken);
3029
response.ApiCallDetails.HasSuccessfulStatusCode.Should().BeTrue("{0}", response.ApiCallDetails.DebugInformation);
3130
}
3231
}

tests/Elastic.Transport.IntegrationTests/Plumbing/Examples/EndpointIntegrationTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@ namespace Elastic.Transport.IntegrationTests.Plumbing.Examples
1717
/// Since it extends <see cref="ClassServerTestsBase{TServer}"/> it server is only shared between the tests inside this class.
1818
/// The server is also started and stopped after all the tests in this class run.
1919
/// </summary>
20-
public class EndpointIntegrationTests : ClassServerTestsBase<TransportTestServer<DummyStartup>>
20+
public class EndpointIntegrationTests(BufferedServerFixture instance)
21+
: ClassServerTestsBase<BufferedServerFixture>(instance)
2122
{
22-
public EndpointIntegrationTests(TransportTestServer<DummyStartup> instance) : base(instance) { }
23-
2423
[Fact]
2524
public async Task CanCallIntoEndpoint()
2625
{
27-
var response = await RequestHandler.GetAsync<StringResponse>(DummyStartup.Endpoint);
26+
var response = await RequestHandler.GetAsync<StringResponse>(BufferedStartup.Endpoint, cancellationToken: TestContext.Current.CancellationToken);
2827
response.ApiCallDetails.HasSuccessfulStatusCode.Should().BeTrue("{0}", response.ApiCallDetails.DebugInformation);
2928
}
3029
}
3130

32-
public class DummyStartup : DefaultStartup
31+
public class BufferedServerFixture : TransportTestServer<BufferedStartup>;
32+
public class BufferedStartup : DefaultStartup
3333
{
34-
public DummyStartup(IConfiguration configuration) : base(configuration) { }
34+
public BufferedStartup(IConfiguration configuration) : base(configuration) { }
3535

3636
public static string Endpoint { get; } = "buffered";
3737

tests/Elastic.Transport.IntegrationTests/Plumbing/Setup.cs

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)