use of com.thoughtworks.gocd.elasticagent.ecs.domain.Agent in project gocd-ecs-elastic-agent by gocd.
the class AgentTest method agentsWithDifferentAttributesDoNotShareSameHashCode.
@Test
void agentsWithDifferentAttributesDoNotShareSameHashCode() throws Exception {
Agent agent1 = new Agent("eeb9e0eb-1f12-4366-a5a5-59011810273b", Agent.AgentState.Building, Agent.BuildState.Cancelled, Agent.ConfigState.Disabled);
Agent agent2 = new Agent();
assertThat(agent1.hashCode()).isNotEqualTo(agent2.hashCode());
}
use of com.thoughtworks.gocd.elasticagent.ecs.domain.Agent in project gocd-ecs-elastic-agent by gocd.
the class JobCompletionRequestExecutorTest method shouldTerminateElasticAgentOnJobCompletion.
@Test
public void shouldTerminateElasticAgentOnJobCompletion() throws Exception {
JobIdentifier jobIdentifier = new JobIdentifier("test", 1L, "test", "test_stage", "1", "test_job", 100L);
String elasticAgentId = "agent-1";
ClusterProfileProperties clusterProfileProperties = new ClusterProfileProperties();
JobCompletionRequest request = new JobCompletionRequest(elasticAgentId, jobIdentifier, new ElasticAgentProfileProperties(), clusterProfileProperties);
JobCompletionRequestExecutor executor = new JobCompletionRequestExecutor(request, mockAgentInstances, mockPluginRequest);
Agents agents = new Agents();
agents.add(new Agent(elasticAgentId));
when(mockPluginRequest.listAgents()).thenReturn(agents);
GoPluginApiResponse response = executor.execute();
InOrder inOrder = inOrder(mockPluginRequest, mockAgentInstances);
inOrder.verify(mockPluginRequest).disableAgents(agentsArgumentCaptor.capture());
inOrder.verify(mockAgentInstances).terminate(elasticAgentId, clusterProfileProperties);
inOrder.verify(mockPluginRequest).deleteAgents(agentsArgumentCaptor.capture());
List<Agent> agentsToDisabled = agentsArgumentCaptor.getValue();
assertThat(1).isEqualTo(agentsToDisabled.size());
assertThat(elasticAgentId).isEqualTo(agentsToDisabled.get(0).elasticAgentId());
List<Agent> agentsToDelete = agentsArgumentCaptor.getValue();
assertThat(agentsToDisabled).isEqualTo(agentsToDelete);
assertThat(200).isEqualTo(response.responseCode());
assertThat(response.responseBody().isEmpty()).isTrue();
}
use of com.thoughtworks.gocd.elasticagent.ecs.domain.Agent in project gocd-ecs-elastic-agent by gocd.
the class ShouldAssignWorkRequestExecutorTest method shouldAssignWorkToContainerWithMatchingJobIdentifier.
@Test
void shouldAssignWorkToContainerWithMatchingJobIdentifier() {
ShouldAssignWorkRequest request = new ShouldAssignWorkRequest(new Agent(task.name(), null, null, null), environment, elasticAgentProfileProperties, getJobIdentifierWithId(1), clusterProfileProperties);
GoPluginApiResponse response = new ShouldAssignWorkRequestExecutor(request, agentInstances).execute();
assertThat(response.responseCode()).isEqualTo(200);
assertThat(response.responseBody()).isEqualTo("true");
}
use of com.thoughtworks.gocd.elasticagent.ecs.domain.Agent in project gocd-ecs-elastic-agent by gocd.
the class AgentTest method agentShouldNotEqualAnotherAgentWithDifferentAttributes.
@Test
void agentShouldNotEqualAnotherAgentWithDifferentAttributes() throws Exception {
Agent agent = new Agent("eeb9e0eb-1f12-4366-a5a5-59011810273b", Agent.AgentState.Building, Agent.BuildState.Cancelled, Agent.ConfigState.Disabled);
assertThat(agent).isNotEqualTo(new Agent());
}
use of com.thoughtworks.gocd.elasticagent.ecs.domain.Agent in project gocd-ecs-elastic-agent by gocd.
the class AgentTest method agentShouldEqualItself.
@Test
void agentShouldEqualItself() throws Exception {
Agent agent = new Agent("eeb9e0eb-1f12-4366-a5a5-59011810273b", Agent.AgentState.Building, Agent.BuildState.Cancelled, Agent.ConfigState.Disabled);
assertThat(agent).isEqualTo(agent);
}
Aggregations