diff --git a/src/Tests/Cat/CatRepositories/CatRepositoriesApiTests.cs b/src/Tests/Cat/CatRepositories/CatRepositoriesApiTests.cs index 6332445debb..97bb65164ed 100644 --- a/src/Tests/Cat/CatRepositories/CatRepositoriesApiTests.cs +++ b/src/Tests/Cat/CatRepositories/CatRepositoriesApiTests.cs @@ -17,10 +17,10 @@ public class CatRepositoriesApiTests : ApiIntegrationTestBase values) + protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { if (!TestClient.Configuration.RunIntegrationTests) return; - var repositoryLocation = Path.Combine(this._cluster.Node.RepositoryPath, RandomString()); + var repositoryLocation = Path.Combine(this.Cluster.Node.RepositoryPath, RandomString()); var create = this.Client.CreateRepository(RepositoryName, cr => cr .FileSystem(fs => fs diff --git a/src/Tests/Cat/CatSnapshots/CatSnapshotsApiTests.cs b/src/Tests/Cat/CatSnapshots/CatSnapshotsApiTests.cs index f2b3c046e0b..00165e3be75 100644 --- a/src/Tests/Cat/CatSnapshots/CatSnapshotsApiTests.cs +++ b/src/Tests/Cat/CatSnapshots/CatSnapshotsApiTests.cs @@ -19,10 +19,10 @@ public class CatSnapshotsApiTests : ApiIntegrationTestBase values) + protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { if (!TestClient.Configuration.RunIntegrationTests) return; - var repositoryLocation = Path.Combine(this._cluster.Node.RepositoryPath, RandomString()); + var repositoryLocation = Path.Combine(this.Cluster.Node.RepositoryPath, RandomString()); var create = this.Client.CreateRepository(RepositoryName, cr => cr .FileSystem(fs => fs diff --git a/src/Tests/Cluster/TaskManagement/TasksCancel/TasksCancelApiTests.cs b/src/Tests/Cluster/TaskManagement/TasksCancel/TasksCancelApiTests.cs index da6c4020350..671e62058a9 100644 --- a/src/Tests/Cluster/TaskManagement/TasksCancel/TasksCancelApiTests.cs +++ b/src/Tests/Cluster/TaskManagement/TasksCancel/TasksCancelApiTests.cs @@ -10,11 +10,12 @@ namespace Tests.Cluster.TaskManagement.TasksCancel { - // TODO Unit tests will fail in mixed mode because SetupTaskIds isn't setup [Collection(IntegrationContext.OwnIndex)] public class TasksCancelApiTests : ApiIntegrationTestBase { - public class Test + private TaskId TaskId => this.RanIntegrationSetup ? this.ExtendedValue("taskId") : "foo:1"; + + private class Test { public long Id { get; set; } public string Flag { get; set; } @@ -22,17 +23,18 @@ public class Test public TasksCancelApiTests(OwnIndexCluster cluster, EndpointUsage usage) : base(cluster, usage) { } - protected IDictionary SetupTaskIds { get; } = new Dictionary(); - - protected override void BeforeAllCalls(IElasticClient client, IDictionary values) + protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { foreach (var index in values.Values) { client.IndexMany(Enumerable.Range(0, 10000).Select(i => new Test { Id = i + 1, Flag = "bar" }), index); client.Refresh(index); } - foreach (var index in values.Values) + foreach (var view in values.Views) { + values.CurrentView = view; + var index = values.Value; + var reindex = client.ReindexOnServer(r => r .Source(s => s.Index(index)) .Destination(s => s.Index($"{index}-clone")) @@ -42,7 +44,7 @@ protected override void BeforeAllCalls(IElasticClient client, IDictionary Calls( @@ -58,20 +60,18 @@ protected override LazyResponses ClientUsage() => Calls( protected override string UrlPath => $"/_tasks/{Uri.EscapeDataString(this.TaskId.ToString())}/_cancel"; protected override bool SupportsDeserialization => false; - private TaskId TaskId => TestClient.Configuration.RunIntegrationTests ? this.SetupTaskIds[CallIsolatedValue] : "foo:1"; protected override Func Fluent => d => d .TaskId(this.TaskId); protected override TasksCancelRequest Initializer => new TasksCancelRequest(this.TaskId); - // TODO this test is flaky, sometimes SetupTaskIds is empty protected override void ExpectResponse(ITasksCancelResponse response) { response.NodeFailures.Should().BeNullOrEmpty(); response.Nodes.Should().NotBeEmpty(); var tasks = response.Nodes.First().Value.Tasks; - tasks.Should().NotBeEmpty().And.ContainKey(this.SetupTaskIds[CallIsolatedValue]); + tasks.Should().NotBeEmpty().And.ContainKey(this.TaskId); } } } diff --git a/src/Tests/Document/Multiple/DeleteByQuery/DeleteByQueryApiTests.cs b/src/Tests/Document/Multiple/DeleteByQuery/DeleteByQueryApiTests.cs index 3e3785561ae..f594349a449 100644 --- a/src/Tests/Document/Multiple/DeleteByQuery/DeleteByQueryApiTests.cs +++ b/src/Tests/Document/Multiple/DeleteByQuery/DeleteByQueryApiTests.cs @@ -17,7 +17,7 @@ public class DeleteByQueryApiTests : ApiIntegrationTestBase values) + protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { foreach (var index in values.Values) { @@ -44,7 +44,7 @@ protected override LazyResponses ClientUsage() => Calls( protected override bool SupportsDeserialization => false; - protected override object ExpectJson { get; } = new + protected override object ExpectJson { get; } = new { query = new { @@ -66,7 +66,7 @@ protected override LazyResponses ClientUsage() => Calls( .Values(Project.Projects.First().Name, "x") ) ); - + protected override DeleteByQueryRequest Initializer => new DeleteByQueryRequest(this.Indices) { IgnoreUnavailable = true, diff --git a/src/Tests/Document/Multiple/ReindexOnServer/ReindexOnServerApiTests.cs b/src/Tests/Document/Multiple/ReindexOnServer/ReindexOnServerApiTests.cs index ae32c82884a..5bbf9476f3b 100644 --- a/src/Tests/Document/Multiple/ReindexOnServer/ReindexOnServerApiTests.cs +++ b/src/Tests/Document/Multiple/ReindexOnServer/ReindexOnServerApiTests.cs @@ -23,7 +23,7 @@ public class Test public ReindexOnServerApiTests(OwnIndexCluster cluster, EndpointUsage usage) : base(cluster, usage) { } - protected override void BeforeAllCalls(IElasticClient client, IDictionary values) + protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { foreach (var index in values.Values) { diff --git a/src/Tests/Document/Multiple/UpdateByQuery/UpdateByQueryApiTests.cs b/src/Tests/Document/Multiple/UpdateByQuery/UpdateByQueryApiTests.cs index a8f7230885f..f98577a2ebb 100644 --- a/src/Tests/Document/Multiple/UpdateByQuery/UpdateByQueryApiTests.cs +++ b/src/Tests/Document/Multiple/UpdateByQuery/UpdateByQueryApiTests.cs @@ -23,7 +23,7 @@ public class Test public UpdateByQueryApiTests(OwnIndexCluster cluster, EndpointUsage usage) : base(cluster, usage) { } - protected override void BeforeAllCalls(IElasticClient client, IDictionary values) + protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { foreach (var index in values.Values) { @@ -131,7 +131,7 @@ public class UpdateByQueryWithFailuresApiTests : UpdateByQueryApiTests { public UpdateByQueryWithFailuresApiTests(OwnIndexCluster cluster, EndpointUsage usage) : base(cluster, usage) { } - protected override void BeforeAllCalls(IElasticClient client, IDictionary values) + protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { foreach (var index in values.Values) { diff --git a/src/Tests/Document/Single/Delete/DeleteApiTests.cs b/src/Tests/Document/Single/Delete/DeleteApiTests.cs index ffb6a36612d..d687ec6eca1 100644 --- a/src/Tests/Document/Single/Delete/DeleteApiTests.cs +++ b/src/Tests/Document/Single/Delete/DeleteApiTests.cs @@ -14,7 +14,7 @@ public class DeleteApiTests : ApiIntegrationTestBase values) + protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { foreach (var id in values.Values) this.Client.Index(Project.Instance, i=>i.Id(id)); diff --git a/src/Tests/Document/Single/Exists/DocumentExistsApiTests.cs b/src/Tests/Document/Single/Exists/DocumentExistsApiTests.cs index cd24b461bb1..b29d92118cb 100644 --- a/src/Tests/Document/Single/Exists/DocumentExistsApiTests.cs +++ b/src/Tests/Document/Single/Exists/DocumentExistsApiTests.cs @@ -14,7 +14,7 @@ public class DocumentExistsApiTests : ApiIntegrationTestBase values) + protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { foreach (var id in values.Values) this.Client.Index(Project.Instance, i=>i.Id(id)); diff --git a/src/Tests/Document/Single/Update/UpdateApiTests.cs b/src/Tests/Document/Single/Update/UpdateApiTests.cs index fc71b21b602..48a52f516e1 100644 --- a/src/Tests/Document/Single/Update/UpdateApiTests.cs +++ b/src/Tests/Document/Single/Update/UpdateApiTests.cs @@ -14,7 +14,7 @@ public class UpdateApiTests : ApiIntegrationTestBase, I { public UpdateApiTests(IndexingCluster cluster, EndpointUsage usage) : base(cluster, usage) { } - protected override void BeforeAllCalls(IElasticClient client, IDictionary values) + protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { foreach (var id in values.Values) this.Client.Index(Project.Instance, i=>i.Id(id)); diff --git a/src/Tests/Document/Single/Update/UpdateWithSourceApiTests.cs b/src/Tests/Document/Single/Update/UpdateWithSourceApiTests.cs index 49efe0f075b..9f40f610480 100644 --- a/src/Tests/Document/Single/Update/UpdateWithSourceApiTests.cs +++ b/src/Tests/Document/Single/Update/UpdateWithSourceApiTests.cs @@ -18,7 +18,7 @@ public class UpdateWithSourceApiTests : ApiIntegrationTestBase values) + protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { foreach (var id in values.Values) this.Client.Index(Project.Instance, i=>i.Id(id)); diff --git a/src/Tests/Framework/ApiIntegrationTestBase.cs b/src/Tests/Framework/ApiIntegrationTestBase.cs index 16b943911bb..d63a35acb7e 100644 --- a/src/Tests/Framework/ApiIntegrationTestBase.cs +++ b/src/Tests/Framework/ApiIntegrationTestBase.cs @@ -8,7 +8,7 @@ namespace Tests.Framework { - public abstract class ApiIntegrationTestBase + public abstract class ApiIntegrationTestBase : ApiTestBase where TResponse : class, IResponse where TDescriptor : class, TInterface @@ -29,8 +29,7 @@ [I] protected async Task HandlesStatusCode() => [I] protected async Task ReturnsExpectedIsValid() => await this.AssertOnAllResponses(r=>r.IsValid.Should().Be(this.ExpectIsValid)); - [I] protected async Task ReturnsExpectedResponse() => - await this.AssertOnAllResponses(r => ExpectResponse(r)); + [I] protected async Task ReturnsExpectedResponse() => await this.AssertOnAllResponses(ExpectResponse); protected override Task AssertOnAllResponses(Action assert) { diff --git a/src/Tests/Framework/ApiTestBase.cs b/src/Tests/Framework/ApiTestBase.cs index 61fd2a2c5b0..3f3fbed01ad 100644 --- a/src/Tests/Framework/ApiTestBase.cs +++ b/src/Tests/Framework/ApiTestBase.cs @@ -16,72 +16,95 @@ public abstract class ApiTestBase Guid.NewGuid().ToString("N").Substring(0, 8); - protected virtual ConnectionSettings GetConnectionSettings(ConnectionSettings settings) => settings; - protected virtual IElasticClient Client => this._cluster.Client(GetConnectionSettings); + protected bool RanIntegrationSetup => this._usage?.CalledSetup ?? false; + + protected IIntegrationCluster Cluster { get; } - protected IDictionary UniqueValues { get; } - protected string CallIsolatedValue { get; private set; } + protected string CallIsolatedValue => _uniqueValues.Value; + protected T ExtendedValue(string key) where T : class => this._uniqueValues.ExtendedValue(key); - protected virtual void BeforeAllCalls(IElasticClient client, IDictionary values) { } + protected virtual void IntegrationSetup(IElasticClient client, CallUniqueValues values) { } protected virtual void OnBeforeCall(IElasticClient client) { } protected virtual void OnAfterCall(IElasticClient client) { } - protected virtual int Port { get; set; } = 9200; + protected IElasticClient Client => this.Cluster.Client(GetConnectionSettings); + protected virtual ConnectionSettings GetConnectionSettings(ConnectionSettings settings) => settings; - protected virtual TInitializer Initializer { get; } + protected virtual TDescriptor NewDescriptor() => Activator.CreateInstance(); protected virtual Func Fluent { get; } + protected virtual TInitializer Initializer { get; } - protected virtual TDescriptor ClientDoesThisInternally(TDescriptor d) => d; protected abstract LazyResponses ClientUsage(); - protected virtual TDescriptor NewDescriptor() => Activator.CreateInstance(); - protected abstract string UrlPath { get; } protected abstract HttpMethod HttpMethod { get; } protected ApiTestBase(IIntegrationCluster cluster, EndpointUsage usage) { - this._cluster = cluster; + this._usage = usage; + this.Cluster = cluster; + this._responses = usage.CallOnce(this.ClientUsage); - this.Port = cluster.Node.Port; - this.UniqueValues = usage.CallUniqueValues; - this.CallIsolatedValue = UniqueValues[Integration.ClientMethod.Fluent]; + this._port = cluster.Node.Port; + this._uniqueValues = usage.CallUniqueValues; this.SetupSerialization(); } - protected virtual LazyResponses Calls( + [U] protected async Task HitsTheCorrectUrl() => + await this.AssertOnAllResponses(r => this.AssertUrl(r.ApiCall.Uri)); + + [U] protected async Task UsesCorrectHttpMethod() => + await this.AssertOnAllResponses(r => r.CallDetails.HttpMethod.Should().Be(this.HttpMethod)); + + [U] protected void SerializesInitializer() => + this.AssertSerializesAndRoundTrips(this.Initializer); + + [U] protected void SerializesFluent() => + this.AssertSerializesAndRoundTrips(this.Fluent?.Invoke(NewDescriptor())); + + protected LazyResponses Calls( Func, TResponse> fluent, Func, Task> fluentAsync, Func request, Func> requestAsync ) { + //this client is outside the lambda so that the callstack is one where we can get the method name + //of the current running test and send that as a header, great for e.g fiddler to relate requests with the test that sent it var client = this.Client; return new LazyResponses(async () => { - this.BeforeAllCalls(client, UniqueValues); + if (TestClient.Configuration.RunIntegrationTests) + { + this.IntegrationSetup(client, _uniqueValues); + } + + this._usage.CalledSetup = true; var dict = new Dictionary(); - this.CallIsolatedValue = UniqueValues[ClientMethod.Fluent]; + _uniqueValues.CurrentView = ClientMethod.Fluent; + OnBeforeCall(client); dict.Add(ClientMethod.Fluent, fluent(client, this.Fluent)); OnAfterCall(client); - this.CallIsolatedValue = UniqueValues[ClientMethod.FluentAsync]; + _uniqueValues.CurrentView = ClientMethod.FluentAsync; OnBeforeCall(client); dict.Add(ClientMethod.FluentAsync, await fluentAsync(client, this.Fluent)); OnAfterCall(client); - this.CallIsolatedValue = UniqueValues[ClientMethod.Initializer]; + _uniqueValues.CurrentView = ClientMethod.Initializer; OnBeforeCall(client); dict.Add(ClientMethod.Initializer, request(client, this.Initializer)); OnAfterCall(client); - this.CallIsolatedValue = UniqueValues[ClientMethod.InitializerAsync]; + _uniqueValues.CurrentView = ClientMethod.InitializerAsync; OnBeforeCall(client); dict.Add(ClientMethod.InitializerAsync, await requestAsync(client, this.Initializer)); OnAfterCall(client); @@ -89,14 +112,14 @@ Func> requestAsync }); } - protected virtual void AssertUrl(Uri u) + private void AssertUrl(Uri u) { var paths = (this.UrlPath ?? "").Split(new[] { '?' }, 2); string path = paths.First(), query = string.Empty; if (paths.Length > 1) query = paths.Last(); - var expectedUri = new UriBuilder("http", "localhost", Port, path, "?" + query).Uri; + var expectedUri = new UriBuilder("http", "localhost", this._port, path, "?" + query).Uri; u.AbsolutePath.Should().Be(expectedUri.AbsolutePath); u = new UriBuilder(u.Scheme, u.Host, u.Port, u.AbsolutePath, u.Query.Replace("pretty=true&", "").Replace("pretty=true", "")).Uri; @@ -131,7 +154,7 @@ protected virtual async Task AssertOnAllResponses(Action assert) var response = kv.Value as TResponse; try { - this.CallIsolatedValue = UniqueValues[kv.Key]; + this._uniqueValues.CurrentView = kv.Key; assert(response); } #pragma warning disable 7095 //enable this if you expect a single overload to act up @@ -143,16 +166,5 @@ protected virtual async Task AssertOnAllResponses(Action assert) } } - [U] protected async Task HitsTheCorrectUrl() => - await this.AssertOnAllResponses(r => this.AssertUrl(r.ApiCall.Uri)); - - [U] protected async Task UsesCorrectHttpMethod() => - await this.AssertOnAllResponses(r => r.CallDetails.HttpMethod.Should().Be(this.HttpMethod)); - - [U] protected void SerializesInitializer() => - this.AssertSerializesAndRoundTrips(this.Initializer); - - [U] protected void SerializesFluent() => - this.AssertSerializesAndRoundTrips(this.Fluent?.Invoke(this.ClientDoesThisInternally(NewDescriptor()))); } } diff --git a/src/Tests/Framework/AsyncLazy.cs b/src/Tests/Framework/AsyncLazy.cs index 41e349102eb..37548dfea91 100644 --- a/src/Tests/Framework/AsyncLazy.cs +++ b/src/Tests/Framework/AsyncLazy.cs @@ -61,4 +61,4 @@ public LazyResponses(Func> facto public LazyResponses(Func>> factory) : base(factory) { } } -} \ No newline at end of file +} diff --git a/src/Tests/Framework/Integration/CallUniqueValues.cs b/src/Tests/Framework/Integration/CallUniqueValues.cs new file mode 100644 index 00000000000..e702b231553 --- /dev/null +++ b/src/Tests/Framework/Integration/CallUniqueValues.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; + +namespace Tests.Framework.Integration +{ + public class CallUniqueValues : Dictionary + { + private string UniqueValue => "nest-" + Guid.NewGuid().ToString("N").Substring(0, 8); + + private IDictionary> ExtendedValues { get; } + = new Dictionary>(); + + public ClientMethod CurrentView { get; set; } = ClientMethod.Fluent; + public ClientMethod[] Views { get; } = new[] { ClientMethod.Fluent, ClientMethod.FluentAsync, ClientMethod.Initializer, ClientMethod.InitializerAsync }; + + public string Value => this[CurrentView]; + public T ExtendedValue(string key) where T : class => this.ExtendedValues[CurrentView][key] as T; + public void ExtendedValue(string key, T value) where T : class => this.ExtendedValues[CurrentView][key] = value; + + public CallUniqueValues() + { + this.Add(ClientMethod.Fluent, this.UniqueValue); + this.Add(ClientMethod.FluentAsync, this.UniqueValue); + this.Add(ClientMethod.Initializer, this.UniqueValue); + this.Add(ClientMethod.InitializerAsync, this.UniqueValue); + + this.ExtendedValues.Add(ClientMethod.Fluent, new Dictionary()); + this.ExtendedValues.Add(ClientMethod.FluentAsync, new Dictionary()); + this.ExtendedValues.Add(ClientMethod.Initializer, new Dictionary()); + this.ExtendedValues.Add(ClientMethod.InitializerAsync, new Dictionary()); + } + } +} \ No newline at end of file diff --git a/src/Tests/Framework/Integration/ClientMethod.cs b/src/Tests/Framework/Integration/ClientMethod.cs new file mode 100644 index 00000000000..ace1230ee34 --- /dev/null +++ b/src/Tests/Framework/Integration/ClientMethod.cs @@ -0,0 +1,10 @@ +namespace Tests.Framework.Integration +{ + public enum ClientMethod + { + Fluent, + FluentAsync, + Initializer, + InitializerAsync + } +} diff --git a/src/Tests/Framework/Integration/EndpointUsage.cs b/src/Tests/Framework/Integration/EndpointUsage.cs index 45f46f9c50d..a0b08036fef 100644 --- a/src/Tests/Framework/Integration/EndpointUsage.cs +++ b/src/Tests/Framework/Integration/EndpointUsage.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Concurrent; -using System.Collections.Generic; -using static Tests.Framework.Integration.ClientMethod; namespace Tests.Framework.Integration { @@ -10,18 +8,13 @@ public class EndpointUsage private readonly object _lock = new object(); private readonly ConcurrentDictionary _usages = new ConcurrentDictionary(); - public IDictionary CallUniqueValues { get; } - private string UniqueValue => "nest-" + Guid.NewGuid().ToString("N").Substring(0, 8); + public CallUniqueValues CallUniqueValues { get; } + + public bool CalledSetup { get; internal set; } public EndpointUsage() { - this.CallUniqueValues = new Dictionary - { - { Fluent, this.UniqueValue }, - { FluentAsync, this.UniqueValue }, - { Initializer, this.UniqueValue }, - { InitializerAsync, this.UniqueValue }, - }; + this.CallUniqueValues = new CallUniqueValues(); } public LazyResponses CallOnce(Func clientUsage, int? k = null) @@ -38,12 +31,4 @@ public LazyResponses CallOnce(Func clientUsage, int? k = null) } } } - - public enum ClientMethod - { - Fluent, - FluentAsync, - Initializer, - InitializerAsync - } -} \ No newline at end of file +} diff --git a/src/Tests/Indices/AliasManagement/Alias/AliasApiTests.cs b/src/Tests/Indices/AliasManagement/Alias/AliasApiTests.cs index 44ecffa86f8..4e7a9543b57 100644 --- a/src/Tests/Indices/AliasManagement/Alias/AliasApiTests.cs +++ b/src/Tests/Indices/AliasManagement/Alias/AliasApiTests.cs @@ -13,7 +13,7 @@ public class AliasApiTests : ApiIntegrationTestBase values) + protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { foreach (var index in values.Values) client.CreateIndex(index); diff --git a/src/Tests/Indices/AliasManagement/AliasExists/AliasExistsApiTests.cs b/src/Tests/Indices/AliasManagement/AliasExists/AliasExistsApiTests.cs index 4408dba421b..72126fc3304 100644 --- a/src/Tests/Indices/AliasManagement/AliasExists/AliasExistsApiTests.cs +++ b/src/Tests/Indices/AliasManagement/AliasExists/AliasExistsApiTests.cs @@ -14,7 +14,7 @@ public class AliasExistsApiTests : ApiIntegrationTestBase values) + protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { foreach (var index in values.Values) client.CreateIndex(index, c=>c diff --git a/src/Tests/Indices/AliasManagement/DeleteAlias/AliasDeleteApiTests.cs b/src/Tests/Indices/AliasManagement/DeleteAlias/AliasDeleteApiTests.cs index ea215b2b07b..5f4b1c17437 100644 --- a/src/Tests/Indices/AliasManagement/DeleteAlias/AliasDeleteApiTests.cs +++ b/src/Tests/Indices/AliasManagement/DeleteAlias/AliasDeleteApiTests.cs @@ -13,7 +13,7 @@ public class DeleteAliasApiTests : ApiIntegrationTestBase Infer.Names(CallIsolatedValue + "-alias"); - protected override void BeforeAllCalls(IElasticClient client, IDictionary values) + protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { foreach (var index in values.Values) client.CreateIndex(index, c=>c diff --git a/src/Tests/Indices/AliasManagement/PutAlias/PutAliasApiTests.cs b/src/Tests/Indices/AliasManagement/PutAlias/PutAliasApiTests.cs index 496d9f3349a..8a5271c72bc 100644 --- a/src/Tests/Indices/AliasManagement/PutAlias/PutAliasApiTests.cs +++ b/src/Tests/Indices/AliasManagement/PutAlias/PutAliasApiTests.cs @@ -11,7 +11,7 @@ namespace Tests.Indices.AliasManagement.PutAlias [Collection(IntegrationContext.Indexing)] public class PutAliasApiTests : ApiIntegrationTestBase { - protected override void BeforeAllCalls(IElasticClient client, IDictionary values) + protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { foreach (var index in values.Values) client.CreateIndex(index); } diff --git a/src/Tests/Indices/IndexManagement/DeleteIndex/DeleteIndexApiTests.cs b/src/Tests/Indices/IndexManagement/DeleteIndex/DeleteIndexApiTests.cs index b7931556425..2a6fd14a9ad 100644 --- a/src/Tests/Indices/IndexManagement/DeleteIndex/DeleteIndexApiTests.cs +++ b/src/Tests/Indices/IndexManagement/DeleteIndex/DeleteIndexApiTests.cs @@ -14,7 +14,7 @@ public class DeleteIndexApiTests { public DeleteIndexApiTests(IndexingCluster cluster, EndpointUsage usage) : base(cluster, usage) { } - protected override void BeforeAllCalls(IElasticClient client, IDictionary values) + protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { foreach (var index in values.Values) client.CreateIndex(index); } diff --git a/src/Tests/Indices/IndexManagement/OpenCloseIndex/CloseIndex/CloseIndexApiTests.cs b/src/Tests/Indices/IndexManagement/OpenCloseIndex/CloseIndex/CloseIndexApiTests.cs index bd3e113aa88..3c37a605601 100644 --- a/src/Tests/Indices/IndexManagement/OpenCloseIndex/CloseIndex/CloseIndexApiTests.cs +++ b/src/Tests/Indices/IndexManagement/OpenCloseIndex/CloseIndex/CloseIndexApiTests.cs @@ -12,7 +12,7 @@ public class CloseIndexApiTests : ApiIntegrationTestBase values) + protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { foreach (var index in values.Values) client.CreateIndex(index); client.ClusterHealth(f => f.WaitForStatus(WaitForStatus.Yellow)); diff --git a/src/Tests/Indices/IndexManagement/OpenCloseIndex/OpenIndex/OpenIndexApiTests.cs b/src/Tests/Indices/IndexManagement/OpenCloseIndex/OpenIndex/OpenIndexApiTests.cs index 8c10c9dcc1e..b2fb7352749 100644 --- a/src/Tests/Indices/IndexManagement/OpenCloseIndex/OpenIndex/OpenIndexApiTests.cs +++ b/src/Tests/Indices/IndexManagement/OpenCloseIndex/OpenIndex/OpenIndexApiTests.cs @@ -14,7 +14,7 @@ public class OpenIndexApiTests { public OpenIndexApiTests(IndexingCluster cluster, EndpointUsage usage) : base(cluster, usage) { } - protected override void BeforeAllCalls(IElasticClient client, IDictionary values) + protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { foreach (var index in values.Values) { diff --git a/src/Tests/Indices/MappingManagement/PutMapping/PutMappingApiTest.cs b/src/Tests/Indices/MappingManagement/PutMapping/PutMappingApiTest.cs index 340e69de265..170a4cf3def 100644 --- a/src/Tests/Indices/MappingManagement/PutMapping/PutMappingApiTest.cs +++ b/src/Tests/Indices/MappingManagement/PutMapping/PutMappingApiTest.cs @@ -15,7 +15,7 @@ public class PutMappingApiTests : ApiIntegrationTestBase values) + protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { foreach (var index in values.Values) client.CreateIndex(index); } diff --git a/src/Tests/Indices/Monitoring/IndicesShardStores/IndicesShardStoresApiTests.cs b/src/Tests/Indices/Monitoring/IndicesShardStores/IndicesShardStoresApiTests.cs index 59eb8f1a717..80216d80bed 100644 --- a/src/Tests/Indices/Monitoring/IndicesShardStores/IndicesShardStoresApiTests.cs +++ b/src/Tests/Indices/Monitoring/IndicesShardStores/IndicesShardStoresApiTests.cs @@ -18,7 +18,7 @@ public IndicesShardStoresApiTests(OwnIndexCluster cluster, EndpointUsage usage) private static string IndexWithUnassignedShards = "nest-" + RandomString(); - protected override void BeforeAllCalls(IElasticClient client, IDictionary values) + protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { client.CreateIndex(IndexWithUnassignedShards, s => s .Settings(settings => settings diff --git a/src/Tests/Indices/StatusManagement/ForceMerge/ForceMergeApiTests.cs b/src/Tests/Indices/StatusManagement/ForceMerge/ForceMergeApiTests.cs index c4800fb296b..f99b4b77521 100644 --- a/src/Tests/Indices/StatusManagement/ForceMerge/ForceMergeApiTests.cs +++ b/src/Tests/Indices/StatusManagement/ForceMerge/ForceMergeApiTests.cs @@ -17,7 +17,7 @@ public class ForceMergeApiTests : ApiIntegrationTestBase values) + protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { foreach (var index in values.Values) client.CreateIndex(index); } diff --git a/src/Tests/Indices/StatusManagement/Optimize/OptimizeApiTests.cs b/src/Tests/Indices/StatusManagement/Optimize/OptimizeApiTests.cs index 691723ac02e..c12aeed9f52 100644 --- a/src/Tests/Indices/StatusManagement/Optimize/OptimizeApiTests.cs +++ b/src/Tests/Indices/StatusManagement/Optimize/OptimizeApiTests.cs @@ -17,7 +17,7 @@ public class OptimizeApiTests : ApiIntegrationTestBase values) + protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { foreach (var index in values.Values) client.CreateIndex(index); } diff --git a/src/Tests/Search/Request/InnerHitsUsageTests.cs b/src/Tests/Search/Request/InnerHitsUsageTests.cs index 74620e3e8b0..f8b1eb9f4da 100644 --- a/src/Tests/Search/Request/InnerHitsUsageTests.cs +++ b/src/Tests/Search/Request/InnerHitsUsageTests.cs @@ -137,7 +137,7 @@ public abstract class InnerHitsApiTestsBase : ApiIntegrationTestBase values) => new RoyalSeeder(this.Client, Index).Seed(); + protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) => new RoyalSeeder(this.Client, Index).Seed(); protected override ConnectionSettings GetConnectionSettings(ConnectionSettings settings) => settings .DisableDirectStreaming(); diff --git a/src/Tests/Tests.csproj b/src/Tests/Tests.csproj index fb93c51d0e9..4786c095bf7 100644 --- a/src/Tests/Tests.csproj +++ b/src/Tests/Tests.csproj @@ -553,6 +553,8 @@ + + diff --git a/src/Tests/tests.yaml b/src/Tests/tests.yaml index bb8ea0f52a5..bed985ced67 100644 --- a/src/Tests/tests.yaml +++ b/src/Tests/tests.yaml @@ -1,5 +1,5 @@ # mode either u (unit test), i (integration test) or m (mixed mode) -mode: m +mode: u # the elasticsearch version that should be started elasticsearch_version: 2.3.0 # whether we want to forcefully reseed on the node, if you are starting the tests with a node already running