Merge "Adds tests for tags in boto (EC2 API)"
diff --git a/tempest/services/botoclients.py b/tempest/services/botoclients.py
index 628151a..32ec109 100644
--- a/tempest/services/botoclients.py
+++ b/tempest/services/botoclients.py
@@ -132,6 +132,7 @@
ALLOWED_METHODS = set(('create_key_pair', 'get_key_pair',
'delete_key_pair', 'import_key_pair',
'get_all_key_pairs',
+ 'get_all_tags',
'create_image', 'get_image',
'register_image', 'deregister_image',
'get_all_images', 'get_image_attribute',
diff --git a/tempest/thirdparty/boto/test_ec2_instance_run.py b/tempest/thirdparty/boto/test_ec2_instance_run.py
index 89891d2..1201866 100644
--- a/tempest/thirdparty/boto/test_ec2_instance_run.py
+++ b/tempest/thirdparty/boto/test_ec2_instance_run.py
@@ -113,6 +113,53 @@
self.cancelResourceCleanUp(rcuk)
@attr(type='smoke')
+ def test_run_stop_terminate_instance_with_tags(self):
+ # EC2 run, stop and terminate instance with tags
+ image_ami = self.ec2_client.get_image(self.images["ami"]
+ ["image_id"])
+ reservation = image_ami.run(kernel_id=self.images["aki"]["image_id"],
+ ramdisk_id=self.images["ari"]["image_id"],
+ instance_type=self.instance_type)
+ rcuk = self.addResourceCleanUp(self.destroy_reservation, reservation)
+
+ for instance in reservation.instances:
+ LOG.info("state: %s", instance.state)
+ if instance.state != "running":
+ self.assertInstanceStateWait(instance, "running")
+ instance.add_tag('key1', value='value1')
+
+ tags = self.ec2_client.get_all_tags()
+ self.assertEquals(tags[0].name, 'key1')
+ self.assertEquals(tags[0].value, 'value1')
+
+ tags = self.ec2_client.get_all_tags(filters={'key': 'key1'})
+ self.assertEquals(tags[0].name, 'key1')
+ self.assertEquals(tags[0].value, 'value1')
+
+ tags = self.ec2_client.get_all_tags(filters={'value': 'value1'})
+ self.assertEquals(tags[0].name, 'key1')
+ self.assertEquals(tags[0].value, 'value1')
+
+ tags = self.ec2_client.get_all_tags(filters={'key': 'value2'})
+ self.assertEquals(len(tags), 0)
+
+ for instance in reservation.instances:
+ instance.remove_tag('key1', value='value1')
+
+ tags = self.ec2_client.get_all_tags()
+ self.assertEquals(len(tags), 0)
+
+ for instance in reservation.instances:
+ instance.stop()
+ LOG.info("state: %s", instance.state)
+ if instance.state != "stopped":
+ self.assertInstanceStateWait(instance, "stopped")
+
+ for instance in reservation.instances:
+ instance.terminate()
+ self.cancelResourceCleanUp(rcuk)
+
+ @attr(type='smoke')
@testtools.skip("Skipped until the Bug #1098891 is resolved")
def test_run_terminate_instance(self):
# EC2 run, terminate immediately