Search in sources :

Example 21 with AgentRuntimeInfo

use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.

the class BuildWorkTest method shouldMaskSecretInEnvironmentVarialbeReport.

@Test
public void shouldMaskSecretInEnvironmentVarialbeReport() throws Exception {
    buildWork = (BuildWork) getWork(WITH_SECRET_ENV_VAR, PIPELINE_NAME);
    buildWork.doWork(environmentVariableContext, new AgentWorkContext(agentIdentifier, buildRepository, artifactManipulator, new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false), packageRepositoryExtension, scmExtension, taskExtension, null, pluginRequestProcessorRegistry));
    String consoleOut = artifactManipulator.consoleOut();
    assertThat(consoleOut, containsString("[go] setting environment variable 'foo' to value 'foo(******)'"));
    assertThat(consoleOut, containsString("[go] setting environment variable 'bar' to value '********'"));
    assertThat(consoleOut, not(containsString("i am a secret")));
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Example 22 with AgentRuntimeInfo

use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.

the class BuildWorkTest method shouldReportConsoleout.

@Test
public void shouldReportConsoleout() throws Exception {
    buildWork = (BuildWork) getWork(WILL_FAIL, PIPELINE_NAME);
    buildWork.doWork(environmentVariableContext, new AgentWorkContext(agentIdentifier, buildRepository, artifactManipulator, new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false), packageRepositoryExtension, scmExtension, taskExtension, null, pluginRequestProcessorRegistry));
    String consoleOutAsString = artifactManipulator.consoleOut();
    String locator = JOB_IDENTIFIER.buildLocator();
    assertThat(consoleOutAsString, printedPreparingInfo(locator));
    assertThat(consoleOutAsString, printedBuildingInfo(locator));
    assertThat(consoleOutAsString, printedUploadingInfo(locator));
    assertThat(consoleOutAsString, printedBuildFailed());
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Example 23 with AgentRuntimeInfo

use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.

the class AgentRemoteHandlerTest method removeRegisteredAgent.

@Test
public void removeRegisteredAgent() throws Exception {
    AgentInstance instance = AgentInstanceMother.idle();
    AgentRuntimeInfo info = new AgentRuntimeInfo(instance.getAgentIdentifier(), AgentRuntimeStatus.Idle, null, null, false);
    when(remote.ping(any(AgentRuntimeInfo.class))).thenReturn(new AgentInstruction(false));
    when(remote.getCookie(instance.getAgentIdentifier(), info.getLocation())).thenReturn("new cookie");
    when(agentService.findAgent(instance.getUuid())).thenReturn(instance);
    handler.process(agent, new Message(Action.ping, MessageEncoding.encodeData(info)));
    handler.remove(agent);
    assertEquals(0, handler.connectedAgents().size());
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) AgentInstruction(com.thoughtworks.go.remote.AgentInstruction) Test(org.junit.Test)

Example 24 with AgentRuntimeInfo

use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.

the class AgentRemoteHandlerTest method reportCompleted.

@Test
public void reportCompleted() throws Exception {
    AgentRuntimeInfo info = new AgentRuntimeInfo(new AgentIdentifier("HostName", "ipAddress", "uuid"), AgentRuntimeStatus.Idle, null, null, false);
    JobIdentifier jobIdentifier = new JobIdentifier();
    handler.process(agent, new Message(Action.reportCompleted, MessageEncoding.encodeData(new Report(info, jobIdentifier, JobResult.Passed))));
    verify(remote).reportCompleted(info, jobIdentifier, JobResult.Passed);
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) Test(org.junit.Test)

Example 25 with AgentRuntimeInfo

use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.

the class AgentRemoteHandlerTest method shouldNotSetDupCookieForSameAgent.

@Test
public void shouldNotSetDupCookieForSameAgent() throws Exception {
    AgentInstance instance = AgentInstanceMother.idle();
    AgentRuntimeInfo info = new AgentRuntimeInfo(instance.getAgentIdentifier(), AgentRuntimeStatus.Idle, null, null, false);
    when(remote.ping(any(AgentRuntimeInfo.class))).thenReturn(new AgentInstruction(false));
    when(remote.getCookie(instance.getAgentIdentifier(), info.getLocation())).thenReturn("cookie");
    when(agentService.findAgent(instance.getUuid())).thenReturn(instance);
    handler.process(agent, new Message(Action.ping, MessageEncoding.encodeData(info)));
    info.setCookie(null);
    reset(remote);
    when(remote.ping(any(AgentRuntimeInfo.class))).thenReturn(new AgentInstruction(false));
    when(remote.getCookie(instance.getAgentIdentifier(), info.getLocation())).thenReturn("new cookie");
    handler.process(agent, new Message(Action.ping, MessageEncoding.encodeData(info)));
    verify(remote).ping(withCookie(info, "cookie"));
    info.setCookie(null);
    handler.remove(agent);
    reset(remote);
    when(remote.ping(any(AgentRuntimeInfo.class))).thenReturn(new AgentInstruction(false));
    when(remote.getCookie(instance.getAgentIdentifier(), info.getLocation())).thenReturn("new cookie");
    handler.process(agent, new Message(Action.ping, MessageEncoding.encodeData(info)));
    verify(remote).ping(withCookie(info, "new cookie"));
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) AgentInstruction(com.thoughtworks.go.remote.AgentInstruction) Test(org.junit.Test)

Aggregations

AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)150 Test (org.junit.jupiter.api.Test)70 Test (org.junit.Test)52 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)35 AgentStatusChangeListener (com.thoughtworks.go.listener.AgentStatusChangeListener)29 File (java.io.File)17 RemoteInvocation (org.springframework.remoting.support.RemoteInvocation)16 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)14 Agent (com.thoughtworks.go.config.Agent)13 AgentInstruction (com.thoughtworks.go.remote.AgentInstruction)13 FakeBuildRepositoryRemote (com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote)12 AgentInstance.createFromLiveAgent (com.thoughtworks.go.domain.AgentInstance.createFromLiveAgent)11 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)11 AgentBuildingInfo (com.thoughtworks.go.server.service.AgentBuildingInfo)11 UploadEntry (com.thoughtworks.go.matchers.UploadEntry)10 ArrayList (java.util.ArrayList)10 StringContains.containsString (org.hamcrest.core.StringContains.containsString)9 AgentInstance (com.thoughtworks.go.domain.AgentInstance)8 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)8 NullAgentInstance (com.thoughtworks.go.domain.NullAgentInstance)7