diff --git a/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeClientIT.java b/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeClientIT.java index 4c2ac89f..d7ebff3a 100644 --- a/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeClientIT.java +++ b/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeClientIT.java @@ -38,7 +38,7 @@ public class ComputeClientIT { private static final Logger log = Logger.getLogger(ComputeClientIT.class.getName()); - private static Map label = getLabel(ComputeClientIT.class); + private static final Map label = getLabel(ComputeClientIT.class); private static ComputeClient client; @ClassRule diff --git a/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloud1WorkerCreatedFor2ExecutorsIT.java b/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloud1WorkerCreatedFor2ExecutorsIT.java index f21c619c..469ccdba 100644 --- a/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloud1WorkerCreatedFor2ExecutorsIT.java +++ b/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloud1WorkerCreatedFor2ExecutorsIT.java @@ -20,7 +20,6 @@ import static com.google.jenkins.plugins.computeengine.integration.ITUtil.NULL_TEMPLATE; import static com.google.jenkins.plugins.computeengine.integration.ITUtil.PROJECT_ID; import static com.google.jenkins.plugins.computeengine.integration.ITUtil.TEST_TIMEOUT_MULTIPLIER; -import static com.google.jenkins.plugins.computeengine.integration.ITUtil.ZONE; import static com.google.jenkins.plugins.computeengine.integration.ITUtil.getLabel; import static com.google.jenkins.plugins.computeengine.integration.ITUtil.initClient; import static com.google.jenkins.plugins.computeengine.integration.ITUtil.initCloud; @@ -31,7 +30,6 @@ import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertEquals; -import com.google.api.services.compute.model.Instance; import com.google.cloud.graphite.platforms.plugin.client.ComputeClient; import com.google.common.collect.ImmutableList; import com.google.jenkins.plugins.computeengine.ComputeEngineCloud; @@ -61,15 +59,13 @@ public class ComputeEngineCloud1WorkerCreatedFor2ExecutorsIT { private static final String MULTIPLE_NUM_EXECUTORS = "2"; @ClassRule - public static Timeout timeout = new Timeout(5 * TEST_TIMEOUT_MULTIPLIER, TimeUnit.MINUTES); + public static Timeout timeout = new Timeout(5L * TEST_TIMEOUT_MULTIPLIER, TimeUnit.MINUTES); @ClassRule public static JenkinsRule jenkinsRule = new JenkinsRule(); private static ComputeClient client; - private static Map label = getLabel(ComputeEngineCloud1WorkerCreatedFor2ExecutorsIT.class); - private static Collection planned; - private static Instance instance; + private static final Map label = getLabel(ComputeEngineCloud1WorkerCreatedFor2ExecutorsIT.class); @BeforeClass public static void init() throws Exception { @@ -87,10 +83,8 @@ public static void init() throws Exception { .googleLabels(label) .build())); - planned = cloud.provision(new LabelAtom(LABEL), 2); + Collection planned = cloud.provision(new LabelAtom(LABEL), 2); planned.iterator().next().future.get(); - - instance = client.getInstance(PROJECT_ID, ZONE, planned.iterator().next().displayName); } @AfterClass diff --git a/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudIgnoreProxyIT.java b/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudIgnoreProxyIT.java index 04836535..6b6f626e 100644 --- a/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudIgnoreProxyIT.java +++ b/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudIgnoreProxyIT.java @@ -37,6 +37,7 @@ import hudson.ProxyConfiguration; import hudson.model.FreeStyleBuild; import hudson.model.FreeStyleProject; +import hudson.model.Result; import hudson.model.labels.LabelAtom; import hudson.tasks.Builder; import java.io.IOException; @@ -51,9 +52,8 @@ import org.junit.ClassRule; import org.junit.Test; import org.junit.rules.Timeout; +import org.jvnet.hudson.test.BuildWatcher; import org.jvnet.hudson.test.JenkinsRule; -import org.jvnet.hudson.test.PrefixedOutputStream; -import org.jvnet.hudson.test.TailLog; /** * Integration test suite for {@link ComputeEngineCloud}. Verifies that when the ignore proxy flag @@ -61,14 +61,18 @@ */ @Log public class ComputeEngineCloudIgnoreProxyIT { + @ClassRule - public static Timeout timeout = new Timeout(10 * TEST_TIMEOUT_MULTIPLIER, TimeUnit.MINUTES); + public static Timeout timeout = new Timeout(10L * TEST_TIMEOUT_MULTIPLIER, TimeUnit.MINUTES); @ClassRule public static JenkinsRule jenkinsRule = new JenkinsRule(); + @ClassRule + public static BuildWatcher bw = new BuildWatcher(); + private static ComputeClient client; - private static Map label = getLabel(ComputeEngineCloudIgnoreProxyIT.class); + private static final Map label = getLabel(ComputeEngineCloudIgnoreProxyIT.class); private static ComputeEngineCloud cloud; @BeforeClass @@ -120,12 +124,10 @@ public void testWorkerIgnoringProxy() throws Exception { .isIgnoreProxy()); var project = createProject(identifier); - try (var tailLog = new TailLog(jenkinsRule, identifier, 1).withColor(PrefixedOutputStream.Color.MAGENTA)) { - Future build = project.scheduleBuild2(0); - ComputeEngineInstance node = (ComputeEngineInstance) build.get().getBuiltOn(); - assertTrue(node.isIgnoreProxy()); - tailLog.waitForCompletion(); - } + Future build = project.scheduleBuild2(0); + ComputeEngineInstance node = (ComputeEngineInstance) build.get().getBuiltOn(); + assertTrue(node.isIgnoreProxy()); + jenkinsRule.assertBuildStatus(Result.SUCCESS, build.get()); } // Due to the proxy configured for Jenkins, the build fails because it is not able to connect to @@ -141,9 +143,7 @@ public void testWorkerNotIgnoringProxyFails() throws Exception { .isIgnoreProxy()); var project = createProject(identifier); - try (var tailLog = new TailLog(jenkinsRule, identifier, 1).withColor(PrefixedOutputStream.Color.YELLOW)) { - Future build = project.scheduleBuild2(0); - build.get(300, TimeUnit.SECONDS); - } + Future build = project.scheduleBuild2(0); + build.get(300, TimeUnit.SECONDS); } } diff --git a/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudMultipleLabelsIT.java b/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudMultipleLabelsIT.java index dafcbc86..5f0a601c 100644 --- a/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudMultipleLabelsIT.java +++ b/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudMultipleLabelsIT.java @@ -54,18 +54,18 @@ * with multiple Jenkins labels and that these labels are properly provisioned. */ public class ComputeEngineCloudMultipleLabelsIT { - private static Logger log = Logger.getLogger(ComputeEngineCloudMultipleLabelsIT.class.getName()); + private static final Logger log = Logger.getLogger(ComputeEngineCloudMultipleLabelsIT.class.getName()); private static final String MULTIPLE_LABEL = "integration test"; @ClassRule - public static Timeout timeout = new Timeout(5 * TEST_TIMEOUT_MULTIPLIER, TimeUnit.MINUTES); + public static Timeout timeout = new Timeout(5L * TEST_TIMEOUT_MULTIPLIER, TimeUnit.MINUTES); @ClassRule public static JenkinsRule jenkinsRule = new JenkinsRule(); private static ComputeClient client; - private static Map label = getLabel(ComputeEngineCloudMultipleLabelsIT.class); + private static final Map label = getLabel(ComputeEngineCloudMultipleLabelsIT.class); private static String name; @BeforeClass diff --git a/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudMultipleMatchingConfigurationsIT.java b/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudMultipleMatchingConfigurationsIT.java index caac3511..47c1a360 100644 --- a/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudMultipleMatchingConfigurationsIT.java +++ b/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudMultipleMatchingConfigurationsIT.java @@ -57,7 +57,8 @@ * with multiple matching {@link InstanceConfiguration} and that these instances are provisioned in round-robin fashion. */ public class ComputeEngineCloudMultipleMatchingConfigurationsIT { - private static Logger log = Logger.getLogger(ComputeEngineCloudMultipleMatchingConfigurationsIT.class.getName()); + private static final Logger log = + Logger.getLogger(ComputeEngineCloudMultipleMatchingConfigurationsIT.class.getName()); private static final String DESC_1 = "type_1"; private static final String DESC_2 = "type_2"; @@ -69,7 +70,7 @@ public class ComputeEngineCloudMultipleMatchingConfigurationsIT { public static JenkinsRule jenkinsRule = new JenkinsRule(); private static ComputeClient client; - private static Map label = getLabel(ComputeEngineCloudMultipleMatchingConfigurationsIT.class); + private static final Map label = getLabel(ComputeEngineCloudMultipleMatchingConfigurationsIT.class); private static Collection planned; @BeforeClass diff --git a/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudNoSnapshotCreatedIT.java b/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudNoSnapshotCreatedIT.java index 0f1bd691..e5864f28 100644 --- a/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudNoSnapshotCreatedIT.java +++ b/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudNoSnapshotCreatedIT.java @@ -51,6 +51,7 @@ import org.junit.ClassRule; import org.junit.Test; import org.junit.rules.Timeout; +import org.jvnet.hudson.test.BuildWatcher; import org.jvnet.hudson.test.JenkinsRule; /** @@ -62,13 +63,16 @@ public class ComputeEngineCloudNoSnapshotCreatedIT { private static final Logger log = Logger.getLogger(ComputeEngineCloudNoSnapshotCreatedIT.class.getName()); @ClassRule - public static Timeout timeout = new Timeout(7 * TEST_TIMEOUT_MULTIPLIER, TimeUnit.MINUTES); + public static Timeout timeout = new Timeout(7L * TEST_TIMEOUT_MULTIPLIER, TimeUnit.MINUTES); @ClassRule public static JenkinsRule jenkinsRule = new JenkinsRule(); + @ClassRule + public static BuildWatcher bw = new BuildWatcher(); + private static ComputeClient client; - private static Map label = getLabel(ComputeEngineCloudNoSnapshotCreatedIT.class); + private static final Map label = getLabel(ComputeEngineCloudNoSnapshotCreatedIT.class); private static String name; @BeforeClass diff --git a/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudNonStandardJavaIT.java b/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudNonStandardJavaIT.java index 9e3987e6..6e1c6b4b 100644 --- a/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudNonStandardJavaIT.java +++ b/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudNonStandardJavaIT.java @@ -50,9 +50,8 @@ import org.junit.ClassRule; import org.junit.Test; import org.junit.rules.Timeout; +import org.jvnet.hudson.test.BuildWatcher; import org.jvnet.hudson.test.JenkinsRule; -import org.jvnet.hudson.test.PrefixedOutputStream; -import org.jvnet.hudson.test.TailLog; /** * Integration test suite for {@link ComputeEngineCloudNonStandardJavaIT}. Verifies that instances @@ -70,6 +69,9 @@ public class ComputeEngineCloudNonStandardJavaIT { @ClassRule public static JenkinsRule jenkinsRule = new JenkinsRule(); + @ClassRule + public static BuildWatcher bw = new BuildWatcher(); + private static ComputeClient client; private static final Map label = getLabel(ComputeEngineCloudNonStandardJavaIT.class); @@ -102,16 +104,14 @@ public static void teardown() throws IOException { public void testBuildOnNonStandardJavaAgent() throws Exception { var p = jenkinsRule.createProject(WorkflowJob.class, "p"); p.setDefinition(new CpsFlowDefinition("node('" + LABEL + "') { sh 'date' }", true)); - try (var tailLog = new TailLog(jenkinsRule, "p", 1).withColor(PrefixedOutputStream.Color.MAGENTA)) { - var r = jenkinsRule.buildAndAssertSuccess(p); - assertEquals(1, jenkinsRule.jenkins.getNodes().size()); - var instance = client.getInstance( - PROJECT_ID, ZONE, jenkinsRule.jenkins.getNodes().get(0).getNodeName()); - tailLog.waitForCompletion(); - assertThat( - "Build did not run on GCP agent", - JenkinsRule.getLog(r), - is(containsString("Running on " + instance.getName()))); - } + var r = jenkinsRule.buildAndAssertSuccess(p); + assertEquals(1, jenkinsRule.jenkins.getNodes().size()); + var instance = client.getInstance( + PROJECT_ID, ZONE, jenkinsRule.jenkins.getNodes().get(0).getNodeName()); + assertThat( + "Build did not run on GCP agent", + JenkinsRule.getLog(r), + is(containsString("Running on " + instance.getName()))); + jenkinsRule.waitUntilNoActivity(); } } diff --git a/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudOneShotInstanceIT.java b/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudOneShotInstanceIT.java index 5eb1ac25..3678af6b 100644 --- a/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudOneShotInstanceIT.java +++ b/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudOneShotInstanceIT.java @@ -53,6 +53,7 @@ import org.junit.ClassRule; import org.junit.Test; import org.junit.rules.Timeout; +import org.jvnet.hudson.test.BuildWatcher; import org.jvnet.hudson.test.JenkinsRule; /** @@ -64,13 +65,16 @@ public class ComputeEngineCloudOneShotInstanceIT { private static final int QUIET_PERIOD_SECS = 30; @ClassRule - public static Timeout timeout = new Timeout(10 * TEST_TIMEOUT_MULTIPLIER, TimeUnit.MINUTES); + public static Timeout timeout = new Timeout(10L * TEST_TIMEOUT_MULTIPLIER, TimeUnit.MINUTES); @ClassRule public static JenkinsRule jenkinsRule = new JenkinsRule(); + @ClassRule + public static BuildWatcher bw = new BuildWatcher(); + private static ComputeClient client; - private static Map label = getLabel(ComputeEngineCloudOneShotInstanceIT.class); + private static final Map label = getLabel(ComputeEngineCloudOneShotInstanceIT.class); private static FreeStyleBuild build; private static String nodeName; private static Future otherBuildFuture; diff --git a/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudRestartPreemptedIT.java b/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudRestartPreemptedIT.java index 7177ac50..b7a7e1a8 100644 --- a/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudRestartPreemptedIT.java +++ b/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudRestartPreemptedIT.java @@ -58,9 +58,8 @@ import org.junit.ClassRule; import org.junit.Test; import org.junit.rules.Timeout; +import org.jvnet.hudson.test.BuildWatcher; import org.jvnet.hudson.test.JenkinsRule; -import org.jvnet.hudson.test.PrefixedOutputStream; -import org.jvnet.hudson.test.TailLog; /** * Integration test suite for {@link ComputeEngineCloud}. Verifies that the build is rescheduled and @@ -77,8 +76,11 @@ public class ComputeEngineCloudRestartPreemptedIT { @ClassRule public static JenkinsRule jenkinsRule = new JenkinsRule(); + @ClassRule + public static BuildWatcher bw = new BuildWatcher(); + private static ComputeClient client; - private static Map label = getLabel(ComputeEngineCloudRestartPreemptedIT.class); + private static final Map label = getLabel(ComputeEngineCloudRestartPreemptedIT.class); private static ComputeEngineCloud cloud; @BeforeClass @@ -138,28 +140,21 @@ public void testIfNodeWasPreempted() throws Exception { project.setAssignedLabel(new LabelAtom(LABEL)); FreeStyleBuild freeStyleBuild; // build1 that gets failed due to preemption - try (var tailLog = new TailLog(jenkinsRule, "p", 1).withColor(PrefixedOutputStream.Color.MAGENTA)) { - QueueTaskFuture taskFuture = project.scheduleBuild2(0); - - Awaitility.await().timeout(7, TimeUnit.MINUTES).until(() -> computer.getLog() - .contains("listening to metadata for preemption event")); + QueueTaskFuture taskFuture = project.scheduleBuild2(0); + Awaitility.await().timeout(7, TimeUnit.MINUTES).until(() -> computer.getLog() + .contains("listening to metadata for preemption event")); - client.simulateMaintenanceEvent(PROJECT_ID, ZONE, name); - Awaitility.await().timeout(8, TimeUnit.MINUTES).until(computer::getPreempted); + client.simulateMaintenanceEvent(PROJECT_ID, ZONE, name); + Awaitility.await().timeout(8, TimeUnit.MINUTES).until(computer::getPreempted); - freeStyleBuild = taskFuture.get(); - assertEquals(FAILURE, freeStyleBuild.getResult()); - tailLog.waitForCompletion(); - } + freeStyleBuild = taskFuture.get(); + assertEquals(FAILURE, freeStyleBuild.getResult()); Awaitility.await().timeout(5, TimeUnit.MINUTES).until(() -> freeStyleBuild.getNextBuild() != null); // build2 gets automatically scheduled and succeeds - try (var tailLog = new TailLog(jenkinsRule, "p", 2).withColor(PrefixedOutputStream.Color.YELLOW)) { - FreeStyleBuild nextBuild = freeStyleBuild.getNextBuild(); - Awaitility.await().timeout(5, TimeUnit.MINUTES).until(() -> nextBuild.getResult() != null); - assertEquals(SUCCESS, nextBuild.getResult()); - tailLog.waitForCompletion(); - } + FreeStyleBuild nextBuild = freeStyleBuild.getNextBuild(); + Awaitility.await().timeout(5, TimeUnit.MINUTES).until(() -> nextBuild.getResult() != null); + assertEquals(SUCCESS, nextBuild.getResult()); } } diff --git a/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudSnapshotCreatedIT.java b/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudSnapshotCreatedIT.java index 5049452d..ed088f56 100644 --- a/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudSnapshotCreatedIT.java +++ b/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudSnapshotCreatedIT.java @@ -54,6 +54,7 @@ import org.junit.ClassRule; import org.junit.Test; import org.junit.rules.Timeout; +import org.jvnet.hudson.test.BuildWatcher; import org.jvnet.hudson.test.JenkinsRule; /** @@ -70,8 +71,11 @@ public class ComputeEngineCloudSnapshotCreatedIT { @ClassRule public static JenkinsRule jenkinsRule = new JenkinsRule(); + @ClassRule + public static BuildWatcher bw = new BuildWatcher(); + private static ComputeClient client; - private static Map label = getLabel(ComputeEngineCloudSnapshotCreatedIT.class); + private static final Map label = getLabel(ComputeEngineCloudSnapshotCreatedIT.class); private static Snapshot createdSnapshot = null; @BeforeClass diff --git a/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudTemplateNoGoogleLabelsIT.java b/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudTemplateNoGoogleLabelsIT.java index e8d8093c..ac1d9bac 100644 --- a/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudTemplateNoGoogleLabelsIT.java +++ b/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudTemplateNoGoogleLabelsIT.java @@ -57,18 +57,18 @@ * still present on the created instance. */ public class ComputeEngineCloudTemplateNoGoogleLabelsIT { - private static Logger log = Logger.getLogger(ComputeEngineCloudTemplateNoGoogleLabelsIT.class.getName()); + private static final Logger log = Logger.getLogger(ComputeEngineCloudTemplateNoGoogleLabelsIT.class.getName()); private static final String TEMPLATE = format("projects/%s/global/instanceTemplates/test-template-no-labels"); @ClassRule - public static Timeout timeout = new Timeout(5 * TEST_TIMEOUT_MULTIPLIER, TimeUnit.MINUTES); + public static Timeout timeout = new Timeout(5L * TEST_TIMEOUT_MULTIPLIER, TimeUnit.MINUTES); @ClassRule public static JenkinsRule jenkinsRule = new JenkinsRule(); private static ComputeClient client; - private static Map label = getLabel(ComputeEngineCloudTemplateNoGoogleLabelsIT.class); + private static final Map label = getLabel(ComputeEngineCloudTemplateNoGoogleLabelsIT.class); private static ComputeEngineCloud cloud; private static Instance instance; diff --git a/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudWorkerCreatedIT.java b/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudWorkerCreatedIT.java index 68c44998..391306ca 100644 --- a/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudWorkerCreatedIT.java +++ b/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudWorkerCreatedIT.java @@ -54,9 +54,8 @@ import org.junit.ClassRule; import org.junit.Test; import org.junit.rules.Timeout; +import org.jvnet.hudson.test.BuildWatcher; import org.jvnet.hudson.test.JenkinsRule; -import org.jvnet.hudson.test.PrefixedOutputStream; -import org.jvnet.hudson.test.TailLog; /** * Integration test suite for {@link ComputeEngineCloud}. This verifies the default case for an @@ -72,9 +71,12 @@ public class ComputeEngineCloudWorkerCreatedIT { @ClassRule public static JenkinsRule jenkinsRule = new JenkinsRule(); + @ClassRule + public static BuildWatcher bw = new BuildWatcher(); + private static ComputeClient client; private static ComputeEngineCloud cloud; - private static Map label = getLabel(ComputeEngineCloudWorkerCreatedIT.class); + private static final Map label = getLabel(ComputeEngineCloudWorkerCreatedIT.class); private static InstanceConfiguration instanceConfiguration; @BeforeClass @@ -135,16 +137,13 @@ public void smokes() throws IOException, ExecutionException, InterruptedExceptio public void testWorkerCanExecuteBuild() throws Exception { var p = jenkinsRule.createProject(WorkflowJob.class, "p"); p.setDefinition(new CpsFlowDefinition("node('" + LABEL + "') { sh 'date' }", true)); - try (var tailLog = new TailLog(jenkinsRule, "p", 1).withColor(PrefixedOutputStream.Color.MAGENTA)) { - var r = jenkinsRule.buildAndAssertSuccess(p); - assertEquals(1, jenkinsRule.jenkins.getNodes().size()); - Node node = jenkinsRule.jenkins.getNodes().get(0); - var instance = client.getInstance(PROJECT_ID, ZONE, node.getNodeName()); - tailLog.waitForCompletion(); - assertThat( - "Build did not run on GCP agent", - JenkinsRule.getLog(r), - is(containsString("Running on " + instance.getName()))); - } + var r = jenkinsRule.buildAndAssertSuccess(p); + assertEquals(1, jenkinsRule.jenkins.getNodes().size()); + Node node = jenkinsRule.jenkins.getNodes().get(0); + var instance = client.getInstance(PROJECT_ID, ZONE, node.getNodeName()); + assertThat( + "Build did not run on GCP agent", + JenkinsRule.getLog(r), + is(containsString("Running on " + instance.getName()))); } } diff --git a/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudWorkerFailedIT.java b/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudWorkerFailedIT.java index 1d835847..9f8958bc 100644 --- a/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudWorkerFailedIT.java +++ b/src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudWorkerFailedIT.java @@ -61,7 +61,7 @@ public class ComputeEngineCloudWorkerFailedIT { public static JenkinsRule jenkinsRule = new JenkinsRule(); private static ComputeClient client; - private static Map label = getLabel(ComputeEngineCloudWorkerFailedIT.class); + private static final Map label = getLabel(ComputeEngineCloudWorkerFailedIT.class); private static Collection planned; @BeforeClass diff --git a/src/test/java/com/google/jenkins/plugins/computeengine/integration/ConfigAsCodeNonStandardJavaIT.java b/src/test/java/com/google/jenkins/plugins/computeengine/integration/ConfigAsCodeNonStandardJavaIT.java index 7b6ecc59..e7ae3a7d 100644 --- a/src/test/java/com/google/jenkins/plugins/computeengine/integration/ConfigAsCodeNonStandardJavaIT.java +++ b/src/test/java/com/google/jenkins/plugins/computeengine/integration/ConfigAsCodeNonStandardJavaIT.java @@ -31,6 +31,7 @@ import org.junit.ClassRule; import org.junit.Test; import org.junit.rules.Timeout; +import org.jvnet.hudson.test.BuildWatcher; import org.jvnet.hudson.test.JenkinsRule; /** @@ -46,8 +47,11 @@ public class ConfigAsCodeNonStandardJavaIT { @ClassRule public static Timeout timeout = new Timeout(5L * TEST_TIMEOUT_MULTIPLIER, TimeUnit.MINUTES); + @ClassRule + public static BuildWatcher bw = new BuildWatcher(); + private static ComputeClient client; - private static Map label = getLabel(ConfigAsCodeNonStandardJavaIT.class); + private static final Map label = getLabel(ConfigAsCodeNonStandardJavaIT.class); @BeforeClass public static void init() throws Exception { @@ -90,6 +94,7 @@ public void testNonStandardJavaWorkerCreated() throws Exception { FreeStyleProject project = jenkinsRule.createFreeStyleProject(); Builder step = execute(Commands.ECHO, "works"); project.getBuildersList().add(step); + project.setAssignedLabel(new LabelAtom("integration-non-standard-java")); jenkinsRule.buildAndAssertSuccess(project); } }