github.com/daniellockard/packer@v0.7.6-0.20141210173435-5a9390934716/test/builder_amazon_ebs.bats (about) 1 #!/usr/bin/env bats 2 # 3 # This tests the amazon-ebs builder. The teardown function will automatically 4 # delete any AMIs with a tag of `packer-test` being equal to "true" so 5 # be sure any test cases set this. 6 7 load test_helper 8 fixtures amazon-ebs 9 10 # This counts how many AMIs were copied to another region 11 aws_ami_region_copy_count() { 12 aws ec2 describe-images --region $1 --owners self --output text \ 13 --filters 'Name=tag:packer-id,Values=ami_region_copy' \ 14 --query "Images[*].ImageId" \ 15 | wc -l 16 } 17 18 teardown() { 19 aws_ami_cleanup 'us-east-1' 20 aws_ami_cleanup 'us-west-1' 21 aws_ami_cleanup 'us-west-2' 22 } 23 24 @test "amazon-ebs: build minimal.json" { 25 run packer build $FIXTURE_ROOT/minimal.json 26 [ "$status" -eq 0 ] 27 } 28 29 # @unit-testable 30 @test "amazon-ebs: AMI region copy" { 31 run packer build $FIXTURE_ROOT/ami_region_copy.json 32 [ "$status" -eq 0 ] 33 [ "$(aws_ami_region_copy_count 'us-east-1')" -eq "1" ] 34 [ "$(aws_ami_region_copy_count 'us-west-1')" -eq "1" ] 35 [ "$(aws_ami_region_copy_count 'us-west-2')" -eq "1" ] 36 }