Search in sources :

Example 6 with AgentIdentifier

use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.

the class BuildWorkArtifactUploadingTest method shouldFailBuildWhenNothingMatchedUsingMatcherStartDotStart.

@Test
public void shouldFailBuildWhenNothingMatchedUsingMatcherStartDotStart() throws Exception {
    ArtifactPlans artifactPlans = new ArtifactPlans();
    artifactPlans.add(new ArtifactPlan("target/pkg/*.*", "MYDEST"));
    BuildAssignment buildAssigment = createAssignment(artifactPlans, new String[] { "target/pkg/" });
    BuildWork work = new BuildWork(buildAssigment);
    GoArtifactsManipulatorStub manipulator = new GoArtifactsManipulatorStub();
    BuildRepositoryRemoteStub repository = new BuildRepositoryRemoteStub();
    AgentIdentifier agentIdentifier = new AgentIdentifier("somename", "127.0.0.1", AGENT_UUID);
    work.doWork(agentIdentifier, repository, manipulator, environmentVariableContext, new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false), packageRepositoryExtension, scmExtension, taskExtension);
    List<UploadEntry> entries = manipulator.uploadEntries();
    assertThat(entries.size(), is(0));
    assertThat(repository.states, containsResult(JobState.Building));
    assertThat(repository.states, containsResult(JobState.Completing));
    assertThat(repository.results, containsResult(JobResult.Failed));
    assertThat(manipulator.consoleOut(), printedRuleDoesNotMatchFailure(buildWorkingDirectory.getPath(), "target/pkg/*.*"));
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) UploadEntry(com.thoughtworks.go.matchers.UploadEntry) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) Test(org.junit.Test)

Example 7 with AgentIdentifier

use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.

the class AgentRuntimeInfoTest method shouldHaveBeautifulPhigureLikeDisplayString.

@Test
public void shouldHaveBeautifulPhigureLikeDisplayString() throws Exception {
    AgentRuntimeInfo agentRuntimeInfo = new AgentRuntimeInfo(new AgentIdentifier("localhost", "127.0.0.1", "uuid"), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false);
    agentRuntimeInfo.setLocation("/nim/appan/mane");
    assertThat(agentRuntimeInfo.agentInfoForDisplay(), is("Agent located at [localhost, 127.0.0.1, /nim/appan/mane]"));
}
Also used : AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) Test(org.junit.Test)

Example 8 with AgentIdentifier

use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.

the class AgentRuntimeInfoTest method shouldHaveRelevantFieldsInDebugString.

@Test
public void shouldHaveRelevantFieldsInDebugString() throws Exception {
    AgentRuntimeInfo agentRuntimeInfo = new AgentRuntimeInfo(new AgentIdentifier("localhost", "127.0.0.1", "uuid"), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false);
    assertThat(agentRuntimeInfo.agentInfoDebugString(), is("Agent [localhost, 127.0.0.1, uuid, cookie]"));
}
Also used : AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) Test(org.junit.Test)

Example 9 with AgentIdentifier

use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.

the class AgentRuntimeInfoTest method shouldUpdateSelfForAnIdleAgent.

@Test
public void shouldUpdateSelfForAnIdleAgent() {
    AgentRuntimeInfo agentRuntimeInfo = new AgentRuntimeInfo(new AgentIdentifier("localhost", "127.0.0.1", "uuid"), AgentRuntimeStatus.Idle, currentWorkingDirectory(), null, false);
    AgentRuntimeInfo newRuntimeInfo = new AgentRuntimeInfo(new AgentIdentifier("go02", "10.10.10.1", "uuid"), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false);
    newRuntimeInfo.setBuildingInfo(new AgentBuildingInfo("Idle", ""));
    newRuntimeInfo.setLocation("home");
    newRuntimeInfo.setUsableSpace(10L);
    newRuntimeInfo.setOperatingSystem("Linux");
    agentRuntimeInfo.updateSelf(newRuntimeInfo);
    assertThat(agentRuntimeInfo.getBuildingInfo(), is(newRuntimeInfo.getBuildingInfo()));
    assertThat(agentRuntimeInfo.getLocation(), is(newRuntimeInfo.getLocation()));
    assertThat(agentRuntimeInfo.getUsableSpace(), is(newRuntimeInfo.getUsableSpace()));
    assertThat(agentRuntimeInfo.getOperatingSystem(), is(newRuntimeInfo.getOperatingSystem()));
}
Also used : AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) Test(org.junit.Test)

Example 10 with AgentIdentifier

use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.

the class AgentRuntimeInfoTest method shouldTellIfHasCookie.

@Test
public void shouldTellIfHasCookie() throws Exception {
    assertThat(new AgentRuntimeInfo(new AgentIdentifier("localhost", "127.0.0.1", "uuid"), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false).hasDuplicateCookie("cookie"), is(false));
    assertThat(new AgentRuntimeInfo(new AgentIdentifier("localhost", "127.0.0.1", "uuid"), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false).hasDuplicateCookie("different"), is(true));
    assertThat(new AgentRuntimeInfo(new AgentIdentifier("localhost", "127.0.0.1", "uuid"), AgentRuntimeStatus.Idle, currentWorkingDirectory(), null, false).hasDuplicateCookie("cookie"), is(false));
    assertThat(new AgentRuntimeInfo(new AgentIdentifier("localhost", "127.0.0.1", "uuid"), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false).hasDuplicateCookie(null), is(false));
}
Also used : AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) Test(org.junit.Test)

Aggregations

AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)73 Test (org.junit.Test)53 AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)31 FakeBuildRepositoryRemote (com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote)11 UploadEntry (com.thoughtworks.go.matchers.UploadEntry)10 File (java.io.File)9 Before (org.junit.Before)8 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)7 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)6 AgentInstance (com.thoughtworks.go.domain.AgentInstance)4 AgentInstruction (com.thoughtworks.go.remote.AgentInstruction)4 NoWork (com.thoughtworks.go.remote.work.NoWork)4 Work (com.thoughtworks.go.remote.work.Work)4 AgentConfig (com.thoughtworks.go.config.AgentConfig)3 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)3 HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)3 GoConfigDao (com.thoughtworks.go.config.GoConfigDao)2 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)2 AgentCookie (com.thoughtworks.go.server.domain.AgentCookie)2 AgentInstances (com.thoughtworks.go.server.domain.AgentInstances)2