ubuntu-server-ec2-testing-dev team mailing list archive
-
ubuntu-server-ec2-testing-dev team
-
Mailing list archive
-
Message #00000
[Merge] lp:~smoser/ubuntu-server-ec2-testing/fixes into lp:ubuntu-server-ec2-testing
Scott Moser has proposed merging lp:~smoser/ubuntu-server-ec2-testing/fixes into lp:ubuntu-server-ec2-testing.
Requested reviews:
Ubuntu Server ec2 Testing Developers (ubuntu-server-ec2-testing-dev)
For more details, see:
https://code.launchpad.net/~smoser/ubuntu-server-ec2-testing/fixes/+merge/79174
add and use 'terminate_and_wait' method
This adds the terminate_and_wait method to TestCaseExecutor.
As seen at [1], TidyUp would raise an exception and prevent
the final retrieval of logs. Without those final logs, there
was no way to debug what went wrong.
--
[1] https://jenkins.qa.ubuntu.com/job/oneiric-server-ec2/10/ARCH=i386,REGION=ap-southeast-1,STORAGE=instance-store,TEST=cloud-config,label=ubuntu-server-ec2-testing/console
--
https://code.launchpad.net/~smoser/ubuntu-server-ec2-testing/fixes/+merge/79174
Your team Ubuntu Server ec2 Testing Developers is requested to review the proposed merge of lp:~smoser/ubuntu-server-ec2-testing/fixes into lp:ubuntu-server-ec2-testing.
=== modified file 'src/ubuntu/ec2/testing.py'
--- src/ubuntu/ec2/testing.py 2011-04-26 08:57:28 +0000
+++ src/ubuntu/ec2/testing.py 2011-10-12 20:05:20 +0000
@@ -454,6 +454,34 @@
if ((not l_instance.complete) and l_instance.sshable):
l_instance.collect_metadata('timeout')
+ def terminate_and_wait(tries=12, naplen=DEFAULT_SLEEP):
+ if not self.reservation:
+ return
+ # turn a result list into an instance list
+ def _resl2instl(result_set):
+ ret = []
+ for res in result_set:
+ for inst in res.instances:
+ ret.append(inst)
+ return(ret)
+
+ iid_l = [l.ec2_instance.id for l in self.test_instances]
+ # check to see if there is work to do, if not, return
+ for tnum in range(1,tries+1):
+ res_l = self.conn.get_all_instances(instance_ids=iid_l)
+ instances = _resl2instl(res_l)
+ to_term = [ i.id for i in instances if i.state != "terminated" ]
+ if len(to_term) == 0:
+ return
+ self.conn.terminate_instances(to_term)
+ iid_l = to_term
+ logging.debug("Waiting on terminate-instances [%i/%i]: %s" %
+ (tnum, tries, to_term))
+ time.sleep(naplen)
+
+ logging.warning("These instances did not terminate: %s" % to_term)
+ return
+
def tidyup(self):
''' Tidyup any residual stuff left over '''
# Remove the private key!!!!
@@ -470,7 +498,7 @@
# terminated
if self.reservation:
logging.debug('Terminating all instances associated with test case')
- self.reservation.stop_all()
+ self.terminate_and_wait()
# Tidyup the keypair
if self.keypair:
Follow ups