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")
def test_get_deploy_group_name_provided(self): cluster = 'test-cluster' service = 'test-service' dgp_name = 'test-deployment-group' response = get_deploy_group_name(service, cluster, dgp_name) self.assertEqual(dgp_name, response)
def test_get_deploy_group_name_provided(self): cluster = 'test-cluster' service = 'test-service' dgp_name = 'test-deployment-group' response = get_deploy_group_name(service, cluster, dgp_name) self.assertEqual(dgp_name, response)
def test_get_deploy_group_name_long(self): cluster = 'ClusterClusterClusterClusterClusterClusterClusterCluster' service = 'ServiceServiceServiceServiceServiceServiceServiceService' expected = DGP_PREFIX + cluster[:MAX_CHAR_LENGTH] + '-' + service[:MAX_CHAR_LENGTH] response = get_deploy_group_name(service, cluster, None) self.assertEqual(expected, response)
def test_get_deploy_group_name_long(self): cluster = 'ClusterClusterClusterClusterClusterClusterClusterCluster' service = 'ServiceServiceServiceServiceServiceServiceServiceService' expected = DGP_PREFIX + cluster[: MAX_CHAR_LENGTH] + '-' + service[: MAX_CHAR_LENGTH] response = get_deploy_group_name(service, cluster, None) self.assertEqual(expected, response)
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 }
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 }
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")
def test_get_deploy_group_name_no_cluster(self): service = 'test-service' expected_name = 'DgpECS-default-test-service' response = get_deploy_group_name(service, None, None) self.assertEqual(expected_name, response)
def test_get_deploy_group_name_no_cluster(self): service = 'test-service' expected_name = 'DgpECS-default-test-service' response = get_deploy_group_name(service, None, None) self.assertEqual(expected_name, response)