From f8bb97fbafd1d39c21fc42e317233b815c0d384a Mon Sep 17 00:00:00 2001 From: Neeraja Potluri Date: Mon, 20 Feb 2023 09:51:58 -0600 Subject: [PATCH 01/28] make the compile work --- .../nodesharingbackend/NoopChannel.java | 2 +- pom.xml | 33 +++++++++++++++---- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/backend-plugin/src/main/java/com/redhat/jenkins/nodesharingbackend/NoopChannel.java b/backend-plugin/src/main/java/com/redhat/jenkins/nodesharingbackend/NoopChannel.java index cd7e601b..8ef6d9d3 100644 --- a/backend-plugin/src/main/java/com/redhat/jenkins/nodesharingbackend/NoopChannel.java +++ b/backend-plugin/src/main/java/com/redhat/jenkins/nodesharingbackend/NoopChannel.java @@ -130,7 +130,7 @@ private NoopChannel(ChannelBuilder settings, CommandTransport transport) throws } @Override - public boolean preloadJar(Callable classLoaderRef, Class... classesInJar) { + public boolean preloadJar(Callable classLoaderRef, Class... classesInJar) { throw new UnsupportedOperationException(); // $COVERAGE-IGNORE$ } diff --git a/pom.xml b/pom.xml index d1e23bf5..7be0c06b 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ org.jenkins-ci.plugins plugin - 3.33 + 4.45 org.jenkins-ci.plugins.nodesharing @@ -199,22 +199,41 @@ https://repo.jenkins-ci.org/public/ - + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 1.4.1 + + + enforce-bytecode-version + none + + + display-info + none + + + + + scm:git:git://github.com/jenkinsci/node-sharing-plugin.git scm:git:git@github.com:jenkinsci/node-sharing-plugin.git https://github.com/jenkinsci/node-sharing-plugin - parent-1.2.6 + parent-1.2.9 - 2.60.3 - 8 - 2.40 + 2.332.4 + 11 + 1922.v91779ee45b_5e UTF-8 false false 0.5C - 1.36 + 1569.vb_72405b_80249 From 5c6e1d7d9189c8774f44bfb3b52f2362b5c60ebe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Gond=C5=BEa?= Date: Wed, 22 Feb 2023 10:10:03 +0100 Subject: [PATCH 02/28] Resolve enforcer issues instead of suppressing it --- .../SharedOnceRetentionStrategy.java | 4 ++-- pom.xml | 21 +------------------ 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/plugin/src/main/java/com/redhat/jenkins/nodesharingfrontend/SharedOnceRetentionStrategy.java b/plugin/src/main/java/com/redhat/jenkins/nodesharingfrontend/SharedOnceRetentionStrategy.java index e4070c04..06e0b103 100644 --- a/plugin/src/main/java/com/redhat/jenkins/nodesharingfrontend/SharedOnceRetentionStrategy.java +++ b/plugin/src/main/java/com/redhat/jenkins/nodesharingfrontend/SharedOnceRetentionStrategy.java @@ -13,8 +13,8 @@ import hudson.slaves.AbstractCloudSlave; import hudson.slaves.CloudRetentionStrategy; import hudson.slaves.OfflineCause; -import hudson.util.TimeUnit2; +import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; @@ -43,7 +43,7 @@ public long check(final AbstractCloudComputer c) { // terminate. If it's not already trying to terminate then lets terminate manually. if (c.isIdle() && !disabled) { final long idleMilliseconds = System.currentTimeMillis() - c.getIdleStartMilliseconds(); - if (idleMilliseconds > TimeUnit2.MINUTES.toMillis(idleMinutes)) { + if (idleMilliseconds > TimeUnit.MINUTES.toMillis(idleMinutes)) { LOGGER.log(Level.INFO, "Disconnecting {0}", c.getName()); done(c); } diff --git a/pom.xml b/pom.xml index 7be0c06b..2cc97744 100644 --- a/pom.xml +++ b/pom.xml @@ -199,26 +199,7 @@ https://repo.jenkins-ci.org/public/ - - - - - org.apache.maven.plugins - maven-enforcer-plugin - 1.4.1 - - - enforce-bytecode-version - none - - - display-info - none - - - - - + scm:git:git://github.com/jenkinsci/node-sharing-plugin.git scm:git:git@github.com:jenkinsci/node-sharing-plugin.git From 86c2cffebb521e8210a142dd0222a9c9abb3bff8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Gond=C5=BEa?= Date: Wed, 22 Feb 2023 10:11:42 +0100 Subject: [PATCH 03/28] Update plugin descriptions --- backend-plugin/src/main/resources/index.jelly | 4 ++++ plugin/src/main/resources/index.jelly | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 backend-plugin/src/main/resources/index.jelly diff --git a/backend-plugin/src/main/resources/index.jelly b/backend-plugin/src/main/resources/index.jelly new file mode 100644 index 00000000..daffae7c --- /dev/null +++ b/backend-plugin/src/main/resources/index.jelly @@ -0,0 +1,4 @@ + +
+ Share machines as Jenkins agents across multiple Jenkins masters. This plugin maintains the nodes in the share pool of preconfigured machines. +
diff --git a/plugin/src/main/resources/index.jelly b/plugin/src/main/resources/index.jelly index db9975f5..9a3850fb 100644 --- a/plugin/src/main/resources/index.jelly +++ b/plugin/src/main/resources/index.jelly @@ -3,5 +3,5 @@ This view is used to render the installed plugins page. -->
- This plugin consumes nodes shared by pool of preconfigured machines. + Share machines as Jenkins agents across multiple Jenkins masters. This plugin consumes nodes from the share pool of preconfigured machines.
From c8cca55921c0041cb742304b5512b94c9b621f88 Mon Sep 17 00:00:00 2001 From: Neeraja Potluri Date: Wed, 22 Feb 2023 07:54:34 -0600 Subject: [PATCH 04/28] remove jenkins-test-harness dependency --- pom.xml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pom.xml b/pom.xml index 2cc97744..200e2987 100644 --- a/pom.xml +++ b/pom.xml @@ -72,11 +72,6 @@ symbol-annotation 1.7 - - org.jenkins-ci.main - jenkins-test-harness - 2.56 - org.jenkins-ci.modules instance-identity @@ -210,7 +205,6 @@ 2.332.4 11 - 1922.v91779ee45b_5e UTF-8 false false From c458991301f0a5a90c11e9b140932a28685c13a2 Mon Sep 17 00:00:00 2001 From: Neeraja Potluri Date: Mon, 27 Feb 2023 09:53:50 -0600 Subject: [PATCH 05/28] changed to import bom for artifact versions --- jth-tests/pom.xml | 12 ++----- nodesharing-lib/pom.xml | 49 +++++++++++++++++++++++++++ pom.xml | 75 +++++++++++------------------------------ 3 files changed, 72 insertions(+), 64 deletions(-) diff --git a/jth-tests/pom.xml b/jth-tests/pom.xml index 706b927d..828b089e 100644 --- a/jth-tests/pom.xml +++ b/jth-tests/pom.xml @@ -60,12 +60,10 @@ org.jenkins-ci.plugins matrix-project - 1.12 org.jenkins-ci.plugins matrix-auth - 2.6.6 org.jenkins-ci.plugins @@ -74,13 +72,9 @@ io.jenkins configuration-as-code - 1.2 - - - io.jenkins.configuration-as-code - configuration-as-code-support - 1.2 + ${configuration-as-code.version} + org.jenkins-ci.plugins job-dsl @@ -91,7 +85,7 @@ org.apache.httpcomponents httpcore - 4.4.4 + 4.4.14 org.codehaus.groovy diff --git a/nodesharing-lib/pom.xml b/nodesharing-lib/pom.xml index f5326e42..605bd7cb 100644 --- a/nodesharing-lib/pom.xml +++ b/nodesharing-lib/pom.xml @@ -21,6 +21,55 @@ com.google.code.gson gson + + + org.jenkins-ci.plugins + credentials + + + + org.jenkins-ci.plugins + resource-disposer + + + + org.jenkins-ci.plugins + script-security + + + + org.jenkins-ci.plugins + ssh-credentials + + + + org.jenkins-ci.plugins + ssh-slaves + + + + org.jenkins-ci.plugins + ws-cleanup + + + + org.jenkins-ci.plugins + structs + + + + org.jenkins-ci.plugins + git-client + + + + + + org.jenkins-ci.modules + sshd + + test + diff --git a/pom.xml b/pom.xml index 200e2987..68f5b7b3 100644 --- a/pom.xml +++ b/pom.xml @@ -62,6 +62,18 @@ + + io.jenkins.tools.bom + bom-2.332.x + 1181.v04b_21d4b_0d6c + import + pom + + + org.json + json + 20210307 + org.jenkins-ci annotation-indexer @@ -87,41 +99,6 @@ cloud-stats 0.20 - - org.jenkins-ci.plugins - credentials - 2.1.16 - - - org.jenkins-ci.plugins - resource-disposer - 0.12 - - - org.jenkins-ci.plugins - script-security - 1.25 - - - org.jenkins-ci.plugins - ssh-credentials - 1.13 - - - org.jenkins-ci.plugins - ssh-slaves - 1.10 - - - org.jenkins-ci.plugins - ws-cleanup - 0.36 - - - org.jenkins-ci.plugins - structs - 1.7 - @@ -134,12 +111,16 @@ test-harness ${configuration-as-code.version} - + + io.jenkins.configuration-as-code + configuration-as-code-support + 1.19 + com.google.code.gson gson - 2.8.0 + 2.8.7 commons-codec @@ -149,27 +130,11 @@ org.apache.httpcomponents httpclient - 4.5.2 + - - - org.jenkins-ci.plugins - git-client - 1.17.1 - - - - - org.jenkins-ci.modules - sshd - 2.0 - test - - - repo.jenkins-ci.org @@ -209,6 +174,6 @@ false false 0.5C - 1569.vb_72405b_80249 + 1.55.1 From e1dbf79e98252e33c28c092fd2ec7039ad218aa0 Mon Sep 17 00:00:00 2001 From: Neeraja Potluri Date: Mon, 27 Feb 2023 13:49:50 -0600 Subject: [PATCH 06/28] command launcher dependency add --- jth-tests/pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/jth-tests/pom.xml b/jth-tests/pom.xml index 828b089e..922ad5bb 100644 --- a/jth-tests/pom.xml +++ b/jth-tests/pom.xml @@ -26,6 +26,11 @@ + + org.jenkins-ci.plugins + command-launcher + 1.5 + commons-codec commons-codec From 222ed6b9fb2d134a69e8ac9032285baf35d71944 Mon Sep 17 00:00:00 2001 From: Neeraja Potluri Date: Mon, 27 Feb 2023 13:51:12 -0600 Subject: [PATCH 07/28] fix dependency for command launch --- pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pom.xml b/pom.xml index 68f5b7b3..0a653982 100644 --- a/pom.xml +++ b/pom.xml @@ -74,6 +74,11 @@ json 20210307 + + org.jenkins-ci.plugins + command-launcher + 1.5 + org.jenkins-ci annotation-indexer From dea8ab9a0e6ab0998dea64c79d2b7413ad4bf991 Mon Sep 17 00:00:00 2001 From: Neeraja Potluri Date: Tue, 28 Feb 2023 07:32:56 -0600 Subject: [PATCH 08/28] fix ambiguity --- .../com/redhat/jenkins/nodesharing/ReservationTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/ReservationTest.java b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/ReservationTest.java index 1b3c71a5..c833d484 100644 --- a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/ReservationTest.java +++ b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/ReservationTest.java @@ -200,7 +200,7 @@ public void reflectChangesInWorkloadReported() throws Exception { List scheduledReservations = j.getQueuedReservations(); assertThat(scheduledReservations, Matchers.iterableWithSize(2)); - Queue.Item[] items = Jenkins.getInstance().getQueue().getItems(); + Queue.Item[] items = Jenkins.get().getQueue().getItems(); assertThat(items, arrayWithSize(4)); // Executor items assertEquals("remove", items[3].task.getName()); @@ -219,7 +219,7 @@ public void reflectChangesInWorkloadReported() throws Exception { List scheduledReservations = j.getQueuedReservations(); assertThat(scheduledReservations, Matchers.iterableWithSize(2)); - Queue.Item[] items = Jenkins.getInstance().getQueue().getItems(); + Queue.Item[] items = Jenkins.get().getQueue().getItems(); assertThat(items, arrayWithSize(4)); assertEquals("keep", items[3].task.getName()); @@ -232,7 +232,7 @@ public void reflectChangesInWorkloadReported() throws Exception { public void buildWithNoLabelShouldNotBeBuilt() throws Exception { j.singleJvmGrid(j.jenkins); SharedNodeCloud cloud = j.addSharedNodeCloud(Pool.getInstance().getConfigRepoUrl()); - assertFalse(cloud.canProvision(null)); + assertFalse(cloud.canProvision((Label) null)); j.jenkins.setNumExecutors(0); FreeStyleProject p = j.createFreeStyleProject(); From 2febc62d6b05fc64449067768b9c8473e9cbc60c Mon Sep 17 00:00:00 2001 From: Neeraja Potluri Date: Tue, 28 Feb 2023 08:31:41 -0600 Subject: [PATCH 09/28] fix the deprecated message --- .../java/com/redhat/jenkins/nodesharing/ReservationTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/ReservationTest.java b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/ReservationTest.java index c833d484..14bf4310 100644 --- a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/ReservationTest.java +++ b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/ReservationTest.java @@ -200,7 +200,7 @@ public void reflectChangesInWorkloadReported() throws Exception { List scheduledReservations = j.getQueuedReservations(); assertThat(scheduledReservations, Matchers.iterableWithSize(2)); - Queue.Item[] items = Jenkins.get().getQueue().getItems(); + Queue.Item[] items = Jenkins.getInstanceOrNull().getQueue().getItems(); assertThat(items, arrayWithSize(4)); // Executor items assertEquals("remove", items[3].task.getName()); @@ -219,7 +219,7 @@ public void reflectChangesInWorkloadReported() throws Exception { List scheduledReservations = j.getQueuedReservations(); assertThat(scheduledReservations, Matchers.iterableWithSize(2)); - Queue.Item[] items = Jenkins.get().getQueue().getItems(); + Queue.Item[] items = Jenkins.getInstanceOrNull().getQueue().getItems(); assertThat(items, arrayWithSize(4)); assertEquals("keep", items[3].task.getName()); From 8f86270395caf82a1a15ee9f0c0be39095f1e9e4 Mon Sep 17 00:00:00 2001 From: Neeraja Potluri Date: Tue, 28 Feb 2023 14:03:10 -0600 Subject: [PATCH 10/28] cleaned specific versions --- backend-plugin/pom.xml | 3 +- jth-tests/pom.xml | 18 +-- nodesharing-lib/pom.xml | 52 +-------- plugin/pom.xml | 5 +- pom.xml | 238 ++++++++++++++++++++++++---------------- 5 files changed, 161 insertions(+), 155 deletions(-) diff --git a/backend-plugin/pom.xml b/backend-plugin/pom.xml index 9340fb7b..4810664a 100644 --- a/backend-plugin/pom.xml +++ b/backend-plugin/pom.xml @@ -19,6 +19,7 @@ org.jenkins-ci.plugins.nodesharing node-sharing-lib + ${project.version} io.jenkins @@ -40,4 +41,4 @@ - + \ No newline at end of file diff --git a/jth-tests/pom.xml b/jth-tests/pom.xml index 922ad5bb..520dcf68 100644 --- a/jth-tests/pom.xml +++ b/jth-tests/pom.xml @@ -15,22 +15,20 @@ org.jenkins-ci.plugins.nodesharing node-sharing-executor + ${project.version} org.jenkins-ci.plugins.nodesharing node-sharing-orchestrator + ${project.version} org.jenkins-ci.plugins.nodesharing node-sharing-lib + ${project.version} - - org.jenkins-ci.plugins - command-launcher - 1.5 - commons-codec commons-codec @@ -38,6 +36,7 @@ com.google.code.gson gson + 2.8.7 com.offbytwo.jenkins @@ -60,7 +59,6 @@ org.hamcrest hamcrest-core - 2.1 org.jenkins-ci.plugins @@ -79,7 +77,11 @@ configuration-as-code ${configuration-as-code.version} - + + io.jenkins.configuration-as-code + configuration-as-code-support + 1.19 + org.jenkins-ci.plugins job-dsl @@ -153,4 +155,4 @@ - + \ No newline at end of file diff --git a/nodesharing-lib/pom.xml b/nodesharing-lib/pom.xml index 605bd7cb..3ad63e0e 100644 --- a/nodesharing-lib/pom.xml +++ b/nodesharing-lib/pom.xml @@ -20,56 +20,8 @@ com.google.code.gson gson + 2.8.7 - - - org.jenkins-ci.plugins - credentials - - - - org.jenkins-ci.plugins - resource-disposer - - - - org.jenkins-ci.plugins - script-security - - - - org.jenkins-ci.plugins - ssh-credentials - - - - org.jenkins-ci.plugins - ssh-slaves - - - - org.jenkins-ci.plugins - ws-cleanup - - - - org.jenkins-ci.plugins - structs - - - - org.jenkins-ci.plugins - git-client - - - - - - org.jenkins-ci.modules - sshd - - test - @@ -87,4 +39,4 @@ - + \ No newline at end of file diff --git a/plugin/pom.xml b/plugin/pom.xml index 9ccc5504..4710d8f9 100644 --- a/plugin/pom.xml +++ b/plugin/pom.xml @@ -21,10 +21,12 @@ org.jenkins-ci.plugins cloud-stats + 0.27 org.jenkins-ci.plugins.nodesharing node-sharing-lib + ${project.version} org.jenkins-ci.plugins @@ -62,6 +64,7 @@ com.google.code.gson gson + 2.8.7 @@ -73,4 +76,4 @@ - + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 0a653982..0de76463 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,18 @@ 4.0.0 + + + + + io.jenkins.tools.bom + bom-2.332.x + 1181.v04b_21d4b_0d6c + import + pom + + + + org.jenkins-ci.plugins plugin @@ -40,105 +53,139 @@ ogondza@gmail.com + - - + - - org.jenkins-ci.plugins.nodesharing - node-sharing-executor - ${project.version} - - - org.jenkins-ci.plugins.nodesharing - node-sharing-lib - ${project.version} - - - org.jenkins-ci.plugins.nodesharing - node-sharing-orchestrator - ${project.version} - + --> - - - io.jenkins.tools.bom - bom-2.332.x - 1181.v04b_21d4b_0d6c - import - pom - - - org.json - json - 20210307 - - - org.jenkins-ci.plugins - command-launcher - 1.5 - - - org.jenkins-ci - annotation-indexer - 1.11 - - - org.jenkins-ci - symbol-annotation - 1.7 - - - org.jenkins-ci.modules - instance-identity - 2.1 - - - org.jenkins-ci.modules - ssh-cli-auth - 1.4 - - - org.jenkins-ci.plugins - cloud-stats - 0.20 - + + + org.jenkins-ci + annotation-indexer + + + org.jenkins-ci + symbol-annotation + + + org.jenkins-ci.main + jenkins-test-harness + 2.72 + + + org.jenkins-ci.modules + instance-identity + + + org.jenkins-ci.modules + ssh-cli-auth + 1.4 + + + org.jenkins-ci.plugins + cloud-stats + 0.27 + + + org.jenkins-ci.plugins + credentials + + + org.jenkins-ci.plugins + resource-disposer + + + org.jenkins-ci.plugins + script-security + + + org.jenkins-ci.plugins + ssh-credentials + + + org.jenkins-ci.plugins + ssh-slaves + + + org.jenkins-ci.plugins + ws-cleanup + + + org.jenkins-ci.plugins + structs + + + org.jenkins-ci.plugins + git-client + + + org.jenkins-ci.plugins + command-launcher + - - - io.jenkins - configuration-as-code - ${configuration-as-code.version} - - - io.jenkins.configuration-as-code - test-harness - ${configuration-as-code.version} - - - io.jenkins.configuration-as-code - configuration-as-code-support - 1.19 - - - - com.google.code.gson - gson - 2.8.7 - - - commons-codec - commons-codec - 1.11 - - - org.apache.httpcomponents - httpclient - + + + io.jenkins + configuration-as-code + test + + + io.jenkins.configuration-as-code + test-harness + test + - - + + + com.google.code.gson + gson + 2.8.7 + + + commons-codec + commons-codec + + + org.apache.httpcomponents + httpclient + 4.5.13 + + + org.apache.httpcomponents + httpcore + 4.4.14 + + + org.json + json + 20210307 + + + + @@ -175,10 +222,11 @@ 2.332.4 11 + 2.40 UTF-8 false false 0.5C 1.55.1 - + \ No newline at end of file From 1212ec297e51fd2754692b2aefc6e4b26e3aec94 Mon Sep 17 00:00:00 2001 From: Neeraja Potluri Date: Wed, 1 Mar 2023 06:38:44 -0600 Subject: [PATCH 11/28] replaces getInstance() with get() --- .../java/com/redhat/jenkins/nodesharing/ReservationTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/ReservationTest.java b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/ReservationTest.java index 14bf4310..c833d484 100644 --- a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/ReservationTest.java +++ b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/ReservationTest.java @@ -200,7 +200,7 @@ public void reflectChangesInWorkloadReported() throws Exception { List scheduledReservations = j.getQueuedReservations(); assertThat(scheduledReservations, Matchers.iterableWithSize(2)); - Queue.Item[] items = Jenkins.getInstanceOrNull().getQueue().getItems(); + Queue.Item[] items = Jenkins.get().getQueue().getItems(); assertThat(items, arrayWithSize(4)); // Executor items assertEquals("remove", items[3].task.getName()); @@ -219,7 +219,7 @@ public void reflectChangesInWorkloadReported() throws Exception { List scheduledReservations = j.getQueuedReservations(); assertThat(scheduledReservations, Matchers.iterableWithSize(2)); - Queue.Item[] items = Jenkins.getInstanceOrNull().getQueue().getItems(); + Queue.Item[] items = Jenkins.get().getQueue().getItems(); assertThat(items, arrayWithSize(4)); assertEquals("keep", items[3].task.getName()); From d6ee563a3cafa26c3f5cfab9043e768fe609b6f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Gond=C5=BEa?= Date: Wed, 1 Mar 2023 14:21:09 +0100 Subject: [PATCH 12/28] Fix config repo init branch --- .../java/com/redhat/jenkins/nodesharing/utils/TestUtils.java | 1 + 1 file changed, 1 insertion(+) diff --git a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/utils/TestUtils.java b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/utils/TestUtils.java index e52e102f..cc17efff 100644 --- a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/utils/TestUtils.java +++ b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/utils/TestUtils.java @@ -64,6 +64,7 @@ public static GitClient createConfigRepo() throws URISyntaxException, IOExceptio EnvVars env = new EnvVars("GIT_AUTHOR_NAME", name, "GIT_AUTHOR_EMAIL", mail, "GIT_COMMITTER_NAME", name, "GIT_COMMITTER_EMAIL", mail); GitClient git = Git.with(listener, env).in(repo).using("git").getClient(); git.init(); + git.checkout().branch("master").execute(); // Enforce branch name so this is not impacted by git config of `init.defaultBranch` git.add("*"); git.commit("Init"); return git; From 3366ba837095681779e9112ae83726bf26755cef Mon Sep 17 00:00:00 2001 From: Neeraja Potluri Date: Wed, 1 Mar 2023 17:01:35 -0600 Subject: [PATCH 13/28] few additional updates --- jth-tests/pom.xml | 22 +------- .../redhat/jenkins/nodesharing/PoolTest.java | 10 +++- .../nodesharing/ReservationVerifierTest.java | 2 +- nodesharing-lib/pom.xml | 5 -- plugin/pom.xml | 6 +- pom.xml | 56 ++++--------------- 6 files changed, 23 insertions(+), 78 deletions(-) diff --git a/jth-tests/pom.xml b/jth-tests/pom.xml index 520dcf68..216ad079 100644 --- a/jth-tests/pom.xml +++ b/jth-tests/pom.xml @@ -33,11 +33,7 @@ commons-codec commons-codec - - com.google.code.gson - gson - 2.8.7 - + com.offbytwo.jenkins jenkins-client @@ -54,7 +50,7 @@ org.mockito mockito-core - 1.9.5 + 5.1.1 org.hamcrest @@ -75,7 +71,6 @@ io.jenkins configuration-as-code - ${configuration-as-code.version} io.jenkins.configuration-as-code @@ -88,17 +83,6 @@ 1.66 - - - org.apache.httpcomponents - httpcore - 4.4.14 - - - org.codehaus.groovy - groovy-all - 2.4.8 - @@ -107,7 +91,7 @@ org.apache.maven.plugins maven-deploy-plugin - 2.8.2 + 3.1.0 true diff --git a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/PoolTest.java b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/PoolTest.java index 43e8c210..dbf2920b 100644 --- a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/PoolTest.java +++ b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/PoolTest.java @@ -54,7 +54,6 @@ import org.junit.Rule; import org.junit.Test; import org.mockito.Mockito; -import org.mockito.internal.util.reflection.Whitebox; import javax.servlet.http.HttpServletResponse; import java.io.File; @@ -112,7 +111,14 @@ public void inactiveWithNoProperty() throws Exception { private void eraseLoadConfig() throws IOException { // There is meaningful value set from startup - erase it - Whitebox.setInternalState(Pool.getInstance(), "config", null); + try { + org.apache.commons.lang3.reflect.FieldUtils.writeField(Pool.getInstance(), "config", null, true); + } catch (IllegalArgumentException ex) { + //setInternalState(Pool.getInstance(), "config", null); + } + catch (IllegalAccessException ex) { + //setInternalState(Pool.getInstance(), "config", null); + } j.jenkins.setNodes(Collections.emptyList()); } diff --git a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/ReservationVerifierTest.java b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/ReservationVerifierTest.java index e137df33..1e0d3257 100644 --- a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/ReservationVerifierTest.java +++ b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/ReservationVerifierTest.java @@ -53,7 +53,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; diff --git a/nodesharing-lib/pom.xml b/nodesharing-lib/pom.xml index 3ad63e0e..e0366fa2 100644 --- a/nodesharing-lib/pom.xml +++ b/nodesharing-lib/pom.xml @@ -17,11 +17,6 @@ commons-codec commons-codec - - com.google.code.gson - gson - 2.8.7 - diff --git a/plugin/pom.xml b/plugin/pom.xml index 4710d8f9..3dcb3cad 100644 --- a/plugin/pom.xml +++ b/plugin/pom.xml @@ -61,11 +61,7 @@ commons-codec commons-codec - - com.google.code.gson - gson - 2.8.7 - + diff --git a/pom.xml b/pom.xml index 0de76463..1c39defb 100644 --- a/pom.xml +++ b/pom.xml @@ -5,8 +5,8 @@ io.jenkins.tools.bom - bom-2.332.x - 1181.v04b_21d4b_0d6c + bom-2.387.x + 1841.v7b_22c5218e1a import pom @@ -16,7 +16,7 @@ org.jenkins-ci.plugins plugin - 4.45 + 4.54 org.jenkins-ci.plugins.nodesharing @@ -55,38 +55,14 @@ - - org.jenkins-ci annotation-indexer - - org.jenkins-ci - symbol-annotation - org.jenkins-ci.main jenkins-test-harness - 2.72 org.jenkins-ci.modules @@ -95,7 +71,7 @@ org.jenkins-ci.modules ssh-cli-auth - 1.4 + 1.8 org.jenkins-ci.plugins @@ -155,7 +131,7 @@ com.google.code.gson gson - 2.8.7 + 2.9.1 commons-codec @@ -169,22 +145,14 @@ org.apache.httpcomponents httpcore - 4.4.14 + 4.4.15 org.json json - 20210307 + 20220320 - - + @@ -216,17 +184,13 @@ scm:git:git://github.com/jenkinsci/node-sharing-plugin.git scm:git:git@github.com:jenkinsci/node-sharing-plugin.git https://github.com/jenkinsci/node-sharing-plugin - parent-1.2.9 + node-sharing-parent-2.0.8
- 2.332.4 + 2.390 11 - 2.40 - UTF-8 false false - 0.5C - 1.55.1 \ No newline at end of file From 6b39f810be4a9e0a3397984a8253a49d4e3f1d98 Mon Sep 17 00:00:00 2001 From: Neeraja Potluri Date: Mon, 6 Mar 2023 08:18:41 -0600 Subject: [PATCH 14/28] fix depricated getInstance() --- .../com/redhat/jenkins/nodesharingbackend/Api.java | 14 +++++++------- .../jenkins/nodesharingbackend/Dashboard.java | 2 +- .../nodesharingbackend/JCasCCompatibilityTest.java | 2 +- .../com/redhat/jenkins/nodesharing/GridTest.java | 2 +- .../nodesharing/transport/ReportWorkloadTest.java | 2 +- pom.xml | 10 ++++++++-- 6 files changed, 19 insertions(+), 13 deletions(-) diff --git a/backend-plugin/src/main/java/com/redhat/jenkins/nodesharingbackend/Api.java b/backend-plugin/src/main/java/com/redhat/jenkins/nodesharingbackend/Api.java index 51e46fa0..c3afc661 100644 --- a/backend-plugin/src/main/java/com/redhat/jenkins/nodesharingbackend/Api.java +++ b/backend-plugin/src/main/java/com/redhat/jenkins/nodesharingbackend/Api.java @@ -85,7 +85,7 @@ public Api() { // PJ: Not working, during JUnit phase execution there aren't made packages... InputStream resource = this.getClass().getClassLoader().getResourceAsStream("nodesharingbackend.properties"); if (resource == null) { - version = Jenkins.getInstance().pluginManager.whichPlugin(getClass()).getVersion(); + version = Jenkins.get().pluginManager.whichPlugin(getClass()).getVersion(); } else { Properties properties = new Properties(); properties.load(resource); @@ -98,7 +98,7 @@ public Api() { } public static @Nonnull Api getInstance() { - ExtensionList list = Jenkins.getInstance().getExtensionList(Api.class); + ExtensionList list = Jenkins.get().getExtensionList(Api.class); assert list.size() == 1; return list.iterator().next(); } @@ -189,7 +189,7 @@ public NodeStatusResponse.Status nodeStatus(@Nonnull final ExecutorJenkins jenki */ @RequirePOST public void doDiscover(StaplerRequest req, StaplerResponse rsp) throws IOException { - Jenkins.getInstance().checkPermission(RestEndpoint.RESERVE); + Jenkins.get().checkPermission(RestEndpoint.RESERVE); Pool pool = Pool.getInstance(); Collection nodes = pool.getConfig().getNodes().values(); // Fail early when there is no config @@ -240,7 +240,7 @@ public void doDiscover(StaplerRequest req, StaplerResponse rsp) throws IOExcepti */ @RequirePOST public void doReportWorkload(@Nonnull final StaplerRequest req, @Nonnull final StaplerResponse rsp) throws IOException { - Jenkins.getInstance().checkPermission(RestEndpoint.RESERVE); + Jenkins.get().checkPermission(RestEndpoint.RESERVE); Pool pool = Pool.getInstance(); final ConfigRepo.Snapshot config = pool.getConfig(); // Fail early when there is no config @@ -264,7 +264,7 @@ public void doReportWorkload(@Nonnull final StaplerRequest req, @Nonnull final S Queue.withLock(new Runnable() { @Override public void run() { - Queue queue = Jenkins.getInstance().getQueue(); + Queue queue = Jenkins.get().getQueue(); for (Queue.Item item : queue.getItems()) { if (item.task instanceof ReservationTask && ((ReservationTask) item.task).getOwner().equals(executor)) { // Cancel items executor is no longer interested in and keep those it cares for @@ -297,7 +297,7 @@ private String unknownExecutor(String executorUrl, String configRepoUrl) { */ @RequirePOST public void doReturnNode(@Nonnull final StaplerRequest req, @Nonnull final StaplerResponse rsp) throws IOException { - Jenkins.getInstance().checkPermission(RestEndpoint.RESERVE); + Jenkins.get().checkPermission(RestEndpoint.RESERVE); String ocr = Pool.getInstance().getConfigRepoUrl(); // Fail early when there is no config ReturnNodeRequest request = Entity.fromInputStream(req.getInputStream(), ReturnNodeRequest.class); @@ -308,7 +308,7 @@ public void doReturnNode(@Nonnull final StaplerRequest req, @Nonnull final Stapl return; } - Jenkins jenkins = Jenkins.getInstance(); + Jenkins jenkins = Jenkins.get(); Computer c = jenkins.getComputer(request.getNodeName()); if (c == null) { LOGGER.info( diff --git a/backend-plugin/src/main/java/com/redhat/jenkins/nodesharingbackend/Dashboard.java b/backend-plugin/src/main/java/com/redhat/jenkins/nodesharingbackend/Dashboard.java index 65d02fdc..332c9e13 100644 --- a/backend-plugin/src/main/java/com/redhat/jenkins/nodesharingbackend/Dashboard.java +++ b/backend-plugin/src/main/java/com/redhat/jenkins/nodesharingbackend/Dashboard.java @@ -51,7 +51,7 @@ public class Dashboard extends View { // It is quite delicate when this is invoked to fit between primary view updates hardcoded in Jenkins class itself @Initializer(after = InitMilestone.JOB_LOADED) public static void registerDashboard() throws IOException { - Jenkins j = Jenkins.getInstance(); + Jenkins j = Jenkins.get(); Dashboard dashboard = new Dashboard(); j.addView(dashboard); j.setPrimaryView(dashboard); diff --git a/backend-plugin/src/test/java/com/redhat/jenkins/nodesharingbackend/JCasCCompatibilityTest.java b/backend-plugin/src/test/java/com/redhat/jenkins/nodesharingbackend/JCasCCompatibilityTest.java index e723a5d3..61217af2 100644 --- a/backend-plugin/src/test/java/com/redhat/jenkins/nodesharingbackend/JCasCCompatibilityTest.java +++ b/backend-plugin/src/test/java/com/redhat/jenkins/nodesharingbackend/JCasCCompatibilityTest.java @@ -9,7 +9,7 @@ import org.junit.Test; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; public class JCasCCompatibilityTest { diff --git a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/GridTest.java b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/GridTest.java index 0c5b16b3..18329d79 100644 --- a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/GridTest.java +++ b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/GridTest.java @@ -55,9 +55,9 @@ import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.matchesPattern; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; @Category(SlowTest.class) diff --git a/nodesharing-lib/src/test/java/com/redhat/jenkins/nodesharing/transport/ReportWorkloadTest.java b/nodesharing-lib/src/test/java/com/redhat/jenkins/nodesharing/transport/ReportWorkloadTest.java index 32fab6bf..359e2751 100644 --- a/nodesharing-lib/src/test/java/com/redhat/jenkins/nodesharing/transport/ReportWorkloadTest.java +++ b/nodesharing-lib/src/test/java/com/redhat/jenkins/nodesharing/transport/ReportWorkloadTest.java @@ -6,8 +6,8 @@ import java.util.List; import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; public class ReportWorkloadTest { diff --git a/pom.xml b/pom.xml index 1c39defb..4633aaa1 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ io.jenkins.tools.bom - bom-2.387.x + bom-2.375.x 1841.v7b_22c5218e1a import pom @@ -152,6 +152,11 @@ json 20220320 + + org.slf4j + slf4j-api + 2.0.5 + @@ -188,8 +193,9 @@ - 2.390 + 2.375.3 11 + 0.5C false false From 087bbf1cca9a207fcf19597bd0723f9a328f729c Mon Sep 17 00:00:00 2001 From: Neeraja Potluri Date: Wed, 8 Mar 2023 13:40:53 -0600 Subject: [PATCH 15/28] add env vars to commandlaunch method --- .../java/com/redhat/jenkins/nodesharing/utils/TestUtils.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/utils/TestUtils.java b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/utils/TestUtils.java index cc17efff..d47163eb 100644 --- a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/utils/TestUtils.java +++ b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/utils/TestUtils.java @@ -122,10 +122,11 @@ public static void declareExecutor(GitClient git, String name, String url) throw // Make the nodes launchable by turning the xml to node, replacing for local launcher and turning it back to xml again public static void makeNodesLaunchable(GitClient git) throws IOException, InterruptedException { final File slaveJar = Which.jarFile(hudson.remoting.Launcher.class).getAbsoluteFile(); + EnvVars env = new EnvVars(); for (FilePath xmlNode : git.getWorkTree().child("nodes").list("*.xml")) { SharedNode node = new SharedNodeFactory.XStreamFactory().create(NodeDefinition.Xml.create(xmlNode)); node.setLauncher(new CommandLauncher( - System.getProperty("java.home") + "/bin/java -jar " + slaveJar + System.getProperty("java.home") + "/bin/java -jar " + slaveJar, env )); try (OutputStream out = xmlNode.write()) { Jenkins.XSTREAM2.toXMLUTF8(node, out); From 47ae24f0eb2b8bb41ccae2856915a51431cfe10a Mon Sep 17 00:00:00 2001 From: Neeraja Potluri Date: Thu, 9 Mar 2023 13:50:50 -0600 Subject: [PATCH 16/28] few more version fixes --- .../dummy_config_repo/nodes/solaris1.acme.com.xml | 2 +- plugin/pom.xml | 3 ++- pom.xml | 6 ++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/jth-tests/src/test/resources/com/redhat/jenkins/nodesharing/dummy_config_repo/nodes/solaris1.acme.com.xml b/jth-tests/src/test/resources/com/redhat/jenkins/nodesharing/dummy_config_repo/nodes/solaris1.acme.com.xml index 9c4fb4d9..b2c5f863 100644 --- a/jth-tests/src/test/resources/com/redhat/jenkins/nodesharing/dummy_config_repo/nodes/solaris1.acme.com.xml +++ b/jth-tests/src/test/resources/com/redhat/jenkins/nodesharing/dummy_config_repo/nodes/solaris1.acme.com.xml @@ -2,7 +2,7 @@ solaris1.acme.com ./var/jenkins-workspace 1 - + 22 diff --git a/plugin/pom.xml b/plugin/pom.xml index 3dcb3cad..fb1d1b86 100644 --- a/plugin/pom.xml +++ b/plugin/pom.xml @@ -21,7 +21,7 @@ org.jenkins-ci.plugins cloud-stats - 0.27 + 267.v577e3742c282 org.jenkins-ci.plugins.nodesharing @@ -46,6 +46,7 @@ org.jenkins-ci annotation-indexer + 1.17 org.jenkins-ci.plugins diff --git a/pom.xml b/pom.xml index a5be0dc0..3ea9472b 100644 --- a/pom.xml +++ b/pom.xml @@ -60,10 +60,12 @@ org.jenkins-ci annotation-indexer + 1.17 org.jenkins-ci.main jenkins-test-harness + 1945.v0efff5a_03b_78 org.jenkins-ci.modules @@ -77,7 +79,7 @@ org.jenkins-ci.plugins cloud-stats - 0.27 + 267.v577e3742c282 org.jenkins-ci.plugins @@ -132,7 +134,7 @@ com.google.code.gson gson - 2.9.1 + 2.10.1 commons-codec From 247805d4720ab730a957a6bf8491d0f8785b46af Mon Sep 17 00:00:00 2001 From: Neeraja Potluri Date: Mon, 13 Mar 2023 09:48:33 -0500 Subject: [PATCH 17/28] fix script approval error --- .../jenkins/nodesharing/SharedNodeCloudTest.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/SharedNodeCloudTest.java b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/SharedNodeCloudTest.java index a24c6dc0..5201973d 100644 --- a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/SharedNodeCloudTest.java +++ b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/SharedNodeCloudTest.java @@ -49,6 +49,8 @@ import hudson.slaves.OfflineCause; import hudson.util.FormValidation; import org.jenkinsci.plugins.gitclient.GitClient; +import org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval; +import org.jenkinsci.plugins.scriptsecurity.scripts.languages.SystemCommandLanguage; import org.junit.Rule; import org.junit.Test; import org.jvnet.hudson.test.LoggerRule; @@ -300,9 +302,12 @@ public void nodeStatusTestOffline() throws Exception { public void nodeStatusTestConnecting() throws Exception { final GitClient gitClient = j.singleJvmGrid(j.jenkins); final SharedNodeCloud cloud = j.addSharedNodeCloud(gitClient.getWorkTree().getRemote()); - + + String command = ((SimpleCommandLauncher) j.createComputerLauncher(null)).cmd; + + ScriptApproval.get().preapprove(command, SystemCommandLanguage.get()); NodeSharingJenkinsRule.BlockingCommandLauncher blockingLauncher = new NodeSharingJenkinsRule.BlockingCommandLauncher( - ((SimpleCommandLauncher) j.createComputerLauncher(null)).cmd + command ); SharedNode connectingSlave = cloud.createNode(cloud.getLatestConfig().getNodes().get("solaris2.acme.com")); @@ -310,6 +315,7 @@ public void nodeStatusTestConnecting() throws Exception { connectingSlave.setNodeName(cloud.getNodeName("aConnectingNode")); j.jenkins.addNode(connectingSlave); assertTrue(connectingSlave.toComputer().isConnecting()); + blockingLauncher.start.block(); checkNodeStatus(cloud, "aConnectingNode", NodeStatusResponse.Status.CONNECTING); From 537af14f0832a9aa9b3feabfca8ec515d7cb809a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Gond=C5=BEa?= Date: Wed, 15 Mar 2023 14:04:11 +0100 Subject: [PATCH 18/28] Do not use CommandLauncher to rewrite node xmls in grid tests It has started depending on ScriptSecurity that is pain to workaround out of Jenkins --- .../jenkins/nodesharing/utils/TestUtils.java | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/utils/TestUtils.java b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/utils/TestUtils.java index d47163eb..b391e890 100644 --- a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/utils/TestUtils.java +++ b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/utils/TestUtils.java @@ -23,16 +23,11 @@ */ package com.redhat.jenkins.nodesharing.utils; -import com.redhat.jenkins.nodesharing.NodeDefinition; -import com.redhat.jenkins.nodesharingfrontend.SharedNode; -import com.redhat.jenkins.nodesharingfrontend.SharedNodeFactory; import hudson.EnvVars; import hudson.FilePath; import hudson.Util; import hudson.remoting.Which; -import hudson.slaves.CommandLauncher; import hudson.util.StreamTaskListener; -import jenkins.model.Jenkins; import org.apache.commons.io.FileUtils; import org.jenkinsci.plugins.gitclient.Git; import org.jenkinsci.plugins.gitclient.GitClient; @@ -41,11 +36,11 @@ import javax.annotation.Nonnull; import java.io.File; import java.io.IOException; -import java.io.OutputStream; import java.net.URISyntaxException; import java.nio.charset.Charset; import java.nio.file.Files; import java.util.Map; +import java.util.regex.Pattern; public class TestUtils { @@ -119,18 +114,17 @@ public static void declareExecutor(GitClient git, String name, String url) throw git.commit("Add Jenkins"); } - // Make the nodes launchable by turning the xml to node, replacing for local launcher and turning it back to xml again + // Make the nodes launchable by replacing for local launcher using default java and jar public static void makeNodesLaunchable(GitClient git) throws IOException, InterruptedException { final File slaveJar = Which.jarFile(hudson.remoting.Launcher.class).getAbsoluteFile(); - EnvVars env = new EnvVars(); - for (FilePath xmlNode : git.getWorkTree().child("nodes").list("*.xml")) { - SharedNode node = new SharedNodeFactory.XStreamFactory().create(NodeDefinition.Xml.create(xmlNode)); - node.setLauncher(new CommandLauncher( - System.getProperty("java.home") + "/bin/java -jar " + slaveJar, env - )); - try (OutputStream out = xmlNode.write()) { - Jenkins.XSTREAM2.toXMLUTF8(node, out); - } + Pattern pattern = Pattern.compile("", Pattern.DOTALL); + for (FilePath file : git.getWorkTree().child("nodes").list("*.xml")) { + String command = System.getProperty("java.home") + "/bin/java -jar " + slaveJar; + String launcherTag = "" + command + ""; + + String xml = pattern.matcher(file.readToString()).replaceAll(launcherTag); + file.write(xml, "UTF-8"); + System.out.println(xml); } git.add("nodes"); git.commit("Making nodes in config repo launchable"); From 9cf91a4937072dd85c7d156820547ba3ee148894 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Gond=C5=BEa?= Date: Wed, 15 Mar 2023 14:24:23 +0100 Subject: [PATCH 19/28] Fix fixture startup --- jth-tests/pom.xml | 10 ++-------- .../jenkins/nodesharing/utils/ExternalJenkinsRule.java | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/jth-tests/pom.xml b/jth-tests/pom.xml index 216ad079..8719f48f 100644 --- a/jth-tests/pom.xml +++ b/jth-tests/pom.xml @@ -72,17 +72,11 @@ io.jenkins configuration-as-code - - io.jenkins.configuration-as-code - configuration-as-code-support - 1.19 - org.jenkins-ci.plugins job-dsl - 1.66 + 1.81.1 - @@ -139,4 +133,4 @@ - \ No newline at end of file + diff --git a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/utils/ExternalJenkinsRule.java b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/utils/ExternalJenkinsRule.java index 673f6a8b..8180f59c 100644 --- a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/utils/ExternalJenkinsRule.java +++ b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/utils/ExternalJenkinsRule.java @@ -370,7 +370,7 @@ private void injectJcascDefinition(ExternalFixture fixture, FilePath jenkinsHome private void installPlugins(ExternalFixture fixture, FilePath jenkinsHome) throws IOException, InterruptedException { Set injectPlugins = new HashSet<>(); - injectPlugins.addAll(Arrays.asList("configuration-as-code", "configuration-as-code-support")); + injectPlugins.addAll(Arrays.asList("configuration-as-code")); injectPlugins = initialPlugins(injectPlugins, fixture); injectPlugins.addAll(Arrays.asList(fixture.injectPlugins())); From e38d5f07bbba826b1d4354956eccf043fd8c568e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Gond=C5=BEa?= Date: Wed, 15 Mar 2023 14:33:13 +0100 Subject: [PATCH 20/28] Remove debug statement --- .../java/com/redhat/jenkins/nodesharing/utils/TestUtils.java | 1 - 1 file changed, 1 deletion(-) diff --git a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/utils/TestUtils.java b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/utils/TestUtils.java index b391e890..d5729d9c 100644 --- a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/utils/TestUtils.java +++ b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/utils/TestUtils.java @@ -124,7 +124,6 @@ public static void makeNodesLaunchable(GitClient git) throws IOException, Interr String xml = pattern.matcher(file.readToString()).replaceAll(launcherTag); file.write(xml, "UTF-8"); - System.out.println(xml); } git.add("nodes"); git.commit("Making nodes in config repo launchable"); From a8d729c848d303568c659df1cfb5c6a8f50b0c10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Gond=C5=BEa?= Date: Wed, 15 Mar 2023 15:04:23 +0100 Subject: [PATCH 21/28] Explicitly trust all CommandLauncher scripts sent by orchestrator --- .../nodesharing/utils/ExternalJenkinsRule.java | 1 + .../nodesharingfrontend/SharedNodeFactory.java | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/utils/ExternalJenkinsRule.java b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/utils/ExternalJenkinsRule.java index 8180f59c..150c1256 100644 --- a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/utils/ExternalJenkinsRule.java +++ b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/utils/ExternalJenkinsRule.java @@ -141,6 +141,7 @@ public boolean hasRole(ExternalFixture fixture, Class future : fixtures.values()) { Fixture f = future.get(); System.out.println(f.getAnnotation().name() + " is running at " + f.getUri() + " logging to " + f.getLog().getRemote()); diff --git a/plugin/src/main/java/com/redhat/jenkins/nodesharingfrontend/SharedNodeFactory.java b/plugin/src/main/java/com/redhat/jenkins/nodesharingfrontend/SharedNodeFactory.java index 374b655c..94558d24 100644 --- a/plugin/src/main/java/com/redhat/jenkins/nodesharingfrontend/SharedNodeFactory.java +++ b/plugin/src/main/java/com/redhat/jenkins/nodesharingfrontend/SharedNodeFactory.java @@ -28,7 +28,11 @@ import hudson.ExtensionList; import hudson.ExtensionPoint; import hudson.model.Node; +import hudson.slaves.CommandLauncher; +import hudson.slaves.ComputerLauncher; import jenkins.model.Jenkins; +import org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval; +import org.jenkinsci.plugins.scriptsecurity.scripts.languages.SystemCommandLanguage; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; @@ -55,6 +59,14 @@ public static SharedNode transform(@Nonnull NodeDefinition def) throws IllegalAr private static SharedNode decorate(@Nonnull SharedNode node) throws IllegalArgumentException { node.setRetentionStrategy(new SharedOnceRetentionStrategy(1)); node.setMode(Node.Mode.EXCLUSIVE); + + // Approve command launcher's script. It is script from orchestrator, that we trust. + ComputerLauncher launcher = node.getLauncher(); + if (launcher instanceof CommandLauncher) { + CommandLauncher cl = (CommandLauncher) launcher; + ScriptApproval.get().preapprove(cl.getCommand(), SystemCommandLanguage.get()); + } + if (node.getNumExecutors() != 1) { throw new IllegalArgumentException("Shared Nodes must have exactly 1 executor"); } From 10322dfe876a380082824365311f852bba51cbbd Mon Sep 17 00:00:00 2001 From: Neeraja Potluri Date: Thu, 16 Mar 2023 06:44:52 -0500 Subject: [PATCH 22/28] add crumbFlag true to resolve forbidden error --- .../redhat/jenkins/nodesharing/GridTest.java | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/GridTest.java b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/GridTest.java index 18329d79..e363d3fc 100644 --- a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/GridTest.java +++ b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/GridTest.java @@ -152,7 +152,7 @@ public void restartOrchestrator() throws Exception { // Run nr. 1 - will be in building state during Orchestrator restart FileBuildBlocker runningBlocker = new FileBuildBlocker(tmp); BuildWithDetails running = triggerJobAndWaitUntilStarted(executorClient, "running", - job.build(runningBlocker.buildParams())); + job.build(runningBlocker.buildParams(), true)); await(10000, () -> runningBlocker.isRunning(), throwable -> { dumpFixtureLogs(); return "Build not running in time"; @@ -160,7 +160,7 @@ public void restartOrchestrator() throws Exception { // Run nr. 2 - will be in queued state during Orchestrator restart FileBuildBlocker queuedBlocker = new FileBuildBlocker(tmp); - QueueReference qr = job.build(queuedBlocker.buildParams()); + QueueReference qr = job.build(queuedBlocker.buildParams(), true); executorClient.getQueueItem(qr); job = executorClient.getJob("running"); @@ -174,7 +174,7 @@ public void restartOrchestrator() throws Exception { JenkinsServer orchestratorClient = o.getClient("admin", "admin"); // Wait until restarted - orchestratorClient.restart(false); + orchestratorClient.restart(true); // Reservation verifier needs RestEndpoint#TIMEOUT * 2 to recover the state so this is going to take a while await(60000 * 3, orchestratorClient::isRunning, throwable -> { dumpFixtureLog(o); @@ -232,7 +232,7 @@ public void changeOrchestratorUrlSmokeTest() throws Exception { // Run nr. 1 - will be in building state during Orchestrator restart FileBuildBlocker runningBlocker = new FileBuildBlocker(tmp); BuildWithDetails running = triggerJobAndWaitUntilStarted(executorClient0, "running", - job.build(runningBlocker.buildParams())); + job.build(runningBlocker.buildParams(),true)); await(10000, () -> runningBlocker.isRunning(), throwable -> { dumpFixtureLogs(); return "Build not running in time"; @@ -240,7 +240,7 @@ public void changeOrchestratorUrlSmokeTest() throws Exception { // Run nr. 2 - will be in queued state during Orchestrator restart FileBuildBlocker queuedBlocker = new FileBuildBlocker(tmp); - QueueReference qr = job.build(queuedBlocker.buildParams()); + QueueReference qr = job.build(queuedBlocker.buildParams(), true); executorClient0.getQueueItem(qr); job = executorClient0.getJob("running"); @@ -264,19 +264,19 @@ public void changeOrchestratorUrlSmokeTest() throws Exception { assertThat(config.readToString(), containsString("orchestrator.url=" + o1.getUri())); // Make sure updated config is propagated through the grid - executorClient0.runScript("Jenkins.instance.getExtensionList(com.redhat.jenkins.nodesharingfrontend.SharedNodeCloud.ConfigRepoUpdater.class).get(0).doRun();"); + executorClient0.runScript("Jenkins.instance.getExtensionList(com.redhat.jenkins.nodesharingfrontend.SharedNodeCloud.ConfigRepoUpdater.class).get(0).doRun();", true); assertThat(executorClient0.runScript( - "com.redhat.jenkins.nodesharingfrontend.SharedNodeCloud.getAll().get(0).getLatestConfig().getOrchestratorUrl();"), + "com.redhat.jenkins.nodesharingfrontend.SharedNodeCloud.getAll().get(0).getLatestConfig().getOrchestratorUrl();", true), equalTo("Result: " + o1.getUri() + "\n") ); - orchestratorClient1.runScript("com.redhat.jenkins.nodesharingbackend.Pool.Updater.getInstance().doRun();"); + orchestratorClient1.runScript("com.redhat.jenkins.nodesharingbackend.Pool.Updater.getInstance().doRun();", true); assertThat(orchestratorClient1.runScript( - "com.redhat.jenkins.nodesharingbackend.Pool.getInstance().getConfig().getOrchestratorUrl();"), + "com.redhat.jenkins.nodesharingbackend.Pool.getInstance().getConfig().getOrchestratorUrl();", true), equalTo("Result: " + o1.getUri() + "\n") ); - orchestratorClient2.runScript("com.redhat.jenkins.nodesharingbackend.Pool.Updater.getInstance().doRun();"); + orchestratorClient2.runScript("com.redhat.jenkins.nodesharingbackend.Pool.Updater.getInstance().doRun();", true); assertThat(orchestratorClient2.runScript( - "com.redhat.jenkins.nodesharingbackend.Pool.getInstance().getConfig().getOrchestratorUrl();"), + "com.redhat.jenkins.nodesharingbackend.Pool.getInstance().getConfig().getOrchestratorUrl();", true), equalTo("Result: " + o1.getUri() + "\n") ); @@ -312,6 +312,8 @@ public void changeOrchestratorUrlSmokeTest() throws Exception { Thread.sleep(1000); String e0Log = e0.getLog().readToString(); +// System.out.println("e0Log: "+ e0Log); +// assertTrue(e0Log.contains("Terminating computer solaris1.acme.com-NodeSharing-")); // Executor should terminate computer twice assertThat(e0Log, matchesPattern( "(.+\n)+" From 1a25dc1e730c1baa9e9208df5e8b313d3d1db0ee Mon Sep 17 00:00:00 2001 From: Neeraja Potluri Date: Fri, 17 Mar 2023 09:29:39 -0500 Subject: [PATCH 23/28] fix asserts with regex --- .../redhat/jenkins/nodesharing/GridTest.java | 44 ++++++++++--------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/GridTest.java b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/GridTest.java index e363d3fc..85372043 100644 --- a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/GridTest.java +++ b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/GridTest.java @@ -38,6 +38,9 @@ import com.redhat.jenkins.nodesharing.utils.GridRule.Orchestrator; import com.redhat.jenkins.nodesharing.utils.SlowTest; import hudson.FilePath; + +import org.hamcrest.Matcher; +import org.hamcrest.Matchers; import org.junit.Rule; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -51,6 +54,7 @@ import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; +import java.util.regex.Pattern; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; @@ -312,36 +316,34 @@ public void changeOrchestratorUrlSmokeTest() throws Exception { Thread.sleep(1000); String e0Log = e0.getLog().readToString(); -// System.out.println("e0Log: "+ e0Log); -// assertTrue(e0Log.contains("Terminating computer solaris1.acme.com-NodeSharing-")); + // Executor should terminate computer twice - assertThat(e0Log, matchesPattern( - "(.+\n)+" - + "INFO: Terminating computer solaris1.acme.com-NodeSharing-.+(.+\n)*" - + "INFO: Terminating computer solaris1.acme.com-NodeSharing-.+(.+\n)*") - ); + String msg = "Terminating computer solaris1.acme.com-NodeSharing-"; + assertThat(e0Log, Matchers.stringContainsInOrder(msg, msg)); String o1Log = o1.getLog().readToString(); // Orchestrator 1 should register one release attempt before it knows that it was reserved, // second reservation should be processed like common case - assertThat(o1Log, matchesPattern( - "(.*\n)*INFO: An attempt to return a node 'solaris1.acme.com' that is not reserved by " + e0.getUri()+"(.*\n)*" - +"INFO: Reservation of solaris1.acme.com by e0 .+ completed(.*\n)*") - ); - + String regex = "An attempt to return a node 'solaris1.acme.com' that is not reserved by " + + e0.getUri(); + assertThat(o1Log.split(regex)[1], matchesPattern("((\\n(.*))+)Reservation of solaris1.acme.com by e0 (.*) completed\\n")); + String o2Log = o2.getLog().readToString(); + String o2LogRegex = o2Log.split("Jenkins is fully up and running")[1]; + Pattern p = Pattern.compile("(?i)Reservation of solaris1.acme.com by e0 (.*) started", Pattern.DOTALL); + java.util.regex.Matcher m = p.matcher(o2LogRegex); + boolean b = m.find(); + // Orchestrator 2 should register one reservation without release - assertThat(o2Log, matchesPattern( - "(.*\n)*INFO: Reservation of solaris1.acme.com by e0 .+ started(.*\n)*") - ); + assertTrue(b); // Orchestrator 2 shouldn't register two reservations - assertThat(o2Log, matchesPattern( - "(.*\n)*(?!INFO: Reservation of solaris1.acme.com by e0 .+ started(.*\n)*INFO: Reservation of solaris1.acme.com by e0 .+ started)(.*\n)*") - ); + b = m.find(); + org.junit.Assert.assertFalse(b); // Orchestrator 2 shouldn't register any release attempt - assertThat(o2Log, matchesPattern( - "(.*\n)*(?!INFO: Reservation of solaris1.acme.com by e0 .+ completed)(.*\n)*") - ); + p = Pattern.compile("(?i)Reservation of solaris1.acme.com by e0 (.*) completed", Pattern.DOTALL); + m = p.matcher(o2LogRegex); + b = m.find(); + org.junit.Assert.assertFalse(b); } private BuildWithDetails buildDetails(JobWithDetails running, int i) throws IOException { From e70c3a4381d8ed536d407a486ba96e034bcb691d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Gond=C5=BEa?= Date: Wed, 22 Mar 2023 15:53:01 +0100 Subject: [PATCH 24/28] Do not build on windows --- Jenkinsfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index af9dd867..0edee54a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,5 +4,4 @@ buildPlugin( configurations: [ [platform: 'linux', jdk: 11], [platform: 'linux', jdk: 17], - [platform: 'windows', jdk: 11], ]) From 8ad284f55cd720d5a9826773f84336c2be9ec126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Gond=C5=BEa?= Date: Wed, 22 Mar 2023 16:09:19 +0100 Subject: [PATCH 25/28] Diagnose HttpHostConnectException --- .../java/com/redhat/jenkins/nodesharing/GridTest.java | 10 ++++++---- .../jenkins/nodesharing/utils/ExternalJenkinsRule.java | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/GridTest.java b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/GridTest.java index 85372043..7e13cf05 100644 --- a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/GridTest.java +++ b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/GridTest.java @@ -91,8 +91,9 @@ public void smoke() throws Exception { System.out.println('.'); verifyBuildHasRun(fixture, "sol", "win"); return; - } catch (AssertionError ex) { + } catch (AssertionError|org.apache.http.conn.HttpHostConnectException ex) { if (i == 8) { + System.err.println(fixture.getLog().readToString()); TimeoutException tex = new TimeoutException("Build not completed in time"); tex.initCause(ex); throw tex; @@ -122,8 +123,9 @@ public void smokeNoEnvCredential() throws Exception { System.out.println('.'); verifyBuildHasRun(fixture, "sol", "win"); return; - } catch (AssertionError ex) { + } catch (AssertionError|org.apache.http.conn.HttpHostConnectException ex) { if (i == 8) { + System.err.println(fixture.getLog().readToString()); TimeoutException tex = new TimeoutException("Build not completed in time"); tex.initCause(ex); throw tex; @@ -324,10 +326,10 @@ public void changeOrchestratorUrlSmokeTest() throws Exception { String o1Log = o1.getLog().readToString(); // Orchestrator 1 should register one release attempt before it knows that it was reserved, // second reservation should be processed like common case - String regex = "An attempt to return a node 'solaris1.acme.com' that is not reserved by " + String regex = "An attempt to return a node 'solaris1.acme.com' that is not reserved by " + e0.getUri(); assertThat(o1Log.split(regex)[1], matchesPattern("((\\n(.*))+)Reservation of solaris1.acme.com by e0 (.*) completed\\n")); - + String o2Log = o2.getLog().readToString(); String o2LogRegex = o2Log.split("Jenkins is fully up and running")[1]; Pattern p = Pattern.compile("(?i)Reservation of solaris1.acme.com by e0 (.*) started", Pattern.DOTALL); diff --git a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/utils/ExternalJenkinsRule.java b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/utils/ExternalJenkinsRule.java index 150c1256..b4aca483 100644 --- a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/utils/ExternalJenkinsRule.java +++ b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/utils/ExternalJenkinsRule.java @@ -517,6 +517,7 @@ private void waitUntilReady(int seconds) throws InterruptedException, TimeoutExc } if (client.isRunning()) { ready = true; + System.err.println("Fixture " + this.annotation.name() + " ready"); return; } Thread.sleep(1000); From 9898abc891257a01030ec0cdeeef7c60fdcccb5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Gond=C5=BEa?= Date: Thu, 23 Mar 2023 08:43:48 +0100 Subject: [PATCH 26/28] More diagnostics --- .../redhat/jenkins/nodesharing/GridTest.java | 8 ++--- .../utils/ExternalJenkinsRule.java | 36 ++++++++++--------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/GridTest.java b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/GridTest.java index 7e13cf05..855f6815 100644 --- a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/GridTest.java +++ b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/GridTest.java @@ -93,8 +93,8 @@ public void smoke() throws Exception { return; } catch (AssertionError|org.apache.http.conn.HttpHostConnectException ex) { if (i == 8) { - System.err.println(fixture.getLog().readToString()); - TimeoutException tex = new TimeoutException("Build not completed in time"); + dumpFixtureLogs(); + TimeoutException tex = new TimeoutException("Build not completed in time by " + new Date()); tex.initCause(ex); throw tex; } @@ -125,8 +125,8 @@ public void smokeNoEnvCredential() throws Exception { return; } catch (AssertionError|org.apache.http.conn.HttpHostConnectException ex) { if (i == 8) { - System.err.println(fixture.getLog().readToString()); - TimeoutException tex = new TimeoutException("Build not completed in time"); + dumpFixtureLogs(); + TimeoutException tex = new TimeoutException("Build not completed in time by " + new Date()); tex.initCause(ex); throw tex; } diff --git a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/utils/ExternalJenkinsRule.java b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/utils/ExternalJenkinsRule.java index b4aca483..0c26a46d 100644 --- a/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/utils/ExternalJenkinsRule.java +++ b/jth-tests/src/test/java/com/redhat/jenkins/nodesharing/utils/ExternalJenkinsRule.java @@ -53,21 +53,15 @@ import java.net.URI; import java.net.URISyntaxException; import java.nio.file.Files; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Set; +import java.util.*; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicInteger; import java.util.jar.JarInputStream; +import java.util.logging.Level; +import java.util.logging.Logger; import java.util.regex.Pattern; /** @@ -76,6 +70,9 @@ * The rule can be subclassed to add custom methods or override callback methods to customize fixture deployment. */ public class ExternalJenkinsRule implements TestRule { + + static final Logger LOGGER = Logger.getLogger(ExternalJenkinsRule.class.getName()); + protected final TemporaryFolder tmp; private Map> fixtures = Collections.emptyMap(); @@ -141,10 +138,10 @@ public boolean hasRole(ExternalFixture fixture, Class future : fixtures.values()) { Fixture f = future.get(); - System.out.println(f.getAnnotation().name() + " is running at " + f.getUri() + " logging to " + f.getLog().getRemote()); + LOGGER.info(f.getAnnotation().name() + " is running at " + f.getUri() + " logging to " + f.getLog().getRemote()); } new BufferedReader(new InputStreamReader(System.in)).readLine(); } catch (IOException | InterruptedException | ExecutionException e) { @@ -502,7 +499,7 @@ public void close() { client.close(); } catch (Exception e) { // Resume the loop so the remaining connections are cleaned too - e.printStackTrace(); + LOGGER.log(Level.WARNING, "Thrown while closing JenkinsServer " + client, e); } } } @@ -513,16 +510,21 @@ private void waitUntilReady(int seconds) throws InterruptedException, TimeoutExc JenkinsServer client = getClient(); for (int i = 0; i < seconds; i++) { if (!process.isAlive()) { - throw new AssertionError("Jenkins " + annotation.name() + " has failed with " + process.exitValue()); + throw new AssertionError(String.format("Jenkins %s has failed with %d", annotation.name(), process.exitValue())); } if (client.isRunning()) { - ready = true; - System.err.println("Fixture " + this.annotation.name() + " ready"); - return; + try { + client.getJobs(); + ready = true; + LOGGER.info("Fixture " + this.annotation.name() + " ready"); + return; + } catch (IOException e) { + LOGGER.log(Level.WARNING, "Thrown while waiting for fixture to be ready", e); + } } Thread.sleep(1000); } - throw new TimeoutException("Fixture " + annotation.name() + " not ready in " + seconds + " seconds"); + throw new TimeoutException(String.format("Fixture %s not ready in %d seconds (%s)", annotation.name(), seconds, new Date())); } } From 5a15501a5cb30b8365141cf00630369c7e720716 Mon Sep 17 00:00:00 2001 From: Neeraja Potluri Date: Tue, 28 Mar 2023 07:01:26 -0500 Subject: [PATCH 27/28] rebuild From 0383aaf872939a2a96e204a812f08028ce5f2553 Mon Sep 17 00:00:00 2001 From: Neeraja Potluri Date: Tue, 28 Mar 2023 13:19:38 -0500 Subject: [PATCH 28/28] rebuild