Search in sources :

Example 46 with SystemEnvironment

use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.

the class ArtifactsDiskIsLow method onTearDown.

public void onTearDown() throws Exception {
    new SystemEnvironment().clearProperty(SystemEnvironment.ARTIFACT_FULL_SIZE_LIMIT);
    new SystemEnvironment().clearProperty(SystemEnvironment.ARTIFACT_WARNING_SIZE_LIMIT);
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment)

Example 47 with SystemEnvironment

use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.

the class DiskSpaceSimulator method onTearDown.

public void onTearDown() {
    new SystemEnvironment().clearProperty(ARTIFACT_FULL_SIZE_LIMIT);
    new SystemEnvironment().clearProperty(ARTIFACT_WARNING_SIZE_LIMIT);
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment)

Example 48 with SystemEnvironment

use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.

the class DiskSpaceSimulator method simulateDiskSpaceLow.

public String simulateDiskSpaceLow() {
    onTearDown();
    long space = new File(".").getFreeSpace() / 1024;
    String limit = (space - 10) + "M";
    new SystemEnvironment().setProperty(ARTIFACT_WARNING_SIZE_LIMIT, limit);
    return limit;
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) File(java.io.File)

Example 49 with SystemEnvironment

use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.

the class AgentMain method main.

public static void main(String... argv) throws Exception {
    assertVMVersion();
    AgentBootstrapperArgs args = new AgentCLI().parse(argv);
    LogConfigurator logConfigurator = new LogConfigurator(DEFAULT_LOGBACK_CONFIGURATION_FILE);
    logConfigurator.initialize();
    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) LogConfigurator(com.thoughtworks.go.logging.LogConfigurator) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) AgentBootstrapperArgs(com.thoughtworks.go.agent.common.AgentBootstrapperArgs)

Example 50 with SystemEnvironment

use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.

the class AgentWebSocketClientControllerTest method processAssignWorkActionWithConsoleLogsThroughWebSockets.

@Test
public void processAssignWorkActionWithConsoleLogsThroughWebSockets() throws IOException, InterruptedException {
    SystemEnvironment env = new SystemEnvironment();
    env.set(SystemEnvironment.WEBSOCKET_ENABLED, true);
    env.set(SystemEnvironment.CONSOLE_LOGS_THROUGH_WEBSOCKET_ENABLED, true);
    ArgumentCaptor<Message> argumentCaptor = ArgumentCaptor.forClass(Message.class);
    agentController = createAgentController();
    agentController.init();
    agentController.process(new Message(Action.assignWork, MessageEncoding.encodeWork(new SleepWork("work1", 0))));
    assertThat(agentController.getAgentRuntimeInfo().getRuntimeStatus(), is(AgentRuntimeStatus.Idle));
    verify(webSocketSessionHandler, times(2)).sendAndWaitForAcknowledgement(argumentCaptor.capture());
    verify(artifactsManipulator).setProperty(null, new Property("work1_result", "done"));
    Message message = argumentCaptor.getAllValues().get(1);
    assertThat(message.getAcknowledgementId(), notNullValue());
    assertThat(message.getAction(), is(Action.ping));
    assertThat(message.getData(), is(MessageEncoding.encodeData(agentController.getAgentRuntimeInfo())));
    Message message2 = argumentCaptor.getAllValues().get(0);
    assertThat(message2.getAcknowledgementId(), notNullValue());
    assertThat(message2.getAction(), is(Action.consoleOut));
    ConsoleTransmission ct = MessageEncoding.decodeData(message2.getData(), ConsoleTransmission.class);
    assertThat(ct.getLine(), RegexMatcher.matches("Sleeping for 0 milliseconds"));
    env.set(SystemEnvironment.WEBSOCKET_ENABLED, false);
    env.set(SystemEnvironment.CONSOLE_LOGS_THROUGH_WEBSOCKET_ENABLED, false);
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) SleepWork(com.thoughtworks.go.work.SleepWork) Test(org.junit.Test)

Aggregations

SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)174 Test (org.junit.Test)93 Before (org.junit.Before)38 File (java.io.File)37 AgentInstance (com.thoughtworks.go.domain.AgentInstance)27 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)15 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)14 ArrayList (java.util.ArrayList)14 AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)11 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)10 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)10 AgentStatusChangeListener (com.thoughtworks.go.listener.AgentStatusChangeListener)10 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)9 AgentConfig (com.thoughtworks.go.config.AgentConfig)8 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)8 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)8 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)7 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)7 Date (java.util.Date)7 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)6