@LocalData public void testMatrixBuildSummary() throws Exception { Hudson hudson = Hudson.getInstance(); List<MatrixProject> projects = hudson.getAllItems(MatrixProject.class); MatrixProject testProject = null; for (MatrixProject project : projects) { System.out.println(project.getName()); if (project.getName().equals("matrix-robot")) testProject = project; } if (testProject == null) fail("Couldn't find example project"); Future<MatrixBuild> run = testProject.scheduleBuild2(0); while (!run.isDone()) { Thread.sleep(5); } Run lastBuild = testProject.getLastBuild(); assertTrue("Build wasn't a success", lastBuild.getResult() == Result.SUCCESS); WebClient wc = getWebClient(); HtmlPage page = wc.goTo("job/matrix-robot"); WebAssert.assertElementPresentByXPath( page, "//div[@id='navigation']//a[@href='/job/matrix-robot/robot']"); WebAssert.assertElementPresentByXPath(page, "//td[@id='main-panel']//img[@src='robot/graph']"); page = wc.goTo("job/matrix-robot/3"); WebAssert.assertElementPresentByXPath( page, "//div[@id='navigation']//a[@href='/job/matrix-robot/3/robot']"); WebAssert.assertElementPresentByXPath( page, "//td[@id='main-panel']//h4[contains(.,'Robot Test Summary:')]"); WebAssert.assertElementPresentByXPath( page, "//td[@id='main-panel']//a[@href='/job/matrix-robot/3/robot' and contains(text(),'Browse results')]"); }
/** Test copying artifacts from a particular configuration of a matrix job */ public void testMatrixJob() throws Exception { MatrixProject other = createMatrixArtifactProject(); FreeStyleProject p = createProject(other.getName() + "/FOO=two", "", "", true, false, false); assertBuildStatusSuccess(other.scheduleBuild2(0, new UserCause()).get()); FreeStyleBuild b = p.scheduleBuild2(0, new UserCause()).get(); assertBuildStatusSuccess(b); assertFile(true, "foo.txt", b); assertFile(true, "two.txt", b); assertFile(true, "subdir/subfoo.txt", b); assertFile(true, "deepfoo/a/b/c.log", b); }
/** Test artifact copy between matrix jobs, for artifact from matching axis */ public void testMatrixToMatrix() throws Exception { MatrixProject other = createMatrixArtifactProject(), p = createMatrixProject(); p.setAxes(new AxisList(new Axis("FOO", "one", "two"))); // should match other job p.getBuildersList() .add( new CopyArtifact( other.getName() + "/FOO=$FOO", new StatusBuildSelector(true), "", "", false, false)); assertBuildStatusSuccess(other.scheduleBuild2(0, new UserCause()).get()); MatrixBuild b = p.scheduleBuild2(0, new UserCause()).get(); assertBuildStatusSuccess(b); MatrixRun r = b.getRun(new Combination(Collections.singletonMap("FOO", "one"))); assertFile(true, "one.txt", r); assertFile(false, "two.txt", r); r = b.getRun(new Combination(Collections.singletonMap("FOO", "two"))); assertFile(false, "one.txt", r); assertFile(true, "two.txt", r); }
/** Test copying artifacts from all configurations of a matrix job */ public void testMatrixAll() throws Exception { MatrixProject mp = createMatrixProject(); mp.setAxes(new AxisList(new Axis("ARCH", "sparc", "x86"))); mp.getBuildersList().add(new ArchMatrixBuilder()); mp.getPublishersList().add(new ArtifactArchiver("target/*", "", false)); assertBuildStatusSuccess(mp.scheduleBuild2(0, new UserCause()).get()); FreeStyleProject p = createProject(mp.getName(), "", "", true, false, false); FreeStyleBuild b = p.scheduleBuild2(0, new UserCause()).get(); assertBuildStatusSuccess(b); assertFile(true, "ARCH=sparc/target/readme.txt", b); assertFile(true, "ARCH=sparc/target/sparc.out", b); assertFile(true, "ARCH=x86/target/readme.txt", b); assertFile(true, "ARCH=x86/target/x86.out", b); }
public void testNoInterpreter() throws Exception { ToxBuilder builder = new ToxBuilder("tox.ini", false, null); MatrixProject project = createMatrixProject(); AxisList axes = new AxisList(new ToxAxis(new String[] {"py27"})); project.setAxes(axes); project.getBuildersList().add(builder); MatrixBuild build = project.scheduleBuild2(0).get(); List<MatrixRun> runs = build.getRuns(); assertEquals(1, runs.size()); MatrixRun run = runs.get(0); String log = FileUtils.readFileToString(run.getLogFile()); assertTrue( "should not have found an interpreter:\n" + log, log.contains(Messages.BuilderUtil_NoInterpreterFound())); }
public void testNoAxis() throws Exception { ToxBuilder builder = new ToxBuilder("tox.ini", false, null); MatrixProject project = createMatrixProject(); AxisList axes = new AxisList(new TextAxis("TOTO", "TUTU")); project.setAxes(axes); project.getBuildersList().add(builder); MatrixBuild build = project.scheduleBuild2(0).get(); List<MatrixRun> runs = build.getRuns(); assertEquals(1, runs.size()); MatrixRun run = runs.get(0); String log = FileUtils.readFileToString(run.getLogFile()); assertTrue( "should not have found a tox axis:\n" + log, log.contains(Messages.ToxBuilder_ToxAxis_Required())); }
public void testToxAxisSuccessful() throws Exception { configureCPython2(); ToxBuilder builder = new ToxBuilder("tox.ini", false, null); MatrixProject project = createMatrixProject(); AxisList axes = new AxisList(new ToxAxis(new String[] {"py27"})); project.setScm(new ToxSCM("tox.ini", "[testenv]\ncommand = echo")); project.setAxes(axes); project.getBuildersList().add(builder); MatrixBuild build = project.scheduleBuild2(0).get(); List<MatrixRun> runs = build.getRuns(); assertEquals(1, runs.size()); MatrixRun run = runs.get(0); String log = FileUtils.readFileToString(run.getLogFile()); assertTrue("tox should have been successful:\n" + log, log.contains("congratulations :)")); assertTrue("build should have been successful:\n" + log, log.contains("SUCCESS")); }
public void testToxenvPatternBlank() throws Exception { configureCPython2(); ToxBuilder builder = new ToxBuilder("tox.ini", false, "$FOOBAR"); MatrixProject project = createMatrixProject(); AxisList axes = new AxisList(new TextAxis("FOOBAR2", "badluck")); project.setScm(new ToxSCM("tox.ini", "[testenv]\ncommand = echo")); project.setAxes(axes); project.getBuildersList().add(builder); MatrixBuild build = project.scheduleBuild2(0).get(); List<MatrixRun> runs = build.getRuns(); assertEquals(1, runs.size()); MatrixRun run = runs.get(0); String log = FileUtils.readFileToString(run.getLogFile()); System.out.println(log); assertTrue( "should not be able to run with a blank TOXENV pattern:\n" + log, log.contains(Messages.ToxBuilder_ToxenvPattern_Invalid("$FOOBAR"))); }
public void testToxAxisAndToxenvPattern() throws Exception { configureCPython2(); ToxBuilder builder = new ToxBuilder("tox.ini", false, "$INTERPRETER$VERSION"); MatrixProject project = createMatrixProject(); AxisList axes = new AxisList( new ToxAxis(new String[] {"py27"}), new TextAxis("INTERPRETER", "py"), new TextAxis("VERSION", "27")); project.setScm(new ToxSCM("tox.ini", "[testenv]\ncommand = echo")); project.setAxes(axes); project.getBuildersList().add(builder); MatrixBuild build = project.scheduleBuild2(0).get(); List<MatrixRun> runs = build.getRuns(); assertEquals(1, runs.size()); MatrixRun run = runs.get(0); String log = FileUtils.readFileToString(run.getLogFile()); System.out.println(log); assertTrue( "should not be able to run with both Tox axis and TOXENV pattern:\n" + log, log.contains(Messages.ToxBuilder_ToxAxis_And_ToxenvPattern())); }