From 252368c811648f66c05eaaf68acf99f768a92a8a Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Tue, 14 Jan 2025 18:02:23 -0500 Subject: [PATCH 1/2] Flaky `WorkflowRunTest.logRotationOnlyProcessesCompletedBuilds` on Windows --- .../plugins/workflow/job/WorkflowRunTest.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/test/java/org/jenkinsci/plugins/workflow/job/WorkflowRunTest.java b/src/test/java/org/jenkinsci/plugins/workflow/job/WorkflowRunTest.java index ed84651e..c5158223 100644 --- a/src/test/java/org/jenkinsci/plugins/workflow/job/WorkflowRunTest.java +++ b/src/test/java/org/jenkinsci/plugins/workflow/job/WorkflowRunTest.java @@ -25,10 +25,9 @@ package org.jenkinsci.plugins.workflow.job; import static org.awaitility.Awaitility.await; -import static org.hamcrest.collection.IsEmptyCollection.empty; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.emptyArray; +import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; @@ -725,11 +724,14 @@ public void onInitialize(Run run) { } LOGGER.info("Checking that all build directories are empty"); for (int i = 0; i < buildsToRun; i++) { - String[] filesInBuildDir = buildDirs[i].list(); - if (filesInBuildDir == null) { - filesInBuildDir = new String[0]; - } - assertThat("Expected " + buildDirs[i] + " to be empty but saw: " + Arrays.toString(filesInBuildDir), filesInBuildDir, emptyArray()); + var dir = buildDirs[i]; + await(dir + " should be empty").until(() -> { + var filesInBuildDir = dir.list(); + if (filesInBuildDir == null) { + filesInBuildDir = new String[0]; + } + return Arrays.asList(filesInBuildDir); + }, empty()); } } From 6ce8e85f9f1ac2d297792eb2aa0faca9250c92b8 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Tue, 14 Jan 2025 18:26:42 -0500 Subject: [PATCH 2/2] Suppress in Windows CI for now, since I cannot reproduce locally, and it seems to be triggered by the switch to VMs from ACI, meaning that it is platform-dependent --- .../org/jenkinsci/plugins/workflow/job/WorkflowRunTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/java/org/jenkinsci/plugins/workflow/job/WorkflowRunTest.java b/src/test/java/org/jenkinsci/plugins/workflow/job/WorkflowRunTest.java index c5158223..86a4f407 100644 --- a/src/test/java/org/jenkinsci/plugins/workflow/job/WorkflowRunTest.java +++ b/src/test/java/org/jenkinsci/plugins/workflow/job/WorkflowRunTest.java @@ -47,6 +47,7 @@ import hudson.AbortException; import hudson.Extension; import hudson.ExtensionList; +import hudson.Functions; import hudson.XmlFile; import hudson.model.*; import hudson.model.listeners.RunListener; @@ -98,6 +99,7 @@ import org.jenkinsci.plugins.workflow.job.properties.DisableConcurrentBuildsJobProperty; import org.jenkinsci.plugins.workflow.support.actions.EnvironmentAction; import org.jenkinsci.plugins.workflow.test.steps.SemaphoreStep; +import static org.junit.Assume.assumeFalse; import org.junit.ClassRule; import org.junit.Ignore; import org.junit.Rule; @@ -696,6 +698,7 @@ public void onInitialize(Run run) { @Issue("JENKINS-73835") @Test public void logRotationOnlyProcessesCompletedBuilds() throws Throwable { + assumeFalse("TODO #502: failing in VMs", Functions.isWindows() && "true".equals(System.getenv("CI"))); logging.record(LogRotator.class, Level.FINER); var p = r.createProject(WorkflowJob.class); p.setDefinition(new CpsFlowDefinition(