Search in sources :

Example 1 with AgentBootstrapperArgs

use of com.thoughtworks.go.agent.common.AgentBootstrapperArgs in project gocd by gocd.

the class AgentBootstrapper method main.

public static void main(String[] argv) {
    BootstrapperLoggingHelper.initLog4j();
    AgentBootstrapperArgs args = new AgentCLI().parse(argv);
    new AgentBootstrapper().go(true, args);
}
Also used : AgentCLI(com.thoughtworks.go.agent.common.AgentCLI) AgentBootstrapperArgs(com.thoughtworks.go.agent.common.AgentBootstrapperArgs)

Example 2 with AgentBootstrapperArgs

use of com.thoughtworks.go.agent.common.AgentBootstrapperArgs in project gocd by gocd.

the class AgentBootstrapperFunctionalTest method shouldDownloadJarIfItDoesNotExist.

@Test
public void shouldDownloadJarIfItDoesNotExist() throws Exception {
    if (!OS_CHECKER.satisfy()) {
        File agentJar = new File("agent.jar");
        agentJar.delete();
        new AgentBootstrapper() {

            @Override
            void jvmExit(int returnValue) {
            }
        }.go(false, new AgentBootstrapperArgs(new URL("http://" + "localhost" + ":" + 9090 + "/go"), null, AgentBootstrapperArgs.SslMode.NONE));
        assertTrue("No agent downloaded", agentJar.exists());
        agentJar.delete();
    }
}
Also used : AgentBootstrapperArgs(com.thoughtworks.go.agent.common.AgentBootstrapperArgs) URL(java.net.URL) Test(org.junit.Test)

Example 3 with AgentBootstrapperArgs

use of com.thoughtworks.go.agent.common.AgentBootstrapperArgs in project gocd by gocd.

the class AgentBootstrapperFunctionalTest method shouldLoadAndBootstrapJarUsingAgentBootstrapCode_specifiedInAgentManifestFile.

@Test
public void shouldLoadAndBootstrapJarUsingAgentBootstrapCode_specifiedInAgentManifestFile() throws Exception {
    if (!OS_CHECKER.satisfy()) {
        PrintStream err = System.err;
        try {
            ByteArrayOutputStream os = new ByteArrayOutputStream();
            System.setErr(new PrintStream(os));
            File agentJar = new File("agent.jar");
            agentJar.delete();
            new AgentBootstrapper() {

                @Override
                void jvmExit(int returnValue) {
                }
            }.go(false, new AgentBootstrapperArgs(new URL("http://" + "localhost" + ":" + 9090 + "/go"), null, AgentBootstrapperArgs.SslMode.NONE));
            agentJar.delete();
            assertThat(new String(os.toByteArray()), containsString("Hello World Fellas!"));
        } finally {
            System.setErr(err);
        }
    }
}
Also used : AgentBootstrapperArgs(com.thoughtworks.go.agent.common.AgentBootstrapperArgs) StringContains.containsString(org.hamcrest.core.StringContains.containsString) URL(java.net.URL) Test(org.junit.Test)

Example 4 with AgentBootstrapperArgs

use of com.thoughtworks.go.agent.common.AgentBootstrapperArgs in project gocd by gocd.

the class DefaultAgentLaunchDescriptorImplTest method contextShouldContainEnvAndPropertiesAndHostAndPort.

@Test
public void contextShouldContainEnvAndPropertiesAndHostAndPort() throws Exception {
    String hostname = "xx.xx.xx";
    int port = 20;
    AgentBootstrapperArgs bootstrapperArgs = new AgentBootstrapperArgs(new URL("https://" + hostname + ":" + port + "/go"), null, AgentBootstrapperArgs.SslMode.NONE);
    DefaultAgentLaunchDescriptorImpl launchDescriptor = new DefaultAgentLaunchDescriptorImpl(bootstrapperArgs, new AgentBootstrapper());
    Map context = launchDescriptor.context();
    assertEquals(context, bootstrapperArgs.toProperties());
}
Also used : AgentBootstrapperArgs(com.thoughtworks.go.agent.common.AgentBootstrapperArgs) Map(java.util.Map) URL(java.net.URL) Test(org.junit.Test)

Example 5 with AgentBootstrapperArgs

use of com.thoughtworks.go.agent.common.AgentBootstrapperArgs in project gocd by gocd.

the class AgentMain method main.

public static void main(String... argv) throws Exception {
    AgentBootstrapperArgs args = new AgentCLI().parse(argv);
    LoggingHelper.configureLoggerIfNoneExists("go-agent.log", "go-agent-log4j.properties");
    new SystemEnvironment().setProperty("go.process.type", "agent");
    new SystemEnvironment().setProperty(SystemEnvironment.SERVICE_URL, args.getServerUrl().toString());
    new SystemEnvironment().setProperty(SystemEnvironment.AGENT_SSL_VERIFICATION_MODE, args.getSslMode().toString());
    if (args.getRootCertFile() != null) {
        new SystemEnvironment().setProperty(SystemEnvironment.AGENT_ROOT_CERT_FILE, args.getRootCertFile().toString());
    }
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
    ctx.registerShutdownHook();
}
Also used : AgentCLI(com.thoughtworks.go.agent.common.AgentCLI) SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) AgentBootstrapperArgs(com.thoughtworks.go.agent.common.AgentBootstrapperArgs)

Aggregations

AgentBootstrapperArgs (com.thoughtworks.go.agent.common.AgentBootstrapperArgs)11 URL (java.net.URL)8 Test (org.junit.Test)8 AgentLaunchDescriptor (com.thoughtworks.cruise.agent.common.launcher.AgentLaunchDescriptor)3 AgentLauncher (com.thoughtworks.cruise.agent.common.launcher.AgentLauncher)3 AgentCLI (com.thoughtworks.go.agent.common.AgentCLI)2 Map (java.util.Map)2 Semaphore (java.util.concurrent.Semaphore)2 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)1 HashMap (java.util.HashMap)1 StringContains.containsString (org.hamcrest.core.StringContains.containsString)1 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)1