use of com.thoughtworks.gocd.elasticagent.ecs.domain.ClusterProfileProperties in project gocd-ecs-elastic-agent by gocd.
the class JobCompletionRequestExecutorTest method shouldSkipTerminatingANonExistingAgent.
@Test
void shouldSkipTerminatingANonExistingAgent() throws Exception {
JobIdentifier jobIdentifier = new JobIdentifier("test", 1L, "test", "test_stage", "1", "test_job", 100L);
String elasticAgentId = "agent-1";
JobCompletionRequest request = new JobCompletionRequest(elasticAgentId, jobIdentifier, new ElasticAgentProfileProperties(), new ClusterProfileProperties());
JobCompletionRequestExecutor executor = new JobCompletionRequestExecutor(request, mockAgentInstances, mockPluginRequest);
when(mockPluginRequest.listAgents()).thenReturn(new Agents());
GoPluginApiResponse response = executor.execute();
verify(mockPluginRequest, never()).disableAgents(anyCollection());
verify(mockPluginRequest, never()).deleteAgents(anyCollection());
verifyNoInteractions(mockAgentInstances);
assertThat(200).isEqualTo(response.responseCode());
}
use of com.thoughtworks.gocd.elasticagent.ecs.domain.ClusterProfileProperties in project gocd-ecs-elastic-agent by gocd.
the class CreateAgentRequestExecutorTest method shouldAskECSTaskToCreateAnAgent.
@Test
void shouldAskECSTaskToCreateAnAgent() throws Exception {
ClusterProfileProperties settings = mock(ClusterProfileProperties.class);
CreateAgentRequest request = mock(CreateAgentRequest.class);
when(request.clusterProfileProperties()).thenReturn(settings);
when(request.getJobIdentifier()).thenReturn(new JobIdentifier("test-pipeline", 1L, "Test Pipeline", "test-stage", "1", "test-job", 100L));
when(request.elasticProfile()).thenReturn(new ElasticAgentProfileProperties());
ECSTasks agentInstances = mock(ECSTasks.class);
PluginRequest pluginRequest = mock(PluginRequest.class);
final EventStream eventStream = mock(EventStream.class);
new CreateAgentRequestExecutor(request, agentInstances, pluginRequest, eventStream).execute();
verify(agentInstances).create(eq(request), eq(settings), any(ConsoleLogAppender.class));
}
use of com.thoughtworks.gocd.elasticagent.ecs.domain.ClusterProfileProperties in project gocd-ecs-elastic-agent by gocd.
the class AgentStatusReportRequestTest method shouldDeserializeFromJSON.
@Test
void shouldDeserializeFromJSON() {
String json = "{\n" + " \"elastic_agent_id\": \"ea1\",\n" + " \"job_identifier\": {\n" + " \"pipeline_name\": \"test-pipeline\",\n" + " \"pipeline_counter\": 1,\n" + " \"pipeline_label\": \"Test Pipeline\",\n" + " \"stage_name\": \"test-stage\",\n" + " \"stage_counter\": \"1\",\n" + " \"job_name\": \"test-job\",\n" + " \"job_id\": 100\n" + " },\n" + " \"cluster_profile_properties\": {\n" + " \"GoServerUrl\": \"https://cd.server.com/go\", \n" + " \"ClusterName\": \"deployment-cluster\"\n" + " }\n" + "}";
AgentStatusReportRequest request = AgentStatusReportRequest.fromJSON(json);
JobIdentifier expectedJobIdentifier = new JobIdentifier("test-pipeline", 1L, "Test Pipeline", "test-stage", "1", "test-job", 100L);
JobIdentifier actualJobIdentifier = request.jobIdentifier();
assertThat(actualJobIdentifier).isEqualTo(expectedJobIdentifier);
assertThat(request.getElasticAgentId()).isEqualTo("ea1");
Map<String, String> clusterProfileConfigurations = new HashMap<>();
clusterProfileConfigurations.put("GoServerUrl", "https://cd.server.com/go");
clusterProfileConfigurations.put("ClusterName", "deployment-cluster");
ClusterProfileProperties expectedClusterProfileProperties = ClusterProfileProperties.fromConfiguration(clusterProfileConfigurations);
assertThat(request.clusterProfileProperties()).isEqualTo(expectedClusterProfileProperties);
}
use of com.thoughtworks.gocd.elasticagent.ecs.domain.ClusterProfileProperties in project gocd-ecs-elastic-agent by gocd.
the class CreateAgentRequestTest method shouldDeserializeFromJSON.
@Test
void shouldDeserializeFromJSON() {
String json = "{\n" + " \"auto_register_key\": \"secret-key\",\n" + " \"elastic_agent_profile_properties\": {\n" + " \"Image\": \"value1\",\n" + " \"MaxMemory\": \"2G\",\n" + " \"ReservedMemory\": \"150M\",\n" + " \"TerminationPolicy\": \"\"\n" + " },\n" + " \"cluster_profile_properties\": {\n" + " \"GoServerUrl\": \"https://cd.server.com/go\", \n" + " \"ClusterName\": \"deployment-cluster\"\n" + " },\n" + " \"environment\": \"prod\"\n" + "}";
CreateAgentRequest request = CreateAgentRequest.fromJSON(json);
assertThat(request.autoRegisterKey()).isEqualTo("secret-key");
assertThat(request.environment()).isEqualTo("prod");
assertThat(request.elasticProfile().getImage()).isEqualTo("value1");
assertThat(request.elasticProfile().getMaxMemory()).isEqualTo(2048);
Map<String, String> clusterProfileConfigurations = new HashMap<>();
clusterProfileConfigurations.put("GoServerUrl", "https://cd.server.com/go");
clusterProfileConfigurations.put("ClusterName", "deployment-cluster");
ClusterProfileProperties expectedClusterProfileProperties = ClusterProfileProperties.fromConfiguration(clusterProfileConfigurations);
assertThat(request.clusterProfileProperties()).isEqualTo(expectedClusterProfileProperties);
}
use of com.thoughtworks.gocd.elasticagent.ecs.domain.ClusterProfileProperties in project gocd-ecs-elastic-agent by gocd.
the class JobCompletionRequestTest method shouldDeserializeFromJSON.
@Test
public void shouldDeserializeFromJSON() {
String json = "{\n" + " \"elastic_agent_id\": \"ea1\",\n" + " \"job_identifier\": {\n" + " \"pipeline_name\": \"test-pipeline\",\n" + " \"pipeline_counter\": 1,\n" + " \"pipeline_label\": \"Test Pipeline\",\n" + " \"stage_name\": \"test-stage\",\n" + " \"stage_counter\": \"1\",\n" + " \"job_name\": \"test-job\",\n" + " \"job_id\": 100\n" + " },\n" + " \"elastic_agent_profile_properties\": {\n" + " \"Image\": \"value1\",\n" + " \"MaxMemory\": \"2G\",\n" + " \"ReservedMemory\": \"150M\",\n" + " \"TerminationPolicy\": \"\"\n" + " },\n" + " \"cluster_profile_properties\": {\n" + " \"GoServerUrl\": \"https://cd.server.com/go\", \n" + " \"ClusterName\": \"deployment-cluster\"\n" + " }\n" + "}";
JobCompletionRequest request = JobCompletionRequest.fromJSON(json);
JobIdentifier expectedJobIdentifier = new JobIdentifier("test-pipeline", 1L, "Test Pipeline", "test-stage", "1", "test-job", 100L);
JobIdentifier actualJobIdentifier = request.jobIdentifier();
assertThat(actualJobIdentifier).isEqualTo(expectedJobIdentifier);
assertThat(request.getElasticAgentId()).isEqualTo("ea1");
assertThat(request.elasticAgentProfileProperties().getImage()).isEqualTo("value1");
assertThat(request.elasticAgentProfileProperties().getMaxMemory()).isEqualTo(2048);
Map<String, String> clusterProfileConfigurations = new HashMap<>();
clusterProfileConfigurations.put("GoServerUrl", "https://cd.server.com/go");
clusterProfileConfigurations.put("ClusterName", "deployment-cluster");
ClusterProfileProperties expectedClusterProfileProperties = ClusterProfileProperties.fromConfiguration(clusterProfileConfigurations);
assertThat(request.clusterProfileProperties()).isEqualTo(expectedClusterProfileProperties);
}
Aggregations