Skip to content
Permalink
Browse files

[JENKINS-48061] Add a test for buildstorm check

This required a newer ish shared libraries plugin in the test scope
which required a slightly newer jenkins core
  • Loading branch information...
rsandell committed Mar 23, 2018
1 parent 54c5a03 commit 54115890411a10e0a853da0ad4ec3d3c214e628c
28 pom.xml
@@ -24,12 +24,12 @@
<inceptionYear>2007</inceptionYear>

<properties>
<jenkins.version>1.625.3</jenkins.version>
<jenkins.version>1.642.3</jenkins.version>
<java.level>7</java.level>
<no-test-jar>false</no-test-jar>
<concurrency>1C</concurrency>
<findbugs.failOnError>false</findbugs.failOnError>
<workflow.version>1.14.2</workflow.version>
<!--<workflow.version>1.14.2</workflow.version>-->
<scm-api-plugin.version>2.2.0</scm-api-plugin.version>
</properties>

@@ -167,7 +167,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-scm-step</artifactId>
<version>${workflow.version}</version>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
@@ -273,7 +273,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<version>${workflow.version}</version>
<version>2.10</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
@@ -287,25 +287,37 @@
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<version>${workflow.version}</version>
<version>2.32</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-job</artifactId>
<version>${workflow.version}</version>
<version>2.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-basic-steps</artifactId>
<version>${workflow.version}</version>
<version>2.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-durable-task-step</artifactId>
<version>${workflow.version}</version>
<version>2.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-multibranch</artifactId>
<version>2.16</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps-global-lib</artifactId>
<version>2.8</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -0,0 +1,73 @@
package jenkins.plugins.git;

import hudson.FilePath;
import hudson.Functions;
import hudson.model.Queue;
import org.apache.commons.io.FileUtils;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.recipes.LocalData;

import java.io.File;
import java.net.URL;

import static org.junit.Assert.*;
import static org.junit.Assume.assumeFalse;

public class GitBranchSCMHeadTest {

@Rule
public JenkinsRule j = new JenkinsRule() {
@Override
public void before() throws Throwable {
if (!Functions.isWindows() && "testMigrationNoBuildStorm".equals(this.getTestDescription().getMethodName())) {
URL res = getClass().getResource("/jenkins/plugins/git/GitBranchSCMHeadTest/testMigrationNoBuildStorm_repositories.zip");
final File path = new File("/tmp/JENKINS-48061");
if (path.exists()) {
if (path.isDirectory()) {
FileUtils.deleteDirectory(path);
} else {
path.delete();
}
}

new FilePath(new File(res.toURI())).unzip(new FilePath(path.getParentFile()));
}
super.before();
}
};


@Issue("JENKINS-48061")
@Test
@LocalData
public void testMigrationNoBuildStorm() throws Exception {
assumeFalse(Functions.isWindows());
final WorkflowMultiBranchProject job = j.jenkins.getItemByFullName("job", WorkflowMultiBranchProject.class);
assertEquals(4, job.getItems().size());
WorkflowJob master = job.getItem("master");
assertEquals(1, master.getBuilds().size());
WorkflowJob dev = job.getItem("dev");
assertEquals(1, dev.getBuilds().size());
WorkflowJob v4 = job.getItem("v4");
assertEquals(0, v4.getBuilds().size());

final Queue.Item item = job.scheduleBuild2(0);
assertNotNull(item);
item.getFuture().waitForStart();
j.waitUntilNoActivity();

assertEquals(4, job.getItems().size());
master = job.getItem("master");
assertEquals(1, master.getBuilds().size());
dev = job.getItem("dev");
assertEquals(1, dev.getBuilds().size());
v4 = job.getItem("v4");
assertEquals(0, v4.getBuilds().size());
}

}
Binary file not shown.
Binary file not shown.

0 comments on commit 5411589

Please sign in to comment.
You can’t perform that action at this time.