@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()); }
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()); } }
/** * 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()); }
@LocalData @Test public void testSlave() throws Exception { DumbSlave s = rule.createOnlineSlave(); project.setAssignedLabel(s.getSelfLabel()); FilePath src = new FilePath(rule.jenkins.getRootPath(), "jobs/" + BASIC_TEST_PROJECT + "/workspace/"); assertNotNull(src); FilePath dest = s.getWorkspaceFor(project); assertNotNull(dest); src.copyRecursiveTo("*.xml", dest); testBasic(); }
@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()); }
@RandomlyFails("TimeoutException from basic") @LocalData("All") @Test public void slave() throws Exception { DumbSlave s = j.createOnlineSlave(); project.setAssignedLabel(s.getSelfLabel()); FilePath src = new FilePath(j.jenkins.getRootPath(), "jobs/junit/workspace/"); assertNotNull(src); FilePath dest = s.getWorkspaceFor(project); assertNotNull(dest); src.copyRecursiveTo("*.xml", dest); basic(); }
private void doRepeatedArchiving(boolean slave) throws Exception { if (slave) { DumbSlave s = j.createOnlineSlave(); project.setAssignedLabel(s.getSelfLabel()); } project.getPublishersList().removeAll(JUnitResultArchiver.class); project.getBuildersList().add(new SimpleArchive("A", 7, 0)); project.getBuildersList().add(new SimpleArchive("B", 0, 1)); FreeStyleBuild build = j.assertBuildStatus(Result.UNSTABLE, project.scheduleBuild2(0).get()); List<TestResultAction> actions = build.getActions(TestResultAction.class); assertEquals(1, actions.size()); TestResultAction testResultAction = actions.get(0); TestResult result = testResultAction.getResult(); assertNotNull("no TestResult", result); assertEquals("should have 1 failing test", 1, testResultAction.getFailCount()); assertEquals("should have 1 failing test", 1, result.getFailCount()); assertEquals("should have 8 total tests", 8, testResultAction.getTotalCount()); assertEquals("should have 8 total tests", 8, result.getTotalCount()); assertEquals(/* ⅞ = 87.5% */87, testResultAction.getBuildHealth().getScore()); } public static final class SimpleArchive extends Builder {
@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()); }