|
1 | 1 | using System; |
2 | | -using System.Collections.Generic; |
3 | | -using Docker.Testify; |
4 | | -using Nest; |
| 2 | +using System.Threading.Tasks; |
| 3 | +using Squadron; |
5 | 4 | using Xunit; |
6 | 5 |
|
7 | 6 | namespace WorkflowCore.Tests.Elasticsearch |
8 | 7 | { |
9 | | - public class ElasticsearchDockerSetup : DockerSetup |
| 8 | + public class ElasticsearchDockerSetup : IAsyncLifetime |
10 | 9 | { |
| 10 | + private readonly ElasticsearchResource _elasticsearchResource; |
11 | 11 | public static string ConnectionString { get; set; } |
12 | | - |
13 | | - public override string ImageName => @"elasticsearch"; |
14 | | - public override string ImageTag => "7.5.1"; |
15 | | - public override int InternalPort => 9200; |
16 | | - public override TimeSpan TimeOut => TimeSpan.FromSeconds(30); |
17 | | - |
18 | | - public override IList<string> EnvironmentVariables => new List<string> { |
19 | | - $"discovery.type=single-node" |
20 | | - }; |
21 | 12 |
|
22 | | - public override void PublishConnectionInfo() |
| 13 | + public ElasticsearchDockerSetup() |
23 | 14 | { |
24 | | - ConnectionString = $"http://localhost:{ExternalPort}"; |
| 15 | + _elasticsearchResource = new ElasticsearchResource(); |
25 | 16 | } |
26 | 17 |
|
27 | | - public override bool TestReady() |
| 18 | + public async Task InitializeAsync() |
28 | 19 | { |
29 | | - try |
30 | | - { |
31 | | - var client = new ElasticClient(new ConnectionSettings(new Uri($"http://localhost:{ExternalPort}"))); |
32 | | - var ping = client.Ping(); |
33 | | - return ping.IsValid; |
34 | | - } |
35 | | - catch |
36 | | - { |
37 | | - return false; |
38 | | - } |
| 20 | + await _elasticsearchResource.InitializeAsync(); |
| 21 | + ConnectionString = $"http://localhost:{_elasticsearchResource.Instance.HostPort}"; |
| 22 | + } |
39 | 23 |
|
| 24 | + public Task DisposeAsync() |
| 25 | + { |
| 26 | + return _elasticsearchResource.DisposeAsync(); |
40 | 27 | } |
41 | 28 | } |
42 | 29 |
|
|
0 commit comments