Merge "test_server_basic_ops: Test metadata service"
diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample
index 07ee026..7d4ba86 100644
--- a/etc/tempest.conf.sample
+++ b/etc/tempest.conf.sample
@@ -376,6 +376,10 @@
# value)
#live_migration = true
+# Does the test environment support metadata service? Ignored unless
+# validation.run_validation=true. (boolean value)
+#metadata_service = true
+
# Does the test environment use block devices for live migration
# (boolean value)
#block_migration_for_live_migration = false
diff --git a/tempest/config.py b/tempest/config.py
index bdfdcdc..ab503e3 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -331,6 +331,10 @@
default=True,
help="Does the test environment support live migration "
"available?"),
+ cfg.BoolOpt('metadata_service',
+ default=True,
+ help="Does the test environment support metadata service? "
+ "Ignored unless validation.run_validation=true."),
cfg.BoolOpt('block_migration_for_live_migration',
default=False,
help="Does the test environment use block devices for live "
diff --git a/tempest/scenario/test_server_basic_ops.py b/tempest/scenario/test_server_basic_ops.py
index d9918f3..f61b151 100644
--- a/tempest/scenario/test_server_basic_ops.py
+++ b/tempest/scenario/test_server_basic_ops.py
@@ -37,6 +37,7 @@
* Add simple permissive rules to the security group
* Launch an instance
* Perform ssh to instance
+ * Verify metadata service
* Terminate the instance
"""
@@ -81,19 +82,26 @@
def verify_ssh(self):
if self.run_ssh:
# Obtain a floating IP
- floating_ip = self.floating_ips_client.create_floating_ip()
+ self.floating_ip = self.floating_ips_client.create_floating_ip()
self.addCleanup(self.delete_wrapper,
self.floating_ips_client.delete_floating_ip,
- floating_ip['id'])
+ self.floating_ip['id'])
# Attach a floating IP
self.floating_ips_client.associate_floating_ip_to_server(
- floating_ip['ip'], self.instance['id'])
+ self.floating_ip['ip'], self.instance['id'])
# Check ssh
- self.get_remote_client(
- server_or_ip=floating_ip['ip'],
+ self.ssh_client = self.get_remote_client(
+ server_or_ip=self.floating_ip['ip'],
username=self.image_utils.ssh_user(self.image_ref),
private_key=self.keypair['private_key'])
+ def verify_metadata(self):
+ if self.run_ssh and CONF.compute_feature_enabled.metadata_service:
+ # Verify metadata service
+ result = self.ssh_client.exec_command(
+ "curl http://169.254.169.254/latest/meta-data/public-ipv4")
+ self.assertEqual(self.floating_ip['ip'], result)
+
@test.idempotent_id('7fff3fb3-91d8-4fd0-bd7d-0204f1f180ba')
@test.attr(type='smoke')
@test.services('compute', 'network')
@@ -102,4 +110,5 @@
self.security_group = self._create_security_group()
self.boot_instance()
self.verify_ssh()
+ self.verify_metadata()
self.servers_client.delete_server(self.instance['id'])