Merge "Check images by ids, not by count. lp#1088515"
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/HACKING b/HACKING
deleted file mode 100644
index c2c403b..0000000
--- a/HACKING
+++ /dev/null
@@ -1,14 +0,0 @@
-Test Data/Configuration
------------------------
-- Assume nothing about existing test data
-- Tests should be self contained (provide their own data)
-- Clean up test data at the completion of each test
-- Use configuration files for values that will vary by environment
-
-General
--------
-- Put two newlines between top-level code (funcs, classes, etc)
-- Put one newline between methods in classes and anywhere else
-- Do not write "except:", use "except Exception:" at the very least
-- Include your name with TODOs as in "#TODO(termie)"
-- Do not name anything the same name as a built-in or reserved word
\ No newline at end of file
diff --git a/HACKING.rst b/HACKING.rst
new file mode 100644
index 0000000..103f8cd
--- /dev/null
+++ b/HACKING.rst
@@ -0,0 +1,195 @@
+Test Data/Configuration
+-----------------------
+- Assume nothing about existing test data
+- Tests should be self contained (provide their own data)
+- Clean up test data at the completion of each test
+- Use configuration files for values that will vary by environment
+
+
+General
+-------
+- Put two newlines between top-level code (funcs, classes, etc)
+- Put one newline between methods in classes and anywhere else
+- Long lines should be wrapped in parentheses
+ in preference to using a backslash for line continuation.
+- Do not write "except:", use "except Exception:" at the very least
+- Include your name with TODOs as in "#TODO(termie)"
+- Do not name anything the same name as a built-in or reserved word Example::
+
+ def list():
+ return [1, 2, 3]
+
+ mylist = list() # BAD, shadows `list` built-in
+
+ class Foo(object):
+ def list(self):
+ return [1, 2, 3]
+
+ mylist = Foo().list() # OKAY, does not shadow built-in
+
+Imports
+-------
+- Do not import objects, only modules (*)
+- Do not import more than one module per line (*)
+- Do not make relative imports
+- Order your imports by the full module path
+- Organize your imports according to the following template
+
+Example::
+
+ # vim: tabstop=4 shiftwidth=4 softtabstop=4
+ {{stdlib imports in human alphabetical order}}
+ \n
+ {{third-party lib imports in human alphabetical order}}
+ \n
+ {{tempest imports in human alphabetical order}}
+ \n
+ \n
+ {{begin your code}}
+
+
+Human Alphabetical Order Examples
+---------------------------------
+Example::
+
+ import httplib
+ import logging
+ import random
+ import StringIO
+ import time
+ import unittest
+
+ import eventlet
+ import webob.exc
+
+ import tempest.config
+ from tempest.services.compute.json.limits_client import LimitsClientJSON
+ from tempest.services.compute.xml.limits_client import LimitsClientXML
+ from tempest.services.volume.volumes_client import VolumesClientJSON
+ import tempest.test
+
+
+Docstrings
+----------
+Example::
+
+ """A one line docstring looks like this and ends in a period."""
+
+
+ """A multi line docstring has a one-line summary, less than 80 characters.
+
+ Then a new paragraph after a newline that explains in more detail any
+ general information about the function, class or method. Example usages
+ are also great to have here if it is a complex class for function.
+
+ When writing the docstring for a class, an extra line should be placed
+ after the closing quotations. For more in-depth explanations for these
+ decisions see http://www.python.org/dev/peps/pep-0257/
+
+ If you are going to describe parameters and return values, use Sphinx, the
+ appropriate syntax is as follows.
+
+ :param foo: the foo parameter
+ :param bar: the bar parameter
+ :returns: return_type -- description of the return value
+ :returns: description of the return value
+ :raises: AttributeError, KeyError
+ """
+
+
+Dictionaries/Lists
+------------------
+If a dictionary (dict) or list object is longer than 80 characters, its items
+should be split with newlines. Embedded iterables should have their items
+indented. Additionally, the last item in the dictionary should have a trailing
+comma. This increases readability and simplifies future diffs.
+
+Example::
+
+ my_dictionary = {
+ "image": {
+ "name": "Just a Snapshot",
+ "size": 2749573,
+ "properties": {
+ "user_id": 12,
+ "arch": "x86_64",
+ },
+ "things": [
+ "thing_one",
+ "thing_two",
+ ],
+ "status": "ACTIVE",
+ },
+ }
+
+
+Calling Methods
+---------------
+Calls to methods 80 characters or longer should format each argument with
+newlines. This is not a requirement, but a guideline::
+
+ unnecessarily_long_function_name('string one',
+ 'string two',
+ kwarg1=constants.ACTIVE,
+ kwarg2=['a', 'b', 'c'])
+
+
+Rather than constructing parameters inline, it is better to break things up::
+
+ list_of_strings = [
+ 'what_a_long_string',
+ 'not as long',
+ ]
+
+ dict_of_numbers = {
+ 'one': 1,
+ 'two': 2,
+ 'twenty four': 24,
+ }
+
+ object_one.call_a_method('string three',
+ 'string four',
+ kwarg1=list_of_strings,
+ kwarg2=dict_of_numbers)
+
+
+OpenStack Trademark
+-------------------
+
+OpenStack is a registered trademark of OpenStack, LLC, and uses the
+following capitalization:
+
+ OpenStack
+
+
+Commit Messages
+---------------
+Using a common format for commit messages will help keep our git history
+readable. Follow these guidelines:
+
+ First, provide a brief summary (it is recommended to keep the commit title
+ under 50 chars).
+
+ The first line of the commit message should provide an accurate
+ description of the change, not just a reference to a bug or
+ blueprint. It must be followed by a single blank line.
+
+ If the change relates to a specific driver (libvirt, xenapi, qpid, etc...),
+ begin the first line of the commit message with the driver name, lowercased,
+ followed by a colon.
+
+ Following your brief summary, provide a more detailed description of
+ the patch, manually wrapping the text at 72 characters. This
+ description should provide enough detail that one does not have to
+ refer to external resources to determine its high-level functionality.
+
+ Once you use 'git review', two lines will be appended to the commit
+ message: a blank line followed by a 'Change-Id'. This is important
+ to correlate this commit with a specific review in Gerrit, and it
+ should not be modified.
+
+For further information on constructing high quality commit messages,
+and how to split up commits into a series of changes, consult the
+project wiki:
+
+ http://wiki.openstack.org/GitCommitMessages
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..cc91716 100644
--- a/etc/tempest.conf.sample
+++ b/etc/tempest.conf.sample
@@ -134,6 +134,11 @@
# performed, which requires XenServer pools in case of using XS)
use_block_migration_for_live_migration = false
+# By default, rely on the status of the diskConfig extension to
+# decide if to execute disk config tests. When set to false, tests
+# are forced to skip, regardless of the extension status
+disk_config_enabled_override = true
+
[image]
# This section contains configuration options used when executing tests
# against the OpenStack Images API
@@ -210,12 +215,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
@@ -261,6 +262,9 @@
#TCP/IP connection timeout
http_socket_timeout = 5
+#Number of retries actions on connection or 5xx error
+num_retries = 1
+
# Status change wait timout
build_timeout = 120
diff --git a/etc/tempest.conf.tpl b/etc/tempest.conf.tpl
deleted file mode 100644
index 880a3c1..0000000
--- a/etc/tempest.conf.tpl
+++ /dev/null
@@ -1,238 +0,0 @@
-[identity]
-# This section contains configuration options that a variety of Tempest
-# test clients use when authenticating with different user/tenant
-# combinations
-
-# Set to True if your test environment's Keystone authentication service should
-# be accessed over HTTPS
-use_ssl = %IDENTITY_USE_SSL%
-# This is the main host address of the authentication service API
-host = %IDENTITY_HOST%
-# Port that the authentication service API is running on
-port = %IDENTITY_PORT%
-# Version of the authentication service API (a string)
-api_version = %IDENTITY_API_VERSION%
-# Path to the authentication service tokens resource (do not modify unless you
-# have a custom authentication API and are not using Keystone)
-path = %IDENTITY_PATH%
-# Should typically be left as keystone unless you have a non-Keystone
-# authentication API service
-strategy = %IDENTITY_STRATEGY%
-
-[compute]
-# This section contains configuration options used when executing tests
-# against the OpenStack Compute API.
-
-# Allows test cases to create/destroy tenants and users. This option
-# enables isolated test cases and better parallel execution,
-# but also requires that OpenStack Identity API admin credentials
-# are known.
-allow_tenant_isolation = %COMPUTE_ALLOW_TENANT_ISOLATION%
-
-# Allows test cases to create/destroy tenants and users. This option
-# enables isolated test cases and better parallel execution,
-# but also requires that OpenStack Identity API admin credentials
-# are known.
-allow_tenant_reuse = %COMPUTE_ALLOW_TENANT_REUSE%
-
-# 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%
-
-# This should be the username of an alternate user WITHOUT
-# administrative privileges
-alt_username = %ALT_USERNAME%
-# The above non-administrative user's password
-alt_password = %ALT_PASSWORD%
-# The above non-administrative user's tenant name
-alt_tenant_name = %ALT_TENANT_NAME%
-
-# Reference data for tests. The ref and ref_alt should be
-# distinct images/flavors.
-image_ref = %IMAGE_ID%
-image_ref_alt = %IMAGE_ID_ALT%
-flavor_ref = %FLAVOR_REF%
-flavor_ref_alt = %FLAVOR_REF_ALT%
-
-# Number of seconds to wait while looping to check the status of an
-# instance that is building.
-build_interval = %COMPUTE_BUILD_INTERVAL%
-
-# Number of seconds to time out on waiting for an instance
-# to build or reach an expected status
-build_timeout = %COMPUTE_BUILD_TIMEOUT%
-
-# The type of endpoint for a Compute API service. Unless you have a
-# custom Keystone service catalog implementation, you probably want to leave
-# this value as "compute"
-catalog_type = %COMPUTE_CATALOG_TYPE%
-
-# Does the Compute API support creation of images?
-create_image_enabled = %COMPUTE_CREATE_IMAGE_ENABLED%
-
-# For resize to work with libvirt/kvm, one of the following must be true:
-# Single node: allow_resize_to_same_host=True must be set in nova.conf
-# Cluster: the 'nova' user must have scp access between cluster nodes
-resize_available = %COMPUTE_RESIZE_AVAILABLE%
-
-# Does the compute API support changing the admin password?
-change_password_available = %COMPUTE_CHANGE_PASSWORD_AVAILABLE%
-
-# Level to log Compute API request/response details.
-log_level = %COMPUTE_LOG_LEVEL%
-
-# Whitebox options for compute. Whitebox options enable the
-# whitebox test cases, which look at internal Nova database state,
-# SSH into VMs to check instance state, etc.
-
-# Should we run whitebox tests for Compute?
-whitebox_enabled = %COMPUTE_WHITEBOX_ENABLED%
-
-# Path of nova source directory
-source_dir = %COMPUTE_SOURCE_DIR%
-
-# Path of nova configuration file
-config_path = %COMPUTE_CONFIG_PATH%
-
-# Directory containing nova binaries such as nova-manage
-bin_dir = %COMPUTE_BIN_DIR%
-
-# Path to a private key file for SSH access to remote hosts
-path_to_private_key = %COMPUTE_PATH_TO_PRIVATE_KEY%
-
-# Connection string to the database of Compute service
-db_uri = %COMPUTE_DB_URI%
-
-# Run live migration tests (requires 2 hosts)
-live_migration_available = %LIVE_MIGRATION_AVAILABLE%
-
-# Use block live migration (Otherwise, non-block migration will be
-# performed, which requires XenServer pools in case of using XS)
-use_block_migration_for_live_migration = %USE_BLOCK_MIGRATION_FOR_LIVE_MIGRATION%
-
-[image]
-# This section contains configuration options used when executing tests
-# against the OpenStack Images API
-
-# The type of endpoint for an Image API service. Unless you have a
-# custom Keystone service catalog implementation, you probably want to leave
-# this value as "image"
-catalog_type = %IMAGE_CATALOG_TYPE%
-
-# The version of the OpenStack Images API to use
-api_version = %IMAGE_API_VERSION%
-
-# This is the main host address of the Image API
-host = %IMAGE_HOST%
-
-# Port that the Image API is running on
-port = %IMAGE_PORT%
-
-# 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%
-
-[compute-admin]
-# This section contains configuration options for an administrative
-# user of the Compute API. These options are used in tests that stress
-# the admin-only parts of the Compute API
-
-# This should be the username of a user WITH administrative privileges
-username = %COMPUTE_ADMIN_USERNAME%
-# The above administrative user's password
-password = %COMPUTE_ADMIN_PASSWORD%
-# The above administrative user's tenant name
-tenant_name = %COMPUTE_ADMIN_TENANT_NAME%
-
-[identity-admin]
-# This section contains configuration options for an administrative
-# user of the Compute API. These options are used in tests that stress
-# the admin-only parts of the Compute API
-
-# This should be the username of a user WITH administrative privileges
-username = %IDENTITY_ADMIN_USERNAME%
-# The above administrative user's password
-password = %IDENTITY_ADMIN_PASSWORD%
-# The above administrative user's tenant name
-tenant_name = %IDENTITY_ADMIN_TENANT_NAME%
-
-[volume]
-# This section contains the configuration options used when executing tests
-# against the OpenStack Block Storage API service
-
-# The type of endpoint for a Cinder or Block Storage API service.
-# Unless you have a custom Keystone service catalog implementation, you
-# probably want to leave this value as "volume"
-catalog_type = %VOLUME_CATALOG_TYPE%
-# Number of seconds to wait while looping to check the status of a
-# volume that is being made available
-build_interval = %VOLUME_BUILD_INTERVAL%
-# Number of seconds to time out on waiting for a volume
-# to be available or reach an expected status
-build_timeout = %VOLUME_BUILD_TIMEOUT%
-
-[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 = %USERNAME%
-# The above non-administrative user's password
-password = %PASSWORD%
-# The above non-administrative user's tenant name
-tenant_name = %TENANT_NAME%
-
-# The type of endpoint for an Object Storage API service. Unless you have a
-# custom Keystone service catalog implementation, you probably want to leave
-# this value as "object-store"
-catalog_type = %OBJECT_CATALOG_TYPE%
-
-[boto]
-# This section contains configuration options used when executing tests
-# with boto.
-
-# EC2 URL
-ec2_url = %BOTO_EC2_URL%
-# S3 URL
-s3_url = %BOTO_S3_URL%
-
-# Use keystone ec2-* command to get those values for your test user and tenant
-aws_access = %BOTO_AWS_ACCESS%
-aws_secret = %BOTO_AWS_SECRET%
-
-#Region
-aws_region = %BOTO_AWS_REGION%
-
-#Image materials for S3 upload
-# ALL content of the specified directory will be uploaded to S3
-s3_materials_path = %BOTO_S3_MATERIALS_PATH%
-
-# The manifest.xml files, must be in the s3_materials_path directory
-# Subdirectories not allowed!
-# The filenames will be used as a Keys in the S3 Buckets
-
-#ARI Ramdisk manifest. Must be in the above s3_materials_path directory
-ari_manifest = %BOTO_ARI_MANIFEST%
-
-#AMI Machine Image manifest. Must be in the above s3_materials_path directory
-ami_manifest = %BOTO_AMI_MANIFEST%
-
-#AKI Kernel Image manifest, Must be in the above s3_materials_path directory
-aki_manifest = %BOTO_AKI_MANIFEST%
-
-#Instance type
-instance_type = %BOTO_FLAVOR_NAME%
-
-#TCP/IP connection timeout
-http_socket_timeout = %BOTO_SOCKET_TIMEOUT%
-
-# Status change wait timout
-build_timeout = %BOTO_BUILD_TIMEOUT%
-
-# Status change wait interval
-build_interval = %BOTO_BUILD_INTERVAL%
diff --git a/run_tests.sh b/run_tests.sh
index e359caf..7016a30 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]..."
@@ -52,10 +52,13 @@
function run_pep8 {
echo "Running pep8 ..."
- PEP8_EXCLUDE="etc,include,tools,*venv"
- PEP8_OPTIONS="--exclude=$PEP8_EXCLUDE --repeat"
- PEP8_INCLUDE="."
- pep8 $PEP8_OPTIONS $PEP8_INCLUDE
+ srcfiles="`find tempest -type f -name "*.py"`"
+ srcfiles+=" `find tools -type f -name "*.py"`"
+ srcfiles+=" setup.py"
+
+ ignore='--ignore=N4,E121,E122,E125,E126'
+
+ python tools/hacking.py ${ignore} ${srcfiles}
}
NOSETESTS="nosetests $noseargs"
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/stress/driver.py b/stress/driver.py
index 3032d58..c50e957 100644
--- a/stress/driver.py
+++ b/stress/driver.py
@@ -15,19 +15,18 @@
Users pass in a description of the workload and a nova manager object
to the bash_openstack function call"""
-
-import random
import datetime
+import random
import time
-
-# local imports
-from test_case import *
-import utils.util
from config import StressConfig
-from state import ClusterState, KeyPairState, FloatingIpState, VolumeState
+from state import ClusterState
+from state import FloatingIpState
+from state import KeyPairState
+from state import VolumeState
+from test_case import *
from tempest.common.utils.data_utils import rand_name
-
+import utils.util
# setup logging to file
logging.basicConfig(
diff --git a/stress/pending_action.py b/stress/pending_action.py
index a2d5a6b..635d2cc 100644
--- a/stress/pending_action.py
+++ b/stress/pending_action.py
@@ -14,9 +14,9 @@
"""Describe follow-up actions using `PendingAction` class to verify
that nova API calls such as create/delete are completed"""
-
import logging
import time
+
from tempest.exceptions import TimeoutException
diff --git a/stress/test_floating_ips.py b/stress/test_floating_ips.py
index 302385a..fcc5904 100755
--- a/stress/test_floating_ips.py
+++ b/stress/test_floating_ips.py
@@ -12,16 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-
-# system imports
-import random
-import time
-import telnetlib
import logging
+import random
+import telnetlib
+import time
-# local imports
-import test_case
import pending_action
+import test_case
class TestChangeFloatingIp(test_case.StressTestCase):
@@ -85,7 +82,7 @@
(self.floating_ip.address, self.elapsed()))
self.floating_ip.change_pending = False
return True
- except:
+ except Exception:
if not self.add:
self._logger.info('%s removed [%.1f secs elapsed]' %
(self.floating_ip.address, self.elapsed()))
diff --git a/stress/test_server_actions.py b/stress/test_server_actions.py
index 58350ac..ca66dec 100644
--- a/stress/test_server_actions.py
+++ b/stress/test_server_actions.py
@@ -17,15 +17,12 @@
sub-class will have a corresponding PendingServerAction. These pending
actions veriy that the API call was successful or not."""
-
-# system imports
import random
import time
-# local imports
-import test_case
import pending_action
from tempest.exceptions import Duplicate
+import test_case
from utils.util import *
diff --git a/stress/test_servers.py b/stress/test_servers.py
index 113e5cb..9957cdb 100644
--- a/stress/test_servers.py
+++ b/stress/test_servers.py
@@ -17,15 +17,11 @@
Each sub-class will have a corresponding PendingServerAction. These pending
actions veriy that the API call was successful or not."""
-
-# system imports
import random
import time
-
-# local imports
-import test_case
import pending_action
+import test_case
class TestCreateVM(test_case.StressTestCase):
diff --git a/stress/tests/floating_ips.py b/stress/tests/floating_ips.py
index 03bd509..8db06d4 100755
--- a/stress/tests/floating_ips.py
+++ b/stress/tests/floating_ips.py
@@ -13,12 +13,12 @@
# limitations under the License.
"""Stress test that associates/disasssociates floating ips"""
-# local imports
-from stress.test_floating_ips import TestChangeFloatingIp
from stress.basher import BasherAction
from stress.driver import *
+from stress.test_floating_ips import TestChangeFloatingIp
from tempest import openstack
+
choice_spec = [
BasherAction(TestChangeFloatingIp(), 100)
]
diff --git a/stress/utils/util.py b/stress/utils/util.py
index 5870ca1..f90796d 100644
--- a/stress/utils/util.py
+++ b/stress/utils/util.py
@@ -14,8 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import subprocess
import shlex
+import subprocess
SSH_OPTIONS = (" -q" +
" -o UserKnownHostsFile=/dev/null" +
diff --git a/tempest/common/rest_client.py b/tempest/common/rest_client.py
index 8311365..8924fd3 100644
--- a/tempest/common/rest_client.py
+++ b/tempest/common/rest_client.py
@@ -15,8 +15,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
import httplib2
+import json
import logging
from lxml import etree
import time
@@ -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):
"""
@@ -95,11 +103,11 @@
params['headers'] = {'User-Agent': 'Test-Client', 'X-Auth-User': user,
'X-Auth-Key': password}
- self.http_obj = httplib2.Http()
+ self.http_obj = httplib2.Http(disable_ssl_certificate_validation=True)
resp, body = self.http_obj.request(auth_url, 'GET', **params)
try:
return resp['x-auth-token'], resp['x-server-management-url']
- except:
+ except Exception:
raise
def keystone_auth(self, user, password, auth_url, service, tenant_name):
@@ -117,7 +125,7 @@
}
}
- self.http_obj = httplib2.Http()
+ self.http_obj = httplib2.Http(disable_ssl_certificate_validation=True)
headers = {'Content-Type': 'application/json'}
body = json.dumps(creds)
resp, body = self.http_obj.request(auth_url, 'POST',
@@ -193,7 +201,7 @@
if (self.token is None) or (self.base_url is None):
self._set_auth()
- self.http_obj = httplib2.Http()
+ self.http_obj = httplib2.Http(disable_ssl_certificate_validation=True)
if headers is None:
headers = {}
headers['X-Auth-Token'] = self.token
@@ -201,6 +209,38 @@
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 resp_body:
+ raise exceptions.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 exceptions.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()
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/ssh.py b/tempest/common/ssh.py
index c03a90c..1b40ddc 100644
--- a/tempest/common/ssh.py
+++ b/tempest/common/ssh.py
@@ -15,12 +15,13 @@
# License for the specific language governing permissions and limitations
# under the License.
-import time
-import socket
-import warnings
-import select
from cStringIO import StringIO
+import select
+import socket
+import time
+import warnings
+
from tempest import exceptions
diff --git a/tempest/common/utils/data_utils.py b/tempest/common/utils/data_utils.py
index 15afd0a..951fb61 100644
--- a/tempest/common/utils/data_utils.py
+++ b/tempest/common/utils/data_utils.py
@@ -15,9 +15,11 @@
# License for the specific language governing permissions and limitations
# under the License.
+import itertools
import random
import re
import urllib
+
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/common/utils/linux/remote_client.py b/tempest/common/utils/linux/remote_client.py
index ca1557f..b501df4 100644
--- a/tempest/common/utils/linux/remote_client.py
+++ b/tempest/common/utils/linux/remote_client.py
@@ -1,10 +1,11 @@
-from tempest.common.ssh import Client
-from tempest.config import TempestConfig
-from tempest.common import utils
-from tempest.exceptions import SSHTimeout, ServerUnreachable
-
-import time
import re
+import time
+
+from tempest.common.ssh import Client
+from tempest.common import utils
+from tempest.config import TempestConfig
+from tempest.exceptions import ServerUnreachable
+from tempest.exceptions import SSHTimeout
class RemoteClient():
diff --git a/tempest/config.py b/tempest/config.py
index 0ccd4b6..25fbbb9 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
@@ -293,6 +294,12 @@
"""Path to a private key file for SSH access to remote hosts"""
return self.get("path_to_private_key")
+ @property
+ def disk_config_enabled_override(self):
+ """If false, skip config tests regardless of the extension status"""
+ return self.get("disk_config_enabled_override",
+ 'true').lower() == 'true'
+
class ComputeAdminConfig(BaseConfig):
@@ -400,21 +407,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')
@@ -484,6 +476,11 @@
return self.get("http_socket_timeout", "3")
@property
+ def num_retries(self):
+ """boto num_retries on error"""
+ return self.get("num_retries", "1")
+
+ @property
def build_timeout(self):
"""status change timeout"""
return float(self.get("build_timeout", "60"))
@@ -528,11 +525,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..c9e2f95 100644
--- a/tempest/exceptions.py
+++ b/tempest/exceptions.py
@@ -66,11 +66,11 @@
class AddImageException(TempestException):
- message = "Image %(image_id) failed to become ACTIVE in the allotted time"
+ message = "Image %(image_id)s failed to become ACTIVE in the allotted time"
class EC2RegisterImageException(TempestException):
- message = ("Image %(image_id) failed to become 'available' "
+ message = ("Image %(image_id)s failed to become 'available' "
"in the allotted time")
@@ -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)d 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 59743e5..a17aa21 100644
--- a/tempest/manager.py
+++ b/tempest/manager.py
@@ -29,19 +29,19 @@
import tempest.config
from tempest import exceptions
# Tempest REST Fuzz testing client libs
+from tempest.services.compute.json import console_output_client
+from tempest.services.compute.json import extensions_client
+from tempest.services.compute.json import flavors_client
+from tempest.services.compute.json import floating_ips_client
+from tempest.services.compute.json import images_client
+from tempest.services.compute.json import keypairs_client
+from tempest.services.compute.json import limits_client
+from tempest.services.compute.json import quotas_client
+from tempest.services.compute.json import security_groups_client
+from tempest.services.compute.json import servers_client
+from tempest.services.compute.json import volumes_extensions_client
from tempest.services.network.json import network_client
from tempest.services.volume.json import volumes_client
-from tempest.services.compute.json import images_client
-from tempest.services.compute.json import flavors_client
-from tempest.services.compute.json import servers_client
-from tempest.services.compute.json import limits_client
-from tempest.services.compute.json import extensions_client
-from tempest.services.compute.json import security_groups_client
-from tempest.services.compute.json import floating_ips_client
-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
diff --git a/tempest/openstack.py b/tempest/openstack.py
index fbd2f00..e29ea8e 100644
--- a/tempest/openstack.py
+++ b/tempest/openstack.py
@@ -19,47 +19,47 @@
from tempest import config
from tempest import exceptions
-from tempest.services.identity.json.admin_client import AdminClientJSON
-from tempest.services.identity.json.admin_client import TokenClientJSON
-from tempest.services.identity.xml.admin_client import AdminClientXML
-from tempest.services.identity.xml.admin_client import TokenClientXML
-from tempest.services.image import service as image_service
-from tempest.services.network.json.network_client import NetworkClient
+from tempest.services.boto.clients import APIClientEC2
+from tempest.services.boto.clients import ObjectClientS3
from tempest.services.compute.json.extensions_client import \
-ExtensionsClientJSON
+ ExtensionsClientJSON
from tempest.services.compute.json.flavors_client import FlavorsClientJSON
from tempest.services.compute.json.floating_ips_client import \
-FloatingIPsClientJSON
+ FloatingIPsClientJSON
from tempest.services.compute.json.images_client import ImagesClientJSON
from tempest.services.compute.json.limits_client import LimitsClientJSON
from tempest.services.compute.json.servers_client import ServersClientJSON
-from tempest.services.compute.json.security_groups_client \
-import SecurityGroupsClientJSON
+from tempest.services.compute.json.security_groups_client import \
+ SecurityGroupsClientJSON
from tempest.services.compute.json.keypairs_client import KeyPairsClientJSON
-from tempest.services.compute.json.volumes_extensions_client \
-import VolumesExtensionsClientJSON
-from tempest.services.compute.json.console_output_client \
-import ConsoleOutputsClient
+from tempest.services.compute.json.quotas_client import QuotasClient
+from tempest.services.compute.json.volumes_extensions_client import \
+ VolumesExtensionsClientJSON
+from tempest.services.compute.json.console_output_client import \
+ ConsoleOutputsClient
from tempest.services.compute.xml.extensions_client import ExtensionsClientXML
from tempest.services.compute.xml.flavors_client import FlavorsClientXML
from tempest.services.compute.xml.floating_ips_client import \
-FloatingIPsClientXML
+ FloatingIPsClientXML
from tempest.services.compute.xml.images_client import ImagesClientXML
from tempest.services.compute.xml.keypairs_client import KeyPairsClientXML
from tempest.services.compute.xml.limits_client import LimitsClientXML
from tempest.services.compute.xml.security_groups_client \
import SecurityGroupsClientXML
from tempest.services.compute.xml.servers_client import ServersClientXML
-from tempest.services.compute.xml.volumes_extensions_client \
-import VolumesExtensionsClientXML
-from tempest.services.volume.json.volumes_client import VolumesClientJSON
-from tempest.services.volume.xml.volumes_client import VolumesClientXML
+from tempest.services.compute.xml.volumes_extensions_client import \
+ VolumesExtensionsClientXML
+from tempest.services.identity.json.admin_client import AdminClientJSON
+from tempest.services.identity.json.admin_client import TokenClientJSON
+from tempest.services.identity.xml.admin_client import AdminClientXML
+from tempest.services.identity.xml.admin_client import TokenClientXML
+from tempest.services.image import service as image_service
+from tempest.services.network.json.network_client import NetworkClient
from tempest.services.object_storage.account_client import AccountClient
from tempest.services.object_storage.container_client import ContainerClient
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
+from tempest.services.volume.json.volumes_client import VolumesClientJSON
+from tempest.services.volume.xml.volumes_client import VolumesClientXML
LOG = logging.getLogger(__name__)
diff --git a/tempest/services/boto/__init__.py b/tempest/services/boto/__init__.py
index 9b9fceb..58a2b37 100644
--- a/tempest/services/boto/__init__.py
+++ b/tempest/services/boto/__init__.py
@@ -15,17 +15,16 @@
# License for the specific language governing permissions and limitations
# under the License.
-import boto
-
from ConfigParser import DuplicateSectionError
+from contextlib import closing
+import re
+from types import MethodType
+
+import boto
from tempest.exceptions import InvalidConfiguration
from tempest.exceptions import NotFound
-import re
-from types import MethodType
-from contextlib import closing
-
class BotoClientBase(object):
@@ -37,6 +36,7 @@
*args, **kwargs):
self.connection_timeout = config.boto.http_socket_timeout
+ self.num_retries = config.boto.num_retries
self.build_timeout = config.boto.build_timeout
# We do not need the "path": "/token" part
if auth_url:
@@ -64,12 +64,13 @@
raise NotFound("Unable to get access and secret keys")
return ec2_cred
- def _config_boto_timeout(self, timeout):
+ def _config_boto_timeout(self, timeout, retries):
try:
boto.config.add_section("Boto")
except DuplicateSectionError:
pass
boto.config.set("Boto", "http_socket_timeout", timeout)
+ boto.config.set("Boto", "num_retries", retries)
def __getattr__(self, name):
"""Automatically creates methods for the allowed methods set"""
@@ -87,7 +88,7 @@
raise AttributeError(name)
def get_connection(self):
- self._config_boto_timeout(self.connection_timeout)
+ self._config_boto_timeout(self.connection_timeout, self.num_retries)
if not all((self.connection_data["aws_access_key_id"],
self.connection_data["aws_secret_access_key"])):
if all(self.ks_cred.itervalues()):
diff --git a/tempest/services/boto/clients.py b/tempest/services/boto/clients.py
index 5fabcae..9cfe234 100644
--- a/tempest/services/boto/clients.py
+++ b/tempest/services/boto/clients.py
@@ -15,12 +15,14 @@
# License for the specific language governing permissions and limitations
# under the License.
-import boto
-from boto.s3.connection import OrdinaryCallingFormat
-from boto.ec2.regioninfo import RegionInfo
-from tempest.services.boto import BotoClientBase
import urlparse
+import boto
+from boto.ec2.regioninfo import RegionInfo
+from boto.s3.connection import OrdinaryCallingFormat
+
+from tempest.services.boto import BotoClientBase
+
class APIClientEC2(BotoClientBase):
diff --git a/tempest/services/compute/json/console_output_client.py b/tempest/services/compute/json/console_output_client.py
index d12fd7d..0c3ba59 100644
--- a/tempest/services/compute/json/console_output_client.py
+++ b/tempest/services/compute/json/console_output_client.py
@@ -15,9 +15,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest.common.rest_client import RestClient
import json
+from tempest.common.rest_client import RestClient
+
class ConsoleOutputsClient(RestClient):
diff --git a/tempest/services/compute/json/extensions_client.py b/tempest/services/compute/json/extensions_client.py
index c0200df..583c3b4 100644
--- a/tempest/services/compute/json/extensions_client.py
+++ b/tempest/services/compute/json/extensions_client.py
@@ -15,9 +15,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest.common.rest_client import RestClient
import json
+from tempest.common.rest_client import RestClient
+
class ExtensionsClientJSON(RestClient):
diff --git a/tempest/services/compute/json/flavors_client.py b/tempest/services/compute/json/flavors_client.py
index 01708a2..1c8d4f3 100644
--- a/tempest/services/compute/json/flavors_client.py
+++ b/tempest/services/compute/json/flavors_client.py
@@ -15,8 +15,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest.common.rest_client import RestClient
import json
+import urllib
+
+from tempest.common.rest_client import RestClient
class FlavorsClientJSON(RestClient):
@@ -28,12 +30,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 +39,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..15882c7 100644
--- a/tempest/services/compute/json/floating_ips_client.py
+++ b/tempest/services/compute/json/floating_ips_client.py
@@ -15,9 +15,11 @@
# License for the specific language governing permissions and limitations
# under the License.
+import json
+import urllib
+
from tempest.common.rest_client import RestClient
from tempest import exceptions
-import json
class FloatingIPsClientJSON(RestClient):
@@ -29,11 +31,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/hosts_client.py b/tempest/services/compute/json/hosts_client.py
index a53d00d..517e230 100644
--- a/tempest/services/compute/json/hosts_client.py
+++ b/tempest/services/compute/json/hosts_client.py
@@ -1,6 +1,7 @@
-from tempest.common.rest_client import RestClient
import json
+from tempest.common.rest_client import RestClient
+
class HostsClientJSON(RestClient):
diff --git a/tempest/services/compute/json/images_client.py b/tempest/services/compute/json/images_client.py
index 102590c..452400a 100644
--- a/tempest/services/compute/json/images_client.py
+++ b/tempest/services/compute/json/images_client.py
@@ -15,10 +15,12 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest.common.rest_client import RestClient
-from tempest import exceptions
import json
import time
+import urllib
+
+from tempest.common.rest_client import RestClient
+from tempest import exceptions
class ImagesClientJSON(RestClient):
@@ -50,12 +52,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 +62,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/keypairs_client.py b/tempest/services/compute/json/keypairs_client.py
index 553936c..90b2096 100644
--- a/tempest/services/compute/json/keypairs_client.py
+++ b/tempest/services/compute/json/keypairs_client.py
@@ -15,9 +15,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest.common.rest_client import RestClient
import json
+from tempest.common.rest_client import RestClient
+
class KeyPairsClientJSON(RestClient):
diff --git a/tempest/services/compute/json/security_groups_client.py b/tempest/services/compute/json/security_groups_client.py
index 9d8de23..f2586e5 100644
--- a/tempest/services/compute/json/security_groups_client.py
+++ b/tempest/services/compute/json/security_groups_client.py
@@ -15,8 +15,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest.common.rest_client import RestClient
import json
+import urllib
+
+from tempest.common.rest_client import RestClient
class SecurityGroupsClientJSON(RestClient):
@@ -31,12 +33,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..2e34ef8 100644
--- a/tempest/services/compute/json/servers_client.py
+++ b/tempest/services/compute/json/servers_client.py
@@ -15,10 +15,12 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest import exceptions
-from tempest.common.rest_client import RestClient
import json
import time
+import urllib
+
+from tempest.common.rest_client import RestClient
+from tempest import exceptions
class ServersClientJSON(RestClient):
@@ -121,12 +123,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 +134,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 240bcfe..6cf6c23 100644
--- a/tempest/services/compute/json/volumes_extensions_client.py
+++ b/tempest/services/compute/json/volumes_extensions_client.py
@@ -15,10 +15,12 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest import exceptions
-from tempest.common.rest_client import RestClient
import json
import time
+import urllib
+
+from tempest.common.rest_client import RestClient
+from tempest import exceptions
class VolumesExtensionsClientJSON(RestClient):
@@ -34,12 +36,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,12 +46,8 @@
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)
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..a0059a8 100644
--- a/tempest/services/compute/xml/floating_ips_client.py
+++ b/tempest/services/compute/xml/floating_ips_client.py
@@ -16,12 +16,13 @@
# under the License.
from lxml import etree
+import urllib
from tempest.common.rest_client import RestClientXML
from tempest import exceptions
-from tempest.services.compute.xml.common import xml_to_json
from tempest.services.compute.xml.common import Document
from tempest.services.compute.xml.common import Element
+from tempest.services.compute.xml.common import xml_to_json
class FloatingIPsClientXML(RestClientXML):
@@ -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..efed3fb 100644
--- a/tempest/services/compute/xml/images_client.py
+++ b/tempest/services/compute/xml/images_client.py
@@ -20,8 +20,8 @@
from lxml import etree
-from tempest import exceptions
from tempest.common.rest_client import RestClientXML
+from tempest import exceptions
from tempest.services.compute.xml.common import Document
from tempest.services.compute.xml.common import Element
from tempest.services.compute.xml.common import Text
@@ -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 229dbee..473952b 100644
--- a/tempest/services/compute/xml/limits_client.py
+++ b/tempest/services/compute/xml/limits_client.py
@@ -15,10 +15,11 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest.common.rest_client import RestClientXML
from lxml import etree
from lxml import objectify
+from tempest.common.rest_client import RestClientXML
+
NS = "{http://docs.openstack.org/common/api/v1.0}"
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..b33335d 100644
--- a/tempest/services/compute/xml/servers_client.py
+++ b/tempest/services/compute/xml/servers_client.py
@@ -16,15 +16,19 @@
# under the License.
import logging
+import time
+import urllib
+
from lxml import etree
-from tempest import exceptions
+
from tempest.common.rest_client import RestClientXML
+from tempest import exceptions
from tempest.services.compute.xml.common import Document
from tempest.services.compute.xml.common import Element
from tempest.services.compute.xml.common import Text
from tempest.services.compute.xml.common import xml_to_json
from tempest.services.compute.xml.common import XMLNS_11
-import time
+
LOG = logging.getLogger(__name__)
@@ -82,24 +86,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 0fbc070..1e8c738 100644
--- a/tempest/services/compute/xml/volumes_extensions_client.py
+++ b/tempest/services/compute/xml/volumes_extensions_client.py
@@ -16,15 +16,17 @@
# under the License.
import time
+import urllib
+
from lxml import etree
-from tempest import exceptions
from tempest.common.rest_client import RestClientXML
-from tempest.services.compute.xml.common import xml_to_json
-from tempest.services.compute.xml.common import XMLNS_11
+from tempest import exceptions
+from tempest.services.compute.xml.common import Document
from tempest.services.compute.xml.common import Element
from tempest.services.compute.xml.common import Text
-from tempest.services.compute.xml.common import Document
+from tempest.services.compute.xml.common import xml_to_json
+from tempest.services.compute.xml.common import XMLNS_11
class VolumesExtensionsClientXML(RestClientXML):
diff --git a/tempest/services/identity/json/admin_client.py b/tempest/services/identity/json/admin_client.py
index 9e171b6..6c36195 100644
--- a/tempest/services/identity/json/admin_client.py
+++ b/tempest/services/identity/json/admin_client.py
@@ -1,8 +1,9 @@
-from tempest.common.rest_client import RestClient
-from tempest import exceptions
import httplib2
import json
+from tempest.common.rest_client import RestClient
+from tempest import exceptions
+
class AdminClientJSON(RestClient):
diff --git a/tempest/services/identity/xml/admin_client.py b/tempest/services/identity/xml/admin_client.py
index 0ace184..3a947b6 100644
--- a/tempest/services/identity/xml/admin_client.py
+++ b/tempest/services/identity/xml/admin_client.py
@@ -15,17 +15,20 @@
# License for the specific language governing permissions and limitations
# under the License.
+import httplib2
+import json
import logging
+
from lxml import etree
+
from tempest.common.rest_client import RestClient
from tempest.common.rest_client import RestClientXML
+from tempest import exceptions
from tempest.services.compute.xml.common import Document
from tempest.services.compute.xml.common import Element
from tempest.services.compute.xml.common import Text
from tempest.services.compute.xml.common import xml_to_json
-from tempest import exceptions
-import httplib2
-import json
+
XMLNS = "http://docs.openstack.org/identity/api/v2.0"
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..6b5342a 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
@@ -93,8 +94,8 @@
item count is beyond 10,000 item listing limit.
Does not require any paramaters aside from container name.
"""
- #TODO: Rewite using json format to avoid newlines at end of obj names
- #Set limit to API limit - 1 (max returned items = 9999)
+ #TODO(dwalleck): Rewite using json format to avoid newlines at end of
+ #obj names. Set limit to API limit - 1 (max returned items = 9999)
limit = 9999
marker = None
if params is not None:
@@ -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/admin/__init__.py b/tempest/services/volume/json/admin/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/services/volume/json/admin/__init__.py
diff --git a/tempest/services/volume/json/admin/volume_types_client.py b/tempest/services/volume/json/admin/volume_types_client.py
new file mode 100644
index 0000000..fc8897f
--- /dev/null
+++ b/tempest/services/volume/json/admin/volume_types_client.py
@@ -0,0 +1,124 @@
+# 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 json
+import urllib
+
+from tempest.common.rest_client import RestClient
+
+
+class VolumeTypesClientJSON(RestClient):
+ """
+ Client class to send CRUD Volume Types API requests to a Cinder endpoint
+ """
+
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ super(VolumeTypesClientJSON, self).__init__(config, username, password,
+ auth_url, tenant_name)
+
+ self.service = self.config.volume.catalog_type
+ self.build_interval = self.config.volume.build_interval
+ self.build_timeout = self.config.volume.build_timeout
+
+ def list_volume_types(self, params=None):
+ """List all the volume_types created"""
+ url = 'types'
+ if params is not None:
+ url += '?%s' % urllib.urlencode(params)
+
+ resp, body = self.get(url)
+ body = json.loads(body)
+ return resp, body['volume_types']
+
+ def get_volume_type(self, volume_id):
+ """Returns the details of a single volume_type"""
+ url = "types/%s" % str(volume_id)
+ resp, body = self.get(url)
+ body = json.loads(body)
+ return resp, body['volume_type']
+
+ def create_volume_type(self, name, **kwargs):
+ """
+ Creates a new Volume_type.
+ name(Required): Name of volume_type.
+ Following optional keyword arguments are accepted:
+ extra_specs: A dictionary of values to be used as extra_specs.
+ """
+ post_body = {
+ 'name': name,
+ 'extra_specs': kwargs.get('extra_specs'),
+ }
+
+ post_body = json.dumps({'volume_type': post_body})
+ resp, body = self.post('types', post_body, self.headers)
+ body = json.loads(body)
+ return resp, body['volume_type']
+
+ def delete_volume_type(self, volume_id):
+ """Deletes the Specified Volume_type"""
+ return self.delete("types/%s" % str(volume_id))
+
+ def list_volume_types_extra_specs(self, vol_type_id, params=None):
+ """List all the volume_types extra specs created"""
+ url = 'types/%s/extra_specs' % str(vol_type_id)
+ if params is not None:
+ url += '?%s' % urllib.urlencode(params)
+
+ resp, body = self.get(url)
+ body = json.loads(body)
+ return resp, body['extra_specs']
+
+ def get_volume_type_extra_specs(self, vol_type_id, extra_spec_name):
+ """Returns the details of a single volume_type extra spec"""
+ url = "types/%s/extra_specs/%s" % (str(vol_type_id),
+ str(extra_spec_name))
+ resp, body = self.get(url)
+ body = json.loads(body)
+ return resp, body
+
+ def create_volume_type_extra_specs(self, vol_type_id, extra_spec):
+ """
+ Creates a new Volume_type extra spec.
+ vol_type_id: Id of volume_type.
+ extra_specs: A dictionary of values to be used as extra_specs.
+ """
+ url = "types/%s/extra_specs" % str(vol_type_id)
+ post_body = json.dumps({'extra_specs': extra_spec})
+ resp, body = self.post(url, post_body, self.headers)
+ body = json.loads(body)
+ return resp, body['extra_specs']
+
+ def delete_volume_type_extra_specs(self, vol_id, extra_spec_name):
+ """Deletes the Specified Volume_type extra spec"""
+ return self.delete("types/%s/extra_specs/%s" % ((str(vol_id)),
+ str(extra_spec_name)))
+
+ def update_volume_type_extra_specs(self, vol_type_id, extra_spec_name,
+ extra_spec):
+ """
+ Update a volume_type extra spec.
+ vol_type_id: Id of volume_type.
+ extra_spec_name: Name of the extra spec to be updated.
+ extra_spec: A dictionary of with key as extra_spec_name and the
+ updated value.
+ """
+ url = "types/%s/extra_specs/%s" % (str(vol_type_id),
+ str(extra_spec_name))
+ put_body = json.dumps(extra_spec)
+ resp, body = self.put(url, put_body, self.headers)
+ body = json.loads(body)
+ return resp, body
diff --git a/tempest/services/volume/json/volumes_client.py b/tempest/services/volume/json/volumes_client.py
index 28dae4e..962fe72 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,12 +49,8 @@
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)
@@ -76,11 +70,13 @@
Following optional keyword arguments are accepted:
display_name: Optional Volume Name.
metadata: A dictionary of values to be used as metadata.
+ volume_type: Optional Name of volume_type for the volume
"""
post_body = {
'size': size,
'display_name': kwargs.get('display_name'),
'metadata': kwargs.get('metadata'),
+ 'volume_type': kwargs.get('volume_type')
}
post_body = json.dumps({'volume': post_body})
diff --git a/tempest/services/volume/xml/volumes_client.py b/tempest/services/volume/xml/volumes_client.py
index 9d2f159..91d0fc7 100644
--- a/tempest/services/volume/xml/volumes_client.py
+++ b/tempest/services/volume/xml/volumes_client.py
@@ -16,16 +16,17 @@
# under the License.
import time
+import urllib
from lxml import etree
from tempest.common.rest_client import RestClientXML
from tempest import exceptions
-from tempest.services.compute.xml.common import xml_to_json
-from tempest.services.compute.xml.common import XMLNS_11
+from tempest.services.compute.xml.common import Document
from tempest.services.compute.xml.common import Element
from tempest.services.compute.xml.common import Text
-from tempest.services.compute.xml.common import Document
+from tempest.services.compute.xml.common import xml_to_json
+from tempest.services.compute.xml.common import XMLNS_11
class VolumesClientXML(RestClientXML):
diff --git a/tempest/testboto.py b/tempest/testboto.py
index 6c51346..3a0eb25 100644
--- a/tempest/testboto.py
+++ b/tempest/testboto.py
@@ -15,21 +15,25 @@
# License for the specific language governing permissions and limitations
# under the License.
-import unittest2 as unittest
-import nose
-import tempest.tests.boto
-from tempest.exceptions import TearDownException
-from tempest.tests.boto.utils.wait import state_wait, wait_no_exception
-from tempest.tests.boto.utils.wait import re_search_wait, wait_exception
-import boto
-from boto.s3.key import Key
-from boto.s3.bucket import Bucket
-from boto.exception import BotoServerError
from contextlib import closing
-import re
import logging
+import re
import time
+import boto
+from boto.exception import BotoServerError
+from boto.s3.bucket import Bucket
+from boto.s3.key import Key
+import nose
+import unittest2 as unittest
+
+from tempest.exceptions import TearDownException
+import tempest.tests.boto
+from tempest.tests.boto.utils.wait import re_search_wait
+from tempest.tests.boto.utils.wait import state_wait
+from tempest.tests.boto.utils.wait import wait_exception
+from tempest.tests.boto.utils.wait import wait_no_exception
+
LOG = logging.getLogger(__name__)
diff --git a/tempest/tests/boto/__init__.py b/tempest/tests/boto/__init__.py
index 11fa077..fdcd3cd 100644
--- a/tempest/tests/boto/__init__.py
+++ b/tempest/tests/boto/__init__.py
@@ -15,16 +15,18 @@
# License for the specific language governing permissions and limitations
# under the License.
-import tempest.config
-from tempest.common.utils.file_utils import have_effective_read_access
-import os
-import tempest.openstack
-import re
-import keystoneclient.exceptions
-import boto.exception
import logging
+import os
+import re
import urlparse
+import boto.exception
+import keystoneclient.exceptions
+
+from tempest.common.utils.file_utils import have_effective_read_access
+import tempest.config
+import tempest.openstack
+
A_I_IMAGES_READY = False # ari,ami,aki
S3_CAN_CONNECT_ERROR = "Unknown Error"
EC2_CAN_CONNECT_ERROR = "Unknown Error"
diff --git a/tempest/tests/boto/test_ec2_instance_run.py b/tempest/tests/boto/test_ec2_instance_run.py
index e5c61fb..023e3d0 100644
--- a/tempest/tests/boto/test_ec2_instance_run.py
+++ b/tempest/tests/boto/test_ec2_instance_run.py
@@ -15,21 +15,23 @@
# License for the specific language governing permissions and limitations
# under the License.
-import nose
-from nose.plugins.attrib import attr
-import unittest2 as unittest
-from tempest.testboto import BotoTestCase
-from tempest.tests.boto.utils.s3 import s3_upload_dir
-import tempest.tests.boto
-from tempest.common.utils.data_utils import rand_name
-from tempest.exceptions import EC2RegisterImageException
-from tempest.tests.boto.utils.wait import state_wait, re_search_wait
-from tempest import openstack
-from tempest.common.utils.linux.remote_client import RemoteClient
-from boto.s3.key import Key
from contextlib import closing
import logging
+from boto.s3.key import Key
+import nose
+from nose.plugins.attrib import attr
+import unittest2 as unittest
+
+from tempest.common.utils.data_utils import rand_name
+from tempest.common.utils.linux.remote_client import RemoteClient
+from tempest.exceptions import EC2RegisterImageException
+from tempest import openstack
+from tempest.testboto import BotoTestCase
+import tempest.tests.boto
+from tempest.tests.boto.utils.s3 import s3_upload_dir
+from tempest.tests.boto.utils.wait import re_search_wait
+from tempest.tests.boto.utils.wait import state_wait
LOG = logging.getLogger(__name__)
diff --git a/tempest/tests/boto/test_ec2_keys.py b/tempest/tests/boto/test_ec2_keys.py
index 79d0b2b..b9e5508 100644
--- a/tempest/tests/boto/test_ec2_keys.py
+++ b/tempest/tests/boto/test_ec2_keys.py
@@ -15,12 +15,12 @@
# License for the specific language governing permissions and limitations
# under the License.
-
from nose.plugins.attrib import attr
import unittest2 as unittest
-from tempest.testboto import BotoTestCase
+
from tempest.common.utils.data_utils import rand_name
from tempest import openstack
+from tempest.testboto import BotoTestCase
def compare_key_pairs(a, b):
diff --git a/tempest/tests/boto/test_ec2_network.py b/tempest/tests/boto/test_ec2_network.py
index accf677..c67b3aa 100644
--- a/tempest/tests/boto/test_ec2_network.py
+++ b/tempest/tests/boto/test_ec2_network.py
@@ -17,8 +17,9 @@
from nose.plugins.attrib import attr
import unittest2 as unittest
-from tempest.testboto import BotoTestCase
+
from tempest import openstack
+from tempest.testboto import BotoTestCase
@attr("EC2")
diff --git a/tempest/tests/boto/test_ec2_security_groups.py b/tempest/tests/boto/test_ec2_security_groups.py
index 3d50e8b..72e8267 100644
--- a/tempest/tests/boto/test_ec2_security_groups.py
+++ b/tempest/tests/boto/test_ec2_security_groups.py
@@ -17,9 +17,10 @@
from nose.plugins.attrib import attr
import unittest2 as unittest
-from tempest.testboto import BotoTestCase
+
from tempest.common.utils.data_utils import rand_name
from tempest import openstack
+from tempest.testboto import BotoTestCase
@attr("EC2")
diff --git a/tempest/tests/boto/test_ec2_volumes.py b/tempest/tests/boto/test_ec2_volumes.py
index 8b7e6be..89698de 100644
--- a/tempest/tests/boto/test_ec2_volumes.py
+++ b/tempest/tests/boto/test_ec2_volumes.py
@@ -15,14 +15,15 @@
# License for the specific language governing permissions and limitations
# under the License.
-
-from nose.plugins.attrib import attr
-from tempest.testboto import BotoTestCase
-from tempest import openstack
-import unittest2 as unittest
import logging
import time
+from nose.plugins.attrib import attr
+import unittest2 as unittest
+
+from tempest import openstack
+from tempest.testboto import BotoTestCase
+
LOG = logging.getLogger(__name__)
@@ -60,7 +61,7 @@
self.client.delete_volume(volume.id)
self.cancelResourceCleanUp(cuk)
- @unittest.skip("Skipped until the Bug #1080284 is resolved")
+ @attr(type='smoke')
def test_create_volme_from_snapshot(self):
"""EC2 Create volume from snapshot"""
volume = self.client.create_volume(1, self.zone)
@@ -78,7 +79,6 @@
snap.update(validate=True)
return snap.status
- #self.assertVolumeStatusWait(_snap_status, "available") # not a volume
self.assertSnapshotStatusWait(_snap_status, "completed")
svol = self.client.create_volume(1, self.zone, snapshot=snap)
diff --git a/tempest/tests/boto/test_s3_buckets.py b/tempest/tests/boto/test_s3_buckets.py
index 56cf52c..ce4b210 100644
--- a/tempest/tests/boto/test_s3_buckets.py
+++ b/tempest/tests/boto/test_s3_buckets.py
@@ -17,9 +17,10 @@
from nose.plugins.attrib import attr
import unittest2 as unittest
-from tempest.testboto import BotoTestCase
+
from tempest.common.utils.data_utils import rand_name
from tempest import openstack
+from tempest.testboto import BotoTestCase
@attr("S3")
diff --git a/tempest/tests/boto/test_s3_ec2_images.py b/tempest/tests/boto/test_s3_ec2_images.py
index eeb7039..4990be6 100644
--- a/tempest/tests/boto/test_s3_ec2_images.py
+++ b/tempest/tests/boto/test_s3_ec2_images.py
@@ -15,19 +15,21 @@
# License for the specific language governing permissions and limitations
# under the License.
+from contextlib import closing
+import logging
+import os
+
+from boto.s3.key import Key
+import nose
from nose.plugins.attrib import attr
import unittest2 as unittest
+
+from tempest.common.utils.data_utils import rand_name
from tempest import openstack
from tempest.testboto import BotoTestCase
import tempest.tests.boto
-from tempest.tests.boto.utils.wait import state_wait
from tempest.tests.boto.utils.s3 import s3_upload_dir
-from tempest.common.utils.data_utils import rand_name
-from contextlib import closing
-from boto.s3.key import Key
-import logging
-import nose
-import os
+from tempest.tests.boto.utils.wait import state_wait
@attr("S3", "EC2")
diff --git a/tempest/tests/boto/test_s3_objects.py b/tempest/tests/boto/test_s3_objects.py
index c31ad6e..cfb1ad5 100644
--- a/tempest/tests/boto/test_s3_objects.py
+++ b/tempest/tests/boto/test_s3_objects.py
@@ -15,14 +15,16 @@
# License for the specific language governing permissions and limitations
# under the License.
+from contextlib import closing
+
+from boto.s3.key import Key
from nose.plugins.attrib import attr
import unittest2 as unittest
-from tempest.testboto import BotoTestCase
+
from tempest.common.utils.data_utils import rand_name
from tempest import openstack
+from tempest.testboto import BotoTestCase
from tempest.tests import boto
-from boto.s3.key import Key
-from contextlib import closing
@attr("S3")
diff --git a/tempest/tests/boto/utils/s3.py b/tempest/tests/boto/utils/s3.py
index 70d9263..4c3229b 100644
--- a/tempest/tests/boto/utils/s3.py
+++ b/tempest/tests/boto/utils/s3.py
@@ -15,13 +15,13 @@
# License for the specific language governing permissions and limitations
# under the License.
-import boto
-from boto.s3.key import Key
from contextlib import closing
+import logging
import os
import re
-import logging
+import boto
+from boto.s3.key import Key
LOG = logging.getLogger(__name__)
diff --git a/tempest/tests/boto/utils/wait.py b/tempest/tests/boto/utils/wait.py
index 38b6ba1..951b5bf 100644
--- a/tempest/tests/boto/utils/wait.py
+++ b/tempest/tests/boto/utils/wait.py
@@ -15,12 +15,14 @@
# License for the specific language governing permissions and limitations
# under the License.
-import tempest.config
-import time
-from unittest2 import TestCase
import logging
import re
+import time
+
from boto.exception import BotoServerError
+from unittest2 import TestCase
+
+import tempest.config
LOG = logging.getLogger(__name__)
diff --git a/tempest/tests/compute/__init__.py b/tempest/tests/compute/__init__.py
index 7396833..53dc415 100644
--- a/tempest/tests/compute/__init__.py
+++ b/tempest/tests/compute/__init__.py
@@ -30,6 +30,7 @@
CHANGE_PASSWORD_AVAILABLE = CONFIG.compute.change_password_available
WHITEBOX_ENABLED = CONFIG.compute.whitebox_enabled
DISK_CONFIG_ENABLED = False
+DISK_CONFIG_ENABLED_OVERRIDE = CONFIG.compute.disk_config_enabled_override
FLAVOR_EXTRA_DATA_ENABLED = False
MULTI_USER = False
@@ -43,7 +44,8 @@
images_client = os.images_client
flavors_client = os.flavors_client
extensions_client = os.extensions_client
- DISK_CONFIG_ENABLED = extensions_client.is_enabled('DiskConfig')
+ DISK_CONFIG_ENABLED = (DISK_CONFIG_ENABLED_OVERRIDE and
+ extensions_client.is_enabled('DiskConfig'))
FLAVOR_EXTRA_DATA_ENABLED = extensions_client.is_enabled('FlavorExtraData')
# Validate reference data exists
diff --git a/tempest/tests/compute/admin/test_flavors.py b/tempest/tests/compute/admin/test_flavors.py
index dc9248d..e5de0cb 100644
--- a/tempest/tests/compute/admin/test_flavors.py
+++ b/tempest/tests/compute/admin/test_flavors.py
@@ -19,8 +19,8 @@
from nose.plugins.attrib import attr
import unittest2 as unittest
-from tempest.tests.compute import base
from tempest.tests import compute
+from tempest.tests.compute import base
class FlavorsAdminTestBase(object):
diff --git a/tempest/tests/compute/admin/test_quotas.py b/tempest/tests/compute/admin/test_quotas.py
index 98ca169..b9474e5 100644
--- a/tempest/tests/compute/admin/test_quotas.py
+++ b/tempest/tests/compute/admin/test_quotas.py
@@ -17,9 +17,9 @@
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
+from tempest.services.compute.admin.json import quotas_client as adm_quotas
+from tempest.tests.compute.base import BaseComputeTest
class QuotasTest(BaseComputeTest):
@@ -73,7 +73,7 @@
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:
+ except Exception:
self.fail("Admin could not get the default quota set for a tenant")
def test_update_all_quota_resources_for_tenant(self):
@@ -91,7 +91,7 @@
**new_quota_set)
self.assertEqual(200, resp.status)
self.assertSequenceEqual(new_quota_set, quota_set)
- except:
+ except Exception:
self.fail("Admin could not update quota set for the tenant")
finally:
# Reset quota resource limits to default values
@@ -109,7 +109,7 @@
resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
self.assertEqual(200, resp.status)
self.assertEqual(quota_set['ram'], 5120)
- except:
+ except Exception:
self.fail("Could not get the update quota limit for resource")
finally:
# Reset quota resource limits to default values
diff --git a/tempest/tests/compute/base.py b/tempest/tests/compute/base.py
index bb2ff8b..5094b46 100644
--- a/tempest/tests/compute/base.py
+++ b/tempest/tests/compute/base.py
@@ -18,13 +18,13 @@
import logging
import time
-import unittest2 as unittest
import nose
+import unittest2 as unittest
+from tempest.common.utils.data_utils import rand_name
from tempest import config
from tempest import exceptions
from tempest import openstack
-from tempest.common.utils.data_utils import rand_name
__all__ = ['BaseComputeTest', 'BaseComputeTestJSON', 'BaseComputeTestXML',
'BaseComputeAdminTestJSON', 'BaseComputeAdminTestXML']
@@ -199,7 +199,7 @@
while True:
try:
condition()
- except:
+ except Exception:
pass
else:
return
diff --git a/tempest/tests/compute/floating_ips/test_floating_ips_actions.py b/tempest/tests/compute/floating_ips/test_floating_ips_actions.py
index 7d30eeb..de6eca3 100644
--- a/tempest/tests/compute/floating_ips/test_floating_ips_actions.py
+++ b/tempest/tests/compute/floating_ips/test_floating_ips_actions.py
@@ -18,9 +18,9 @@
from nose.plugins.attrib import attr
import unittest2 as unittest
-from tempest import openstack
-from tempest import exceptions
from tempest.common.utils.data_utils import rand_name
+from tempest import exceptions
+from tempest import openstack
from tempest.tests.compute import base
@@ -124,12 +124,11 @@
#Deleting the non existent floating IP
try:
resp, body = self.client.delete_floating_ip(self.non_exist_id)
- except:
+ except Exception:
pass
else:
self.fail('Should not be able to delete a nonexistent floating IP')
- @unittest.skip("Skipped until the Bug #957706 is resolved")
@attr(type='negative')
def test_associate_nonexistant_floating_ip(self):
"""
@@ -204,7 +203,6 @@
#Deletion of server created in this method
resp, body = self.servers_client.delete_server(self.new_server_id)
- @unittest.skip("Skipped until the Bug #957706 is resolved")
@attr(type='negative')
def test_associate_ip_to_server_without_passing_floating_ip(self):
"""
diff --git a/tempest/tests/compute/floating_ips/test_list_floating_ips.py b/tempest/tests/compute/floating_ips/test_list_floating_ips.py
index 34d7369..6f74f74 100644
--- a/tempest/tests/compute/floating_ips/test_list_floating_ips.py
+++ b/tempest/tests/compute/floating_ips/test_list_floating_ips.py
@@ -18,8 +18,8 @@
from nose.plugins.attrib import attr
import unittest2 as unittest
-from tempest import exceptions
from tempest.common.utils.data_utils import rand_name
+from tempest import exceptions
from tempest.tests.compute import base
diff --git a/tempest/tests/compute/images/test_images.py b/tempest/tests/compute/images/test_images.py
index 5937811..1fbbf2e 100644
--- a/tempest/tests/compute/images/test_images.py
+++ b/tempest/tests/compute/images/test_images.py
@@ -15,16 +15,17 @@
# License for the specific language governing permissions and limitations
# under the License.
+import nose
from nose.plugins.attrib import attr
import unittest2 as unittest
-import nose
-from tempest.common.utils.data_utils import rand_name, parse_image_id
+from tempest.common.utils.data_utils import parse_image_id
+from tempest.common.utils.data_utils import rand_name
import tempest.config
from tempest import exceptions
from tempest import openstack
-from tempest.tests.compute import base
from tempest.tests import compute
+from tempest.tests.compute import base
class ImagesTestBase(object):
@@ -92,7 +93,7 @@
meta = {'image_type': 'test'}
resp, body = self.client.create_image(server['id'], name, meta)
- except:
+ except Exception:
pass
else:
@@ -198,7 +199,7 @@
snapshot_name = rand_name('a' * 260)
self.assertRaises(exceptions.BadRequest, self.client.create_image,
server['id'], snapshot_name)
- except:
+ except Exception:
self.fail("Should return 400 Bad Request if image name is over 256"
" characters")
@@ -210,7 +211,7 @@
test_uuid = ('a' * 35)
self.assertRaises(exceptions.NotFound, self.client.create_image,
test_uuid, snapshot_name)
- except:
+ except Exception:
self.fail("Should return 404 Not Found if server uuid is 35"
" characters or less")
@@ -222,7 +223,7 @@
test_uuid = ('a' * 37)
self.assertRaises(exceptions.NotFound, self.client.create_image,
test_uuid, snapshot_name)
- except:
+ except Exception:
self.fail("Should return 404 Not Found if server uuid is 37"
" characters or more")
@@ -237,7 +238,7 @@
self.assertRaises(exceptions.BadRequest,
self.client.create_image, server['id'],
snapshot_name)
- except:
+ except Exception:
self.fail("Should return 400 Bad Request if multi byte characters"
" are used for image name")
@@ -253,7 +254,7 @@
self.assertRaises(exceptions.BadRequest, self.client.create_image,
server['id'], snapshot_name, meta)
- except:
+ except Exception:
self.fail("Should raise 400 Bad Request if meta data is invalid")
@attr(type='negative')
@@ -268,7 +269,7 @@
self.assertRaises(exceptions.OverLimit, self.client.create_image,
server['id'], snapshot_name, meta)
- except:
+ except Exception:
self.fail("Should raise 413 Over Limit if meta data was too long")
@attr(type='negative')
@@ -300,7 +301,7 @@
try:
self.assertRaises(exceptions.NotFound, self.client.delete_image,
'')
- except:
+ except Exception:
self.fail("Did not return HTTP 404 NotFound for blank image id")
@attr(type='negative')
@@ -311,7 +312,7 @@
try:
self.assertRaises(exceptions.NotFound, self.client.delete_image,
image_id)
- except:
+ except Exception:
self.fail("Did not return HTTP 404 NotFound for non hex image")
@attr(type='negative')
@@ -321,7 +322,7 @@
try:
self.assertRaises(exceptions.NotFound, self.client.delete_image,
-1)
- except:
+ except Exception:
self.fail("Did not return HTTP 404 NotFound for negative image id")
@attr(type='negative')
@@ -331,7 +332,7 @@
try:
self.assertRaises(exceptions.NotFound, self.client.delete_image,
'11a22b9-120q-5555-cc11-00ab112223gj-3fac')
- except:
+ except Exception:
self.fail("Did not return HTTP 404 NotFound for image id that "
"exceeds 35 character ID length limit")
diff --git a/tempest/tests/compute/images/test_images_whitebox.py b/tempest/tests/compute/images/test_images_whitebox.py
index 40433a7..8eb258c 100644
--- a/tempest/tests/compute/images/test_images_whitebox.py
+++ b/tempest/tests/compute/images/test_images_whitebox.py
@@ -73,7 +73,7 @@
self.assertRaises(exceptions.Duplicate,
self.client.create_image,
self.shared_server['id'], image_name)
- except:
+ except Exception:
self.fail("Should not allow create image when vm_state=%s and "
"task_state=%s" % (vm_state, task_state))
finally:
diff --git a/tempest/tests/compute/images/test_list_image_filters.py b/tempest/tests/compute/images/test_list_image_filters.py
index b6be358..fd19369 100644
--- a/tempest/tests/compute/images/test_list_image_filters.py
+++ b/tempest/tests/compute/images/test_list_image_filters.py
@@ -17,8 +17,9 @@
from nose.plugins.attrib import attr
+from tempest.common.utils.data_utils import parse_image_id
+from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
-from tempest.common.utils.data_utils import rand_name, parse_image_id
from tempest.tests.compute.base import BaseComputeTest
@@ -242,7 +243,7 @@
"""Negative test: GET on non existant image should fail"""
try:
resp, image = self.client.get_image(999)
- except:
+ except Exception:
pass
else:
self.fail('GET on non existant image should fail')
diff --git a/tempest/tests/compute/images/test_list_images.py b/tempest/tests/compute/images/test_list_images.py
index ca8ec18..838c3a3 100644
--- a/tempest/tests/compute/images/test_list_images.py
+++ b/tempest/tests/compute/images/test_list_images.py
@@ -17,8 +17,9 @@
from nose.plugins.attrib import attr
+from tempest.common.utils.data_utils import parse_image_id
+from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
-from tempest.common.utils.data_utils import rand_name, parse_image_id
from tempest.tests.compute.base import BaseComputeTest
diff --git a/tempest/tests/compute/keypairs/test_keypairs.py b/tempest/tests/compute/keypairs/test_keypairs.py
index 95520b5..447d965 100644
--- a/tempest/tests/compute/keypairs/test_keypairs.py
+++ b/tempest/tests/compute/keypairs/test_keypairs.py
@@ -18,8 +18,8 @@
from nose.plugins.attrib import attr
import unittest2 as unittest
-from tempest import exceptions
from tempest.common.utils.data_utils import rand_name
+from tempest import exceptions
from tempest.tests.compute.base import BaseComputeTestJSON
from tempest.tests.compute.base import BaseComputeTestXML
@@ -93,7 +93,7 @@
public_key = keypair_detail['public_key']
self.assertTrue(public_key is not None,
"Field public_key is empty or not found.")
- except:
+ except Exception:
self.fail("GET keypair details requested by keypair name "
"has failed")
finally:
@@ -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/security_groups/test_security_group_rules.py b/tempest/tests/compute/security_groups/test_security_group_rules.py
index fd56dc3..ab5af92 100644
--- a/tempest/tests/compute/security_groups/test_security_group_rules.py
+++ b/tempest/tests/compute/security_groups/test_security_group_rules.py
@@ -17,8 +17,8 @@
from nose.plugins.attrib import attr
-from tempest import exceptions
from tempest.common.utils.data_utils import rand_name
+from tempest import exceptions
from tempest.tests.compute import base
@@ -65,40 +65,46 @@
with optional arguments
should be successfull
"""
+ rule_id = None
+ secgroup1 = None
+ secgroup2 = None
try:
#Creating a Security Group to add rules to it
s_name = rand_name('securitygroup-')
s_description = rand_name('description-')
resp, securitygroup =\
self.client.create_security_group(s_name, s_description)
- securitygroup_id1 = securitygroup['id']
+ secgroup1 = securitygroup['id']
#Creating a Security Group so as to assign group_id to the rule
s_name2 = rand_name('securitygroup-')
s_description2 = rand_name('description-')
resp, securitygroup =\
self.client.create_security_group(s_name2, s_description2)
- securitygroup_id2 = securitygroup['id']
+ secgroup2 = securitygroup['id']
#Adding rules to the created Security Group with optional arguments
- parent_group_id = securitygroup_id1
+ parent_group_id = secgroup1
ip_protocol = 'tcp'
from_port = 22
to_port = 22
cidr = '10.2.3.124/24'
- group_id = securitygroup_id2
+ group_id = secgroup2
resp, rule =\
self.client.create_security_group_rule(parent_group_id,
ip_protocol,
from_port, to_port,
cidr=cidr,
group_id=group_id)
+ rule_id = rule['id']
self.assertEqual(200, resp.status)
finally:
#Deleting the Security Group rule, created in this method
- group_rule_id = rule['id']
- self.client.delete_security_group_rule(group_rule_id)
+ if rule_id:
+ self.client.delete_security_group_rule(rule_id)
#Deleting the Security Groups created in this method
- resp, _ = self.client.delete_security_group(securitygroup_id1)
- resp, _ = self.client.delete_security_group(securitygroup_id2)
+ if secgroup1:
+ self.client.delete_security_group(secgroup1)
+ if secgroup2:
+ self.client.delete_security_group(secgroup2)
@attr(type='positive')
def test_security_group_rules_create_delete(self):
diff --git a/tempest/tests/compute/security_groups/test_security_groups.py b/tempest/tests/compute/security_groups/test_security_groups.py
index 81e84ce..1c0cc94 100644
--- a/tempest/tests/compute/security_groups/test_security_groups.py
+++ b/tempest/tests/compute/security_groups/test_security_groups.py
@@ -17,8 +17,8 @@
from nose.plugins.attrib import attr
-from tempest import exceptions
from tempest.common.utils.data_utils import rand_name
+from tempest import exceptions
from tempest.tests.compute import base
diff --git a/tempest/tests/compute/servers/test_console_output.py b/tempest/tests/compute/servers/test_console_output.py
index b08dcc2..e88aac9 100644
--- a/tempest/tests/compute/servers/test_console_output.py
+++ b/tempest/tests/compute/servers/test_console_output.py
@@ -18,8 +18,8 @@
from nose.plugins.attrib import attr
import unittest2 as unittest
-from tempest import exceptions
from tempest.common.utils.data_utils import rand_name
+from tempest import exceptions
from tempest.tests.compute.base import BaseComputeTest
diff --git a/tempest/tests/compute/servers/test_create_server.py b/tempest/tests/compute/servers/test_create_server.py
index 5d6c2ba..4fe4284 100644
--- a/tempest/tests/compute/servers/test_create_server.py
+++ b/tempest/tests/compute/servers/test_create_server.py
@@ -16,13 +16,16 @@
# under the License.
import base64
+import nose
from nose.plugins.attrib import attr
import unittest2 as unittest
-import tempest.config
+
from tempest.common.utils.data_utils import rand_name
from tempest.common.utils.linux.remote_client import RemoteClient
+import tempest.config
+from tempest.tests import compute
from tempest.tests.compute import base
@@ -35,6 +38,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 +52,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 +73,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 +123,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 +174,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..638e093 100644
--- a/tempest/tests/compute/servers/test_disk_config.py
+++ b/tempest/tests/compute/servers/test_disk_config.py
@@ -19,10 +19,10 @@
from nose.plugins.attrib import attr
import unittest2 as unittest
-from tempest import exceptions
from tempest.common.utils.data_utils import rand_name
-from tempest.tests.compute.base import BaseComputeTest
+from tempest import exceptions
from tempest.tests import compute
+from tempest.tests.compute.base import BaseComputeTest
class TestServerDiskConfig(BaseComputeTest):
@@ -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_list_server_filters.py b/tempest/tests/compute/servers/test_list_server_filters.py
index 5e4b267..3aeb8e8 100644
--- a/tempest/tests/compute/servers/test_list_server_filters.py
+++ b/tempest/tests/compute/servers/test_list_server_filters.py
@@ -15,15 +15,16 @@
# License for the specific language governing permissions and limitations
# under the License.
-import nose.plugins.skip
+
+import nose
from nose.plugins.attrib import attr
+import nose.plugins.skip
import unittest2 as unittest
-from tempest import exceptions
from tempest.common.utils.data_utils import rand_name
+from tempest import exceptions
from tempest.tests.compute import base
from tempest.tests import utils
-import nose
class ListServerFiltersTest(object):
diff --git a/tempest/tests/compute/servers/test_list_servers_negative.py b/tempest/tests/compute/servers/test_list_servers_negative.py
index b2d053d..f891c49 100644
--- a/tempest/tests/compute/servers/test_list_servers_negative.py
+++ b/tempest/tests/compute/servers/test_list_servers_negative.py
@@ -18,14 +18,14 @@
import re
import sys
-import unittest2 as unittest
import nose
+import unittest2 as unittest
+from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
from tempest import openstack
-from tempest.common.utils.data_utils import rand_name
-from tempest.tests.compute.base import BaseComputeTest
from tempest.tests import compute
+from tempest.tests.compute.base import BaseComputeTest
class ListServersNegativeTest(BaseComputeTest):
diff --git a/tempest/tests/compute/servers/test_server_actions.py b/tempest/tests/compute/servers/test_server_actions.py
index dd6b02f..835afb0 100644
--- a/tempest/tests/compute/servers/test_server_actions.py
+++ b/tempest/tests/compute/servers/test_server_actions.py
@@ -21,12 +21,12 @@
from nose.plugins.attrib import attr
import unittest2 as unittest
-import tempest.config
-from tempest import exceptions
from tempest.common.utils.data_utils import rand_name
from tempest.common.utils.linux.remote_client import RemoteClient
-from tempest.tests.compute import base
+import tempest.config
+from tempest import exceptions
from tempest.tests import compute
+from tempest.tests.compute import base
class ServerActionsTestBase(object):
diff --git a/tempest/tests/compute/servers/test_server_addresses.py b/tempest/tests/compute/servers/test_server_addresses.py
index 164548d..745a9d8 100644
--- a/tempest/tests/compute/servers/test_server_addresses.py
+++ b/tempest/tests/compute/servers/test_server_addresses.py
@@ -17,8 +17,8 @@
from nose.plugins.attrib import attr
-from tempest import exceptions
from tempest.common.utils.data_utils import rand_name
+from tempest import exceptions
from tempest.tests.compute.base import BaseComputeTest
diff --git a/tempest/tests/compute/servers/test_server_basic_ops.py b/tempest/tests/compute/servers/test_server_basic_ops.py
index 04b1451..3453d86 100644
--- a/tempest/tests/compute/servers/test_server_basic_ops.py
+++ b/tempest/tests/compute/servers/test_server_basic_ops.py
@@ -79,7 +79,7 @@
try:
self.compute_client.security_group_rules.create(
self.secgroup.id, **ruleset)
- except:
+ except Exception:
self.fail("Failed to create rule in security group.")
def test_003_boot_instance(self):
diff --git a/tempest/tests/compute/servers/test_server_metadata.py b/tempest/tests/compute/servers/test_server_metadata.py
index 4022dad..844e394 100644
--- a/tempest/tests/compute/servers/test_server_metadata.py
+++ b/tempest/tests/compute/servers/test_server_metadata.py
@@ -135,7 +135,7 @@
"""Negative test: GET on nonexistant server should not succeed"""
try:
resp, meta = self.client.get_server_metadata_item(999, 'test2')
- except:
+ except Exception:
pass
else:
self.fail('GET on nonexistant server should not succeed')
@@ -147,7 +147,7 @@
"""
try:
resp, metadata = self.client.list_server_metadata(999)
- except:
+ except Exception:
pass
else:
self.fail('List metadata on a non existant server should'
@@ -161,7 +161,7 @@
meta = {'meta1': 'data1'}
try:
resp, metadata = self.client.set_server_metadata(999, meta)
- except:
+ except Exception:
pass
else:
self.fail('Set metadata on a non existant server should'
@@ -175,7 +175,7 @@
meta = {'key1': 'value1', 'key2': 'value2'}
try:
resp, metadata = self.client.update_server_metadata(999, meta)
- except:
+ except Exception:
pass
else:
self.fail('An update should not happen for a nonexistant image')
@@ -191,7 +191,7 @@
#Delete the metadata item
try:
resp, metadata = self.client.delete_server_metadata_item(999, 'd')
- except:
+ except Exception:
pass
else:
self.fail('A delete should not happen for a nonexistant image')
diff --git a/tempest/tests/compute/servers/test_server_personality.py b/tempest/tests/compute/servers/test_server_personality.py
index 75457d1..3003a52 100644
--- a/tempest/tests/compute/servers/test_server_personality.py
+++ b/tempest/tests/compute/servers/test_server_personality.py
@@ -19,8 +19,8 @@
from nose.plugins.attrib import attr
-from tempest import exceptions
from tempest.common.utils.data_utils import rand_name
+from tempest import exceptions
from tempest.tests.compute import base
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/servers/test_servers_negative.py b/tempest/tests/compute/servers/test_servers_negative.py
index fb88d1e..60f3daf 100644
--- a/tempest/tests/compute/servers/test_servers_negative.py
+++ b/tempest/tests/compute/servers/test_servers_negative.py
@@ -17,13 +17,13 @@
import sys
+import nose
from nose.plugins.attrib import attr
import unittest2 as unittest
-import nose
+from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
from tempest import openstack
-from tempest.common.utils.data_utils import rand_name
from tempest.tests.compute.base import BaseComputeTest
diff --git a/tempest/tests/compute/servers/test_servers_whitebox.py b/tempest/tests/compute/servers/test_servers_whitebox.py
index 980f6cf..c02a1a2 100644
--- a/tempest/tests/compute/servers/test_servers_whitebox.py
+++ b/tempest/tests/compute/servers/test_servers_whitebox.py
@@ -15,12 +15,12 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest import exceptions
-from tempest import whitebox
-from tempest.tests.identity.base import BaseIdentityAdminTest
+import nose
from nose.plugins.attrib import attr
-import nose
+from tempest import exceptions
+from tempest.tests.identity.base import BaseIdentityAdminTest
+from tempest import whitebox
@attr(type='whitebox')
@@ -149,7 +149,7 @@
self.assertEqual(1, result.deleted)
self.assertEqual('deleted', result.vm_state)
self.assertEqual(None, result.task_state)
- except:
+ except Exception:
self.fail("Should be able to delete a server when vm_state=%s and "
"task_state=%s" % (vm_state, task_state))
@@ -164,7 +164,7 @@
self.assertRaises(exceptions.Unauthorized,
self.client.delete_server,
self.shared_server['id'])
- except:
+ except Exception:
self.fail("Should not allow delete server when vm_state=%s and "
"task_state=%s" % (vm_state, task_state))
finally:
diff --git a/tempest/tests/compute/test_authorization.py b/tempest/tests/compute/test_authorization.py
index 12fa94b..a31ee49 100644
--- a/tempest/tests/compute/test_authorization.py
+++ b/tempest/tests/compute/test_authorization.py
@@ -16,15 +16,16 @@
# under the License.
from nose.plugins.attrib import attr
-from nose.tools import raises
from nose import SkipTest
+from nose.tools import raises
import unittest2 as unittest
-from tempest import openstack
-from tempest.common.utils.data_utils import rand_name, parse_image_id
+from tempest.common.utils.data_utils import parse_image_id
+from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
-from tempest.tests.compute.base import BaseComputeTest
+from tempest import openstack
from tempest.tests import compute
+from tempest.tests.compute.base import BaseComputeTest
class AuthorizationTest(BaseComputeTest):
@@ -232,6 +233,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)
@@ -323,7 +325,6 @@
"happen if the tenant id does not match the"
" current user")
- @unittest.skip("Skipped until the Bug #1001118 is resolved")
@raises(exceptions.NotFound)
@attr(type='negative')
def test_delete_security_group_rule_of_alt_account_fails(self):
diff --git a/tempest/tests/compute/test_live_block_migration.py b/tempest/tests/compute/test_live_block_migration.py
index 92c2cf6..48d374f 100644
--- a/tempest/tests/compute/test_live_block_migration.py
+++ b/tempest/tests/compute/test_live_block_migration.py
@@ -15,19 +15,19 @@
# License for the specific language governing permissions and limitations
# under the License.
-import nose
-import unittest2 as unittest
-from nose.plugins.attrib import attr
import random
import string
-from tempest.tests.compute import base
+import nose
+from nose.plugins.attrib import attr
+import unittest2 as unittest
+
from tempest.common.utils.linux.remote_client import RemoteClient
from tempest import config
from tempest import exceptions
-
from tempest.services.compute.json.hosts_client import HostsClientJSON
from tempest.services.compute.json.servers_client import ServersClientJSON
+from tempest.tests.compute import base
@attr(category='live-migration')
diff --git a/tempest/tests/compute/test_quotas.py b/tempest/tests/compute/test_quotas.py
index d07064f..bf7d648 100644
--- a/tempest/tests/compute/test_quotas.py
+++ b/tempest/tests/compute/test_quotas.py
@@ -45,5 +45,5 @@
resp, quota_set = self.client.get_quota_set(self.tenant_id)
self.assertEqual(200, resp.status)
self.assertSequenceEqual(expected_quota_set, quota_set)
- except:
+ except Exception:
self.fail("Quota set for tenant did not have default limits")
diff --git a/tempest/tests/compute/volumes/test_attach_volume.py b/tempest/tests/compute/volumes/test_attach_volume.py
index cb695c1..b95a9fd 100644
--- a/tempest/tests/compute/volumes/test_attach_volume.py
+++ b/tempest/tests/compute/volumes/test_attach_volume.py
@@ -18,9 +18,9 @@
from nose.plugins.attrib import attr
import unittest2 as unittest
-import tempest.config
from tempest.common.utils.data_utils import rand_name
from tempest.common.utils.linux.remote_client import RemoteClient
+import tempest.config
from tempest import openstack
from tempest.tests.compute import base
diff --git a/tempest/tests/compute/volumes/test_volumes_list.py b/tempest/tests/compute/volumes/test_volumes_list.py
index 2c09add..5162a85 100644
--- a/tempest/tests/compute/volumes/test_volumes_list.py
+++ b/tempest/tests/compute/volumes/test_volumes_list.py
@@ -83,7 +83,7 @@
resp, volume = cls.client.get_volume(volume['id'])
cls.volume_list.append(volume)
cls.volume_id_list.append(volume['id'])
- except:
+ except Exception:
if cls.volume_list:
# We could not create all the volumes, though we were able
# to create *some* of the volumes. This is typically
@@ -129,7 +129,7 @@
resp, volume = cls.client.get_volume(volume['id'])
cls.volume_list.append(volume)
cls.volume_id_list.append(volume['id'])
- except:
+ except Exception:
if cls.volume_list:
# We could not create all the volumes, though we were able
# to create *some* of the volumes. This is typically
diff --git a/tempest/tests/compute/volumes/test_volumes_negative.py b/tempest/tests/compute/volumes/test_volumes_negative.py
index fa14640..6994ab1 100644
--- a/tempest/tests/compute/volumes/test_volumes_negative.py
+++ b/tempest/tests/compute/volumes/test_volumes_negative.py
@@ -18,8 +18,8 @@
from nose.plugins.attrib import attr
from nose.tools import raises
-from tempest import exceptions
from tempest.common.utils.data_utils import rand_name
+from tempest import exceptions
from tempest.tests.compute import base
diff --git a/tempest/tests/identity/admin/test_roles.py b/tempest/tests/identity/admin/test_roles.py
index 637cee5..0e1da7d 100644
--- a/tempest/tests/identity/admin/test_roles.py
+++ b/tempest/tests/identity/admin/test_roles.py
@@ -17,8 +17,8 @@
import unittest2 as unittest
-from tempest import exceptions
from tempest.common.utils.data_utils import rand_name
+from tempest import exceptions
from tempest.tests.identity import base
diff --git a/tempest/tests/identity/admin/test_services.py b/tempest/tests/identity/admin/test_services.py
index da697ab..6baa7c2 100644
--- a/tempest/tests/identity/admin/test_services.py
+++ b/tempest/tests/identity/admin/test_services.py
@@ -17,8 +17,8 @@
import nose
-from tempest import exceptions
from tempest.common.utils.data_utils import rand_name
+from tempest import exceptions
from tempest.tests.identity import base
diff --git a/tempest/tests/identity/admin/test_tenants.py b/tempest/tests/identity/admin/test_tenants.py
index 1b4ec18..226aae6 100644
--- a/tempest/tests/identity/admin/test_tenants.py
+++ b/tempest/tests/identity/admin/test_tenants.py
@@ -17,8 +17,8 @@
import unittest2 as unittest
-from tempest import exceptions
from tempest.common.utils.data_utils import rand_name
+from tempest import exceptions
from tempest.tests.identity import base
diff --git a/tempest/tests/identity/admin/test_users.py b/tempest/tests/identity/admin/test_users.py
index a724ce9..e2938bd 100644
--- a/tempest/tests/identity/admin/test_users.py
+++ b/tempest/tests/identity/admin/test_users.py
@@ -18,8 +18,8 @@
from nose.plugins.attrib import attr
import unittest2 as unittest
-from tempest import exceptions
from tempest.common.utils.data_utils import rand_name
+from tempest import exceptions
from tempest.tests.identity import base
diff --git a/tempest/tests/network/base.py b/tempest/tests/network/base.py
index 887056e..78a69f8 100644
--- a/tempest/tests/network/base.py
+++ b/tempest/tests/network/base.py
@@ -18,9 +18,9 @@
import nose
import unittest2 as unittest
+from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
from tempest import openstack
-from tempest.common.utils.data_utils import rand_name
class BaseNetworkTest(unittest.TestCase):
diff --git a/tempest/tests/object_storage/test_container_services.py b/tempest/tests/object_storage/test_container_services.py
index e57256b..b99859e 100644
--- a/tempest/tests/object_storage/test_container_services.py
+++ b/tempest/tests/object_storage/test_container_services.py
@@ -16,7 +16,9 @@
# under the License.
from nose.plugins.attrib import attr
-from tempest.common.utils.data_utils import rand_name, arbitrary_string
+
+from tempest.common.utils.data_utils import arbitrary_string
+from tempest.common.utils.data_utils import rand_name
from tempest.tests.object_storage import base
diff --git a/tempest/tests/object_storage/test_object_services.py b/tempest/tests/object_storage/test_object_services.py
index d0862eb..3be2bee 100644
--- a/tempest/tests/object_storage/test_object_services.py
+++ b/tempest/tests/object_storage/test_object_services.py
@@ -16,7 +16,9 @@
# under the License.
from nose.plugins.attrib import attr
-from tempest.common.utils.data_utils import rand_name, arbitrary_string
+
+from tempest.common.utils.data_utils import arbitrary_string
+from tempest.common.utils.data_utils import rand_name
from tempest.tests.object_storage import base
@@ -122,7 +124,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 +142,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 +162,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 +204,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/tempest/tests/volume/admin/__init__.py b/tempest/tests/volume/admin/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/tests/volume/admin/__init__.py
diff --git a/tempest/tests/volume/admin/test_volume_types.py b/tempest/tests/volume/admin/test_volume_types.py
new file mode 100644
index 0000000..224a927
--- /dev/null
+++ b/tempest/tests/volume/admin/test_volume_types.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 tempest.common.utils.data_utils import rand_name
+from tempest.services.volume.json.admin import volume_types_client
+from tempest.tests.volume.base import BaseVolumeTest
+
+
+class VolumeTypesTest(BaseVolumeTest):
+
+ @classmethod
+ def setUpClass(cls):
+ super(VolumeTypesTest, 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.client = volume_types_client.VolumeTypesClientJSON(cls.config,
+ adm_user,
+ adm_pass,
+ auth_url,
+ adm_tenant)
+
+ @classmethod
+ def tearDownClass(cls):
+ super(VolumeTypesTest, cls).tearDownClass()
+
+ def test_volume_type_list(self):
+ """List Volume types."""
+ try:
+ resp, body = self.client.list_volume_types()
+ self.assertEqual(200, resp.status)
+ self.assertTrue(type(body), list)
+ except Exception:
+ self.fail("Could not list volume types")
+
+ def test_create_get_delete_volume_with_volume_type_and_extra_specs(self):
+ """ Create/get/delete volume with volume_type and extra spec. """
+ try:
+ volume = {}
+ vol_name = rand_name("volume-")
+ vol_type_name = rand_name("volume-type-")
+ extra_specs = {"Spec1": "Val1", "Spec2": "Val2"}
+ body = {}
+ resp, body = self.client.create_volume_type(vol_type_name,
+ extra_specs=
+ extra_specs)
+ self.assertEqual(200, resp.status)
+ self.assertTrue('id' in body)
+ self.assertTrue('name' in body)
+ resp, volume = self.volumes_client.\
+ create_volume(size=1, display_name=vol_name,
+ volume_type=vol_type_name)
+ self.assertEqual(200, resp.status)
+ self.assertTrue('id' in volume)
+ self.assertTrue('display_name' in volume)
+ self.assertEqual(volume['display_name'], vol_name,
+ "The created volume name is not equal "
+ "to the requested name")
+ self.assertTrue(volume['id'] is not None,
+ "Field volume id is empty or not found.")
+ self.volumes_client.wait_for_volume_status(volume['id'],
+ 'available')
+ resp, fetched_volume = self.volumes_client.\
+ get_volume(volume['id'])
+ self.assertEqual(200, resp.status)
+ self.assertEqual(vol_name, fetched_volume['display_name'],
+ 'The fetched Volume is different '
+ 'from the created Volume')
+ self.assertEqual(volume['id'], fetched_volume['id'],
+ 'The fetched Volume is different '
+ 'from the created Volume')
+ self.assertEqual(vol_type_name, fetched_volume['volume_type'],
+ 'The fetched Volume is different '
+ 'from the created Volume')
+ except Exception:
+ self.fail("Could not create correct volume with volume_type")
+ finally:
+ if volume:
+ # Delete the Volume if it was created
+ resp, _ = self.volumes_client.delete_volume(volume['id'])
+ self.assertEqual(202, resp.status)
+
+ if body:
+ resp, _ = self.client.delete_volume_type(body['id'])
+ self.assertEqual(202, resp.status)
+
+ def test_volume_type_create_delete(self):
+ """ Create/Delete volume type."""
+ try:
+ name = rand_name("volume-type-")
+ extra_specs = {"Spec1": "Val1", "Spec2": "Val2"}
+ resp, body = self.client.\
+ create_volume_type(name, extra_specs=extra_specs)
+ self.assertEqual(200, resp.status)
+ self.assertTrue('id' in body)
+ self.assertTrue('name' in body)
+ self.assertEqual(body['name'], name,
+ "The created volume_type name is not equal "
+ "to the requested name")
+ self.assertTrue(body['id'] is not None,
+ "Field volume_type id is empty or not found.")
+ resp, fetched_volume_type = self.client.\
+ delete_volume_type(body['id'])
+ self.assertEqual(202, resp.status)
+ except Exception:
+ self.fail("Could not create a volume_type")
+
+ def test_volume_type_create_get(self):
+ """ Create/get volume type."""
+ try:
+ body = {}
+ name = rand_name("volume-type-")
+ extra_specs = {"Spec1": "Val1", "Spec2": "Val2"}
+ resp, body = self.client.\
+ create_volume_type(name, extra_specs=extra_specs)
+ self.assertEqual(200, resp.status)
+ self.assertTrue('id' in body)
+ self.assertTrue('name' in body)
+ self.assertEqual(body['name'], name,
+ "The created volume_type name is not equal "
+ "to the requested name")
+ self.assertTrue(body['id'] is not None,
+ "Field volume_type id is empty or not found.")
+ resp, fetched_volume_type = self.client.get_volume_type(body['id'])
+ self.assertEqual(200, resp.status)
+ self.assertEqual(name, fetched_volume_type['name'],
+ 'The fetched Volume_type is different '
+ 'from the created Volume_type')
+ self.assertEqual(str(body['id']), fetched_volume_type['id'],
+ 'The fetched Volume_type is different '
+ 'from the created Volume_type')
+ self.assertEqual(extra_specs, fetched_volume_type['extra_specs'],
+ 'The fetched Volume_type is different '
+ 'from the created Volume_type')
+ except Exception:
+ self.fail("Could not create a volume_type")
+ finally:
+ if body:
+ resp, _ = self.client.delete_volume_type(body['id'])
+ self.assertEqual(202, resp.status)
diff --git a/tempest/tests/volume/admin/test_volume_types_extra_specs.py b/tempest/tests/volume/admin/test_volume_types_extra_specs.py
new file mode 100644
index 0000000..181c37c
--- /dev/null
+++ b/tempest/tests/volume/admin/test_volume_types_extra_specs.py
@@ -0,0 +1,109 @@
+# 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 tempest.common.utils.data_utils import rand_name
+from tempest.services.volume.json.admin import volume_types_client
+from tempest.tests.volume.base import BaseVolumeTest
+
+
+class VolumeTypesExtraSpecsTest(BaseVolumeTest):
+
+ @classmethod
+ def setUpClass(cls):
+ super(VolumeTypesExtraSpecsTest, 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.client = volume_types_client.VolumeTypesClientJSON(cls.config,
+ adm_user,
+ adm_pass,
+ auth_url,
+ adm_tenant)
+
+ vol_type_name = rand_name('Volume-type-')
+ cls.extra_spec = {"spec1": "val1"}
+ resp, cls.volume_type = cls.client.create_volume_type(vol_type_name)
+
+ @classmethod
+ def tearDownClass(cls):
+ super(VolumeTypesExtraSpecsTest, cls).tearDownClass()
+ cls.client.delete_volume_type(cls.volume_type['id'])
+
+ def test_volume_type_extra_specs_list(self):
+ """List Volume types extra specs."""
+ try:
+ resp, body = self.client.\
+ list_volume_types_extra_specs(self.volume_type['id'])
+ self.assertEqual(200, resp.status)
+ self.assertTrue(type(body), dict)
+ self.assertTrue('spec1' in body, "Incorrect volume type extra"
+ " spec returned")
+ except Exception:
+ self.fail("Could not list volume types extra specs")
+
+ def test_volume_type_extra_specs_update(self):
+ """ Update volume type extra specs"""
+ try:
+ extra_spec = {"spec1": "val2"}
+ resp, body = self.client.\
+ update_volume_type_extra_specs(self.volume_type['id'],
+ extra_spec.keys()[0],
+ extra_spec)
+ self.assertEqual(200, resp.status)
+ self.assertTrue('spec1' in body,
+ "Volume type extra spec incorrectly updated")
+ self.assertEqual(extra_spec['spec1'], body['spec1'],
+ "Volume type extra spec incorrectly updated")
+ except Exception:
+ self.fail("Couldnt update volume type extra spec")
+
+ def test_volume_type_extra_spec_create_delete(self):
+ """ Create/Delete volume type extra spec."""
+ try:
+ extra_specs = {"spec2": "val1"}
+ resp, body = self.client.\
+ create_volume_type_extra_specs(self.volume_type['id'], extra_specs)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(extra_specs, body,
+ "Volume type extra spec incorrectly created")
+ resp, _ = self.client.\
+ delete_volume_type_extra_specs(self.volume_type['id'],
+ extra_specs.keys()[0])
+ self.assertEqual(202, resp.status)
+ except Exception:
+ self.fail("Could not create a volume_type extra spec")
+
+ def test_volume_type_extra_spec_create_get(self):
+ """ Create/get volume type extra spec"""
+ try:
+ extra_specs = {"spec1": "val1"}
+ resp, body = self.client.\
+ create_volume_type_extra_specs(self.volume_type['id'], extra_specs)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(extra_specs, body,
+ "Volume type extra spec incorrectly created")
+ resp, fetched_vol_type_extra_spec = self.client.\
+ get_volume_type_extra_specs(self.volume_type['id'],
+ extra_specs.keys()[0])
+ self.assertEqual(200, resp.status)
+ self.assertEqual(extra_specs, body,
+ "Volume type extra spec incorrectly fetched")
+ except Exception:
+ self.fail("Could not create a volume_type extra spec")
diff --git a/tempest/tests/volume/base.py b/tempest/tests/volume/base.py
index 6af4bbf..f4401ff 100644
--- a/tempest/tests/volume/base.py
+++ b/tempest/tests/volume/base.py
@@ -17,14 +17,14 @@
import logging
import time
-import nose
+import nose
import unittest2 as unittest
-from tempest import config
-from tempest import openstack
from tempest.common.utils.data_utils import rand_name
+from tempest import config
from tempest import exceptions
+from tempest import openstack
LOG = logging.getLogger(__name__)
@@ -138,7 +138,7 @@
while True:
try:
condition()
- except:
+ except Exception:
pass
else:
return
diff --git a/tempest/tests/volume/test_volumes_actions.py b/tempest/tests/volume/test_volumes_actions.py
index f76235d..52c270c 100644
--- a/tempest/tests/volume/test_volumes_actions.py
+++ b/tempest/tests/volume/test_volumes_actions.py
@@ -58,7 +58,7 @@
mountpoint)
self.assertEqual(202, resp.status)
self.client.wait_for_volume_status(self.volume['id'], 'in-use')
- except:
+ except Exception:
self.fail("Could not attach volume to instance")
finally:
# Detach the volume from the instance
@@ -83,7 +83,7 @@
self.assertEqual(self.server['id'], attachment['server_id'])
self.assertEqual(self.volume['id'], attachment['id'])
self.assertEqual(self.volume['id'], attachment['volume_id'])
- except:
+ except Exception:
self.fail("Could not get attachment details from volume")
finally:
self.client.detach_volume(self.volume['id'])
diff --git a/tempest/tests/volume/test_volumes_get.py b/tempest/tests/volume/test_volumes_get.py
index fa8e86e..048c340 100644
--- a/tempest/tests/volume/test_volumes_get.py
+++ b/tempest/tests/volume/test_volumes_get.py
@@ -58,7 +58,7 @@
fetched_volume['metadata'],
'The fetched Volume is different '
'from the created Volume')
- except:
+ except Exception:
self.fail("Could not create a volume")
finally:
if volume:
@@ -85,7 +85,7 @@
resp, fetched_volume = self.client.get_volume(volume['id'])
self.assertEqual(200, resp.status)
self.assertEqual(fetched_volume['metadata'], {})
- except:
+ except Exception:
self.fail("Could not get volume metadata")
finally:
if volume:
diff --git a/tempest/tests/volume/test_volumes_list.py b/tempest/tests/volume/test_volumes_list.py
index e9bafaf..b387b15 100644
--- a/tempest/tests/volume/test_volumes_list.py
+++ b/tempest/tests/volume/test_volumes_list.py
@@ -80,7 +80,7 @@
resp, volume = cls.client.get_volume(volume['id'])
cls.volume_list.append(volume)
cls.volume_id_list.append(volume['id'])
- except:
+ except Exception:
if cls.volume_list:
# We could not create all the volumes, though we were able
# to create *some* of the volumes. This is typically
@@ -126,7 +126,7 @@
resp, volume = cls.client.get_volume(volume['id'])
cls.volume_list.append(volume)
cls.volume_id_list.append(volume['id'])
- except:
+ except Exception:
if cls.volume_list:
# We could not create all the volumes, though we were able
# to create *some* of the volumes. This is typically
diff --git a/tempest/tests/volume/test_volumes_negative.py b/tempest/tests/volume/test_volumes_negative.py
index bf7e5f0..2c8b006 100644
--- a/tempest/tests/volume/test_volumes_negative.py
+++ b/tempest/tests/volume/test_volumes_negative.py
@@ -18,8 +18,8 @@
from nose.plugins.attrib import attr
from nose.tools import raises
-from tempest import exceptions
from tempest.common.utils.data_utils import rand_name
+from tempest import exceptions
from tempest.tests.volume import base
diff --git a/tempest/whitebox.py b/tempest/whitebox.py
index 2711903..39cd666 100644
--- a/tempest/whitebox.py
+++ b/tempest/whitebox.py
@@ -17,15 +17,15 @@
import logging
import os
-import sys
import shlex
import subprocess
+import sys
import nose
from sqlalchemy import create_engine, MetaData
-from tempest.common.utils.data_utils import rand_name
from tempest.common.ssh import Client
+from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
from tempest import test
from tempest.tests import compute
diff --git a/tools/hacking.py b/tools/hacking.py
new file mode 100755
index 0000000..6e66005
--- /dev/null
+++ b/tools/hacking.py
@@ -0,0 +1,484 @@
+#!/usr/bin/env python
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright (c) 2012, Cloudscaling
+# 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.
+
+"""tempest HACKING file compliance testing
+
+built on top of pep8.py
+"""
+
+import fnmatch
+import inspect
+import logging
+import os
+import re
+import subprocess
+import sys
+import tokenize
+import warnings
+
+import pep8
+
+# Don't need this for testing
+logging.disable('LOG')
+
+#N1xx comments
+#N2xx except
+#N3xx imports
+#N4xx docstrings
+#N5xx dictionaries/lists
+#N6xx calling methods
+#N7xx localization
+#N8xx git commit messages
+
+IMPORT_EXCEPTIONS = ['sqlalchemy', 'migrate']
+DOCSTRING_TRIPLE = ['"""', "'''"]
+VERBOSE_MISSING_IMPORT = os.getenv('HACKING_VERBOSE_MISSING_IMPORT', 'False')
+
+
+# Monkey patch broken excluded filter in pep8
+# See https://github.com/jcrocholl/pep8/pull/111
+def excluded(self, filename):
+ """
+ Check if options.exclude contains a pattern that matches filename.
+ """
+ basename = os.path.basename(filename)
+ return any((pep8.filename_match(filename, self.options.exclude,
+ default=False),
+ pep8.filename_match(basename, self.options.exclude,
+ default=False)))
+
+
+def input_dir(self, dirname):
+ """Check all files in this directory and all subdirectories."""
+ dirname = dirname.rstrip('/')
+ if self.excluded(dirname):
+ return 0
+ counters = self.options.report.counters
+ verbose = self.options.verbose
+ filepatterns = self.options.filename
+ runner = self.runner
+ for root, dirs, files in os.walk(dirname):
+ if verbose:
+ print('directory ' + root)
+ counters['directories'] += 1
+ for subdir in sorted(dirs):
+ if self.excluded(os.path.join(root, subdir)):
+ dirs.remove(subdir)
+ for filename in sorted(files):
+ # contain a pattern that matches?
+ if ((pep8.filename_match(filename, filepatterns) and
+ not self.excluded(filename))):
+ runner(os.path.join(root, filename))
+
+
+def is_import_exception(mod):
+ return (mod in IMPORT_EXCEPTIONS or
+ any(mod.startswith(m + '.') for m in IMPORT_EXCEPTIONS))
+
+
+def import_normalize(line):
+ # convert "from x import y" to "import x.y"
+ # handle "from x import y as z" to "import x.y as z"
+ split_line = line.split()
+ if ("import" in line and line.startswith("from ") and "," not in line and
+ split_line[2] == "import" and split_line[3] != "*" and
+ split_line[1] != "__future__" and
+ (len(split_line) == 4 or
+ (len(split_line) == 6 and split_line[4] == "as"))):
+ return "import %s.%s" % (split_line[1], split_line[3])
+ else:
+ return line
+
+
+def tempest_todo_format(physical_line):
+ """Check for 'TODO()'.
+
+ tempest HACKING guide recommendation for TODO:
+ Include your name with TODOs as in "#TODO(termie)"
+ N101
+ """
+ pos = physical_line.find('TODO')
+ pos1 = physical_line.find('TODO(')
+ pos2 = physical_line.find('#') # make sure it's a comment
+ if (pos != pos1 and pos2 >= 0 and pos2 < pos):
+ return pos, "TEMPEST N101: Use TODO(NAME)"
+
+
+def tempest_except_format(logical_line):
+ """Check for 'except:'.
+
+ tempest HACKING guide recommends not using except:
+ Do not write "except:", use "except Exception:" at the very least
+ N201
+ """
+ if logical_line.startswith("except:"):
+ yield 6, "TEMPEST N201: no 'except:' at least use 'except Exception:'"
+
+
+def tempest_except_format_assert(logical_line):
+ """Check for 'assertRaises(Exception'.
+
+ tempest HACKING guide recommends not using assertRaises(Exception...):
+ Do not use overly broad Exception type
+ N202
+ """
+ if logical_line.startswith("self.assertRaises(Exception"):
+ yield 1, "TEMPEST N202: assertRaises Exception too broad"
+
+
+def tempest_one_import_per_line(logical_line):
+ """Check for import format.
+
+ tempest HACKING guide recommends one import per line:
+ Do not import more than one module per line
+
+ Examples:
+ BAD: from tempest.common.rest_client import RestClient, RestClientXML
+ N301
+ """
+ pos = logical_line.find(',')
+ parts = logical_line.split()
+ if (pos > -1 and (parts[0] == "import" or
+ parts[0] == "from" and parts[2] == "import") and
+ not is_import_exception(parts[1])):
+ yield pos, "TEMPEST N301: one import per line"
+
+_missingImport = set([])
+
+
+def tempest_import_module_only(logical_line):
+ """Check for import module only.
+
+ tempest HACKING guide recommends importing only modules:
+ Do not import objects, only modules
+ N302 import only modules
+ N303 Invalid Import
+ N304 Relative Import
+ """
+ def importModuleCheck(mod, parent=None, added=False):
+ """
+ If can't find module on first try, recursively check for relative
+ imports
+ """
+ current_path = os.path.dirname(pep8.current_file)
+ try:
+ with warnings.catch_warnings():
+ warnings.simplefilter('ignore', DeprecationWarning)
+ valid = True
+ if parent:
+ if is_import_exception(parent):
+ return
+ parent_mod = __import__(parent, globals(), locals(),
+ [mod], -1)
+ valid = inspect.ismodule(getattr(parent_mod, mod))
+ else:
+ __import__(mod, globals(), locals(), [], -1)
+ valid = inspect.ismodule(sys.modules[mod])
+ if not valid:
+ if added:
+ sys.path.pop()
+ added = False
+ return logical_line.find(mod), ("TEMPEST N304: No "
+ "relative imports. "
+ "'%s' is a relative "
+ "import"
+ % logical_line)
+ return logical_line.find(mod), ("TEMPEST N302: import only"
+ " modules. '%s' does not "
+ "import a module"
+ % logical_line)
+
+ except (ImportError, NameError) as exc:
+ if not added:
+ added = True
+ sys.path.append(current_path)
+ return importModuleCheck(mod, parent, added)
+ else:
+ name = logical_line.split()[1]
+ if name not in _missingImport:
+ if VERBOSE_MISSING_IMPORT != 'False':
+ print >> sys.stderr, ("ERROR: import '%s' in %s "
+ "failed: %s" %
+ (name, pep8.current_file, exc))
+ _missingImport.add(name)
+ added = False
+ sys.path.pop()
+ return
+
+ except AttributeError:
+ # Invalid import
+ return logical_line.find(mod), ("TEMPEST N303: Invalid import, "
+ "AttributeError raised")
+
+ # convert "from x import y" to " import x.y"
+ # convert "from x import y as z" to " import x.y"
+ import_normalize(logical_line)
+ split_line = logical_line.split()
+
+ if (logical_line.startswith("import ") and "," not in logical_line and
+ (len(split_line) == 2 or
+ (len(split_line) == 4 and split_line[2] == "as"))):
+ mod = split_line[1]
+ rval = importModuleCheck(mod)
+ if rval is not None:
+ yield rval
+
+ # TODO(jogo) handle "from x import *"
+
+#TODO(jogo): import template: N305
+
+
+def tempest_import_alphabetical(logical_line, line_number, lines):
+ """Check for imports in alphabetical order.
+
+ Tempest HACKING guide recommendation for imports:
+ imports in human alphabetical order
+ N306
+ """
+ # handle import x
+ # use .lower since capitalization shouldn't dictate order
+ split_line = import_normalize(logical_line.strip()).lower().split()
+ split_previous = import_normalize(lines[
+ line_number - 2]).strip().lower().split()
+ # with or without "as y"
+ length = [2, 4]
+ if (len(split_line) in length and len(split_previous) in length and
+ split_line[0] == "import" and split_previous[0] == "import"):
+ if split_line[1] < split_previous[1]:
+ yield (0, "TEMPEST N306: imports not in alphabetical order"
+ " (%s, %s)"
+ % (split_previous[1], split_line[1]))
+
+
+def tempest_docstring_start_space(physical_line):
+ """Check for docstring not start with space.
+
+ tempest HACKING guide recommendation for docstring:
+ Docstring should not start with space
+ N401
+ """
+ pos = max([physical_line.find(i) for i in DOCSTRING_TRIPLE]) # start
+ if (pos != -1 and len(physical_line) > pos + 1):
+ if (physical_line[pos + 3] == ' '):
+ return (pos, "TEMPEST N401: one line docstring should not start"
+ " with a space")
+
+
+def tempest_docstring_one_line(physical_line):
+ """Check one line docstring end.
+
+ tempest HACKING guide recommendation for one line docstring:
+ A one line docstring looks like this and ends in a period.
+ N402
+ """
+ pos = max([physical_line.find(i) for i in DOCSTRING_TRIPLE]) # start
+ end = max([physical_line[-4:-1] == i for i in DOCSTRING_TRIPLE]) # end
+ if (pos != -1 and end and len(physical_line) > pos + 4):
+ if (physical_line[-5] != '.'):
+ return pos, "TEMPEST N402: one line docstring needs a period"
+
+
+def tempest_docstring_multiline_end(physical_line):
+ """Check multi line docstring end.
+
+ Tempest HACKING guide recommendation for docstring:
+ Docstring should end on a new line
+ N403
+ """
+ pos = max([physical_line.find(i) for i in DOCSTRING_TRIPLE]) # start
+ if (pos != -1 and len(physical_line) == pos):
+ if (physical_line[pos + 3] == ' '):
+ return (pos, "TEMPEST N403: multi line docstring end on new line")
+
+
+FORMAT_RE = re.compile("%(?:"
+ "%|" # Ignore plain percents
+ "(\(\w+\))?" # mapping key
+ "([#0 +-]?" # flag
+ "(?:\d+|\*)?" # width
+ "(?:\.\d+)?" # precision
+ "[hlL]?" # length mod
+ "\w))") # type
+
+
+class LocalizationError(Exception):
+ pass
+
+
+def check_i18n():
+ """Generator that checks token stream for localization errors.
+
+ Expects tokens to be ``send``ed one by one.
+ Raises LocalizationError if some error is found.
+ """
+ while True:
+ try:
+ token_type, text, _, _, line = yield
+ except GeneratorExit:
+ return
+ if (token_type == tokenize.NAME and text == "_" and
+ not line.startswith('def _(msg):')):
+
+ while True:
+ token_type, text, start, _, _ = yield
+ if token_type != tokenize.NL:
+ break
+ if token_type != tokenize.OP or text != "(":
+ continue # not a localization call
+
+ format_string = ''
+ while True:
+ token_type, text, start, _, _ = yield
+ if token_type == tokenize.STRING:
+ format_string += eval(text)
+ elif token_type == tokenize.NL:
+ pass
+ else:
+ break
+
+ if not format_string:
+ raise LocalizationError(start,
+ "TEMEPST N701: Empty localization "
+ "string")
+ if token_type != tokenize.OP:
+ raise LocalizationError(start,
+ "TEMPEST N701: Invalid localization "
+ "call")
+ if text != ")":
+ if text == "%":
+ raise LocalizationError(start,
+ "TEMPEST N702: Formatting "
+ "operation should be outside"
+ " of localization method call")
+ elif text == "+":
+ raise LocalizationError(start,
+ "TEMPEST N702: Use bare string "
+ "concatenation instead of +")
+ else:
+ raise LocalizationError(start,
+ "TEMPEST N702: Argument to _ must"
+ " be just a string")
+
+ format_specs = FORMAT_RE.findall(format_string)
+ positional_specs = [(key, spec) for key, spec in format_specs
+ if not key and spec]
+ # not spec means %%, key means %(smth)s
+ if len(positional_specs) > 1:
+ raise LocalizationError(start,
+ "TEMPEST N703: Multiple positional "
+ "placeholders")
+
+
+def tempest_localization_strings(logical_line, tokens):
+ """Check localization in line.
+
+ N701: bad localization call
+ N702: complex expression instead of string as argument to _()
+ N703: multiple positional placeholders
+ """
+
+ gen = check_i18n()
+ next(gen)
+ try:
+ map(gen.send, tokens)
+ gen.close()
+ except LocalizationError as e:
+ yield e.args
+
+#TODO(jogo) Dict and list objects
+
+current_file = ""
+
+
+def readlines(filename):
+ """Record the current file being tested."""
+ pep8.current_file = filename
+ return open(filename).readlines()
+
+
+def add_tempest():
+ """Monkey patch in tempest guidelines.
+
+ Look for functions that start with tempest_ and have arguments
+ and add them to pep8 module
+ Assumes you know how to write pep8.py checks
+ """
+ for name, function in globals().items():
+ if not inspect.isfunction(function):
+ continue
+ args = inspect.getargspec(function)[0]
+ if args and name.startswith("tempest"):
+ exec("pep8.%s = %s" % (name, name))
+
+
+def once_git_check_commit_title():
+ """Check git commit messages.
+
+ tempest HACKING recommends not referencing a bug or blueprint
+ in first line, it should provide an accurate description of the change
+ N801
+ N802 Title limited to 50 chars
+ """
+ #Get title of most recent commit
+
+ subp = subprocess.Popen(['git', 'log', '--no-merges', '--pretty=%s', '-1'],
+ stdout=subprocess.PIPE)
+ title = subp.communicate()[0]
+ if subp.returncode:
+ raise Exception("git log failed with code %s" % subp.returncode)
+
+ #From https://github.com/openstack/openstack-ci-puppet
+ # /blob/master/modules/gerrit/manifests/init.pp#L74
+ #Changeid|bug|blueprint
+ git_keywords = (r'(I[0-9a-f]{8,40})|'
+ '([Bb]ug|[Ll][Pp])[\s\#:]*(\d+)|'
+ '([Bb]lue[Pp]rint|[Bb][Pp])[\s\#:]*([A-Za-z0-9\\-]+)')
+ GIT_REGEX = re.compile(git_keywords)
+
+ error = False
+ #NOTE(jogo) if match regex but over 3 words, acceptable title
+ if GIT_REGEX.search(title) is not None and len(title.split()) <= 3:
+ print ("N801: git commit title ('%s') should provide an accurate "
+ "description of the change, not just a reference to a bug "
+ "or blueprint" % title.strip())
+ error = True
+ if len(title.decode('utf-8')) > 72:
+ print ("N802: git commit title ('%s') should be under 50 chars"
+ % title.strip())
+ error = True
+ return error
+
+if __name__ == "__main__":
+ #include tempest path
+ sys.path.append(os.getcwd())
+ #Run once tests (not per line)
+ once_error = once_git_check_commit_title()
+ #TEMPEST error codes start with an N
+ pep8.ERRORCODE_REGEX = re.compile(r'[EWN]\d{3}')
+ add_tempest()
+ pep8.current_file = current_file
+ pep8.readlines = readlines
+ pep8.StyleGuide.excluded = excluded
+ pep8.StyleGuide.input_dir = input_dir
+ try:
+ pep8._main()
+ sys.exit(once_error)
+ finally:
+ if len(_missingImport) > 0:
+ print >> sys.stderr, ("%i imports missing in this test environment"
+ % len(_missingImport))
diff --git a/tools/pip-requires b/tools/pip-requires
index 9c861d9..3a2283f 100644
--- a/tools/pip-requires
+++ b/tools/pip-requires
@@ -1,7 +1,7 @@
anyjson
nose
httplib2>=0.7.0
-pika
unittest2
lxml
boto>=2.2.1
+paramiko
diff --git a/tox.ini b/tox.ini
index 433c55f..e2dbdc8 100644
--- a/tox.ini
+++ b/tox.ini
@@ -15,4 +15,4 @@
[testenv:pep8]
deps = pep8==1.3.3
-commands = pep8 --ignore=E121,E122,E125,E126 --repeat --show-source --exclude=.venv,.tox,dist,doc,openstack .
+commands = python tools/hacking.py --ignore=N4,E121,E122,E125,E126 --repeat --show-source --exclude=.venv,.tox,dist,doc,openstack .