@@ -144,8 +144,8 @@ def setUpClass(cls):
144144 cls .apiclient ,
145145 cls .services ["isolated_network_offering" ]
146146 )
147- cls .network_offering_isolated .update (cls .apiclient , state = 'Enabled' )
148147 cls ._cleanup .append (cls .network_offering_isolated )
148+ cls .network_offering_isolated .update (cls .apiclient , state = 'Enabled' )
149149
150150 # 4. Create sub-domain
151151 cls .sub_domain = Domain .create (
@@ -176,6 +176,7 @@ def setUpClass(cls):
176176 networkofferingid = cls .network_offering_isolated .id ,
177177 zoneid = cls .zone .id
178178 )
179+ cls ._cleanup .append (cls .user_network_1 )
179180
180181 cls .services ["network" ]["name" ] = "Test Network Isolated - Regular user - 2"
181182 cls .user_network_2 = Network .create (
@@ -184,12 +185,14 @@ def setUpClass(cls):
184185 networkofferingid = cls .network_offering_isolated .id ,
185186 zoneid = cls .zone .id
186187 )
188+ cls ._cleanup .append (cls .user_network_2 )
187189
188190 # 8. Create SSH Keypairs
189191 cls .keypair_1 = SSHKeyPair .create (
190192 cls .regular_user_apiclient ,
191193 name = "keypair1"
192194 )
195+
193196 cls .keypair_2 = SSHKeyPair .create (
194197 cls .regular_user_apiclient ,
195198 name = "keypair2"
@@ -224,17 +227,41 @@ def setUpClass(cls):
224227 relationaloperator = "GE" ,
225228 threshold = 1
226229 )
230+ cls ._cleanup .append (cls .scale_up_condition )
227231
228232 cls .scale_down_condition = AutoScaleCondition .create (
229233 cls .regular_user_apiclient ,
230234 counterid = cls .counter_cpu_or_memory_id ,
231235 relationaloperator = "LE" ,
232236 threshold = 100
233237 )
234-
235- cls ._cleanup .append (cls .scale_up_condition )
236238 cls ._cleanup .append (cls .scale_down_condition )
237239
240+ # 10.2 Create new AS conditions for VM group update
241+ cls .new_condition_1 = AutoScaleCondition .create (
242+ cls .regular_user_apiclient ,
243+ counterid = cls .counter_network_received_id ,
244+ relationaloperator = "GE" ,
245+ threshold = 0
246+ )
247+ cls ._cleanup .append (cls .new_condition_1 )
248+
249+ cls .new_condition_2 = AutoScaleCondition .create (
250+ cls .regular_user_apiclient ,
251+ counterid = cls .counter_network_transmit_id ,
252+ relationaloperator = "GE" ,
253+ threshold = 0
254+ )
255+ cls ._cleanup .append (cls .new_condition_2 )
256+
257+ cls .new_condition_3 = AutoScaleCondition .create (
258+ cls .regular_user_apiclient ,
259+ counterid = cls .counter_lb_connection_id ,
260+ relationaloperator = "GE" ,
261+ threshold = 0
262+ )
263+ cls ._cleanup .append (cls .new_condition_3 )
264+
238265 # 11. Create AS policies
239266 cls .scale_up_policy = AutoScalePolicy .create (
240267 cls .regular_user_apiclient ,
@@ -243,6 +270,7 @@ def setUpClass(cls):
243270 quiettime = DEFAULT_QUIETTIME ,
244271 duration = DEFAULT_DURATION
245272 )
273+ cls ._cleanup .append (cls .scale_up_policy )
246274
247275 cls .scale_down_policy = AutoScalePolicy .create (
248276 cls .regular_user_apiclient ,
@@ -251,8 +279,6 @@ def setUpClass(cls):
251279 quiettime = DEFAULT_QUIETTIME ,
252280 duration = DEFAULT_DURATION
253281 )
254-
255- cls ._cleanup .append (cls .scale_up_policy )
256282 cls ._cleanup .append (cls .scale_down_policy )
257283
258284 # 12. Create AS VM Profile
@@ -288,6 +314,7 @@ def setUpClass(cls):
288314 ipaddressid = cls .public_ip_address .ipaddress .id ,
289315 networkid = cls .user_network_1 .id
290316 )
317+ cls ._cleanup .append (cls .load_balancer_rule )
291318
292319 # 14. Create AS VM Group
293320 cls .autoscaling_vmgroup = AutoScaleVmGroup .create (
@@ -663,28 +690,10 @@ def test_03_scale_down_verify(self):
663690 )
664691 scale_down_policy = policies [0 ]
665692
666- new_condition_1 = AutoScaleCondition .create (
667- self .regular_user_apiclient ,
668- counterid = self .counter_network_received_id ,
669- relationaloperator = "GE" ,
670- threshold = 0
671- )
672- new_condition_2 = AutoScaleCondition .create (
673- self .regular_user_apiclient ,
674- counterid = self .counter_network_transmit_id ,
675- relationaloperator = "GE" ,
676- threshold = 0
677- )
678- new_condition_3 = AutoScaleCondition .create (
679- self .regular_user_apiclient ,
680- counterid = self .counter_lb_connection_id ,
681- relationaloperator = "GE" ,
682- threshold = 0
683- )
684693 Autoscale .updateAutoscalePolicy (
685694 self .regular_user_apiclient ,
686695 id = scale_down_policy .id ,
687- conditionids = ',' .join ([new_condition_1 .id , new_condition_2 .id , new_condition_3 .id ])
696+ conditionids = ',' .join ([self . new_condition_1 .id , self . new_condition_2 .id , self . new_condition_3 .id ])
688697 )
689698
690699 self .autoscaling_vmgroup .enable (self .regular_user_apiclient )
@@ -807,6 +816,7 @@ def test_06_autoscaling_vmgroup_on_project_network(self):
807816 relationaloperator = "GE" ,
808817 threshold = 1
809818 )
819+ self .cleanup .append (scale_up_condition_project )
810820
811821 scale_down_condition_project = AutoScaleCondition .create (
812822 self .regular_user_apiclient ,
@@ -815,8 +825,6 @@ def test_06_autoscaling_vmgroup_on_project_network(self):
815825 relationaloperator = "LE" ,
816826 threshold = 100
817827 )
818-
819- self .cleanup .append (scale_up_condition_project )
820828 self .cleanup .append (scale_down_condition_project )
821829
822830 # Create AS policies for project
@@ -827,6 +835,7 @@ def test_06_autoscaling_vmgroup_on_project_network(self):
827835 quiettime = DEFAULT_QUIETTIME ,
828836 duration = DEFAULT_DURATION
829837 )
838+ self .cleanup .append (scale_up_policy_project )
830839
831840 scale_down_policy_project = AutoScalePolicy .create (
832841 self .regular_user_apiclient ,
@@ -835,8 +844,6 @@ def test_06_autoscaling_vmgroup_on_project_network(self):
835844 quiettime = DEFAULT_QUIETTIME ,
836845 duration = DEFAULT_DURATION
837846 )
838-
839- self .cleanup .append (scale_up_policy_project )
840847 self .cleanup .append (scale_down_policy_project )
841848
842849 # Create AS VM Profile for project
@@ -848,6 +855,7 @@ def test_06_autoscaling_vmgroup_on_project_network(self):
848855 expungevmgraceperiod = DEFAULT_EXPUNGE_VM_GRACE_PERIOD ,
849856 projectid = project .id
850857 )
858+ self .cleanup .append (autoscaling_vmprofile_project )
851859
852860 # Create AS VM Group for project
853861 autoscaling_vmgroup_project = AutoScaleVmGroup .create (
@@ -989,47 +997,50 @@ def test_07_autoscaling_vmgroup_on_vpc_network(self):
989997 relationaloperator = "GE" ,
990998 threshold = 1
991999 )
992- scale_up_condition_3 = AutoScaleCondition .create (
1000+ self .cleanup .append (scale_up_condition_1 )
1001+
1002+ scale_up_condition_2 = AutoScaleCondition .create (
9931003 self .regular_user_apiclient ,
9941004 counterid = self .counter_network_received_id ,
9951005 relationaloperator = "GE" ,
9961006 threshold = 0
9971007 )
998- scale_up_condition_4 = AutoScaleCondition .create (
1008+ self .cleanup .append (scale_up_condition_2 )
1009+
1010+ scale_up_condition_3 = AutoScaleCondition .create (
9991011 self .regular_user_apiclient ,
10001012 counterid = self .counter_network_transmit_id ,
10011013 relationaloperator = "GE" ,
10021014 threshold = 0
10031015 )
1004- scale_up_condition_5 = AutoScaleCondition .create (
1016+ self .cleanup .append (scale_up_condition_3 )
1017+
1018+ scale_up_condition_4 = AutoScaleCondition .create (
10051019 self .regular_user_apiclient ,
10061020 counterid = self .counter_lb_connection_id ,
10071021 relationaloperator = "GE" ,
10081022 threshold = 0
10091023 )
1024+ self .cleanup .append (scale_up_condition_4 )
10101025
10111026 scale_down_condition_vpc = AutoScaleCondition .create (
10121027 self .regular_user_apiclient ,
10131028 counterid = self .counter_cpu_or_memory_id ,
10141029 relationaloperator = "LE" ,
10151030 threshold = 100
10161031 )
1017-
1018- self .cleanup .append (scale_up_condition_1 )
1019- self .cleanup .append (scale_up_condition_3 )
1020- self .cleanup .append (scale_up_condition_4 )
1021- self .cleanup .append (scale_up_condition_5 )
10221032 self .cleanup .append (scale_down_condition_vpc )
10231033
10241034 # Create AS policies for vpc
10251035 scale_up_policy_vpc = AutoScalePolicy .create (
10261036 self .regular_user_apiclient ,
10271037 action = 'ScaleUp' ,
1028- conditionids = ',' .join ([scale_up_condition_1 .id , scale_up_condition_3 .id ,
1029- scale_up_condition_4 .id , scale_up_condition_5 .id ]),
1038+ conditionids = ',' .join ([scale_up_condition_1 .id , scale_up_condition_2 .id ,
1039+ scale_up_condition_3 .id , scale_up_condition_4 .id ]),
10301040 quiettime = DEFAULT_QUIETTIME ,
10311041 duration = DEFAULT_DURATION
10321042 )
1043+ self .cleanup .append (scale_up_policy_vpc )
10331044
10341045 scale_down_policy_vpc = AutoScalePolicy .create (
10351046 self .regular_user_apiclient ,
@@ -1038,8 +1049,6 @@ def test_07_autoscaling_vmgroup_on_vpc_network(self):
10381049 quiettime = DEFAULT_QUIETTIME ,
10391050 duration = DEFAULT_DURATION
10401051 )
1041-
1042- self .cleanup .append (scale_up_policy_vpc )
10431052 self .cleanup .append (scale_down_policy_vpc )
10441053
10451054 # Create AS VM Profile for vpc
0 commit comments