Skip to content

Commit b971468

Browse files
committed
fix tests
Signed-off-by: wind57 <[email protected]>
1 parent 621339d commit b971468

File tree

1 file changed

+8
-7
lines changed
  • spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-leader-election/src/test/java/org/springframework/cloud/kubernetes/fabric8/leader/election

1 file changed

+8
-7
lines changed

spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-leader-election/src/test/java/org/springframework/cloud/kubernetes/fabric8/leader/election/Assertions.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,23 @@ static void assertAcquireAndRenew(CapturedOutput output, Supplier<Lease> leaseSu
4242
// let's unwind some logs to see that the process is how we expect it to be
4343

4444
// 1. lease is used as the lock (comes from our code)
45-
assertThat(output.getOut()).contains("will use lease as the lock for leader election");
45+
awaitUntil(5, 100, () -> output.getOut().contains("will use lease as the lock for leader election"));
4646

4747
// 2. we start leader initiator for our hostname (comes from our code)
48-
assertThat(output.getOut()).contains("starting leader initiator : " + candidateIdentity);
48+
awaitUntil(5, 100, () -> output.getOut().contains("starting leader initiator : " + candidateIdentity));
4949

5050
// 3. we try to acquire the lease (comes from fabric8 code)
51-
assertThat(output.getOut())
51+
awaitUntil(5, 100, () -> output.getOut()
5252
.contains("Attempting to acquire leader lease 'LeaseLock: default - spring-k8s-leader-election-lock " + "("
53-
+ candidateIdentity + ")'");
53+
+ candidateIdentity + ")'"));
5454

5555
// 4. lease has been acquired
56-
assertThat(output.getOut()).contains("Acquired lease 'LeaseLock: default - spring-k8s-leader-election-lock "
57-
+ "(" + candidateIdentity + ")'");
56+
awaitUntil(5, 100, () -> output.getOut().contains("Acquired lease 'LeaseLock: default - spring-k8s-leader-election-lock "
57+
+ "(" + candidateIdentity + ")'"));
5858

5959
// 5. we are the leader (comes from fabric8 code)
60-
assertThat(output.getOut()).matches("(?s).*Leader changed from (|null) to " + candidateIdentity + ".*");
60+
awaitUntil(5, 100, () -> output.getOut()
61+
.matches("(?s).*Leader changed from (|null) to " + candidateIdentity + ".*"));
6162

6263
// 6. wait until a renewal happens (comes from fabric code)
6364
// this one means that we have extended our leadership

0 commit comments

Comments
 (0)