update acc test

This commit is contained in:
mingsheng.su 2019-06-13 18:38:07 +08:00
parent c8bab9b382
commit 156d31f933
2 changed files with 15 additions and 11 deletions

View File

@ -78,7 +78,7 @@ const testBuilderAccUbuntu = `
"instance_type": "n-basic-2", "instance_type": "n-basic-2",
"source_image_id":"uimage-irofn4", "source_image_id":"uimage-irofn4",
"ssh_username":"ubuntu", "ssh_username":"ubuntu",
"image_name": "packer-test-basic_{{timestamp}}" "image_name": "packer-test-ubuntu_{{timestamp}}"
}] }]
}` }`
@ -90,16 +90,17 @@ func TestBuilderAcc_regionCopy(t *testing.T) {
testAccPreCheck(t) testAccPreCheck(t)
}, },
Builder: &Builder{}, Builder: &Builder{},
Template: testBuilderAccRegionCopy, Template: testBuilderAccRegionCopy(projectId),
Check: checkRegionCopy( Check: checkRegionCopy(
projectId, projectId,
[]ImageDestination{ []ImageDestination{
{"org-fthbzm", "cn-sh2", "packer-test-regionCopy-sh", "test"}, {projectId, "cn-sh2", "packer-test-regionCopy-sh", "test"},
}), }),
}) })
} }
const testBuilderAccRegionCopy = ` func testBuilderAccRegionCopy(projectId string) string {
return fmt.Sprintf(`
{ {
"builders": [{ "builders": [{
"type": "test", "type": "test",
@ -108,15 +109,16 @@ const testBuilderAccRegionCopy = `
"instance_type": "n-basic-2", "instance_type": "n-basic-2",
"source_image_id":"uimage-f1chxn", "source_image_id":"uimage-f1chxn",
"ssh_username":"root", "ssh_username":"root",
"image_name": "packer-test-regionCopy_{{timestamp}}", "image_name": "packer-test-regionCopy-bj",
"image_copy_mappings": [{ "image_copy_to_mappings": [{
"image_copy_project_id": "org-fthbzm", "project_id": %q,
"image_copy_region": "cn-sh2", "region": "cn-sh2",
"image_copy_name": "packer-test-regionCopy-sh", "name": "packer-test-regionCopy-sh",
"image_copy_description": "test" "description": "test"
}] }]
}] }]
}` }`, projectId)
}
func checkRegionCopy(projectId string, imageDst []ImageDestination) builderT.TestCheckFunc { func checkRegionCopy(projectId string, imageDst []ImageDestination) builderT.TestCheckFunc {
return func(artifacts []packer.Artifact) error { return func(artifacts []packer.Artifact) error {

View File

@ -17,6 +17,8 @@ customized images based on an existing base images.
This builder builds an UCloud image by launching an UHost instance from a source image, This builder builds an UCloud image by launching an UHost instance from a source image,
provisioning that running machine, and then creating an image from that machine. provisioning that running machine, and then creating an image from that machine.
\~> **Note:** This builder only support ssh authenticating with username and given password.
## Configuration Reference ## Configuration Reference
The following configuration options available for building UCloud images. They are The following configuration options available for building UCloud images. They are