Skip to content

Commit 00a6a5b

Browse files
authored
Fix CCR Tests. (#3734)
* Fix CCR Tests. - WaitForActiveShards is a new feature in 6.7.0, which defaults to false, this is opposite behaviour of 6.6.0 (which implicitly waits for active shards) - Unfollowing a closed index in 6.7.0 now throws an exception * Add IntrusiveOperationSeeded cluster that indexes the default data and change ClusterRerouteApiTests to use this cluster
1 parent 190b79e commit 00a6a5b

File tree

3 files changed

+71
-10
lines changed

3 files changed

+71
-10
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Elastic.Managed.Ephemeral.Plugins;
2+
using Tests.Core.ManagedElasticsearch.NodeSeeders;
3+
4+
namespace Tests.Core.ManagedElasticsearch.Clusters
5+
{
6+
/// <summary>
7+
/// Use this cluster for heavy API's, either on ES's side or the client (intricate setup etc)
8+
/// </summary>
9+
public class IntrusiveOperationSeededCluster : ClientTestClusterBase
10+
{
11+
public IntrusiveOperationSeededCluster() : base(new ClientTestClusterConfiguration(
12+
ElasticsearchPlugin.IngestGeoIp, ElasticsearchPlugin.IngestAttachment
13+
)
14+
{
15+
MaxConcurrency = 1
16+
}) { }
17+
18+
protected override void SeedCluster()
19+
{
20+
var seeder = new DefaultSeeder(Client);
21+
seeder.SeedNode();
22+
}
23+
}
24+
}

src/Tests/Tests/Cluster/ClusterReroute/ClusterRerouteApiTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
namespace Tests.Cluster.ClusterReroute
1313
{
1414
public class ClusterRerouteApiTests
15-
: ApiIntegrationTestBase<IntrusiveOperationCluster, IClusterRerouteResponse, IClusterRerouteRequest, ClusterRerouteDescriptor,
15+
: ApiIntegrationTestBase<IntrusiveOperationSeededCluster, IClusterRerouteResponse, IClusterRerouteRequest, ClusterRerouteDescriptor,
1616
ClusterRerouteRequest>
1717
{
18-
public ClusterRerouteApiTests(IntrusiveOperationCluster cluster, EndpointUsage usage) : base(cluster, usage) { }
18+
public ClusterRerouteApiTests(IntrusiveOperationSeededCluster cluster, EndpointUsage usage) : base(cluster, usage) { }
1919

2020
protected override bool ExpectIsValid => false;
2121

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

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ namespace Tests.XPack.CrossClusterReplication
2121
[SkipVersion("<6.5.0", "")]
2222
public class CrossClusterReplicationFollowTests : CoordinatedIntegrationTestBase<WritableCluster>
2323
{
24+
private readonly WritableCluster _cluster;
2425
private const string CloseIndexStep = nameof(CloseIndexStep);
2526
private const string CountAfterStep = nameof(CountAfterStep);
2627
private const string CountBeforeStep = nameof(CountBeforeStep);
@@ -73,14 +74,37 @@ public CrossClusterReplicationFollowTests(WritableCluster cluster, EndpointUsage
7374
{
7475
FollowIndexStep, u =>
7576
u.Calls<CreateFollowIndexDescriptor, CreateFollowIndexRequest, ICreateFollowIndexRequest, ICreateFollowIndexResponse>(
76-
v => new CreateFollowIndexRequest(CopyIndex(v))
77+
v =>
7778
{
78-
RemoteCluster = DefaultSeeder.RemoteClusterName,
79-
LeaderIndex = v
79+
if (cluster.ClusterConfiguration.Version < "6.7.0")
80+
{
81+
return new CreateFollowIndexRequest(CopyIndex(v))
82+
{
83+
RemoteCluster = DefaultSeeder.RemoteClusterName,
84+
LeaderIndex = v
85+
};
86+
}
87+
return new CreateFollowIndexRequest(CopyIndex(v))
88+
{
89+
RemoteCluster = DefaultSeeder.RemoteClusterName,
90+
LeaderIndex = v,
91+
WaitForActiveShards = "1"
92+
};
93+
},
94+
(v, d) =>
95+
{
96+
if (cluster.ClusterConfiguration.Version < "6.7.0")
97+
{
98+
return d
99+
.RemoteCluster(DefaultSeeder.RemoteClusterName)
100+
.LeaderIndex(v);
101+
}
102+
103+
return d
104+
.RemoteCluster(DefaultSeeder.RemoteClusterName)
105+
.LeaderIndex(v)
106+
.WaitForActiveShards("1");
80107
},
81-
(v, d) => d
82-
.RemoteCluster(DefaultSeeder.RemoteClusterName)
83-
.LeaderIndex(v),
84108
(v, c, f) => c.CreateFollowIndex(CopyIndex(v), f),
85109
(v, c, f) => c.CreateFollowIndexAsync(CopyIndex(v), f),
86110
(v, c, r) => c.CreateFollowIndex(r),
@@ -197,7 +221,10 @@ public CrossClusterReplicationFollowTests(WritableCluster cluster, EndpointUsage
197221
(v, c, r) => c.UnfollowIndexAsync(r)
198222
)
199223
},
200-
}) { }
224+
})
225+
{
226+
_cluster = cluster;
227+
}
201228

202229
protected static string Prefix { get; } = $"f{Guid.NewGuid().ToString("N").Substring(0, 4)}";
203230

@@ -318,6 +345,16 @@ [I] public async Task PauseBeforeCloseIsAcked() =>
318345
[I] public async Task CloseIsAcked() => await Assert<CloseIndexResponse>(CloseIndexStep, r => r.Acknowledged.Should().BeTrue());
319346

320347
[I] public async Task UnfollowAfterCloseIsAcked() =>
321-
await Assert<UnfollowIndexResponse>(UnfollowAgainStep, r => r.Acknowledged.Should().BeTrue());
348+
await Assert<UnfollowIndexResponse>(UnfollowAgainStep, r =>
349+
{
350+
// Unfollowing an index after closing on 6.7.0 throws an exception.
351+
if (_cluster.ClusterConfiguration.Version < "6.7.0")
352+
{
353+
r.Acknowledged.Should().BeTrue();
354+
return;
355+
}
356+
r.IsValid.Should().BeFalse();
357+
r.ServerError.Should().NotBeNull();
358+
});
322359
}
323360
}

0 commit comments

Comments
 (0)