Merge "Empty Body testing according to the RFC2616"
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/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 c5d5c7e..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
@@ -62,24 +64,10 @@
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/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/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/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_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/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