use of com.amazonaws.services.ecs.model.Cluster in project gocd-ecs-elastic-agent by gocd.
the class PluginStatusReportViewTest method shouldBuildViewWithoutContainerInstanceAndPrintNoRunningContainerInstanceMessage.
@Test
void shouldBuildViewWithoutContainerInstanceAndPrintNoRunningContainerInstanceMessage() throws Exception {
final Cluster cluster = clusterWith("GoCD", 0, 0, 0);
final ECSCluster ecsCluster = new ECSCluster(cluster, emptyList(), emptyList(), emptyList(), 2, 3, 0, 0);
Map<String, Object> dataModel = new HashMap<>();
dataModel.put("cluster", ecsCluster);
dataModel.put("errors", Collections.emptyList());
dataModel.put("region", "us-east-2");
final PluginStatusReportViewBuilder statusReportViewBuilder = PluginStatusReportViewBuilder.instance();
final Template template = statusReportViewBuilder.getTemplate("status-report.template.ftlh");
final String view = statusReportViewBuilder.build(template, dataModel);
assertView(view, ecsCluster);
}
use of com.amazonaws.services.ecs.model.Cluster in project gocd-ecs-elastic-agent by gocd.
the class PluginStatusReportViewTest method shouldBuildStatusReportViewWithDefaultValues.
@Test
void shouldBuildStatusReportViewWithDefaultValues() throws Exception {
final Cluster cluster = clusterWith("GoCD", 0, 0, 0);
final ContainerInstance containerInstance = containerInstance("instance-id", "arn/container-instance-1", "ACTIVE", 0, 0, 0, 0);
final Instance instance = instance("instance-id", C3Large, "ami-23456", toDate("13/05/2017 12:50:20"));
final ECSContainer alpineContainer = containerWith("arn/container-instance-1", "container-name", "alpine", 100, 200, "13/05/2017 12:55:20", null);
final ECSCluster ecsCluster = new ECSCluster(cluster, singletonList(containerInstance), singletonList(instance), singletonList(alpineContainer), 2, 3, 0, 0);
Map<String, Object> dataModel = new HashMap<>();
dataModel.put("cluster", ecsCluster);
dataModel.put("maxAllowedInstances", 5);
dataModel.put("errors", Collections.emptyList());
dataModel.put("region", "us-east-2");
final PluginStatusReportViewBuilder statusReportViewBuilder = PluginStatusReportViewBuilder.instance();
final Template template = statusReportViewBuilder.getTemplate("status-report.template.ftlh");
final String view = statusReportViewBuilder.build(template, dataModel);
assertView(view, ecsCluster);
}
use of com.amazonaws.services.ecs.model.Cluster in project gocd-ecs-elastic-agent by gocd.
the class ECSClusterTest method shouldBuildECSClusterWithDetailsOfInstanceType.
@Test
void shouldBuildECSClusterWithDetailsOfInstanceType() throws ParseException {
final Cluster cluster = clusterWith("GoCD", 5, 10, 0);
final ContainerInstance onDemandContainerInstance = containerInstance("instance-id-1");
final ContainerInstance spotContainerInstance = containerInstance("instance-id-2");
final Instance onDemandInstance = instance("instance-id-1", C3Large, "ami-2dad3da", toDate("13/05/2017 12:50:20"));
final Instance spotInstance = spotInstance("instance-id-2", "running", "ami-2dad3da");
final ECSContainer alpineContainer = containerWith("arn/container-instance-1", "alpine-container", "alpine", 100, 200, "13/05/2017 12:55:00", "13/05/2017 12:56:30");
final ECSCluster ecsCluster = new ECSCluster(cluster, asList(onDemandContainerInstance, spotContainerInstance), asList(onDemandInstance, spotInstance), singletonList(alpineContainer), 2, 3, 0, 0);
assertThat(ecsCluster.getEc2InstanceType().size()).isEqualTo(2);
assertThat(ecsCluster.getEc2InstanceType().get("instance-id-1")).isEqualTo("On-Demand");
assertThat(ecsCluster.getEc2InstanceType().get("instance-id-2")).isEqualTo("Spot");
}
use of com.amazonaws.services.ecs.model.Cluster in project gocd-ecs-elastic-agent by gocd.
the class ECSClusterTest method shouldBuildECSClusterWithDetails.
@Test
void shouldBuildECSClusterWithDetails() throws Exception {
final Cluster cluster = clusterWith("GoCD", 5, 10, 0);
final ContainerInstance containerInstance = containerInstance("instance-id-1", "arn/container-instance-1", "ACTIVE", 8, 4096, 4, 1024);
final Instance instance = instance("instance-id-1", C3Large, "ami-2dad3da", toDate("13/05/2017 12:50:20"));
final ECSContainer alpineContainer = containerWith("arn/container-instance-1", "alpine-container", "alpine", 100, 200, "13/05/2017 12:55:00", "13/05/2017 12:56:30");
final ECSCluster ecsCluster = new ECSCluster(cluster, singletonList(containerInstance), singletonList(instance), singletonList(alpineContainer), 2, 3, 0, 0);
assertThat(ecsCluster.getName()).isEqualTo("GoCD");
assertThat(ecsCluster.getRunningTasksCount()).isEqualTo(10);
assertThat(ecsCluster.getContainerInstances()).hasSize(1).contains(new ECSContainerInstance(containerInstance, instance, singletonList(alpineContainer)));
}
Aggregations