@@ -10,20 +10,19 @@ import (
1010)
1111
1212// Test ESA OriginPool. >>> Resource test cases, automatically generated.
13- // Case originpool_test
14- func TestAccAliCloudESAOriginPooloriginpool_test (t * testing.T ) {
13+ // Case 0
14+ func TestAccAliCloudESAOriginPool_basic0 (t * testing.T ) {
1515 var v map [string ]interface {}
1616 resourceId := "alicloud_esa_origin_pool.default"
17- ra := resourceAttrInit (resourceId , AliCloudESAOriginPooloriginpool_testMap )
17+ ra := resourceAttrInit (resourceId , AliCloudESAOriginPoolMap0 )
1818 rc := resourceCheckInitWithDescribeMethod (resourceId , & v , func () interface {} {
1919 return & EsaServiceV2 {testAccProvider .Meta ().(* connectivity.AliyunClient )}
2020 }, "DescribeEsaOriginPool" )
2121 rac := resourceAttrCheckInit (rc , ra )
2222 testAccCheck := rac .resourceAttrMapUpdateSet ()
2323 rand := acctest .RandIntRange (10000 , 99999 )
2424 name := fmt .Sprintf ("bcd%d.com" , rand )
25-
26- testAccConfig := resourceTestAccConfigFunc (resourceId , name , AliCloudESAOriginPooloriginpool_testBasicDependence )
25+ testAccConfig := resourceTestAccConfigFunc (resourceId , name , AliCloudESAOriginPoolBasicDependence0 )
2726 resource .Test (t , resource.TestCase {
2827 PreCheck : func () {
2928 testAccPreCheck (t )
@@ -33,44 +32,91 @@ func TestAccAliCloudESAOriginPooloriginpool_test(t *testing.T) {
3332 Providers : testAccProviders ,
3433 CheckDestroy : rac .checkResourceDestroy (),
3534 Steps : []resource.TestStep {
35+ {
36+ Config : testAccConfig (map [string ]interface {}{
37+ "site_id" : "${data.alicloud_esa_sites.default.sites.0.id}" ,
38+ "origin_pool_name" : name ,
39+ "origins" : []map [string ]interface {}{
40+ {
41+ "type" : "S3" ,
42+ "address" : "test.s3.com" ,
43+ "auth_conf" : []map [string ]interface {}{
44+ {
45+ "secret_key" : "bd8tjba5lXxxxxiRXFIBvoCIfJIL2WJ" ,
46+ "version" : "v2" ,
47+ "region" : "us-east-1" ,
48+ "auth_type" : "private" ,
49+ "access_key" : "LTAI5tGLgmPe1wFwpX8645BF" ,
50+ },
51+ },
52+ "weight" : "50" ,
53+ "name" : name ,
54+ },
55+ },
56+ }),
57+ Check : resource .ComposeTestCheckFunc (
58+ testAccCheck (map [string ]string {
59+ "site_id" : CHECKSET ,
60+ "origin_pool_name" : name ,
61+ "origins.#" : "1" ,
62+ }),
63+ ),
64+ },
65+ {
66+ Config : testAccConfig (map [string ]interface {}{
67+ "enabled" : "false" ,
68+ }),
69+ Check : resource .ComposeTestCheckFunc (
70+ testAccCheck (map [string ]string {
71+ "enabled" : "false" ,
72+ }),
73+ ),
74+ },
75+ {
76+ Config : testAccConfig (map [string ]interface {}{
77+ "enabled" : "true" ,
78+ }),
79+ Check : resource .ComposeTestCheckFunc (
80+ testAccCheck (map [string ]string {
81+ "enabled" : "true" ,
82+ }),
83+ ),
84+ },
3685 {
3786 Config : testAccConfig (map [string ]interface {}{
3887 "origins" : []map [string ]interface {}{
39-
4088 {
4189 "type" : "OSS" ,
42- "address" : "zhouwei123 .oss-cn-beijing.aliyuncs.com" ,
43- "header" : "{\\ \" Host\\ \" :[\\ \" zhouwei123 .oss-cn-beijing.aliyuncs.com\\ \" ]}" ,
44- "enabled" : "true " ,
90+ "address" : "zhouwei456 .oss-cn-beijing.aliyuncs.com" ,
91+ "header" : "{\\ \" Host\\ \" :[\\ \" zhouwei456 .oss-cn-beijing.aliyuncs.com\\ \" ]}" ,
92+ "enabled" : "false " ,
4593 "auth_conf" : []map [string ]interface {}{
4694 {
4795 "secret_key" : "bd8tjba5lXxxxxiRXFIBvoCIfJIL2WJ" ,
4896 "auth_type" : "private_cross_account" ,
4997 "access_key" : "LTAI5tGLgmPe1wFwpX8645BF" ,
5098 },
5199 },
52- "weight" : "50 " ,
53- "name" : "origin1 " ,
100+ "weight" : "60 " ,
101+ "name" : "origin11 " ,
54102 },
55-
56103 {
57104 "type" : "S3" ,
58- "address" : "test .s3.com" ,
59- "header" : "{\\ \" Host\\ \" :[\\ \" example1 .com\\ \" ]}" ,
60- "enabled" : "true " ,
105+ "address" : "test11 .s3.com" ,
106+ "header" : "{\\ \" Host\\ \" :[\\ \" example11 .com\\ \" ]}" ,
107+ "enabled" : "false " ,
61108 "auth_conf" : []map [string ]interface {}{
62109 {
63110 "secret_key" : "bd8tjba5lXxxxxiRXFIBvoCIfJIL2WJ" ,
64- "version" : "v2 " ,
65- "region" : "us-east-1 " ,
111+ "version" : "v4 " ,
112+ "region" : "us-east-11 " ,
66113 "auth_type" : "private" ,
67114 "access_key" : "LTAI5tGLgmPe1wFwpX8645BF" ,
68115 },
69116 },
70- "weight" : "50 " ,
71- "name" : "origin2 " ,
117+ "weight" : "70 " ,
118+ "name" : "origin22 " ,
72119 },
73-
74120 {
75121 "type" : "S3" ,
76122 "address" : "test1111.s3.com" ,
@@ -89,26 +135,50 @@ func TestAccAliCloudESAOriginPooloriginpool_test(t *testing.T) {
89135 "name" : "origin3" ,
90136 },
91137 },
92- "site_id" : "${alicloud_esa_site.resource_Site_OriginPool_test.id}" ,
93- "origin_pool_name" : "testoriginpool" ,
94- "enabled" : "true" ,
95138 }),
96139 Check : resource .ComposeTestCheckFunc (
97- testAccCheck (map [string ]string {}),
140+ testAccCheck (map [string ]string {
141+ "origins.#" : "3" ,
142+ }),
98143 ),
99144 },
100145 {
101- Config : testAccConfig (map [string ]interface {}{
102- "enabled" : "false" ,
103- }),
104- Check : resource .ComposeTestCheckFunc (
105- testAccCheck (map [string ]string {}),
106- ),
146+ ResourceName : resourceId ,
147+ ImportState : true ,
148+ ImportStateVerify : true ,
149+ ImportStateVerifyIgnore : []string {"" },
107150 },
151+ },
152+ })
153+ }
154+
155+ func TestAccAliCloudESAOriginPool_basic0_twin (t * testing.T ) {
156+ var v map [string ]interface {}
157+ resourceId := "alicloud_esa_origin_pool.default"
158+ ra := resourceAttrInit (resourceId , AliCloudESAOriginPoolMap0 )
159+ rc := resourceCheckInitWithDescribeMethod (resourceId , & v , func () interface {} {
160+ return & EsaServiceV2 {testAccProvider .Meta ().(* connectivity.AliyunClient )}
161+ }, "DescribeEsaOriginPool" )
162+ rac := resourceAttrCheckInit (rc , ra )
163+ testAccCheck := rac .resourceAttrMapUpdateSet ()
164+ rand := acctest .RandIntRange (10000 , 99999 )
165+ name := fmt .Sprintf ("bcd%d.com" , rand )
166+ testAccConfig := resourceTestAccConfigFunc (resourceId , name , AliCloudESAOriginPoolBasicDependence0 )
167+ resource .Test (t , resource.TestCase {
168+ PreCheck : func () {
169+ testAccPreCheck (t )
170+ testAccPreCheckWithRegions (t , true , []connectivity.Region {"cn-hangzhou" })
171+ },
172+ IDRefreshName : resourceId ,
173+ Providers : testAccProviders ,
174+ CheckDestroy : rac .checkResourceDestroy (),
175+ Steps : []resource.TestStep {
108176 {
109177 Config : testAccConfig (map [string ]interface {}{
178+ "site_id" : "${data.alicloud_esa_sites.default.sites.0.id}" ,
179+ "origin_pool_name" : name ,
180+ "enabled" : "true" ,
110181 "origins" : []map [string ]interface {}{
111-
112182 {
113183 "type" : "OSS" ,
114184 "address" : "zhouwei456.oss-cn-beijing.aliyuncs.com" ,
@@ -124,16 +194,6 @@ func TestAccAliCloudESAOriginPooloriginpool_test(t *testing.T) {
124194 "weight" : "60" ,
125195 "name" : "origin11" ,
126196 },
127- },
128- }),
129- Check : resource .ComposeTestCheckFunc (
130- testAccCheck (map [string ]string {}),
131- ),
132- },
133- {
134- Config : testAccConfig (map [string ]interface {}{
135- "origins" : []map [string ]interface {}{
136-
137197 {
138198 "type" : "S3" ,
139199 "address" : "test11.s3.com" ,
@@ -151,50 +211,58 @@ func TestAccAliCloudESAOriginPooloriginpool_test(t *testing.T) {
151211 "weight" : "70" ,
152212 "name" : "origin22" ,
153213 },
214+ {
215+ "type" : "S3" ,
216+ "address" : "test1111.s3.com" ,
217+ "header" : "{\\ \" Host\\ \" :[\\ \" example1111.com\\ \" ]}" ,
218+ "enabled" : "true" ,
219+ "auth_conf" : []map [string ]interface {}{
220+ {
221+ "secret_key" : "bd8tjba5lXxxxxiRXFIBvoCIfJIL2WJ" ,
222+ "version" : "v2" ,
223+ "region" : "us-east-1" ,
224+ "auth_type" : "private" ,
225+ "access_key" : "LTAI5tGLgmPe1wFwpX8645BF" ,
226+ },
227+ },
228+ "weight" : "30" ,
229+ "name" : "origin3" ,
230+ },
154231 },
155232 }),
156233 Check : resource .ComposeTestCheckFunc (
157- testAccCheck (map [string ]string {}),
158- ),
159- },
160- {
161- Config : testAccConfig (map [string ]interface {}{}),
162- Check : resource .ComposeTestCheckFunc (
163- testAccCheck (map [string ]string {}),
234+ testAccCheck (map [string ]string {
235+ "site_id" : CHECKSET ,
236+ "origin_pool_name" : name ,
237+ "enabled" : "true" ,
238+ "origins.#" : "3" ,
239+ }),
164240 ),
165241 },
166242 {
167243 ResourceName : resourceId ,
168244 ImportState : true ,
169245 ImportStateVerify : true ,
170- ImportStateVerifyIgnore : []string {"origins " },
246+ ImportStateVerifyIgnore : []string {"" },
171247 },
172248 },
173249 })
174250}
175251
176- var AliCloudESAOriginPooloriginpool_testMap = map [string ]string {
177- "id" : CHECKSET ,
252+ var AliCloudESAOriginPoolMap0 = map [string ]string {
253+ "enabled" : CHECKSET ,
254+ "origin_pool_id" : CHECKSET ,
178255}
179256
180- func AliCloudESAOriginPooloriginpool_testBasicDependence (name string ) string {
257+ func AliCloudESAOriginPoolBasicDependence0 (name string ) string {
181258 return fmt .Sprintf (`
182259variable "name" {
183- default = "%s"
260+ default = "%s"
184261}
185262
186-
187263data "alicloud_esa_sites" "default" {
188264 plan_subscribe_type = "enterpriseplan"
189265}
190-
191- resource "alicloud_esa_site" "resource_Site_OriginPool_test" {
192- site_name = var.name
193- instance_id = data.alicloud_esa_sites.default.sites.0.instance_id
194- coverage = "overseas"
195- access_type = "NS"
196- }
197-
198266` , name )
199267}
200268
0 commit comments