Merge "tempest/config.py parse some sections incorrectly"
diff --git a/HACKING.rst b/HACKING.rst
index 9878b67..7871f60 100644
--- a/HACKING.rst
+++ b/HACKING.rst
@@ -2,22 +2,12 @@
====================
- Step 1: Read the OpenStack Style Commandments
- https://github.com/openstack-dev/hacking/blob/master/HACKING.rst
+ http://docs.openstack.org/developer/hacking/
- Step 2: Read on
Tempest Specific Commandments
------------------------------
-[T101] If a test is broken because of a bug it is appropriate to skip the test until
-bug has been fixed. However, the skip message should be formatted so that
-Tempest's skip tracking tool can watch the bug status. The skip message should
-contain the string 'Bug' immediately followed by a space. Then the bug number
-should be included in the message '#' in front of the number.
-
-Example::
-
- @testtools.skip("Skipped until the Bug #980688 is resolved")
-
- [T102] Cannot import OpenStack python clients in tempest/api tests
- [T103] tempest/tests is deprecated
- [T104] Scenario tests require a services decorator
@@ -115,6 +105,19 @@
in tempest.api.compute would require a service tag for those services, however
they do not need to be tagged as compute.
+Test skips because of Known Bugs
+--------------------------------
+
+If a test is broken because of a bug it is appropriate to skip the test until
+bug has been fixed. You should use the skip_because decorator so that
+Tempest's skip tracking tool can watch the bug status.
+
+Example::
+
+ @skip_because(bug="980688")
+ def test_this_and_that(self):
+ ...
+
Guidelines
----------
- Do not submit changesets with only testcases which are skipped as
diff --git a/doc/source/conf.py b/doc/source/conf.py
index 178bf62..cf838c0 100644
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -11,7 +11,8 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
-import sys, os
+import sys
+import os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
@@ -25,7 +26,14 @@
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
-extensions = ['sphinx.ext.autodoc', 'sphinx.ext.todo', 'sphinx.ext.viewcode']
+extensions = ['sphinx.ext.autodoc',
+ 'sphinx.ext.intersphinx',
+ 'sphinx.ext.todo',
+ 'sphinx.ext.viewcode',
+ 'oslo.sphinx'
+ ]
+
+todo_include_todos = True
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
@@ -41,16 +49,18 @@
# General information about the project.
project = u'Tempest'
-copyright = u'2013, Sean Dague'
+copyright = u'2013, OpenStack QA Team'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
-version = 'havana'
+import pbr.version
+version_info = pbr.version.VersionInfo('tempest')
+version = version_info.version_string()
# The full version, including alpha/beta/rc tags.
-release = 'havana'
+release = version_info.release_string()
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
@@ -74,17 +84,17 @@
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
-#add_module_names = True
+add_module_names = False
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
-#show_authors = False
+show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
-#modindex_common_prefix = []
+modindex_common_prefix = ['tempest.']
# -- Options for HTML output ---------------------------------------------------
@@ -124,7 +134,8 @@
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
-#html_last_updated_fmt = '%b %d, %Y'
+git_cmd = "git log --pretty=format:'%ad, commit %h' --date=local -n1"
+html_last_updated_fmt = os.popen(git_cmd).read()
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
@@ -184,7 +195,7 @@
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'Tempest.tex', u'Tempest Documentation',
- u'Sean Dague', 'manual'),
+ u'OpenStack QA Team', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
@@ -214,7 +225,7 @@
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'tempest', u'Tempest Documentation',
- [u'Sean Dague'], 1)
+ [u'OpenStack QA Team'], 1)
]
# If true, show URL addresses after external links.
@@ -228,7 +239,7 @@
# dir menu entry, description, category)
texinfo_documents = [
('index', 'Tempest', u'Tempest Documentation',
- u'Sean Dague', 'Tempest', 'One line description of project.',
+ u'OpenStack QA Team', 'Tempest', 'One line description of project.',
'Miscellaneous'),
]
@@ -247,8 +258,8 @@
# Bibliographic Dublin Core info.
epub_title = u'Tempest'
epub_author = u'Sean Dague'
-epub_publisher = u'Sean Dague'
-epub_copyright = u'2013, Sean Dague'
+epub_publisher = u'OpenStack QA Team'
+epub_copyright = u'2013, OpenStack QA Team'
# The language of the text. It defaults to the language option
# or en if the language is not set.
diff --git a/requirements.txt b/requirements.txt
index b15fb92..3b9ec44 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -17,7 +17,7 @@
testresources>=0.2.4
keyring>=1.6.1
testrepository>=0.0.17
-oslo.config>=1.1.0
+oslo.config>=1.2.0
eventlet>=0.13.0
six<1.4.0
iso8601>=0.1.4
diff --git a/run_tests.sh b/run_tests.sh
index 710fbaa..970da51 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -58,7 +58,7 @@
-c|--nova-coverage) let nova_coverage=1;;
-C|--config) config_file=$2; shift;;
-p|--pep8) let just_pep8=1;;
- -s|--smoke) testrargs="$testrargs smoke";;
+ -s|--smoke) testrargs+="smoke"; noseargs+="--attr=type=smoke";;
-t|--serial) serial=1;;
-l|--logging) logging=1;;
-L|--logging-config) logging_config=$2; shift;;
@@ -107,12 +107,13 @@
}
function run_tests_nose {
- NOSE_WITH_OPENSTACK=1
- NOSE_OPENSTACK_COLOR=1
- NOSE_OPENSTACK_RED=15.00
- NOSE_OPENSTACK_YELLOW=3.00
- NOSE_OPENSTACK_SHOW_ELAPSED=1
- NOSE_OPENSTACK_STDOUT=1
+ export NOSE_WITH_OPENSTACK=1
+ export NOSE_OPENSTACK_COLOR=1
+ export NOSE_OPENSTACK_RED=15.00
+ export NOSE_OPENSTACK_YELLOW=3.00
+ export NOSE_OPENSTACK_SHOW_ELAPSED=1
+ export NOSE_OPENSTACK_STDOUT=1
+ export TEMPEST_PY26_NOSE_COMPAT=1
if [[ "x$noseargs" =~ "tempest" ]]; then
noseargs="$testrargs"
else
diff --git a/tempest/api/compute/admin/test_aggregates.py b/tempest/api/compute/admin/test_aggregates.py
index 40b005d..14ab236 100644
--- a/tempest/api/compute/admin/test_aggregates.py
+++ b/tempest/api/compute/admin/test_aggregates.py
@@ -97,6 +97,38 @@
self.assertEqual(aggregate['availability_zone'],
body['availability_zone'])
+ @attr(type='gate')
+ def test_aggregate_create_update_with_az(self):
+ # Update an aggregate and ensure properties are updated correctly
+ self.useFixture(fixtures.LockFixture('availability_zone'))
+ aggregate_name = rand_name(self.aggregate_name_prefix)
+ az_name = rand_name(self.az_name_prefix)
+ resp, aggregate = self.client.create_aggregate(aggregate_name, az_name)
+ self.addCleanup(self.client.delete_aggregate, aggregate['id'])
+
+ self.assertEqual(200, resp.status)
+ self.assertEqual(aggregate_name, aggregate['name'])
+ self.assertEqual(az_name, aggregate['availability_zone'])
+ self.assertIsNotNone(aggregate['id'])
+
+ aggregate_id = aggregate['id']
+ new_aggregate_name = aggregate_name + '_new'
+ new_az_name = az_name + '_new'
+
+ resp, resp_aggregate = self.client.update_aggregate(aggregate_id,
+ new_aggregate_name,
+ new_az_name)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(new_aggregate_name, resp_aggregate['name'])
+ self.assertEqual(new_az_name, resp_aggregate['availability_zone'])
+
+ resp, aggregates = self.client.list_aggregates()
+ self.assertEqual(200, resp.status)
+ self.assertIn((aggregate_id, new_aggregate_name, new_az_name),
+ map(lambda x:
+ (x['id'], x['name'], x['availability_zone']),
+ aggregates))
+
@attr(type=['negative', 'gate'])
def test_aggregate_create_as_user(self):
# Regular user is not allowed to create an aggregate.
diff --git a/tempest/api/compute/admin/test_flavors.py b/tempest/api/compute/admin/test_flavors.py
index 3ef75ba..004268e 100644
--- a/tempest/api/compute/admin/test_flavors.py
+++ b/tempest/api/compute/admin/test_flavors.py
@@ -15,14 +15,13 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-
from tempest.api import compute
from tempest.api.compute import base
from tempest.common.utils.data_utils import rand_int_id
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
from tempest.test import attr
+from tempest.test import skip_because
class FlavorsAdminTestJSON(base.BaseComputeAdminTest):
@@ -195,7 +194,7 @@
flag = True
self.assertTrue(flag)
- @testtools.skip("Skipped until the Bug #1209101 is resolved")
+ @skip_because(bug="1209101")
@attr(type='gate')
def test_list_non_public_flavor(self):
# Create a flavor with os-flavor-access:is_public false should
diff --git a/tempest/api/compute/admin/test_servers.py b/tempest/api/compute/admin/test_servers.py
index 0abf779..e730d31 100644
--- a/tempest/api/compute/admin/test_servers.py
+++ b/tempest/api/compute/admin/test_servers.py
@@ -43,6 +43,8 @@
cls.s1_name = rand_name('server')
resp, server = cls.create_server(name=cls.s1_name,
wait_until='ACTIVE')
+ cls.s1_id = server['id']
+
cls.s2_name = rand_name('server')
resp, server = cls.create_server(name=cls.s2_name,
wait_until='ACTIVE')
@@ -77,6 +79,14 @@
self.assertIn(self.s1_name, servers_name)
self.assertIn(self.s2_name, servers_name)
+ @attr(type='gate')
+ def test_admin_delete_servers_of_others(self):
+ # Administrator can delete servers of others
+ _, server = self.create_server()
+ resp, _ = self.client.delete_server(server['id'])
+ self.assertEqual('204', resp['status'])
+ self.servers_client.wait_for_server_termination(server['id'])
+
@attr(type=['negative', 'gate'])
def test_resize_server_using_overlimit_ram(self):
flavor_name = rand_name("flavor-")
@@ -113,6 +123,41 @@
self.servers[0]['id'],
flavor_ref['id'])
+ @attr(type='gate')
+ def test_reset_state_server(self):
+ # Reset server's state to 'error'
+ resp, server = self.client.reset_state(self.s1_id)
+ self.assertEqual(202, resp.status)
+
+ # Verify server's state
+ resp, server = self.client.get_server(self.s1_id)
+ self.assertEqual(server['status'], 'ERROR')
+
+ # Reset server's state to 'active'
+ resp, server = self.client.reset_state(self.s1_id, state='active')
+ self.assertEqual(202, resp.status)
+
+ # Verify server's state
+ resp, server = self.client.get_server(self.s1_id)
+ self.assertEqual(server['status'], 'ACTIVE')
+
+ @attr(type=['negative', 'gate'])
+ def test_reset_state_server_invalid_state(self):
+ self.assertRaises(exceptions.BadRequest,
+ self.client.reset_state, self.s1_id,
+ state='invalid')
+
+ @attr(type=['negative', 'gate'])
+ def test_reset_state_server_invalid_type(self):
+ self.assertRaises(exceptions.BadRequest,
+ self.client.reset_state, self.s1_id,
+ state=1)
+
+ @attr(type=['negative', 'gate'])
+ def test_reset_state_server_nonexistent_server(self):
+ self.assertRaises(exceptions.NotFound,
+ self.client.reset_state, '999')
+
class ServersAdminTestXML(ServersAdminTestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/floating_ips/test_list_floating_ips.py b/tempest/api/compute/floating_ips/test_list_floating_ips.py
index 1c72eba..3c76069 100644
--- a/tempest/api/compute/floating_ips/test_list_floating_ips.py
+++ b/tempest/api/compute/floating_ips/test_list_floating_ips.py
@@ -93,6 +93,14 @@
self.assertRaises(exceptions.NotFound,
self.client.get_floating_ip_details, non_exist_id)
+ @attr(type='gate')
+ def test_list_floating_ip_pools(self):
+ # Positive test:Should return the list of floating IP Pools
+ resp, floating_ip_pools = self.client.list_floating_ip_pools()
+ self.assertEqual(200, resp.status)
+ self.assertNotEqual(0, len(floating_ip_pools),
+ "Expected floating IP Pools. Got zero.")
+
class FloatingIPDetailsTestXML(FloatingIPDetailsTestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/images/test_images_oneserver.py b/tempest/api/compute/images/test_images_oneserver.py
index 7df9010..800b2de 100644
--- a/tempest/api/compute/images/test_images_oneserver.py
+++ b/tempest/api/compute/images/test_images_oneserver.py
@@ -24,6 +24,7 @@
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
from tempest.test import attr
+from tempest.test import skip_because
class ImagesOneServerTestJSON(base.BaseComputeTest):
@@ -64,7 +65,7 @@
cls.alt_manager = clients.AltManager()
cls.alt_client = cls.alt_manager.images_client
- @testtools.skip("Skipped until the Bug #1006725 is resolved.")
+ @skip_because(bug="1006725")
@attr(type=['negative', 'gate'])
def test_create_image_specify_multibyte_character_image_name(self):
# Return an error if the image name has multi-byte characters
diff --git a/tempest/api/compute/security_groups/test_security_group_rules.py b/tempest/api/compute/security_groups/test_security_group_rules.py
index 61db61d..cbc0080 100644
--- a/tempest/api/compute/security_groups/test_security_group_rules.py
+++ b/tempest/api/compute/security_groups/test_security_group_rules.py
@@ -15,13 +15,12 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-
from tempest.api.compute import base
from tempest.common.utils.data_utils import rand_name
from tempest import config
from tempest import exceptions
from tempest.test import attr
+from tempest.test import skip_because
class SecurityGroupRulesTestJSON(base.BaseComputeTest):
@@ -94,8 +93,8 @@
self.addCleanup(self.client.delete_security_group_rule, rule['id'])
self.assertEqual(200, resp.status)
- @testtools.skipIf(config.TempestConfig().service_available.neutron,
- "Skipped until the Bug #1182384 is resolved")
+ @skip_because(bug="1182384",
+ condition=config.TempestConfig().service_available.neutron)
@attr(type=['negative', 'gate'])
def test_security_group_rules_create_with_invalid_id(self):
# Negative test: Creation of Security Group rule should FAIL
@@ -186,8 +185,8 @@
self.client.create_security_group_rule,
secgroup_id, ip_protocol, from_port, to_port)
- @testtools.skipIf(config.TempestConfig().service_available.neutron,
- "Skipped until the Bug #1182384 is resolved")
+ @skip_because(bug="1182384",
+ condition=config.TempestConfig().service_available.neutron)
@attr(type=['negative', 'gate'])
def test_security_group_rules_delete_with_invalid_id(self):
# Negative test: Deletion of Security Group rule should be FAIL
diff --git a/tempest/api/compute/security_groups/test_security_groups.py b/tempest/api/compute/security_groups/test_security_groups.py
index 5cca3b2..fba2f53 100644
--- a/tempest/api/compute/security_groups/test_security_groups.py
+++ b/tempest/api/compute/security_groups/test_security_groups.py
@@ -22,6 +22,7 @@
from tempest import config
from tempest import exceptions
from tempest.test import attr
+from tempest.test import skip_because
class SecurityGroupsTestJSON(base.BaseComputeTest):
@@ -107,8 +108,8 @@
"The fetched Security Group is different "
"from the created Group")
- @testtools.skipIf(config.TempestConfig().service_available.neutron,
- "Skipped until the Bug #1182384 is resolved")
+ @skip_because(bug="1182384",
+ condition=config.TempestConfig().service_available.neutron)
@attr(type=['negative', 'gate'])
def test_security_group_get_nonexistant_group(self):
# Negative test:Should not be able to GET the details
@@ -125,8 +126,8 @@
self.assertRaises(exceptions.NotFound, self.client.get_security_group,
non_exist_id)
- @testtools.skipIf(config.TempestConfig().service_available.neutron,
- "Skipped until the Bug #1161411 is resolved")
+ @skip_because(bug="1161411",
+ condition=config.TempestConfig().service_available.neutron)
@attr(type=['negative', 'gate'])
def test_security_group_create_with_invalid_group_name(self):
# Negative test: Security Group should not be created with group name
@@ -145,8 +146,8 @@
self.client.create_security_group, s_name,
s_description)
- @testtools.skipIf(config.TempestConfig().service_available.neutron,
- "Skipped until the Bug #1161411 is resolved")
+ @skip_because(bug="1161411",
+ condition=config.TempestConfig().service_available.neutron)
@attr(type=['negative', 'gate'])
def test_security_group_create_with_invalid_group_description(self):
# Negative test:Security Group should not be created with description
@@ -197,8 +198,8 @@
self.client.delete_security_group,
default_security_group_id)
- @testtools.skipIf(config.TempestConfig().service_available.neutron,
- "Skipped until the Bug #1182384 is resolved")
+ @skip_because(bug="1182384",
+ condition=config.TempestConfig().service_available.neutron)
@attr(type=['negative', 'gate'])
def test_delete_nonexistant_security_group(self):
# Negative test:Deletion of a non-existent Security Group should Fail
diff --git a/tempest/api/compute/servers/test_list_server_filters.py b/tempest/api/compute/servers/test_list_server_filters.py
index a56bdf3..c469827 100644
--- a/tempest/api/compute/servers/test_list_server_filters.py
+++ b/tempest/api/compute/servers/test_list_server_filters.py
@@ -15,14 +15,13 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-
from tempest.api.compute import base
from tempest.api import utils
from tempest.common.utils.data_utils import rand_name
from tempest import config
from tempest import exceptions
from tempest.test import attr
+from tempest.test import skip_because
class ListServerFiltersTestJSON(base.BaseComputeTest):
@@ -205,7 +204,7 @@
self.assertNotIn(self.s2_name, map(lambda x: x['name'], servers))
self.assertNotIn(self.s3_name, map(lambda x: x['name'], servers))
- @testtools.skip('Skipped until the Bug #1170718 is resolved.')
+ @skip_because(bug="1170718")
@attr(type='gate')
def test_list_servers_filtered_by_ip(self):
# Filter servers by ip
@@ -219,8 +218,8 @@
self.assertNotIn(self.s2_name, map(lambda x: x['name'], servers))
self.assertNotIn(self.s3_name, map(lambda x: x['name'], servers))
- @testtools.skipIf(config.TempestConfig().service_available.neutron,
- "Skipped until the Bug #1182883 is resolved")
+ @skip_because(bug="1182883",
+ condition=config.TempestConfig().service_available.neutron)
@attr(type='gate')
def test_list_servers_filtered_by_ip_regex(self):
# Filter servers by regex ip
diff --git a/tempest/api/compute/servers/test_list_servers_negative.py b/tempest/api/compute/servers/test_list_servers_negative.py
index 1050054..983258d 100644
--- a/tempest/api/compute/servers/test_list_servers_negative.py
+++ b/tempest/api/compute/servers/test_list_servers_negative.py
@@ -28,6 +28,26 @@
_interface = 'json'
@classmethod
+ def _ensure_no_servers(cls, servers, username, tenant_name):
+ """
+ If there are servers and there is tenant isolation then a
+ skipException is raised to skip the test since it requires no servers
+ to already exist for the given user/tenant.
+ If there are servers and there is not tenant isolation then the test
+ blocks while the servers are being deleted.
+ """
+ if len(servers):
+ if not compute.MULTI_USER:
+ for srv in servers:
+ cls.client.wait_for_server_termination(srv['id'],
+ ignore_error=True)
+ else:
+ msg = ("User/tenant %(u)s/%(t)s already have "
+ "existing server instances. Skipping test." %
+ {'u': username, 't': tenant_name})
+ raise cls.skipException(msg)
+
+ @classmethod
def setUpClass(cls):
super(ListServersNegativeTestJSON, cls).setUpClass()
cls.client = cls.servers_client
@@ -54,26 +74,14 @@
# start of the test instead of destroying any existing
# servers.
resp, body = cls.client.list_servers()
- servers = body['servers']
- num_servers = len(servers)
- if num_servers > 0:
- username = cls.os.username
- tenant_name = cls.os.tenant_name
- msg = ("User/tenant %(u)s/%(t)s already have "
- "existing server instances. Skipping test." %
- {'u': username, 't': tenant_name})
- raise cls.skipException(msg)
+ cls._ensure_no_servers(body['servers'],
+ cls.os.username,
+ cls.os.tenant_name)
resp, body = cls.alt_client.list_servers()
- servers = body['servers']
- num_servers = len(servers)
- if num_servers > 0:
- username = cls.alt_manager.username
- tenant_name = cls.alt_manager.tenant_name
- msg = ("Alt User/tenant %(u)s/%(t)s already have "
- "existing server instances. Skipping test." %
- {'u': username, 't': tenant_name})
- raise cls.skipException(msg)
+ cls._ensure_no_servers(body['servers'],
+ cls.alt_manager.username,
+ cls.alt_manager.tenant_name)
# The following servers are created for use
# by the test methods in this class. These
@@ -81,6 +89,7 @@
# tearDownClass method of the super-class.
cls.existing_fixtures = []
cls.deleted_fixtures = []
+ cls.start_time = datetime.datetime.utcnow()
for x in xrange(2):
resp, srv = cls.create_server()
cls.existing_fixtures.append(srv)
@@ -173,8 +182,7 @@
@attr(type='gate')
def test_list_servers_by_changes_since(self):
# Servers are listed by specifying changes-since date
- since = datetime.datetime.utcnow() - datetime.timedelta(minutes=2)
- changes_since = {'changes-since': since.isoformat()}
+ changes_since = {'changes-since': self.start_time.isoformat()}
resp, body = self.client.list_servers(changes_since)
self.assertEqual('200', resp['status'])
# changes-since returns all instances, including deleted.
diff --git a/tempest/api/compute/servers/test_server_actions.py b/tempest/api/compute/servers/test_server_actions.py
index aec1d49..e9defe5 100644
--- a/tempest/api/compute/servers/test_server_actions.py
+++ b/tempest/api/compute/servers/test_server_actions.py
@@ -27,6 +27,7 @@
import tempest.config
from tempest import exceptions
from tempest.test import attr
+from tempest.test import skip_because
class ServerActionsTestJSON(base.BaseComputeTest):
@@ -86,7 +87,7 @@
new_boot_time = linux_client.get_boot_time()
self.assertGreater(new_boot_time, boot_time)
- @testtools.skip('Skipped until the Bug #1014647 is resolved.')
+ @skip_because(bug="1014647")
@attr(type='smoke')
def test_reboot_server_soft(self):
# The server should be signaled to reboot gracefully
@@ -250,7 +251,7 @@
self.servers_client.get_console_output,
'!@#$%^&*()', 10)
- @testtools.skip('Skipped until the Bug #1014683 is resolved.')
+ @skip_because(bug="1014683")
@attr(type='gate')
def test_get_console_output_server_id_in_reboot_status(self):
# Positive test:Should be able to GET the console output
@@ -300,6 +301,26 @@
self.assertEqual(202, resp.status)
self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
+ @attr(type='gate')
+ def test_lock_unlock_server(self):
+ # Lock the server,try server stop(exceptions throw),unlock it and retry
+ resp, server = self.servers_client.lock_server(self.server_id)
+ self.assertEqual(202, resp.status)
+ resp, server = self.servers_client.get_server(self.server_id)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(server['status'], 'ACTIVE')
+ # Locked server is not allowed to be stopped by non-admin user
+ self.assertRaises(exceptions.BadRequest,
+ self.servers_client.stop, self.server_id)
+ resp, server = self.servers_client.unlock_server(self.server_id)
+ self.assertEqual(202, resp.status)
+ resp, server = self.servers_client.stop(self.server_id)
+ self.assertEqual(202, resp.status)
+ self.servers_client.wait_for_server_status(self.server_id, 'SHUTOFF')
+ resp, server = self.servers_client.start(self.server_id)
+ self.assertEqual(202, resp.status)
+ self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
+
class ServerActionsTestXML(ServerActionsTestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/servers/test_servers.py b/tempest/api/compute/servers/test_servers.py
index 625964c..5ce51c0 100644
--- a/tempest/api/compute/servers/test_servers.py
+++ b/tempest/api/compute/servers/test_servers.py
@@ -112,6 +112,13 @@
resp, _ = self.client.delete_server(server['id'])
self.assertEqual('204', resp['status'])
+ @attr(type='gate')
+ def test_delete_active_server(self):
+ # Delete a server while it's VM state is Active
+ resp, server = self.create_server(wait_until='ACTIVE')
+ resp, _ = self.client.delete_server(server['id'])
+ self.assertEqual('204', resp['status'])
+
class ServersTestXML(ServersTestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/servers/test_servers_negative.py b/tempest/api/compute/servers/test_servers_negative.py
index e864343..5d9a5ce 100644
--- a/tempest/api/compute/servers/test_servers_negative.py
+++ b/tempest/api/compute/servers/test_servers_negative.py
@@ -16,6 +16,7 @@
# under the License.
import sys
+import uuid
from tempest.api.compute import base
from tempest import clients
@@ -258,16 +259,66 @@
@attr(type=['negative', 'gate'])
def test_stop_non_existent_server(self):
# Stop a non existent server
- non_exist_id = rand_name('non-existent-server')
self.assertRaises(exceptions.NotFound, self.servers_client.stop,
- non_exist_id)
+ str(uuid.uuid4()))
@attr(type=['negative', 'gate'])
def test_pause_non_existent_server(self):
# pause a non existent server
- non_exist_id = rand_name('non-existent-server')
self.assertRaises(exceptions.NotFound, self.client.pause_server,
- non_exist_id)
+ str(uuid.uuid4()))
+
+ @attr(type=['negative', 'gate'])
+ def test_unpause_non_existent_server(self):
+ # unpause a non existent server
+ self.assertRaises(exceptions.NotFound, self.client.unpause_server,
+ str(uuid.uuid4()))
+
+ @attr(type=['negative', 'gate'])
+ def test_unpause_server_invalid_state(self):
+ # unpause an active server.
+ resp, server = self.create_server(wait_until='ACTIVE')
+ server_id = server['id']
+ self.assertRaises(exceptions.Duplicate,
+ self.client.unpause_server,
+ server_id)
+
+ @attr(type=['negative', 'gate'])
+ def test_suspend_non_existent_server(self):
+ # suspend a non existent server
+ self.assertRaises(exceptions.NotFound, self.client.suspend_server,
+ str(uuid.uuid4()))
+
+ @attr(type=['negative', 'gate'])
+ def test_suspend_server_invalid_state(self):
+ # create server.
+ resp, server = self.create_server(wait_until='ACTIVE')
+ server_id = server['id']
+
+ # suspend a suspended server.
+ resp, _ = self.client.suspend_server(server_id)
+ self.assertEqual(202, resp.status)
+ self.client.wait_for_server_status(server_id, 'SUSPENDED')
+ self.assertRaises(exceptions.Duplicate,
+ self.client.suspend_server,
+ server_id)
+
+ @attr(type=['negative', 'gate'])
+ def test_resume_non_existent_server(self):
+ # resume a non existent server
+ self.assertRaises(exceptions.NotFound, self.client.resume_server,
+ str(uuid.uuid4()))
+
+ @attr(type=['negative', 'gate'])
+ def test_resume_server_invalid_state(self):
+ # create server.
+ resp, server = self.create_server(wait_until='ACTIVE')
+ server_id = server['id']
+
+ # resume an active server.
+ self.assertRaises(exceptions.Duplicate,
+ self.client.resume_server,
+ server_id)
class ServersNegativeTestXML(ServersNegativeTestJSON):
diff --git a/tempest/api/compute/servers/test_virtual_interfaces.py b/tempest/api/compute/servers/test_virtual_interfaces.py
index b743a85..2c7ff32 100644
--- a/tempest/api/compute/servers/test_virtual_interfaces.py
+++ b/tempest/api/compute/servers/test_virtual_interfaces.py
@@ -16,13 +16,13 @@
# under the License.
import netaddr
-import testtools
from tempest.api.compute import base
from tempest.common.utils.data_utils import rand_name
from tempest import config
from tempest import exceptions
from tempest.test import attr
+from tempest.test import skip_because
class VirtualInterfacesTestJSON(base.BaseComputeTest):
@@ -37,8 +37,8 @@
resp, server = cls.create_server(wait_until='ACTIVE')
cls.server_id = server['id']
- @testtools.skipIf(CONF.service_available.neutron, "Not implemented by " +
- "Neutron. Skipped until the Bug #1183436 is resolved.")
+ @skip_because(bug="1183436",
+ condition=CONF.service_available.neutron)
@attr(type='gate')
def test_list_virtual_interfaces(self):
# Positive test:Should be able to GET the virtual interfaces list
diff --git a/tempest/api/identity/admin/v3/test_projects.py b/tempest/api/identity/admin/v3/test_projects.py
new file mode 100644
index 0000000..36ced70
--- /dev/null
+++ b/tempest/api/identity/admin/v3/test_projects.py
@@ -0,0 +1,256 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 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.api.identity import base
+from tempest.common.utils.data_utils import rand_name
+from tempest import exceptions
+from tempest.test import attr
+
+
+class ProjectsTestJSON(base.BaseIdentityAdminTest):
+ _interface = 'json'
+
+ def _delete_project(self, project_id):
+ resp, _ = self.v3_client.delete_project(project_id)
+ self.assertEqual(resp['status'], '204')
+ self.assertRaises(
+ exceptions.NotFound, self.v3_client.get_project, project_id)
+
+ @attr(type='gate')
+ def test_project_list_delete(self):
+ # Create several projects and delete them
+ for _ in xrange(3):
+ resp, project = self.v3_client.create_project(
+ rand_name('project-new'))
+ self.addCleanup(self._delete_project, project['id'])
+
+ resp, list_projects = self.v3_client.list_projects()
+ self.assertEqual(resp['status'], '200')
+
+ resp, get_project = self.v3_client.get_project(project['id'])
+ self.assertIn(get_project, list_projects)
+
+ @attr(type='gate')
+ def test_project_create_with_description(self):
+ # Create project with a description
+ project_name = rand_name('project-')
+ project_desc = rand_name('desc-')
+ resp, project = self.v3_client.create_project(
+ project_name, description=project_desc)
+ self.v3data.projects.append(project)
+ st1 = resp['status']
+ project_id = project['id']
+ desc1 = project['description']
+ self.assertEqual(st1, '201')
+ self.assertEqual(desc1, project_desc, 'Description should have '
+ 'been sent in response for create')
+ resp, body = self.v3_client.get_project(project_id)
+ desc2 = body['description']
+ self.assertEqual(desc2, project_desc, 'Description does not appear'
+ 'to be set')
+
+ @attr(type='gate')
+ def test_project_create_enabled(self):
+ # Create a project that is enabled
+ project_name = rand_name('project-')
+ resp, project = self.v3_client.create_project(
+ project_name, enabled=True)
+ self.v3data.projects.append(project)
+ project_id = project['id']
+ st1 = resp['status']
+ en1 = project['enabled']
+ self.assertEqual(st1, '201')
+ self.assertTrue(en1, 'Enable should be True in response')
+ resp, body = self.v3_client.get_project(project_id)
+ en2 = body['enabled']
+ self.assertTrue(en2, 'Enable should be True in lookup')
+
+ @attr(type='gate')
+ def test_project_create_not_enabled(self):
+ # Create a project that is not enabled
+ project_name = rand_name('project-')
+ resp, project = self.v3_client.create_project(
+ project_name, enabled=False)
+ self.v3data.projects.append(project)
+ st1 = resp['status']
+ en1 = project['enabled']
+ self.assertEqual(st1, '201')
+ self.assertEqual('false', str(en1).lower(),
+ 'Enable should be False in response')
+ resp, body = self.v3_client.get_project(project['id'])
+ en2 = body['enabled']
+ self.assertEqual('false', str(en2).lower(),
+ 'Enable should be False in lookup')
+
+ @attr(type='gate')
+ def test_project_update_name(self):
+ # Update name attribute of a project
+ p_name1 = rand_name('project-')
+ resp, project = self.v3_client.create_project(p_name1)
+ self.v3data.projects.append(project)
+
+ resp1_name = project['name']
+
+ p_name2 = rand_name('project2-')
+ resp, body = self.v3_client.update_project(project['id'], name=p_name2)
+ st2 = resp['status']
+ resp2_name = body['name']
+ self.assertEqual(st2, '200')
+ self.assertNotEqual(resp1_name, resp2_name)
+
+ resp, body = self.v3_client.get_project(project['id'])
+ resp3_name = body['name']
+
+ self.assertNotEqual(resp1_name, resp3_name)
+ self.assertEqual(p_name1, resp1_name)
+ self.assertEqual(resp2_name, resp3_name)
+
+ @attr(type='gate')
+ def test_project_update_desc(self):
+ # Update description attribute of a project
+ p_name = rand_name('project-')
+ p_desc = rand_name('desc-')
+ resp, project = self.v3_client.create_project(
+ p_name, description=p_desc)
+ self.v3data.projects.append(project)
+ resp1_desc = project['description']
+
+ p_desc2 = rand_name('desc2-')
+ resp, body = self.v3_client.update_project(
+ project['id'], description=p_desc2)
+ st2 = resp['status']
+ resp2_desc = body['description']
+ self.assertEqual(st2, '200')
+ self.assertNotEqual(resp1_desc, resp2_desc)
+
+ resp, body = self.v3_client.get_project(project['id'])
+ resp3_desc = body['description']
+
+ self.assertNotEqual(resp1_desc, resp3_desc)
+ self.assertEqual(p_desc, resp1_desc)
+ self.assertEqual(resp2_desc, resp3_desc)
+
+ @attr(type='gate')
+ def test_project_update_enable(self):
+ # Update the enabled attribute of a project
+ p_name = rand_name('project-')
+ p_en = False
+ resp, project = self.v3_client.create_project(p_name, enabled=p_en)
+ self.v3data.projects.append(project)
+
+ resp1_en = project['enabled']
+
+ p_en2 = True
+ resp, body = self.v3_client.update_project(
+ project['id'], enabled=p_en2)
+ st2 = resp['status']
+ resp2_en = body['enabled']
+ self.assertEqual(st2, '200')
+ self.assertNotEqual(resp1_en, resp2_en)
+
+ resp, body = self.v3_client.get_project(project['id'])
+ resp3_en = body['enabled']
+
+ self.assertNotEqual(resp1_en, resp3_en)
+ self.assertEqual('false', str(resp1_en).lower())
+ self.assertEqual(resp2_en, resp3_en)
+
+ @attr(type='gate')
+ def test_associate_user_to_project(self):
+ #Associate a user to a project
+ #Create a Project
+ p_name = rand_name('project-')
+ resp, project = self.v3_client.create_project(p_name)
+ self.v3data.projects.append(project)
+
+ #Create a User
+ u_name = rand_name('user-')
+ u_desc = u_name + 'description'
+ u_email = u_name + '@testmail.tm'
+ u_password = rand_name('pass-')
+ resp, user = self.v3_client.create_user(
+ u_name, description=u_desc, password=u_password,
+ email=u_email, project_id=project['id'])
+ self.assertEqual(resp['status'], '201')
+ # Delete the User at the end of this method
+ self.addCleanup(self.v3_client.delete_user, user['id'])
+
+ # Get User To validate the user details
+ resp, new_user_get = self.v3_client.get_user(user['id'])
+ #Assert response body of GET
+ self.assertEqual(u_name, new_user_get['name'])
+ self.assertEqual(u_desc, new_user_get['description'])
+ self.assertEqual(project['id'],
+ new_user_get['project_id'])
+ self.assertEqual(u_email, new_user_get['email'])
+
+ @attr(type=['negative', 'gate'])
+ def test_list_projects_by_unauthorized_user(self):
+ # Non-admin user should not be able to list projects
+ self.assertRaises(exceptions.Unauthorized,
+ self.v3_non_admin_client.list_projects)
+
+ @attr(type=['negative', 'gate'])
+ def test_project_create_duplicate(self):
+ # Project names should be unique
+ project_name = rand_name('project-dup-')
+ resp, project = self.v3_client.create_project(project_name)
+ self.v3data.projects.append(project)
+
+ self.assertRaises(
+ exceptions.Duplicate, self.v3_client.create_project, project_name)
+
+ @attr(type=['negative', 'gate'])
+ def test_create_project_by_unauthorized_user(self):
+ # Non-admin user should not be authorized to create a project
+ project_name = rand_name('project-')
+ self.assertRaises(
+ exceptions.Unauthorized, self.v3_non_admin_client.create_project,
+ project_name)
+
+ @attr(type=['negative', 'gate'])
+ def test_create_project_with_empty_name(self):
+ # Project name should not be empty
+ self.assertRaises(exceptions.BadRequest, self.v3_client.create_project,
+ name='')
+
+ @attr(type=['negative', 'gate'])
+ def test_create_projects_name_length_over_64(self):
+ # Project name length should not be greater than 64 characters
+ project_name = 'a' * 65
+ self.assertRaises(exceptions.BadRequest, self.v3_client.create_project,
+ project_name)
+
+ @attr(type=['negative', 'gate'])
+ def test_project_delete_by_unauthorized_user(self):
+ # Non-admin user should not be able to delete a project
+ project_name = rand_name('project-')
+ resp, project = self.v3_client.create_project(project_name)
+ self.v3data.projects.append(project)
+ self.assertRaises(
+ exceptions.Unauthorized, self.v3_non_admin_client.delete_project,
+ project['id'])
+
+ @attr(type=['negative', 'gate'])
+ def test_delete_non_existent_project(self):
+ # Attempt to delete a non existent project should fail
+ self.assertRaises(exceptions.NotFound, self.v3_client.delete_project,
+ 'junk_Project_123456abc')
+
+
+class ProjectsTestXML(ProjectsTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/identity/admin/v3/test_tokens.py b/tempest/api/identity/admin/v3/test_tokens.py
index 22d74d3..f8a62a6 100644
--- a/tempest/api/identity/admin/v3/test_tokens.py
+++ b/tempest/api/identity/admin/v3/test_tokens.py
@@ -19,13 +19,11 @@
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
from tempest.test import attr
-import testtools
class UsersTestJSON(base.BaseIdentityAdminTest):
_interface = 'json'
- @testtools.skip("Skipped until the Bug #1221889 is resolved")
@attr(type='smoke')
def test_tokens(self):
# Valid user's token is authenticated
@@ -51,7 +49,7 @@
self.assertEqual(token_details['user']['name'], u_name)
# Perform Delete Token
resp, _ = self.v3_client.delete_token(subject_token)
- self.assertRaises(exceptions.Unauthorized, self.v3_client.get_token,
+ self.assertRaises(exceptions.NotFound, self.v3_client.get_token,
subject_token)
diff --git a/tempest/api/identity/base.py b/tempest/api/identity/base.py
index 09fdd22..ab89af4 100644
--- a/tempest/api/identity/base.py
+++ b/tempest/api/identity/base.py
@@ -40,13 +40,16 @@
raise cls.skipException("Admin extensions disabled")
cls.data = DataGenerator(cls.client)
+ cls.v3data = DataGenerator(cls.v3_client)
os = clients.Manager(interface=cls._interface)
cls.non_admin_client = os.identity_client
+ cls.v3_non_admin_client = os.identity_v3_client
@classmethod
def tearDownClass(cls):
cls.data.teardown_all()
+ cls.v3data.teardown_all()
super(BaseIdentityAdminTest, cls).tearDownClass()
def disable_user(self, user_name):
@@ -84,6 +87,9 @@
self.tenants = []
self.roles = []
self.role_name = None
+ self.v3_users = []
+ self.projects = []
+ self.v3_roles = []
def setup_test_user(self):
"""Set up a test user."""
@@ -112,6 +118,33 @@
resp, self.role = self.client.create_role(self.test_role)
self.roles.append(self.role)
+ def setup_test_v3_user(self):
+ """Set up a test v3 user."""
+ self.setup_test_project()
+ self.test_user = rand_name('test_user_')
+ self.test_password = rand_name('pass_')
+ self.test_email = self.test_user + '@testmail.tm'
+ resp, self.v3_user = self.client.create_user(self.test_user,
+ self.test_password,
+ self.project['id'],
+ self.test_email)
+ self.v3_users.append(self.v3_user)
+
+ def setup_test_project(self):
+ """Set up a test project."""
+ self.test_project = rand_name('test_project_')
+ self.test_description = rand_name('desc_')
+ resp, self.project = self.client.create_project(
+ name=self.test_project,
+ description=self.test_description)
+ self.projects.append(self.project)
+
+ def setup_test_v3_role(self):
+ """Set up a test v3 role."""
+ self.test_role = rand_name('role')
+ resp, self.v3_role = self.client.create_role(self.test_role)
+ self.v3_roles.append(self.v3_role)
+
def teardown_all(self):
for user in self.users:
self.client.delete_user(user['id'])
@@ -119,3 +152,9 @@
self.client.delete_tenant(tenant['id'])
for role in self.roles:
self.client.delete_role(role['id'])
+ for v3_user in self.v3_users:
+ self.client.delete_user(v3_user['id'])
+ for v3_project in self.projects:
+ self.client.delete_project(v3_project['id'])
+ for v3_role in self.v3_roles:
+ self.client.delete_role(v3_role['id'])
diff --git a/tempest/api/image/v1/test_image_members.py b/tempest/api/image/v1/test_image_members.py
index fcbde50..e9c395e 100644
--- a/tempest/api/image/v1/test_image_members.py
+++ b/tempest/api/image/v1/test_image_members.py
@@ -18,6 +18,8 @@
from tempest.api.image import base
from tempest import clients
+from tempest.common.utils.data_utils import rand_name
+from tempest import exceptions
from tempest.test import attr
@@ -83,3 +85,25 @@
self.assertEqual(200, resp.status)
members = body['members']
self.assertEqual(0, len(members))
+
+ @attr(type=['negative', 'gate'])
+ def test_add_member_with_non_existing_image(self):
+ # Add member with non existing image.
+ non_exist_image = rand_name('image_')
+ self.assertRaises(exceptions.NotFound, self.client.add_member,
+ self.tenants[0], non_exist_image)
+
+ @attr(type=['negative', 'gate'])
+ def test_delete_member_with_non_existing_image(self):
+ # Delete member with non existing image.
+ non_exist_image = rand_name('image_')
+ self.assertRaises(exceptions.NotFound, self.client.delete_member,
+ self.tenants[0], non_exist_image)
+
+ @attr(type=['negative', 'gate'])
+ def test_delete_member_with_non_existing_tenant(self):
+ # Delete member with non existing tenant.
+ image_id = self._create_image()
+ non_exist_tenant = rand_name('tenant_')
+ self.assertRaises(exceptions.NotFound, self.client.delete_member,
+ non_exist_tenant, image_id)
diff --git a/tempest/api/network/test_floating_ips.py b/tempest/api/network/test_floating_ips.py
index 017864f..ca2c879 100644
--- a/tempest/api/network/test_floating_ips.py
+++ b/tempest/api/network/test_floating_ips.py
@@ -20,7 +20,7 @@
from tempest.test import attr
-class FloatingIPTest(base.BaseNetworkTest):
+class FloatingIPTestJSON(base.BaseNetworkTest):
_interface = 'json'
"""
@@ -41,7 +41,7 @@
@classmethod
def setUpClass(cls):
- super(FloatingIPTest, cls).setUpClass()
+ super(FloatingIPTestJSON, cls).setUpClass()
cls.ext_net_id = cls.config.network.public_network_id
# Create network, subnet, router and add interface
@@ -67,7 +67,7 @@
for i in range(2):
cls.client.delete_port(cls.port[i]['id'])
cls.client.delete_router(cls.router['id'])
- super(FloatingIPTest, cls).tearDownClass()
+ super(FloatingIPTestJSON, cls).tearDownClass()
def _delete_floating_ip(self, floating_ip_id):
# Deletes a floating IP and verifies if it is deleted or not
@@ -133,3 +133,7 @@
self.assertIsNone(update_floating_ip['port_id'])
self.assertIsNone(update_floating_ip['fixed_ip_address'])
self.assertIsNone(update_floating_ip['router_id'])
+
+
+class FloatingIPTestXML(FloatingIPTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/object_storage/test_container_sync.py b/tempest/api/object_storage/test_container_sync.py
index a43b2b5..ff9f7bf 100644
--- a/tempest/api/object_storage/test_container_sync.py
+++ b/tempest/api/object_storage/test_container_sync.py
@@ -17,11 +17,10 @@
import time
-import testtools
-
from tempest.api.object_storage import base
from tempest.common.utils.data_utils import rand_name
from tempest.test import attr
+from tempest.test import skip_because
class ContainerSyncTest(base.BaseObjectTest):
@@ -52,7 +51,7 @@
cls.delete_containers(cls.containers, client[0], client[1])
super(ContainerSyncTest, cls).tearDownClass()
- @testtools.skip('Skipped until the Bug #1093743 is resolved.')
+ @skip_because(bug="1093743")
@attr(type='gate')
def test_container_synchronization(self):
# container to container synchronization
diff --git a/tempest/api/object_storage/test_object_expiry.py b/tempest/api/object_storage/test_object_expiry.py
index db38401..cb52d88 100644
--- a/tempest/api/object_storage/test_object_expiry.py
+++ b/tempest/api/object_storage/test_object_expiry.py
@@ -17,13 +17,12 @@
import time
-import testtools
-
from tempest.api.object_storage import base
from tempest.common.utils.data_utils import arbitrary_string
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
from tempest.test import attr
+from tempest.test import skip_because
class ObjectExpiryTest(base.BaseObjectTest):
@@ -43,7 +42,7 @@
cls.delete_containers([cls.container_name])
super(ObjectExpiryTest, cls).tearDownClass()
- @testtools.skip('Skipped until the Bug #1069849 is resolved.')
+ @skip_because(bug="1069849")
@attr(type='gate')
def test_get_object_after_expiry_time(self):
# TODO(harika-vakadi): similar test case has to be created for
diff --git a/tempest/api/object_storage/test_object_services.py b/tempest/api/object_storage/test_object_services.py
index 7c10138..407c3ec 100644
--- a/tempest/api/object_storage/test_object_services.py
+++ b/tempest/api/object_storage/test_object_services.py
@@ -16,7 +16,6 @@
# under the License.
import hashlib
-import time
from tempest.api.object_storage import base
from tempest.common.utils.data_utils import arbitrary_string
@@ -225,44 +224,6 @@
self.assertEqual(resp[actual_meta_key], meta_value)
@attr(type='gate')
- def test_get_object_using_temp_url(self):
- # access object using temporary URL within expiration time
-
- try:
- # update account metadata
- # flag to check if account metadata got updated
- flag = False
- key = 'Meta'
- metadata = {'Temp-URL-Key': key}
- resp, _ = self.account_client.create_account_metadata(
- metadata=metadata)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
- flag = True
- resp, _ = self.account_client.list_account_metadata()
- self.assertIn('x-account-meta-temp-url-key', resp)
- self.assertEqual(resp['x-account-meta-temp-url-key'], key)
-
- # create object
- object_name = rand_name(name='ObjectTemp')
- data = arbitrary_string(size=len(object_name),
- base_text=object_name)
- self.object_client.create_object(self.container_name,
- object_name, data)
- expires = int(time.time() + 10)
-
- # trying to get object using temp url with in expiry time
- _, body = self.object_client.get_object_using_temp_url(
- self.container_name, object_name,
- expires, key)
- self.assertEqual(body, data)
- finally:
- if flag:
- resp, _ = self.account_client.delete_account_metadata(
- metadata=metadata)
- resp, _ = self.account_client.list_account_metadata()
- self.assertNotIn('x-account-meta-temp-url-key', resp)
-
- @attr(type='gate')
def test_object_upload_in_segments(self):
# create object
object_name = rand_name(name='LObject')
diff --git a/tempest/api/object_storage/test_object_temp_url.py b/tempest/api/object_storage/test_object_temp_url.py
new file mode 100644
index 0000000..0fd5499
--- /dev/null
+++ b/tempest/api/object_storage/test_object_temp_url.py
@@ -0,0 +1,157 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
+#
+# Author: Joe H. Rahme <joe.hakim.rahme@enovance.com>
+#
+# 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 hashlib
+import hmac
+import time
+import urlparse
+
+from tempest.api.object_storage import base
+from tempest.common.utils.data_utils import arbitrary_string
+from tempest.common.utils.data_utils import rand_name
+from tempest import exceptions
+from tempest.test import attr
+from tempest.test import HTTP_SUCCESS
+
+
+class ObjectTempUrlTest(base.BaseObjectTest):
+
+ @classmethod
+ def setUpClass(cls):
+ super(ObjectTempUrlTest, cls).setUpClass()
+ cls.container_name = rand_name(name='TestContainer')
+ cls.container_client.create_container(cls.container_name)
+ cls.containers = [cls.container_name]
+
+ # update account metadata
+ cls.key = 'Meta'
+ cls.metadata = {'Temp-URL-Key': cls.key}
+ cls.account_client.create_account_metadata(metadata=cls.metadata)
+ cls.account_client_metadata, _ = \
+ cls.account_client.list_account_metadata()
+
+ @classmethod
+ def tearDownClass(cls):
+ resp, _ = cls.account_client.delete_account_metadata(
+ metadata=cls.metadata)
+ resp, _ = cls.account_client.list_account_metadata()
+
+ cls.delete_containers(cls.containers)
+ # delete the user setup created
+ cls.data.teardown_all()
+ super(ObjectTempUrlTest, cls).tearDownClass()
+
+ def setUp(self):
+ super(ObjectTempUrlTest, self).setUp()
+ # make sure the metadata has been set
+ self.assertIn('x-account-meta-temp-url-key',
+ self.account_client_metadata)
+
+ self.assertEqual(
+ self.account_client_metadata['x-account-meta-temp-url-key'],
+ self.key)
+
+ # create object
+ self.object_name = rand_name(name='ObjectTemp')
+ self.data = arbitrary_string(size=len(self.object_name),
+ base_text=self.object_name)
+ self.object_client.create_object(self.container_name,
+ self.object_name, self.data)
+
+ def get_temp_url(self, container, object_name, method, expires,
+ key):
+ """Create the temporary URL."""
+
+ path = "%s/%s/%s" % (
+ urlparse.urlparse(self.object_client.base_url).path,
+ container, object_name)
+
+ hmac_body = '%s\n%s\n%s' % (method, expires, path)
+ sig = hmac.new(key, hmac_body, hashlib.sha1).hexdigest()
+
+ url = "%s/%s?temp_url_sig=%s&temp_url_expires=%s" % (container,
+ object_name,
+ sig, expires)
+
+ return url
+
+ @attr(type='gate')
+ def test_get_object_using_temp_url(self):
+ EXPIRATION_TIME = 10000 # high to ensure the test finishes.
+ expires = int(time.time() + EXPIRATION_TIME)
+
+ # get a temp URL for the created object
+ url = self.get_temp_url(self.container_name,
+ self.object_name, "GET",
+ expires, self.key)
+
+ # trying to get object using temp url within expiry time
+ _, body = self.object_client.get_object_using_temp_url(url)
+
+ self.assertEqual(body, self.data)
+
+ # Testing a HEAD on this Temp URL
+ resp, body = self.object_client.head(url)
+ self.assertIn(int(resp['status']), HTTP_SUCCESS)
+
+ @attr(type='gate')
+ def test_put_object_using_temp_url(self):
+ # make sure the metadata has been set
+ new_data = arbitrary_string(size=len(self.object_name),
+ base_text=rand_name(name="random"))
+
+ EXPIRATION_TIME = 10000 # high to ensure the test finishes.
+ expires = int(time.time() + EXPIRATION_TIME)
+
+ url = self.get_temp_url(self.container_name,
+ self.object_name, "PUT",
+ expires, self.key)
+
+ # trying to put random data in the object using temp url
+ resp, body = self.object_client.put_object_using_temp_url(
+ url, new_data)
+
+ self.assertIn(int(resp['status']), HTTP_SUCCESS)
+
+ # Testing a HEAD on this Temp URL
+ resp, body = self.object_client.head(url)
+ self.assertIn(int(resp['status']), HTTP_SUCCESS)
+
+ # Validate that the content of the object has been modified
+ url = self.get_temp_url(self.container_name,
+ self.object_name, "GET",
+ expires, self.key)
+
+ _, body = self.object_client.get_object_using_temp_url(url)
+ self.assertEqual(body, new_data)
+
+ @attr(type=['gate', 'negative'])
+ def test_get_object_after_expiration_time(self):
+ EXPIRATION_TIME = 1
+ expires = int(time.time() + EXPIRATION_TIME)
+
+ # get a temp URL for the created object
+ url = self.get_temp_url(self.container_name,
+ self.object_name, "GET",
+ expires, self.key)
+
+ # temp URL is valid for 1 seconds, let's wait 3
+ time.sleep(EXPIRATION_TIME + 2)
+
+ self.assertRaises(exceptions.Unauthorized,
+ self.object_client.get_object_using_temp_url,
+ url)
diff --git a/tempest/api/orchestration/base.py b/tempest/api/orchestration/base.py
index 2a72c95..7c72991 100644
--- a/tempest/api/orchestration/base.py
+++ b/tempest/api/orchestration/base.py
@@ -31,6 +31,7 @@
super(BaseOrchestrationTest, cls).setUpClass()
os = clients.OrchestrationManager()
cls.orchestration_cfg = os.config.orchestration
+ cls.compute_cfg = os.config.compute
if not os.config.service_available.heat:
raise cls.skipException("Heat support is required")
cls.build_timeout = cls.orchestration_cfg.build_timeout
@@ -40,10 +41,18 @@
cls.orchestration_client = os.orchestration_client
cls.servers_client = os.servers_client
cls.keypairs_client = os.keypairs_client
+ cls.network_client = os.network_client
cls.stacks = []
cls.keypairs = []
@classmethod
+ def _get_default_network(cls):
+ resp, networks = cls.network_client.list_networks()
+ for net in networks['networks']:
+ if net['name'] == cls.compute_cfg.fixed_network_name:
+ return net
+
+ @classmethod
def _get_identity_admin_client(cls):
"""
Returns an instance of the Identity Admin API client
diff --git a/tempest/api/orchestration/stacks/test_non_empty_stack.py b/tempest/api/orchestration/stacks/test_non_empty_stack.py
index defb910..0ecc5ff 100644
--- a/tempest/api/orchestration/stacks/test_non_empty_stack.py
+++ b/tempest/api/orchestration/stacks/test_non_empty_stack.py
@@ -36,6 +36,8 @@
Type: String
ImageId:
Type: String
+ Subnet:
+ Type: String
Resources:
SmokeServer:
Type: AWS::EC2::Instance
@@ -45,6 +47,7 @@
ImageId: {Ref: ImageId}
InstanceType: {Ref: InstanceType}
KeyName: {Ref: KeyName}
+ SubnetId: {Ref: Subnet}
UserData:
Fn::Base64:
Fn::Join:
@@ -78,13 +81,15 @@
cls._create_keypair()['name'])
# create the stack
+ subnet = cls._get_default_network()['subnets'][0]
cls.stack_identifier = cls.create_stack(
cls.stack_name,
cls.template,
parameters={
'KeyName': keypair_name,
'InstanceType': cls.orchestration_cfg.instance_type,
- 'ImageId': cls.orchestration_cfg.image_ref
+ 'ImageId': cls.orchestration_cfg.image_ref,
+ 'Subnet': subnet
})
cls.stack_id = cls.stack_identifier.split('/')[1]
cls.resource_name = 'SmokeServer'
diff --git a/tempest/api/orchestration/stacks/test_server_cfn_init.py b/tempest/api/orchestration/stacks/test_server_cfn_init.py
index 41849d0..ea0bff5 100644
--- a/tempest/api/orchestration/stacks/test_server_cfn_init.py
+++ b/tempest/api/orchestration/stacks/test_server_cfn_init.py
@@ -43,6 +43,8 @@
Type: String
image:
Type: String
+ network:
+ Type: String
Resources:
CfnUser:
Type: AWS::IAM::User
@@ -88,6 +90,8 @@
key_name: {Ref: key_name}
security_groups:
- {Ref: SmokeSecurityGroup}
+ networks:
+ - uuid: {Ref: network}
user_data:
Fn::Base64:
Fn::Join:
@@ -118,7 +122,7 @@
SmokeServerIp:
Description: IP address of server
Value:
- Fn::GetAtt: [SmokeServer, first_private_address]
+ Fn::GetAtt: [SmokeServer, first_address]
"""
@classmethod
@@ -142,7 +146,8 @@
parameters={
'key_name': keypair_name,
'flavor': cls.orchestration_cfg.instance_type,
- 'image': cls.orchestration_cfg.image_ref
+ 'image': cls.orchestration_cfg.image_ref,
+ 'network': cls._get_default_network()['id']
})
@attr(type='slow')
diff --git a/tempest/cli/simple_read_only/test_keystone.py b/tempest/cli/simple_read_only/test_keystone.py
index 4c1c27f..a7e7147 100644
--- a/tempest/cli/simple_read_only/test_keystone.py
+++ b/tempest/cli/simple_read_only/test_keystone.py
@@ -50,7 +50,10 @@
self.assertTrue(svc['__label'].startswith('Service:'),
msg=('Invalid beginning of service block: '
'%s' % svc['__label']))
- self.assertIn('id', svc.keys())
+ # check that region and publicURL exists. One might also
+ # check for adminURL and internalURL. id seems to be optional
+ # and is missing in the catalog backend
+ self.assertIn('publicURL', svc.keys())
self.assertIn('region', svc.keys())
def test_admin_endpoint_list(self):
diff --git a/tempest/common/isolated_creds.py b/tempest/common/isolated_creds.py
index 2fc4eb9..8c82ec0 100644
--- a/tempest/common/isolated_creds.py
+++ b/tempest/common/isolated_creds.py
@@ -94,7 +94,9 @@
for ten in tenants:
if ten['name'] == name:
tenant = ten
- raise exceptions.NotFound('No such tenant')
+ break
+ else:
+ raise exceptions.NotFound('No such tenant')
return tenant
def _create_user(self, username, password, tenant, email):
@@ -150,7 +152,6 @@
rand_name_root += suffix
tenant_name = rand_name_root + "-tenant"
tenant_desc = tenant_name + "-desc"
- rand_name_root = rand_name(self.name)
tenant = self._create_tenant(name=tenant_name,
description=tenant_desc)
if suffix:
diff --git a/tempest/common/rest_client.py b/tempest/common/rest_client.py
index a867a12..4b5127a 100644
--- a/tempest/common/rest_client.py
+++ b/tempest/common/rest_client.py
@@ -80,6 +80,21 @@
self.http_obj = http.ClosingHttp(
disable_ssl_certificate_validation=dscv)
+ def __str__(self):
+ STRING_LIMIT = 80
+ str_format = ("config:%s, user:%s, password:%s, "
+ "auth_url:%s, tenant_name:%s, auth_version:%s, "
+ "service:%s, base_url:%s, region:%s, "
+ "endpoint_url:%s, build_interval:%s, build_timeout:%s"
+ "\ntoken:%s..., \nheaders:%s...")
+ return str_format % (self.config, self.user, self.password,
+ self.auth_url, self.tenant_name,
+ self.auth_version, self.service,
+ self.base_url, self.region, self.endpoint_url,
+ self.build_interval, self.build_timeout,
+ str(self.token)[0:STRING_LIMIT],
+ str(self.headers)[0:STRING_LIMIT])
+
def _set_auth(self):
"""
Sets the token and base_url used in requests based on the strategy type
@@ -448,8 +463,8 @@
# NOTE(mtreinish): This is for compatibility with Glance and swift
# APIs. These are the return content types that Glance api v1
# (and occasionally swift) are using.
- TXT_ENC = ['text/plain; charset=UTF-8', 'text/html; charset=UTF-8',
- 'text/plain; charset=utf-8']
+ TXT_ENC = ['text/plain', 'text/plain; charset=UTF-8',
+ 'text/html; charset=UTF-8', 'text/plain; charset=utf-8']
XML_ENC = ['application/xml', 'application/xml; charset=UTF-8']
if ctype in JSON_ENC or ctype in XML_ENC:
diff --git a/tempest/config.py b/tempest/config.py
index e95755e..af78381 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -182,8 +182,8 @@
"succeed."),
cfg.IntOpt('ready_wait',
default=0,
- help="Additinal wait time for clean state, when there is"
- " no OS-EXT-STS extension availiable"),
+ help="Additional wait time for clean state, when there is "
+ "no OS-EXT-STS extension available"),
cfg.IntOpt('ssh_channel_timeout',
default=60,
help="Timeout in seconds to wait for output from ssh "
@@ -273,7 +273,7 @@
cfg.StrOpt('http_image',
default='http://download.cirros-cloud.net/0.3.1/'
'cirros-0.3.1-x86_64-uec.tar.gz',
- help='http accessable image')
+ help='http accessible image')
]
@@ -702,6 +702,7 @@
register_stress_opts(cfg.CONF)
register_scenario_opts(cfg.CONF)
register_service_available_opts(cfg.CONF)
+ register_debug_opts(cfg.CONF)
self.compute = cfg.CONF.compute
self.identity = cfg.CONF.identity
self.images = cfg.CONF.image
@@ -715,6 +716,7 @@
self.stress = cfg.CONF.stress
self.scenario = cfg.CONF.scenario
self.service_available = cfg.CONF.service_available
+ self.debug = cfg.CONF.debug
if not self.compute_admin.username:
self.compute_admin.username = self.identity.admin_username
self.compute_admin.password = self.identity.admin_password
diff --git a/tempest/hacking/checks.py b/tempest/hacking/checks.py
index aa97211..4c1c107 100644
--- a/tempest/hacking/checks.py
+++ b/tempest/hacking/checks.py
@@ -19,28 +19,11 @@
PYTHON_CLIENTS = ['cinder', 'glance', 'keystone', 'nova', 'swift', 'neutron']
-SKIP_DECORATOR_RE = re.compile(r'\s*@testtools.skip\((.*)\)')
-SKIP_STR_RE = re.compile(r'.*Bug #\d+.*')
PYTHON_CLIENT_RE = re.compile('import (%s)client' % '|'.join(PYTHON_CLIENTS))
TEST_DEFINITION = re.compile(r'^\s*def test.*')
SCENARIO_DECORATOR = re.compile(r'\s*@.*services\(')
-def skip_bugs(physical_line):
- """Check skip lines for proper bug entries
-
- T101: skips must contain "Bug #<bug_number>"
- """
-
- res = SKIP_DECORATOR_RE.match(physical_line)
- if res:
- content = res.group(1)
- res = SKIP_STR_RE.match(content)
- if not res:
- return (physical_line.find(content),
- 'T101: skips must contain "Bug #<bug_number>"')
-
-
def import_no_clients_in_api(physical_line, filename):
"""Check for client imports from tempest/api tests
@@ -70,6 +53,5 @@
def factory(register):
- register(skip_bugs)
register(import_no_clients_in_api)
register(scenario_tests_need_service_tags)
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index c01de83..c4b98d5 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -656,3 +656,10 @@
@classmethod
def _stack_rand_name(cls):
return rand_name(cls.__name__ + '-')
+
+ @classmethod
+ def _get_default_network(cls):
+ networks = cls.network_client.list_networks()
+ for net in networks['networks']:
+ if net['name'] == cls.config.compute.fixed_network_name:
+ return net
diff --git a/tempest/scenario/orchestration/test_autoscaling.py b/tempest/scenario/orchestration/test_autoscaling.py
index 1a4d802..658e9bb 100644
--- a/tempest/scenario/orchestration/test_autoscaling.py
+++ b/tempest/scenario/orchestration/test_autoscaling.py
@@ -37,11 +37,13 @@
self.keypair_name = self.keypair.id
def launch_stack(self):
+ net = self._get_default_network()
self.parameters = {
'KeyName': self.keypair_name,
'InstanceType': self.config.orchestration.instance_type,
'ImageId': self.config.orchestration.image_ref,
- 'StackStart': str(time.time())
+ 'StackStart': str(time.time()),
+ 'Subnet': net['subnets'][0]
}
# create the stack
diff --git a/tempest/scenario/orchestration/test_autoscaling.yaml b/tempest/scenario/orchestration/test_autoscaling.yaml
index 045b3bc..745eb05 100644
--- a/tempest/scenario/orchestration/test_autoscaling.yaml
+++ b/tempest/scenario/orchestration/test_autoscaling.yaml
@@ -8,6 +8,8 @@
Type: String
ImageId:
Type: String
+ Subnet:
+ Type: String
StackStart:
Description: Epoch seconds when the stack was launched
Type: Number
@@ -39,6 +41,7 @@
LaunchConfigurationName: {Ref: LaunchConfig}
MinSize: '1'
MaxSize: '3'
+ VPCZoneIdentifier: [{Ref: Subnet}]
SmokeServerScaleUpPolicy:
Type: AWS::AutoScaling::ScalingPolicy
Properties:
diff --git a/tempest/services/compute/json/aggregates_client.py b/tempest/services/compute/json/aggregates_client.py
index 7ae1eee..75ce9ff 100644
--- a/tempest/services/compute/json/aggregates_client.py
+++ b/tempest/services/compute/json/aggregates_client.py
@@ -52,6 +52,19 @@
body = json.loads(body)
return resp, body['aggregate']
+ def update_aggregate(self, aggregate_id, name, availability_zone=None):
+ """Update a aggregate."""
+ put_body = {
+ 'name': name,
+ 'availability_zone': availability_zone
+ }
+ put_body = json.dumps({'aggregate': put_body})
+ resp, body = self.put('os-aggregates/%s' % str(aggregate_id),
+ put_body, self.headers)
+
+ body = json.loads(body)
+ return resp, body['aggregate']
+
def delete_aggregate(self, aggregate_id):
"""Deletes the given aggregate."""
return self.delete("os-aggregates/%s" % str(aggregate_id))
diff --git a/tempest/services/compute/json/floating_ips_client.py b/tempest/services/compute/json/floating_ips_client.py
index 769c538..8349263 100644
--- a/tempest/services/compute/json/floating_ips_client.py
+++ b/tempest/services/compute/json/floating_ips_client.py
@@ -94,3 +94,13 @@
except exceptions.NotFound:
return True
return False
+
+ def list_floating_ip_pools(self, params=None):
+ """Returns a list of all floating IP Pools."""
+ url = 'os-floating-ip-pools'
+ if params:
+ url += '?%s' % urllib.urlencode(params)
+
+ resp, body = self.get(url)
+ body = json.loads(body)
+ return resp, body['floating_ip_pools']
diff --git a/tempest/services/compute/xml/aggregates_client.py b/tempest/services/compute/xml/aggregates_client.py
index 0ef8e22..8ef0af6 100644
--- a/tempest/services/compute/xml/aggregates_client.py
+++ b/tempest/services/compute/xml/aggregates_client.py
@@ -72,6 +72,17 @@
aggregate = self._format_aggregate(etree.fromstring(body))
return resp, aggregate
+ def update_aggregate(self, aggregate_id, name, availability_zone=None):
+ """Update a aggregate."""
+ put_body = Element("aggregate",
+ name=name,
+ availability_zone=availability_zone)
+ resp, body = self.put('os-aggregates/%s' % str(aggregate_id),
+ str(Document(put_body)),
+ self.headers)
+ aggregate = self._format_aggregate(etree.fromstring(body))
+ return resp, aggregate
+
def delete_aggregate(self, aggregate_id):
"""Deletes the given aggregate."""
return self.delete("os-aggregates/%s" % str(aggregate_id),
diff --git a/tempest/services/compute/xml/common.py b/tempest/services/compute/xml/common.py
index cb24917..84b56c2 100644
--- a/tempest/services/compute/xml/common.py
+++ b/tempest/services/compute/xml/common.py
@@ -15,6 +15,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+import collections
+
XMLNS_11 = "http://docs.openstack.org/compute/api/v1.1"
@@ -110,3 +112,19 @@
ns, tag = tag.split("}", 1)
json[tag] = xml_to_json(child)
return json
+
+
+def deep_dict_to_xml(dest, source):
+ """Populates the ``dest`` xml element with the ``source`` ``Mapping``
+ elements, if the source Mapping's value is also a ``Mapping``
+ they will be recursively added as a child elements.
+ :param source: A python ``Mapping`` (dict)
+ :param dest: XML child element will be added to the ``dest``
+ """
+ for element, content in source.iteritems():
+ if isinstance(content, collections.Mapping):
+ xml_element = Element(element)
+ deep_dict_to_xml(xml_element, content)
+ dest.append(xml_element)
+ else:
+ dest.append(Element(element, content))
diff --git a/tempest/services/compute/xml/floating_ips_client.py b/tempest/services/compute/xml/floating_ips_client.py
index 278cc88..2fffaa2 100644
--- a/tempest/services/compute/xml/floating_ips_client.py
+++ b/tempest/services/compute/xml/floating_ips_client.py
@@ -107,3 +107,13 @@
except exceptions.NotFound:
return True
return False
+
+ def list_floating_ip_pools(self, params=None):
+ """Returns a list of all floating IP Pools."""
+ url = 'os-floating-ip-pools'
+ if params:
+ url += '?%s' % urllib.urlencode(params)
+
+ resp, body = self.get(url, self.headers)
+ body = self._parse_array(etree.fromstring(body))
+ return resp, body
diff --git a/tempest/services/compute/xml/servers_client.py b/tempest/services/compute/xml/servers_client.py
index bf72bdc..c58c3ee 100644
--- a/tempest/services/compute/xml/servers_client.py
+++ b/tempest/services/compute/xml/servers_client.py
@@ -193,6 +193,14 @@
server = self._parse_server(etree.fromstring(body))
return resp, server
+ def lock_server(self, server_id, **kwargs):
+ """Locks the given server."""
+ return self.action(server_id, 'lock', None, **kwargs)
+
+ def unlock_server(self, server_id, **kwargs):
+ """Unlocks the given server."""
+ return self.action(server_id, 'unlock', None, **kwargs)
+
def suspend_server(self, server_id, **kwargs):
"""Suspends the provided server."""
return self.action(server_id, 'suspend', None, **kwargs)
@@ -209,6 +217,10 @@
"""Un-pauses the provided server."""
return self.action(server_id, 'unpause', None, **kwargs)
+ def reset_state(self, server_id, state='error'):
+ """Resets the state of a server to active/error."""
+ return self.action(server_id, 'os-resetState', None, state=state)
+
def delete_server(self, server_id):
"""Deletes the given server."""
return self.delete("servers/%s" % str(server_id))
diff --git a/tempest/services/identity/v3/json/identity_client.py b/tempest/services/identity/v3/json/identity_client.py
index 0a56e84..ec99d37 100644
--- a/tempest/services/identity/v3/json/identity_client.py
+++ b/tempest/services/identity/v3/json/identity_client.py
@@ -123,6 +123,30 @@
body = json.loads(body)
return resp, body['project']
+ def list_projects(self):
+ resp, body = self.get("projects")
+ body = json.loads(body)
+ return resp, body['projects']
+
+ def update_project(self, project_id, **kwargs):
+ resp, body = self.get_project(project_id)
+ name = kwargs.get('name', body['name'])
+ desc = kwargs.get('description', body['description'])
+ en = kwargs.get('enabled', body['enabled'])
+ domain_id = kwargs.get('domain_id', body['domain_id'])
+ post_body = {
+ 'id': project_id,
+ 'name': name,
+ 'description': desc,
+ 'enabled': en,
+ 'domain_id': domain_id,
+ }
+ post_body = json.dumps({'project': post_body})
+ resp, body = self.patch('projects/%s' % project_id, post_body,
+ self.headers)
+ body = json.loads(body)
+ return resp, body['project']
+
def get_project(self, project_id):
"""GET a Project."""
resp, body = self.get("projects/%s" % project_id)
diff --git a/tempest/services/identity/v3/xml/identity_client.py b/tempest/services/identity/v3/xml/identity_client.py
index 03e06dc..3fffc1f 100644
--- a/tempest/services/identity/v3/xml/identity_client.py
+++ b/tempest/services/identity/v3/xml/identity_client.py
@@ -163,6 +163,31 @@
body = self._parse_body(etree.fromstring(body))
return resp, body
+ def list_projects(self):
+ """Get the list of projects."""
+ resp, body = self.get("projects", self.headers)
+ body = self._parse_projects(etree.fromstring(body))
+ return resp, body
+
+ def update_project(self, project_id, **kwargs):
+ """Updates a Project."""
+ resp, body = self.get_project(project_id)
+ name = kwargs.get('name', body['name'])
+ desc = kwargs.get('description', body['description'])
+ en = kwargs.get('enabled', body['enabled'])
+ domain_id = kwargs.get('domain_id', body['domain_id'])
+ post_body = Element("project",
+ xmlns=XMLNS,
+ name=name,
+ description=desc,
+ enabled=str(en).lower(),
+ domain_id=domain_id)
+ resp, body = self.patch('projects/%s' % project_id,
+ str(Document(post_body)),
+ self.headers)
+ body = self._parse_body(etree.fromstring(body))
+ return resp, body
+
def get_project(self, project_id):
"""GET a Project."""
resp, body = self.get("projects/%s" % project_id, self.headers)
diff --git a/tempest/services/network/xml/network_client.py b/tempest/services/network/xml/network_client.py
index 1523ed0..cf8154a 100755
--- a/tempest/services/network/xml/network_client.py
+++ b/tempest/services/network/xml/network_client.py
@@ -16,6 +16,7 @@
import xml.etree.ElementTree as ET
from tempest.common.rest_client import RestClientXML
+from tempest.services.compute.xml.common import deep_dict_to_xml
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
@@ -441,6 +442,111 @@
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
+ def create_router(self, name, **kwargs):
+ uri = '%s/routers' % (self.uri_prefix)
+ router = Element("router")
+ router.append(Element("name", name))
+ deep_dict_to_xml(router, kwargs)
+ resp, body = self.post(uri, str(Document(router)), self.headers)
+ body = _root_tag_fetcher_and_xml_to_json_parse(body)
+ return resp, body
+
+ def delete_router(self, router_id):
+ uri = '%s/routers/%s' % (self.uri_prefix, router_id)
+ resp, body = self.delete(uri, self.headers)
+ return resp, body
+
+ def show_router(self, router_id):
+ uri = '%s/routers/%s' % (self.uri_prefix, router_id)
+ resp, body = self.get(uri, self.headers)
+ body = _root_tag_fetcher_and_xml_to_json_parse(body)
+ return resp, body
+
+ def update_router(self, router_id, **kwargs):
+ uri = '%s/routers/%s' % (self.uri_prefix, router_id)
+ router = Element("router")
+ for element, content in kwargs.iteritems():
+ router.append(Element(element, content))
+ resp, body = self.put(uri, str(Document(router)), self.headers)
+ body = _root_tag_fetcher_and_xml_to_json_parse(body)
+ return resp, body
+
+ def add_router_interface_with_subnet_id(self, router_id, subnet_id):
+ uri = '%s/routers/%s/add_router_interface' % (self.uri_prefix,
+ router_id)
+ subnet = Element("subnet_id", subnet_id)
+ resp, body = self.put(uri, str(Document(subnet)), self.headers)
+ body = _root_tag_fetcher_and_xml_to_json_parse(body)
+ return resp, body
+
+ def add_router_interface_with_port_id(self, router_id, port_id):
+ uri = '%s/routers/%s/add_router_interface' % (self.uri_prefix,
+ router_id)
+ port = Element("port_id", port_id)
+ resp, body = self.put(uri, str(Document(port)), self.headers)
+ body = _root_tag_fetcher_and_xml_to_json_parse(body)
+ return resp, body
+
+ def remove_router_interface_with_subnet_id(self, router_id, subnet_id):
+ uri = '%s/routers/%s/remove_router_interface' % (self.uri_prefix,
+ router_id)
+ subnet = Element("subnet_id", subnet_id)
+ resp, body = self.put(uri, str(Document(subnet)), self.headers)
+ body = _root_tag_fetcher_and_xml_to_json_parse(body)
+ return resp, body
+
+ def remove_router_interface_with_port_id(self, router_id, port_id):
+ uri = '%s/routers/%s/remove_router_interface' % (self.uri_prefix,
+ router_id)
+ port = Element("port_id", port_id)
+ resp, body = self.put(uri, str(Document(port)), self.headers)
+ body = _root_tag_fetcher_and_xml_to_json_parse(body)
+ return resp, body
+
+ def create_floating_ip(self, ext_network_id, **kwargs):
+ uri = '%s/floatingips' % (self.uri_prefix)
+ floatingip = Element('floatingip')
+ floatingip.append(Element("floating_network_id", ext_network_id))
+ for element, content in kwargs.iteritems():
+ floatingip.append(Element(element, content))
+ resp, body = self.post(uri, str(Document(floatingip)), self.headers)
+ body = _root_tag_fetcher_and_xml_to_json_parse(body)
+ return resp, body
+
+ def show_floating_ip(self, floating_ip_id):
+ uri = '%s/floatingips/%s' % (self.uri_prefix, floating_ip_id)
+ resp, body = self.get(uri, self.headers)
+ body = _root_tag_fetcher_and_xml_to_json_parse(body)
+ return resp, body
+
+ def list_floating_ips(self):
+ uri = '%s/floatingips' % (self.uri_prefix)
+ resp, body = self.get(uri, self.headers)
+ floatingips = self._parse_array(etree.fromstring(body))
+ floatingips = {"floatingips": floatingips}
+ return resp, floatingips
+
+ def delete_floating_ip(self, floating_ip_id):
+ uri = '%s/floatingips/%s' % (self.uri_prefix, floating_ip_id)
+ resp, body = self.delete(uri, self.headers)
+ return resp, body
+
+ def update_floating_ip(self, floating_ip_id, **kwargs):
+ uri = '%s/floatingips/%s' % (self.uri_prefix, floating_ip_id)
+ floatingip = Element('floatingip')
+ floatingip.add_attr('xmlns:xsi',
+ 'http://www.w3.org/2001/XMLSchema-instance')
+ for element, content in kwargs.iteritems():
+ if content is None:
+ xml_elem = Element(element)
+ xml_elem.add_attr("xsi:nil", "true")
+ floatingip.append(xml_elem)
+ else:
+ floatingip.append(Element(element, content))
+ resp, body = self.put(uri, str(Document(floatingip)), self.headers)
+ body = _root_tag_fetcher_and_xml_to_json_parse(body)
+ return resp, body
+
def _root_tag_fetcher_and_xml_to_json_parse(xml_returned_body):
body = ET.fromstring(xml_returned_body)
@@ -448,5 +554,10 @@
if root_tag.startswith("{"):
ns, root_tag = root_tag.split("}", 1)
body = xml_to_json(etree.fromstring(xml_returned_body))
+ nil = '{http://www.w3.org/2001/XMLSchema-instance}nil'
+ for key, val in body.iteritems():
+ if isinstance(val, dict):
+ if (nil in val and val[nil] == 'true'):
+ body[key] = None
body = {root_tag: body}
return body
diff --git a/tempest/services/object_storage/object_client.py b/tempest/services/object_storage/object_client.py
index d338d45..2fee042 100644
--- a/tempest/services/object_storage/object_client.py
+++ b/tempest/services/object_storage/object_client.py
@@ -15,10 +15,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-import hashlib
-import hmac
-import urlparse
-
from tempest.common import http
from tempest.common.rest_client import RestClient
from tempest import exceptions
@@ -125,29 +121,20 @@
resp, body = self.copy(url, headers=headers)
return resp, body
- def get_object_using_temp_url(self, container, object_name, expires, key):
- """Retrieve object's data using temporary URL."""
-
- self._set_auth()
- method = 'GET'
- path = "%s/%s/%s" % (urlparse.urlparse(self.base_url).path, container,
- object_name)
- hmac_body = '%s\n%s\n%s' % (method, expires, path)
- sig = hmac.new(key, hmac_body, hashlib.sha1).hexdigest()
-
- url = "%s/%s?temp_url_sig=%s&temp_url_expires=%s" % (container,
- object_name,
- sig, expires)
-
- resp, body = self.get(url)
- return resp, body
-
def create_object_segments(self, container, object_name, segment, data):
"""Creates object segments."""
url = "{0}/{1}/{2}".format(container, object_name, segment)
resp, body = self.put(url, data, self.headers)
return resp, body
+ def get_object_using_temp_url(self, url):
+ """Retrieve object's data using temp URL."""
+ return self.get(url)
+
+ def put_object_using_temp_url(self, url, data):
+ """Put data in an object using temp URL."""
+ return self.put(url, data, None)
+
class ObjectClientCustomizedHeader(RestClient):
diff --git a/tempest/stress/driver.py b/tempest/stress/driver.py
index d959543..55404ce 100644
--- a/tempest/stress/driver.py
+++ b/tempest/stress/driver.py
@@ -35,11 +35,14 @@
username = admin_manager.config.stress.target_ssh_user
key_filename = admin_manager.config.stress.target_private_key_path
if not (username and key_filename):
+ LOG.error('username and key_filename should not be empty')
return None
ssh_client = ssh.Client(host, username, key_filename=key_filename)
try:
return ssh_client.exec_command(command)
except exceptions.SSHExecCommandFailed:
+ LOG.error('do_ssh raise exception. command:%s, host:%s.'
+ % (command, host))
return None
@@ -62,19 +65,20 @@
return nodes
-def _error_in_logs(logfiles, nodes):
+def _has_error_in_logs(logfiles, nodes, stop_on_error=False):
"""
Detect errors in the nova log files on the controller and compute nodes.
"""
grep = 'egrep "ERROR|TRACE" %s' % logfiles
+ ret = False
for node in nodes:
errors = do_ssh(grep, node)
- if not errors:
- return None
if len(errors) > 0:
LOG.error('%s: %s' % (node, errors))
- return errors
- return None
+ ret = True
+ if stop_on_error:
+ break
+ return ret
def sigchld_handler(signal, frame):
@@ -192,8 +196,7 @@
if not logfiles:
continue
- errors = _error_in_logs(logfiles, computes)
- if errors:
+ if _has_error_in_logs(logfiles, computes):
had_errors = True
break
diff --git a/tempest/test.py b/tempest/test.py
index 6acb1c9..0c7c916 100644
--- a/tempest/test.py
+++ b/tempest/test.py
@@ -103,6 +103,21 @@
return decorator
+def skip_because(*args, **kwargs):
+ """A decorator useful to skip tests hitting known bugs
+
+ @param bug: bug number causing the test to skip
+ @param condition: optional condition to be True for the skip to have place
+ """
+ def decorator(f):
+ if "bug" in kwargs:
+ if "condition" not in kwargs or kwargs["condition"] is True:
+ msg = "Skipped until Bug: %s is resolved." % kwargs["bug"]
+ raise testtools.TestCase.skipException(msg)
+ return f
+ return decorator
+
+
# there is a mis-match between nose and testtools for older pythons.
# testtools will set skipException to be either
# unittest.case.SkipTest, unittest2.case.SkipTest or an internal skip
diff --git a/tempest/thirdparty/boto/test_ec2_instance_run.py b/tempest/thirdparty/boto/test_ec2_instance_run.py
index 486e0a0..0f455e1 100644
--- a/tempest/thirdparty/boto/test_ec2_instance_run.py
+++ b/tempest/thirdparty/boto/test_ec2_instance_run.py
@@ -16,7 +16,6 @@
# under the License.
from boto import exception
-import testtools
from tempest import clients
from tempest.common.utils.data_utils import rand_name
@@ -24,6 +23,7 @@
from tempest import exceptions
from tempest.openstack.common import log as logging
from tempest.test import attr
+from tempest.test import skip_because
from tempest.thirdparty.boto.test import BotoTestCase
from tempest.thirdparty.boto.utils.s3 import s3_upload_dir
from tempest.thirdparty.boto.utils.wait import re_search_wait
@@ -188,13 +188,13 @@
self.assertEqual(tags[0].value, 'value1')
tags = self.ec2_client.get_all_tags(filters={'key': 'value2'})
- self.assertEqual(len(tags), 0)
+ self.assertEqual(len(tags), 0, str(tags))
for instance in reservation.instances:
instance.remove_tag('key1', value='value1')
tags = self.ec2_client.get_all_tags()
- self.assertEqual(len(tags), 0)
+ self.assertEqual(len(tags), 0, str(tags))
for instance in reservation.instances:
instance.stop()
@@ -206,8 +206,8 @@
instance.terminate()
self.cancelResourceCleanUp(rcuk)
+ @skip_because(bug="1098891")
@attr(type='smoke')
- @testtools.skip("Skipped until the Bug #1098891 is resolved")
def test_run_terminate_instance(self):
# EC2 run, terminate immediately
image_ami = self.ec2_client.get_image(self.images["ami"]
@@ -233,7 +233,7 @@
# NOTE(afazekas): doctored test case,
# with normal validation it would fail
- @testtools.skip("Skipped until the Bug #1182679 is resolved.")
+ @skip_because(bug="1182679")
@attr(type='smoke')
def test_integration_1(self):
# EC2 1. integration test (not strict)
diff --git a/tempest/thirdparty/boto/test_ec2_keys.py b/tempest/thirdparty/boto/test_ec2_keys.py
index 85a99c0..5592d8c 100644
--- a/tempest/thirdparty/boto/test_ec2_keys.py
+++ b/tempest/thirdparty/boto/test_ec2_keys.py
@@ -15,11 +15,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-
from tempest import clients
from tempest.common.utils.data_utils import rand_name
from tempest.test import attr
+from tempest.test import skip_because
from tempest.thirdparty.boto.test import BotoTestCase
@@ -47,8 +46,8 @@
self.assertTrue(compare_key_pairs(keypair,
self.client.get_key_pair(key_name)))
+ @skip_because(bug="1072318")
@attr(type='smoke')
- @testtools.skip("Skipped until the Bug #1072318 is resolved")
def test_delete_ec2_keypair(self):
# EC2 delete KeyPair
key_name = rand_name("keypair-")
diff --git a/tempest/thirdparty/boto/test_ec2_network.py b/tempest/thirdparty/boto/test_ec2_network.py
index ae8c3c2..b4949c8 100644
--- a/tempest/thirdparty/boto/test_ec2_network.py
+++ b/tempest/thirdparty/boto/test_ec2_network.py
@@ -15,10 +15,9 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-
from tempest import clients
from tempest.test import attr
+from tempest.test import skip_because
from tempest.thirdparty.boto.test import BotoTestCase
@@ -30,8 +29,8 @@
cls.os = clients.Manager()
cls.client = cls.os.ec2api_client
-# Note(afazekas): these tests for things duable without an instance
- @testtools.skip("Skipped until the Bug #1080406 is resolved")
+ # Note(afazekas): these tests for things duable without an instance
+ @skip_because(bug="1080406")
@attr(type='smoke')
def test_disassociate_not_associated_floating_ip(self):
# EC2 disassociate not associated floating ip
diff --git a/tempest/thirdparty/boto/test_s3_buckets.py b/tempest/thirdparty/boto/test_s3_buckets.py
index e43cbaa..1a8fbe0 100644
--- a/tempest/thirdparty/boto/test_s3_buckets.py
+++ b/tempest/thirdparty/boto/test_s3_buckets.py
@@ -15,11 +15,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-
from tempest import clients
from tempest.common.utils.data_utils import rand_name
from tempest.test import attr
+from tempest.test import skip_because
from tempest.thirdparty.boto.test import BotoTestCase
@@ -31,7 +30,7 @@
cls.os = clients.Manager()
cls.client = cls.os.s3_client
- @testtools.skip("Skipped until the Bug #1076965 is resolved")
+ @skip_because(bug="1076965")
@attr(type='smoke')
def test_create_and_get_delete_bucket(self):
# S3 Create, get and delete bucket
diff --git a/test-requirements.txt b/test-requirements.txt
index 1ede25e..8aa6ed9 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -3,3 +3,4 @@
docutils==0.9.1
sphinx>=1.1.2
python-subunit
+oslo.sphinx
diff --git a/tools/skip_tracker.py b/tools/skip_tracker.py
index c38ccdb..ffaf134 100755
--- a/tools/skip_tracker.py
+++ b/tools/skip_tracker.py
@@ -61,8 +61,8 @@
"""
Return the skip tuples in a test file
"""
- BUG_RE = re.compile(r'.*skip.*bug:*\s*\#*(\d+)', re.IGNORECASE)
- DEF_RE = re.compile(r'.*def (\w+)\(')
+ BUG_RE = re.compile(r'\s*@.*skip_because\(bug=[\'"](\d+)[\'"]')
+ DEF_RE = re.compile(r'\s*def (\w+)\(')
bug_found = False
results = []
lines = open(path, 'rb').readlines()
diff --git a/tox.ini b/tox.ini
index abc9e42..ff09b3f 100644
--- a/tox.ini
+++ b/tox.ini
@@ -51,6 +51,7 @@
NOSE_OPENSTACK_YELLOW=3
NOSE_OPENSTACK_SHOW_ELAPSED=1
NOSE_OPENSTACK_STDOUT=1
+ TEMPEST_PY26_NOSE_COMPAT=1
commands =
nosetests --logging-format '%(asctime)-15s %(message)s' --with-xunit -sv --xunit-file=nosetests-full.xml tempest/api tempest/scenario tempest/thirdparty tempest/cli tempest/tests {posargs}
@@ -62,6 +63,7 @@
NOSE_OPENSTACK_YELLOW=3
NOSE_OPENSTACK_SHOW_ELAPSED=1
NOSE_OPENSTACK_STDOUT=1
+ TEMPEST_PY26_NOSE_COMPAT=1
commands =
nosetests --logging-format '%(asctime)-15s %(message)s' --with-xunit -sv --attr=type=smoke --xunit-file=nosetests-smoke.xml tempest {posargs}