use of org.jenkinsci.test.acceptance.plugins.nodelabelparameter.NodeParameter in project acceptance-test-harness by jenkinsci.
the class NodeLabelParameterPluginTest method run_on_online_slave_and_master_with_node_restriction.
/**
* This test is intended to check that two created slaves are added to the
* node restriction box. Additionally, when selecting the 2 slaves as
* nodes in the restriction panel, only those should be available for the
* build.
*/
@Test
public void run_on_online_slave_and_master_with_node_restriction() throws Exception {
Slave s1 = slave.install(jenkins).get();
Slave s2 = slave.install(jenkins).get();
FreeStyleJob j = jenkins.jobs.create();
j.configure();
NodeParameter p = j.addParameter(NodeParameter.class);
p.setName("slavename");
// master, ALL + 2 slaves
assertThat("Amount of possible nodes does not match", p.getPossibleNodesOptions().size(), is(4));
p.allowMultiple.check();
p.allowedNodes.select(s1.getName());
p.allowedNodes.select(s2.getName());
j.concurrentBuild.check();
j.save();
assertThat(s1.isOnline(), is(true));
assertThat(s2.isOnline(), is(true));
// checks that build selection box only contains the possible nodes
visit(j.getBuildUrl());
List<String> slaves = p.applicableNodes();
assertThat("Amount of selectable nodes", slaves.size(), is(2));
assertThat(slaves, containsInAnyOrder(s1.getName(), s2.getName()));
j.startBuild(singletonMap("slavename", s1.getName() + "," + s2.getName())).waitUntilFinished();
assertThat(s1.getBuildHistory(), containsBuildOf(j));
assertThat(s2.getBuildHistory(), containsBuildOf(j));
assertThat(j.getNextBuildNumber(), is(3));
}
use of org.jenkinsci.test.acceptance.plugins.nodelabelparameter.NodeParameter in project acceptance-test-harness by jenkinsci.
the class NodeLabelParameterPluginTest method run_on_several_slaves.
@Test
public void run_on_several_slaves() throws Exception {
FreeStyleJob j = jenkins.jobs.create();
Slave s1 = slave.install(jenkins).get();
Slave s2 = slave.install(jenkins).get();
j.configure();
NodeParameter p = j.addParameter(NodeParameter.class);
p.setName("slavename");
p.allowMultiple.check();
j.concurrentBuild.check();
j.save();
j.startBuild(singletonMap("slavename", s1.getName() + "," + s2.getName())).shouldSucceed();
assertThat(j.getNextBuildNumber(), is(3));
j.getLastBuild().waitUntilFinished();
assertThat(s1.getBuildHistory(), containsBuildOf(j));
assertThat(s2.getBuildHistory(), containsBuildOf(j));
}
use of org.jenkinsci.test.acceptance.plugins.nodelabelparameter.NodeParameter in project acceptance-test-harness by jenkinsci.
the class NodeLabelParameterPluginTest method pending_build_with_no_valid_node.
/**
* This test is intended to check that an offline slave is ignored
* when selected for a job and the job is configured with "Node eligibility" setting
* is set to "Ignore offline Nodes" in combination with "Allow multiple nodes" option.
* <p/>
* The job shall run on a mixed configuration of online slaves.
* It is expected that a number of builds is created equivalent to the number of
* slaves selected. The build shall be pending as there is no valid online slave.
* Pending builds will be reactivated as soon as the particular slave becomes online.
*/
@Test
public void pending_build_with_no_valid_node() throws Exception {
FreeStyleJob j = jenkins.jobs.create();
Slave s1 = slave.install(jenkins).get();
Slave s2 = slave.install(jenkins).get();
j.configure();
NodeParameter p = j.addParameter(NodeParameter.class);
p.setName("slavename");
p.allowMultiple.check();
j.concurrentBuild.check();
p.eligibility.select("Ignore Offline Nodes");
j.save();
// as both slaves have been started after creation, we have to take one of them down
s2.markOffline();
assertThat(s2.isOffline(), is(true));
assertThat(s1.isOnline(), is(true));
// select both slaves for this build
Build b = j.startBuild(singletonMap("slavename", s1.getName()));
// wait for the build on slave 1 to finish
b.waitUntilFinished();
// ensure that the build on the online slave has been done
assertThat(s1.getBuildHistory().getBuildsOf(j), contains(b));
// use scheduleBuild instead of startBuild to avoid a timeout waiting for Build being started
b = j.scheduleBuild(singletonMap("slavename", s2.getName()));
// shown in queue
waitFor(by.href("/queue/cancelItem?id=2"));
// after some time
elasticSleep(10000);
shouldBeTriggeredWithoutValidOnlineNode(b, s2.getName());
}
use of org.jenkinsci.test.acceptance.plugins.nodelabelparameter.NodeParameter in project acceptance-test-harness by jenkinsci.
the class NodeLabelParameterPluginTest method trigger_if_succeeds_with_unstable_post_build_step.
/**
* This test is intended to verify that the second build is not started when the
* build already deemed unstable on the first slave in combination with the
* "run next build only if build succeeds" setting of the node parameter.
* <p/>
* The JUnit test publisher is used to create an unstable build during the post
* build step.
* <p/>
* Note that in this case the main build action is still completed with status SUCCESS.
*/
@Test
@Issue("JENKINS-23129")
@Ignore("Until JENKINS-23129 is fixed")
public void trigger_if_succeeds_with_unstable_post_build_step() throws Exception {
FreeStyleJob j = jenkins.jobs.create();
ArrayList<Node> slaves = new ArrayList<>();
slaves.add(slave.install(jenkins).get());
slaves.add(slave.install(jenkins).get());
j.configure();
// set up the node parameter
NodeParameter p = j.addParameter(NodeParameter.class);
p.setName("slavename");
p.runIfSuccess.check();
// copy the unit test results
j.copyResource(resource("/junit/failure/com.simple.project.AppTest.txt"));
j.copyResource(resource("/junit/failure/TEST-com.simple.project.AppTest.xml"));
// add the post build step
j.addPublisher(JUnitPublisher.class).testResults.set("*.xml");
j.save();
// select both slaves for this build
j.startBuild(singletonMap("slavename", slaves.get(0).getName() + "," + slaves.get(1).getName())).shouldFail();
// verify unstable result prevents the job to be built on further nodes.
// As the nodes get random names and the selected nodes are utilized in alphabetical order
// of their names, the first build will not necessarily be done on s1. Thus, it can only
// be verified that the job has been built on one of the slaves.
j.startBuild(singletonMap("slavename", slaves.get(0).getName() + "," + slaves.get(1).getName())).shouldFail();
assertThat(j.getNextBuildNumber(), is(2));
}
use of org.jenkinsci.test.acceptance.plugins.nodelabelparameter.NodeParameter in project acceptance-test-harness by jenkinsci.
the class NodeLabelParameterPluginTest method trigger_if_succeeds_with_failed_main_build.
/**
* This test is intended to verify that the second build is not started when the
* build already failed on the first slave in combination with the
* "run next build only if build succeeds" setting of the node parameter.
* <p/>
* As a build can fail in different stages this test simulates a FAILED result
* during the main build action.
*/
@Test
public void trigger_if_succeeds_with_failed_main_build() throws Exception {
FreeStyleJob j = jenkins.jobs.create();
Slave s1 = slave.install(jenkins).get();
Slave s2 = slave.install(jenkins).get();
j.configure();
// set up the node parameter
NodeParameter p = j.addParameter(NodeParameter.class);
p.setName("slavename");
p.runIfSuccess.check();
// ensure the main build fails by using a shell exit command
if (SystemUtils.IS_OS_WINDOWS) {
j.addBatchStep("exit 1");
} else {
j.addShellStep("exit 1");
}
j.save();
// select both slaves for this build
Build build = j.startBuild(singletonMap("slavename", s1.getName() + "," + s2.getName())).shouldFail();
// verify failed result prevents the job to be built on further nodes.
// As the nodes get random names and the selected nodes are utilized in alphabetical order
// of their names, the first build will not necessarily be done on s1. Thus, it can only
// be verified that the job has been built on one of the slaves.
Set<Build> history = s1.getBuildHistory().getBuilds();
history.addAll(s2.getBuildHistory().getBuilds());
assertThat(history, contains(build));
assertThat(j.getNextBuildNumber(), is(2));
}
Aggregations