def test_code_build_should_not_add_vpc_config(self): action = code_build_action.CodeBuildAction( action_name="Test", stage_name_to_add="the_stage", input_artifact_name="no-input", ) project = action.create_project( chain_context=self.context, codebuild_role='dummy-role', codebuild_environment=self.environment, name='test', ) self.assertNotIn('VpcConfig', project.to_dict())
def test_code_build_should_add_vpc_config(self): action = code_build_action.CodeBuildAction( vpc_config=VpcConfig(vpc_id='dummy-vpc', subnets=['dummy-subnet1']), action_name="testAction", stage_name_to_add="thestage", input_artifact_name="test-input") project = action.create_project( chain_context=self.context, codebuild_role='dummy-role', codebuild_environment=self.environment, name='test', ) self.assertIn('VpcConfig', project.properties)
def create_template(self): t = self.template t.add_description("Acceptance Tests for cumulus pipelines") instance = self.name + self.context.environment['env'] # TODO: give to builder the_chain = chain.Chain() # bucket becomes: cumulus-acceptance-tests-123123-namespace pipeline_bucket_name = troposphere.Join('', [ self.context.namespace, "-", troposphere.Ref("AWS::AccountId"), "-", "automatedtests" ]) the_chain.add( pipeline.Pipeline( name=self.name, bucket_name=pipeline_bucket_name, )) source_stage_name = "SourceStage" deploy_stage_name = "DeployStage" service_artifact = "ServiceArtifact" the_chain.add( pipeline_stage.PipelineStage(stage_name=source_stage_name)) the_chain.add( pipeline_source_action.PipelineSourceAction( action_name="MicroserviceSource", output_artifact_name=service_artifact, s3_bucket_name=pipeline_bucket_name, s3_object_key="artifact.tar.gz")) the_chain.add( pipeline_stage.PipelineStage(stage_name=deploy_stage_name, ), ) inline_ls_url_spec = """version: 0.2 phases: build: commands: - ls -lah - env - curl $URL """ test_env = troposphere.codebuild.Environment( ComputeType='BUILD_GENERAL1_SMALL', Image='aws/codebuild/golang:1.10', Type='LINUX_CONTAINER', EnvironmentVariables=[{ 'Name': 'URL', 'Value': "https://google.ca" }], ) deploy_test = code_build_action.CodeBuildAction( action_name="DeployMyStuff", stage_name_to_add=deploy_stage_name, input_artifact_name=service_artifact, environment=test_env, buildspec=inline_ls_url_spec, ) the_chain.add(deploy_test) lambda1 = lambda_action.LambdaAction( action_name="TriggerLambda", input_artifact_name=service_artifact, # TODO make optional ? stage_name_to_add=deploy_stage_name, function_name="bswift-mock-function-mock-createUser") the_chain.add(lambda1) # the_chain.add(code_build_action.CodeBuildAction( # action_name="NotificationSmokeTest", # stage_name_to_add=deploy_stage_name, # input_artifact_name=service_artifact, # environment=test_env, # buildspec='buildspec_smoke_test.yml', # )) # TODO: integration tests don't confirm the below.. yet. Do it. destroy_stage_name = "EchoAURL" the_chain.add( pipeline_stage.PipelineStage(stage_name=destroy_stage_name, ), ) the_chain.add( ApprovalAction(action_name="ApproveDestruction", stage_name_to_add=destroy_stage_name)) the_chain.add( code_build_action.CodeBuildAction( action_name="DestroyService", stage_name_to_add=destroy_stage_name, input_artifact_name=service_artifact, )) chain_context = chaincontext.ChainContext(template=t, instance_name=instance) the_chain.run(chain_context)