Skip to content

Commit 8524372

Browse files
authored
Fix mutation function in JoinStatusTests (#92534) (#92545)
Sometimes `mutateJoinStatus()` would fail to return a different object, e.g. if the message was very short. Also in case 4 it was mutating both the message and the age, but should not have been mutating the message.
1 parent fcaf082 commit 8524372

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

server/src/test/java/org/elasticsearch/cluster/coordination/JoinStatusTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,16 @@ private JoinStatus mutateJoinStatus(JoinStatus originalJoinStatus) {
4747
return new JoinStatus(
4848
originalJoinStatus.remoteNode(),
4949
originalJoinStatus.term(),
50-
randomAlphaOfLengthBetween(0, 30),
50+
randomValueOtherThan(originalJoinStatus.message(), () -> randomAlphaOfLengthBetween(0, 30)),
5151
originalJoinStatus.age()
5252
);
5353
}
5454
case 3 -> {
5555
return new JoinStatus(
5656
originalJoinStatus.remoteNode(),
5757
originalJoinStatus.term(),
58-
randomAlphaOfLength(30),
59-
randomNonNegativeTimeValue()
58+
originalJoinStatus.message(),
59+
randomValueOtherThan(originalJoinStatus.age(), this::randomNonNegativeTimeValue)
6060
);
6161
}
6262
case 4 -> {

0 commit comments

Comments
 (0)