Skip to content

Commit 66cddbc

Browse files
committed
Fix CrossClusterReplicationFollowTests integration test
Relates: elastic/elasticsearch#36647 This commit fixes the CrossClusterReplicationFollowTests to make assertions based on the Elasticsearch version under test. The follower stats API response behaviour changed from 6.5.3 to 6.5.4 - in 6.5.3 and previous, a request to e.g. GET /<indexname>/_ccr/stats returns in the `"indices"` array a collection of indices including `<indexname>` but also including other indices that are not `<indexname>` (and are not even a wildcard match for it). In 6.5.4 and above, that call returns only the single index named `<indexname>` in the `"indices"` array.
1 parent 7432a72 commit 66cddbc

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/Tests/Tests/XPack/CrossClusterReplication/CrossClusterReplicationFollowTests.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
using Elasticsearch.Net;
77
using FluentAssertions;
88
using Nest;
9+
using Tests.Configuration;
10+
using Tests.Core.Client;
11+
using Tests.Core.Extensions;
912
using Tests.Core.ManagedElasticsearch.Clusters;
1013
using Tests.Core.ManagedElasticsearch.NodeSeeders;
1114
using Tests.Domain;
@@ -200,6 +203,9 @@ public CrossClusterReplicationFollowTests(WritableCluster cluster, EndpointUsage
200203

201204
private static string CopyIndex(string v) => $"{v}-copy";
202205

206+
// see https://github.com/elastic/elasticsearch/pull/36647. difference in behaviour between <=6.5.3 and 6.5.4+
207+
private static int ExpectedFollowerIndices => TestClient.Configuration.InRange("<=6.5.3") ? 4 : 1;
208+
203209
[I] public async Task CreateReadOnlyIndexIsOk() => await Assert<CreateIndexResponse>(CreateIndexStep, r => r.Acknowledged.Should().BeTrue());
204210

205211
[I] public async Task IndexingDataIsOk() => await AssertRunsToCompletion(IndexDataStep);
@@ -222,9 +228,9 @@ [I] public async Task FollowStatsResponse() => await Assert<FollowIndexStatsResp
222228
{
223229
r.IsValid.Should().BeTrue();
224230
r.Indices.Should().NotBeEmpty();
225-
r.Indices.Count.Should().BeGreaterOrEqualTo(4);
231+
r.Indices.Count.Should().BeGreaterOrEqualTo(ExpectedFollowerIndices);
226232
var currentIndices = r.Indices.Where(i => i.Index.StartsWith(Prefix)).ToArray();
227-
currentIndices.Should().HaveCount(4);
233+
currentIndices.Should().HaveCount(ExpectedFollowerIndices);
228234
foreach (var i in currentIndices)
229235
{
230236
i.Index.Should().NotBeNullOrWhiteSpace("index name");
@@ -263,7 +269,7 @@ [I] public async Task FollowStatsResponseAgain() => await Assert<FollowIndexStat
263269
r.IsValid.Should().BeTrue();
264270
r.Indices.Should().NotBeEmpty();
265271
var currentIndices = r.Indices.Where(i => i.Index.StartsWith(Prefix)).ToArray();
266-
currentIndices.Should().HaveCount(4);
272+
currentIndices.Should().HaveCount(ExpectedFollowerIndices);
267273
AssertErrorsOnShardStats(currentIndices);
268274
});
269275

@@ -290,7 +296,7 @@ private static void AssertErrorsOnShardStats(FollowIndexStats[] currentIndices)
290296
}
291297
if (s.FatalException != null)
292298
{
293-
//eventhough read exceptions is set fatal exception can still be null (race condition?).
299+
//even though read exceptions is set fatal exception can still be null (race condition?).
294300
s.FatalException.Should().NotBeNull($"{s.FollowerIndex}", because);
295301
s.FatalException.Type.Should().NotBeNullOrWhiteSpace().And.EndWith("_exception", because);
296302
}

0 commit comments

Comments
 (0)