Merge "Add tests for nova's os-attach-interfaces extension"
diff --git a/tempest/clients.py b/tempest/clients.py
index b832929..16f73d3 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -52,7 +52,7 @@
from tempest.services.identity.json.identity_client import TokenClientJSON
from tempest.services.identity.xml.identity_client import IdentityClientXML
from tempest.services.identity.xml.identity_client import TokenClientXML
-from tempest.services.image.json.image_client import ImageClientJSON
+from tempest.services.image.v1.json.image_client import ImageClientJSON
from tempest.services.network.json.network_client import NetworkClient
from tempest.services.object_storage.account_client import AccountClient
from tempest.services.object_storage.account_client import \
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/openstack/common/setup.py b/tempest/openstack/common/setup.py
index 2fb9cf2..80a0ece 100644
--- a/tempest/openstack/common/setup.py
+++ b/tempest/openstack/common/setup.py
@@ -43,6 +43,11 @@
return mapping
+def _parse_git_mailmap(git_dir, mailmap='.mailmap'):
+ mailmap = os.path.join(os.path.dirname(git_dir), mailmap)
+ return parse_mailmap(mailmap)
+
+
def canonicalize_emails(changelog, mapping):
"""Takes in a string and an email alias mapping and replaces all
instances of the aliases in the string with their real email.
@@ -117,9 +122,9 @@
output = subprocess.Popen(["/bin/sh", "-c", cmd],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
+ out = output.communicate()
if output.returncode and throw_on_error:
raise Exception("%s returned %d" % cmd, output.returncode)
- out = output.communicate()
if len(out) == 0:
return None
if len(out[0].strip()) == 0:
@@ -127,14 +132,26 @@
return out[0].strip()
+def _get_git_directory():
+ parent_dir = os.path.dirname(__file__)
+ while True:
+ git_dir = os.path.join(parent_dir, '.git')
+ if os.path.exists(git_dir):
+ return git_dir
+ parent_dir, child = os.path.split(parent_dir)
+ if not child: # reached to root dir
+ return None
+
+
def write_git_changelog():
"""Write a changelog based on the git changelog."""
new_changelog = 'ChangeLog'
+ git_dir = _get_git_directory()
if not os.getenv('SKIP_WRITE_GIT_CHANGELOG'):
- if os.path.isdir('.git'):
- git_log_cmd = 'git log --stat'
+ if git_dir:
+ git_log_cmd = 'git --git-dir=%s log --stat' % git_dir
changelog = _run_shell_command(git_log_cmd)
- mailmap = parse_mailmap()
+ mailmap = _parse_git_mailmap(git_dir)
with open(new_changelog, "w") as changelog_file:
changelog_file.write(canonicalize_emails(changelog, mailmap))
else:
@@ -146,13 +163,15 @@
jenkins_email = 'jenkins@review.(openstack|stackforge).org'
old_authors = 'AUTHORS.in'
new_authors = 'AUTHORS'
+ git_dir = _get_git_directory()
if not os.getenv('SKIP_GENERATE_AUTHORS'):
- if os.path.isdir('.git'):
+ if git_dir:
# don't include jenkins email address in AUTHORS file
- git_log_cmd = ("git log --format='%aN <%aE>' | sort -u | "
+ git_log_cmd = ("git --git-dir=" + git_dir +
+ " log --format='%aN <%aE>' | sort -u | "
"egrep -v '" + jenkins_email + "'")
changelog = _run_shell_command(git_log_cmd)
- mailmap = parse_mailmap()
+ mailmap = _parse_git_mailmap(git_dir)
with open(new_authors, 'w') as new_authors_fh:
new_authors_fh.write(canonicalize_emails(changelog, mailmap))
if os.path.exists(old_authors):
@@ -258,40 +277,44 @@
return cmdclass
-def _get_revno():
+def _get_revno(git_dir):
"""Return the number of commits since the most recent tag.
We use git-describe to find this out, but if there are no
tags then we fall back to counting commits since the beginning
of time.
"""
- describe = _run_shell_command("git describe --always")
+ describe = _run_shell_command(
+ "git --git-dir=%s describe --always" % git_dir)
if "-" in describe:
return describe.rsplit("-", 2)[-2]
# no tags found
- revlist = _run_shell_command("git rev-list --abbrev-commit HEAD")
+ revlist = _run_shell_command(
+ "git --git-dir=%s rev-list --abbrev-commit HEAD" % git_dir)
return len(revlist.splitlines())
def _get_version_from_git(pre_version):
"""Return a version which is equal to the tag that's on the current
revision if there is one, or tag plus number of additional revisions
- if the current revision has no tag.
- """
+ if the current revision has no tag."""
- if os.path.isdir('.git'):
+ git_dir = _get_git_directory()
+ if git_dir:
if pre_version:
try:
return _run_shell_command(
- "git describe --exact-match",
+ "git --git-dir=" + git_dir + " describe --exact-match",
throw_on_error=True).replace('-', '.')
except Exception:
- sha = _run_shell_command("git log -n1 --pretty=format:%h")
- return "%s.a%s.g%s" % (pre_version, _get_revno(), sha)
+ sha = _run_shell_command(
+ "git --git-dir=" + git_dir + " log -n1 --pretty=format:%h")
+ return "%s.a%s.g%s" % (pre_version, _get_revno(git_dir), sha)
else:
return _run_shell_command(
- "git describe --always").replace('-', '.')
+ "git --git-dir=" + git_dir + " describe --always").replace(
+ '-', '.')
return None
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/servers_client.py b/tempest/services/compute/xml/servers_client.py
index efb28e6..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)
@@ -305,7 +321,8 @@
resp, body = self.get("servers/%s/ips" % str(server_id), self.headers)
networks = {}
- for child in etree.fromstring(body.getchildren()):
+ xml_list = etree.fromstring(body)
+ for child in xml_list.getchildren():
network = self._parse_network(child)
networks.update(**network)
@@ -383,6 +400,58 @@
def remove_security_group(self, server_id, name):
return self.action(server_id, 'removeSecurityGroup', None, name=name)
+ def list_server_metadata(self, server_id):
+ resp, body = self.get("servers/%s/metadata" % str(server_id),
+ self.headers)
+ body = self._parse_key_value(etree.fromstring(body))
+ return resp, body
+
+ def set_server_metadata(self, server_id, meta):
+ doc = Document()
+ metadata = Element("metadata")
+ doc.append(metadata)
+ for k, v in meta.items():
+ meta_element = Element("meta", key=k)
+ meta_element.append(Text(v))
+ metadata.append(meta_element)
+ resp, body = self.put('servers/%s/metadata' % str(server_id),
+ str(doc), self.headers)
+ return resp, xml_to_json(etree.fromstring(body))
+
+ def update_server_metadata(self, server_id, meta):
+ doc = Document()
+ metadata = Element("metadata")
+ doc.append(metadata)
+ for k, v in meta.items():
+ meta_element = Element("meta", key=k)
+ meta_element.append(Text(v))
+ metadata.append(meta_element)
+ resp, body = self.post("/servers/%s/metadata" % str(server_id),
+ str(doc), headers=self.headers)
+ body = xml_to_json(etree.fromstring(body))
+ return resp, body
+
+ def get_server_metadata_item(self, server_id, key):
+ resp, body = self.get("servers/%s/metadata/%s" % (str(server_id), key),
+ headers=self.headers)
+ return resp, dict([(etree.fromstring(body).attrib['key'],
+ xml_to_json(etree.fromstring(body)))])
+
+ def set_server_metadata_item(self, server_id, key, meta):
+ doc = Document()
+ for k, v in meta.items():
+ meta_element = Element("meta", key=k)
+ meta_element.append(Text(v))
+ doc.append(meta_element)
+ resp, body = self.put('servers/%s/metadata/%s' % (str(server_id), key),
+ str(doc), self.headers)
+ return resp, xml_to_json(etree.fromstring(body))
+
+ def delete_server_metadata_item(self, server_id, key):
+ resp, body = self.delete("servers/%s/metadata/%s" %
+ (str(server_id), key))
+ return resp, body
+
def get_console_output(self, server_id, length):
return self.action(server_id, 'os-getConsoleOutput', 'output',
length=length)
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/json/__init__.py b/tempest/services/image/v1/__init__.py
similarity index 100%
copy from tempest/services/image/json/__init__.py
copy to tempest/services/image/v1/__init__.py
diff --git a/tempest/services/image/json/__init__.py b/tempest/services/image/v1/json/__init__.py
similarity index 100%
rename from tempest/services/image/json/__init__.py
rename to tempest/services/image/v1/json/__init__.py
diff --git a/tempest/services/image/json/image_client.py b/tempest/services/image/v1/json/image_client.py
similarity index 97%
rename from tempest/services/image/json/image_client.py
rename to tempest/services/image/v1/json/image_client.py
index 277075e..cd2b57c 100644
--- a/tempest/services/image/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/boto/test_ec2_instance_run.py b/tempest/tests/boto/test_ec2_instance_run.py
index 98fdc8b..4ad37b6 100644
--- a/tempest/tests/boto/test_ec2_instance_run.py
+++ b/tempest/tests/boto/test_ec2_instance_run.py
@@ -142,6 +142,7 @@
#NOTE(afazekas): doctored test case,
# with normal validation it would fail
@attr("slow", type='smoke')
+ @testtools.skip("Skipped until the Bug #1117555 is resolved")
def test_integration_1(self):
# EC2 1. integration test (not strict)
image_ami = self.ec2_client.get_image(self.images["ami"]["image_id"])
@@ -151,16 +152,18 @@
group_desc)
self.addResourceCleanUp(self.destroy_security_group_wait,
security_group)
- self.ec2_client.authorize_security_group(sec_group_name,
- ip_protocol="icmp",
- cidr_ip="0.0.0.0/0",
- from_port=-1,
- to_port=-1)
- self.ec2_client.authorize_security_group(sec_group_name,
- ip_protocol="tcp",
- cidr_ip="0.0.0.0/0",
- from_port=22,
- to_port=22)
+ self.assertTrue(self.ec2_client.authorize_security_group(
+ sec_group_name,
+ ip_protocol="icmp",
+ cidr_ip="0.0.0.0/0",
+ from_port=-1,
+ to_port=-1))
+ self.assertTrue(self.ec2_client.authorize_security_group(
+ sec_group_name,
+ ip_protocol="tcp",
+ cidr_ip="0.0.0.0/0",
+ from_port=22,
+ to_port=22))
reservation = image_ami.run(kernel_id=self.images["aki"]["image_id"],
ramdisk_id=self.images["ari"]["image_id"],
instance_type=self.instance_type,
@@ -177,7 +180,7 @@
address = self.ec2_client.allocate_address()
rcuk_a = self.addResourceCleanUp(address.delete)
- address.associate(instance.id)
+ self.assertTrue(address.associate(instance.id))
rcuk_da = self.addResourceCleanUp(address.disassociate)
#TODO(afazekas): ping test. dependecy/permission ?
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_server_metadata.py b/tempest/tests/compute/servers/test_server_metadata.py
index 4b17fa2..bc523de 100644
--- a/tempest/tests/compute/servers/test_server_metadata.py
+++ b/tempest/tests/compute/servers/test_server_metadata.py
@@ -15,28 +15,25 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
from tempest.test import attr
from tempest.tests.compute import base
-class ServerMetadataTest(base.BaseComputeTest):
+class ServerMetadataTestJSON(base.BaseComputeTest):
_interface = 'json'
@classmethod
def setUpClass(cls):
- super(ServerMetadataTest, cls).setUpClass()
+ super(ServerMetadataTestJSON, cls).setUpClass()
cls.client = cls.servers_client
cls.quotas = cls.quotas_client
cls.admin_client = cls._get_identity_admin_client()
resp, tenants = cls.admin_client.list_tenants()
cls.tenant_id = [tnt['id'] for tnt in tenants if tnt['name'] ==
cls.client.tenant_name][0]
- #Create a server to be used for all read only tests
- name = rand_name('server')
- resp, server = cls.client.create_server(name, cls.image_ref,
- cls.flavor_ref, meta={})
+ resp, server = cls.create_server(meta={})
+
cls.server_id = server['id']
#Wait for the server to become active
@@ -45,10 +42,10 @@
@classmethod
def tearDownClass(cls):
cls.client.delete_server(cls.server_id)
- super(ServerMetadataTest, cls).tearDownClass()
+ super(ServerMetadataTestJSON, cls).tearDownClass()
def setUp(self):
- super(ServerMetadataTest, self).setUp()
+ super(ServerMetadataTestJSON, self).setUp()
meta = {'key1': 'value1', 'key2': 'value2'}
resp, _ = self.client.set_server_metadata(self.server_id, meta)
self.assertEqual(resp.status, 200)
@@ -238,3 +235,7 @@
self.assertRaises(exceptions.BadRequest,
self.client.set_server_metadata,
self.server_id, meta=meta)
+
+
+class ServerMetadataTestXML(ServerMetadataTestJSON):
+ _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/services/image/json/__init__.py b/tempest/tests/image/v1/__init__.py
similarity index 100%
copy from tempest/services/image/json/__init__.py
copy to tempest/tests/image/v1/__init__.py
diff --git a/tempest/tests/image/test_images.py b/tempest/tests/image/v1/test_images.py
similarity index 100%
rename from tempest/tests/image/test_images.py
rename to tempest/tests/image/v1/test_images.py
diff --git a/tools/install_venv_common.py b/tools/install_venv_common.py
index 8f91251..fd9076f 100644
--- a/tools/install_venv_common.py
+++ b/tools/install_venv_common.py
@@ -21,20 +21,12 @@
Synced in from openstack-common
"""
+import argparse
import os
import subprocess
import sys
-possible_topdir = os.getcwd()
-if os.path.exists(os.path.join(possible_topdir, "tempest",
- "__init__.py")):
- sys.path.insert(0, possible_topdir)
-
-
-from tempest.openstack.common import cfg
-
-
class InstallVenv(object):
def __init__(self, root, venv, pip_requires, test_requires, py_version,
@@ -139,17 +131,12 @@
def parse_args(self, argv):
"""Parses command-line arguments."""
- cli_opts = [
- cfg.BoolOpt('no-site-packages',
- default=False,
- short='n',
- help="Do not inherit packages from global Python"
- "install"),
- ]
- CLI = cfg.ConfigOpts()
- CLI.register_cli_opts(cli_opts)
- CLI(argv[1:])
- return CLI
+ parser = argparse.ArgumentParser()
+ parser.add_argument('-n', '--no-site-packages',
+ action='store_true',
+ help="Do not inherit packages from global Python "
+ "install")
+ return parser.parse_args(argv[1:])
class Distro(InstallVenv):