Beispiel #1
0
    def test_create_multiple_clusters(self):
        with mock_ecs():
            clusters = ("test-cluster0", "test-cluster1")
            logger = "stacker.hooks.ecs"
            client = boto3.client("ecs", region_name=REGION)
            response = client.list_clusters()

            self.assertEqual(len(response["clusterArns"]), 0)
            for cluster in clusters:
                with LogCapture(logger) as logs:
                    self.assertTrue(
                        create_clusters(
                            provider=self.provider,
                            context=self.context,
                            clusters=cluster,
                        )
                    )

                    logs.check(
                        (
                            logger,
                            "DEBUG",
                            "Creating ECS cluster: %s" % cluster
                        )
                    )

            response = client.list_clusters()
            self.assertEqual(len(response["clusterArns"]), 2)
Beispiel #2
0
    def test_fail_create_cluster(self):
        with mock_ecs():
            logger = "stacker.hooks.ecs"
            client = boto3.client("ecs", region_name=REGION)
            response = client.list_clusters()

            self.assertEqual(len(response["clusterArns"]), 0)
            with LogCapture(logger) as logs:
                create_clusters(provider=self.provider, context=self.context)

                logs.check(
                    (logger, "ERROR",
                     "setup_clusters hook missing \"clusters\" argument"))

            response = client.list_clusters()
            self.assertEqual(len(response["clusterArns"]), 0)
Beispiel #3
0
    def test_create_single_cluster(self):
        with mock_ecs():
            cluster = "test-cluster"
            logger = "stacker.hooks.ecs"
            client = boto3.client("ecs", region_name=REGION)
            response = client.list_clusters()

            self.assertEqual(len(response["clusterArns"]), 0)
            with LogCapture(logger) as logs:
                self.assertTrue(
                    create_clusters(
                        provider=self.provider,
                        context=self.context,
                        clusters=cluster,
                    ))

                logs.check(
                    (logger, "DEBUG", "Creating ECS cluster: %s" % cluster))

            response = client.list_clusters()
            self.assertEqual(len(response["clusterArns"]), 1)
Beispiel #4
0
    def test_create_single_cluster(self):
        with mock_ecs():
            cluster = "test-cluster"
            logger = "stacker.hooks.ecs"
            client = boto3.client("ecs", region_name=REGION)
            response = client.list_clusters()

            self.assertEqual(len(response["clusterArns"]), 0)
            with LogCapture(logger) as logs:
                self.assertTrue(
                    create_clusters(region=REGION,
                                    namespace="fake",
                                    mappings={},
                                    parameters={},
                                    clusters=cluster))

                logs.check(
                    (logger, "DEBUG", "Creating ECS cluster: %s" % cluster))

            response = client.list_clusters()
            self.assertEqual(len(response["clusterArns"]), 1)