Search in sources :

Example 11 with Resource

use of org.jenkinsci.test.acceptance.junit.Resource in project acceptance-test-harness by jenkinsci.

the class Job method copyResource.

/**
 * "Copies" a resource (can be a single file or a directory) to the jobs workspace by utilizing a shell step.
 *
 * @param resourcePath the resource to copy
 */
public void copyResource(String resourcePath) {
    ensureConfigPage();
    final Resource res = resource(resourcePath);
    // decide whether to utilize copyResource or copyDir
    if (res.asFile().isDirectory()) {
        copyDir(res);
    } else {
        copyResource(res);
    }
}
Also used : Resource(org.jenkinsci.test.acceptance.junit.Resource)

Example 12 with Resource

use of org.jenkinsci.test.acceptance.junit.Resource in project acceptance-test-harness by jenkinsci.

the class LogParserTest method globalConfig.

@Before
public void globalConfig() {
    config = LogParserGlobalConfig.getInstance(jenkins.getConfigPage());
    parserRules = new HashMap<>();
    // initialize a sample rule for the following test cases
    Resource sampleRule = resource("/logparser_plugin/rules/log-parser-rules-sample");
    parserRules.put("sampleRule", "" + sampleRule.url.getPath());
    addLogParserRules(parserRules);
}
Also used : Resource(org.jenkinsci.test.acceptance.junit.Resource) Before(org.junit.Before)

Example 13 with Resource

use of org.jenkinsci.test.acceptance.junit.Resource in project acceptance-test-harness by jenkinsci.

the class LogParserTest method configureSampleJob.

private Job configureSampleJob() {
    FreeStyleJob job = jenkins.jobs.create(FreeStyleJob.class, "sampleJob");
    // configure job
    job.configure(() -> {
        LogParserPublisher lpp = job.addPublisher(LogParserPublisher.class);
        lpp.setRule(LogParserPublisher.RuleType.GLOBAL, parserRules.get("sampleRule"));
        // write sample output
        Resource sampleRule = resource("/logparser_plugin/console-outputs/sample-log");
        catToConsole(job, sampleRule.url.getPath());
    });
    return job;
}
Also used : LogParserPublisher(org.jenkinsci.test.acceptance.plugins.logparser.LogParserPublisher) Resource(org.jenkinsci.test.acceptance.junit.Resource)

Example 14 with Resource

use of org.jenkinsci.test.acceptance.junit.Resource in project acceptance-test-harness by jenkinsci.

the class GlobalPublishPluginTest method publish_slave_resourses.

@Test
public void publish_slave_resourses() throws IOException, InterruptedException, ExecutionException {
    DockerContainer dock = container.get();
    Resource cpFile = resource("/ftp_plugin/odes.txt");
    Slave s = slaves.get().install(jenkins).get();
    s.configure();
    s.save();
    FreeStyleJob j = jenkins.jobs.create();
    configurePublisher("asd", dock);
    j.configure();
    {
        j.copyResource(cpFile);
        PublishGlobalPublisher fp = addGlobalPublisher(j);
        PublishGlobalPublisher.GlobalPublishSite fps = fp.getDefault();
        fps.getDefaultTransfer().sourceFile.set("odes.txt");
    }
    j.save();
    j.startBuild().shouldSucceed();
    assertThat(dock.cp("/tmp/odes.txt", "/tmp"), is(true));
    assertThat(FileUtils.readFileToString(new File("/tmp/odes.txt")), CoreMatchers.is(cpFile.asText()));
}
Also used : DockerContainer(org.jenkinsci.test.acceptance.docker.DockerContainer) Slave(org.jenkinsci.test.acceptance.po.Slave) Resource(org.jenkinsci.test.acceptance.junit.Resource) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) PublishGlobalPublisher(org.jenkinsci.test.acceptance.plugins.publish_over.PublishGlobalPublisher) File(java.io.File) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) DockerTest(org.jenkinsci.test.acceptance.junit.DockerTest)

Example 15 with Resource

use of org.jenkinsci.test.acceptance.junit.Resource in project acceptance-test-harness by jenkinsci.

the class GlobalPublishPluginTest method publish_resources_with_excludes.

@Test
public void publish_resources_with_excludes() {
    DockerContainer dock = container.get();
    Resource cpDir = resource("/ftp_plugin/");
    FreeStyleJob j = jenkins.jobs.create();
    configurePublisher("asd", dock);
    j.configure();
    {
        j.copyDir(cpDir);
        PublishGlobalPublisher fp = addGlobalPublisher(j);
        PublishGlobalPublisher.GlobalPublishSite fps = fp.getDefault();
        fps.getDefaultTransfer().sourceFile.set("prefix_/");
        fps.getDefaultTransfer().excludes.set("**/*.exclude");
    }
    j.save();
    j.startBuild().shouldSucceed();
    assertThat(dock.cp("/tmp/prefix_/", "/tmp"), is(true));
    assertThat(!dock.cp("/tmp/prefix_/.exclude", "/tmp"), is(true));
}
Also used : DockerContainer(org.jenkinsci.test.acceptance.docker.DockerContainer) Resource(org.jenkinsci.test.acceptance.junit.Resource) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) PublishGlobalPublisher(org.jenkinsci.test.acceptance.plugins.publish_over.PublishGlobalPublisher) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) DockerTest(org.jenkinsci.test.acceptance.junit.DockerTest)

Aggregations

Resource (org.jenkinsci.test.acceptance.junit.Resource)23 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)20 Test (org.junit.Test)20 DockerTest (org.jenkinsci.test.acceptance.junit.DockerTest)19 FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)19 DockerContainer (org.jenkinsci.test.acceptance.docker.DockerContainer)17 PublishGlobalPublisher (org.jenkinsci.test.acceptance.plugins.publish_over.PublishGlobalPublisher)17 File (java.io.File)11 SshdContainer (org.jenkinsci.test.acceptance.docker.fixtures.SshdContainer)2 ScpGlobalConfig (org.jenkinsci.test.acceptance.plugins.scp.ScpGlobalConfig)2 Site (org.jenkinsci.test.acceptance.plugins.scp.ScpGlobalConfig.Site)2 ScpPublisher (org.jenkinsci.test.acceptance.plugins.scp.ScpPublisher)2 Ignore (org.junit.Ignore)2 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 Properties (java.util.Properties)1 DockerContainerHolder (org.jenkinsci.test.acceptance.docker.DockerContainerHolder)1 LogParserPublisher (org.jenkinsci.test.acceptance.plugins.logparser.LogParserPublisher)1 Plot (org.jenkinsci.test.acceptance.plugins.plot.Plot)1