Skip to content
Permalink
Browse files
JENKINS-33288 Xvfb error does not fail build
  • Loading branch information
zregvart committed Mar 20, 2016
1 parent 050a80c commit 5915aae09d545964b574c6642fbf8803d5def48e
Showing with 55 additions and 55 deletions.
  1. +1 −1 src/main/java/org/jenkinsci/plugins/xvfb/Xvfb.java
  2. +54 −54 src/test/java/org/jenkinsci/plugins/xvfb/XvfbBuildWrapperTest.java
@@ -565,7 +565,7 @@ private XvfbEnvironment launchXvfb(final Run<?, ?> run, final FilePath workspace
if (installation == null) {
listener.error(Messages.XvfbBuildWrapper_NoInstallationsConfigured());

throw new InterruptedException();
throw new RunnerAbortedException();
}

final ArgumentListBuilder cmd = createCommandArguments(installation, frameBufferDir, displayNameUsed);
@@ -142,20 +142,66 @@ public void setupXvfbInstallations() throws IOException {
setupXvfbInstallations(system.jenkins, tempDir);
}

@Test
public void shouldCreateCommandLineArguments() throws IOException {
final Xvfb xvfb = new Xvfb();
xvfb.setInstallationName("cmd");
xvfb.setDisplayName(42);

final XvfbInstallation installation = new XvfbInstallation("cmd", "/usr/local/cmd-xvfb", null);

final File tempDirRoot = tempDir.getRoot();
final ArgumentListBuilder arguments = xvfb.createCommandArguments(installation, new FilePath(tempDirRoot), 42);

assertThat(arguments.toList(), contains("/usr/local/cmd-xvfb/Xvfb", ":42", "-screen", "0", Xvfb.DEFAULT_SCREEN, "-fbdir", tempDirRoot.getAbsolutePath()));
}

@Test
@Issue("JENKINS-32039")
public void shouldCreateCommandLineArgumentsWithoutScreenIfEmpty() throws IOException {
final Xvfb xvfb = new Xvfb();
xvfb.setInstallationName("cmd");
xvfb.setDisplayName(42);
xvfb.setScreen("");

final XvfbInstallation installation = new XvfbInstallation("cmd", "/usr/local/cmd-xvfb", null);

final File tempDirRoot = tempDir.getRoot();
final ArgumentListBuilder arguments = xvfb.createCommandArguments(installation, new FilePath(tempDirRoot), 42);

assertThat(arguments.toList(), contains("/usr/local/cmd-xvfb/Xvfb", ":42", "-fbdir", tempDirRoot.getAbsolutePath()));
}

@Test
@Issue("JENKINS-32039")
public void shouldCreateCommandLineArgumentsWithoutScreenIfNotGiven() throws IOException {
final Xvfb xvfb = new Xvfb();
xvfb.setInstallationName("cmd");
xvfb.setDisplayName(42);
xvfb.setScreen(null);

final XvfbInstallation installation = new XvfbInstallation("cmd", "/usr/local/cmd-xvfb", null);

final File tempDirRoot = tempDir.getRoot();
final ArgumentListBuilder arguments = xvfb.createCommandArguments(installation, new FilePath(tempDirRoot), 42);

assertThat(arguments.toList(), contains("/usr/local/cmd-xvfb/Xvfb", ":42", "-fbdir", tempDirRoot.getAbsolutePath()));
}

@SuppressWarnings("unchecked")
@Test
public void shouldAbortIfInstallationIsNotFound() throws Exception {
public void shouldFailIfInstallationIsNotFound() throws Exception {
final Xvfb xvfb = new Xvfb();
xvfb.setInstallationName("nonexistant");

final FreeStyleProject project = createFreeStyleJob(system, "shouldAbortIfInstallationIsNotFound");
final FreeStyleProject project = createFreeStyleJob(system, "shouldFailIfInstallationIsNotFound");
setupXvfbOn(project, xvfb);

final QueueTaskFuture<FreeStyleBuild> buildResult = project.scheduleBuild2(0);

final FreeStyleBuild build = buildResult.get();

system.assertBuildStatus(Result.ABORTED, build);
system.assertBuildStatus(Result.FAILURE, build);

final List<String> logLines = build.getLog(10);

@@ -164,17 +210,17 @@ public void shouldAbortIfInstallationIsNotFound() throws Exception {

@SuppressWarnings("unchecked")
@Test
public void shouldAbortIfNoInstallationIsDefined() throws Exception {
public void shouldFailIfNoInstallationIsDefined() throws Exception {
final Xvfb xvfb = new Xvfb();

final FreeStyleProject project = createFreeStyleJob(system, "shouldAbortIfNoInstallationIsDefined");
final FreeStyleProject project = createFreeStyleJob(system, "shouldFailIfNoInstallationIsDefined");
setupXvfbOn(project, xvfb);

final QueueTaskFuture<FreeStyleBuild> buildResult = project.scheduleBuild2(0);

final FreeStyleBuild build = buildResult.get();

system.assertBuildStatus(Result.ABORTED, build);
system.assertBuildStatus(Result.FAILURE, build);

final List<String> logLines = build.getLog(10);

@@ -184,12 +230,12 @@ public void shouldAbortIfNoInstallationIsDefined() throws Exception {
@SuppressWarnings("unchecked")
@Test
@Issue("JENKINS-18094")
public void shouldAbortIfXvfbFailsToStart() throws Exception {
public void shouldFailIfXvfbFailsToStart() throws Exception {
final Xvfb xvfb = new Xvfb();
xvfb.setInstallationName("failing");
xvfb.setTimeout(10);

final FreeStyleProject project = createFreeStyleJob(system, "shouldAbortIfXvfbFailsToStart");
final FreeStyleProject project = createFreeStyleJob(system, "shouldFailIfXvfbFailsToStart");
setupXvfbOn(project, xvfb);

final QueueTaskFuture<FreeStyleBuild> buildResult = project.scheduleBuild2(0);
@@ -205,52 +251,6 @@ public void shouldAbortIfXvfbFailsToStart() throws Exception {

}

@Test
public void shouldCreateCommandLineArguments() throws IOException {
final Xvfb xvfb = new Xvfb();
xvfb.setInstallationName("cmd");
xvfb.setDisplayName(42);

final XvfbInstallation installation = new XvfbInstallation("cmd", "/usr/local/cmd-xvfb", null);

final File tempDirRoot = tempDir.getRoot();
final ArgumentListBuilder arguments = xvfb.createCommandArguments(installation, new FilePath(tempDirRoot), 42);

assertThat(arguments.toList(), contains("/usr/local/cmd-xvfb/Xvfb", ":42", "-screen", "0", Xvfb.DEFAULT_SCREEN, "-fbdir", tempDirRoot.getAbsolutePath()));
}

@Test
@Issue("JENKINS-32039")
public void shouldCreateCommandLineArgumentsWithoutScreenIfNotGiven() throws IOException {
final Xvfb xvfb = new Xvfb();
xvfb.setInstallationName("cmd");
xvfb.setDisplayName(42);
xvfb.setScreen(null);

final XvfbInstallation installation = new XvfbInstallation("cmd", "/usr/local/cmd-xvfb", null);

final File tempDirRoot = tempDir.getRoot();
final ArgumentListBuilder arguments = xvfb.createCommandArguments(installation, new FilePath(tempDirRoot), 42);

assertThat(arguments.toList(), contains("/usr/local/cmd-xvfb/Xvfb", ":42", "-fbdir", tempDirRoot.getAbsolutePath()));
}

@Test
@Issue("JENKINS-32039")
public void shouldCreateCommandLineArgumentsWithoutScreenIfEmpty() throws IOException {
final Xvfb xvfb = new Xvfb();
xvfb.setInstallationName("cmd");
xvfb.setDisplayName(42);
xvfb.setScreen("");

final XvfbInstallation installation = new XvfbInstallation("cmd", "/usr/local/cmd-xvfb", null);

final File tempDirRoot = tempDir.getRoot();
final ArgumentListBuilder arguments = xvfb.createCommandArguments(installation, new FilePath(tempDirRoot), 42);

assertThat(arguments.toList(), contains("/usr/local/cmd-xvfb/Xvfb", ":42", "-fbdir", tempDirRoot.getAbsolutePath()));
}

@Test
public void shouldHonourSpecifiedDisplayNameOffset() throws Exception {
final Xvfb xvfb = new Xvfb();

0 comments on commit 5915aae

Please sign in to comment.