From 852a40366a84d292937dd9c7b23d7f0dff58f8dd Mon Sep 17 00:00:00 2001 From: Martijn Laarman Date: Mon, 24 Feb 2020 15:59:58 +0100 Subject: [PATCH 1/3] Small changes, make sure we print errors at the end when running test suite locally. --- azure-pipelines.yml | 12 ++ tests/.ci.runsettings | 6 + tests/.runsettings | 10 -- tests/Tests.TestLogger/PrettyLogger.cs | 153 +++++++++++++++---------- tests/Tests.TestLogger/WordWrapper.cs | 8 +- 5 files changed, 114 insertions(+), 75 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1eb3bb22aad..873682829d8 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,3 +1,15 @@ +trigger: + batch: true + branches: + include: + - master + +pr: + autoCancel: true + branches: + exclude: + - "backport-*" + jobs: - job: StaleDocs pool: diff --git a/tests/.ci.runsettings b/tests/.ci.runsettings index a2ad332e3e3..7221061b4c6 100644 --- a/tests/.ci.runsettings +++ b/tests/.ci.runsettings @@ -2,6 +2,12 @@ true + + + + + + diff --git a/tests/.runsettings b/tests/.runsettings index fa2542fde5e..453367a1351 100644 --- a/tests/.runsettings +++ b/tests/.runsettings @@ -11,14 +11,4 @@ - - - - - cobertura - true - - - - diff --git a/tests/Tests.TestLogger/PrettyLogger.cs b/tests/Tests.TestLogger/PrettyLogger.cs index 35e5d8470ff..43f0529bec4 100644 --- a/tests/Tests.TestLogger/PrettyLogger.cs +++ b/tests/Tests.TestLogger/PrettyLogger.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; @@ -25,9 +26,17 @@ public class PrettyLogger : ITestLogger private readonly List _disableSkipNamespaces = new List(); public static Uri RootUri { get; } = new Uri(Environment.CurrentDirectory + Path.DirectorySeparatorChar, UriKind.Absolute); + private readonly ConcurrentQueue _failedTests = new ConcurrentQueue(); + public void Initialize(TestLoggerEvents events, string testRunDirectory) { - events.TestResult += TestResultHandler; + events.TestResult += (s, e) => + { + if (e.Result.Outcome != TestOutcome.Failed) return; + _failedTests.Enqueue(e.Result); + }; + + //events.TestResult += TestResultHandler; events.TestRunComplete += TestRunCompleteHandler; events.TestRunStart += (sender, args) => { @@ -49,7 +58,6 @@ public void Initialize(TestLoggerEvents events, string testRunDirectory) .Where(s => !string.IsNullOrWhiteSpace(s)) ); } - foreach (var a in StartUpActions) a(); }; } @@ -77,37 +85,44 @@ public void TestResultHandler(object sender, TestResultEventArgs e) break; default: - if (_writtenPassed > 0) - { - Console.WriteLine(); - _writtenPassed = 0; - } - PrintTestOutcomeHeader(e.Result.Outcome, testCase.FullyQualifiedName); - switch (e.Result.Outcome) - { - case TestOutcome.NotFound: break; - case TestOutcome.None: break; - case TestOutcome.Passed: - PrintLocation(testCase); - PrintDuration(e.Result.Duration); - break; - case TestOutcome.Skipped: - foreach (var p in e.Result.Messages) - p.Text.WriteWordWrapped(); - - break; - case TestOutcome.Failed: - PrintLocation(testCase); - PrintDuration(e.Result.Duration); - e.Result.ErrorMessage.WriteWordWrapped(WordWrapper.WriteWithExceptionHighlighted); - PrintStackTrace(e.Result.ErrorStackTrace); - break; - } + WriteTestResult(e.Result); break; } } + private void WriteTestResult(TestResult result, bool longForm = true) + { + if (_writtenPassed > 0) + { + Console.WriteLine(); + _writtenPassed = 0; + } + var testCase = result.TestCase; + PrintTestOutcomeHeader(result.Outcome, result.TestCase.FullyQualifiedName); + switch (result.Outcome) + { + case TestOutcome.NotFound: break; + case TestOutcome.None: break; + case TestOutcome.Passed: + PrintLocation(testCase); + PrintDuration(result.Duration); + break; + case TestOutcome.Skipped: + foreach (var p in result.Messages) + p.Text.WriteWordWrapped(); + + break; + case TestOutcome.Failed: + PrintLocation(testCase); + PrintDuration(result.Duration); + result.ErrorMessage.WriteWordWrapped(WordWrapper.WriteWithExceptionHighlighted, longForm); + if (longForm) + PrintStackTrace(result.ErrorStackTrace); + break; + } + } + private static int _slowTests = 0; private static void PrintDuration(TimeSpan duration) { @@ -144,20 +159,19 @@ private static void PrintStackTrace(string stackTrace) var atIn = line.Split(new[] { ") in " }, StringSplitOptions.RemoveEmptyEntries); var at = atIn[0] + ")"; Console.WriteLine(at); - if (atIn.Length > 1) - { - var @in = atIn[1].Split(':'); - var file = @in[0]; - var lineNumber = @in[1]; - Console.ForegroundColor = ConsoleColor.Gray; - Console.Write(" in "); - Console.ForegroundColor = ConsoleColor.Blue; - Console.Write(lineNumber); - Console.Write(" "); - Console.ForegroundColor = ConsoleColor.DarkGray; - Console.WriteLine(file.CreateRelativePath()); - Console.ResetColor(); - } + if (atIn.Length <= 1) continue; + + var @in = atIn[1].Split(':'); + var file = @in[0]; + var lineNumber = @in[1]; + Console.ForegroundColor = ConsoleColor.Gray; + Console.Write(" in "); + Console.ForegroundColor = ConsoleColor.Blue; + Console.Write(lineNumber); + Console.Write(" "); + Console.ForegroundColor = ConsoleColor.DarkGray; + Console.WriteLine(file.CreateRelativePath()); + Console.ResetColor(); } Console.WriteLine(); } @@ -172,9 +186,9 @@ private static void PrintLocation(TestCase testCase) Console.ResetColor(); } - public void TestRunCompleteHandler(object sender, TestRunCompleteEventArgs e) + private void TestRunCompleteHandler(object sender, TestRunCompleteEventArgs e) { - void WriteBox(string boxString, ConsoleColor boxColor, string metric) + static void WriteBox(string boxString, ConsoleColor boxColor, string metric) { boxString = " " + boxString.PadRight(5); Console.ForegroundColor = ConsoleColor.White; @@ -188,23 +202,17 @@ void WriteBox(string boxString, ConsoleColor boxColor, string metric) Console.WriteLine(); } - Console.WriteLine(); - Console.BackgroundColor = ConsoleColor.White; - Console.ForegroundColor = ConsoleColor.Black; - Console.Write(" "); - Console.ResetColor(); - Console.WriteLine(); - Console.BackgroundColor = ConsoleColor.White; - Console.ForegroundColor = ConsoleColor.Black; - Console.Write(" 🌈 SUMMARY RESULTS 🌈 "); - Console.ResetColor(); - Console.WriteLine(); - Console.BackgroundColor = ConsoleColor.White; - Console.ForegroundColor = ConsoleColor.Black; - Console.Write(" "); - Console.ResetColor(); - Console.WriteLine(); - Console.WriteLine(); + + //Reprint first 20 test failures at the bottom for convenience + Announce($"SEEN {_failedTests.Count} FAILURE{(_failedTests.Count > 1 ? "S" : "")}"); + + for (var expanded = 0; _failedTests.TryDequeue(out var testResult); expanded++) + { + WriteTestResult(testResult, expanded <= 20); + } + + + Announce(" 🌈 SUMMARY RESULTS 🌈 "); WriteBox("ALL", ConsoleColor.DarkGray, e.TestRunStatistics.ExecutedTests.ToString()); @@ -228,6 +236,27 @@ void WriteBox(string boxString, ConsoleColor boxColor, string metric) Console.WriteLine(); Console.WriteLine(); + } + + private static void Announce(string text) + { + Console.WriteLine(); + var padding = new string(' ', text.Length + 4); + Console.BackgroundColor = ConsoleColor.White; + Console.ForegroundColor = ConsoleColor.Black; + Console.Write(padding); + Console.ResetColor(); + Console.WriteLine(); + Console.BackgroundColor = ConsoleColor.White; + Console.ForegroundColor = ConsoleColor.Black; + Console.Write($" {text} "); + Console.ResetColor(); + Console.WriteLine(); + Console.BackgroundColor = ConsoleColor.White; + Console.ForegroundColor = ConsoleColor.Black; + Console.Write(padding); + Console.ResetColor(); + Console.WriteLine(); Console.WriteLine(); } @@ -303,7 +332,5 @@ private static string ToStringFromMilliseconds(double milliseconds, bool @fixed return (milliseconds / 60_000d).ToString("N0", Provider) + " m"; } - public static void AddStartupAction(Action action) => StartUpActions.Add(action); - private static List StartUpActions { get; } = new List(); } } diff --git a/tests/Tests.TestLogger/WordWrapper.cs b/tests/Tests.TestLogger/WordWrapper.cs index fa6cd5150fb..c8cc35d3fad 100644 --- a/tests/Tests.TestLogger/WordWrapper.cs +++ b/tests/Tests.TestLogger/WordWrapper.cs @@ -1,15 +1,19 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.RegularExpressions; namespace Tests.Core.VsTest { internal static class WordWrapper { - public static void WriteWordWrapped(this string paragraph, Action write = null, int tabSize = 4, int indent = 7) + public static void WriteWordWrapped(this string paragraph, Action write = null, bool printAll = true, int tabSize = 4, int indent = 7) { write ??= Console.WriteLine; - foreach (var line in paragraph.ToWordWrappedLines(tabSize, indent)) + var lines = paragraph.ToWordWrappedLines(tabSize, indent); + if (!printAll) + lines = lines.Take(2).Concat(new[] { $"{new string(' ', indent)} ..abbreviated.." }); + foreach (var line in lines) write(line); } From 458f37a9bab1d7a49fe539f5cbb286fdbf82463f Mon Sep 17 00:00:00 2001 From: Martijn Laarman Date: Mon, 24 Feb 2020 16:05:38 +0100 Subject: [PATCH 2/3] include branches ending in .x --- azure-pipelines.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 873682829d8..980bea74b26 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -3,6 +3,7 @@ trigger: branches: include: - master + - "*.x" pr: autoCancel: true From 678ee787d4b7970688f7883836773c34ab3811ff Mon Sep 17 00:00:00 2001 From: Martijn Laarman Date: Tue, 25 Feb 2020 00:27:05 +0100 Subject: [PATCH 3/3] Move intrusive xpack tests to own cluster (#4446) * Moves tests further into their own clusters Enrich is now a CoordinatedUsageTest Slm is in its own cluster Security is in its own cluster to not have role/users API potentially cluttering the rest of the tests * GetRepository does not need to be an integration test as RepositoryCrud covers this already * Move watcher tests to own cluster * fix failing unit test after moving enrich stats api over to unit test only * update docs --- build/scripts/scripts.fsproj | 2 +- .../geo-hash-grid-aggregation-usage.asciidoc | 60 ++++++++ .../rank-feature-query-usage.asciidoc | 38 ++++- .../Tests.Configuration.csproj | 2 +- .../Tests.Core/Extensions/ClientExtensions.cs | 11 ++ .../Clusters/XPackCluster.cs | 2 - tests/Tests.Core/Tests.Core.csproj | 2 +- tests/Tests.Domain/Tests.Domain.csproj | 2 +- .../CleanupRepositoryApiTests.cs | 2 - .../GetRepository/GetRepositoryApiTests.cs | 53 +------ .../DeletePolicy/DeletePolicyApiTests.cs | 39 +---- tests/Tests/XPack/Enrich/EnrichApiTests.cs | 136 ++++++++++++++++++ tests/Tests/XPack/Enrich/EnrichCluster.cs | 9 ++ .../ExecutePolicy/ExecutePolicyApiTests.cs | 31 +--- .../Enrich/GetPolicy/GetPolicyApiTests.cs | 37 +---- .../Enrich/PutPolicy/PutPolicyApiTests.cs | 12 +- .../Tests/XPack/Enrich/Stats/StatsApiTests.cs | 46 +----- tests/Tests/XPack/Security/Security.cs | 9 ++ .../GetUserAccessTokenApiTests.cs | 6 +- .../InvalidateUserAccessTokenApiTests.cs | 6 +- .../Security/User/PutUser/PutUserApiTests.cs | 8 +- .../XPack/Security/User/UserCrudTests.cs | 4 +- tests/Tests/XPack/Slm/SlmApiTests.cs | 4 +- tests/Tests/XPack/Slm/SlmCluster.cs | 9 ++ .../AcknowledgeWatchApiTests.cs | 4 +- .../ActivateWatch/ActivateWatchApiTests.cs | 4 +- .../DeactivateWatchApiTests.cs | 4 +- .../DeleteWatch/DeleteWatchApiTests.cs | 8 +- .../ExecuteWatch/ExecuteWatchApiTests.cs | 8 +- .../Watcher/GetWatch/GetWatchApiTests.cs | 8 +- .../Watcher/PutWatch/PutWatchApiTests.cs | 8 +- tests/Tests/XPack/Watcher/WatcherCluster.cs | 9 ++ .../WatcherStats/WatcherStatsApiTests.cs | 4 +- 33 files changed, 342 insertions(+), 245 deletions(-) create mode 100644 tests/Tests.Core/Extensions/ClientExtensions.cs create mode 100644 tests/Tests/XPack/Enrich/EnrichApiTests.cs create mode 100644 tests/Tests/XPack/Enrich/EnrichCluster.cs create mode 100644 tests/Tests/XPack/Security/Security.cs create mode 100644 tests/Tests/XPack/Slm/SlmCluster.cs create mode 100644 tests/Tests/XPack/Watcher/WatcherCluster.cs diff --git a/build/scripts/scripts.fsproj b/build/scripts/scripts.fsproj index 8fc8238b48d..e4048af1a77 100644 --- a/build/scripts/scripts.fsproj +++ b/build/scripts/scripts.fsproj @@ -38,7 +38,7 @@ - + diff --git a/docs/aggregations/bucket/geo-hash-grid/geo-hash-grid-aggregation-usage.asciidoc b/docs/aggregations/bucket/geo-hash-grid/geo-hash-grid-aggregation-usage.asciidoc index 768e086ebef..8fd165483aa 100644 --- a/docs/aggregations/bucket/geo-hash-grid/geo-hash-grid-aggregation-usage.asciidoc +++ b/docs/aggregations/bucket/geo-hash-grid/geo-hash-grid-aggregation-usage.asciidoc @@ -65,3 +65,63 @@ var myGeoHashGrid = response.Aggregations.GeoHash("my_geohash_grid"); myGeoHashGrid.Should().NotBeNull(); ---- +==== Fluent DSL example + +[source,csharp] +---- +a => a +.GeoHash("my_geohash_grid", g => g + .Field(p => p.LocationPoint) + .Bounds(b => b + .TopLeft(90,-180) + .BottomRight(-90, 180) + ) +) +---- + +==== Object Initializer syntax example + +[source,csharp] +---- +new GeoHashGridAggregation("my_geohash_grid") +{ + Field = Field(p => p.LocationPoint), + Bounds = new BoundingBox + { + TopLeft = new GeoLocation(90, -180), + BottomRight = new GeoLocation(-90, 180) + } +} +---- + +[source,javascript] +.Example json output +---- +{ + "my_geohash_grid": { + "geohash_grid": { + "field": "locationPoint", + "bounds": { + "top_left": { + "lat": 90.0, + "lon": -180.0 + }, + "bottom_right": { + "lat": -90.0, + "lon": 180.0 + } + } + } + } +} +---- + +==== Handling Responses + +[source,csharp] +---- +response.ShouldBeValid(); +var myGeoHashGrid = response.Aggregations.GeoHash("my_geohash_grid"); +myGeoHashGrid.Should().NotBeNull(); +---- + diff --git a/docs/query-dsl/specialized/rank-feature/rank-feature-query-usage.asciidoc b/docs/query-dsl/specialized/rank-feature/rank-feature-query-usage.asciidoc index 66578f111fc..64e56f4eafd 100644 --- a/docs/query-dsl/specialized/rank-feature/rank-feature-query-usage.asciidoc +++ b/docs/query-dsl/specialized/rank-feature/rank-feature-query-usage.asciidoc @@ -44,7 +44,7 @@ q new RankFeatureQuery() { Name = "named_query", - Boost = 1.1, + Boost = 1.1, Field = Infer.Field(f => f.Rank), Function = new RankFeatureSaturationFunction() } @@ -63,3 +63,39 @@ new RankFeatureQuery() } ---- +==== Fluent DSL example + +[source,csharp] +---- +q +.RankFeature(rf => rf + .Name("named_query") + .Boost(1.1) + .Field(f => f.Rank) +) +---- + +==== Object Initializer syntax example + +[source,csharp] +---- +new RankFeatureQuery +{ + Name = "named_query", + Boost = 1.1, + Field = Infer.Field(f => f.Rank), +} +---- + +[source,javascript] +.Example json output +---- +{ + "rank_feature": { + "_name": "named_query", + "boost": 1.1, + "field": "rank" + } +} +---- + diff --git a/tests/Tests.Configuration/Tests.Configuration.csproj b/tests/Tests.Configuration/Tests.Configuration.csproj index fb6d7a32ec8..23de5686d49 100644 --- a/tests/Tests.Configuration/Tests.Configuration.csproj +++ b/tests/Tests.Configuration/Tests.Configuration.csproj @@ -3,6 +3,6 @@ netstandard2.0 - + \ No newline at end of file diff --git a/tests/Tests.Core/Extensions/ClientExtensions.cs b/tests/Tests.Core/Extensions/ClientExtensions.cs new file mode 100644 index 00000000000..1ba03b03b09 --- /dev/null +++ b/tests/Tests.Core/Extensions/ClientExtensions.cs @@ -0,0 +1,11 @@ +using Elasticsearch.Net; +using Nest; + +namespace Tests.Core.Extensions +{ + public static class ClientExtensions + { + public static ClusterHealthResponse WaitForSecurityIndices(this IElasticClient client) => + client.Cluster.Health(new ClusterHealthRequest(".security-*") { WaitForStatus = WaitForStatus.Green }); + } +} diff --git a/tests/Tests.Core/ManagedElasticsearch/Clusters/XPackCluster.cs b/tests/Tests.Core/ManagedElasticsearch/Clusters/XPackCluster.cs index 24365f17c3e..56a7676ccec 100644 --- a/tests/Tests.Core/ManagedElasticsearch/Clusters/XPackCluster.cs +++ b/tests/Tests.Core/ManagedElasticsearch/Clusters/XPackCluster.cs @@ -50,10 +50,8 @@ protected virtual ConnectionSettings ConnectionSettings(ConnectionSettings s) => protected sealed override void SeedCluster() { Client.Cluster.Health(new ClusterHealthRequest { WaitForStatus = WaitForStatus.Green }); - Client.Cluster.Health(new ClusterHealthRequest(".security-7") { WaitForStatus = WaitForStatus.Green }); SeedNode(); Client.Cluster.Health(new ClusterHealthRequest { WaitForStatus = WaitForStatus.Green }); - Client.Cluster.Health(new ClusterHealthRequest(".security-7") { WaitForStatus = WaitForStatus.Green }); } protected virtual void SeedNode() => new DefaultSeeder(Client).SeedNode(); diff --git a/tests/Tests.Core/Tests.Core.csproj b/tests/Tests.Core/Tests.Core.csproj index 8361d2c1066..61ca2e40951 100644 --- a/tests/Tests.Core/Tests.Core.csproj +++ b/tests/Tests.Core/Tests.Core.csproj @@ -18,7 +18,7 @@ - + diff --git a/tests/Tests.Domain/Tests.Domain.csproj b/tests/Tests.Domain/Tests.Domain.csproj index e41387f00b4..02dac54b453 100644 --- a/tests/Tests.Domain/Tests.Domain.csproj +++ b/tests/Tests.Domain/Tests.Domain.csproj @@ -11,7 +11,7 @@ - + diff --git a/tests/Tests/Modules/SnapshotAndRestore/Repositories/CleanupRepository/CleanupRepositoryApiTests.cs b/tests/Tests/Modules/SnapshotAndRestore/Repositories/CleanupRepository/CleanupRepositoryApiTests.cs index 70e6ed46d7d..452a3f507f6 100644 --- a/tests/Tests/Modules/SnapshotAndRestore/Repositories/CleanupRepository/CleanupRepositoryApiTests.cs +++ b/tests/Tests/Modules/SnapshotAndRestore/Repositories/CleanupRepository/CleanupRepositoryApiTests.cs @@ -7,8 +7,6 @@ namespace Tests.Modules.SnapshotAndRestore.Repositories.CleanupRepository { - // TODO NOT an integration tests, move SnapshotCrud tests over to a coordinatedtestbase so we can inject this in the request pipeline in order - // todo meaningful assertions public class CleanupRepositoryApiTests : ApiTestBase { diff --git a/tests/Tests/Modules/SnapshotAndRestore/Repositories/GetRepository/GetRepositoryApiTests.cs b/tests/Tests/Modules/SnapshotAndRestore/Repositories/GetRepository/GetRepositoryApiTests.cs index 089e3520ef1..1bb16602414 100644 --- a/tests/Tests/Modules/SnapshotAndRestore/Repositories/GetRepository/GetRepositoryApiTests.cs +++ b/tests/Tests/Modules/SnapshotAndRestore/Repositories/GetRepository/GetRepositoryApiTests.cs @@ -10,51 +10,14 @@ namespace Tests.Modules.SnapshotAndRestore.Repositories.GetRepository { public class GetRepositoryApiTests - : ApiIntegrationTestBase + : ApiTestBase { - protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) - { - foreach (var callUniqueValue in values) - { - var createRepositoryResponse = client.Snapshot.CreateRepository(callUniqueValue.Value, d => d - .SourceOnly(so => so - .FileSystem(fs => fs - .Settings("some/location", s => s - .Compress() - .ConcurrentStreams(5) - .ChunkSize("64mb") - .RestoreBytesPerSecondMaximum("100mb") - .SnapshotBytesPerSecondMaximum("200mb") - ) - ) - ) - ); - - if (!createRepositoryResponse.IsValid) - throw new Exception($"Error in integration setup: {createRepositoryResponse.DebugInformation}"); - } - } - - protected override void IntegrationTeardown(IElasticClient client, CallUniqueValues values) - { - foreach (var callUniqueValue in values) - { - var deleteRepositoryResponse = client.Snapshot.DeleteRepository(callUniqueValue.Value); - - if (!deleteRepositoryResponse.IsValid) - throw new Exception($"Error in integration teardown: {deleteRepositoryResponse.DebugInformation}"); - } - } - public GetRepositoryApiTests(WritableCluster cluster, EndpointUsage usage) : base(cluster, usage) { } protected override Func Fluent => d => d.RepositoryName(CallIsolatedValue); protected override HttpMethod HttpMethod => HttpMethod.GET; - protected override bool ExpectIsValid => true; - - protected override int ExpectStatusCode => 200; protected override GetRepositoryRequest Initializer => new GetRepositoryRequest(CallIsolatedValue); protected override bool SupportsDeserialization => false; @@ -67,19 +30,5 @@ protected override LazyResponses ClientUsage() => Calls( (client, r) => client.Snapshot.GetRepositoryAsync(r) ); - protected override void ExpectResponse(GetRepositoryResponse response) - { - response.ShouldBeValid(); - - response.Repositories.Should().ContainKey(CallIsolatedValue); - - var repository = response.Repositories[CallIsolatedValue]; - repository.Type.Should().Be("source"); - - var sourceOnlyRespository = repository as ISourceOnlyRepository; - sourceOnlyRespository.Should().NotBeNull(); - sourceOnlyRespository.DelegateType.Should().Be("fs"); - sourceOnlyRespository.DelegateSettings.Should().BeAssignableTo(); - } } } diff --git a/tests/Tests/XPack/Enrich/DeletePolicy/DeletePolicyApiTests.cs b/tests/Tests/XPack/Enrich/DeletePolicy/DeletePolicyApiTests.cs index a5e4e96e327..42d1f34c14a 100644 --- a/tests/Tests/XPack/Enrich/DeletePolicy/DeletePolicyApiTests.cs +++ b/tests/Tests/XPack/Enrich/DeletePolicy/DeletePolicyApiTests.cs @@ -1,11 +1,6 @@ -using System; -using Elastic.Xunit.XunitPlumbing; +using Elastic.Xunit.XunitPlumbing; using Elasticsearch.Net; -using FluentAssertions; using Nest; -using Tests.Core.ManagedElasticsearch.Clusters; -using Tests.Core.Xunit; -using Tests.Domain; using Tests.Framework.EndpointTests; using Tests.Framework.EndpointTests.TestState; using static Elasticsearch.Net.HttpMethod; @@ -14,46 +9,20 @@ namespace Tests.XPack.Enrich.DeletePolicy { [SkipVersion("<7.5.0", "Introduced in 7.5.0")] public class DeletePolicyApiTests - : ApiIntegrationTestBase + : ApiTestBase { - public DeletePolicyApiTests(XPackCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + public DeletePolicyApiTests(EnrichCluster cluster, EndpointUsage usage) : base(cluster, usage) { } - protected override bool ExpectIsValid => true; - protected override int ExpectStatusCode => 200; protected override HttpMethod HttpMethod => DELETE; - - protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) - { - foreach (var callUniqueValue in values) - { - var putPolicyResponse = client.Enrich.PutPolicy(callUniqueValue.Value, p => p - .Match(m => m - .Indices(typeof(Project)) - .MatchField(f => f.Name) - .EnrichFields(f => f - .Field(ff => ff.Description) - .Field(ff => ff.Tags) - ) - ) - ); - - if (!putPolicyResponse.IsValid) - throw new Exception($"Failure setting up integration test: {putPolicyResponse.DebugInformation}"); - } - } + protected override string UrlPath => $"/_enrich/policy/{CallIsolatedValue}"; protected override DeleteEnrichPolicyRequest Initializer => new DeleteEnrichPolicyRequest(CallIsolatedValue); - protected override string UrlPath => $"/_enrich/policy/{CallIsolatedValue}"; - protected override LazyResponses ClientUsage() => Calls( (client, f) => client.Enrich.DeletePolicy(CallIsolatedValue, f), (client, f) => client.Enrich.DeletePolicyAsync(CallIsolatedValue, f), (client, r) => client.Enrich.DeletePolicy(r), (client, r) => client.Enrich.DeletePolicyAsync(r) ); - - protected override void ExpectResponse(DeleteEnrichPolicyResponse response) => - response.Acknowledged.Should().BeTrue(); } } diff --git a/tests/Tests/XPack/Enrich/EnrichApiTests.cs b/tests/Tests/XPack/Enrich/EnrichApiTests.cs new file mode 100644 index 00000000000..15bb2852ff7 --- /dev/null +++ b/tests/Tests/XPack/Enrich/EnrichApiTests.cs @@ -0,0 +1,136 @@ +using System; +using System.Linq; +using System.Threading.Tasks; +using Elastic.Xunit.XunitPlumbing; +using FluentAssertions; +using Nest; +using Tests.Core.Extensions; +using Tests.Domain; +using Tests.Framework.EndpointTests; +using Tests.Framework.EndpointTests.TestState; +using static Nest.Infer; + +namespace Tests.XPack.Enrich +{ + [SkipVersion("<7.5.0", "Introduced in 7.50")] + public class EnrichApiTests : CoordinatedIntegrationTestBase + { + private const string PutPolicyStep = nameof(PutPolicyStep); + private const string GetPolicyStep = nameof(GetPolicyStep); + private const string ExecutePolicyStep = nameof(ExecutePolicyStep); + private const string StatsStep = nameof(StatsStep); + private const string DeletePolicyStep = nameof(DeletePolicyStep); + + public EnrichApiTests(EnrichCluster cluster, EndpointUsage usage) : base(new CoordinatedUsage(cluster, usage) + { + { + PutPolicyStep, u => + u.Calls, PutEnrichPolicyRequest, IPutEnrichPolicyRequest, PutEnrichPolicyResponse>( + v => new PutEnrichPolicyRequest(v) + { + Match = new EnrichPolicy + { + Indices = typeof(Project), + MatchField = Field(f => f.Name), + EnrichFields = Fields( + f => f.Description, + f => f.Tags + ) + } + }, + (v, d) => d + .Match(m => m + .Indices(typeof(Project)) + .MatchField(f => f.Name) + .EnrichFields(f => f + .Field(ff => ff.Description) + .Field(ff => ff.Tags) + ) + ), + (v, c, f) => c.Enrich.PutPolicy(v, f), + (v, c, f) => c.Enrich.PutPolicyAsync(v, f), + (v, c, r) => c.Enrich.PutPolicy(r), + (v, c, r) => c.Enrich.PutPolicyAsync(r) + ) + }, + { + GetPolicyStep, u => + u.Calls( + v => new GetEnrichPolicyRequest(v), + (v, d) => d, + (v, c, f) => c.Enrich.GetPolicy(v, f), + (v, c, f) => c.Enrich.GetPolicyAsync(v, f), + (v, c, r) => c.Enrich.GetPolicy(r), + (v, c, r) => c.Enrich.GetPolicyAsync(r) + ) + }, + { + ExecutePolicyStep, u => + u.Calls( + v => new ExecuteEnrichPolicyRequest(v), + (v, d) => d, + (v, c, f) => c.Enrich.ExecutePolicy(v, f), + (v, c, f) => c.Enrich.ExecutePolicyAsync(v, f), + (v, c, r) => c.Enrich.ExecutePolicy(r), + (v, c, r) => c.Enrich.ExecutePolicyAsync(r) + ) + }, + { + StatsStep, u => + u.Calls( + v => new EnrichStatsRequest() { }, + (v, d) => d, + (v, c, f) => c.Enrich.Stats(f), + (v, c, f) => c.Enrich.StatsAsync(f), + (v, c, r) => c.Enrich.Stats(r), + (v, c, r) => c.Enrich.StatsAsync(r) + ) + }, + { + DeletePolicyStep, u => + u.Calls( + v => new DeleteEnrichPolicyRequest(v), + (v, d) => d, + (v, c, f) => c.Enrich.DeletePolicy(v, f), + (v, c, f) => c.Enrich.DeletePolicyAsync(v, f), + (v, c, r) => c.Enrich.DeletePolicy(r), + (v, c, r) => c.Enrich.DeletePolicyAsync(r) + ) + }, + }) { } + + [I] public async Task PutEnrichPolicyResponse() => await Assert(PutPolicyStep, (v, r) => + { + r.Acknowledged.Should().BeTrue(); + }); + + [I] public async Task GetEnrichPolicyResponse() => await Assert(GetPolicyStep, (v, r) => + { + r.Policies.Should().HaveCount(1); + var policyConfig = r.Policies.First().Config; + + policyConfig.Match.Should().NotBeNull(); + policyConfig.Match.Name.Should().Be(v); + policyConfig.Match.Indices.Should().Be((Nest.Indices)"project"); + policyConfig.Match.MatchField.Should().Be("name"); + policyConfig.Match.EnrichFields.Should().HaveCount(2).And.Contain(new Field[] { "description", "tags" }); + + }); + + [I] public async Task ExecuteEnrichPolicyResponse() => await Assert(ExecutePolicyStep, (v, r) => + { + r.Status.Phase.Should().Be(EnrichPolicyPhase.Complete); + }); + + [I] public async Task EnrichStatsResponse() => await Assert(StatsStep, (v, r) => + { + r.ExecutingPolicies.Should().NotBeNull(); + r.CoordinatorStats.Should().NotBeNull(); + }); + + [I] public async Task DeleteEnrichPolicyResponse() => await Assert(DeletePolicyStep, (v, r) => + { + r.Acknowledged.Should().BeTrue(); + }); + } +} diff --git a/tests/Tests/XPack/Enrich/EnrichCluster.cs b/tests/Tests/XPack/Enrich/EnrichCluster.cs new file mode 100644 index 00000000000..7a631be76ad --- /dev/null +++ b/tests/Tests/XPack/Enrich/EnrichCluster.cs @@ -0,0 +1,9 @@ +using Tests.Core.ManagedElasticsearch.Clusters; + +namespace Tests.XPack.Enrich +{ + public class EnrichCluster : XPackCluster + { + + } +} diff --git a/tests/Tests/XPack/Enrich/ExecutePolicy/ExecutePolicyApiTests.cs b/tests/Tests/XPack/Enrich/ExecutePolicy/ExecutePolicyApiTests.cs index 9ebe407ad9d..47b97b0e150 100644 --- a/tests/Tests/XPack/Enrich/ExecutePolicy/ExecutePolicyApiTests.cs +++ b/tests/Tests/XPack/Enrich/ExecutePolicy/ExecutePolicyApiTests.cs @@ -13,46 +13,21 @@ namespace Tests.XPack.Enrich.ExecutePolicy { [SkipVersion("<7.5.0", "Introduced in 7.5.0")] public class ExecutePolicyApiTests - : ApiIntegrationTestBase + : ApiTestBase { - public ExecutePolicyApiTests(XPackCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + public ExecutePolicyApiTests(EnrichCluster cluster, EndpointUsage usage) : base(cluster, usage) { } - protected override bool ExpectIsValid => true; - protected override int ExpectStatusCode => 200; protected override HttpMethod HttpMethod => PUT; - protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) - { - foreach (var callUniqueValue in values) - { - var putPolicyResponse = client.Enrich.PutPolicy(callUniqueValue.Value, p => p - .Match(m => m - .Indices(typeof(Project)) - .MatchField(f => f.Name) - .EnrichFields(f => f - .Field(ff => ff.Description) - .Field(ff => ff.Tags) - ) - ) - ); - - if (!putPolicyResponse.IsValid) - throw new Exception($"Failure setting up integration test: {putPolicyResponse.DebugInformation}"); - } - } + protected override string UrlPath => $"/_enrich/policy/{CallIsolatedValue}/_execute"; protected override ExecuteEnrichPolicyRequest Initializer => new ExecuteEnrichPolicyRequest(CallIsolatedValue); - protected override string UrlPath => $"/_enrich/policy/{CallIsolatedValue}/_execute"; - protected override LazyResponses ClientUsage() => Calls( (client, f) => client.Enrich.ExecutePolicy(CallIsolatedValue, f), (client, f) => client.Enrich.ExecutePolicyAsync(CallIsolatedValue, f), (client, r) => client.Enrich.ExecutePolicy(r), (client, r) => client.Enrich.ExecutePolicyAsync(r) ); - - protected override void ExpectResponse(ExecuteEnrichPolicyResponse response) => - response.Status.Phase.Should().Be(EnrichPolicyPhase.Complete); } } diff --git a/tests/Tests/XPack/Enrich/GetPolicy/GetPolicyApiTests.cs b/tests/Tests/XPack/Enrich/GetPolicy/GetPolicyApiTests.cs index bee33d280d9..33a6ba37adc 100644 --- a/tests/Tests/XPack/Enrich/GetPolicy/GetPolicyApiTests.cs +++ b/tests/Tests/XPack/Enrich/GetPolicy/GetPolicyApiTests.cs @@ -14,36 +14,17 @@ namespace Tests.XPack.Enrich.GetPolicy { [SkipVersion("<7.5.0", "Introduced in 7.5.0")] public class GetPolicyApiTests - : ApiIntegrationTestBase + : ApiTestBase { private static readonly string PolicyName = "example_policy"; - public GetPolicyApiTests(XPackCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + public GetPolicyApiTests(EnrichCluster cluster, EndpointUsage usage) : base(cluster, usage) { } - protected override bool ExpectIsValid => true; - protected override int ExpectStatusCode => 200; protected override HttpMethod HttpMethod => GET; - protected override GetEnrichPolicyRequest Initializer => new GetEnrichPolicyRequest(PolicyName); - protected override string UrlPath => $"/_enrich/policy/{PolicyName}"; - protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) - { - var putPolicyResponse = client.Enrich.PutPolicy(PolicyName, p => p - .Match(m => m - .Indices(typeof(Project)) - .MatchField(f => f.Name) - .EnrichFields(f => f - .Field(ff => ff.Description) - .Field(ff => ff.Tags) - ) - ) - ); - - if (!putPolicyResponse.IsValid) - throw new Exception($"Failure setting up integration test: {putPolicyResponse.DebugInformation}"); - } + protected override GetEnrichPolicyRequest Initializer => new GetEnrichPolicyRequest(PolicyName); protected override LazyResponses ClientUsage() => Calls( (client, f) => client.Enrich.GetPolicy(PolicyName, f), @@ -51,17 +32,5 @@ protected override LazyResponses ClientUsage() => Calls( (client, r) => client.Enrich.GetPolicy(r), (client, r) => client.Enrich.GetPolicyAsync(r) ); - - protected override void ExpectResponse(GetEnrichPolicyResponse response) - { - response.Policies.Should().HaveCount(1); - var policyConfig = response.Policies.First().Config; - - policyConfig.Match.Should().NotBeNull(); - policyConfig.Match.Name.Should().Be(PolicyName); - policyConfig.Match.Indices.Should().Be((Nest.Indices)"project"); - policyConfig.Match.MatchField.Should().Be("name"); - policyConfig.Match.EnrichFields.Should().HaveCount(2).And.Contain(new Field[] { "description", "tags" }); - } } } diff --git a/tests/Tests/XPack/Enrich/PutPolicy/PutPolicyApiTests.cs b/tests/Tests/XPack/Enrich/PutPolicy/PutPolicyApiTests.cs index 23e671e3fde..129c8a44813 100644 --- a/tests/Tests/XPack/Enrich/PutPolicy/PutPolicyApiTests.cs +++ b/tests/Tests/XPack/Enrich/PutPolicy/PutPolicyApiTests.cs @@ -14,14 +14,14 @@ namespace Tests.XPack.Enrich.PutPolicy { [SkipVersion("<7.5.0", "Introduced in 7.5.0")] public class PutPolicyApiTests - : ApiIntegrationTestBase, PutEnrichPolicyRequest> + : ApiTestBase, PutEnrichPolicyRequest> { - public PutPolicyApiTests(XPackCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + public PutPolicyApiTests(EnrichCluster cluster, EndpointUsage usage) : base(cluster, usage) { } - protected override bool ExpectIsValid => true; - protected override int ExpectStatusCode => 200; protected override HttpMethod HttpMethod => PUT; + protected override string UrlPath => $"/_enrich/policy/{CallIsolatedValue}"; + protected override object ExpectJson => new { match = new @@ -57,8 +57,6 @@ public PutPolicyApiTests(XPackCluster cluster, EndpointUsage usage) : base(clust ) ); - protected override string UrlPath => $"/_enrich/policy/{CallIsolatedValue}"; - protected override LazyResponses ClientUsage() => Calls( (client, f) => client.Enrich.PutPolicy(CallIsolatedValue, f), (client, f) => client.Enrich.PutPolicyAsync(CallIsolatedValue, f), @@ -66,7 +64,5 @@ protected override LazyResponses ClientUsage() => Calls( (client, r) => client.Enrich.PutPolicyAsync(r) ); - protected override void ExpectResponse(PutEnrichPolicyResponse response) => - response.Acknowledged.Should().BeTrue(); } } diff --git a/tests/Tests/XPack/Enrich/Stats/StatsApiTests.cs b/tests/Tests/XPack/Enrich/Stats/StatsApiTests.cs index a38e7898cf8..c3921000a84 100644 --- a/tests/Tests/XPack/Enrich/Stats/StatsApiTests.cs +++ b/tests/Tests/XPack/Enrich/Stats/StatsApiTests.cs @@ -13,55 +13,19 @@ namespace Tests.XPack.Enrich.Stats { [SkipVersion("<7.5.0", "Introduced in 7.5.0")] public class EnrichStatsApiTests - : ApiIntegrationTestBase + : ApiTestBase { public EnrichStatsApiTests(XPackCluster cluster, EndpointUsage usage) : base(cluster, usage) { } - protected override bool ExpectIsValid => true; - protected override int ExpectStatusCode => 200; protected override HttpMethod HttpMethod => GET; - protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) - { - foreach (var callUniqueValue in values) - { - var putPolicyResponse = client.Enrich.PutPolicy(callUniqueValue.Value, p => p - .Match(m => m - .Indices(typeof(Project)) - .MatchField(f => f.Name) - .EnrichFields(f => f - .Field(ff => ff.Description) - .Field(ff => ff.Tags) - ) - ) - ); - - if (!putPolicyResponse.IsValid) - throw new Exception($"Failure setting up integration test: {putPolicyResponse.DebugInformation}"); - } - } - - protected override void OnBeforeCall(IElasticClient client) - { - var executePolicyResponse = client.Enrich.ExecutePolicy(CallIsolatedValue, e => e.WaitForCompletion(false)); - - if (!executePolicyResponse.IsValid) - throw new Exception($"Failure setting up integration test: {executePolicyResponse.DebugInformation}"); - } - protected override string UrlPath => $"/_enrich/_stats"; protected override LazyResponses ClientUsage() => Calls( - (client, f) => client.Enrich.Stats(f), - (client, f) => client.Enrich.StatsAsync(f), - (client, r) => client.Enrich.Stats(r), - (client, r) => client.Enrich.StatsAsync(r) + (client, f) => client.Enrich.Stats(), + (client, f) => client.Enrich.StatsAsync(), + (client, r) => client.Enrich.Stats(), + (client, r) => client.Enrich.StatsAsync() ); - - protected override void ExpectResponse(EnrichStatsResponse response) - { - response.ExecutingPolicies.Should().NotBeNull(); - response.CoordinatorStats.Should().NotBeNull(); - } } } diff --git a/tests/Tests/XPack/Security/Security.cs b/tests/Tests/XPack/Security/Security.cs new file mode 100644 index 00000000000..b826513a322 --- /dev/null +++ b/tests/Tests/XPack/Security/Security.cs @@ -0,0 +1,9 @@ +using Tests.Core.ManagedElasticsearch.Clusters; + +namespace Tests.XPack.Security +{ + public class Security : XPackCluster + { + + } +} diff --git a/tests/Tests/XPack/Security/User/GetUserAccessToken/GetUserAccessTokenApiTests.cs b/tests/Tests/XPack/Security/User/GetUserAccessToken/GetUserAccessTokenApiTests.cs index 06507e866bc..6716c7d59a0 100644 --- a/tests/Tests/XPack/Security/User/GetUserAccessToken/GetUserAccessTokenApiTests.cs +++ b/tests/Tests/XPack/Security/User/GetUserAccessToken/GetUserAccessTokenApiTests.cs @@ -12,10 +12,10 @@ namespace Tests.XPack.Security.User.GetUserAccessToken { [SkipVersion("<5.5.0", "")] public class GetUserAccessTokenApiTests - : ApiIntegrationTestBase { - public GetUserAccessTokenApiTests(XPackCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + public GetUserAccessTokenApiTests(Security cluster, EndpointUsage usage) : base(cluster, usage) { } protected override bool ExpectIsValid => true; @@ -65,7 +65,7 @@ protected override void ExpectResponse(GetUserAccessTokenResponse response) public class GetUserAccessTokenBadPasswordApiTests : GetUserAccessTokenApiTests { - public GetUserAccessTokenBadPasswordApiTests(XPackCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + public GetUserAccessTokenBadPasswordApiTests(Security cluster, EndpointUsage usage) : base(cluster, usage) { } protected override bool ExpectIsValid => false; protected override int ExpectStatusCode => 401; diff --git a/tests/Tests/XPack/Security/User/InvalidateUserAccessToken/InvalidateUserAccessTokenApiTests.cs b/tests/Tests/XPack/Security/User/InvalidateUserAccessToken/InvalidateUserAccessTokenApiTests.cs index ab4c64a8029..34816c8b7ab 100644 --- a/tests/Tests/XPack/Security/User/InvalidateUserAccessToken/InvalidateUserAccessTokenApiTests.cs +++ b/tests/Tests/XPack/Security/User/InvalidateUserAccessToken/InvalidateUserAccessTokenApiTests.cs @@ -13,12 +13,12 @@ namespace Tests.XPack.Security.User.InvalidateUserAccessToken { [SkipVersion("<5.5.0", "")] public class InvalidateUserAccessTokenApiTests - : ApiIntegrationTestBase { protected const string AccessTokenValueKey = "accesstoken"; - public InvalidateUserAccessTokenApiTests(XPackCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + public InvalidateUserAccessTokenApiTests(Security cluster, EndpointUsage usage) : base(cluster, usage) { } protected virtual string CurrentAccessToken => RanIntegrationSetup ? ExtendedValue(AccessTokenValueKey) : "foo"; @@ -61,7 +61,7 @@ protected override LazyResponses ClientUsage() => Calls( public class InvalidateUserAccessTokenBadPasswordApiTests : InvalidateUserAccessTokenApiTests { - public InvalidateUserAccessTokenBadPasswordApiTests(XPackCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + public InvalidateUserAccessTokenBadPasswordApiTests(Security cluster, EndpointUsage usage) : base(cluster, usage) { } protected override string CurrentAccessToken => "bad_password"; diff --git a/tests/Tests/XPack/Security/User/PutUser/PutUserApiTests.cs b/tests/Tests/XPack/Security/User/PutUser/PutUserApiTests.cs index 5080ef98c3a..46ba97cc3f0 100644 --- a/tests/Tests/XPack/Security/User/PutUser/PutUserApiTests.cs +++ b/tests/Tests/XPack/Security/User/PutUser/PutUserApiTests.cs @@ -12,9 +12,9 @@ namespace Tests.XPack.Security.User.PutUser { [SkipVersion("<2.3.0", "")] - public class PutUserApiTests : ApiIntegrationTestBase + public class PutUserApiTests : ApiIntegrationTestBase { - public PutUserApiTests(XPackCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + public PutUserApiTests(Security cluster, EndpointUsage usage) : base(cluster, usage) { } protected override bool ExpectIsValid => true; @@ -72,13 +72,13 @@ protected override LazyResponses ClientUsage() => Calls( protected override PutUserDescriptor NewDescriptor() => new PutUserDescriptor(CallIsolatedValue); - protected override void ExpectResponse(PutUserResponse response) => + protected override void ExpectResponse(PutUserResponse response) => response.Created.Should().BeTrue("{0}", response.DebugInformation); } public class PutUserRunAsApiTests : PutUserApiTests { - public PutUserRunAsApiTests(XPackCluster cluster, EndpointUsage usage) : base(cluster, usage) + public PutUserRunAsApiTests(Security cluster, EndpointUsage usage) : base(cluster, usage) { // ReSharper disable VirtualMemberCallInConstructor var x = Client.Security.GetUser(new GetUserRequest(ClusterAuthentication.User.Username)); diff --git a/tests/Tests/XPack/Security/User/UserCrudTests.cs b/tests/Tests/XPack/Security/User/UserCrudTests.cs index f18ab5bdfe1..c20a65acc93 100644 --- a/tests/Tests/XPack/Security/User/UserCrudTests.cs +++ b/tests/Tests/XPack/Security/User/UserCrudTests.cs @@ -11,11 +11,11 @@ namespace Tests.XPack.Security.User { [SkipVersion("<2.3.0", "")] public class UserCrudTests - : CrudTestBase + : CrudTestBase { private readonly string[] _roles = { "user" }; - public UserCrudTests(XPackCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + public UserCrudTests(Security cluster, EndpointUsage usage) : base(cluster, usage) { } //Since we basically take the first 8 characters of a guid we have no way //to guarantee it starts with a-zA-Z which is mandatory since 5.1 diff --git a/tests/Tests/XPack/Slm/SlmApiTests.cs b/tests/Tests/XPack/Slm/SlmApiTests.cs index 674a32abd35..703a841db7d 100644 --- a/tests/Tests/XPack/Slm/SlmApiTests.cs +++ b/tests/Tests/XPack/Slm/SlmApiTests.cs @@ -12,7 +12,7 @@ namespace Tests.XPack.Slm { [SkipVersion("<7.5.0", "All APIs exist in Elasticsearch 7.4.0, Retention, Status, Start and Stop added in 7.5.0")] - public class SlmApiTests : CoordinatedIntegrationTestBase + public class SlmApiTests : CoordinatedIntegrationTestBase { private const string CreateRepositoryStep = nameof(CreateRepositoryStep); private const string DeleteSnapshotLifecycleStep = nameof(DeleteSnapshotLifecycleStep); @@ -27,7 +27,7 @@ public class SlmApiTests : CoordinatedIntegrationTestBase private const string StopSnapshotLifecycleStep = nameof(StopSnapshotLifecycleStep); private const string GetSnapshotLifecycleStats = nameof(GetSnapshotLifecycleStats); - public SlmApiTests(XPackCluster cluster, EndpointUsage usage) : base(new CoordinatedUsage(cluster, usage) + public SlmApiTests(SlmCluster cluster, EndpointUsage usage) : base(new CoordinatedUsage(cluster, usage) { { CreateRepositoryStep, u => diff --git a/tests/Tests/XPack/Slm/SlmCluster.cs b/tests/Tests/XPack/Slm/SlmCluster.cs new file mode 100644 index 00000000000..fef37090940 --- /dev/null +++ b/tests/Tests/XPack/Slm/SlmCluster.cs @@ -0,0 +1,9 @@ +using Tests.Core.ManagedElasticsearch.Clusters; + +namespace Tests.XPack.Slm +{ + public class SlmCluster : XPackCluster + { + + } +} diff --git a/tests/Tests/XPack/Watcher/AcknowledgeWatch/AcknowledgeWatchApiTests.cs b/tests/Tests/XPack/Watcher/AcknowledgeWatch/AcknowledgeWatchApiTests.cs index c6a963bbcd1..26954ce4fc9 100644 --- a/tests/Tests/XPack/Watcher/AcknowledgeWatch/AcknowledgeWatchApiTests.cs +++ b/tests/Tests/XPack/Watcher/AcknowledgeWatch/AcknowledgeWatchApiTests.cs @@ -10,10 +10,10 @@ namespace Tests.XPack.Watcher.AcknowledgeWatch { public class AcknowledgeWatchApiTests - : ApiIntegrationTestBase { - public AcknowledgeWatchApiTests(XPackCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + public AcknowledgeWatchApiTests(WatcherCluster cluster, EndpointUsage usage) : base(cluster, usage) { } protected override bool ExpectIsValid => true; diff --git a/tests/Tests/XPack/Watcher/ActivateWatch/ActivateWatchApiTests.cs b/tests/Tests/XPack/Watcher/ActivateWatch/ActivateWatchApiTests.cs index ba6e827d202..4f3a08d5de3 100644 --- a/tests/Tests/XPack/Watcher/ActivateWatch/ActivateWatchApiTests.cs +++ b/tests/Tests/XPack/Watcher/ActivateWatch/ActivateWatchApiTests.cs @@ -10,9 +10,9 @@ namespace Tests.XPack.Watcher.ActivateWatch { public class ActivateWatchApiTests - : ApiIntegrationTestBase + : ApiIntegrationTestBase { - public ActivateWatchApiTests(XPackCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + public ActivateWatchApiTests(WatcherCluster cluster, EndpointUsage usage) : base(cluster, usage) { } protected override bool ExpectIsValid => true; diff --git a/tests/Tests/XPack/Watcher/DeactivateWatch/DeactivateWatchApiTests.cs b/tests/Tests/XPack/Watcher/DeactivateWatch/DeactivateWatchApiTests.cs index e9b1c6d4716..13f658e008e 100644 --- a/tests/Tests/XPack/Watcher/DeactivateWatch/DeactivateWatchApiTests.cs +++ b/tests/Tests/XPack/Watcher/DeactivateWatch/DeactivateWatchApiTests.cs @@ -10,9 +10,9 @@ namespace Tests.XPack.Watcher.DeactivateWatch { public class DeactivateWatchApiTests - : ApiIntegrationTestBase + : ApiIntegrationTestBase { - public DeactivateWatchApiTests(XPackCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + public DeactivateWatchApiTests(WatcherCluster cluster, EndpointUsage usage) : base(cluster, usage) { } protected override bool ExpectIsValid => true; diff --git a/tests/Tests/XPack/Watcher/DeleteWatch/DeleteWatchApiTests.cs b/tests/Tests/XPack/Watcher/DeleteWatch/DeleteWatchApiTests.cs index f7d0170f108..afcaac1d8d9 100644 --- a/tests/Tests/XPack/Watcher/DeleteWatch/DeleteWatchApiTests.cs +++ b/tests/Tests/XPack/Watcher/DeleteWatch/DeleteWatchApiTests.cs @@ -9,9 +9,9 @@ namespace Tests.XPack.Watcher.DeleteWatch { public class DeleteWatchApiTests - : ApiIntegrationTestBase + : ApiIntegrationTestBase { - public DeleteWatchApiTests(XPackCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + public DeleteWatchApiTests(WatcherCluster cluster, EndpointUsage usage) : base(cluster, usage) { } protected override bool ExpectIsValid => true; @@ -74,9 +74,9 @@ protected override void ExpectResponse(DeleteWatchResponse response) } public class DeleteNonExistentWatchApiTests - : ApiIntegrationTestBase + : ApiIntegrationTestBase { - public DeleteNonExistentWatchApiTests(XPackCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + public DeleteNonExistentWatchApiTests(WatcherCluster cluster, EndpointUsage usage) : base(cluster, usage) { } protected override bool ExpectIsValid => false; diff --git a/tests/Tests/XPack/Watcher/ExecuteWatch/ExecuteWatchApiTests.cs b/tests/Tests/XPack/Watcher/ExecuteWatch/ExecuteWatchApiTests.cs index de838349723..17a898d47e0 100644 --- a/tests/Tests/XPack/Watcher/ExecuteWatch/ExecuteWatchApiTests.cs +++ b/tests/Tests/XPack/Watcher/ExecuteWatch/ExecuteWatchApiTests.cs @@ -13,11 +13,11 @@ namespace Tests.XPack.Watcher.ExecuteWatch { public class ExecuteWatchApiTests - : ApiIntegrationTestBase + : ApiIntegrationTestBase { private readonly DateTimeOffset _triggeredDateTime = new DateTimeOffset(2016, 11, 17, 13, 00, 00, TimeSpan.Zero); - public ExecuteWatchApiTests(XPackCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + public ExecuteWatchApiTests(WatcherCluster cluster, EndpointUsage usage) : base(cluster, usage) { } protected override bool ExpectIsValid => true; @@ -269,11 +269,11 @@ protected override void ExpectResponse(ExecuteWatchResponse response) } public class ExecuteInlineWatchApiTests - : ApiIntegrationTestBase + : ApiIntegrationTestBase { private readonly DateTimeOffset _triggeredDateTime = new DateTimeOffset(2016, 11, 17, 13, 00, 00, TimeSpan.Zero); - public ExecuteInlineWatchApiTests(XPackCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + public ExecuteInlineWatchApiTests(WatcherCluster cluster, EndpointUsage usage) : base(cluster, usage) { } protected override bool ExpectIsValid => true; diff --git a/tests/Tests/XPack/Watcher/GetWatch/GetWatchApiTests.cs b/tests/Tests/XPack/Watcher/GetWatch/GetWatchApiTests.cs index 4b19313a193..ab80e7b78d5 100644 --- a/tests/Tests/XPack/Watcher/GetWatch/GetWatchApiTests.cs +++ b/tests/Tests/XPack/Watcher/GetWatch/GetWatchApiTests.cs @@ -12,9 +12,9 @@ namespace Tests.XPack.Watcher.GetWatch { // TODO: there was already a bunch of commented code in this file which needs to be revalidated - public class GetWatchApiTests : ApiIntegrationTestBase + public class GetWatchApiTests : ApiIntegrationTestBase { - public GetWatchApiTests(XPackCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + public GetWatchApiTests(WatcherCluster cluster, EndpointUsage usage) : base(cluster, usage) { } protected override bool ExpectIsValid => true; @@ -294,9 +294,9 @@ protected override void ExpectResponse(GetWatchResponse response) } public class GetNonExistentWatchApiTests - : ApiIntegrationTestBase + : ApiIntegrationTestBase { - public GetNonExistentWatchApiTests(XPackCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + public GetNonExistentWatchApiTests(WatcherCluster cluster, EndpointUsage usage) : base(cluster, usage) { } protected override bool ExpectIsValid => false; diff --git a/tests/Tests/XPack/Watcher/PutWatch/PutWatchApiTests.cs b/tests/Tests/XPack/Watcher/PutWatch/PutWatchApiTests.cs index 682ac4c3ce3..32eb11142a8 100644 --- a/tests/Tests/XPack/Watcher/PutWatch/PutWatchApiTests.cs +++ b/tests/Tests/XPack/Watcher/PutWatch/PutWatchApiTests.cs @@ -12,9 +12,9 @@ namespace Tests.XPack.Watcher.PutWatch { - public class PutWatchApiTests : ApiIntegrationTestBase + public class PutWatchApiTests : ApiIntegrationTestBase { - public PutWatchApiTests(XPackCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + public PutWatchApiTests(WatcherCluster cluster, EndpointUsage usage) : base(cluster, usage) { } protected override bool ExpectIsValid => true; @@ -713,9 +713,9 @@ protected override void ExpectResponse(PutWatchResponse response) } [SkipVersion("<7.4.0", "Foreach introduced in 7.3.0, max iterations in 7.4.0")] - public class PutWatchApiWithForeachTests : ApiIntegrationTestBase + public class PutWatchApiWithForeachTests : ApiIntegrationTestBase { - public PutWatchApiWithForeachTests(XPackCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + public PutWatchApiWithForeachTests(WatcherCluster cluster, EndpointUsage usage) : base(cluster, usage) { } protected override bool ExpectIsValid => true; diff --git a/tests/Tests/XPack/Watcher/WatcherCluster.cs b/tests/Tests/XPack/Watcher/WatcherCluster.cs new file mode 100644 index 00000000000..70dbd69252f --- /dev/null +++ b/tests/Tests/XPack/Watcher/WatcherCluster.cs @@ -0,0 +1,9 @@ +using Tests.Core.ManagedElasticsearch.Clusters; + +namespace Tests.XPack.Watcher +{ + public class WatcherCluster : XPackCluster + { + + } +} diff --git a/tests/Tests/XPack/Watcher/WatcherStats/WatcherStatsApiTests.cs b/tests/Tests/XPack/Watcher/WatcherStats/WatcherStatsApiTests.cs index ecb473a4bda..a6ef2ad75f8 100644 --- a/tests/Tests/XPack/Watcher/WatcherStats/WatcherStatsApiTests.cs +++ b/tests/Tests/XPack/Watcher/WatcherStats/WatcherStatsApiTests.cs @@ -10,9 +10,9 @@ namespace Tests.XPack.Watcher.WatcherStats { public class WatcherStatsApiTests - : ApiIntegrationTestBase + : ApiIntegrationTestBase { - public WatcherStatsApiTests(XPackCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + public WatcherStatsApiTests(WatcherCluster cluster, EndpointUsage usage) : base(cluster, usage) { } protected override bool ExpectIsValid => true;