fix ebs acc test
This commit is contained in:
parent
df790a889d
commit
dfd5f07145
|
@ -153,6 +153,12 @@ specific package / folder. The `TESTARGS` variable is recommended to filter
|
||||||
down to a specific resource to test, since testing all of them at once can
|
down to a specific resource to test, since testing all of them at once can
|
||||||
sometimes take a very long time.
|
sometimes take a very long time.
|
||||||
|
|
||||||
|
To run only a specific test, use the `-run` argument:
|
||||||
|
|
||||||
|
```
|
||||||
|
make testacc TEST=./builder/amazon/ebs TESTARGS="-run TestBuilderAcc_forceDeleteSnapshot"
|
||||||
|
```
|
||||||
|
|
||||||
Acceptance tests typically require other environment variables to be set for
|
Acceptance tests typically require other environment variables to be set for
|
||||||
things such as API tokens and keys. Each test should error and tell you which
|
things such as API tokens and keys. Each test should error and tell you which
|
||||||
credentials are missing, so those are not documented here.
|
credentials are missing, so those are not documented here.
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
|
/*
|
||||||
|
Deregister the test image with
|
||||||
|
aws ec2 deregister-image --image-id $(aws ec2 describe-images --output text --filters "Name=name,Values=packer-test-packer-test-dereg" --query 'Images[*].{ID:ImageId}')
|
||||||
|
*/
|
||||||
package ebs
|
package ebs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go/aws"
|
"github.com/aws/aws-sdk-go/aws"
|
||||||
|
@ -58,14 +61,14 @@ func TestBuilderAcc_forceDeleteSnapshot(t *testing.T) {
|
||||||
|
|
||||||
// Get image data by AMI name
|
// Get image data by AMI name
|
||||||
ec2conn, _ := testEC2Conn()
|
ec2conn, _ := testEC2Conn()
|
||||||
imageResp, _ := ec2conn.DescribeImages(
|
describeInput := &ec2.DescribeImagesInput{Filters: []*ec2.Filter{
|
||||||
&ec2.DescribeImagesInput{Filters: []*ec2.Filter{
|
{
|
||||||
{
|
Name: aws.String("name"),
|
||||||
Name: aws.String("name"),
|
Values: []*string{aws.String(amiName)},
|
||||||
Values: []*string{aws.String(amiName)},
|
},
|
||||||
},
|
}}
|
||||||
}},
|
ec2conn.WaitUntilImageExists(describeInput)
|
||||||
)
|
imageResp, _ := ec2conn.DescribeImages(describeInput)
|
||||||
image := imageResp.Images[0]
|
image := imageResp.Images[0]
|
||||||
|
|
||||||
// Get snapshot ids for image
|
// Get snapshot ids for image
|
||||||
|
@ -243,13 +246,6 @@ func checkBootEncrypted() builderT.TestCheckFunc {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccPreCheck(t *testing.T) {
|
func testAccPreCheck(t *testing.T) {
|
||||||
if v := os.Getenv("AWS_ACCESS_KEY_ID"); v == "" {
|
|
||||||
t.Fatal("AWS_ACCESS_KEY_ID must be set for acceptance tests")
|
|
||||||
}
|
|
||||||
|
|
||||||
if v := os.Getenv("AWS_SECRET_ACCESS_KEY"); v == "" {
|
|
||||||
t.Fatal("AWS_SECRET_ACCESS_KEY must be set for acceptance tests")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testEC2Conn() (*ec2.EC2, error) {
|
func testEC2Conn() (*ec2.EC2, error) {
|
||||||
|
@ -298,7 +294,7 @@ const testBuilderAccForceDeregister = `
|
||||||
"source_ami": "ami-76b2a71e",
|
"source_ami": "ami-76b2a71e",
|
||||||
"ssh_username": "ubuntu",
|
"ssh_username": "ubuntu",
|
||||||
"force_deregister": "%s",
|
"force_deregister": "%s",
|
||||||
"ami_name": "packer-test-%s"
|
"ami_name": "%s"
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
@ -313,7 +309,7 @@ const testBuilderAccForceDeleteSnapshot = `
|
||||||
"ssh_username": "ubuntu",
|
"ssh_username": "ubuntu",
|
||||||
"force_deregister": "%s",
|
"force_deregister": "%s",
|
||||||
"force_delete_snapshot": "%s",
|
"force_delete_snapshot": "%s",
|
||||||
"ami_name": "packer-test-%s"
|
"ami_name": "%s"
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
Loading…
Reference in New Issue