Skip to content

Commit 73df33d

Browse files
authored
[ML] making test more determinate (#40374)
* [ML] making test more determinate * unmuting test
1 parent a3e10a7 commit 73df33d

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

x-pack/plugin/data-frame/src/test/java/org/elasticsearch/xpack/dataframe/checkpoint/DataFrameTransformsCheckpointServiceTests.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ public void testExtractIndexCheckpointsLostPrimaries() {
8282
}
8383
}
8484

85-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/40368")
8685
public void testExtractIndexCheckpointsInconsistentGlobalCheckpoints() {
8786
Map<String, long[]> expectedCheckpoints = new HashMap<>();
8887
Set<String> indices = randomUserIndices();
@@ -141,9 +140,19 @@ private static ShardStats[] createRandomShardStats(Map<String, long[]> expectedC
141140
// we need at least one replica for testing
142141
int numShardCopies = randomIntBetween(2, 4);
143142

143+
int primaryShard = 0;
144+
if (skipPrimaries) {
145+
primaryShard = randomInt(numShardCopies - 1);
146+
}
144147
int inconsistentReplica = -1;
145148
if (inconsistentGlobalCheckpoints) {
146-
inconsistentReplica = randomIntBetween(0, numShardCopies - 1);
149+
List<Integer> replicas = new ArrayList<>(numShardCopies - 1);
150+
for (int i = 0; i < numShardCopies; i++) {
151+
if (primaryShard != i) {
152+
replicas.add(i);
153+
}
154+
}
155+
inconsistentReplica = randomFrom(replicas);
147156
}
148157

149158
// SeqNoStats asserts that checkpoints are logical
@@ -156,11 +165,7 @@ private static ShardStats[] createRandomShardStats(Map<String, long[]> expectedC
156165

157166
for (int replica = 0; replica < numShardCopies; replica++) {
158167
ShardId shardId = new ShardId(index, shardIndex);
159-
boolean primary = (replica == 0);
160-
161-
if (skipPrimaries) {
162-
primary = randomBoolean();
163-
}
168+
boolean primary = (replica == primaryShard);
164169

165170
Path path = createTempDir().resolve("indices").resolve(index.getUUID()).resolve(String.valueOf(shardIndex));
166171
ShardRouting shardRouting = ShardRouting.newUnassigned(shardId, primary,

0 commit comments

Comments
 (0)