Merge "Add ability to skip disk_config tests regardless of extension status"
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/etc/tempest.conf.tpl b/etc/tempest.conf.tpl
deleted file mode 100644
index 8ef5b84..0000000
--- a/etc/tempest.conf.tpl
+++ /dev/null
@@ -1,235 +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
-
-# 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
-# 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 059ac75..7016a30 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -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/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 f430f02..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
@@ -103,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):
@@ -125,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',
@@ -201,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
@@ -213,8 +213,8 @@
#TODO(afazekas): Make sure we can validate all responses, and the
#http library does not do any action automatically
if (resp.status in set((204, 205, 304)) or resp.status < 200 or
- method.upper() == 'HEAD') and body:
- raise exception.ResponseWithNonEmptyBody(status=resp.status)
+ method.upper() == 'HEAD') and resp_body:
+ raise exceptions.ResponseWithNonEmptyBody(status=resp.status)
#NOTE(afazekas):
# If the HTTP Status Code is 205
@@ -228,7 +228,7 @@
if (resp.status == 205 and
0 != len(set(resp.keys()) - set(('status',)) -
self.response_header_lc - self.general_header_lc)):
- raise exception.ResponseWithEntity()
+ raise exceptions.ResponseWithEntity()
#NOTE(afazekas)
# Now the swift sometimes (delete not empty container)
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 22e4742..951fb61 100644
--- a/tempest/common/utils/data_utils.py
+++ b/tempest/common/utils/data_utils.py
@@ -15,10 +15,10 @@
# License for the specific language governing permissions and limitations
# under the License.
+import itertools
import random
import re
import urllib
-import itertools
from tempest import exceptions
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/exceptions.py b/tempest/exceptions.py
index 86ec2eb..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")
@@ -140,7 +140,7 @@
class ResponseWithNonEmptyBody(RFCViolation):
- message = ("RFC Violation! Response with %(status) HTTP Status Code "
+ message = ("RFC Violation! Response with %(status)d HTTP Status Code "
"MUST NOT have a body")
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..2cac843 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):
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 dc825df..1c8d4f3 100644
--- a/tempest/services/compute/json/flavors_client.py
+++ b/tempest/services/compute/json/flavors_client.py
@@ -15,10 +15,11 @@
# 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):
diff --git a/tempest/services/compute/json/floating_ips_client.py b/tempest/services/compute/json/floating_ips_client.py
index 1303c52..15882c7 100644
--- a/tempest/services/compute/json/floating_ips_client.py
+++ b/tempest/services/compute/json/floating_ips_client.py
@@ -15,11 +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 urllib
+from tempest.common.rest_client import RestClient
+from tempest import exceptions
+
class FloatingIPsClientJSON(RestClient):
def __init__(self, config, username, password, auth_url, tenant_name=None):
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 999d6cb..452400a 100644
--- a/tempest/services/compute/json/images_client.py
+++ b/tempest/services/compute/json/images_client.py
@@ -15,12 +15,13 @@
# 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):
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 cf8fed7..f2586e5 100644
--- a/tempest/services/compute/json/security_groups_client.py
+++ b/tempest/services/compute/json/security_groups_client.py
@@ -15,10 +15,11 @@
# 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):
diff --git a/tempest/services/compute/json/servers_client.py b/tempest/services/compute/json/servers_client.py
index 97ef78e..2e34ef8 100644
--- a/tempest/services/compute/json/servers_client.py
+++ b/tempest/services/compute/json/servers_client.py
@@ -15,12 +15,13 @@
# 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):
diff --git a/tempest/services/compute/json/volumes_extensions_client.py b/tempest/services/compute/json/volumes_extensions_client.py
index 1c5d525..6cf6c23 100644
--- a/tempest/services/compute/json/volumes_extensions_client.py
+++ b/tempest/services/compute/json/volumes_extensions_client.py
@@ -15,12 +15,13 @@
# 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):
diff --git a/tempest/services/compute/xml/floating_ips_client.py b/tempest/services/compute/xml/floating_ips_client.py
index fcb16d3..a0059a8 100644
--- a/tempest/services/compute/xml/floating_ips_client.py
+++ b/tempest/services/compute/xml/floating_ips_client.py
@@ -20,9 +20,9 @@
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):
diff --git a/tempest/services/compute/xml/images_client.py b/tempest/services/compute/xml/images_client.py
index b9cb220..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
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/servers_client.py b/tempest/services/compute/xml/servers_client.py
index b354fb9..b33335d 100644
--- a/tempest/services/compute/xml/servers_client.py
+++ b/tempest/services/compute/xml/servers_client.py
@@ -16,16 +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
-import urllib
+
LOG = logging.getLogger(__name__)
diff --git a/tempest/services/compute/xml/volumes_extensions_client.py b/tempest/services/compute/xml/volumes_extensions_client.py
index 871f2e5..1e8c738 100644
--- a/tempest/services/compute/xml/volumes_extensions_client.py
+++ b/tempest/services/compute/xml/volumes_extensions_client.py
@@ -16,16 +16,17 @@
# under the License.
import time
-from lxml import etree
import urllib
-from tempest import exceptions
+from lxml import etree
+
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/container_client.py b/tempest/services/object_storage/container_client.py
index 37a8375..6b5342a 100644
--- a/tempest/services/object_storage/container_client.py
+++ b/tempest/services/object_storage/container_client.py
@@ -94,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:
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 2045f3c..962fe72 100644
--- a/tempest/services/volume/json/volumes_client.py
+++ b/tempest/services/volume/json/volumes_client.py
@@ -70,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 b90c65a..91d0fc7 100644
--- a/tempest/services/volume/xml/volumes_client.py
+++ b/tempest/services/volume/xml/volumes_client.py
@@ -22,11 +22,11 @@
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/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 9d297f6..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:
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 ea23cf5..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
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 1f4408b..4fe4284 100644
--- a/tempest/tests/compute/servers/test_create_server.py
+++ b/tempest/tests/compute/servers/test_create_server.py
@@ -21,11 +21,12 @@
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
-from tempest.tests.compute import base
+import tempest.config
from tempest.tests import compute
+from tempest.tests.compute import base
class ServersTest(object):
diff --git a/tempest/tests/compute/servers/test_disk_config.py b/tempest/tests/compute/servers/test_disk_config.py
index 1273fe4..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):
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_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 9b6be80..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):
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 97b7e0d..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
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 e9baed5..3a2283f 100644
--- a/tools/pip-requires
+++ b/tools/pip-requires
@@ -4,3 +4,4 @@
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 .