use of org.jenkinsci.test.acceptance.po.DumbSlave in project acceptance-test-harness by jenkinsci.
the class CheckStylePluginTest method should_show_warnings_per_user.
/**
* Verifies that blaming of warnings works on agents: creates a new project in a Git repository in a docker
* container. Registers the same docker container as slave agent to build the project. Uses the recorded build
* results in checkstyle-result.xml (no actual maven goal is invoked). Verifies that the blame information is
* correctly assigned for each of the warnings. Also checks, that the age is increased for yet another build.
*/
@Test
@WithPlugins({ "git", "dashboard-view", "analysis-core@1.88-SNAPSHOT", "ssh-slaves" })
@WithDocker
@Issue("JENKINS-6748")
@WithCredentials(credentialType = WithCredentials.SSH_USERNAME_PRIVATE_KEY, values = { CREDENTIALS_ID, CREDENTIALS_KEY })
public void should_show_warnings_per_user() {
// avoid JENKINS-49026
jenkins.restart();
DumbSlave agent = createDockerAgent();
String gitRepositoryUrl = createGitRepositoryInDockerContainer();
FreeStyleJob job = createFreeStyleJob(jenkins, null, settings -> settings.pattern.set("**/checkstyle-result.xml"));
job.configure(() -> {
job.useScm(GitScm.class).url(gitRepositoryUrl).credentials(CREDENTIALS_ID);
job.setLabelExpression(agent.getName());
});
buildSuccessfulJob(job);
CheckStyleAction action = new CheckStyleAction(job);
action.open();
SortedMap<String, Integer> expectedPeople = new TreeMap<>();
expectedPeople.put("Unknown authors", 1);
expectedPeople.put("Jenkins-ATH <jenkins-ath@example.org>", 11);
assertThat(action.getPeopleTabContents(), is(expectedPeople));
action.find(By.partialLinkText("Jenkins-ATH")).click();
assertThat(driver, hasContent("Checkstyle Warnings - Jenkins-ATH"));
action.open();
SortedMap<String, String> expectedOrigin = new TreeMap<>();
expectedOrigin.put("Main.java:0", "-");
expectedOrigin.put("Main.java:2", "Jenkins-ATH");
expectedOrigin.put("Main.java:4", "Jenkins-ATH");
expectedOrigin.put("Main.java:6", "Jenkins-ATH");
expectedOrigin.put("Main.java:9", "Jenkins-ATH");
expectedOrigin.put("Main.java:13", "Jenkins-ATH");
expectedOrigin.put("Main.java:18", "Jenkins-ATH");
expectedOrigin.put("Main.java:23", "Jenkins-ATH");
expectedOrigin.put("Main.java:24", "Jenkins-ATH");
expectedOrigin.put("Main.java:27", "Jenkins-ATH");
assertThat(action.getOriginTabContentsAsStrings(AUTHOR), is(expectedOrigin));
assertThatAgeIsAt(action, expectedOrigin, 1);
buildSuccessfulJob(job);
assertThatAgeIsAt(action, expectedOrigin, 2);
GraphConfigurationView view = action.configureTrendGraphForUser();
view.open();
view.setUserGraph();
view.save();
WebElement graph = find(getUsersTrendGraphXpath());
assertThat(graph.isDisplayed(), is(true));
verifyNoAuthors(action, true);
WebElement nothing = getElement(getUsersTrendGraphXpath());
assertThat(nothing, nullValue());
verifyNoAuthors(action, false);
}
use of org.jenkinsci.test.acceptance.po.DumbSlave in project acceptance-test-harness by jenkinsci.
the class WarningsPluginTest method should_parse_codenarc_on_agent.
@Test
@Issue("JENKINS-17787")
@WithPlugins({ "violations", "ssh-slaves" })
@WithDocker
@Ignore("Reproduces JENKINS-17787")
@WithCredentials(credentialType = WithCredentials.SSH_USERNAME_PRIVATE_KEY, values = { CREDENTIALS_ID, CREDENTIALS_KEY })
public void should_parse_codenarc_on_agent() {
DumbSlave dockerSlave = createDockerAgent();
FreeStyleJob job = prepareDockerSlave(dockerSlave);
assertThatCodeNarcActionExists(job);
}
use of org.jenkinsci.test.acceptance.po.DumbSlave in project acceptance-test-harness by jenkinsci.
the class WarningsPluginTest method should_scan_console_log_of_slave_build.
@Test
@WithDocker
@WithCredentials(credentialType = WithCredentials.SSH_USERNAME_PRIVATE_KEY, values = { CREDENTIALS_ID, CREDENTIALS_KEY })
@WithPlugins("ssh-slaves")
public void should_scan_console_log_of_slave_build() throws ExecutionException, InterruptedException {
DumbSlave dockerSlave = createDockerAgent();
FreeStyleJob job = prepareDockerSlave(dockerSlave);
job.configure();
job.copyResource(resource(RESOURCE_WARNING_MAIN_JAVA_PATH));
ShellBuildStep shellBuildStep = job.addBuildStep(ShellBuildStep.class);
shellBuildStep.command(CMD_WARNING_MAIN_JAVA_CONSOLE);
WarningsPublisher warningsPublisher = job.addPublisher(WarningsPublisher.class);
warningsPublisher.addConsoleScanner(JAVA_ID);
job.save();
Build build = job.startBuild().shouldSucceed();
assertThatActionExists(job, build, "Java Warnings");
WarningsAction action = createJavaResultAction(build);
assertThatWarningsCountInSummaryIs(action, 3);
String codeLine = action.getLinkedSourceFileText(AnalysisAction.Tab.DETAILS, "WarningMain.java", 10);
String[] codeLineArr = codeLine.trim().split("\\s+", 2);
assertThat("Warning should be at line", codeLineArr[0], is("10"));
assertThat("Assert failed comparing code line is", codeLineArr[1], is("text = (TextClass) text2;"));
}
use of org.jenkinsci.test.acceptance.po.DumbSlave in project acceptance-test-harness by jenkinsci.
the class SshSlaveController method create.
private Slave create(String host, Jenkins j) {
// Just to make sure the dumb slave is set up properly, we should seed it
// with a FS root and executors
final DumbSlave s = j.slaves.create(DumbSlave.class);
s.find(by.input("_.host")).sendKeys(host);
elasticSleep(25);
final Select cId = new Select(s.find(by.input("_.credentialsId")));
final String credentialName = String.format("%s (%s)", machine.getUser(), fingerprint);
waitFor().until(new Callable<Object>() {
@Override
public Object call() throws Exception {
List<WebElement> options = cId.getOptions();
for (WebElement e : options) {
if (credentialName.equals(e.getText()))
return true;
}
return false;
}
});
cId.selectByVisibleText(credentialName);
s.setExecutors(1);
s.save();
return s;
}
use of org.jenkinsci.test.acceptance.po.DumbSlave in project acceptance-test-harness by jenkinsci.
the class TSRCreateSlaveTest method newSlave.
@Test
@Since("1.560")
public void newSlave() {
// this test requires a newer version of credentials plugin that has inline "Add" button
// I'm not sure exactly which version it is, but 1.532 LTS doesn't have it, and 1.555 has it,
// so it's somewhere in between
// TODO: this should be converted to "@WithPlugin("ssh-credentials") with specific version tag,
// not the core version
// Just to make sure the dumb slave is set up properly, we should seed it
// with a FS root and executors
final DumbSlave s = jenkins.slaves.create(DumbSlave.class);
{
SshSlaveLauncher l = s.setLauncher(SshSlaveLauncher.class);
String username = "user1";
String privateKey = "1212122112";
String description = "Ssh key";
l.host.set("127.0.0.1");
// make sure this exists
l.credentialsId.resolve();
try {
l.credentialsId.select(String.format("%s (%s)", username, description));
fail();
} catch (NoSuchElementException e) {
// ignore
}
SshCredentialDialog f = l.addCredential();
{
SshPrivateKeyCredential sc = f.select(SshPrivateKeyCredential.class);
sc.description.set(description);
sc.username.set(username);
sc.selectEnterDirectly().privateKey.set(privateKey);
}
f.add();
l.credentialsId.select(String.format("%s (%s)", username, description));
}
s.save();
}
Aggregations