/** * Creates and launches a new slave on the local host. */ public DumbSlave createSlave(Label l) throws Exception { return createSlave(l, null); }
public DumbSlave createSlave() throws Exception { return createSlave("",null); }
public DumbSlave createSlave(EnvVars env) throws Exception { return createSlave("",env); }
/** * Creates a slave with certain additional environment variables */ public DumbSlave createSlave(String labels, EnvVars env) throws Exception { synchronized (jenkins) { int sz = jenkins.getNodes().size(); return createSlave("slave" + sz,labels,env); } }
/** * Create a new slave on the local host and wait for it to come online * before returning * @see #waitOnline */ @SuppressWarnings({"deprecation"}) public DumbSlave createOnlineSlave(Label l, EnvVars env) throws Exception { DumbSlave s = createSlave(l, env); waitOnline(s); return s; }
public DumbSlave createSlave(boolean waitForChannelConnect) throws Exception { DumbSlave slave = createSlave(); if (waitForChannelConnect) { long start = System.currentTimeMillis(); while (slave.getChannel() == null) { if (System.currentTimeMillis() > (start + 10000)) { throw new IllegalStateException("Timed out waiting on DumbSlave channel to connect."); } Thread.sleep(200); } } return slave; }
public DumbSlave createSlave(Label l, EnvVars env) throws Exception { return createSlave(l==null ? null : l.getExpression(), env); }
public Node call() throws Exception { // simulate the delay in provisioning a new slave, // since it's normally some async operation. Thread.sleep(time); System.out.println("launching slave"); final DumbSlave slave = rule.createSlave(label); for (NodeProperty nodeProperty : nodeProperties) { slave.getNodeProperties().add(updateWithNode(nodeProperty, slave)); } computer = slave.toComputer(); computer.connect(false).get(); synchronized (DummyCloudImpl.this) { System.out.println(computer.getName()+" launch"+(computer.isOnline()?"ed successfully":" failed")); System.out.println(computer.getLog()); } return slave; } }
public DumbSlave createSlave(JenkinsRule j) throws Exception { DumbSlave s = j.createSlave(); s.getComputer().connect(false).get(); // wait for the slave to fully get connected return s; }
@Issue("JENKINS-16533") @Test public void pollingRespectExternalsWithRevision() throws Exception { // trunk has svn:externals="-r 1 ^/vendor vendor" (pinned) // latest commit on vendor is r3 (> r1) File repo = new CopyExisting(getClass().getResource("JENKINS-16533.zip")).allocate(); SubversionSCM scm = new SubversionSCM("file://" + repo.toURI().toURL().getPath() + "trunk"); // pinned externals should be recorded with ::p in revisions.txt FreeStyleProject p = r.createFreeStyleProject(); p.setScm(scm); p.setAssignedLabel(r.createSlave().getSelfLabel()); r.assertBuildStatusSuccess(p.scheduleBuild2(0).get()); // should not find any change (pinned externals should be skipped on poll) // fail if it checks the revision of external URL larger than the pinned revision assertFalse(p.poll(StreamTaskListener.fromStdout()).hasChanges()); }
/** * Used for experimenting the memory leak problem. * This test by itself doesn't detect that, but I'm leaving it in anyway. */ @Issue("JENKINS-8061") @Test public void pollingLeak() throws Exception { Proc p = runSvnServe(getClass().getResource("small.zip")); try { FreeStyleProject b = r.createFreeStyleProject(); b.setScm(new SubversionSCM("svn://localhost/")); b.setAssignedNode(r.createSlave()); r.assertBuildStatusSuccess(b.scheduleBuild2(0)); b.poll(new StreamTaskListener(System.out,Charset.defaultCharset())); } finally { p.kill(); } }
private void invokeTestPollingExternalsForFile() throws Exception { // trunk has svn:externals="^/vendor/target.txt target.txt" File repo = new CopyExisting(getClass().getResource("JENKINS-20165.zip")).allocate(); String path = "file://" + repo.toURI().toURL().getPath(); SubversionSCM scm = new SubversionSCM(path + "trunk"); // first checkout FreeStyleProject p = r.createFreeStyleProject(); p.setScm(scm); p.setAssignedLabel(r.createSlave().getSelfLabel()); r.assertBuildStatusSuccess(p.scheduleBuild2(0).get()); // update target.txt in vendor SubversionSCM vendor = new SubversionSCM(path + "vendor"); createWorkingCopy(vendor); changeFiles("target.txt"); commitWorkingCopy("update"); // should detect change assertTrue(p.poll(StreamTaskListener.fromStdout()).hasChanges()); } }
/** * There was a bug that credentials stored in the remote call context was serialized wrongly. */ @Issue("JENKINS-8061") @Test public void remoteBuild() throws Exception { Proc p = runSvnServe(SubversionSCMTest.class.getResource("HUDSON-1379.zip")); try { SystemCredentialsProvider.getInstance().setDomainCredentialsMap(Collections.singletonMap(Domain.global(), Arrays.<Credentials>asList( new UsernamePasswordCredentialsImpl(CredentialsScope.GLOBAL, "1-alice", null, "alice", "alice") ) )); FreeStyleProject b = r.createFreeStyleProject(); b.setScm(new SubversionSCM("svn://localhost/bob", "1-alice", ".")); b.setAssignedNode(r.createSlave()); FreeStyleBuild run = r.buildAndAssertSuccess(b); /* TODO runSvnServe not guaranteed to use port 3690; otherwise this works: assertLogContains(Messages.CredentialsSVNAuthenticationProviderImpl_sole_credentials("alice/******", "<svn://localhost:3690> 8a677b3a-1c61-4b23-9212-1bf3c3d713a7"), run); */ } finally { p.kill(); } } }
/** * Do the polling on the slave and make sure it works. */ @Issue("JENKINS-4299") @Test public void polling() throws Exception { // SLAVE_DEBUG_PORT = 8001; File repo = new CopyExisting(getClass().getResource("two-revisions.zip")).allocate(); SubversionSCM scm = new SubversionSCM("file://" + repo.toURI().toURL().getPath()); FreeStyleProject p = r.createFreeStyleProject(); p.setScm(scm); p.setAssignedLabel(r.createSlave().getSelfLabel()); r.assertBuildStatusSuccess(p.scheduleBuild2(0).get()); // initial polling on the slave for the code path that doesn't find any change assertFalse(p.poll(StreamTaskListener.fromStdout()).hasChanges()); createCommit(scm, "foo"); // polling on the slave for the code path that doesn't find any change assertTrue(p.poll(StreamTaskListener.fromStdout()).hasChanges()); }
@Test public void masterPolling() throws Exception { File repo = new CopyExisting(getClass().getResource("two-revisions.zip")).allocate(); SubversionSCM scm = new SubversionSCM("file://" + repo.toURI().toURL().getPath()); scm.setPollFromMaster(true); FreeStyleProject p = r.createFreeStyleProject(); p.setScm(scm); p.setAssignedLabel(r.createSlave().getSelfLabel()); r.assertBuildStatusSuccess(p.scheduleBuild2(2).get()); // initial polling on the master for the code path that doesn't find any change assertFalse(p.poll(StreamTaskListener.fromStdout()).hasChanges()); // create a commit FreeStyleProject forCommit = r.createFreeStyleProject(); forCommit.setScm(scm); forCommit.setAssignedLabel(r.jenkins.getSelfLabel()); FreeStyleBuild b = r.assertBuildStatusSuccess(forCommit.scheduleBuild2(0).get()); FilePath newFile = b.getWorkspace().child("foo"); newFile.touch(System.currentTimeMillis()); SvnClientManager svnm = SubversionSCM.createClientManager(p); svnm.getWCClient().doAdd(new File(newFile.getRemote()),false,false,false, SVNDepth.INFINITY, false,false); SVNCommitClient cc = svnm.getCommitClient(); cc.doCommit(new File[]{new File(newFile.getRemote())},false,"added",null,null,false,false,SVNDepth.INFINITY); // polling on the master for the code path that doesn't find any change assertTrue(p.poll(StreamTaskListener.fromStdout()).hasChanges()); }
@Url("http://hudson.pastebin.com/m3ea34eea") @Test @Ignore("TODO use docker-fixtures for a reproducible test case") public void remoteCheckOut() throws Exception { DumbSlave s = r.createSlave(); FreeStyleProject p = r.createFreeStyleProject(); p.setAssignedLabel(s.getSelfLabel()); p.setScm(new SubversionSCM("https://svn.jenkins-ci.org/trunk/hudson/test-projects/trivial-ant/")); FreeStyleBuild b = r.assertBuildStatusSuccess(p.scheduleBuild2(0, new Cause.UserIdCause()).get()); assertTrue(b.getWorkspace().child("build.xml").exists()); r.assertBuildStatusSuccess(p.scheduleBuild2(0).get()); }