Exemple #1
0
 def setUp(self):
     super(TestDeployCommand, self).setUp()
     # setup required values
     files = FileCreator()
     self.task_def_file = files.create_file(
         'taskDef.json', json.dumps(self.TASK_DEFINITION_JSON), mode='w')
     self.appspec_file = files.create_file(
         'appspec.yaml', self.YAML_APPSPEC, mode='w')
     self.appspec_file_json = files.create_file(
         'appspec.json', self.JSON_APPSPEC, mode='w')
     self.service_name = 'serviceTest'
     self.service_arn = 'arn:aws:ecs:::service/serviceTest'
     # setup default optional values
     self.cluster_name = 'default'
     self.cluster_arn = 'arn:aws:ecs:::cluster/default'
     self.application_name = get_app_name(
         self.service_name, self.cluster_name, None)
     self.deployment_group_name = get_deploy_group_name(
         self.service_name, self.cluster_name, None)
     # setup test response resources
     self.missing_properties_appspec = files.create_file(
         'appspec_bad.yaml', self.BAD_APPSPEC, mode='w')
     self.task_definition_arn = \
         'arn:aws:ecs::1234567890:task-definition\\test:2'
     self.deployment_id = 'd-1234567XX'
     self.mock_deployer = CodeDeployer(None, self.APPSPEC_DICT)
     self.mock_deployer.update_task_def_arn(self.task_definition_arn)
     self.expected_stdout = ("Successfully registered new ECS task "
                             "definition " + self.task_definition_arn + "\n"
                             "Successfully created deployment " +
                             self.deployment_id + "\n"
                             "Waiting for " + self.deployment_id +
                             " to succeed...\nSuccessfully deployed "
                             + self.task_definition_arn + " to service '"
                             + self.service_name + "'\n")
Exemple #2
0
    def test_get_app_name_provided(self):
        cluster = 'test-cluster'
        service = 'test-service'
        app_name = 'test-app'

        response = get_app_name(service, cluster, app_name)
        self.assertEqual(app_name, response)
    def test_get_app_name_provided(self):
        cluster = 'test-cluster'
        service = 'test-service'
        app_name = 'test-app'

        response = get_app_name(service, cluster, app_name)
        self.assertEqual(app_name, response)
Exemple #4
0
    def test_get_app_name_long(self):
        cluster = 'ClusterClusterClusterClusterClusterClusterClusterCluster'
        service = 'ServiceServiceServiceServiceServiceServiceServiceService'

        expected = APP_PREFIX + cluster[:MAX_CHAR_LENGTH] + '-' + service[:MAX_CHAR_LENGTH]
        response = get_app_name(service, cluster, None)

        self.assertEqual(expected, response)
    def test_get_app_name_long(self):
        cluster = 'ClusterClusterClusterClusterClusterClusterClusterCluster'
        service = 'ServiceServiceServiceServiceServiceServiceServiceService'

        expected = APP_PREFIX + cluster[:
                                        MAX_CHAR_LENGTH] + '-' + service[:
                                                                         MAX_CHAR_LENGTH]
        response = get_app_name(service, cluster, None)

        self.assertEqual(expected, response)
Exemple #6
0
    def _get_resource_names(self, args, ecs_client):
        service_details = ecs_client.get_service_details()
        service_name = service_details['service_name']
        cluster_name = service_details['cluster_name']

        application_name = filehelpers.get_app_name(
            service_name, cluster_name, args.codedeploy_application)
        deployment_group_name = filehelpers.get_deploy_group_name(
            service_name, cluster_name, args.codedeploy_deployment_group)

        return {
            'service': service_name,
            'service_arn': service_details['service_arn'],
            'cluster': cluster_name,
            'cluster_arn': service_details['cluster_arn'],
            'app_name': application_name,
            'deployment_group_name': deployment_group_name
        }
Exemple #7
0
    def _get_resource_names(self, args, ecs_client):
        service_details = ecs_client.get_service_details()
        service_name = service_details['service_name']
        cluster_name = service_details['cluster_name']

        application_name = filehelpers.get_app_name(
            service_name, cluster_name, args.codedeploy_application)
        deployment_group_name = filehelpers.get_deploy_group_name(
            service_name, cluster_name, args.codedeploy_deployment_group)

        return {
            'service': service_name,
            'service_arn': service_details['service_arn'],
            'cluster': cluster_name,
            'cluster_arn': service_details['cluster_arn'],
            'app_name': application_name,
            'deployment_group_name': deployment_group_name
        }
Exemple #8
0
 def setUp(self):
     super(TestDeployCommand, self).setUp()
     # setup required values
     files = FileCreator()
     self.task_def_file = files.create_file('taskDef.json',
                                            json.dumps(
                                                self.TASK_DEFINITION_JSON),
                                            mode='w')
     self.appspec_file = files.create_file('appspec.yaml',
                                           self.YAML_APPSPEC,
                                           mode='w')
     self.appspec_file_json = files.create_file('appspec.json',
                                                self.JSON_APPSPEC,
                                                mode='w')
     self.service_name = 'serviceTest'
     self.service_arn = 'arn:aws:ecs:::service/serviceTest'
     # setup default optional values
     self.cluster_name = 'default'
     self.cluster_arn = 'arn:aws:ecs:::cluster/default'
     self.application_name = get_app_name(self.service_name,
                                          self.cluster_name, None)
     self.deployment_group_name = get_deploy_group_name(
         self.service_name, self.cluster_name, None)
     # setup test response resources
     self.missing_properties_appspec = files.create_file('appspec_bad.yaml',
                                                         self.BAD_APPSPEC,
                                                         mode='w')
     self.task_definition_arn = \
         'arn:aws:ecs::1234567890:task-definition\\test:2'
     self.deployment_id = 'd-1234567XX'
     self.mock_deployer = CodeDeployer(None, self.APPSPEC_DICT)
     self.mock_deployer.update_task_def_arn(self.task_definition_arn)
     self.expected_stdout = ("Successfully registered new ECS task "
                             "definition " + self.task_definition_arn + "\n"
                             "Successfully created deployment " +
                             self.deployment_id + "\n"
                             "Waiting for " + self.deployment_id +
                             " to succeed...\nSuccessfully deployed " +
                             self.task_definition_arn + " to service '" +
                             self.service_name + "'\n")
Exemple #9
0
    def test_get_app_name_no_cluster(self):
        service = 'test-service'
        expected_name = 'AppECS-default-test-service'

        response = get_app_name(service, None, None)
        self.assertEqual(expected_name, response)
Exemple #10
0
    def test_get_app_name_no_cluster(self):
        service = 'test-service'
        expected_name = 'AppECS-default-test-service'

        response = get_app_name(service, None, None)
        self.assertEqual(expected_name, response)