Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump parent pom to 3.54 #99

Merged
merged 3 commits into from
Dec 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>3.42</version>
<version>3.54</version>
<relativePath />
</parent>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
Expand Down Expand Up @@ -64,14 +64,14 @@
<properties>
<revision>3.4</revision>
<changelist>-SNAPSHOT</changelist>
<jenkins.version>2.121.1</jenkins.version>
<jenkins.version>2.138.4</jenkins.version>
<java.level>8</java.level>
<no-test-jar>false</no-test-jar>
<useBeta>true</useBeta>
<hpi.compatibleSinceVersion>3.0</hpi.compatibleSinceVersion>
<git-plugin.version>3.7.0</git-plugin.version>
<workflow-scm-step-plugin.version>2.7</workflow-scm-step-plugin.version>
<workflow-step-api-plugin.version>2.19</workflow-step-api-plugin.version>
<workflow-step-api-plugin.version>2.20</workflow-step-api-plugin.version>
<scm-api-plugin.version>2.2.6</scm-api-plugin.version>
</properties>
<dependencies>
Expand All @@ -83,7 +83,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-api</artifactId>
<version>2.30</version>
<version>2.36</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
Expand Down Expand Up @@ -123,7 +123,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
<version>1.17</version>
<version>1.18</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -154,7 +154,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-job</artifactId>
<version>2.21</version>
<version>2.36</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,10 @@ public void evaluate() throws Throwable {

// Like org.hamcrest.text.MatchesPattern.matchesPattern(String) but doing a substring, not whole-string, match:
private static Matcher<String> containsRegexp(final String rx) {
return new SubstringMatcher(rx) {
return new SubstringMatcher("containing the regexp", false, rx) {
@Override protected boolean evalSubstringOf(String string) {
return Pattern.compile(rx).matcher(string).find();
}
@Override protected String relationship() {
return "containing the regexp";
}
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.jenkinsci.plugins.workflow.test.steps;

import hudson.model.Result;
import hudson.model.queue.QueueTaskFuture;
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;

import static org.junit.Assert.assertNotNull;

public class SemaphoreStepTest {
@Rule
public JenkinsRule j = new JenkinsRule();

@Test
public void hardKill() throws Exception {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the problem that this test is reproducing? Did it hang forever with older implementations of WorkflowRun.doKill or something?

Copy link
Contributor Author

@slonopotamus slonopotamus Dec 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, look at jenkinsci/lockable-resources-plugin#170.

They have issues with upgrading to modern JTH, LockStepHardKillTest leaves open file descriptors after test ends and this is detected by jenkinsci/jenkins-test-harness#166.

However, this failure isn't related to lockable-resources-plugin at all, it is local to workflow-support-plugin + workflow-api. That's why I am creating a test here that is a stripped-down version of LockStepHardKillTest demonstrating the same issue.

Note that issue cannot be detected by JMH without upgrading parent POM, that's why I put these changes together.

You may see how this test fails without workflow-api upgrade in build 3 of current PR.

Overall, I'm currently walking through different Jenkins plugins and updating parent pom to 3.54 (you've seen some of my PRs already). Some plugins update cleanly, some encounter different issues related to jenkinsci/jenkins-test-harness#166.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so if I understand correctly, the problem is that older versions of workflow-api leave the log file opened in some cases (I guess related to the bugs fixed in versions 2.31, 2.32, and 2.33 of that plugin), which causes test failures on Windows because the temp directories for the tests can't be deleted? I'm just confused why workflow-support has anything to do with it, since you didn't update any code related to SemaphoreStep here, I would think you could see the same problem with waitUntil or maybe even sleep.

You should be able to update the version of workflow-api that lockable-resources depends on (right now it picks up an old version through the workflow-support dependency). From a quick look at the APIs it is using, I think that it would make more sense for lockable-resources to only depend on workflow-step-api and workflow-api in compile scope, and move the workflow-support non-tests-classifier dependency to test scope.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Adding the test here is fine, thanks for adding it! I just don't think it matters for lockable-resources)

Copy link
Contributor Author

@slonopotamus slonopotamus Dec 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the problem is that older versions of workflow-api leave the log file opened in some cases

Right. Newer parent pom brings in newer JTH. Newer JTH is smart enough to detect a bug in older workflow-api versions. This bug can be demonstrated by a (useful, IMO) test that terminates build during semaphore step. lockable-resources have such test. workflow-support-plugin doesn't (until this PR). Fixing it requires updating dependency on workflow-api. And that's what I am doing here.

I do not say that this PR is a prerequisite to fix lockable-resources, they have other options to go.

I would think you could see the same problem with waitUntil or maybe even sleep.

Yes, though semaphore is more deterministic (no hardcoded timeouts and stuff like that).

WorkflowJob p1 = j.jenkins.createProject(WorkflowJob.class, "p");
p1.setDefinition(new CpsFlowDefinition("echo 'locked!'; semaphore 'wait'"));
QueueTaskFuture<WorkflowRun> future = p1.scheduleBuild2(0);
assertNotNull(future);
WorkflowRun b = future.waitForStart();
SemaphoreStep.waitForStart("wait/1", b);

b.doKill();
j.waitForMessage("Hard kill!", b);
j.assertBuildStatus(Result.ABORTED, future);
}
}