Merge "Stop test execution in case of an plugin error"
diff --git a/requirements.txt b/requirements.txt
index 66e5b16..d0419f7 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,7 +1,7 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
-pbr<2.0,>=0.11
+pbr<2.0,>=1.3
cliff>=1.13.0 # Apache-2.0
anyjson>=0.3.3
httplib2>=0.7.5
@@ -11,13 +11,13 @@
paramiko>=1.13.0
netaddr>=0.7.12
testrepository>=0.0.18
-pyOpenSSL>=0.11
+pyOpenSSL>=0.14
oslo.concurrency>=2.1.0 # Apache-2.0
oslo.config>=1.11.0 # Apache-2.0
oslo.i18n>=1.5.0 # Apache-2.0
-oslo.log>=1.2.0 # Apache-2.0
+oslo.log>=1.6.0 # Apache-2.0
oslo.serialization>=1.4.0 # Apache-2.0
-oslo.utils>=1.6.0 # Apache-2.0
+oslo.utils>=1.9.0 # Apache-2.0
six>=1.9.0
iso8601>=0.1.9
fixtures>=1.3.1
diff --git a/setup.py b/setup.py
index 056c16c..d8080d0 100644
--- a/setup.py
+++ b/setup.py
@@ -25,5 +25,5 @@
pass
setuptools.setup(
- setup_requires=['pbr'],
+ setup_requires=['pbr>=1.3'],
pbr=True)
diff --git a/tempest/common/isolated_creds.py b/tempest/common/isolated_creds.py
index 2102638..ff4eda9 100644
--- a/tempest/common/isolated_creds.py
+++ b/tempest/common/isolated_creds.py
@@ -51,11 +51,21 @@
def create_project(self, name, description):
pass
- def assign_user_role(self, user, project, role_name):
+ def _check_role_exists(self, role_name):
try:
roles = self._list_roles()
role = next(r for r in roles if r['name'] == role_name)
except StopIteration:
+ return None
+ return role
+
+ def create_user_role(self, role_name):
+ if not self._check_role_exists(role_name):
+ self.identity_client.create_role(role_name)
+
+ def assign_user_role(self, user, project, role_name):
+ role = self._check_role_exists(role_name)
+ if not role:
msg = 'No "%s" role found' % role_name
raise lib_exc.NotFound(msg)
try:
@@ -196,16 +206,27 @@
email = data_utils.rand_name(root) + suffix + "@example.com"
user = self.creds_client.create_user(
username, user_password, project, email)
+ role_assigned = False
if admin:
self.creds_client.assign_user_role(user, project,
CONF.identity.admin_role)
+ role_assigned = True
# Add roles specified in config file
for conf_role in CONF.auth.tempest_roles:
self.creds_client.assign_user_role(user, project, conf_role)
+ role_assigned = True
# Add roles requested by caller
if roles:
for role in roles:
self.creds_client.assign_user_role(user, project, role)
+ role_assigned = True
+ # NOTE(mtreinish) For a user to have access to a project with v3 auth
+ # it must beassigned a role on the project. So we need to ensure that
+ # our newly created user has a role on the newly created project.
+ if self.identity_version == 'v3' and not role_assigned:
+ self.creds_client.create_user_role('Member')
+ self.creds_client.assign_user_role(user, project, 'Member')
+
creds = self.creds_client.get_credentials(user, project, user_password)
return cred_provider.TestResources(creds)
diff --git a/tempest/test_discover/test_discover.py b/tempest/test_discover/test_discover.py
index 86aa855..dac7d91 100644
--- a/tempest/test_discover/test_discover.py
+++ b/tempest/test_discover/test_discover.py
@@ -48,8 +48,8 @@
for plugin in plugin_load_tests:
test_dir, top_path = plugin_load_tests[plugin]
if not pattern:
- suite.addTests(loader.discover(test_dir, top_level=top_path))
+ suite.addTests(loader.discover(test_dir, top_level_dir=top_path))
else:
suite.addTests(loader.discover(test_dir, pattern=pattern,
- top_level=top_path))
+ top_level_dir=top_path))
return suite
diff --git a/tempest/tests/services/__init__.py b/tempest/tests/services/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/tests/services/__init__.py
diff --git a/tempest/tests/services/compute/__init__.py b/tempest/tests/services/compute/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/tests/services/compute/__init__.py
diff --git a/tempest/tests/services/compute/test_agents_client.py b/tempest/tests/services/compute/test_agents_client.py
new file mode 100644
index 0000000..e8ea525
--- /dev/null
+++ b/tempest/tests/services/compute/test_agents_client.py
@@ -0,0 +1,50 @@
+# Copyright 2015 NEC Corporation. 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 httplib2
+
+from oslotest import mockpatch
+
+from tempest.services.compute.json import agents_client
+from tempest.tests import base
+from tempest.tests import fake_auth_provider
+from tempest.tests import fake_config
+
+
+class TestAgentsClient(base.TestCase):
+
+ def setUp(self):
+ super(TestAgentsClient, self).setUp()
+ self.useFixture(fake_config.ConfigFixture())
+ fake_auth = fake_auth_provider.FakeAuthProvider()
+ self.client = agents_client.AgentsClient(fake_auth,
+ 'compute', 'regionOne')
+
+ def _test_list_agents(self, bytes_body=False):
+ if bytes_body:
+ body = bytes(b'{"agents": []}')
+ else:
+ body = '{"agents": []}'
+ expected = []
+ response = (httplib2.Response({'status': 200}), body)
+ self.useFixture(mockpatch.Patch(
+ 'tempest.common.service_client.ServiceClient.get',
+ return_value=response))
+ self.assertEqual(expected, self.client.list_agents())
+
+ def test_list_agents_with_str_body(self):
+ self._test_list_agents()
+
+ def test_list_agents_with_bytes_body(self):
+ self._test_list_agents(bytes_body=True)
diff --git a/test-requirements.txt b/test-requirements.txt
index 7115168..8fcf071 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -10,4 +10,4 @@
mock>=1.1;python_version!='2.6'
mock==1.0.1;python_version=='2.6'
coverage>=3.6
-oslotest>=1.5.1 # Apache-2.0
+oslotest>=1.7.0 # Apache-2.0