From 9d75e657a431d5627af3b976a0ed95c376b6c0e2 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Fri, 28 Jul 2023 19:26:43 -0400 Subject: [PATCH] Flakes in `Security2180Test` --- .../plugins/matrixauth/Security2180Test.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/test/java/org/jenkinsci/plugins/matrixauth/Security2180Test.java b/src/test/java/org/jenkinsci/plugins/matrixauth/Security2180Test.java index aae3342..0c05ed3 100644 --- a/src/test/java/org/jenkinsci/plugins/matrixauth/Security2180Test.java +++ b/src/test/java/org/jenkinsci/plugins/matrixauth/Security2180Test.java @@ -23,6 +23,7 @@ import java.util.Collections; import java.util.Map; import java.util.Set; +import java.util.logging.Logger; import jenkins.model.DirectlyModifiableTopLevelItemGroup; import jenkins.model.Jenkins; import org.htmlunit.Page; @@ -31,9 +32,12 @@ import org.jenkinsci.plugins.matrixauth.inheritance.InheritParentStrategy; import org.jenkinsci.plugins.matrixauth.inheritance.InheritanceStrategy; import org.jenkinsci.plugins.matrixauth.inheritance.NonInheritingStrategy; +import org.junit.After; import org.junit.Assert; +import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; +import org.jvnet.hudson.test.BuildWatcher; import org.jvnet.hudson.test.JenkinsRule; import org.jvnet.hudson.test.SleepBuilder; @@ -43,9 +47,26 @@ public class Security2180Test { private static final Map> ANONYMOUS_CAN_ITEM_READ = Collections.singletonMap(Item.READ, Collections.singleton("anonymous")); + private static final Logger LOGGER = Logger.getLogger(Security2180Test.class.getName()); + + @ClassRule + public static BuildWatcher watcher = new BuildWatcher(); + @Rule public JenkinsRule j = new JenkinsRule(); + @After + public void stopBuilds() throws Exception { + for (FreeStyleProject p : j.jenkins.allItems(FreeStyleProject.class)) { + for (FreeStyleBuild b : p.getBuilds()) { + LOGGER.info(() -> "Stopping " + b + "…"); + b.doStop(); + j.waitForCompletion(b); + LOGGER.info(() -> "…done."); + } + } + } + /** * Helper method that creates a nested folder structure: Each parameter but the last creates a folder, the last one * creates a freestyle job. Every non-null argument will be added as that item's property.