Search in sources :

Example 1 with Slave

use of org.jenkinsci.test.acceptance.po.Slave in project acceptance-test-harness by jenkinsci.

the class OpenstackCloudPluginTest method sshSlaveShouldSurviveRestart.

@Test
@WithCredentials(credentialType = WithCredentials.USERNAME_PASSWORD, values = { MACHINE_USERNAME, "ath" })
@TestActivation({ "HARDWARE_ID", "IMAGE_ID", "KEY_PAIR_NAME", "NETWORK_ID" })
public void sshSlaveShouldSurviveRestart() {
    assumeTrue("This test requires a restartable Jenkins", jenkins.canRestart());
    configureCloudInit("cloud-init");
    configureProvisioning("SSH", "label");
    FreeStyleJob job = jenkins.jobs.create();
    job.configure();
    job.setLabelExpression("label");
    job.addShellStep("uname -a");
    job.save();
    Node created = job.scheduleBuild().waitUntilFinished(PROVISIONING_TIMEOUT).shouldSucceed().getNode();
    jenkins.restart();
    Node reconnected = job.scheduleBuild().waitUntilFinished(PROVISIONING_TIMEOUT).shouldSucceed().getNode();
    assertEquals(created, reconnected);
    Slave slave = ((Slave) reconnected);
    slave.open();
    slave.clickLink("Schedule Termination");
    waitFor(slave, pageObjectDoesNotExist(), 1000);
}
Also used : Slave(org.jenkinsci.test.acceptance.po.Slave) OpenstackOneOffSlave(org.jenkinsci.test.acceptance.plugins.openstack.OpenstackOneOffSlave) Node(org.jenkinsci.test.acceptance.po.Node) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) WithCredentials(org.jenkinsci.test.acceptance.junit.WithCredentials) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) TestActivation(org.jenkinsci.test.acceptance.junit.TestActivation)

Example 2 with Slave

use of org.jenkinsci.test.acceptance.po.Slave in project acceptance-test-harness by jenkinsci.

the class SshSlaveController method install.

@Override
public Future<Slave> install(Jenkins j) {
    ManagedCredentials credential = new ManagedCredentials(j);
    try {
        credential.open();
        if (credential.checkIfCredentialsExist(fingerprint) == null) {
            CredentialsPage cp = new CredentialsPage(j, ManagedCredentials.DEFAULT_DOMAIN);
            SshPrivateKeyCredential sc = cp.add(SshPrivateKeyCredential.class);
            sc.username.set(machine.getUser());
            sc.description.set(fingerprint);
            sc.selectEnterDirectly().privateKey.set(keyPair.readPrivateKey());
            cp.create();
        }
    } catch (IOException e) {
        throw new AssertionError(e);
    }
    final Slave s = create(machine.getPublicIpAddress(), j);
    // Slave is configured, now wait till its online
    return new Future<Slave>() {

        @Override
        public boolean cancel(boolean mayInterruptIfRunning) {
            return false;
        }

        @Override
        public boolean isCancelled() {
            return slaveWaitComplete.get();
        }

        @Override
        public boolean isDone() {
            return slaveWaitComplete.get() || s.isOnline();
        }

        @Override
        public Slave get() throws InterruptedException, ExecutionException {
            waitForOnLineSlave(s, slaveReadyTimeOutInSec);
            return s;
        }

        @Override
        public Slave get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
            if (unit != TimeUnit.SECONDS) {
                timeout = unit.toSeconds(timeout);
            }
            waitForOnLineSlave(s, (int) timeout);
            return s;
        }
    };
}
Also used : SshPrivateKeyCredential(org.jenkinsci.test.acceptance.plugins.ssh_credentials.SshPrivateKeyCredential) DumbSlave(org.jenkinsci.test.acceptance.po.DumbSlave) Slave(org.jenkinsci.test.acceptance.po.Slave) CredentialsPage(org.jenkinsci.test.acceptance.plugins.credentials.CredentialsPage) Future(java.util.concurrent.Future) TimeUnit(java.util.concurrent.TimeUnit) IOException(java.io.IOException) ManagedCredentials(org.jenkinsci.test.acceptance.plugins.credentials.ManagedCredentials)

Example 3 with Slave

use of org.jenkinsci.test.acceptance.po.Slave in project acceptance-test-harness by jenkinsci.

the class MailWatcherPluginTest method notify_slave_on_restart.

@Test
public void notify_slave_on_restart() throws Exception {
    assumeTrue("This test requires a restartable Jenkins", jenkins.canRestart());
    Future<Slave> futureSlave = slaveController.install(jenkins);
    Slave slave = futureSlave.get();
    slave.configure();
    {
        OnlineStatusNotification notification = new OnlineStatusNotification(slave);
        notification.onOnline("on@online.com");
        notification.onOffline("on@offline.com");
    }
    slave.save();
    jenkins.restart();
    mailhog.assertMail(regex("Computer %s marked offline", slave.getName()), "on@offline.com");
    mailhog.assertMail(regex("Computer %s marked online", slave.getName()), "on@online.com");
}
Also used : Slave(org.jenkinsci.test.acceptance.po.Slave) OnlineStatusNotification(org.jenkinsci.test.acceptance.plugins.mail_watcher.OnlineStatusNotification) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) DockerTest(org.jenkinsci.test.acceptance.junit.DockerTest)

Example 4 with Slave

use of org.jenkinsci.test.acceptance.po.Slave in project acceptance-test-harness by jenkinsci.

the class XvncPluginTest method setUp.

@Before
public void setUp() {
    Slave slave = containerHolder.get().connect(jenkins);
    slave.setLabels("xvnc");
    slave.save();
}
Also used : Slave(org.jenkinsci.test.acceptance.po.Slave) Before(org.junit.Before)

Example 5 with Slave

use of org.jenkinsci.test.acceptance.po.Slave in project acceptance-test-harness by jenkinsci.

the class DockerBuildStepTest method run_commands_remotelly.

@Test
public void run_commands_remotelly() throws Exception {
    Slave slave = slaveController.install(jenkins).get();
    FreeStyleJob job = jenkins.jobs.create();
    job.configure();
    job.setLabelExpression(slave.getName());
    job.copyDir(resource("/docker_build_step/context.dir"));
    command(job, DockerCommand.CreateImage.class).contextFolder("$WORKSPACE").tag("my_image");
    job.save();
    Build build = job.startBuild().waitUntilFinished();
    assertTrue(build.isSuccess());
}
Also used : Slave(org.jenkinsci.test.acceptance.po.Slave) Build(org.jenkinsci.test.acceptance.po.Build) DockerCommand(org.jenkinsci.test.acceptance.plugins.docker_build_step.DockerCommand) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) DockerTest(org.jenkinsci.test.acceptance.junit.DockerTest)

Aggregations

Slave (org.jenkinsci.test.acceptance.po.Slave)13 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)8 Test (org.junit.Test)8 FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)4 DockerTest (org.jenkinsci.test.acceptance.junit.DockerTest)3 DumbSlave (org.jenkinsci.test.acceptance.po.DumbSlave)3 Script (org.jenkinsci.test.acceptance.plugins.scriptler.Script)2 LocalSlaveController (org.jenkinsci.test.acceptance.slave.LocalSlaveController)2 File (java.io.File)1 IOException (java.io.IOException)1 ExecutionException (java.util.concurrent.ExecutionException)1 Future (java.util.concurrent.Future)1 TimeUnit (java.util.concurrent.TimeUnit)1 BasicFuture (org.apache.http.concurrent.BasicFuture)1 DockerContainer (org.jenkinsci.test.acceptance.docker.DockerContainer)1 Resource (org.jenkinsci.test.acceptance.junit.Resource)1 SmokeTest (org.jenkinsci.test.acceptance.junit.SmokeTest)1 TestActivation (org.jenkinsci.test.acceptance.junit.TestActivation)1 WithCredentials (org.jenkinsci.test.acceptance.junit.WithCredentials)1 CredentialsPage (org.jenkinsci.test.acceptance.plugins.credentials.CredentialsPage)1