Merge "Add a rule for blocking "-" from rand_name call"
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index 9aacfa5..a1f6f99 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -16,11 +16,10 @@
import time
from oslo_log import log as logging
-from oslo_utils import excutils
from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
-from tempest.common import fixed_network
+from tempest.common import compute
from tempest import config
from tempest import exceptions
import tempest.test
@@ -192,41 +191,21 @@
server_group_id)
@classmethod
- def create_test_server(cls, **kwargs):
- """Wrapper utility that returns a test server."""
- name = data_utils.rand_name(cls.__name__ + "-instance")
- if 'name' in kwargs:
- name = kwargs.pop('name')
- flavor = kwargs.get('flavor', cls.flavor_ref)
- image_id = kwargs.get('image_id', cls.image_ref)
+ def create_test_server(cls, validatable=False, **kwargs):
+ """Wrapper utility that returns a test server.
- kwargs = fixed_network.set_networks_kwarg(
- cls.get_tenant_network(), kwargs) or {}
- body = cls.servers_client.create_server(
- name, image_id, flavor, **kwargs)
-
- # handle the case of multiple servers
- servers = [body]
- if 'min_count' in kwargs or 'max_count' in kwargs:
- # Get servers created which name match with name param.
- b = cls.servers_client.list_servers()
- servers = [s for s in b['servers'] if s['name'].startswith(name)]
-
- if 'wait_until' in kwargs:
- for server in servers:
- try:
- cls.servers_client.wait_for_server_status(
- server['id'], kwargs['wait_until'])
- except Exception:
- with excutils.save_and_reraise_exception():
- if ('preserve_server_on_error' not in kwargs
- or kwargs['preserve_server_on_error'] is False):
- for server in servers:
- try:
- cls.servers_client.delete_server(
- server['id'])
- except Exception:
- pass
+ This wrapper utility calls the common create test server and
+ returns a test server. The purpose of this wrapper is to minimize
+ the impact on the code of the tests already using this
+ function.
+ """
+ tenant_network = cls.get_tenant_network()
+ body, servers = compute.create_test_server(
+ cls.os,
+ validatable,
+ validation_resources=cls.validation_resources,
+ tenant_network=tenant_network,
+ **kwargs)
cls.servers.extend(servers)
diff --git a/tempest/api/compute/servers/test_create_server.py b/tempest/api/compute/servers/test_create_server.py
index 16b1597..408d4ee 100644
--- a/tempest/api/compute/servers/test_create_server.py
+++ b/tempest/api/compute/servers/test_create_server.py
@@ -53,14 +53,16 @@
personality = [{'path': '/test.txt',
'contents': base64.b64encode(file_contents)}]
disk_config = cls.disk_config
- cls.server_initial = cls.create_test_server(name=cls.name,
- meta=cls.meta,
- accessIPv4=cls.accessIPv4,
- accessIPv6=cls.accessIPv6,
- personality=personality,
- disk_config=disk_config)
+ cls.server_initial = cls.create_test_server(
+ validatable=True,
+ wait_until='ACTIVE',
+ name=cls.name,
+ meta=cls.meta,
+ accessIPv4=cls.accessIPv4,
+ accessIPv6=cls.accessIPv6,
+ personality=personality,
+ disk_config=disk_config)
cls.password = cls.server_initial['adminPass']
- cls.client.wait_for_server_status(cls.server_initial['id'], 'ACTIVE')
cls.server = cls.client.get_server(cls.server_initial['id'])
@test.attr(type='smoke')
diff --git a/tempest/api/network/admin/test_l3_agent_scheduler.py b/tempest/api/network/admin/test_l3_agent_scheduler.py
index 2ff8897..38d68c2 100644
--- a/tempest/api/network/admin/test_l3_agent_scheduler.py
+++ b/tempest/api/network/admin/test_l3_agent_scheduler.py
@@ -27,6 +27,7 @@
class L3AgentSchedulerTestJSON(base.BaseAdminNetworkTest):
_agent_mode = 'legacy'
+ is_dvr_router = False
"""
Tests the following operations in the Neutron API using the REST client for
diff --git a/tempest/api/object_storage/test_object_expiry.py b/tempest/api/object_storage/test_object_expiry.py
index fec6873..b263050 100644
--- a/tempest/api/object_storage/test_object_expiry.py
+++ b/tempest/api/object_storage/test_object_expiry.py
@@ -56,18 +56,33 @@
# we want to ensure that we will sleep long enough for things to
# actually expire, so figure out how many secs in the future that is.
sleepy_time = int(resp['x-delete-at']) - int(time.time())
-
+ sleepy_time = sleepy_time if sleepy_time > 0 else 0
resp, body = self.object_client.get_object(self.container_name,
self.object_name)
self.assertHeaders(resp, 'Object', 'GET')
self.assertIn('x-delete-at', resp)
- # add a couple of seconds for safety.
- time.sleep(sleepy_time + 3)
+ # add several seconds for safety.
+ time.sleep(sleepy_time)
+
+ # Checking whether object still exists for several seconds:
+ # sometimes object is not deleted immediately, so we are making
+ # get calls for an approximately 1 minute in a total. Get calls
+ # can take 3s each sometimes so we are making the requests in
+ # exponential periodicity
+ for i in range(1, 6):
+ time.sleep(2 ** i)
+ try:
+ self.object_client.get_object(self.container_name,
+ self.object_name)
+ except lib_exc.NotFound:
+ break
# object should not be there anymore
- self.assertRaises(lib_exc.NotFound, self.object_client.get_object,
- self.container_name, self.object_name)
+ self.assertRaises(lib_exc.NotFound,
+ self.object_client.get_object,
+ self.container_name,
+ self.object_name)
@test.idempotent_id('fb024a42-37f3-4ba5-9684-4f40a7910b41')
def test_get_object_after_expiry_time(self):
diff --git a/tempest/api_schema/response/compute/v2_1/agents.py b/tempest/api_schema/response/compute/v2_1/agents.py
index 84c5fd3..da38198 100644
--- a/tempest/api_schema/response/compute/v2_1/agents.py
+++ b/tempest/api_schema/response/compute/v2_1/agents.py
@@ -23,6 +23,7 @@
'url': {'type': 'string', 'format': 'uri'},
'md5hash': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['agent_id', 'hypervisor', 'os', 'architecture',
'version', 'url', 'md5hash']
}
@@ -37,6 +38,7 @@
'items': common_agent_info
}
},
+ 'additionalProperties': False,
'required': ['agents']
}
}
@@ -48,6 +50,7 @@
'properties': {
'agent': common_agent_info
},
+ 'additionalProperties': False,
'required': ['agent']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/aggregates.py b/tempest/api_schema/response/compute/v2_1/aggregates.py
index c935592..1a9fe41 100644
--- a/tempest/api_schema/response/compute/v2_1/aggregates.py
+++ b/tempest/api_schema/response/compute/v2_1/aggregates.py
@@ -26,6 +26,7 @@
'name': {'type': 'string'},
'updated_at': {'type': ['string', 'null']}
},
+ 'additionalProperties': False,
'required': ['availability_zone', 'created_at', 'deleted',
'deleted_at', 'id', 'name', 'updated_at'],
}
@@ -47,6 +48,7 @@
'items': common_aggregate_info
}
},
+ 'additionalProperties': False,
'required': ['aggregates'],
}
}
@@ -58,6 +60,7 @@
'properties': {
'aggregate': common_aggregate_info
},
+ 'additionalProperties': False,
'required': ['aggregate'],
}
}
@@ -81,6 +84,7 @@
'properties': {
'aggregate': aggregate_for_create
},
+ 'additionalProperties': False,
'required': ['aggregate'],
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/availability_zone.py b/tempest/api_schema/response/compute/v2_1/availability_zone.py
index 5c1224e..d9aebce 100644
--- a/tempest/api_schema/response/compute/v2_1/availability_zone.py
+++ b/tempest/api_schema/response/compute/v2_1/availability_zone.py
@@ -31,16 +31,19 @@
'properties': {
'available': {'type': 'boolean'}
},
+ 'additionalProperties': False,
'required': ['available']
},
# NOTE: Here is the difference between detail and
# non-detail.
'hosts': {'type': 'null'}
},
+ 'additionalProperties': False,
'required': ['zoneName', 'zoneState', 'hosts']
}
}
},
+ 'additionalProperties': False,
'required': ['availabilityZoneInfo']
}
}
@@ -60,6 +63,7 @@
'active': {'type': 'boolean'},
'updated_at': {'type': ['string', 'null']}
},
+ 'additionalProperties': False,
'required': ['available', 'active', 'updated_at']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/baremetal_nodes.py b/tempest/api_schema/response/compute/v2_1/baremetal_nodes.py
index 82506e7..d1ee877 100644
--- a/tempest/api_schema/response/compute/v2_1/baremetal_nodes.py
+++ b/tempest/api_schema/response/compute/v2_1/baremetal_nodes.py
@@ -25,6 +25,7 @@
'memory_mb': {'type': ['integer', 'string']},
'disk_gb': {'type': ['integer', 'string']},
},
+ 'additionalProperties': False,
'required': ['id', 'interfaces', 'host', 'task_state', 'cpus', 'memory_mb',
'disk_gb']
}
@@ -39,6 +40,7 @@
'items': node
}
},
+ 'additionalProperties': False,
'required': ['nodes']
}
}
@@ -50,6 +52,7 @@
'properties': {
'node': node
},
+ 'additionalProperties': False,
'required': ['node']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/certificates.py b/tempest/api_schema/response/compute/v2_1/certificates.py
index 35445d8..4e7cbe4 100644
--- a/tempest/api_schema/response/compute/v2_1/certificates.py
+++ b/tempest/api_schema/response/compute/v2_1/certificates.py
@@ -25,9 +25,11 @@
'data': {'type': 'string'},
'private_key': {'type': 'string'},
},
+ 'additionalProperties': False,
'required': ['data', 'private_key']
}
},
+ 'additionalProperties': False,
'required': ['certificate']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/extensions.py b/tempest/api_schema/response/compute/v2_1/extensions.py
index 570cd03..a6a455c 100644
--- a/tempest/api_schema/response/compute/v2_1/extensions.py
+++ b/tempest/api_schema/response/compute/v2_1/extensions.py
@@ -35,11 +35,13 @@
'alias': {'type': 'string'},
'description': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['updated', 'name', 'links', 'namespace',
'alias', 'description']
}
}
},
+ 'additionalProperties': False,
'required': ['extensions']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/fixed_ips.py b/tempest/api_schema/response/compute/v2_1/fixed_ips.py
index 13e70bf..6d5ba67 100644
--- a/tempest/api_schema/response/compute/v2_1/fixed_ips.py
+++ b/tempest/api_schema/response/compute/v2_1/fixed_ips.py
@@ -28,9 +28,11 @@
'host': {'type': 'string'},
'hostname': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['address', 'cidr', 'host', 'hostname']
}
},
+ 'additionalProperties': False,
'required': ['fixed_ip']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/flavors.py b/tempest/api_schema/response/compute/v2_1/flavors.py
index 26760ac..5f5b2e3 100644
--- a/tempest/api_schema/response/compute/v2_1/flavors.py
+++ b/tempest/api_schema/response/compute/v2_1/flavors.py
@@ -28,11 +28,13 @@
'links': parameter_types.links,
'id': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['name', 'links', 'id']
}
},
'flavors_links': parameter_types.links
},
+ 'additionalProperties': False,
# NOTE(gmann): flavors_links attribute is not necessary
# to be present always So it is not 'required'.
'required': ['flavors']
@@ -56,6 +58,7 @@
'rxtx_factor': {'type': 'number'},
'OS-FLV-EXT-DATA:ephemeral': {'type': 'integer'}
},
+ 'additionalProperties': False,
# 'OS-FLV-DISABLED', 'os-flavor-access', 'rxtx_factor' and
# 'OS-FLV-EXT-DATA' are API extensions. So they are not 'required'.
'required': ['name', 'links', 'ram', 'vcpus', 'swap', 'disk', 'id']
@@ -74,6 +77,7 @@
# to be present always So it is not 'required'.
'flavors_links': parameter_types.links
},
+ 'additionalProperties': False,
'required': ['flavors']
}
}
@@ -89,6 +93,7 @@
'properties': {
'flavor': common_flavor_info
},
+ 'additionalProperties': False,
'required': ['flavor']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/flavors_access.py b/tempest/api_schema/response/compute/v2_1/flavors_access.py
index cd31b0a..a4d6af0 100644
--- a/tempest/api_schema/response/compute/v2_1/flavors_access.py
+++ b/tempest/api_schema/response/compute/v2_1/flavors_access.py
@@ -25,10 +25,12 @@
'flavor_id': {'type': 'string'},
'tenant_id': {'type': 'string'},
},
+ 'additionalProperties': False,
'required': ['flavor_id', 'tenant_id'],
}
}
},
+ 'additionalProperties': False,
'required': ['flavor_access']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/flavors_extra_specs.py b/tempest/api_schema/response/compute/v2_1/flavors_extra_specs.py
index faa25d0..a438d48 100644
--- a/tempest/api_schema/response/compute/v2_1/flavors_extra_specs.py
+++ b/tempest/api_schema/response/compute/v2_1/flavors_extra_specs.py
@@ -24,6 +24,7 @@
}
}
},
+ 'additionalProperties': False,
'required': ['extra_specs']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/floating_ips.py b/tempest/api_schema/response/compute/v2_1/floating_ips.py
index ad1c531..28dd40a 100644
--- a/tempest/api_schema/response/compute/v2_1/floating_ips.py
+++ b/tempest/api_schema/response/compute/v2_1/floating_ips.py
@@ -30,6 +30,7 @@
'format': 'ip-address'
}
},
+ 'additionalProperties': False,
'required': ['id', 'pool', 'instance_id',
'ip', 'fixed_ip'],
@@ -44,6 +45,7 @@
'items': common_floating_ip_info
},
},
+ 'additionalProperties': False,
'required': ['floating_ips'],
}
}
@@ -55,6 +57,7 @@
'properties': {
'floating_ip': common_floating_ip_info
},
+ 'additionalProperties': False,
'required': ['floating_ip'],
}
}
@@ -71,10 +74,12 @@
'properties': {
'name': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['name'],
}
}
},
+ 'additionalProperties': False,
'required': ['floating_ip_pools'],
}
}
@@ -95,9 +100,11 @@
'ip_range': {'type': 'string'},
'pool': {'type': ['string', 'null']},
},
+ 'additionalProperties': False,
'required': ['interface', 'ip_range', 'pool'],
}
},
+ 'additionalProperties': False,
'required': ['floating_ips_bulk_create'],
}
}
@@ -109,6 +116,7 @@
'properties': {
'floating_ips_bulk_delete': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['floating_ips_bulk_delete'],
}
}
@@ -136,6 +144,7 @@
'format': 'ip-address'
}
},
+ 'additionalProperties': False,
# NOTE: fixed_ip is introduced after JUNO release,
# So it is not defined as 'required'.
'required': ['address', 'instance_uuid', 'interface',
@@ -143,6 +152,7 @@
}
}
},
+ 'additionalProperties': False,
'required': ['floating_ip_info'],
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/hosts.py b/tempest/api_schema/response/compute/v2_1/hosts.py
index 72d5a07..ae70ff1 100644
--- a/tempest/api_schema/response/compute/v2_1/hosts.py
+++ b/tempest/api_schema/response/compute/v2_1/hosts.py
@@ -29,10 +29,12 @@
'service': {'type': 'string'},
'zone': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['host_name', 'service', 'zone']
}
}
},
+ 'additionalProperties': False,
'required': ['hosts']
}
}
@@ -56,14 +58,17 @@
'memory_mb': {'type': 'integer'},
'project': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['cpu', 'disk_gb', 'host',
'memory_mb', 'project']
}
},
+ 'additionalProperties': False,
'required': ['resource']
}
}
},
+ 'additionalProperties': False,
'required': ['host']
}
}
@@ -76,6 +81,7 @@
'host': {'type': 'string'},
'power_action': {'enum': ['startup']}
},
+ 'additionalProperties': False,
'required': ['host', 'power_action']
}
}
@@ -104,6 +110,7 @@
'off_maintenance']},
'status': {'enum': ['enabled', 'disabled']}
},
+ 'additionalProperties': False,
'required': ['host', 'maintenance_mode', 'status']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/hypervisors.py b/tempest/api_schema/response/compute/v2_1/hypervisors.py
index 3efa46b..e24389d 100644
--- a/tempest/api_schema/response/compute/v2_1/hypervisors.py
+++ b/tempest/api_schema/response/compute/v2_1/hypervisors.py
@@ -35,6 +35,7 @@
'vcpus': {'type': 'integer'},
'vcpus_used': {'type': 'integer'}
},
+ 'additionalProperties': False,
'required': ['count', 'current_workload',
'disk_available_least', 'free_disk_gb',
'free_ram_mb', 'local_gb', 'local_gb_used',
@@ -42,6 +43,7 @@
'vcpus', 'vcpus_used']
}
},
+ 'additionalProperties': False,
'required': ['hypervisor_statistics']
}
}
@@ -77,11 +79,13 @@
'id': {'type': ['integer', 'string']},
'disabled_reason': {'type': ['string', 'null']}
},
+ 'additionalProperties': False,
'required': ['host', 'id']
},
'vcpus': {'type': 'integer'},
'vcpus_used': {'type': 'integer'}
},
+ 'additionalProperties': False,
# NOTE: When loading os-hypervisor-status extension,
# a response contains status and state. So these params
# should not be required.
@@ -104,6 +108,7 @@
'items': hypervisor_detail
}
},
+ 'additionalProperties': False,
'required': ['hypervisors']
}
}
@@ -115,6 +120,7 @@
'properties': {
'hypervisor': hypervisor_detail
},
+ 'additionalProperties': False,
'required': ['hypervisor']
}
}
@@ -134,6 +140,7 @@
'id': {'type': ['integer', 'string']},
'hypervisor_hostname': {'type': 'string'}
},
+ 'additionalProperties': False,
# NOTE: When loading os-hypervisor-status extension,
# a response contains status and state. So these params
# should not be required.
@@ -141,6 +148,7 @@
}
}
},
+ 'additionalProperties': False,
'required': ['hypervisors']
}
}
@@ -159,12 +167,14 @@
'hypervisor_hostname': {'type': 'string'},
'uptime': {'type': 'string'}
},
+ 'additionalProperties': False,
# NOTE: When loading os-hypervisor-status extension,
# a response contains status and state. So these params
# should not be required.
'required': ['id', 'hypervisor_hostname', 'uptime']
}
},
+ 'additionalProperties': False,
'required': ['hypervisor']
}
}
@@ -178,7 +188,8 @@
'properties': {
'uuid': {'type': 'string'},
'name': {'type': 'string'}
- }
+ },
+ 'additionalProperties': False,
}
}
# In V2 API, if there is no servers (VM) on the Hypervisor host then 'servers'
diff --git a/tempest/api_schema/response/compute/v2_1/images.py b/tempest/api_schema/response/compute/v2_1/images.py
index e6f8db6..a513dcb 100644
--- a/tempest/api_schema/response/compute/v2_1/images.py
+++ b/tempest/api_schema/response/compute/v2_1/images.py
@@ -38,11 +38,13 @@
'id': {'type': 'string'},
'links': parameter_types.links
},
+ 'additionalProperties': False,
'required': ['id', 'links']
},
'OS-EXT-IMG-SIZE:size': {'type': 'integer'},
'OS-DCF:diskConfig': {'type': 'string'}
},
+ 'additionalProperties': False,
# 'server' attributes only comes in response body if image is
# associated with any server. 'OS-EXT-IMG-SIZE:size' & 'OS-DCF:diskConfig'
# are API extension, So those are not defined as 'required'.
@@ -58,6 +60,7 @@
'properties': {
'image': common_image_schema
},
+ 'additionalProperties': False,
'required': ['image']
}
}
@@ -76,11 +79,13 @@
'links': image_links,
'name': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['id', 'links', 'name']
}
},
'images_links': parameter_types.links
},
+ 'additionalProperties': False,
# NOTE(gmann): images_links attribute is not necessary to be
# present always So it is not 'required'.
'required': ['images']
@@ -113,6 +118,7 @@
'properties': {
'metadata': {'type': 'object'}
},
+ 'additionalProperties': False,
'required': ['metadata']
}
}
@@ -124,6 +130,7 @@
'properties': {
'meta': {'type': 'object'}
},
+ 'additionalProperties': False,
'required': ['meta']
}
}
@@ -139,6 +146,7 @@
},
'images_links': parameter_types.links
},
+ 'additionalProperties': False,
# NOTE(gmann): images_links attribute is not necessary to be
# present always So it is not 'required'.
'required': ['images']
diff --git a/tempest/api_schema/response/compute/v2_1/instance_usage_audit_logs.py b/tempest/api_schema/response/compute/v2_1/instance_usage_audit_logs.py
index 658f574..c6c4deb 100644
--- a/tempest/api_schema/response/compute/v2_1/instance_usage_audit_logs.py
+++ b/tempest/api_schema/response/compute/v2_1/instance_usage_audit_logs.py
@@ -30,6 +30,7 @@
'total_errors': {'type': 'integer'},
'total_instances': {'type': 'integer'}
},
+ 'additionalProperties': False,
'required': ['hosts_not_run', 'log', 'num_hosts', 'num_hosts_done',
'num_hosts_not_run', 'num_hosts_running', 'overall_status',
'period_beginning', 'period_ending', 'total_errors',
@@ -43,6 +44,7 @@
'properties': {
'instance_usage_audit_log': common_instance_usage_audit_log
},
+ 'additionalProperties': False,
'required': ['instance_usage_audit_log']
}
}
@@ -54,6 +56,7 @@
'properties': {
'instance_usage_audit_logs': common_instance_usage_audit_log
},
+ 'additionalProperties': False,
'required': ['instance_usage_audit_logs']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/interfaces.py b/tempest/api_schema/response/compute/v2_1/interfaces.py
index 033f816..b18fba6 100644
--- a/tempest/api_schema/response/compute/v2_1/interfaces.py
+++ b/tempest/api_schema/response/compute/v2_1/interfaces.py
@@ -32,6 +32,7 @@
'format': 'ipv4'
}
},
+ 'additionalProperties': False,
'required': ['subnet_id', 'ip_address']
}
},
@@ -39,6 +40,7 @@
'net_id': {'type': 'string', 'format': 'uuid'},
'mac_addr': parameter_types.mac_address
},
+ 'additionalProperties': False,
'required': ['port_state', 'fixed_ips', 'port_id', 'net_id', 'mac_addr']
}
@@ -49,6 +51,7 @@
'properties': {
'interfaceAttachment': interface_common_info
},
+ 'additionalProperties': False,
'required': ['interfaceAttachment']
}
}
@@ -63,6 +66,7 @@
'items': interface_common_info
}
},
+ 'additionalProperties': False,
'required': ['interfaceAttachments']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/keypairs.py b/tempest/api_schema/response/compute/v2_1/keypairs.py
index ceae6cf..9c04c79 100644
--- a/tempest/api_schema/response/compute/v2_1/keypairs.py
+++ b/tempest/api_schema/response/compute/v2_1/keypairs.py
@@ -31,6 +31,7 @@
'id': {'type': 'integer'}
},
+ 'additionalProperties': False,
# When we run the get keypair API, response body includes
# all the above mentioned attributes.
# But in Nova API sample file, response body includes only
@@ -39,6 +40,7 @@
'required': ['public_key', 'name', 'fingerprint']
}
},
+ 'additionalProperties': False,
'required': ['keypair']
}
}
@@ -57,12 +59,14 @@
'user_id': {'type': 'string'},
'private_key': {'type': 'string'}
},
+ 'additionalProperties': False,
# When create keypair API is being called with 'Public key'
# (Importing keypair) then, response body does not contain
# 'private_key' So it is not defined as 'required'
'required': ['fingerprint', 'name', 'public_key', 'user_id']
}
},
+ 'additionalProperties': False,
'required': ['keypair']
}
}
@@ -88,13 +92,16 @@
'name': {'type': 'string'},
'fingerprint': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['public_key', 'name', 'fingerprint']
}
},
+ 'additionalProperties': False,
'required': ['keypair']
}
}
},
+ 'additionalProperties': False,
'required': ['keypairs']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/limits.py b/tempest/api_schema/response/compute/v2_1/limits.py
index a7decb7..81f175f 100644
--- a/tempest/api_schema/response/compute/v2_1/limits.py
+++ b/tempest/api_schema/response/compute/v2_1/limits.py
@@ -43,6 +43,7 @@
'maxServerGroups': {'type': 'integer'},
'totalServerGroupsUsed': {'type': 'integer'}
},
+ 'additionalProperties': False,
# NOTE(gmann): maxServerGroupMembers, maxServerGroups
# and totalServerGroupsUsed are API extension,
# and some environments return a response without these
@@ -84,18 +85,22 @@
{'type': 'integer'},
'verb':
{'type': 'string'}
- }
+ },
+ 'additionalProperties': False,
}
},
'regex': {'type': 'string'},
'uri': {'type': 'string'}
- }
+ },
+ 'additionalProperties': False,
}
}
},
+ 'additionalProperties': False,
'required': ['absolute', 'rate']
}
},
+ 'additionalProperties': False,
'required': ['limits']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/migrations.py b/tempest/api_schema/response/compute/v2_1/migrations.py
index 6549272..722372c 100644
--- a/tempest/api_schema/response/compute/v2_1/migrations.py
+++ b/tempest/api_schema/response/compute/v2_1/migrations.py
@@ -35,6 +35,7 @@
'created_at': {'type': 'string'},
'updated_at': {'type': ['string', 'null']}
},
+ 'additionalProperties': False,
'required': [
'id', 'status', 'instance_uuid', 'source_node',
'source_compute', 'dest_node', 'dest_compute',
@@ -44,6 +45,7 @@
}
}
},
+ 'additionalProperties': False,
'required': ['migrations']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/parameter_types.py b/tempest/api_schema/response/compute/v2_1/parameter_types.py
index 90d4c8f..7b4264c 100644
--- a/tempest/api_schema/response/compute/v2_1/parameter_types.py
+++ b/tempest/api_schema/response/compute/v2_1/parameter_types.py
@@ -23,6 +23,7 @@
},
'rel': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['href', 'rel']
}
}
@@ -60,6 +61,7 @@
]
}
},
+ 'additionalProperties': False,
'required': ['version', 'addr']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/quotas.py b/tempest/api_schema/response/compute/v2_1/quotas.py
index 9141f7e..7953983 100644
--- a/tempest/api_schema/response/compute/v2_1/quotas.py
+++ b/tempest/api_schema/response/compute/v2_1/quotas.py
@@ -37,6 +37,7 @@
'injected_file_content_bytes': {'type': 'integer'},
'injected_file_path_bytes': {'type': 'integer'}
},
+ 'additionalProperties': False,
# NOTE: server_group_members and server_groups are represented
# when enabling quota_server_group extension. So they should
# not be required.
@@ -48,6 +49,7 @@
'injected_file_path_bytes']
}
},
+ 'additionalProperties': False,
'required': ['quota_set']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/security_group_default_rule.py b/tempest/api_schema/response/compute/v2_1/security_group_default_rule.py
index 9246ab8..2ec2826 100644
--- a/tempest/api_schema/response/compute/v2_1/security_group_default_rule.py
+++ b/tempest/api_schema/response/compute/v2_1/security_group_default_rule.py
@@ -23,10 +23,12 @@
'properties': {
'cidr': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['cidr'],
},
'to_port': {'type': 'integer'},
},
+ 'additionalProperties': False,
'required': ['from_port', 'id', 'ip_protocol', 'ip_range', 'to_port'],
}
@@ -38,6 +40,7 @@
'security_group_default_rule':
common_security_group_default_rule_info
},
+ 'additionalProperties': False,
'required': ['security_group_default_rule']
}
}
@@ -56,6 +59,7 @@
'items': common_security_group_default_rule_info
}
},
+ 'additionalProperties': False,
'required': ['security_group_default_rules']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/security_groups.py b/tempest/api_schema/response/compute/v2_1/security_groups.py
index 9a852e5..5ed5a5c 100644
--- a/tempest/api_schema/response/compute/v2_1/security_groups.py
+++ b/tempest/api_schema/response/compute/v2_1/security_groups.py
@@ -20,7 +20,8 @@
'properties': {
'tenant_id': {'type': 'string'},
'name': {'type': 'string'}
- }
+ },
+ 'additionalProperties': False,
},
'ip_protocol': {'type': ['string', 'null']},
# 'parent_group_id' can be UUID so defining it as 'string' also.
@@ -29,7 +30,8 @@
'type': 'object',
'properties': {
'cidr': {'type': 'string'}
- }
+ },
+ 'additionalProperties': False,
# When optional argument is provided in request body
# like 'group_id' then, attribute 'cidr' does not
# comes in response body. So it is not 'required'.
@@ -47,11 +49,13 @@
'type': 'array',
'items': {
'type': ['object', 'null'],
- 'properties': common_security_group_rule
+ 'properties': common_security_group_rule,
+ 'additionalProperties': False,
}
},
'description': {'type': 'string'},
},
+ 'additionalProperties': False,
'required': ['id', 'name', 'tenant_id', 'rules', 'description'],
}
@@ -65,6 +69,7 @@
'items': common_security_group
}
},
+ 'additionalProperties': False,
'required': ['security_groups']
}
}
@@ -76,6 +81,7 @@
'properties': {
'security_group': common_security_group
},
+ 'additionalProperties': False,
'required': ['security_group']
}
}
@@ -92,10 +98,12 @@
'security_group_rule': {
'type': 'object',
'properties': common_security_group_rule,
+ 'additionalProperties': False,
'required': ['from_port', 'to_port', 'group', 'ip_protocol',
'parent_group_id', 'id', 'ip_range']
}
},
+ 'additionalProperties': False,
'required': ['security_group_rule']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/servers.py b/tempest/api_schema/response/compute/v2_1/servers.py
index 875f607..44ab9e9 100644
--- a/tempest/api_schema/response/compute/v2_1/servers.py
+++ b/tempest/api_schema/response/compute/v2_1/servers.py
@@ -29,12 +29,14 @@
'links': parameter_types.links,
'OS-DCF:diskConfig': {'type': 'string'}
},
+ 'additionalProperties': False,
# NOTE: OS-DCF:diskConfig & security_groups are API extension,
# and some environments return a response without these
# attributes.So they are not 'required'.
'required': ['id', 'links']
}
},
+ 'additionalProperties': False,
'required': ['server']
}
}
@@ -59,11 +61,13 @@
'links': parameter_types.links,
'name': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['id', 'links', 'name']
}
},
'servers_links': parameter_types.links
},
+ 'additionalProperties': False,
# NOTE(gmann): servers_links attribute is not necessary to be
# present always So it is not 'required'.
'required': ['servers']
@@ -86,6 +90,7 @@
'id': {'type': 'string'},
'links': parameter_types.links
},
+ 'additionalProperties': False,
'required': ['id', 'links']},
{'type': ['string', 'null']}
]},
@@ -95,6 +100,7 @@
'id': {'type': 'string'},
'links': parameter_types.links
},
+ 'additionalProperties': False,
'required': ['id', 'links']
},
'fault': {
@@ -105,6 +111,7 @@
'message': {'type': 'string'},
'details': {'type': 'string'},
},
+ 'additionalProperties': False,
# NOTE(gmann): 'details' is not necessary to be present
# in the 'fault'. So it is not defined as 'required'.
'required': ['code', 'created', 'message']
@@ -122,6 +129,7 @@
'accessIPv4': parameter_types.access_ip_v4,
'accessIPv6': parameter_types.access_ip_v6
},
+ 'additionalProperties': False,
# NOTE(GMann): 'progress' attribute is present in the response
# only when server's status is one of the progress statuses
# ("ACTIVE","BUILD", "REBUILD", "RESIZE","VERIFY_RESIZE")
@@ -142,6 +150,7 @@
'properties': {
'server': common_show_server
},
+ 'additionalProperties': False,
'required': ['server']
}
}
@@ -184,6 +193,7 @@
'properties': {
'server': server_detail
},
+ 'additionalProperties': False,
'required': ['server']
}
}
@@ -199,6 +209,7 @@
},
'servers_links': parameter_types.links
},
+ 'additionalProperties': False,
# NOTE(gmann): servers_links attribute is not necessary to be
# present always So it is not 'required'.
'required': ['servers']
@@ -221,6 +232,7 @@
'properties': {
'adminPass': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['adminPass']
}
}
@@ -239,12 +251,14 @@
'mac_address': parameter_types.mac_address,
'OS-EXT-VIF-NET:net_id': {'type': 'string'}
},
+ 'additionalProperties': False,
# 'OS-EXT-VIF-NET:net_id' is API extension So it is
# not defined as 'required'
'required': ['id', 'mac_address']
}
}
},
+ 'additionalProperties': False,
'required': ['virtual_interfaces']
}
}
@@ -257,6 +271,7 @@
'volumeId': {'type': 'string'},
'serverId': {'type': ['integer', 'string']}
},
+ 'additionalProperties': False,
'required': ['id', 'device', 'volumeId', 'serverId']
}
@@ -267,6 +282,7 @@
'properties': {
'volumeAttachment': common_attach_volume_info
},
+ 'additionalProperties': False,
'required': ['volumeAttachment']
}
}
@@ -289,6 +305,7 @@
'items': common_attach_volume_info
}
},
+ 'additionalProperties': False,
'required': ['volumeAttachments']
}
}
@@ -308,6 +325,7 @@
'properties': {
'addresses': parameter_types.addresses
},
+ 'additionalProperties': False,
'required': ['addresses']
}
}
@@ -329,6 +347,7 @@
},
'metadata': {'type': 'object'}
},
+ 'additionalProperties': False,
'required': ['id', 'name', 'policies', 'members', 'metadata']
}
@@ -339,6 +358,7 @@
'properties': {
'server_group': common_server_group
},
+ 'additionalProperties': False,
'required': ['server_group']
}
}
@@ -357,6 +377,7 @@
'items': common_server_group
}
},
+ 'additionalProperties': False,
'required': ['server_groups']
}
}
@@ -372,6 +393,7 @@
'message': {'type': ['string', 'null']},
'instance_uuid': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['action', 'request_id', 'user_id', 'project_id',
'start_time', 'message', 'instance_uuid']
}
@@ -387,6 +409,7 @@
'result': {'type': 'string'},
'traceback': {'type': ['string', 'null']}
},
+ 'additionalProperties': False,
'required': ['event', 'start_time', 'finish_time', 'result',
'traceback']
}
@@ -402,6 +425,7 @@
'items': instance_actions
}
},
+ 'additionalProperties': False,
'required': ['instanceActions']
}
}
@@ -419,6 +443,7 @@
'properties': {
'instanceAction': instance_actions_with_events
},
+ 'additionalProperties': False,
'required': ['instanceAction']
}
}
@@ -430,6 +455,7 @@
'properties': {
'password': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['password']
}
}
@@ -448,9 +474,11 @@
'format': 'uri'
}
},
+ 'additionalProperties': False,
'required': ['type', 'url']
}
},
+ 'additionalProperties': False,
'required': ['console']
}
}
@@ -462,6 +490,7 @@
'properties': {
'output': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['output']
}
}
@@ -478,6 +507,7 @@
}
}
},
+ 'additionalProperties': False,
'required': ['metadata']
}
}
@@ -502,6 +532,7 @@
}
}
},
+ 'additionalProperties': False,
'required': ['meta']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/services.py b/tempest/api_schema/response/compute/v2_1/services.py
index 6f361ef..c2c7a51 100644
--- a/tempest/api_schema/response/compute/v2_1/services.py
+++ b/tempest/api_schema/response/compute/v2_1/services.py
@@ -32,11 +32,13 @@
'updated_at': {'type': ['string', 'null']},
'disabled_reason': {'type': ['string', 'null']}
},
+ 'additionalProperties': False,
'required': ['id', 'zone', 'host', 'state', 'binary',
'status', 'updated_at', 'disabled_reason']
}
}
},
+ 'additionalProperties': False,
'required': ['services']
}
}
@@ -53,9 +55,11 @@
'binary': {'type': 'string'},
'host': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['status', 'binary', 'host']
}
},
+ 'additionalProperties': False,
'required': ['service']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/tenant_networks.py b/tempest/api_schema/response/compute/v2_1/tenant_networks.py
index 0b2868a..ddfab96 100644
--- a/tempest/api_schema/response/compute/v2_1/tenant_networks.py
+++ b/tempest/api_schema/response/compute/v2_1/tenant_networks.py
@@ -19,6 +19,7 @@
'cidr': {'type': ['string', 'null']},
'label': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['id', 'cidr', 'label']
}
@@ -33,6 +34,7 @@
'items': param_network
}
},
+ 'additionalProperties': False,
'required': ['networks']
}
}
@@ -45,6 +47,7 @@
'properties': {
'network': param_network
},
+ 'additionalProperties': False,
'required': ['network']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/volumes.py b/tempest/api_schema/response/compute/v2_1/volumes.py
index 541d3ff..bb34acb 100644
--- a/tempest/api_schema/response/compute/v2_1/volumes.py
+++ b/tempest/api_schema/response/compute/v2_1/volumes.py
@@ -39,7 +39,8 @@
'device': {'type': 'string'},
'volumeId': {'type': 'string'},
'serverId': {'type': 'string'}
- }
+ },
+ 'additionalProperties': False,
# NOTE- If volume is not attached to any server
# then, 'attachments' attributes comes as array
# with empty objects "[{}]" due to that elements
@@ -49,11 +50,13 @@
}
}
},
+ 'additionalProperties': False,
'required': ['id', 'status', 'displayName', 'availabilityZone',
'createdAt', 'displayDescription', 'volumeType',
'snapshotId', 'metadata', 'size', 'attachments']
}
},
+ 'additionalProperties': False,
'required': ['volume']
}
}
@@ -87,7 +90,8 @@
'device': {'type': 'string'},
'volumeId': {'type': 'string'},
'serverId': {'type': 'string'}
- }
+ },
+ 'additionalProperties': False,
# NOTE- If volume is not attached to any server
# then, 'attachments' attributes comes as array
# with empty object "[{}]" due to that elements
@@ -97,6 +101,7 @@
}
}
},
+ 'additionalProperties': False,
'required': ['id', 'status', 'displayName',
'availabilityZone', 'createdAt',
'displayDescription', 'volumeType',
@@ -105,6 +110,7 @@
}
}
},
+ 'additionalProperties': False,
'required': ['volumes']
}
}
diff --git a/tempest/common/compute.py b/tempest/common/compute.py
new file mode 100644
index 0000000..5de4b0e
--- /dev/null
+++ b/tempest/common/compute.py
@@ -0,0 +1,124 @@
+# Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from oslo_log import log as logging
+from oslo_utils import excutils
+from tempest_lib.common.utils import data_utils
+
+from tempest.common import fixed_network
+from tempest import config
+
+CONF = config.CONF
+
+LOG = logging.getLogger(__name__)
+
+
+def create_test_server(clients, validatable, validation_resources=None,
+ tenant_network=None, **kwargs):
+ """Common wrapper utility returning a test server.
+
+ This method is a common wrapper returning a test server that can be
+ pingable or sshable.
+
+ :param clients: Client manager which provides Openstack Tempest clients.
+ :param validatable: Whether the server will be pingable or sshable.
+ :param validation_resources: Resources created for the connection to the
+ server. Include a keypair, a security group and an IP.
+ :returns a tuple
+ """
+
+ # TODO(jlanoux) add support of wait_until PINGABLE/SSHABLE
+
+ if 'name' in kwargs:
+ name = kwargs.pop('name')
+ else:
+ name = data_utils.rand_name(__name__ + "-instance")
+
+ flavor = kwargs.get('flavor', CONF.compute.flavor_ref)
+ image_id = kwargs.get('image_id', CONF.compute.image_ref)
+
+ kwargs = fixed_network.set_networks_kwarg(
+ tenant_network, kwargs) or {}
+
+ if CONF.validation.run_validation and validatable:
+ # As a first implementation, multiple pingable or sshable servers will
+ # not be supported
+ if 'min_count' in kwargs or 'max_count' in kwargs:
+ msg = ("Multiple pingable or sshable servers not supported at "
+ "this stage.")
+ raise ValueError(msg)
+
+ if 'security_groups' in kwargs:
+ kwargs['security_groups'].append(
+ {'name': validation_resources['security_group']['name']})
+ else:
+ try:
+ kwargs['security_groups'] = [
+ {'name': validation_resources['security_group']['name']}]
+ except KeyError:
+ LOG.debug("No security group provided.")
+
+ if 'key_name' not in kwargs:
+ try:
+ kwargs['key_name'] = validation_resources['keypair']['name']
+ except KeyError:
+ LOG.debug("No key provided.")
+
+ if CONF.validation.connect_method == 'floating':
+ if 'wait_until' not in kwargs:
+ kwargs['wait_until'] = 'ACTIVE'
+
+ body = clients.servers_client.create_server(name, image_id, flavor,
+ **kwargs)
+
+ # handle the case of multiple servers
+ servers = [body]
+ if 'min_count' in kwargs or 'max_count' in kwargs:
+ # Get servers created which name match with name param.
+ body_servers = clients.servers_client.list_servers()
+ servers = \
+ [s for s in body_servers['servers'] if s['name'].startswith(name)]
+
+ # The name of the method to associate a floating IP to as server is too
+ # long for PEP8 compliance so:
+ assoc = clients.floating_ips_client.associate_floating_ip_to_server
+
+ if 'wait_until' in kwargs:
+ for server in servers:
+ try:
+ clients.servers_client.wait_for_server_status(
+ server['id'], kwargs['wait_until'])
+
+ # Multiple validatable servers are not supported for now. Their
+ # creation will fail with the condition above (l.58).
+ if CONF.validation.run_validation and validatable:
+ if CONF.validation.connect_method == 'floating':
+ assoc(floating_ip=validation_resources[
+ 'floating_ip']['ip'],
+ server_id=servers[0]['id'])
+
+ except Exception:
+ with excutils.save_and_reraise_exception():
+ if ('preserve_server_on_error' not in kwargs
+ or kwargs['preserve_server_on_error'] is False):
+ for server in servers:
+ try:
+ clients.servers_client.delete_server(
+ server['id'])
+ except Exception:
+ LOG.exception('Deleting server %s failed'
+ % server['id'])
+
+ return body, servers