Merge "early failures would prevent cleanup"
diff --git a/.gitignore b/.gitignore
index 55096ed..061c2ff 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,5 @@
*.swo
*.egg-info
.tox
+dist
+build
diff --git a/bin/tempest b/bin/tempest
new file mode 100755
index 0000000..87ba6d5
--- /dev/null
+++ b/bin/tempest
@@ -0,0 +1,52 @@
+#!/usr/bin/env bash
+
+function usage {
+ echo "Usage: $0 [OPTION]..."
+ echo "Run Tempest test suite"
+ echo ""
+ echo " -s, --smoke Only run smoke tests"
+ echo " -w, --whitebox Only run whitebox tests"
+ echo " -h, --help Print this usage message"
+ echo " -d. --debug Debug this script -- set -o xtrace"
+ exit
+}
+
+function process_option {
+ case "$1" in
+ -h|--help) usage;;
+ -d|--debug) set -o xtrace;;
+ -s|--smoke) noseargs="$noseargs --attr=type=smoke";;
+ -w|--whitebox) noseargs="$noseargs --attr=type=whitebox";;
+ *) noseargs="$noseargs $1"
+ esac
+}
+
+noseargs=""
+
+export NOSE_WITH_OPENSTACK=1
+export NOSE_OPENSTACK_COLOR=1
+export NOSE_OPENSTACK_RED=15.00
+export NOSE_OPENSTACK_YELLOW=3.00
+export NOSE_OPENSTACK_SHOW_ELAPSED=1
+export NOSE_OPENSTACK_STDOUT=1
+
+for arg in "$@"; do
+ process_option $arg
+done
+
+
+# only add tempest default if we don't specify a test
+if [[ "x$noseargs" =~ "tempest" ]]; then
+ noseargs="$noseargs"
+else
+ noseargs="$noseargs tempest"
+fi
+
+
+function run_tests {
+ $NOSETESTS
+}
+
+NOSETESTS="nosetests $noseargs"
+
+run_tests || exit
diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample
index ed3cf6c..020baa1 100644
--- a/etc/tempest.conf.sample
+++ b/etc/tempest.conf.sample
@@ -210,12 +210,8 @@
[object-storage]
# This section contains configuration options used when executing tests
# against the OpenStack Object Storage API.
-# This should be the username of a user WITHOUT administrative privileges
-username = admin
-# The above non-administrative user's password
-password = password
-# The above non-administrative user's tenant name
-tenant_name = admin
+
+# You can configure the credentials in the compute section
# The type of endpoint for an Object Storage API service. Unless you have a
# custom Keystone service catalog implementation, you probably want to leave
diff --git a/etc/tempest.conf.tpl b/etc/tempest.conf.tpl
index 880a3c1..8ef5b84 100644
--- a/etc/tempest.conf.tpl
+++ b/etc/tempest.conf.tpl
@@ -181,11 +181,8 @@
# This section contains configuration options used when executing tests
# against the OpenStack Object Storage API.
# This should be the username of a user WITHOUT administrative privileges
-username = %USERNAME%
-# The above non-administrative user's password
-password = %PASSWORD%
-# The above non-administrative user's tenant name
-tenant_name = %TENANT_NAME%
+
+# You can configure the credentials in the compute section
# The type of endpoint for an Object Storage API service. Unless you have a
# custom Keystone service catalog implementation, you probably want to leave
diff --git a/run_tests.sh b/run_tests.sh
index e359caf..059ac75 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
function usage {
echo "Usage: $0 [OPTION]..."
diff --git a/setup.py b/setup.py
old mode 100644
new mode 100755
index fceadba..2e046ea
--- a/setup.py
+++ b/setup.py
@@ -1,34 +1,51 @@
-#!/usr/bin/python
-# Copyright (c) 2012 OpenStack, LLC.
+#!/usr/bin/env python
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2010 United States Government as represented by the
+# Administrator of the National Aeronautics and Space Administration.
+# 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
+# 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
+# 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.
+# 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 setuptools
-setuptools.setup(
- name='tempest',
- version="0.1",
- description='The OpenStack Integration Test Suite',
- license='Apache License (2.0)',
- author='OpenStack',
- author_email='openstack@lists.launchpad.net',
- url='http://github.com/openstack/tempest/',
- classifiers=[
- 'Development Status :: 4 - Beta',
- 'License :: OSI Approved :: Apache Software License',
- 'Operating System :: POSIX :: Linux',
- 'Programming Language :: Python :: 2.6',
- 'Environment :: No Input/Output (Daemon)',
- ],
- py_modules=[])
+from tempest.common import setup
+
+requires = setup.parse_requirements()
+depend_links = setup.parse_dependency_links()
+
+setuptools.setup(name='tempest',
+ version="2012.2",
+ description='Integration test tools',
+ author='OpenStack',
+ author_email='openstack-qa@lists.launchpad.net',
+ url='http://www.openstack.org/',
+ classifiers=['Environment :: OpenStack',
+ 'Intended Audience :: Information Technology',
+ 'Intended Audience :: System Administrators',
+ 'Intended Audience :: Developers',
+ 'License :: OSI Approved :'
+ ': Apache Software License',
+ 'Operating System :: POSIX :: Linux',
+ 'Programming Language :: Python',
+ 'Programming Language :: Python :: 2',
+ 'Programming Language :: Python :: 2.7', ],
+ cmdclass=setup.get_cmdclass(),
+ packages=setuptools.find_packages(exclude=['bin']),
+ install_requires=requires,
+ dependency_links=depend_links,
+ include_package_data=True,
+ test_suite='nose.collector',
+ setup_requires=['setuptools_git>=0.4'],
+ scripts=['bin/tempest'],
+ py_modules=[])
diff --git a/tempest/common/rest_client.py b/tempest/common/rest_client.py
index 52ed6bc..f430f02 100644
--- a/tempest/common/rest_client.py
+++ b/tempest/common/rest_client.py
@@ -51,6 +51,14 @@
'Accept': 'application/%s' % self.TYPE}
self.build_interval = config.compute.build_interval
self.build_timeout = config.compute.build_timeout
+ self.general_header_lc = set(('cache-control', 'connection',
+ 'date', 'pragma', 'trailer',
+ 'transfer-encoding', 'via',
+ 'warning'))
+ self.response_header_lc = set(('accept-ranges', 'age', 'etag',
+ 'location', 'proxy-authenticate',
+ 'retry-after', 'server',
+ 'vary', 'www-authenticate'))
def _set_auth(self):
"""
@@ -162,8 +170,8 @@
def post(self, url, body, headers):
return self.request('POST', url, headers, body)
- def get(self, url, headers=None):
- return self.request('GET', url, headers)
+ def get(self, url, headers=None, wait=None):
+ return self.request('GET', url, headers, wait=wait)
def delete(self, url, headers=None):
return self.request('DELETE', url, headers)
@@ -186,7 +194,8 @@
def _parse_resp(self, body):
return json.loads(body)
- def request(self, method, url, headers=None, body=None, depth=0):
+ def request(self, method, url,
+ headers=None, body=None, depth=0, wait=None):
"""A simple HTTP request interface."""
if (self.token is None) or (self.base_url is None):
@@ -200,12 +209,45 @@
req_url = "%s/%s" % (self.base_url, url)
resp, resp_body = self.http_obj.request(req_url, method,
headers=headers, body=body)
+
+ #TODO(afazekas): Make sure we can validate all responses, and the
+ #http library does not do any action automatically
+ if (resp.status in set((204, 205, 304)) or resp.status < 200 or
+ method.upper() == 'HEAD') and body:
+ raise exception.ResponseWithNonEmptyBody(status=resp.status)
+
+ #NOTE(afazekas):
+ # If the HTTP Status Code is 205
+ # 'The response MUST NOT include an entity.'
+ # A HTTP entity has an entity-body and an 'entity-header'.
+ # In the HTTP response specification (Section 6) the 'entity-header'
+ # 'generic-header' and 'response-header' are in OR relation.
+ # All headers not in the above two group are considered as entity
+ # header in every interpretation.
+
+ if (resp.status == 205 and
+ 0 != len(set(resp.keys()) - set(('status',)) -
+ self.response_header_lc - self.general_header_lc)):
+ raise exception.ResponseWithEntity()
+
+ #NOTE(afazekas)
+ # Now the swift sometimes (delete not empty container)
+ # returns with non json error response, we can create new rest class
+ # for swift.
+ # Usually RFC2616 says error responses SHOULD contain an explanation.
+ # The warning is normal for SHOULD/SHOULD NOT case
+
+ # Likely it will cause error
+ if not body and resp.status >= 400:
+ self.log.warning("status >= 400 response with empty body")
+
if resp.status == 401 or resp.status == 403:
self._log(req_url, body, resp, resp_body)
raise exceptions.Unauthorized()
if resp.status == 404:
- self._log(req_url, body, resp, resp_body)
+ if not wait:
+ self._log(req_url, body, resp, resp_body)
raise exceptions.NotFound(resp_body)
if resp.status == 400:
diff --git a/tempest/common/setup.py b/tempest/common/setup.py
new file mode 100644
index 0000000..e6f72f0
--- /dev/null
+++ b/tempest/common/setup.py
@@ -0,0 +1,366 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2011 OpenStack LLC.
+# 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.
+
+"""
+Utilities with minimum-depends for use in setup.py
+"""
+
+import datetime
+import os
+import re
+import subprocess
+import sys
+
+from setuptools.command import sdist
+
+
+def parse_mailmap(mailmap='.mailmap'):
+ mapping = {}
+ if os.path.exists(mailmap):
+ with open(mailmap, 'r') as fp:
+ for l in fp:
+ l = l.strip()
+ if not l.startswith('#') and ' ' in l:
+ canonical_email, alias = [x for x in l.split(' ')
+ if x.startswith('<')]
+ mapping[alias] = canonical_email
+ return mapping
+
+
+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.
+ """
+ for alias, email in mapping.iteritems():
+ changelog = changelog.replace(alias, email)
+ return changelog
+
+
+# Get requirements from the first file that exists
+def get_reqs_from_files(requirements_files):
+ for requirements_file in requirements_files:
+ if os.path.exists(requirements_file):
+ with open(requirements_file, 'r') as fil:
+ return fil.read().split('\n')
+ return []
+
+
+def parse_requirements(requirements_files=['requirements.txt',
+ 'tools/pip-requires']):
+ requirements = []
+ for line in get_reqs_from_files(requirements_files):
+ # For the requirements list, we need to inject only the portion
+ # after egg= so that distutils knows the package it's looking for
+ # such as:
+ # -e git://github.com/openstack/nova/master#egg=nova
+ if re.match(r'\s*-e\s+', line):
+ requirements.append(re.sub(r'\s*-e\s+.*#egg=(.*)$', r'\1',
+ line))
+ # such as:
+ # http://github.com/openstack/nova/zipball/master#egg=nova
+ elif re.match(r'\s*https?:', line):
+ requirements.append(re.sub(r'\s*https?:.*#egg=(.*)$', r'\1',
+ line))
+ # -f lines are for index locations, and don't get used here
+ elif re.match(r'\s*-f\s+', line):
+ pass
+ # argparse is part of the standard library starting with 2.7
+ # adding it to the requirements list screws distro installs
+ elif line == 'argparse' and sys.version_info >= (2, 7):
+ pass
+ else:
+ requirements.append(line)
+
+ return requirements
+
+
+def parse_dependency_links(requirements_files=['requirements.txt',
+ 'tools/pip-requires']):
+ dependency_links = []
+ # dependency_links inject alternate locations to find packages listed
+ # in requirements
+ for line in get_reqs_from_files(requirements_files):
+ # skip comments and blank lines
+ if re.match(r'(\s*#)|(\s*$)', line):
+ continue
+ # lines with -e or -f need the whole line, minus the flag
+ if re.match(r'\s*-[ef]\s+', line):
+ dependency_links.append(re.sub(r'\s*-[ef]\s+', '', line))
+ # lines that are only urls can go in unmolested
+ elif re.match(r'\s*https?:', line):
+ dependency_links.append(line)
+ return dependency_links
+
+
+def write_requirements():
+ venv = os.environ.get('VIRTUAL_ENV', None)
+ if venv is not None:
+ with open("requirements.txt", "w") as req_file:
+ output = subprocess.Popen(["pip", "-E", venv, "freeze", "-l"],
+ stdout=subprocess.PIPE)
+ requirements = output.communicate()[0].strip()
+ req_file.write(requirements)
+
+
+def _run_shell_command(cmd):
+ if os.name == 'nt':
+ output = subprocess.Popen(["cmd.exe", "/C", cmd],
+ stdout=subprocess.PIPE)
+ else:
+ output = subprocess.Popen(["/bin/sh", "-c", cmd],
+ stdout=subprocess.PIPE)
+ out = output.communicate()
+ if len(out) == 0:
+ return None
+ if len(out[0].strip()) == 0:
+ return None
+ return out[0].strip()
+
+
+def _get_git_next_version_suffix(branch_name):
+ datestamp = datetime.datetime.now().strftime('%Y%m%d')
+ if branch_name == 'milestone-proposed':
+ revno_prefix = "r"
+ else:
+ revno_prefix = ""
+ _run_shell_command("git fetch origin +refs/meta/*:refs/remotes/meta/*")
+ milestone_cmd = "git show meta/openstack/release:%s" % branch_name
+ milestonever = _run_shell_command(milestone_cmd)
+ if milestonever:
+ first_half = "%s~%s" % (milestonever, datestamp)
+ else:
+ first_half = datestamp
+
+ post_version = _get_git_post_version()
+ # post version should look like:
+ # 0.1.1.4.gcc9e28a
+ # where the bit after the last . is the short sha, and the bit between
+ # the last and second to last is the revno count
+ (revno, sha) = post_version.split(".")[-2:]
+ second_half = "%s%s.%s" % (revno_prefix, revno, sha)
+ return ".".join((first_half, second_half))
+
+
+def _get_git_current_tag():
+ return _run_shell_command("git tag --contains HEAD")
+
+
+def _get_git_tag_info():
+ return _run_shell_command("git describe --tags")
+
+
+def _get_git_post_version():
+ current_tag = _get_git_current_tag()
+ if current_tag is not None:
+ return current_tag
+ else:
+ tag_info = _get_git_tag_info()
+ if tag_info is None:
+ base_version = "0.0"
+ cmd = "git --no-pager log --oneline"
+ out = _run_shell_command(cmd)
+ revno = len(out.split("\n"))
+ sha = _run_shell_command("git describe --always")
+ else:
+ tag_infos = tag_info.split("-")
+ base_version = "-".join(tag_infos[:-2])
+ (revno, sha) = tag_infos[-2:]
+ return "%s.%s.%s" % (base_version, revno, sha)
+
+
+def write_git_changelog():
+ """Write a changelog based on the git changelog."""
+ new_changelog = 'ChangeLog'
+ if not os.getenv('SKIP_WRITE_GIT_CHANGELOG'):
+ if os.path.isdir('.git'):
+ git_log_cmd = 'git log --stat'
+ changelog = _run_shell_command(git_log_cmd)
+ mailmap = parse_mailmap()
+ with open(new_changelog, "w") as changelog_file:
+ changelog_file.write(canonicalize_emails(changelog, mailmap))
+ else:
+ open(new_changelog, 'w').close()
+
+
+def generate_authors():
+ """Create AUTHORS file using git commits."""
+ jenkins_email = 'jenkins@review.(openstack|stackforge).org'
+ old_authors = 'AUTHORS.in'
+ new_authors = 'AUTHORS'
+ if not os.getenv('SKIP_GENERATE_AUTHORS'):
+ if os.path.isdir('.git'):
+ # don't include jenkins email address in AUTHORS file
+ git_log_cmd = ("git log --format='%aN <%aE>' | sort -u | "
+ "egrep -v '" + jenkins_email + "'")
+ changelog = _run_shell_command(git_log_cmd)
+ mailmap = parse_mailmap()
+ with open(new_authors, 'w') as new_authors_fh:
+ new_authors_fh.write(canonicalize_emails(changelog, mailmap))
+ if os.path.exists(old_authors):
+ with open(old_authors, "r") as old_authors_fh:
+ new_authors_fh.write('\n' + old_authors_fh.read())
+ else:
+ open(new_authors, 'w').close()
+
+
+_rst_template = """%(heading)s
+%(underline)s
+
+.. automodule:: %(module)s
+ :members:
+ :undoc-members:
+ :show-inheritance:
+"""
+
+
+def read_versioninfo(project):
+ """Read the versioninfo file. If it doesn't exist, we're in a github
+ zipball, and there's really no way to know what version we really
+ are, but that should be ok, because the utility of that should be
+ just about nil if this code path is in use in the first place."""
+ versioninfo_path = os.path.join(project, 'versioninfo')
+ if os.path.exists(versioninfo_path):
+ with open(versioninfo_path, 'r') as vinfo:
+ version = vinfo.read().strip()
+ else:
+ version = "0.0.0"
+ return version
+
+
+def write_versioninfo(project, version):
+ """Write a simple file containing the version of the package."""
+ with open(os.path.join(project, 'versioninfo'), 'w') as fil:
+ fil.write("%s\n" % version)
+
+
+def get_cmdclass():
+ """Return dict of commands to run from setup.py."""
+
+ cmdclass = dict()
+
+ def _find_modules(arg, dirname, files):
+ for filename in files:
+ if filename.endswith('.py') and filename != '__init__.py':
+ arg["%s.%s" % (dirname.replace('/', '.'),
+ filename[:-3])] = True
+
+ class LocalSDist(sdist.sdist):
+ """Builds the ChangeLog and Authors files from VC first."""
+
+ def run(self):
+ write_git_changelog()
+ generate_authors()
+ # sdist.sdist is an old style class, can't use super()
+ sdist.sdist.run(self)
+
+ cmdclass['sdist'] = LocalSDist
+
+ # If Sphinx is installed on the box running setup.py,
+ # enable setup.py to build the documentation, otherwise,
+ # just ignore it
+ try:
+ from sphinx.setup_command import BuildDoc
+
+ class LocalBuildDoc(BuildDoc):
+ def generate_autoindex(self):
+ print "**Autodocumenting from %s" % os.path.abspath(os.curdir)
+ modules = {}
+ option_dict = self.distribution.get_option_dict('build_sphinx')
+ source_dir = os.path.join(option_dict['source_dir'][1], 'api')
+ if not os.path.exists(source_dir):
+ os.makedirs(source_dir)
+ for pkg in self.distribution.packages:
+ if '.' not in pkg:
+ os.path.walk(pkg, _find_modules, modules)
+ module_list = modules.keys()
+ module_list.sort()
+ autoindex_filename = os.path.join(source_dir, 'autoindex.rst')
+ with open(autoindex_filename, 'w') as autoindex:
+ autoindex.write(""".. toctree::
+ :maxdepth: 1
+
+""")
+ for module in module_list:
+ output_filename = os.path.join(source_dir,
+ "%s.rst" % module)
+ heading = "The :mod:`%s` Module" % module
+ underline = "=" * len(heading)
+ values = dict(module=module, heading=heading,
+ underline=underline)
+
+ print "Generating %s" % output_filename
+ with open(output_filename, 'w') as output_file:
+ output_file.write(_rst_template % values)
+ autoindex.write(" %s.rst\n" % module)
+
+ def run(self):
+ if not os.getenv('SPHINX_DEBUG'):
+ self.generate_autoindex()
+
+ for builder in ['html', 'man']:
+ self.builder = builder
+ self.finalize_options()
+ self.project = self.distribution.get_name()
+ self.version = self.distribution.get_version()
+ self.release = self.distribution.get_version()
+ BuildDoc.run(self)
+ cmdclass['build_sphinx'] = LocalBuildDoc
+ except ImportError:
+ pass
+
+ return cmdclass
+
+
+def get_git_branchname():
+ for branch in _run_shell_command("git branch --color=never").split("\n"):
+ if branch.startswith('*'):
+ _branch_name = branch.split()[1].strip()
+ if _branch_name == "(no":
+ _branch_name = "no-branch"
+ return _branch_name
+
+
+def get_pre_version(projectname, base_version):
+ """Return a version which is leading up to a version that will
+ be released in the future."""
+ if os.path.isdir('.git'):
+ current_tag = _get_git_current_tag()
+ if current_tag is not None:
+ version = current_tag
+ else:
+ branch_name = os.getenv('BRANCHNAME',
+ os.getenv('GERRIT_REFNAME',
+ get_git_branchname()))
+ version_suffix = _get_git_next_version_suffix(branch_name)
+ version = "%s~%s" % (base_version, version_suffix)
+ write_versioninfo(projectname, version)
+ return version
+ else:
+ version = read_versioninfo(projectname)
+ return version
+
+
+def get_post_version(projectname):
+ """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 os.path.isdir('.git'):
+ version = _get_git_post_version()
+ write_versioninfo(projectname, version)
+ return version
+ return read_versioninfo(projectname)
diff --git a/tempest/common/utils/data_utils.py b/tempest/common/utils/data_utils.py
index 15afd0a..22e4742 100644
--- a/tempest/common/utils/data_utils.py
+++ b/tempest/common/utils/data_utils.py
@@ -18,6 +18,8 @@
import random
import re
import urllib
+import itertools
+
from tempest import exceptions
@@ -58,30 +60,14 @@
def parse_image_id(image_ref):
"""Return the image id from a given image ref"""
- temp = image_ref.rsplit('/')
- #Return the last item, which is the image id
- return temp[len(temp) - 1]
+ return image_ref.rsplit('/')[-1]
def arbitrary_string(size=4, base_text=None):
- """Return exactly size bytes worth of base_text as a string"""
-
- if (base_text is None) or (base_text == ''):
+ """
+ Return size characters from base_text, repeating the base_text infinitely
+ if needed.
+ """
+ if not base_text:
base_text = 'test'
-
- if size <= 0:
- return ''
-
- extra = size % len(base_text)
- body = ''
-
- if extra == 0:
- body = base_text * size
-
- if extra == size:
- body = base_text[:size]
-
- if extra > 0 and extra < size:
- body = (size / len(base_text)) * base_text + base_text[:extra]
-
- return body
+ return ''.join(itertools.islice(itertools.cycle(base_text), size))
diff --git a/tempest/config.py b/tempest/config.py
index 0ccd4b6..60da85c 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -18,6 +18,7 @@
import ConfigParser
import logging
import os
+import sys
from tempest.common.utils import data_utils
@@ -400,21 +401,6 @@
SECTION_NAME = "object-storage"
@property
- def username(self):
- """Username to use for Object-Storage API requests."""
- return self.get("username", "admin")
-
- @property
- def tenant_name(self):
- """Tenant name to use for Object-Storage API requests."""
- return self.get("tenant_name", "admin")
-
- @property
- def password(self):
- """API key to use when authenticating."""
- return self.get("password", "password")
-
- @property
def catalog_type(self):
"""Catalog type of the Object-Storage service."""
return self.get("catalog_type", 'object-store')
@@ -528,11 +514,17 @@
path = os.path.join(conf_dir, conf_file)
+ if (not os.path.isfile(path) and
+ not 'TEMPEST_CONFIG_DIR' in os.environ and
+ not 'TEMPEST_CONFIG' in os.environ):
+ path = "/etc/tempest/" + self.DEFAULT_CONFIG_FILE
+
LOG.info("Using tempest config file %s" % path)
if not os.path.exists(path):
msg = "Config file %(path)s not found" % locals()
- raise RuntimeError(msg)
+ print >> sys.stderr, RuntimeError(msg)
+ sys.exit(os.EX_NOINPUT)
self._conf = self.load_config(path)
self.compute = ComputeConfig(self._conf)
diff --git a/tempest/exceptions.py b/tempest/exceptions.py
index 016de69..86ec2eb 100644
--- a/tempest/exceptions.py
+++ b/tempest/exceptions.py
@@ -133,3 +133,17 @@
class TearDownException(TempestException):
message = "%(num)d cleanUp operation failed"
+
+
+class RFCViolation(TempestException):
+ message = "RFC Violation"
+
+
+class ResponseWithNonEmptyBody(RFCViolation):
+ message = ("RFC Violation! Response with %(status) HTTP Status Code "
+ "MUST NOT have a body")
+
+
+class ResponseWithEntity(RFCViolation):
+ message = ("RFC Violation! Response with 205 HTTP Status Code "
+ "MUST NOT have an entity")
diff --git a/tempest/manager.py b/tempest/manager.py
index fda887c..59743e5 100644
--- a/tempest/manager.py
+++ b/tempest/manager.py
@@ -41,6 +41,7 @@
from tempest.services.compute.json import keypairs_client
from tempest.services.compute.json import volumes_extensions_client
from tempest.services.compute.json import console_output_client
+from tempest.services.compute.json import quotas_client
NetworkClient = network_client.NetworkClient
ImagesClient = images_client.ImagesClientJSON
@@ -54,6 +55,7 @@
VolumesExtensionsClient = volumes_extensions_client.VolumesExtensionsClientJSON
VolumesClient = volumes_client.VolumesClientJSON
ConsoleOutputsClient = console_output_client.ConsoleOutputsClient
+QuotasClient = quotas_client.QuotasClient
LOG = logging.getLogger(__name__)
@@ -233,6 +235,7 @@
self.volumes_extensions_client = VolumesExtensionsClient(*client_args)
self.volumes_client = VolumesClient(*client_args)
self.console_outputs_client = ConsoleOutputsClient(*client_args)
+ self.quotas_client = QuotasClient(*client_args)
self.network_client = NetworkClient(*client_args)
diff --git a/tempest/openstack.py b/tempest/openstack.py
index dc73bd7..fbd2f00 100644
--- a/tempest/openstack.py
+++ b/tempest/openstack.py
@@ -59,7 +59,7 @@
from tempest.services.object_storage.object_client import ObjectClient
from tempest.services.boto.clients import APIClientEC2
from tempest.services.boto.clients import ObjectClientS3
-
+from tempest.services.compute.json.quotas_client import QuotasClient
LOG = logging.getLogger(__name__)
@@ -184,6 +184,7 @@
msg = "Unsupported interface type `%s'" % interface
raise exceptions.InvalidConfiguration(msg)
self.console_outputs_client = ConsoleOutputsClient(*client_args)
+ self.quotas_client = QuotasClient(*client_args)
self.network_client = NetworkClient(*client_args)
self.account_client = AccountClient(*client_args)
self.container_client = ContainerClient(*client_args)
diff --git a/tempest/services/compute/admin/__init__.py b/tempest/services/compute/admin/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/services/compute/admin/__init__.py
diff --git a/tempest/services/compute/admin/json/__init__.py b/tempest/services/compute/admin/json/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/services/compute/admin/json/__init__.py
diff --git a/tempest/services/compute/admin/json/quotas_client.py b/tempest/services/compute/admin/json/quotas_client.py
new file mode 100644
index 0000000..625d4d4
--- /dev/null
+++ b/tempest/services/compute/admin/json/quotas_client.py
@@ -0,0 +1,79 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+#
+# Copyright 2012 NTT Data
+# 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.services.compute.json.quotas_client import QuotasClient
+
+
+class AdminQuotasClient(QuotasClient):
+
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ super(AdminQuotasClient, self).__init__(config, username, password,
+ auth_url, tenant_name)
+
+ def update_quota_set(self, tenant_id, injected_file_content_bytes=None,
+ metadata_items=None, ram=None, floating_ips=None,
+ key_pairs=None, instances=None,
+ security_group_rules=None, injected_files=None,
+ cores=None, injected_file_path_bytes=None,
+ security_groups=None):
+ """
+ Updates the tenant's quota limits for one or more resources
+ """
+ post_body = {}
+
+ if injected_file_content_bytes >= 0:
+ post_body['injected_file_content_bytes'] = \
+ injected_file_content_bytes
+
+ if metadata_items >= 0:
+ post_body['metadata_items'] = metadata_items
+
+ if ram >= 0:
+ post_body['ram'] = ram
+
+ if floating_ips >= 0:
+ post_body['floating_ips'] = floating_ips
+
+ if key_pairs >= 0:
+ post_body['key_pairs'] = key_pairs
+
+ if instances >= 0:
+ post_body['instances'] = instances
+
+ if security_group_rules >= 0:
+ post_body['security_group_rules'] = security_group_rules
+
+ if injected_files >= 0:
+ post_body['injected_files'] = injected_files
+
+ if cores >= 0:
+ post_body['cores'] = cores
+
+ if injected_file_path_bytes >= 0:
+ post_body['injected_file_path_bytes'] = injected_file_path_bytes
+
+ if security_groups >= 0:
+ post_body['security_groups'] = security_groups
+
+ post_body = json.dumps({'quota_set': post_body})
+ resp, body = self.put('os-quota-sets/%s' % str(tenant_id), post_body,
+ self.headers)
+
+ body = json.loads(body)
+ return resp, body['quota_set']
diff --git a/tempest/services/compute/json/flavors_client.py b/tempest/services/compute/json/flavors_client.py
index 01708a2..dc825df 100644
--- a/tempest/services/compute/json/flavors_client.py
+++ b/tempest/services/compute/json/flavors_client.py
@@ -17,6 +17,7 @@
from tempest.common.rest_client import RestClient
import json
+import urllib
class FlavorsClientJSON(RestClient):
@@ -28,12 +29,8 @@
def list_flavors(self, params=None):
url = 'flavors'
- if params is not None:
- param_list = []
- for param, value in params.iteritems():
- param_list.append("%s=%s&" % (param, value))
-
- url = "flavors?" + "".join(param_list)
+ if params:
+ url += '?%s' % urllib.urlencode(params)
resp, body = self.get(url)
body = json.loads(body)
@@ -41,12 +38,8 @@
def list_flavors_with_detail(self, params=None):
url = 'flavors/detail'
- if params is not None:
- param_list = []
- for param, value in params.iteritems():
- param_list.append("%s=%s&" % (param, value))
-
- url = "flavors/detail?" + "".join(param_list)
+ if params:
+ url += '?%s' % urllib.urlencode(params)
resp, body = self.get(url)
body = json.loads(body)
diff --git a/tempest/services/compute/json/floating_ips_client.py b/tempest/services/compute/json/floating_ips_client.py
index 6219f34..1303c52 100644
--- a/tempest/services/compute/json/floating_ips_client.py
+++ b/tempest/services/compute/json/floating_ips_client.py
@@ -18,6 +18,7 @@
from tempest.common.rest_client import RestClient
from tempest import exceptions
import json
+import urllib
class FloatingIPsClientJSON(RestClient):
@@ -29,11 +30,9 @@
def list_floating_ips(self, params=None):
"""Returns a list of all floating IPs filtered by any parameters"""
url = 'os-floating-ips'
- if params is not None:
- param_list = []
- for param, value in params.iteritems():
- param_list.append("%s=%s" % (param, value))
- url += '?' + ' &'.join(param_list)
+ if params:
+ url += '?%s' % urllib.urlencode(params)
+
resp, body = self.get(url)
body = json.loads(body)
return resp, body['floating_ips']
diff --git a/tempest/services/compute/json/images_client.py b/tempest/services/compute/json/images_client.py
index 102590c..999d6cb 100644
--- a/tempest/services/compute/json/images_client.py
+++ b/tempest/services/compute/json/images_client.py
@@ -19,6 +19,7 @@
from tempest import exceptions
import json
import time
+import urllib
class ImagesClientJSON(RestClient):
@@ -50,12 +51,8 @@
def list_images(self, params=None):
"""Returns a list of all images filtered by any parameters"""
url = 'images'
- if params is not None:
- param_list = []
- for param, value in params.iteritems():
- param_list.append("%s=%s&" % (param, value))
-
- url = "images?" + "".join(param_list)
+ if params:
+ url += '?%s' % urllib.urlencode(params)
resp, body = self.get(url)
body = json.loads(body)
@@ -64,12 +61,8 @@
def list_images_with_detail(self, params=None):
"""Returns a detailed list of images filtered by any parameters"""
url = 'images/detail'
- if params is not None:
- param_list = []
- for param, value in params.iteritems():
- param_list.append("%s=%s&" % (param, value))
-
- url = "images/detail?" + "".join(param_list)
+ if params:
+ url += '?%s' % urllib.urlencode(params)
resp, body = self.get(url)
body = json.loads(body)
diff --git a/tempest/services/compute/json/limits_client.py b/tempest/services/compute/json/limits_client.py
index f363bf7..945477a 100644
--- a/tempest/services/compute/json/limits_client.py
+++ b/tempest/services/compute/json/limits_client.py
@@ -26,19 +26,15 @@
auth_url, tenant_name)
self.service = self.config.compute.catalog_type
- def get_limits(self):
+ def get_absolute_limits(self):
resp, body = self.get("limits")
body = json.loads(body)
- return resp, body['limits']
+ return resp, body['limits']['absolute']
- def get_max_server_meta(self):
- resp, limits_dict = self.get_limits()
- return resp, limits_dict['absolute']['maxServerMeta']
-
- def get_personality_file_limit(self):
- resp, limits_dict = self.get_limits()
- return resp, limits_dict['absolute']['maxPersonality']
-
- def get_personality_size_limit(self):
- resp, limits_dict = self.get_limits()
- return resp, limits_dict['absolute']['maxPersonalitySize']
+ def get_specific_absolute_limit(self, absolute_limit):
+ resp, body = self.get("limits")
+ body = json.loads(body)
+ if absolute_limit not in body['limits']['absolute']:
+ return None
+ else:
+ return body['limits']['absolute'][absolute_limit]
diff --git a/tempest/services/compute/json/quotas_client.py b/tempest/services/compute/json/quotas_client.py
new file mode 100644
index 0000000..2cc417f
--- /dev/null
+++ b/tempest/services/compute/json/quotas_client.py
@@ -0,0 +1,36 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+#
+# Copyright 2012 NTT Data
+# 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 QuotasClient(RestClient):
+
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ super(QuotasClient, self).__init__(config, username, password,
+ auth_url, tenant_name)
+ self.service = self.config.compute.catalog_type
+
+ def get_quota_set(self, tenant_id):
+ """List the quota set for a tenant"""
+
+ url = 'os-quota-sets/%s' % str(tenant_id)
+ resp, body = self.get(url)
+ body = json.loads(body)
+ return resp, body['quota_set']
diff --git a/tempest/services/compute/json/security_groups_client.py b/tempest/services/compute/json/security_groups_client.py
index 9d8de23..cf8fed7 100644
--- a/tempest/services/compute/json/security_groups_client.py
+++ b/tempest/services/compute/json/security_groups_client.py
@@ -17,6 +17,7 @@
from tempest.common.rest_client import RestClient
import json
+import urllib
class SecurityGroupsClientJSON(RestClient):
@@ -31,12 +32,8 @@
"""List all security groups for a user"""
url = 'os-security-groups'
- if params is not None:
- param_list = []
- for param, value in params.iteritems():
- param_list.append("%s=%s" % (param, value))
-
- url += '?' + ' &'.join(param_list)
+ if params:
+ url += '?%s' % urllib.urlencode(params)
resp, body = self.get(url)
body = json.loads(body)
diff --git a/tempest/services/compute/json/servers_client.py b/tempest/services/compute/json/servers_client.py
index 94fe637..97ef78e 100644
--- a/tempest/services/compute/json/servers_client.py
+++ b/tempest/services/compute/json/servers_client.py
@@ -19,6 +19,7 @@
from tempest.common.rest_client import RestClient
import json
import time
+import urllib
class ServersClientJSON(RestClient):
@@ -121,12 +122,8 @@
"""Lists all servers for a user"""
url = 'servers'
- if params is not None:
- param_list = []
- for param, value in params.iteritems():
- param_list.append("%s=%s&" % (param, value))
-
- url = "servers?" + "".join(param_list)
+ if params:
+ url += '?%s' % urllib.urlencode(params)
resp, body = self.get(url)
body = json.loads(body)
@@ -136,12 +133,8 @@
"""Lists all servers in detail for a user"""
url = 'servers/detail'
- if params is not None:
- param_list = []
- for param, value in params.iteritems():
- param_list.append("%s=%s&" % (param, value))
-
- url = "servers/detail?" + "".join(param_list)
+ if params:
+ url += '?%s' % urllib.urlencode(params)
resp, body = self.get(url)
body = json.loads(body)
diff --git a/tempest/services/compute/json/volumes_extensions_client.py b/tempest/services/compute/json/volumes_extensions_client.py
index 5ac1124..1c5d525 100644
--- a/tempest/services/compute/json/volumes_extensions_client.py
+++ b/tempest/services/compute/json/volumes_extensions_client.py
@@ -19,6 +19,7 @@
from tempest.common.rest_client import RestClient
import json
import time
+import urllib
class VolumesExtensionsClientJSON(RestClient):
@@ -34,12 +35,8 @@
def list_volumes(self, params=None):
"""List all the volumes created"""
url = 'os-volumes'
- if params is not None:
- param_list = []
- for param, value in params.iteritems():
- param_list.append("%s=%s&" % (param, value))
-
- url += '?' + ' '.join(param_list)
+ if params:
+ url += '?%s' % urllib.urlencode(params)
resp, body = self.get(url)
body = json.loads(body)
@@ -48,21 +45,17 @@
def list_volumes_with_detail(self, params=None):
"""List all the details of volumes"""
url = 'os-volumes/detail'
- if params is not None:
- param_list = []
- for param, value in params.iteritems():
- param_list.append("%s=%s&" % (param, value))
-
- url = '?' + ' '.join(param_list)
+ if params:
+ url += '?%s' % urllib.urlencode(params)
resp, body = self.get(url)
body = json.loads(body)
return resp, body['volumes']
- def get_volume(self, volume_id):
+ def get_volume(self, volume_id, wait=None):
"""Returns the details of a single volume"""
url = "os-volumes/%s" % str(volume_id)
- resp, body = self.get(url)
+ resp, body = self.get(url, wait=wait)
body = json.loads(body)
return resp, body['volume']
@@ -111,7 +104,7 @@
def is_resource_deleted(self, id):
try:
- self.get_volume(id)
+ self.get_volume(id, wait=True)
except exceptions.NotFound:
return True
return False
diff --git a/tempest/services/compute/xml/flavors_client.py b/tempest/services/compute/xml/flavors_client.py
index 63ce267..1dc34a5 100644
--- a/tempest/services/compute/xml/flavors_client.py
+++ b/tempest/services/compute/xml/flavors_client.py
@@ -63,7 +63,7 @@
return [self._format_flavor(xml_to_json(x)) for x in node]
def _list_flavors(self, url, params):
- if params is not None:
+ if params:
url += "?%s" % urllib.urlencode(params)
resp, body = self.get(url, self.headers)
diff --git a/tempest/services/compute/xml/floating_ips_client.py b/tempest/services/compute/xml/floating_ips_client.py
index 2f87926..fcb16d3 100644
--- a/tempest/services/compute/xml/floating_ips_client.py
+++ b/tempest/services/compute/xml/floating_ips_client.py
@@ -16,6 +16,7 @@
# under the License.
from lxml import etree
+import urllib
from tempest.common.rest_client import RestClientXML
from tempest import exceptions
@@ -43,11 +44,8 @@
def list_floating_ips(self, params=None):
"""Returns a list of all floating IPs filtered by any parameters"""
url = 'os-floating-ips'
- if params is not None:
- param_list = []
- for param, value in params.iteritems():
- param_list.append("%s=%s" % (param, value))
- url += "?" + "&".join(param_list)
+ if params:
+ url += '?%s' % urllib.urlencode(params)
resp, body = self.get(url, self.headers)
body = self._parse_array(etree.fromstring(body))
diff --git a/tempest/services/compute/xml/images_client.py b/tempest/services/compute/xml/images_client.py
index 12ad4d4..b9cb220 100644
--- a/tempest/services/compute/xml/images_client.py
+++ b/tempest/services/compute/xml/images_client.py
@@ -89,8 +89,7 @@
"""Returns a list of all images filtered by any parameters"""
url = 'images'
if params:
- param_list = urllib.urlencode(params)
- url += "?" + param_list
+ url += '?%s' % urllib.urlencode(params)
resp, body = self.get(url, self.headers)
body = xml_to_json(etree.fromstring(body))
diff --git a/tempest/services/compute/xml/limits_client.py b/tempest/services/compute/xml/limits_client.py
index 75142a9..229dbee 100644
--- a/tempest/services/compute/xml/limits_client.py
+++ b/tempest/services/compute/xml/limits_client.py
@@ -29,7 +29,7 @@
auth_url, tenant_name)
self.service = self.config.compute.catalog_type
- def get_limits(self):
+ def get_absolute_limits(self):
resp, body = self.get("limits", self.headers)
body = objectify.fromstring(body)
lim = NS + 'absolute'
@@ -37,23 +37,19 @@
for el in body[lim].iterchildren():
attributes = el.attrib
- if attributes['name'] == 'maxServerMeta':
- ret['maxServerMeta'] = int(attributes['value'])
- elif attributes['name'] == 'maxPersonality':
- ret['maxPersonality'] = int(attributes['value'])
- elif attributes['name'] == 'maxPersonalitySize':
- ret['maxPersonalitySize'] = int(attributes['value'])
-
+ ret[attributes['name']] = attributes['value']
return resp, ret
- def get_max_server_meta(self):
- resp, limits_dict = self.get_limits()
- return resp, limits_dict['maxServerMeta']
+ def get_specific_absolute_limit(self, absolute_limit):
+ resp, body = self.get("limits", self.headers)
+ body = objectify.fromstring(body)
+ lim = NS + 'absolute'
+ ret = {}
- def get_personality_file_limit(self):
- resp, limits_dict = self.get_limits()
- return resp, limits_dict['maxPersonality']
-
- def get_personality_size_limit(self):
- resp, limits_dict = self.get_limits()
- return resp, limits_dict['maxPersonalitySize']
+ for el in body[lim].iterchildren():
+ attributes = el.attrib
+ ret[attributes['name']] = attributes['value']
+ if absolute_limit not in ret:
+ return None
+ else:
+ return ret[absolute_limit]
diff --git a/tempest/services/compute/xml/security_groups_client.py b/tempest/services/compute/xml/security_groups_client.py
index 0e35112..bfd6c7a 100644
--- a/tempest/services/compute/xml/security_groups_client.py
+++ b/tempest/services/compute/xml/security_groups_client.py
@@ -16,6 +16,7 @@
# under the License.
from lxml import etree
+import urllib
from tempest.common.rest_client import RestClientXML
from tempest.services.compute.xml.common import Document
@@ -46,12 +47,8 @@
"""List all security groups for a user"""
url = 'os-security-groups'
- if params is not None:
- param_list = []
- for param, value in params.iteritems():
- param_list.append("%s=%s" % (param, value))
-
- url += '?' + ' &'.join(param_list)
+ if params:
+ url += '?%s' % urllib.urlencode(params)
resp, body = self.get(url, self.headers)
body = self._parse_array(etree.fromstring(body))
diff --git a/tempest/services/compute/xml/servers_client.py b/tempest/services/compute/xml/servers_client.py
index d7c88b7..b354fb9 100644
--- a/tempest/services/compute/xml/servers_client.py
+++ b/tempest/services/compute/xml/servers_client.py
@@ -25,6 +25,7 @@
from tempest.services.compute.xml.common import xml_to_json
from tempest.services.compute.xml.common import XMLNS_11
import time
+import urllib
LOG = logging.getLogger(__name__)
@@ -82,24 +83,18 @@
def list_servers(self, params=None):
url = 'servers/detail'
- if params is not None:
- param_list = []
- for param, value in params.iteritems():
- param_list.append("%s=%s" % (param, value))
+ if params:
+ url += '?%s' % urllib.urlencode(params)
- url += "?" + "&".join(param_list)
resp, body = self.get(url, self.headers)
servers = self._parse_array(etree.fromstring(body))
return resp, {"servers": servers}
def list_servers_with_detail(self, params=None):
url = 'servers/detail'
- if params is not None:
- param_list = []
- for param, value in params.iteritems():
- param_list.append("%s=%s" % (param, value))
+ if params:
+ url += '?%s' % urllib.urlencode(params)
- url += "?" + "&".join(param_list)
resp, body = self.get(url, self.headers)
servers = self._parse_array(etree.fromstring(body))
return resp, {"servers": servers}
diff --git a/tempest/services/compute/xml/volumes_extensions_client.py b/tempest/services/compute/xml/volumes_extensions_client.py
index 6869360..871f2e5 100644
--- a/tempest/services/compute/xml/volumes_extensions_client.py
+++ b/tempest/services/compute/xml/volumes_extensions_client.py
@@ -17,6 +17,7 @@
import time
from lxml import etree
+import urllib
from tempest import exceptions
from tempest.common.rest_client import RestClientXML
@@ -79,10 +80,10 @@
volumes += [self._parse_volume(vol) for vol in list(body)]
return resp, volumes
- def get_volume(self, volume_id):
+ def get_volume(self, volume_id, wait=None):
"""Returns the details of a single volume"""
url = "os-volumes/%s" % str(volume_id)
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url, self.headers, wait=wait)
body = etree.fromstring(body)
return resp, self._parse_volume(body)
@@ -139,7 +140,7 @@
def is_resource_deleted(self, id):
try:
- self.get_volume(id)
+ self.get_volume(id, wait=True)
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 4eaeb34..0ab5cd4 100644
--- a/tempest/services/object_storage/account_client.py
+++ b/tempest/services/object_storage/account_client.py
@@ -16,6 +16,7 @@
# under the License.
import json
+import urllib
from tempest.common.rest_client import RestClient
@@ -81,11 +82,9 @@
DEFAULT: Python-List returned in response body
"""
- param_list = ['format=%s&' % self.format]
- if params is not None:
- for param, value in params.iteritems():
- param_list.append("%s=%s&" % (param, value))
- url = '?' + ''.join(param_list)
+ url = '?format=%s' % self.format
+ if params:
+ url += '&%s' + urllib.urlencode(params)
resp, body = self.get(url)
body = json.loads(body)
diff --git a/tempest/services/object_storage/container_client.py b/tempest/services/object_storage/container_client.py
index bb08de2..37a8375 100644
--- a/tempest/services/object_storage/container_client.py
+++ b/tempest/services/object_storage/container_client.py
@@ -16,6 +16,7 @@
# under the License.
import json
+import urllib
from tempest.common.rest_client import RestClient
@@ -36,7 +37,7 @@
Creates a container, with optional metadata passed in as a
dictonary
"""
- url = container_name
+ url = str(container_name)
headers = {}
if metadata is not None:
@@ -48,14 +49,14 @@
def delete_container(self, container_name):
"""Deletes the container (if it's empty)"""
- url = container_name
+ url = str(container_name)
resp, body = self.delete(url)
return resp, body
def update_container_metadata(self, container_name, metadata,
metadata_prefix='X-Container-Meta-'):
"""Updates arbitrary metadata on container"""
- url = container_name
+ url = str(container_name)
headers = {}
if metadata is not None:
@@ -68,7 +69,7 @@
def delete_container_metadata(self, container_name, metadata,
metadata_prefix='X-Remove-Container-Meta-'):
"""Deletes arbitrary metadata on container"""
- url = container_name
+ url = str(container_name)
headers = {}
if metadata is not None:
@@ -82,7 +83,7 @@
"""
Retrieves container metadata headers
"""
- url = container_name
+ url = str(container_name)
headers = {"X-Storage-Token": self.token}
resp, body = self.head(url, headers=headers)
return resp, body
@@ -162,11 +163,9 @@
"""
url = str(container)
- param_list = ['format=%s&' % self.format]
- if params is not None:
- for param, value in params.iteritems():
- param_list.append("%s=%s&" % (param, value))
- url += '?' + ''.join(param_list)
+ url += '?format=%s' % self.format
+ if params:
+ url += '&%s' % urllib.urlencode(params)
resp, body = self.get(url)
body = json.loads(body)
diff --git a/tempest/services/object_storage/object_client.py b/tempest/services/object_storage/object_client.py
index 440d043..c8f63ef 100644
--- a/tempest/services/object_storage/object_client.py
+++ b/tempest/services/object_storage/object_client.py
@@ -69,8 +69,8 @@
resp, body = self.get(url)
return resp, body
- def copy_object(self, container, src_object_name, dest_object_name,
- metadata=None):
+ def copy_object_in_same_container(self, container, src_object_name,
+ dest_object_name, metadata=None):
"""Copy storage object's data to the new object using PUT"""
url = "{0}/{1}".format(container, dest_object_name)
@@ -85,6 +85,23 @@
resp, body = self.put(url, None, headers=headers)
return resp, body
+ def copy_object_across_containers(self, src_container, src_object_name,
+ dst_container, dst_object_name,
+ metadata=None):
+ """Copy storage object's data to the new object using PUT"""
+
+ url = "{0}/{1}".format(dst_container, dst_object_name)
+ headers = {}
+ headers['X-Copy-From'] = "%s/%s" % (str(src_container),
+ str(src_object_name))
+ headers['content-length'] = '0'
+ if metadata:
+ for key in metadata:
+ headers[str(key)] = metadata[key]
+
+ resp, body = self.put(url, None, headers=headers)
+ return resp, body
+
def copy_object_2d_way(self, container, src_object_name, dest_object_name,
metadata=None):
"""Copy storage object's data to the new object using COPY"""
diff --git a/tempest/services/volume/json/volumes_client.py b/tempest/services/volume/json/volumes_client.py
index 6f04e5e..2045f3c 100644
--- a/tempest/services/volume/json/volumes_client.py
+++ b/tempest/services/volume/json/volumes_client.py
@@ -17,6 +17,7 @@
import json
import time
+import urllib
from tempest.common.rest_client import RestClient
from tempest import exceptions
@@ -38,12 +39,9 @@
def list_volumes(self, params=None):
"""List all the volumes created"""
url = 'volumes'
- if params is not None:
- param_list = []
- for param, value in params.iteritems():
- param_list.append("%s=%s&" % (param, value))
+ if params:
+ url += '?%s' % urllib.urlencode(params)
- url += '?' + ' '.join(param_list)
resp, body = self.get(url)
body = json.loads(body)
return resp, body['volumes']
@@ -51,21 +49,17 @@
def list_volumes_with_detail(self, params=None):
"""List the details of all volumes"""
url = 'volumes/detail'
- if params is not None:
- param_list = []
- for param, value in params.iteritems():
- param_list.append("%s=%s&" % (param, value))
-
- url = '?' + ' '.join(param_list)
+ if params:
+ url += '?%s' % urllib.urlencode(params)
resp, body = self.get(url)
body = json.loads(body)
return resp, body['volumes']
- def get_volume(self, volume_id):
+ def get_volume(self, volume_id, wait=None):
"""Returns the details of a single volume"""
url = "volumes/%s" % str(volume_id)
- resp, body = self.get(url)
+ resp, body = self.get(url, wait=wait)
body = json.loads(body)
return resp, body['volume']
@@ -133,7 +127,7 @@
def is_resource_deleted(self, id):
try:
- self.get_volume(id)
+ self.get_volume(id, wait=True)
except exceptions.NotFound:
return True
return False
diff --git a/tempest/services/volume/xml/volumes_client.py b/tempest/services/volume/xml/volumes_client.py
index ef5f3e9..b90c65a 100644
--- a/tempest/services/volume/xml/volumes_client.py
+++ b/tempest/services/volume/xml/volumes_client.py
@@ -16,6 +16,7 @@
# under the License.
import time
+import urllib
from lxml import etree
@@ -82,10 +83,10 @@
volumes += [self._parse_volume(vol) for vol in list(body)]
return resp, volumes
- def get_volume(self, volume_id):
+ def get_volume(self, volume_id, wait=None):
"""Returns the details of a single volume"""
url = "volumes/%s" % str(volume_id)
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url, self.headers, wait=wait)
body = etree.fromstring(body)
return resp, self._parse_volume(body)
@@ -140,7 +141,7 @@
def is_resource_deleted(self, id):
try:
- self.get_volume(id)
+ self.get_volume(id, wait=True)
except exceptions.NotFound:
return True
return False
diff --git a/tempest/tests/boto/__init__.py b/tempest/tests/boto/__init__.py
index 3d5ea6c..11fa077 100644
--- a/tempest/tests/boto/__init__.py
+++ b/tempest/tests/boto/__init__.py
@@ -73,7 +73,6 @@
EC2_CAN_CONNECT_ERROR = "AWS credentials not set," +\
" faild to get them even by keystoneclient"
except Exception as exc:
- logging.exception(exc)
EC2_CAN_CONNECT_ERROR = str(exc)
else:
EC2_CAN_CONNECT_ERROR = None
@@ -88,7 +87,6 @@
if exc.status == 403:
_cred_sub_check(s3client.connection_data)
except Exception as exc:
- logging.exception(exc)
S3_CAN_CONNECT_ERROR = str(exc)
except keystoneclient.exceptions.Unauthorized:
S3_CAN_CONNECT_ERROR = "AWS credentials not set," +\
diff --git a/tempest/tests/boto/test_ec2_security_groups.py b/tempest/tests/boto/test_ec2_security_groups.py
index 4e978e1..3d50e8b 100644
--- a/tempest/tests/boto/test_ec2_security_groups.py
+++ b/tempest/tests/boto/test_ec2_security_groups.py
@@ -39,8 +39,8 @@
group = self.client.create_security_group(group_name,
group_description)
self.addResourceCleanUp(self.client.delete_security_group, group_name)
- groups_get = self.client.get_all_security_groups(groupnames=
- (group_name,))
+ groups_get = self.client.get_all_security_groups(
+ groupnames=(group_name,))
self.assertEqual(len(groups_get), 1)
group_get = groups_get[0]
self.assertEqual(group.name, group_get.name)
@@ -61,8 +61,8 @@
to_port=22)
self.assertTrue(success)
#TODO(afazekas): Duplicate tests
- group_get = self.client.get_all_security_groups(groupnames=
- (group_name,))[0]
+ group_get = self.client.get_all_security_groups(
+ groupnames=(group_name,))[0]
#remove listed rules
for ip_permission in group_get.rules:
for cidr in ip_permission.grants:
@@ -72,7 +72,7 @@
from_port=ip_permission.from_port,
to_port=ip_permission.to_port))
- group_get = self.client.get_all_security_groups(groupnames=
- (group_name,))[0]
+ group_get = self.client.get_all_security_groups(
+ groupnames=(group_name,))[0]
#all rules shuld be removed now
self.assertEqual(0, len(group_get.rules))
diff --git a/tempest/tests/compute/admin/test_quotas.py b/tempest/tests/compute/admin/test_quotas.py
new file mode 100644
index 0000000..98ca169
--- /dev/null
+++ b/tempest/tests/compute/admin/test_quotas.py
@@ -0,0 +1,156 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2012 OpenStack, LLC
+# 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 nose.plugins.attrib import attr
+
+from tempest.tests.compute.base import BaseComputeTest
+from tempest.services.compute.admin.json import quotas_client as adm_quotas
+from tempest import exceptions
+
+
+class QuotasTest(BaseComputeTest):
+
+ @classmethod
+ def setUpClass(cls):
+ super(QuotasTest, cls).setUpClass()
+ adm_user = cls.config.compute_admin.username
+ adm_pass = cls.config.compute_admin.password
+ adm_tenant = cls.config.compute_admin.tenant_name
+ auth_url = cls.config.identity.auth_url
+
+ cls.adm_client = adm_quotas.AdminQuotasClient(cls.config, adm_user,
+ adm_pass, auth_url,
+ adm_tenant)
+ cls.client = cls.os.quotas_client
+ cls.identity_admin_client = cls._get_identity_admin_client()
+ resp, tenants = cls.identity_admin_client.list_tenants()
+
+ if cls.config.compute.allow_tenant_isolation:
+ cls.demo_tenant_id = cls.isolated_creds[0][0]['tenantId']
+ else:
+ cls.demo_tenant_id = [tnt['id'] for tnt in tenants if tnt['name']
+ == cls.config.compute.tenant_name][0]
+
+ cls.adm_tenant_id = [tnt['id'] for tnt in tenants if tnt['name'] ==
+ cls.config.compute_admin.tenant_name][0]
+
+ cls.default_quota_set = {'injected_file_content_bytes': 10240,
+ 'metadata_items': 128, 'injected_files': 5,
+ 'ram': 51200, 'floating_ips': 10,
+ 'key_pairs': 100,
+ 'injected_file_path_bytes': 255,
+ 'instances': 10, 'security_group_rules': 20,
+ 'cores': 20, 'security_groups': 10}
+
+ @classmethod
+ def tearDown(cls):
+ for server in cls.servers:
+ try:
+ cls.servers_client.delete_server(server['id'])
+ except exceptions.NotFound:
+ continue
+
+ @attr(type='smoke')
+ def test_get_default_quotas(self):
+ """Admin can get the default resource quota set for a tenant"""
+ expected_quota_set = self.default_quota_set.copy()
+ expected_quota_set['id'] = self.demo_tenant_id
+ try:
+ resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
+ self.assertEqual(200, resp.status)
+ self.assertSequenceEqual(expected_quota_set, quota_set)
+ except:
+ self.fail("Admin could not get the default quota set for a tenant")
+
+ def test_update_all_quota_resources_for_tenant(self):
+ """Admin can update all the resource quota limits for a tenant"""
+ new_quota_set = {'injected_file_content_bytes': 20480,
+ 'metadata_items': 256, 'injected_files': 10,
+ 'ram': 10240, 'floating_ips': 20, 'key_pairs': 200,
+ 'injected_file_path_bytes': 512, 'instances': 20,
+ 'security_group_rules': 20, 'cores': 2,
+ 'security_groups': 20}
+ try:
+ # Update limits for all quota resources
+ resp, quota_set = self.adm_client.update_quota_set(
+ self.demo_tenant_id,
+ **new_quota_set)
+ self.assertEqual(200, resp.status)
+ self.assertSequenceEqual(new_quota_set, quota_set)
+ except:
+ self.fail("Admin could not update quota set for the tenant")
+ finally:
+ # Reset quota resource limits to default values
+ resp, quota_set = self.adm_client.update_quota_set(
+ self.demo_tenant_id,
+ **self.default_quota_set)
+ self.assertEqual(200, resp.status, "Failed to reset quota "
+ "defaults")
+
+ def test_get_updated_quotas(self):
+ """Verify that GET shows the updated quota set"""
+ self.adm_client.update_quota_set(self.demo_tenant_id,
+ ram='5120')
+ try:
+ resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(quota_set['ram'], 5120)
+ except:
+ self.fail("Could not get the update quota limit for resource")
+ finally:
+ # Reset quota resource limits to default values
+ resp, quota_set = self.adm_client.update_quota_set(
+ self.demo_tenant_id,
+ **self.default_quota_set)
+ self.assertEqual(200, resp.status, "Failed to reset quota "
+ "defaults")
+
+ def test_create_server_when_cpu_quota_is_full(self):
+ """Disallow server creation when tenant's vcpu quota is full"""
+ resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
+ default_vcpu_quota = quota_set['cores']
+ vcpu_quota = 0 # Set the quota to zero to conserve resources
+
+ resp, quota_set = self.adm_client.update_quota_set(self.demo_tenant_id,
+ cores=vcpu_quota)
+ try:
+ self.create_server()
+ except exceptions.OverLimit:
+ pass
+ else:
+ self.fail("Could create servers over the VCPU quota limit")
+ finally:
+ self.adm_client.update_quota_set(self.demo_tenant_id,
+ cores=default_vcpu_quota)
+
+ def test_create_server_when_memory_quota_is_full(self):
+ """Disallow server creation when tenant's memory quota is full"""
+ resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
+ default_mem_quota = quota_set['ram']
+ mem_quota = 0 # Set the quota to zero to conserve resources
+
+ self.adm_client.update_quota_set(self.demo_tenant_id,
+ ram=mem_quota)
+ try:
+ self.create_server()
+ except exceptions.OverLimit:
+ pass
+ else:
+ self.fail("Could create servers over the memory quota limit")
+ finally:
+ self.adm_client.update_quota_set(self.demo_tenant_id,
+ ram=default_mem_quota)
diff --git a/tempest/tests/compute/base.py b/tempest/tests/compute/base.py
index ebf3b54..bb2ff8b 100644
--- a/tempest/tests/compute/base.py
+++ b/tempest/tests/compute/base.py
@@ -17,14 +17,13 @@
import logging
import time
-import nose
import unittest2 as unittest
import nose
from tempest import config
-from tempest import openstack
from tempest import exceptions
+from tempest import openstack
from tempest.common.utils.data_utils import rand_name
__all__ = ['BaseComputeTest', 'BaseComputeTestJSON', 'BaseComputeTestXML',
@@ -61,6 +60,7 @@
cls.keypairs_client = os.keypairs_client
cls.security_groups_client = os.security_groups_client
cls.console_outputs_client = os.console_outputs_client
+ cls.quotas_client = os.quotas_client
cls.limits_client = os.limits_client
cls.volumes_extensions_client = os.volumes_extensions_client
cls.volumes_client = os.volumes_client
@@ -178,10 +178,12 @@
cls.clear_isolated_creds()
@classmethod
- def create_server(cls, image_id=None):
+ def create_server(cls, image_id=None, flavor=None):
"""Wrapper utility that returns a test server"""
server_name = rand_name(cls.__name__ + "-instance")
- flavor = cls.flavor_ref
+
+ if not flavor:
+ flavor = cls.flavor_ref
if not image_id:
image_id = cls.image_ref
diff --git a/tempest/tests/compute/keypairs/test_keypairs.py b/tempest/tests/compute/keypairs/test_keypairs.py
index 95520b5..9d297f6 100644
--- a/tempest/tests/compute/keypairs/test_keypairs.py
+++ b/tempest/tests/compute/keypairs/test_keypairs.py
@@ -137,6 +137,7 @@
self.fail('Expected BadRequest for invalid public key')
@attr(type='negative')
+ @unittest.skip("Skipped until the Bug #1086980 is resolved")
def test_keypair_delete_nonexistant_key(self):
"""Non-existant key deletion should throw a proper error"""
k_name = rand_name("keypair-non-existant-")
diff --git a/tempest/tests/compute/limits/__init__.py b/tempest/tests/compute/limits/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/tests/compute/limits/__init__.py
diff --git a/tempest/tests/compute/limits/test_absolute_limits.py b/tempest/tests/compute/limits/test_absolute_limits.py
new file mode 100644
index 0000000..ede0dc2
--- /dev/null
+++ b/tempest/tests/compute/limits/test_absolute_limits.py
@@ -0,0 +1,68 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2012 OpenStack, LLC
+# 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 unittest2 as unittest
+
+from tempest.tests.compute import base
+
+
+class AbsoluteLimitsTest(object):
+
+ @staticmethod
+ def setUpClass(cls):
+ cls.client = cls.limits_client
+
+ @unittest.skip("Skipped until the Bug #1025294 is resolved")
+ def test_absLimits_get(self):
+ """
+ To check if all limits are present in the response
+ """
+ resp, absolute_limits = self.client.get_absolute_limits()
+ expected_elements = ['maxImageMeta', 'maxPersonality',
+ 'maxPersonalitySize',
+ 'maxPersonalityFilePathSize',
+ 'maxServerMeta', 'maxTotalCores',
+ 'maxTotalFloatingIps', 'maxSecurityGroups',
+ 'maxSecurityGroupRules', 'maxTotalInstances',
+ 'maxTotalKeypairs', 'maxTotalRAMSize',
+ 'maxTotalVolumeGigabytes', 'maxTotalVolumes',
+ 'totalCoresUsed', 'totalFloatingIpsUsed',
+ 'totalSecurityGroupsUsed', 'totalInstancesUsed',
+ 'totalKeyPairsUsed', 'totalRAMUsed',
+ 'totalVolumeGigabytesUsed', 'totalVolumesUsed']
+ # check whether all expected elements exist
+ missing_elements =\
+ [ele for ele in expected_elements if ele not in absolute_limits]
+ self.assertEqual(0, len(missing_elements),
+ "Failed to find element %s in absolute limits list"
+ % ', '.join(ele for ele in missing_elements))
+
+
+class AbsoluteLimitsTestJSON(base.BaseComputeTestJSON,
+ AbsoluteLimitsTest):
+ @classmethod
+ def setUpClass(cls):
+ super(AbsoluteLimitsTestJSON, cls).setUpClass()
+ AbsoluteLimitsTest.setUpClass(cls)
+
+
+class AbsoluteLimitsTestXML(base.BaseComputeTestXML,
+ AbsoluteLimitsTest):
+ @classmethod
+ def setUpClass(cls):
+ super(AbsoluteLimitsTestXML, cls).setUpClass()
+ AbsoluteLimitsTest.setUpClass(cls)
diff --git a/tempest/tests/compute/servers/test_create_server.py b/tempest/tests/compute/servers/test_create_server.py
index 5d6c2ba..461f5e4 100644
--- a/tempest/tests/compute/servers/test_create_server.py
+++ b/tempest/tests/compute/servers/test_create_server.py
@@ -24,6 +24,7 @@
from tempest.common.utils.data_utils import rand_name
from tempest.common.utils.linux.remote_client import RemoteClient
from tempest.tests.compute import base
+from tempest.tests import compute
class ServersTest(object):
@@ -35,6 +36,9 @@
cls.meta = {'hello': 'world'}
cls.accessIPv4 = '1.1.1.1'
cls.accessIPv6 = '::babe:220.12.22.2'
+ # See: http://tools.ietf.org/html/rfc5952 (section 4)
+ # This is the canonicalized form of the above.
+ cls.accessIPv6canon = '::babe:dc0c:1602'
cls.name = rand_name('server')
file_contents = 'This is a test file.'
personality = [{'path': '/etc/test.txt',
@@ -46,7 +50,8 @@
meta=cls.meta,
accessIPv4=cls.accessIPv4,
accessIPv6=cls.accessIPv6,
- personality=personality)
+ personality=personality,
+ disk_config=cls.disk_config)
cls.resp, cls.server_initial = cli_resp
cls.password = cls.server_initial['adminPass']
cls.client.wait_for_server_status(cls.server_initial['id'], 'ACTIVE')
@@ -66,9 +71,9 @@
@attr(type='smoke')
def test_verify_server_details(self):
"""Verify the specified server attributes are set correctly"""
-
self.assertEqual(self.accessIPv4, self.server['accessIPv4'])
- self.assertEqual(self.accessIPv6, self.server['accessIPv6'])
+ self.assertIn(self.server['accessIPv6'],
+ [self.accessIPv6, self.accessIPv6canon])
self.assertEqual(self.name, self.server['name'])
self.assertEqual(self.image_ref, self.server['image']['id'])
self.assertEqual(str(self.flavor_ref), self.server['flavor']['id'])
@@ -116,11 +121,49 @@
self.assertTrue(linux_client.hostname_equals_servername(self.name))
+@attr(type='positive')
+class ServersTestAutoDisk(base.BaseComputeTestJSON,
+ ServersTest):
+ @classmethod
+ def setUpClass(cls):
+ if not compute.DISK_CONFIG_ENABLED:
+ msg = "DiskConfig extension not enabled."
+ raise nose.SkipTest(msg)
+ super(ServersTestAutoDisk, cls).setUpClass()
+ cls.disk_config = 'AUTO'
+ ServersTest.setUpClass(cls)
+
+ @classmethod
+ def tearDownClass(cls):
+ ServersTest.tearDownClass(cls)
+ super(ServersTestAutoDisk, cls).tearDownClass()
+
+
+@attr(type='positive')
+class ServersTestManualDisk(base.BaseComputeTestJSON,
+ ServersTest):
+ @classmethod
+ def setUpClass(cls):
+ if not compute.DISK_CONFIG_ENABLED:
+ msg = "DiskConfig extension not enabled."
+ raise nose.SkipTest(msg)
+ super(ServersTestManualDisk, cls).setUpClass()
+ cls.disk_config = 'MANUAL'
+ ServersTest.setUpClass(cls)
+
+ @classmethod
+ def tearDownClass(cls):
+ ServersTest.tearDownClass(cls)
+ super(ServersTestManualDisk, cls).tearDownClass()
+
+
+@attr(type='smoke')
class ServersTestJSON(base.BaseComputeTestJSON,
ServersTest):
@classmethod
def setUpClass(cls):
super(ServersTestJSON, cls).setUpClass()
+ cls.disk_config = None
ServersTest.setUpClass(cls)
@classmethod
@@ -129,11 +172,13 @@
super(ServersTestJSON, cls).tearDownClass()
+@attr(type='smoke')
class ServersTestXML(base.BaseComputeTestXML,
ServersTest):
@classmethod
def setUpClass(cls):
super(ServersTestXML, cls).setUpClass()
+ cls.disk_config = None
ServersTest.setUpClass(cls)
@classmethod
diff --git a/tempest/tests/compute/servers/test_disk_config.py b/tempest/tests/compute/servers/test_disk_config.py
index a18fabb..1273fe4 100644
--- a/tempest/tests/compute/servers/test_disk_config.py
+++ b/tempest/tests/compute/servers/test_disk_config.py
@@ -36,44 +36,6 @@
cls.client = cls.os.servers_client
@attr(type='positive')
- def test_create_server_with_manual_disk_config(self):
- """A server should be created with manual disk config"""
- name = rand_name('server')
- resp, server = self.client.create_server(name,
- self.image_ref,
- self.flavor_ref,
- disk_config='MANUAL')
-
- #Wait for the server to become active
- self.client.wait_for_server_status(server['id'], 'ACTIVE')
-
- #Verify the specified attributes are set correctly
- resp, server = self.client.get_server(server['id'])
- self.assertEqual('MANUAL', server['OS-DCF:diskConfig'])
-
- #Delete the server
- resp, body = self.client.delete_server(server['id'])
-
- @attr(type='positive')
- def test_create_server_with_auto_disk_config(self):
- """A server should be created with auto disk config"""
- name = rand_name('server')
- resp, server = self.client.create_server(name,
- self.image_ref,
- self.flavor_ref,
- disk_config='AUTO')
-
- #Wait for the server to become active
- self.client.wait_for_server_status(server['id'], 'ACTIVE')
-
- #Verify the specified attributes are set correctly
- resp, server = self.client.get_server(server['id'])
- self.assertEqual('AUTO', server['OS-DCF:diskConfig'])
-
- #Delete the server
- resp, body = self.client.delete_server(server['id'])
-
- @attr(type='positive')
def test_rebuild_server_with_manual_disk_config(self):
"""A server should be rebuilt using the manual disk config option"""
name = rand_name('server')
diff --git a/tempest/tests/compute/servers/test_server_personality.py b/tempest/tests/compute/servers/test_server_personality.py
index a570aec..75457d1 100644
--- a/tempest/tests/compute/servers/test_server_personality.py
+++ b/tempest/tests/compute/servers/test_server_personality.py
@@ -34,8 +34,9 @@
name = rand_name('server')
file_contents = 'This is a test file.'
personality = []
- _, max_file_limit = self.user_client.get_personality_file_limit()
- for i in range(0, max_file_limit + 1):
+ max_file_limit = \
+ self.user_client.get_specific_absolute_limit("maxPersonality")
+ for i in range(0, int(max_file_limit) + 1):
path = 'etc/test' + str(i) + '.txt'
personality.append({'path': path,
'contents': base64.b64encode(file_contents)})
@@ -57,18 +58,16 @@
name = rand_name('server')
file_contents = 'This is a test file.'
- cli_resp = self.user_client.get_personality_file_limit()
- resp, max_file_limit = cli_resp
- self.assertEqual(200, resp.status)
+ max_file_limit = \
+ self.user_client.get_specific_absolute_limit("maxPersonality")
personality = []
- for i in range(0, max_file_limit):
+ for i in range(0, int(max_file_limit)):
path = 'etc/test' + str(i) + '.txt'
personality.append({
'path': path,
'contents': base64.b64encode(file_contents),
})
-
resp, server = self.client.create_server(name, self.image_ref,
self.flavor_ref,
personality=personality)
diff --git a/tempest/tests/compute/servers/test_servers.py b/tempest/tests/compute/servers/test_servers.py
index 4132b02..c534829 100644
--- a/tempest/tests/compute/servers/test_servers.py
+++ b/tempest/tests/compute/servers/test_servers.py
@@ -31,6 +31,7 @@
"""
try:
+ server = None
name = rand_name('server')
resp, server = self.client.create_server(name, self.image_ref,
self.flavor_ref,
@@ -41,12 +42,15 @@
#Teardown
finally:
- self.client.delete_server(server['id'])
+ if server:
+ self.client.delete_server(server['id'])
def test_create_with_existing_server_name(self):
"""Creating a server with a name that already exists is allowed"""
try:
+ id1 = None
+ id2 = None
server_name = rand_name('server')
resp, server = self.client.create_server(server_name,
self.image_ref,
@@ -74,6 +78,7 @@
"""Specify a keypair while creating a server"""
try:
+ server = None
key_name = rand_name('key')
resp, keypair = self.keypairs_client.create_keypair(key_name)
resp, body = self.keypairs_client.list_keypairs()
@@ -94,6 +99,7 @@
def test_update_server_name(self):
"""The server name should be changed to the the provided value"""
try:
+ server = None
name = rand_name('server')
resp, server = self.client.create_server(name, self.image_ref,
self.flavor_ref)
@@ -111,7 +117,8 @@
#Teardown
finally:
- self.client.delete_server(server['id'])
+ if server:
+ self.client.delete_server(server['id'])
@attr(type='positive')
def test_update_access_server_address(self):
@@ -119,6 +126,7 @@
The server's access addresses should reflect the provided values
"""
try:
+ server = None
name = rand_name('server')
resp, server = self.client.create_server(name, self.image_ref,
self.flavor_ref)
@@ -138,7 +146,8 @@
#Teardown
finally:
- self.client.delete_server(server['id'])
+ if server:
+ self.client.delete_server(server['id'])
def test_delete_server_while_in_building_state(self):
"""Delete a server while it's VM state is Building"""
diff --git a/tempest/tests/compute/test_authorization.py b/tempest/tests/compute/test_authorization.py
index 12fa94b..0d08c18 100644
--- a/tempest/tests/compute/test_authorization.py
+++ b/tempest/tests/compute/test_authorization.py
@@ -232,6 +232,7 @@
@raises(exceptions.NotFound)
@attr(type='negative')
+ @unittest.skip("Skipped until the Bug #1086980 is resolved")
def test_delete_keypair_of_alt_account_fails(self):
"""A DELETE request for another user's keypair should fail"""
self.alt_keypairs_client.delete_keypair(self.keypairname)
diff --git a/tempest/tests/compute/test_quotas.py b/tempest/tests/compute/test_quotas.py
new file mode 100644
index 0000000..d07064f
--- /dev/null
+++ b/tempest/tests/compute/test_quotas.py
@@ -0,0 +1,49 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2012 OpenStack, LLC
+# 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 nose.plugins.attrib import attr
+
+from tempest.tests.compute.base import BaseComputeTest
+
+
+class QuotasTest(BaseComputeTest):
+
+ @classmethod
+ def setUpClass(cls):
+ super(QuotasTest, cls).setUpClass()
+ cls.client = 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]
+
+ @attr(type='smoke')
+ def test_get_default_quotas(self):
+ """User can get the default quota set for it's tenant"""
+ expected_quota_set = {'injected_file_content_bytes': 10240,
+ 'metadata_items': 128, 'injected_files': 5,
+ 'ram': 51200, 'floating_ips': 10,
+ 'key_pairs': 100,
+ 'injected_file_path_bytes': 255, 'instances': 10,
+ 'security_group_rules': 20, 'cores': 20,
+ 'id': self.tenant_id, 'security_groups': 10}
+ try:
+ resp, quota_set = self.client.get_quota_set(self.tenant_id)
+ self.assertEqual(200, resp.status)
+ self.assertSequenceEqual(expected_quota_set, quota_set)
+ except:
+ self.fail("Quota set for tenant did not have default limits")
diff --git a/tempest/tests/compute/volumes/test_volumes_get.py b/tempest/tests/compute/volumes/test_volumes_get.py
index e80e5b9..0a207b9 100644
--- a/tempest/tests/compute/volumes/test_volumes_get.py
+++ b/tempest/tests/compute/volumes/test_volumes_get.py
@@ -26,6 +26,7 @@
@attr(type='smoke')
def test_volume_create_get_delete(self):
"""CREATE, GET, DELETE Volume"""
+ volume = None
try:
v_name = rand_name('Volume-%s-') % self._interface
metadata = {'Type': 'work'}
@@ -61,11 +62,12 @@
'from the created Volume')
finally:
- #Delete the Volume created in this method
- resp, _ = self.client.delete_volume(volume['id'])
- self.assertEqual(202, resp.status)
- #Checking if the deleted Volume still exists
- self.client.wait_for_resource_deletion(volume['id'])
+ if volume:
+ #Delete the Volume created in this method
+ resp, _ = self.client.delete_volume(volume['id'])
+ self.assertEqual(202, resp.status)
+ #Checking if the deleted Volume still exists
+ self.client.wait_for_resource_deletion(volume['id'])
@attr(type='positive')
def test_volume_get_metadata_none(self):
diff --git a/tempest/tests/object_storage/test_object_services.py b/tempest/tests/object_storage/test_object_services.py
index d0862eb..97b7e0d 100644
--- a/tempest/tests/object_storage/test_object_services.py
+++ b/tempest/tests/object_storage/test_object_services.py
@@ -122,7 +122,7 @@
self.assertEqual(body, data)
@attr(type='smoke')
- def test_copy_object(self):
+ def test_copy_object_in_same_container(self):
"""Copy storage object"""
# Create source Object
@@ -140,9 +140,8 @@
dst_object_name, dst_data)
# Copy source object to destination
- resp, _ = self.object_client.copy_object(self.container_name,
- src_object_name,
- dst_object_name)
+ resp, _ = self.object_client.copy_object_in_same_container(
+ self.container_name, src_object_name, dst_object_name)
self.assertEqual(resp['status'], '201')
# Check data
@@ -161,15 +160,13 @@
object_name, data)
# Get the old content type
resp_tmp, _ = self.object_client.list_object_metadata(
- self.container_name,
- object_name)
+ self.container_name,
+ object_name)
# Change the content type of the object
metadata = {'content-type': 'text/plain; charset=UTF-8'}
self.assertNotEqual(resp_tmp['content-type'], metadata['content-type'])
- resp, _ = self.object_client.copy_object(self.container_name,
- object_name,
- object_name,
- metadata)
+ resp, _ = self.object_client.copy_object_in_same_container(
+ self.container_name, object_name, object_name, metadata)
self.assertEqual(resp['status'], '201')
# Check the content type
@@ -205,3 +202,62 @@
resp, body = self.object_client.get_object(self.container_name,
dst_object_name)
self.assertEqual(body, src_data)
+
+ @attr(type='smoke')
+ def test_copy_object_across_containers(self):
+ """Copy storage object across containers"""
+
+ #Create a container so as to use as source container
+ src_container_name = rand_name(name='TestSourceContainer')
+ self.container_client.create_container(src_container_name)
+
+ #Create a container so as to use as destination container
+ dst_container_name = rand_name(name='TestDestinationContainer')
+ self.container_client.create_container(dst_container_name)
+
+ # Create Object in source container
+ object_name = rand_name(name='Object')
+ data = arbitrary_string(size=len(object_name) * 2,
+ base_text=object_name)
+ resp, _ = self.object_client.create_object(src_container_name,
+ object_name, data)
+ #Set Object Metadata
+ meta_key = rand_name(name='test-')
+ meta_value = rand_name(name='MetaValue-')
+ orig_metadata = {meta_key: meta_value}
+
+ resp, _ = \
+ self.object_client.update_object_metadata(src_container_name,
+ object_name,
+ orig_metadata)
+ self.assertEqual(resp['status'], '202')
+
+ try:
+ # Copy object from source container to destination container
+ resp, _ = self.object_client.copy_object_across_containers(
+ src_container_name, object_name, dst_container_name,
+ object_name)
+ self.assertEqual(resp['status'], '201')
+
+ # Check if object is present in destination container
+ resp, body = self.object_client.get_object(dst_container_name,
+ object_name)
+ self.assertEqual(body, data)
+ actual_meta_key = 'x-object-meta-' + meta_key
+ self.assertTrue(actual_meta_key in resp)
+ self.assertEqual(resp[actual_meta_key], meta_value)
+
+ except Exception as e:
+ self.fail("Got exception :%s ; while copying"
+ " object across containers" % e)
+ finally:
+ #Delete objects from respective containers
+ resp, _ = self.object_client.delete_object(dst_container_name,
+ object_name)
+ resp, _ = self.object_client.delete_object(src_container_name,
+ object_name)
+ #Delete containers created in this method
+ resp, _ = self.container_client.delete_container(
+ src_container_name)
+ resp, _ = self.container_client.delete_container(
+ dst_container_name)
diff --git a/tempest/tests/object_storage/test_object_version.py b/tempest/tests/object_storage/test_object_version.py
new file mode 100644
index 0000000..a291ae7
--- /dev/null
+++ b/tempest/tests/object_storage/test_object_version.py
@@ -0,0 +1,114 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2012 OpenStack, LLC
+# 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 nose.plugins.attrib import attr
+from tempest.common.utils.data_utils import rand_name
+from tempest.tests.object_storage import base
+
+
+class ContainerTest(base.BaseObjectTest):
+
+ @classmethod
+ def setUpClass(cls):
+ super(ContainerTest, cls).setUpClass()
+ cls.containers = []
+
+ @classmethod
+ def tearDownClass(cls):
+ for container in cls.containers:
+ #Get list of all object in the container
+ objlist = \
+ cls.container_client.list_all_container_objects(container)
+
+ #Attempt to delete every object in the container
+ for obj in objlist:
+ resp, _ = \
+ cls.object_client.delete_object(container, obj['name'])
+
+ #Attempt to delete the container
+ resp, _ = cls.container_client.delete_container(container)
+
+ def assertContainer(self, container, count, byte, versioned):
+ resp, _ = self.container_client.list_container_metadata(container)
+ self.assertEqual(resp['status'], ('204'))
+ header_value = resp.get('x-container-object-count', 'Missing Header')
+ self.assertEqual(header_value, count)
+ header_value = resp.get('x-container-bytes-used', 'Missing Header')
+ self.assertEqual(header_value, byte)
+ header_value = resp.get('x-versions-location', 'Missing Header')
+ self.assertEqual(header_value, versioned)
+
+ @attr(type='smoke')
+ def test_versioned_container(self):
+ """Versioned container responses tests"""
+
+ # Create a containers
+ vers_container_name = rand_name(name='TestVersionContainer')
+ resp, body = self.container_client.create_container(
+ vers_container_name)
+ self.containers.append(vers_container_name)
+ self.assertIn(resp['status'], ('202', '201'))
+ self.assertContainer(vers_container_name, '0', '0',
+ 'Missing Header')
+
+ base_container_name = rand_name(name='TestBaseContainer')
+ headers = {'X-versions-Location': vers_container_name}
+ resp, body = self.container_client.create_container(
+ base_container_name,
+ metadata=headers,
+ metadata_prefix='')
+ self.containers.append(base_container_name)
+ self.assertIn(resp['status'], ('202', '201'))
+ self.assertContainer(base_container_name, '0', '0',
+ vers_container_name)
+ # Create Object
+ object_name = rand_name(name='TestObject')
+ resp, _ = self.object_client.create_object(base_container_name,
+ object_name, '1')
+
+ resp, _ = self.object_client.create_object(base_container_name,
+ object_name, '2')
+
+ resp, body = self.object_client.get_object(base_container_name,
+ object_name)
+ self.assertEqual(body, '2')
+ # Delete Object version 2
+ resp, _ = self.object_client.delete_object(base_container_name,
+ object_name)
+ self.assertContainer(base_container_name, '1', '1',
+ vers_container_name)
+ resp, body = self.object_client.get_object(base_container_name,
+ object_name)
+ self.assertEqual(body, '1')
+
+ # Delete Object version 1
+ resp, _ = self.object_client.delete_object(base_container_name,
+ object_name)
+ # Containers are Empty
+ self.assertContainer(base_container_name, '0', '0',
+ vers_container_name)
+ self.assertContainer(vers_container_name, '0', '0',
+ 'Missing Header')
+
+ # Delete Containers
+ resp, _ = self.container_client.delete_container(base_container_name)
+ self.assertEqual(resp['status'], '204')
+ self.containers.remove(base_container_name)
+
+ resp, _ = self.container_client.delete_container(vers_container_name)
+ self.assertEqual(resp['status'], '204')
+ self.containers.remove(vers_container_name)
diff --git a/tools/pip-requires b/tools/pip-requires
index 9c861d9..e9baed5 100644
--- a/tools/pip-requires
+++ b/tools/pip-requires
@@ -1,7 +1,6 @@
anyjson
nose
httplib2>=0.7.0
-pika
unittest2
lxml
boto>=2.2.1