Merge "Enable XML testing for test_server_addresses"
diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample
index a70a7ab..02bfdcb 100644
--- a/etc/tempest.conf.sample
+++ b/etc/tempest.conf.sample
@@ -193,6 +193,9 @@
# for each tenant to have their own router.
public_router_id = {$PUBLIC_ROUTER_ID}
+# Whether or not quantum is expected to be available
+quantum_available = false
+
[volume]
# This section contains the configuration options used when executing tests
# against the OpenStack Block Storage API service
diff --git a/tempest/clients.py b/tempest/clients.py
index f2e89a7..16f73d3 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -69,6 +69,10 @@
VolumeTypesClientXML
from tempest.services.volume.xml.snapshots_client import SnapshotsClientXML
from tempest.services.volume.xml.volumes_client import VolumesClientXML
+from tempest.services.compute.json.interfaces_client import \
+ InterfacesClientJSON
+from tempest.services.compute.xml.interfaces_client import \
+ InterfacesClientXML
LOG = logging.getLogger(__name__)
@@ -147,6 +151,11 @@
"xml": SecurityGroupsClientXML,
}
+INTERFACES_CLIENT = {
+ "json": InterfacesClientJSON,
+ "xml": InterfacesClientXML,
+}
+
class Manager(object):
@@ -208,6 +217,7 @@
self.token_client = TOKEN_CLIENT[interface](self.config)
self.security_groups_client = \
SECURITY_GROUPS_CLIENT[interface](*client_args)
+ self.interfaces_client = INTERFACES_CLIENT[interface](*client_args)
except KeyError:
msg = "Unsupported interface type `%s'" % interface
raise exceptions.InvalidConfiguration(msg)
diff --git a/tempest/common/rest_client.py b/tempest/common/rest_client.py
index c582826..5ce3be6 100644
--- a/tempest/common/rest_client.py
+++ b/tempest/common/rest_client.py
@@ -177,8 +177,8 @@
def post(self, url, body, headers):
return self.request('POST', url, headers, body)
- def get(self, url, headers=None, wait=None):
- return self.request('GET', url, headers, wait=wait)
+ def get(self, url, headers=None):
+ return self.request('GET', url, headers)
def delete(self, url, headers=None):
return self.request('DELETE', url, headers)
@@ -257,7 +257,7 @@
self.LOG.warning("status >= 400 response with empty body")
def request(self, method, url,
- headers=None, body=None, depth=0, wait=None):
+ headers=None, body=None, depth=0):
"""A simple HTTP request interface."""
if (self.token is None) or (self.base_url is None):
@@ -276,13 +276,12 @@
self._log_response(resp, resp_body)
self.response_checker(method, url, headers, body, resp, resp_body)
- self._error_checker(method, url, headers, body, resp, resp_body, depth,
- wait)
+ self._error_checker(method, url, headers, body, resp, resp_body, depth)
return resp, resp_body
def _error_checker(self, method, url,
- headers, body, resp, resp_body, depth=0, wait=None):
+ headers, body, resp, resp_body, depth=0):
# NOTE(mtreinish): Check for httplib response from glance_http. The
# object can't be used here because importing httplib breaks httplib2.
@@ -336,7 +335,7 @@
resp_body = self._parse_resp(resp_body)
#Checking whether Absolute/Rate limit
return self.check_over_limit(resp_body, method, url, headers, body,
- depth, wait)
+ depth)
if resp.status == 422:
if parse_resp:
@@ -367,11 +366,11 @@
raise exceptions.RestClientException(str(resp.status))
def check_over_limit(self, resp_body, method, url,
- headers, body, depth, wait):
+ headers, body, depth):
self.is_absolute_limit(resp_body['overLimit'])
return self.is_rate_limit_retry_max_recursion_depth(
resp_body['overLimit'], method, url, headers,
- body, depth, wait)
+ body, depth)
def is_absolute_limit(self, resp_body):
if 'exceeded' in resp_body['message']:
@@ -380,15 +379,14 @@
return
def is_rate_limit_retry_max_recursion_depth(self, resp_body, method,
- url, headers, body, depth,
- wait):
+ url, headers, body, depth):
if 'retryAfter' in resp_body:
if depth < MAX_RECURSION_DEPTH:
delay = resp_body['retryAfter']
time.sleep(int(delay))
return self.request(method, url, headers=headers,
body=body,
- depth=depth + 1, wait=wait)
+ depth=depth + 1)
else:
raise exceptions.RateLimitExceeded(
message=resp_body['overLimitFault']['message'],
@@ -422,8 +420,8 @@
return xml_to_json(etree.fromstring(body))
def check_over_limit(self, resp_body, method, url,
- headers, body, depth, wait):
+ headers, body, depth):
self.is_absolute_limit(resp_body)
return self.is_rate_limit_retry_max_recursion_depth(
resp_body, method, url, headers,
- body, depth, wait)
+ body, depth)
diff --git a/tempest/config.py b/tempest/config.py
index 856be16..2f4ce6a 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -280,6 +280,9 @@
default="",
help="Id of the public router that provides external "
"connectivity"),
+ cfg.BoolOpt('quantum_available',
+ default=False,
+ help="Whether or not quantum is expected to be available"),
]
diff --git a/tempest/services/compute/json/interfaces_client.py b/tempest/services/compute/json/interfaces_client.py
new file mode 100644
index 0000000..468a5c2
--- /dev/null
+++ b/tempest/services/compute/json/interfaces_client.py
@@ -0,0 +1,57 @@
+# Copyright 2013 IBM Corp.
+# 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.
+
+import json
+
+from tempest.common.rest_client import RestClient
+
+
+class InterfacesClientJSON(RestClient):
+
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ super(InterfacesClientJSON, self).__init__(config, username, password,
+ auth_url, tenant_name)
+ self.service = self.config.compute.catalog_type
+
+ def list_interfaces(self, server):
+ resp, body = self.get('servers/%s/os-interface' % server)
+ body = json.loads(body)
+ return resp, body['interfaceAttachments']
+
+ def create_interface(self, server, port_id=None, network_id=None,
+ fixed_ip=None):
+ post_body = dict(interfaceAttachment=dict())
+ if port_id:
+ post_body['port_id'] = port_id
+ if network_id:
+ post_body['net_id'] = network_id
+ if fixed_ip:
+ post_body['fixed_ips'] = [dict(ip_address=fixed_ip)]
+ post_body = json.dumps(post_body)
+ resp, body = self.post('servers/%s/os-interface' % server,
+ headers=self.headers,
+ body=post_body)
+ body = json.loads(body)
+ return resp, body['interfaceAttachment']
+
+ def show_interface(self, server, port_id):
+ resp, body = self.get('servers/%s/os-interface/%s' % (server, port_id))
+ body = json.loads(body)
+ return resp, body['interfaceAttachment']
+
+ def delete_interface(self, server, port_id):
+ resp, body = self.delete('servers/%s/os-interface/%s' % (server,
+ port_id))
+ return resp, body
diff --git a/tempest/services/compute/json/volumes_extensions_client.py b/tempest/services/compute/json/volumes_extensions_client.py
index e4271d9..d12b97b 100644
--- a/tempest/services/compute/json/volumes_extensions_client.py
+++ b/tempest/services/compute/json/volumes_extensions_client.py
@@ -53,10 +53,10 @@
body = json.loads(body)
return resp, body['volumes']
- def get_volume(self, volume_id, wait=None):
+ def get_volume(self, volume_id):
"""Returns the details of a single volume."""
url = "os-volumes/%s" % str(volume_id)
- resp, body = self.get(url, wait=wait)
+ resp, body = self.get(url)
body = json.loads(body)
return resp, body['volume']
diff --git a/tempest/services/compute/xml/interfaces_client.py b/tempest/services/compute/xml/interfaces_client.py
new file mode 100644
index 0000000..4a692a1
--- /dev/null
+++ b/tempest/services/compute/xml/interfaces_client.py
@@ -0,0 +1,82 @@
+# Copyright 2013 IBM Corp.
+# 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 lxml import etree
+
+from tempest.common.rest_client import RestClientXML
+from tempest.services.compute.xml.common import Document
+from tempest.services.compute.xml.common import Element
+from tempest.services.compute.xml.common import Text
+from tempest.services.compute.xml.common import xml_to_json
+
+
+class InterfacesClientXML(RestClientXML):
+
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ super(InterfacesClientXML, self).__init__(config, username, password,
+ auth_url, tenant_name)
+ self.service = self.config.compute.catalog_type
+
+ def _process_xml_interface(self, node):
+ iface = xml_to_json(node)
+ # NOTE(danms): if multiple addresses per interface is ever required,
+ # xml_to_json will need to be fixed or replaced in this case
+ iface['fixed_ips'] = [dict(iface['fixed_ips']['fixed_ip'].items())]
+ return iface
+
+ def list_interfaces(self, server):
+ resp, body = self.get('servers/%s/os-interface' % server, self.headers)
+ node = etree.fromstring(body)
+ interfaces = [self._process_xml_interface(x)
+ for x in node.getchildren()]
+ return resp, interfaces
+
+ def create_interface(self, server, port_id=None, network_id=None,
+ fixed_ip=None):
+ doc = Document()
+ iface = Element('interfaceAttachment')
+ if port_id:
+ _port_id = Element('port_id')
+ _port_id.append(Text(port_id))
+ iface.append(_port_id)
+ if network_id:
+ _network_id = Element('net_id')
+ _network_id.append(Text(network_id))
+ iface.append(_network_id)
+ if fixed_ip:
+ _fixed_ips = Element('fixed_ips')
+ _fixed_ip = Element('fixed_ip')
+ _ip_address = Element('ip_address')
+ _ip_address.append(Text(fixed_ip))
+ _fixed_ip.append(_ip_address)
+ _fixed_ips.append(_fixed_ip)
+ iface.append(_fixed_ips)
+ doc.append(iface)
+ resp, body = self.post('servers/%s/os-interface' % server,
+ headers=self.headers,
+ body=str(doc))
+ body = self._process_xml_interface(etree.fromstring(body))
+ return resp, body
+
+ def show_interface(self, server, port_id):
+ resp, body = self.get('servers/%s/os-interface/%s' % (server, port_id),
+ self.headers)
+ body = self._process_xml_interface(etree.fromstring(body))
+ return resp, body
+
+ def delete_interface(self, server, port_id):
+ resp, body = self.delete('servers/%s/os-interface/%s' % (server,
+ port_id))
+ return resp, body
diff --git a/tempest/services/compute/xml/servers_client.py b/tempest/services/compute/xml/servers_client.py
index 955d97e..5f33e8b 100644
--- a/tempest/services/compute/xml/servers_client.py
+++ b/tempest/services/compute/xml/servers_client.py
@@ -182,13 +182,13 @@
server = Element("server")
doc.append(server)
- if name:
+ if name is not None:
server.add_attr("name", name)
- if accessIPv4:
+ if accessIPv4 is not None:
server.add_attr("accessIPv4", accessIPv4)
- if accessIPv6:
+ if accessIPv6 is not None:
server.add_attr("accessIPv6", accessIPv6)
- if meta:
+ if meta is not None:
metadata = Element("metadata")
server.append(metadata)
for k, v in meta:
@@ -228,10 +228,26 @@
flavorRef=flavor_ref,
name=name)
- for attr in ["adminPass", "accessIPv4", "accessIPv6", "key_name"]:
+ for attr in ["adminPass", "accessIPv4", "accessIPv6", "key_name",
+ "user_data", "availability_zone"]:
if attr in kwargs:
server.add_attr(attr, kwargs[attr])
+ if 'security_groups' in kwargs:
+ secgroups = Element("security_groups")
+ server.append(secgroups)
+ for secgroup in kwargs['security_groups']:
+ s = Element("security_group", name=secgroup['name'])
+ secgroups.append(s)
+
+ if 'networks' in kwargs:
+ networks = Element("networks")
+ server.append(networks)
+ for network in kwargs['networks']:
+ s = Element("network", uuid=network['uuid'],
+ fixed_ip=network['fixed_ip'])
+ networks.append(s)
+
if 'meta' in kwargs:
metadata = Element("metadata")
server.append(metadata)
diff --git a/tempest/services/compute/xml/volumes_extensions_client.py b/tempest/services/compute/xml/volumes_extensions_client.py
index 69b9bac..06cfcfb 100644
--- a/tempest/services/compute/xml/volumes_extensions_client.py
+++ b/tempest/services/compute/xml/volumes_extensions_client.py
@@ -81,10 +81,10 @@
volumes += [self._parse_volume(vol) for vol in list(body)]
return resp, volumes
- def get_volume(self, volume_id, wait=None):
+ def get_volume(self, volume_id):
"""Returns the details of a single volume."""
url = "os-volumes/%s" % str(volume_id)
- resp, body = self.get(url, self.headers, wait=wait)
+ resp, body = self.get(url, self.headers)
body = etree.fromstring(body)
return resp, self._parse_volume(body)
diff --git a/tempest/services/image/v1/json/image_client.py b/tempest/services/image/v1/json/image_client.py
index 277075e..cd2b57c 100644
--- a/tempest/services/image/v1/json/image_client.py
+++ b/tempest/services/image/v1/json/image_client.py
@@ -191,15 +191,15 @@
body = json.loads(body)
return resp, body['images']
- def get_image(self, image_id, wait=None):
+ def get_image(self, image_id):
url = 'v1/images/%s' % image_id
- resp, __ = self.get(url, wait=wait)
+ resp, __ = self.get(url)
body = self._image_meta_from_headers(resp)
return resp, body
def is_resource_deleted(self, id):
try:
- self.get_image(id, wait=True)
+ self.get_image(id)
except exceptions.NotFound:
return True
return False
diff --git a/tempest/services/object_storage/account_client.py b/tempest/services/object_storage/account_client.py
index fec273c..a71a287 100644
--- a/tempest/services/object_storage/account_client.py
+++ b/tempest/services/object_storage/account_client.py
@@ -103,7 +103,7 @@
self.service = self.config.object_storage.catalog_type
self.format = 'json'
- def request(self, method, url, headers=None, body=None, wait=None):
+ def request(self, method, url, headers=None, body=None):
"""A simple HTTP request interface."""
self.http_obj = httplib2.Http()
if headers is None:
diff --git a/tempest/services/object_storage/object_client.py b/tempest/services/object_storage/object_client.py
index ac1859a..9626b6b 100644
--- a/tempest/services/object_storage/object_client.py
+++ b/tempest/services/object_storage/object_client.py
@@ -156,7 +156,7 @@
self.service = self.config.object_storage.catalog_type
self.format = 'json'
- def request(self, method, url, headers=None, body=None, wait=None):
+ def request(self, method, url, headers=None, body=None):
"""A simple HTTP request interface."""
dscv = self.config.identity.disable_ssl_certificate_validation
self.http_obj = httplib2.Http(disable_ssl_certificate_validation=dscv)
diff --git a/tempest/services/volume/json/volumes_client.py b/tempest/services/volume/json/volumes_client.py
index ff1556f..6b0befd 100644
--- a/tempest/services/volume/json/volumes_client.py
+++ b/tempest/services/volume/json/volumes_client.py
@@ -56,10 +56,10 @@
body = json.loads(body)
return resp, body['volumes']
- def get_volume(self, volume_id, wait=None):
+ def get_volume(self, volume_id):
"""Returns the details of a single volume."""
url = "volumes/%s" % str(volume_id)
- resp, body = self.get(url, wait=wait)
+ resp, body = self.get(url)
body = json.loads(body)
return resp, body['volume']
diff --git a/tempest/services/volume/xml/volumes_client.py b/tempest/services/volume/xml/volumes_client.py
index 5041869..4c15256 100644
--- a/tempest/services/volume/xml/volumes_client.py
+++ b/tempest/services/volume/xml/volumes_client.py
@@ -84,10 +84,10 @@
volumes += [self._parse_volume(vol) for vol in list(body)]
return resp, volumes
- def get_volume(self, volume_id, wait=None):
+ def get_volume(self, volume_id):
"""Returns the details of a single volume."""
url = "volumes/%s" % str(volume_id)
- resp, body = self.get(url, self.headers, wait=wait)
+ resp, body = self.get(url, self.headers)
body = etree.fromstring(body)
return resp, self._parse_volume(body)
diff --git a/tempest/tests/compute/base.py b/tempest/tests/compute/base.py
index 94fff13..3b2026e 100644
--- a/tempest/tests/compute/base.py
+++ b/tempest/tests/compute/base.py
@@ -59,6 +59,7 @@
cls.limits_client = os.limits_client
cls.volumes_extensions_client = os.volumes_extensions_client
cls.volumes_client = os.volumes_client
+ cls.interfaces_client = os.interfaces_client
cls.build_interval = cls.config.compute.build_interval
cls.build_timeout = cls.config.compute.build_timeout
cls.ssh_user = cls.config.compute.ssh_user
diff --git a/tempest/tests/compute/security_groups/test_security_group_rules.py b/tempest/tests/compute/security_groups/test_security_group_rules.py
index 32ac52b..dc85f4b 100644
--- a/tempest/tests/compute/security_groups/test_security_group_rules.py
+++ b/tempest/tests/compute/security_groups/test_security_group_rules.py
@@ -37,18 +37,19 @@
#Creating a Security Group to add rules to it
s_name = rand_name('securitygroup-')
s_description = rand_name('description-')
- resp, securitygroup =\
- self.client.create_security_group(s_name, s_description)
+ resp, securitygroup = \
+ self.client.create_security_group(s_name, s_description)
securitygroup_id = securitygroup['id']
#Adding rules to the created Security Group
parent_group_id = securitygroup['id']
ip_protocol = 'tcp'
from_port = 22
to_port = 22
- resp, rule =\
- self.client.create_security_group_rule(parent_group_id,
- ip_protocol, from_port,
- to_port)
+ resp, rule = \
+ self.client.create_security_group_rule(parent_group_id,
+ ip_protocol,
+ from_port,
+ to_port)
self.assertEqual(200, resp.status)
finally:
#Deleting the Security Group rule, created in this method
@@ -70,14 +71,14 @@
#Creating a Security Group to add rules to it
s_name = rand_name('securitygroup-')
s_description = rand_name('description-')
- resp, securitygroup =\
- self.client.create_security_group(s_name, s_description)
+ resp, securitygroup = \
+ self.client.create_security_group(s_name, s_description)
secgroup1 = securitygroup['id']
#Creating a Security Group so as to assign group_id to the rule
s_name2 = rand_name('securitygroup-')
s_description2 = rand_name('description-')
- resp, securitygroup =\
- self.client.create_security_group(s_name2, s_description2)
+ resp, securitygroup = \
+ self.client.create_security_group(s_name2, s_description2)
secgroup2 = securitygroup['id']
#Adding rules to the created Security Group with optional arguments
parent_group_id = secgroup1
@@ -86,12 +87,13 @@
to_port = 22
cidr = '10.2.3.124/24'
group_id = secgroup2
- resp, rule =\
- self.client.create_security_group_rule(parent_group_id,
- ip_protocol,
- from_port, to_port,
- cidr=cidr,
- group_id=group_id)
+ resp, rule = \
+ self.client.create_security_group_rule(parent_group_id,
+ ip_protocol,
+ from_port,
+ to_port,
+ cidr=cidr,
+ group_id=group_id)
rule_id = rule['id']
self.assertEqual(200, resp.status)
finally:
@@ -112,18 +114,19 @@
#Creating a Security Group to add rule to it
s_name = rand_name('securitygroup-')
s_description = rand_name('description-')
- resp, securitygroup =\
- self.client.create_security_group(s_name, s_description)
+ resp, securitygroup = \
+ self.client.create_security_group(s_name, s_description)
securitygroup_id = securitygroup['id']
#Adding rules to the created Security Group
parent_group_id = securitygroup['id']
ip_protocol = 'tcp'
from_port = 22
to_port = 22
- resp, rule =\
- self.client.create_security_group_rule(parent_group_id,
- ip_protocol,
- from_port, to_port)
+ resp, rule = \
+ self.client.create_security_group_rule(parent_group_id,
+ ip_protocol,
+ from_port,
+ to_port)
finally:
#Deleting the Security Group rule, created in this method
group_rule_id = rule['id']
@@ -203,6 +206,25 @@
parent_group_id, ip_protocol, from_port, to_port)
@attr(type='negative')
+ def test_security_group_rules_create_with_invalid_port_range(self):
+ # Negative test: Creation of Security Group rule should FAIL
+ # with invalid port range.
+ # Creating a Security Group to add rule to it.
+ s_name = rand_name('securitygroup-')
+ s_description = rand_name('description-')
+ resp, securitygroup = self.client.create_security_group(s_name,
+ s_description)
+ # Adding a rule to the created Security Group
+ secgroup_id = securitygroup['id']
+ ip_protocol = 'tcp'
+ from_port = 22
+ to_port = 21
+ self.addCleanup(self.client.delete_security_group, securitygroup['id'])
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_security_group_rule,
+ secgroup_id, ip_protocol, from_port, to_port)
+
+ @attr(type='negative')
def test_security_group_rules_delete_with_invalid_id(self):
# Negative test: Deletion of Security Group rule should be FAIL
# with invalid rule id
diff --git a/tempest/tests/compute/security_groups/test_security_groups.py b/tempest/tests/compute/security_groups/test_security_groups.py
index e5b0380..70a01a0 100644
--- a/tempest/tests/compute/security_groups/test_security_groups.py
+++ b/tempest/tests/compute/security_groups/test_security_groups.py
@@ -38,8 +38,8 @@
for i in range(3):
s_name = rand_name('securitygroup-')
s_description = rand_name('description-')
- resp, securitygroup =\
- self.client.create_security_group(s_name, s_description)
+ resp, securitygroup = \
+ self.client.create_security_group(s_name, s_description)
self.assertEqual(200, resp.status)
security_group_list.append(securitygroup)
#Fetch all Security Groups and verify the list
@@ -47,8 +47,8 @@
resp, fetched_list = self.client.list_security_groups()
self.assertEqual(200, resp.status)
#Now check if all the created Security Groups are in fetched list
- missing_sgs =\
- [sg for sg in security_group_list if sg not in fetched_list]
+ missing_sgs = \
+ [sg for sg in security_group_list if sg not in fetched_list]
self.assertFalse(missing_sgs,
"Failed to find Security Group %s in fetched "
"list" % ', '.join(m_group['name']
@@ -56,8 +56,8 @@
finally:
#Delete all the Security Groups created in this method
for securitygroup in security_group_list:
- resp, _ =\
- self.client.delete_security_group(securitygroup['id'])
+ resp, _ = \
+ self.client.delete_security_group(securitygroup['id'])
self.assertEqual(202, resp.status)
@attr(type='positive')
@@ -67,7 +67,7 @@
s_name = rand_name('securitygroup-')
s_description = rand_name('description-')
resp, securitygroup = \
- self.client.create_security_group(s_name, s_description)
+ self.client.create_security_group(s_name, s_description)
self.assertEqual(200, resp.status)
self.assertTrue('id' in securitygroup)
securitygroup_id = securitygroup['id']
@@ -88,12 +88,12 @@
try:
s_name = rand_name('securitygroup-')
s_description = rand_name('description-')
- resp, securitygroup =\
- self.client.create_security_group(s_name, s_description)
+ resp, securitygroup = \
+ self.client.create_security_group(s_name, s_description)
self.assertEqual(200, resp.status)
#Now fetch the created Security Group by its 'id'
- resp, fetched_group =\
- self.client.get_security_group(securitygroup['id'])
+ resp, fetched_group = \
+ self.client.get_security_group(securitygroup['id'])
self.assertEqual(200, resp.status)
self.assertEqual(securitygroup, fetched_group,
"The fetched Security Group is different "
@@ -172,6 +172,20 @@
s_description)
@attr(type='negative')
+ def test_delete_the_default_security_group(self):
+ # Negative test:Deletion of the "default" Security Group should Fail
+ default_security_group_id = None
+ resp, body = self.client.list_security_groups()
+ for i in range(len(body)):
+ if body[i]['name'] == 'default':
+ default_security_group_id = body[i]['id']
+ break
+ #Deleting the "default" Security Group
+ self.assertRaises(exceptions.BadRequest,
+ self.client.delete_security_group,
+ default_security_group_id)
+
+ @attr(type='negative')
def test_delete_nonexistant_security_group(self):
# Negative test:Deletion of a nonexistant Security Group should Fail
security_group_id = []
diff --git a/tempest/tests/compute/servers/test_attach_interfaces.py b/tempest/tests/compute/servers/test_attach_interfaces.py
new file mode 100644
index 0000000..47c0575
--- /dev/null
+++ b/tempest/tests/compute/servers/test_attach_interfaces.py
@@ -0,0 +1,112 @@
+# Copyright 2013 IBM Corp.
+# 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 tempest import clients
+from tempest.tests.compute import base
+
+import time
+
+
+class AttachInterfacesTestJSON(base.BaseComputeTest):
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(AttachInterfacesTestJSON, cls).setUpClass()
+ os = clients.Manager()
+ if not os.config.network.quantum_available:
+ raise cls.skipException("Quantum is required")
+ cls.client = os.interfaces_client
+
+ def _check_interface(self, iface, port_id=None, network_id=None,
+ fixed_ip=None):
+ self.assertIn('port_state', iface)
+ if port_id:
+ self.assertEqual(iface['port_id'], port_id)
+ if network_id:
+ self.assertEqual(iface['net_id'], network_id)
+ if fixed_ip:
+ self.assertEqual(iface['fixed_ips'][0]['ip_address'], fixed_ip)
+
+ def _create_server_get_interfaces(self):
+ server = self.create_server()
+ self.os.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
+ resp, ifs = self.client.list_interfaces(server['id'])
+ return server, ifs
+
+ def _test_create_interface(self, server):
+ resp, iface = self.client.create_interface(server['id'])
+ self._check_interface(iface)
+ return iface
+
+ def _test_create_interface_by_network_id(self, server, ifs):
+ network_id = ifs[0]['net_id']
+ resp, iface = self.client.create_interface(server['id'],
+ network_id=network_id)
+ self._check_interface(iface, network_id=network_id)
+ return iface
+
+ def _test_show_interface(self, server, ifs):
+ iface = ifs[0]
+ resp, _iface = self.client.show_interface(server['id'],
+ iface['port_id'])
+ self.assertEqual(iface, _iface)
+
+ def _test_delete_interface(self, server, ifs):
+ # NOTE(danms): delete not the first or last, but one in the middle
+ iface = ifs[1]
+ self.client.delete_interface(server['id'], iface['port_id'])
+ for i in range(0, 5):
+ _r, _ifs = self.client.list_interfaces(server['id'])
+ if len(ifs) != len(_ifs):
+ break
+ time.sleep(1)
+
+ self.assertEqual(len(_ifs), len(ifs) - 1)
+ for _iface in _ifs:
+ self.assertNotEqual(iface['port_id'], _iface['port_id'])
+ return _ifs
+
+ def _compare_iface_list(self, list1, list2):
+ # NOTE(danms): port_state will likely have changed, so just
+ # confirm the port_ids are the same at least
+ list1 = [x['port_id'] for x in list1]
+ list2 = [x['port_id'] for x in list2]
+
+ self.assertEqual(sorted(list1), sorted(list2))
+
+ def test_create_list_show_delete_interfaces(self):
+ server, ifs = self._create_server_get_interfaces()
+ interface_count = len(ifs)
+ self.assertTrue(interface_count > 0)
+ self._check_interface(ifs[0])
+
+ iface = self._test_create_interface(server)
+ ifs.append(iface)
+
+ iface = self._test_create_interface_by_network_id(server, ifs)
+ ifs.append(iface)
+
+ resp, _ifs = self.client.list_interfaces(server['id'])
+ self._compare_iface_list(ifs, _ifs)
+
+ self._test_show_interface(server, ifs)
+
+ _ifs = self._test_delete_interface(server, ifs)
+ self.assertEqual(len(ifs) - 1, len(_ifs))
+
+
+class AttachInterfacesTestXML(AttachInterfacesTestJSON):
+ _interface = 'xml'
diff --git a/tempest/tests/compute/servers/test_servers_negative.py b/tempest/tests/compute/servers/test_servers_negative.py
index 366b630..9013b36 100644
--- a/tempest/tests/compute/servers/test_servers_negative.py
+++ b/tempest/tests/compute/servers/test_servers_negative.py
@@ -29,7 +29,6 @@
@classmethod
def setUpClass(cls):
- raise cls.skipException("Until Bug 1046870 is fixed")
super(ServersNegativeTest, cls).setUpClass()
cls.client = cls.servers_client
cls.img_client = cls.images_client
@@ -115,6 +114,8 @@
@attr(type='negative')
def test_create_numeric_server_name(self):
# Create a server with a numeric name
+ if self.__class__._interface == "xml":
+ raise self.skipException("Not testable in XML")
server_name = 12345
self.assertRaises(exceptions.BadRequest,
@@ -182,7 +183,7 @@
def test_update_server_of_another_tenant(self):
# Update name of a server that belongs to another tenant
- server = self.create_server()
+ resp, server = self.create_server(wait_until='ACTIVE')
new_name = server['id'] + '_new'
self.assertRaises(exceptions.NotFound,
self.alt_client.update_server, server['id'],
@@ -192,7 +193,7 @@
def test_update_server_name_length_exceeds_256(self):
# Update name of server exceed the name length limit
- server = self.create_server()
+ resp, server = self.create_server(wait_until='ACTIVE')
new_name = 'a' * 256
self.assertRaises(exceptions.BadRequest,
self.client.update_server,
@@ -210,7 +211,7 @@
def test_delete_a_server_of_another_tenant(self):
# Delete a server that belongs to another tenant
try:
- server = self.create_server()
+ resp, server = self.create_server(wait_until='ACTIVE')
self.assertRaises(exceptions.NotFound,
self.alt_client.delete_server,
server['id'])
@@ -245,3 +246,7 @@
self.assertRaises(exceptions.NotFound, self.client.get_server,
'999erra43')
+
+
+class ServersNegativeTestXML(ServersNegativeTest):
+ _interface = 'xml'
diff --git a/tempest/tests/network/base.py b/tempest/tests/network/base.py
index 4cc8b29..1b09513 100644
--- a/tempest/tests/network/base.py
+++ b/tempest/tests/network/base.py
@@ -18,7 +18,6 @@
from tempest import clients
from tempest.common.utils.data_utils import rand_name
-from tempest import exceptions
import tempest.test
@@ -27,15 +26,9 @@
@classmethod
def setUpClass(cls):
os = clients.Manager()
- client = os.network_client
- # Validate that there is even an endpoint configured
- # for networks, and mark the attr for skipping if not
- try:
- client.list_networks()
- except exceptions.EndpointNotFound:
- skip_msg = "No OpenStack Network API endpoint"
- raise cls.skipException(skip_msg)
+ if not os.config.network.quantum_available:
+ raise cls.skipException("Quantum support is required")
@classmethod
def tearDownClass(cls):