-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix flake on
ReaperTest#testRemoveWatchWhenCloudRemoved
(#1516)
* Fix Flake on ReaperTest#testRemoveWatchWhenCloudRemoved Failure reproduced with ``` Index: src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/retention/Reaper.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/retention/Reaper.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/retention/Reaper.java --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/retention/Reaper.java (revision a81cd9f) +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/retention/Reaper.java (date 1709649329339) @@ -198,6 +198,11 @@ // close any cloud watchers that have been removed cloudNames.stream().map(this.watchers::get).filter(Objects::nonNull).forEach(cpw -> { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } LOGGER.info(() -> "stopping pod watcher for deleted kubernetes cloud " + cpw.cloudName); cpw.stop(); }); ``` The cause is that watcher really gets removed in a separate thread, so the test must await and avoid checking immediately. * Use structured assertion everywhere Also happened to find a problem with org.csanchez.jenkins.plugins.kubernetes.pod.retention.ReaperTest.testKeepWatchingOnStatusWatchEvent so fixed it.
- Loading branch information
Showing
1 changed file
with
35 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters