Search in sources :

Example 6 with Cluster

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);
}
Also used : ECSCluster(com.thoughtworks.gocd.elasticagent.ecs.domain.ECSCluster) Cluster(com.amazonaws.services.ecs.model.Cluster) ECSCluster(com.thoughtworks.gocd.elasticagent.ecs.domain.ECSCluster) Template(freemarker.template.Template) Test(org.junit.jupiter.api.Test)

Example 7 with Cluster

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);
}
Also used : ContainerInstance(com.amazonaws.services.ecs.model.ContainerInstance) ECSContainerInstance(com.thoughtworks.gocd.elasticagent.ecs.domain.ECSContainerInstance) ECSContainer(com.thoughtworks.gocd.elasticagent.ecs.domain.ECSContainer) ContainerInstance(com.amazonaws.services.ecs.model.ContainerInstance) ContainerInstanceMother.containerInstance(com.thoughtworks.gocd.elasticagent.ecs.aws.ContainerInstanceMother.containerInstance) Instance(com.amazonaws.services.ec2.model.Instance) ECSContainerInstance(com.thoughtworks.gocd.elasticagent.ecs.domain.ECSContainerInstance) ECSCluster(com.thoughtworks.gocd.elasticagent.ecs.domain.ECSCluster) Cluster(com.amazonaws.services.ecs.model.Cluster) ECSCluster(com.thoughtworks.gocd.elasticagent.ecs.domain.ECSCluster) Template(freemarker.template.Template) Test(org.junit.jupiter.api.Test)

Example 8 with Cluster

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");
}
Also used : ContainerInstance(com.amazonaws.services.ecs.model.ContainerInstance) ContainerInstance(com.amazonaws.services.ecs.model.ContainerInstance) ContainerInstanceMother.containerInstance(com.thoughtworks.gocd.elasticagent.ecs.aws.ContainerInstanceMother.containerInstance) Instance(com.amazonaws.services.ec2.model.Instance) Cluster(com.amazonaws.services.ecs.model.Cluster) Test(org.junit.jupiter.api.Test)

Example 9 with Cluster

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)));
}
Also used : ContainerInstance(com.amazonaws.services.ecs.model.ContainerInstance) ContainerInstance(com.amazonaws.services.ecs.model.ContainerInstance) ContainerInstanceMother.containerInstance(com.thoughtworks.gocd.elasticagent.ecs.aws.ContainerInstanceMother.containerInstance) Instance(com.amazonaws.services.ec2.model.Instance) Cluster(com.amazonaws.services.ecs.model.Cluster) Test(org.junit.jupiter.api.Test)

Aggregations

Cluster (com.amazonaws.services.ecs.model.Cluster)9 Test (org.junit.jupiter.api.Test)8 Instance (com.amazonaws.services.ec2.model.Instance)7 ContainerInstance (com.amazonaws.services.ecs.model.ContainerInstance)7 Template (freemarker.template.Template)6 ECSContainer (com.thoughtworks.gocd.elasticagent.ecs.domain.ECSContainer)5 ContainerInstanceMother.containerInstance (com.thoughtworks.gocd.elasticagent.ecs.aws.ContainerInstanceMother.containerInstance)4 ECSCluster (com.thoughtworks.gocd.elasticagent.ecs.domain.ECSCluster)4 ECSContainerInstance (com.thoughtworks.gocd.elasticagent.ecs.domain.ECSContainerInstance)2 JsonObject (com.google.gson.JsonObject)1 GoPluginApiResponse (com.thoughtworks.go.plugin.api.response.GoPluginApiResponse)1 ClusterProfileProperties (com.thoughtworks.gocd.elasticagent.ecs.domain.ClusterProfileProperties)1 JobIdentifier (com.thoughtworks.gocd.elasticagent.ecs.domain.JobIdentifier)1 TemplateException (freemarker.template.TemplateException)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1