use of hudson.model.Slave in project support-core-plugin by jenkinsci.
the class SupportActionTest method anonymizationSmokes.
@Test
public void anonymizationSmokes() throws Exception {
Slave node = j.createSlave(Label.get("super_secret_node"));
File bundleFile = temp.newFile();
List<Component> componentsToCreate = Collections.singletonList(ExtensionList.lookup(Component.class).get(AboutJenkins.class));
try (OutputStream os = Files.newOutputStream(bundleFile.toPath())) {
ContentFilters.get().setEnabled(false);
SupportPlugin.writeBundle(os, componentsToCreate);
ZipFile zip = new ZipFile(bundleFile);
String nodeComponentText = IOUtils.toString(zip.getInputStream(zip.getEntry("nodes.md")), StandardCharsets.UTF_8);
assertThat("Node name should be present when anonymization is disabled", nodeComponentText, containsString(node.getNodeName()));
}
bundleFile = temp.newFile();
try (OutputStream os = Files.newOutputStream(bundleFile.toPath())) {
ContentFilters.get().setEnabled(true);
SupportPlugin.writeBundle(os, componentsToCreate);
ZipFile zip = new ZipFile(bundleFile);
String nodeComponentText = IOUtils.toString(zip.getInputStream(zip.getEntry("nodes.md")), StandardCharsets.UTF_8);
assertThat("Node name should not be present when anonymization is enabled", nodeComponentText, not(containsString(node.getNodeName())));
String anonymousNodeName = ContentMappings.get().getMappings().get(node.getNodeName());
assertThat("Anonymous node name should be present when anonymization is enabled", nodeComponentText, containsString(anonymousNodeName));
}
}
use of hudson.model.Slave in project blueocean-plugin by jenkinsci.
the class PipelineNodeTest method sequentialParallelStagesWithPost.
@Test
@Issue("JENKINS-49779")
public void sequentialParallelStagesWithPost() throws Exception {
WorkflowJob p = createWorkflowJobWithJenkinsfile(getClass(), "sequentialParallelWithPost.jenkinsfile");
Slave s = j.createOnlineSlave();
s.setNumExecutors(2);
// Run until completed
j.buildAndAssertSuccess(p);
List<Map> nodes = get("/organizations/jenkins/pipelines/" + p.getName() + "/runs/1/nodes/", List.class);
assertEquals(9, nodes.size());
Optional<Map> thirdSeqStage = nodes.stream().filter(map -> map.get("displayName").equals("third-sequential-stage")).findFirst();
assertTrue(thirdSeqStage.isPresent());
List<Map> steps = get("/organizations/jenkins/pipelines/" + p.getName() + "/runs/1/nodes/" + thirdSeqStage.get().get("id") + "/steps/", List.class);
assertEquals(2, steps.size());
assertEquals("echo 'dummy text third-sequential-stage'", steps.get(0).get("displayDescription"));
assertEquals("echo 'dummy text post multiple-stages'", steps.get(1).get("displayDescription"));
}
use of hudson.model.Slave in project blueocean-plugin by jenkinsci.
the class PipelineNodeTest method parallelStagesGroupsAndNestedStages.
@Test
@Issue("JENKINS-49050")
public void parallelStagesGroupsAndNestedStages() throws Exception {
WorkflowJob p = createWorkflowJobWithJenkinsfile(getClass(), "parallelStagesGroupsAndStages.jenkinsfile");
Slave s = j.createOnlineSlave();
s.setLabelString("foo");
s.setNumExecutors(2);
// Run until completed
WorkflowRun run = p.scheduleBuild2(0).waitForStart();
j.waitForCompletion(run);
PipelineNodeGraphVisitor pipelineNodeGraphVisitor = new PipelineNodeGraphVisitor(run);
assertTrue(pipelineNodeGraphVisitor.isDeclarative());
List<FlowNodeWrapper> wrappers = pipelineNodeGraphVisitor.getPipelineNodes();
FlowNodeWrapper flowNodeWrapper = wrappers.get(0);
assertEquals("top", flowNodeWrapper.getDisplayName());
assertEquals(2, flowNodeWrapper.edges.size());
flowNodeWrapper = wrappers.get(1);
assertEquals("first", flowNodeWrapper.getDisplayName());
assertEquals(1, flowNodeWrapper.edges.size());
assertEquals(1, flowNodeWrapper.getParents().size());
assertEquals("first-inner-first", flowNodeWrapper.edges.get(0).getDisplayName());
assertEquals(7, wrappers.size());
List<Map> nodes = get("/organizations/jenkins/pipelines/" + p.getName() + "/runs/1/nodes/", List.class);
assertEquals(7, nodes.size());
}
use of hudson.model.Slave in project blueocean-plugin by jenkinsci.
the class PipelineNodeTest method nestedStagesGroups.
@Test
public void nestedStagesGroups() throws Exception {
WorkflowJob p = createWorkflowJobWithJenkinsfile(getClass(), "nestedStagesGroups.jenkinsfile");
Slave s = j.createOnlineSlave();
s.setLabelString("foo");
s.setNumExecutors(4);
// Run until completed
WorkflowRun run = p.scheduleBuild2(0).waitForStart();
j.waitForCompletion(run);
PipelineNodeGraphVisitor pipelineNodeGraphVisitor = new PipelineNodeGraphVisitor(run);
assertTrue(pipelineNodeGraphVisitor.isDeclarative());
List<FlowNodeWrapper> wrappers = pipelineNodeGraphVisitor.getPipelineNodes();
assertEquals(7, wrappers.size());
}
use of hudson.model.Slave in project configuration-as-code-plugin by jenkinsci.
the class BuildAgentsTest method configure_build_agents.
@Test
@ConfiguredWithReadme(value = "build_agents/README.md")
public void configure_build_agents() {
assertThat(j.getInstance().getComputers().length, is(3));
Slave slave = (Slave) j.getInstance().getNode("utility-node");
assertThat(slave.getRemoteFS(), is("/home/user1"));
JNLPLauncher jnlpLauncher = ((JNLPLauncher) slave.getLauncher());
assertThat(jnlpLauncher.getWorkDirSettings().getWorkDirPath(), is("/tmp"));
assertThat(jnlpLauncher.getWorkDirSettings().getInternalDir(), is("remoting"));
assertTrue(jnlpLauncher.getWorkDirSettings().isDisabled());
assertFalse(jnlpLauncher.getWorkDirSettings().isFailIfWorkDirIsMissing());
assertThat(j.getInstance().getNode("utility-node-2").getNumExecutors(), is(4));
assertThat(j.getInstance().getNode("utility-node-2").getMode(), is(Mode.NORMAL));
slave = (Slave) j.getInstance().getNode("utility-node-2");
assertThat(slave.getRemoteFS(), is("/home/user2"));
SSHLauncher launcher = ((SSHLauncher) slave.getLauncher());
assertThat(launcher.getHost(), is("192.168.1.1"));
assertThat(launcher.getPort(), is(22));
assertThat(launcher.getCredentialsId(), is("test"));
assertThat(launcher.getMaxNumRetries(), is(3));
assertThat(launcher.getRetryWaitTime(), is(30));
}
Aggregations