Merge "Add shelve_offload test for Nova API"
diff --git a/.gitignore b/.gitignore
index 0f4880f..8d2b281 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,3 +15,5 @@
dist
build
.testrepository
+.coverage
+cover/
diff --git a/etc/logging.conf.sample b/etc/logging.conf.sample
index 3b468f1..cdeedef 100644
--- a/etc/logging.conf.sample
+++ b/etc/logging.conf.sample
@@ -1,46 +1,40 @@
[loggers]
-keys=root,tempest,tempest_stress
+keys=root,tempest_stress
[handlers]
-keys=file,syslog,devel
+keys=file,devel,syslog
[formatters]
-keys=default,tests
+keys=simple,tests
[logger_root]
-level=NOTSET
-handlers=syslog
-
-[logger_tempest]
level=DEBUG
handlers=file
-qualname=tempest
[logger_tempest_stress]
-level=INFO
+level=DEBUG
handlers=file,devel
qualname=tempest.stress
[handler_file]
class=FileHandler
level=DEBUG
+args=('tempest.log', 'w+')
formatter=tests
-args=('tempest.log', 'w')
[handler_syslog]
class=handlers.SysLogHandler
level=ERROR
-formatter = default
args = ('/dev/log', handlers.SysLogHandler.LOG_USER)
[handler_devel]
class=StreamHandler
level=DEBUG
-formatter=default
args=(sys.stdout,)
-
-[formatter_default]
-format=%(name)s: %(levelname)s: %(message)s
+formatter=simple
[formatter_tests]
-class = tempest.common.log.TestsFormatter
+class = tempest.openstack.common.log.ContextFormatter
+
+[formatter_simple]
+format=%(asctime)s.%(msecs)03d %(process)d %(levelname)s: %(message)s
diff --git a/etc/schemas/compute/admin/flavor_create.json b/etc/schemas/compute/admin/flavor_create.json
new file mode 100644
index 0000000..0a3e7b3
--- /dev/null
+++ b/etc/schemas/compute/admin/flavor_create.json
@@ -0,0 +1,20 @@
+{
+ "name": "flavor-create",
+ "http-method": "POST",
+ "admin_client": true,
+ "url": "flavors",
+ "default_result_code": 400,
+ "json-schema": {
+ "type": "object",
+ "properties": {
+ "name": { "type": "string"},
+ "ram": { "type": "integer", "minimum": 1},
+ "vcpus": { "type": "integer", "minimum": 1},
+ "disk": { "type": "integer"},
+ "id": { "type": "integer"},
+ "swap": { "type": "integer"},
+ "rxtx_factor": { "type": "integer"},
+ "OS-FLV-EXT-DATA:ephemeral": { "type": "integer"}
+ }
+ }
+}
diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample
index b0c7826..068a666 100644
--- a/etc/tempest.conf.sample
+++ b/etc/tempest.conf.sample
@@ -562,6 +562,16 @@
#ssh_user_regex=[["^.*[Cc]irros.*$", "root"]]
+[negative]
+
+#
+# Options defined in tempest.config
+#
+
+# Test generator class for all negative tests (string value)
+#test_generator=tempest.common.generator.negative_generator.NegativeTestGenerator
+
+
[network]
#
@@ -712,6 +722,16 @@
#max_template_size=524288
+[queuing]
+
+#
+# Options defined in tempest.config
+#
+
+# Catalog type of the Queuing service. (string value)
+#catalog_type=queuing
+
+
[scenario]
#
@@ -791,6 +811,10 @@
# value)
#trove=false
+# Whether or not Marconi is expected to be available (boolean
+# value)
+#marconi=false
+
[stress]
diff --git a/requirements.txt b/requirements.txt
index 0bddca3..48d1b12 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -9,7 +9,7 @@
netaddr>=0.7.6
python-glanceclient>=0.9.0
python-keystoneclient>=0.6.0
-python-novaclient>=2.15.0
+python-novaclient>=2.17.0
python-neutronclient>=2.3.4,<3
python-cinderclient>=1.0.6
python-heatclient>=0.2.3
diff --git a/tempest/api/compute/admin/test_aggregates.py b/tempest/api/compute/admin/test_aggregates.py
index 6797005..fb249e5 100644
--- a/tempest/api/compute/admin/test_aggregates.py
+++ b/tempest/api/compute/admin/test_aggregates.py
@@ -16,7 +16,7 @@
from tempest.api.compute import base
from tempest.common import tempest_fixtures as fixtures
from tempest.common.utils import data_utils
-from tempest.test import attr
+from tempest import test
class AggregatesAdminTestJSON(base.BaseV2ComputeAdminTest):
@@ -39,7 +39,7 @@
filter(lambda y: y['service'] == 'compute', hosts_all))
cls.host = hosts[0]
- @attr(type='gate')
+ @test.attr(type='gate')
def test_aggregate_create_delete(self):
# Create and delete an aggregate.
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
@@ -52,7 +52,7 @@
self.assertEqual(200, resp.status)
self.client.wait_for_resource_deletion(aggregate['id'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_aggregate_create_delete_with_az(self):
# Create and delete an aggregate.
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
@@ -67,7 +67,7 @@
self.assertEqual(200, resp.status)
self.client.wait_for_resource_deletion(aggregate['id'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_aggregate_create_verify_entry_in_list(self):
# Create an aggregate and ensure it is listed.
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
@@ -80,7 +80,7 @@
map(lambda x: (x['id'], x['availability_zone']),
aggregates))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_aggregate_create_update_metadata_get_details(self):
# Create an aggregate and ensure its details are returned.
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
@@ -105,7 +105,7 @@
self.assertEqual(200, resp.status)
self.assertEqual(meta, body["metadata"])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_aggregate_create_update_with_az(self):
# Update an aggregate and ensure properties are updated correctly
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
@@ -137,7 +137,7 @@
(x['id'], x['name'], x['availability_zone']),
aggregates))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_aggregate_add_remove_host(self):
# Add an host to the given aggregate and remove.
self.useFixture(fixtures.LockFixture('availability_zone'))
@@ -159,7 +159,7 @@
body['availability_zone'])
self.assertNotIn(self.host, body['hosts'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_aggregate_add_host_list(self):
# Add an host to the given aggregate and list.
self.useFixture(fixtures.LockFixture('availability_zone'))
@@ -177,7 +177,7 @@
self.assertIsNone(agg['availability_zone'])
self.assertIn(self.host, agg['hosts'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_aggregate_add_host_get_details(self):
# Add an host to the given aggregate and get details.
self.useFixture(fixtures.LockFixture('availability_zone'))
@@ -192,7 +192,7 @@
self.assertIsNone(body['availability_zone'])
self.assertIn(self.host, body['hosts'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_aggregate_add_host_create_server_with_az(self):
# Add an host to the given aggregate and create a server.
self.useFixture(fixtures.LockFixture('availability_zone'))
diff --git a/tempest/api/compute/admin/test_aggregates_negative.py b/tempest/api/compute/admin/test_aggregates_negative.py
index 3d34d47..690f2ab 100644
--- a/tempest/api/compute/admin/test_aggregates_negative.py
+++ b/tempest/api/compute/admin/test_aggregates_negative.py
@@ -17,7 +17,7 @@
from tempest.common import tempest_fixtures as fixtures
from tempest.common.utils import data_utils
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class AggregatesAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
@@ -39,7 +39,7 @@
filter(lambda y: y['service'] == 'compute', hosts_all))
cls.host = hosts[0]
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_aggregate_create_as_user(self):
# Regular user is not allowed to create an aggregate.
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
@@ -47,14 +47,14 @@
self.user_client.create_aggregate,
name=aggregate_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_aggregate_create_aggregate_name_length_less_than_1(self):
# the length of aggregate name should >= 1 and <=255
self.assertRaises(exceptions.BadRequest,
self.client.create_aggregate,
name='')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_aggregate_create_aggregate_name_length_exceeds_255(self):
# the length of aggregate name should >= 1 and <=255
aggregate_name = 'a' * 256
@@ -62,7 +62,7 @@
self.client.create_aggregate,
name=aggregate_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_aggregate_create_with_existent_aggregate_name(self):
# creating an aggregate with existent aggregate name is forbidden
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
@@ -74,7 +74,7 @@
self.client.create_aggregate,
name=aggregate_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_aggregate_delete_as_user(self):
# Regular user is not allowed to delete an aggregate.
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
@@ -86,13 +86,13 @@
self.user_client.delete_aggregate,
aggregate['id'])
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_aggregate_list_as_user(self):
# Regular user is not allowed to list aggregates.
self.assertRaises(exceptions.Unauthorized,
self.user_client.list_aggregates)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_aggregate_get_details_as_user(self):
# Regular user is not allowed to get aggregate details.
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
@@ -104,19 +104,19 @@
self.user_client.get_aggregate,
aggregate['id'])
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_aggregate_delete_with_invalid_id(self):
# Delete an aggregate with invalid id should raise exceptions.
self.assertRaises(exceptions.NotFound,
self.client.delete_aggregate, -1)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_aggregate_get_details_with_invalid_id(self):
# Get aggregate details with invalid id should raise exceptions.
self.assertRaises(exceptions.NotFound,
self.client.get_aggregate, -1)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_aggregate_add_non_exist_host(self):
# Adding a non-exist host to an aggregate should raise exceptions.
resp, hosts_all = self.os_adm.hosts_client.list_hosts()
@@ -133,7 +133,7 @@
self.assertRaises(exceptions.NotFound, self.client.add_host,
aggregate['id'], non_exist_host)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_aggregate_add_host_as_user(self):
# Regular user is not allowed to add a host to an aggregate.
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
@@ -145,7 +145,7 @@
self.user_client.add_host,
aggregate['id'], self.host)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_aggregate_add_existent_host(self):
self.useFixture(fixtures.LockFixture('availability_zone'))
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
@@ -160,7 +160,7 @@
self.assertRaises(exceptions.Conflict, self.client.add_host,
aggregate['id'], self.host)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_aggregate_remove_host_as_user(self):
# Regular user is not allowed to remove a host from an aggregate.
self.useFixture(fixtures.LockFixture('availability_zone'))
@@ -176,7 +176,7 @@
self.user_client.remove_host,
aggregate['id'], self.host)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_aggregate_remove_nonexistent_host(self):
non_exist_host = data_utils.rand_name('nonexist_host_')
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
diff --git a/tempest/api/compute/admin/test_availability_zone.py b/tempest/api/compute/admin/test_availability_zone.py
index 1387261..3c06624 100644
--- a/tempest/api/compute/admin/test_availability_zone.py
+++ b/tempest/api/compute/admin/test_availability_zone.py
@@ -14,7 +14,7 @@
# under the License.
from tempest.api.compute import base
-from tempest.test import attr
+from tempest import test
class AZAdminTestJSON(base.BaseV2ComputeAdminTest):
@@ -28,14 +28,14 @@
super(AZAdminTestJSON, cls).setUpClass()
cls.client = cls.os_adm.availability_zone_client
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_availability_zone_list(self):
# List of availability zone
resp, availability_zone = self.client.get_availability_zone_list()
self.assertEqual(200, resp.status)
self.assertTrue(len(availability_zone) > 0)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_availability_zone_list_detail(self):
# List of availability zones and available services
resp, availability_zone = \
diff --git a/tempest/api/compute/admin/test_availability_zone_negative.py b/tempest/api/compute/admin/test_availability_zone_negative.py
index 8cc8bce..ce97491 100644
--- a/tempest/api/compute/admin/test_availability_zone_negative.py
+++ b/tempest/api/compute/admin/test_availability_zone_negative.py
@@ -14,7 +14,7 @@
from tempest.api.compute import base
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class AZAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
@@ -28,7 +28,7 @@
super(AZAdminNegativeTestJSON, cls).setUpClass()
cls.non_adm_client = cls.availability_zone_client
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_get_availability_zone_list_detail_with_non_admin_user(self):
# List of availability zones and available services with
# non-administrator user
diff --git a/tempest/api/compute/admin/test_fixed_ips.py b/tempest/api/compute/admin/test_fixed_ips.py
index 00bb9c3..b0692b1 100644
--- a/tempest/api/compute/admin/test_fixed_ips.py
+++ b/tempest/api/compute/admin/test_fixed_ips.py
@@ -15,7 +15,7 @@
from tempest.api.compute import base
from tempest import config
-from tempest.test import attr
+from tempest import test
CONF = config.CONF
@@ -39,18 +39,18 @@
if cls.ip:
break
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_fixed_ip_details(self):
resp, fixed_ip = self.client.get_fixed_ip_details(self.ip)
self.assertEqual(fixed_ip['address'], self.ip)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_set_reserve(self):
body = {"reserve": "None"}
resp, body = self.client.reserve_fixed_ip(self.ip, body)
self.assertEqual(resp.status, 202)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_set_unreserve(self):
body = {"unreserve": "None"}
resp, body = self.client.reserve_fixed_ip(self.ip, body)
diff --git a/tempest/api/compute/admin/test_fixed_ips_negative.py b/tempest/api/compute/admin/test_fixed_ips_negative.py
index 0faedb2..3fb3829 100644
--- a/tempest/api/compute/admin/test_fixed_ips_negative.py
+++ b/tempest/api/compute/admin/test_fixed_ips_negative.py
@@ -15,7 +15,7 @@
from tempest.api.compute import base
from tempest import config
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
CONF = config.CONF
@@ -40,26 +40,26 @@
if cls.ip:
break
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_list_fixed_ip_details_with_non_admin_user(self):
self.assertRaises(exceptions.Unauthorized,
self.non_admin_client.get_fixed_ip_details, self.ip)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_set_reserve_with_non_admin_user(self):
body = {"reserve": "None"}
self.assertRaises(exceptions.Unauthorized,
self.non_admin_client.reserve_fixed_ip,
self.ip, body)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_set_unreserve_with_non_admin_user(self):
body = {"unreserve": "None"}
self.assertRaises(exceptions.Unauthorized,
self.non_admin_client.reserve_fixed_ip,
self.ip, body)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_set_reserve_with_invalid_ip(self):
# NOTE(maurosr): since this exercises the same code snippet, we do it
# only for reserve action
@@ -68,7 +68,7 @@
self.client.reserve_fixed_ip,
"my.invalid.ip", body)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_fixed_ip_with_invalid_action(self):
body = {"invalid_action": "None"}
self.assertRaises(exceptions.BadRequest,
diff --git a/tempest/api/compute/admin/test_flavors_negative.py b/tempest/api/compute/admin/test_flavors_negative.py
index 49d49ef..b882ff4 100644
--- a/tempest/api/compute/admin/test_flavors_negative.py
+++ b/tempest/api/compute/admin/test_flavors_negative.py
@@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+import testscenarios
import uuid
from tempest.api.compute import base
@@ -20,6 +21,8 @@
from tempest import exceptions
from tempest import test
+load_tests = testscenarios.load_tests_apply_scenarios
+
class FlavorsAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
@@ -44,11 +47,6 @@
cls.swap = 1024
cls.rxtx = 2
- def flavor_clean_up(self, flavor_id):
- resp, body = self.client.delete_flavor(flavor_id)
- self.assertEqual(resp.status, 202)
- self.client.wait_for_resource_deletion(flavor_id)
-
@test.attr(type=['negative', 'gate'])
def test_get_flavor_details_for_deleted_flavor(self):
# Delete a flavor and ensure it is not listed
@@ -85,13 +83,6 @@
self.assertTrue(flag)
@test.attr(type=['negative', 'gate'])
- def test_invalid_is_public_string(self):
- # the 'is_public' parameter can be 'none/true/false' if it exists
- self.assertRaises(exceptions.BadRequest,
- self.client.list_flavors_with_detail,
- {'is_public': 'invalid'})
-
- @test.attr(type=['negative', 'gate'])
def test_create_flavor_as_user(self):
# only admin user can create a flavor
flavor_name = data_utils.rand_name(self.flavor_name_prefix)
@@ -110,231 +101,16 @@
self.user_client.delete_flavor,
self.flavor_ref_alt)
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_using_invalid_ram(self):
- # the 'ram' attribute must be positive integer
- flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = str(uuid.uuid4())
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- flavor_name, -1, self.vcpus,
- self.disk, new_flavor_id)
+class FlavorCreateNegativeTestJSON(base.BaseV2ComputeAdminTest,
+ test.NegativeAutoTest):
+ _interface = 'json'
+ _service = 'compute'
+ _schema_file = 'compute/admin/flavor_create.json'
+
+ scenarios = test.NegativeAutoTest.generate_scenario(_schema_file)
@test.attr(type=['negative', 'gate'])
- def test_create_flavor_using_invalid_vcpus(self):
- # the 'vcpu' attribute must be positive integer
- flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = str(uuid.uuid4())
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- flavor_name, self.ram, -1,
- self.disk, new_flavor_id)
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_with_name_length_less_than_1(self):
- # ensure name length >= 1
- new_flavor_id = str(uuid.uuid4())
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- '',
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=self.rxtx,
- is_public='False')
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_with_name_length_exceeds_255(self):
- # ensure name do not exceed 255 characters
- new_flavor_name = 'a' * 256
- new_flavor_id = str(uuid.uuid4())
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- new_flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=self.rxtx,
- is_public='False')
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_with_invalid_name(self):
- # the regex of flavor_name is '^[\w\.\- ]*$'
- invalid_flavor_name = data_utils.rand_name('invalid-!@#$%-')
- new_flavor_id = str(uuid.uuid4())
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- invalid_flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=self.rxtx,
- is_public='False')
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_with_invalid_flavor_id(self):
- # the regex of flavor_id is '^[\w\.\- ]*$', and it cannot contain
- # leading and/or trailing whitespace
- new_flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- invalid_flavor_id = '!@#$%'
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- new_flavor_name,
- self.ram, self.vcpus,
- self.disk,
- invalid_flavor_id,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=self.rxtx,
- is_public='False')
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_with_id_length_exceeds_255(self):
- # the length of flavor_id should not exceed 255 characters
- new_flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- invalid_flavor_id = 'a' * 256
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- new_flavor_name,
- self.ram, self.vcpus,
- self.disk,
- invalid_flavor_id,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=self.rxtx,
- is_public='False')
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_with_invalid_root_gb(self):
- # root_gb attribute should be non-negative ( >= 0) integer
- new_flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = str(uuid.uuid4())
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- new_flavor_name,
- self.ram, self.vcpus,
- -1,
- new_flavor_id,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=self.rxtx,
- is_public='False')
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_with_invalid_ephemeral_gb(self):
- # ephemeral_gb attribute should be non-negative ( >= 0) integer
- new_flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = str(uuid.uuid4())
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- new_flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- ephemeral=-1,
- swap=self.swap,
- rxtx=self.rxtx,
- is_public='False')
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_with_invalid_swap(self):
- # swap attribute should be non-negative ( >= 0) integer
- new_flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = str(uuid.uuid4())
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- new_flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- ephemeral=self.ephemeral,
- swap=-1,
- rxtx=self.rxtx,
- is_public='False')
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_with_invalid_rxtx_factor(self):
- # rxtx_factor attribute should be a positive float
- new_flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = str(uuid.uuid4())
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- new_flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=-1.5,
- is_public='False')
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_with_invalid_is_public(self):
- # is_public attribute should be boolean
- new_flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = str(uuid.uuid4())
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- new_flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=self.rxtx,
- is_public='Invalid')
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_already_exists(self):
- flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = str(uuid.uuid4())
-
- resp, flavor = self.client.create_flavor(flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=self.rxtx)
- self.assertEqual(200, resp.status)
- self.addCleanup(self.flavor_clean_up, flavor['id'])
-
- self.assertRaises(exceptions.Conflict,
- self.client.create_flavor,
- flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=self.rxtx)
-
- @test.attr(type=['negative', 'gate'])
- def test_delete_nonexistent_flavor(self):
- nonexistent_flavor_id = str(uuid.uuid4())
-
- self.assertRaises(exceptions.NotFound,
- self.client.delete_flavor,
- nonexistent_flavor_id)
-
-
-class FlavorsAdminNegativeTestXML(FlavorsAdminNegativeTestJSON):
- _interface = 'xml'
+ def test_create_flavor(self):
+ # flavor details are not returned for non-existent flavors
+ self.execute(self._schema_file)
diff --git a/tempest/api/compute/admin/test_flavors_negative_xml.py b/tempest/api/compute/admin/test_flavors_negative_xml.py
new file mode 100644
index 0000000..a06b0e6
--- /dev/null
+++ b/tempest/api/compute/admin/test_flavors_negative_xml.py
@@ -0,0 +1,268 @@
+# Copyright 2012 OpenStack Foundation
+# 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 uuid
+
+from tempest.api.compute.admin import test_flavors_negative
+from tempest.common.utils import data_utils
+from tempest import exceptions
+from tempest import test
+
+
+class FlavorsAdminNegativeTestXML(test_flavors_negative.
+ FlavorsAdminNegativeTestJSON):
+
+ """
+ Tests Flavors API Create and Delete that require admin privileges
+ """
+
+ _interface = 'xml'
+
+ def flavor_clean_up(self, flavor_id):
+ resp, body = self.client.delete_flavor(flavor_id)
+ self.assertEqual(resp.status, 202)
+ self.client.wait_for_resource_deletion(flavor_id)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_invalid_is_public_string(self):
+ # the 'is_public' parameter can be 'none/true/false' if it exists
+ self.assertRaises(exceptions.BadRequest,
+ self.client.list_flavors_with_detail,
+ {'is_public': 'invalid'})
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_flavor_using_invalid_ram(self):
+ # the 'ram' attribute must be positive integer
+ flavor_name = data_utils.rand_name(self.flavor_name_prefix)
+ new_flavor_id = str(uuid.uuid4())
+
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_flavor,
+ flavor_name, -1, self.vcpus,
+ self.disk, new_flavor_id)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_flavor_using_invalid_vcpus(self):
+ # the 'vcpu' attribute must be positive integer
+ flavor_name = data_utils.rand_name(self.flavor_name_prefix)
+ new_flavor_id = str(uuid.uuid4())
+
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_flavor,
+ flavor_name, self.ram, -1,
+ self.disk, new_flavor_id)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_flavor_with_name_length_less_than_1(self):
+ # ensure name length >= 1
+ new_flavor_id = str(uuid.uuid4())
+
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_flavor,
+ '',
+ self.ram, self.vcpus,
+ self.disk,
+ new_flavor_id,
+ ephemeral=self.ephemeral,
+ swap=self.swap,
+ rxtx=self.rxtx,
+ is_public='False')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_flavor_with_name_length_exceeds_255(self):
+ # ensure name do not exceed 255 characters
+ new_flavor_name = 'a' * 256
+ new_flavor_id = str(uuid.uuid4())
+
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_flavor,
+ new_flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ new_flavor_id,
+ ephemeral=self.ephemeral,
+ swap=self.swap,
+ rxtx=self.rxtx,
+ is_public='False')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_flavor_with_invalid_name(self):
+ # the regex of flavor_name is '^[\w\.\- ]*$'
+ invalid_flavor_name = data_utils.rand_name('invalid-!@#$%-')
+ new_flavor_id = str(uuid.uuid4())
+
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_flavor,
+ invalid_flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ new_flavor_id,
+ ephemeral=self.ephemeral,
+ swap=self.swap,
+ rxtx=self.rxtx,
+ is_public='False')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_flavor_with_invalid_flavor_id(self):
+ # the regex of flavor_id is '^[\w\.\- ]*$', and it cannot contain
+ # leading and/or trailing whitespace
+ new_flavor_name = data_utils.rand_name(self.flavor_name_prefix)
+ invalid_flavor_id = '!@#$%'
+
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_flavor,
+ new_flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ invalid_flavor_id,
+ ephemeral=self.ephemeral,
+ swap=self.swap,
+ rxtx=self.rxtx,
+ is_public='False')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_flavor_with_id_length_exceeds_255(self):
+ # the length of flavor_id should not exceed 255 characters
+ new_flavor_name = data_utils.rand_name(self.flavor_name_prefix)
+ invalid_flavor_id = 'a' * 256
+
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_flavor,
+ new_flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ invalid_flavor_id,
+ ephemeral=self.ephemeral,
+ swap=self.swap,
+ rxtx=self.rxtx,
+ is_public='False')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_flavor_with_invalid_root_gb(self):
+ # root_gb attribute should be non-negative ( >= 0) integer
+ new_flavor_name = data_utils.rand_name(self.flavor_name_prefix)
+ new_flavor_id = str(uuid.uuid4())
+
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_flavor,
+ new_flavor_name,
+ self.ram, self.vcpus,
+ -1,
+ new_flavor_id,
+ ephemeral=self.ephemeral,
+ swap=self.swap,
+ rxtx=self.rxtx,
+ is_public='False')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_flavor_with_invalid_ephemeral_gb(self):
+ # ephemeral_gb attribute should be non-negative ( >= 0) integer
+ new_flavor_name = data_utils.rand_name(self.flavor_name_prefix)
+ new_flavor_id = str(uuid.uuid4())
+
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_flavor,
+ new_flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ new_flavor_id,
+ ephemeral=-1,
+ swap=self.swap,
+ rxtx=self.rxtx,
+ is_public='False')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_flavor_with_invalid_swap(self):
+ # swap attribute should be non-negative ( >= 0) integer
+ new_flavor_name = data_utils.rand_name(self.flavor_name_prefix)
+ new_flavor_id = str(uuid.uuid4())
+
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_flavor,
+ new_flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ new_flavor_id,
+ ephemeral=self.ephemeral,
+ swap=-1,
+ rxtx=self.rxtx,
+ is_public='False')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_flavor_with_invalid_rxtx_factor(self):
+ # rxtx_factor attribute should be a positive float
+ new_flavor_name = data_utils.rand_name(self.flavor_name_prefix)
+ new_flavor_id = str(uuid.uuid4())
+
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_flavor,
+ new_flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ new_flavor_id,
+ ephemeral=self.ephemeral,
+ swap=self.swap,
+ rxtx=-1.5,
+ is_public='False')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_flavor_with_invalid_is_public(self):
+ # is_public attribute should be boolean
+ new_flavor_name = data_utils.rand_name(self.flavor_name_prefix)
+ new_flavor_id = str(uuid.uuid4())
+
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_flavor,
+ new_flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ new_flavor_id,
+ ephemeral=self.ephemeral,
+ swap=self.swap,
+ rxtx=self.rxtx,
+ is_public='Invalid')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_flavor_already_exists(self):
+ flavor_name = data_utils.rand_name(self.flavor_name_prefix)
+ new_flavor_id = str(uuid.uuid4())
+
+ resp, flavor = self.client.create_flavor(flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ new_flavor_id,
+ ephemeral=self.ephemeral,
+ swap=self.swap,
+ rxtx=self.rxtx)
+ self.assertEqual(200, resp.status)
+ self.addCleanup(self.flavor_clean_up, flavor['id'])
+
+ self.assertRaises(exceptions.Conflict,
+ self.client.create_flavor,
+ flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ new_flavor_id,
+ ephemeral=self.ephemeral,
+ swap=self.swap,
+ rxtx=self.rxtx)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_delete_nonexistent_flavor(self):
+ nonexistent_flavor_id = str(uuid.uuid4())
+
+ self.assertRaises(exceptions.NotFound,
+ self.client.delete_flavor,
+ nonexistent_flavor_id)
diff --git a/tempest/api/compute/admin/test_hosts.py b/tempest/api/compute/admin/test_hosts.py
index b4b3139..e612566 100644
--- a/tempest/api/compute/admin/test_hosts.py
+++ b/tempest/api/compute/admin/test_hosts.py
@@ -14,7 +14,7 @@
from tempest.api.compute import base
from tempest.common import tempest_fixtures as fixtures
-from tempest.test import attr
+from tempest import test
class HostsAdminTestJSON(base.BaseV2ComputeAdminTest):
@@ -28,13 +28,13 @@
super(HostsAdminTestJSON, cls).setUpClass()
cls.client = cls.os_adm.hosts_client
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_hosts(self):
resp, hosts = self.client.list_hosts()
self.assertEqual(200, resp.status)
self.assertTrue(len(hosts) >= 2, str(hosts))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_hosts_with_zone(self):
self.useFixture(fixtures.LockFixture('availability_zone'))
resp, hosts = self.client.list_hosts()
@@ -46,7 +46,7 @@
self.assertTrue(len(hosts) >= 1)
self.assertIn(host, hosts)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_hosts_with_a_blank_zone(self):
# If send the request with a blank zone, the request will be successful
# and it will return all the hosts list
@@ -55,7 +55,7 @@
self.assertNotEqual(0, len(hosts))
self.assertEqual(200, resp.status)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_hosts_with_nonexistent_zone(self):
# If send the request with a nonexistent zone, the request will be
# successful and no hosts will be retured
@@ -64,7 +64,7 @@
self.assertEqual(0, len(hosts))
self.assertEqual(200, resp.status)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_show_host_detail(self):
resp, hosts = self.client.list_hosts()
self.assertEqual(200, resp.status)
diff --git a/tempest/api/compute/admin/test_hypervisor.py b/tempest/api/compute/admin/test_hypervisor.py
index 4e1b289..48f9ffb 100644
--- a/tempest/api/compute/admin/test_hypervisor.py
+++ b/tempest/api/compute/admin/test_hypervisor.py
@@ -14,7 +14,7 @@
# under the License.
from tempest.api.compute import base
-from tempest.test import attr
+from tempest import test
class HypervisorAdminTestJSON(base.BaseV2ComputeAdminTest):
@@ -37,20 +37,20 @@
def assertHypervisors(self, hypers):
self.assertTrue(len(hypers) > 0, "No hypervisors found: %s" % hypers)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_hypervisor_list(self):
# List of hypervisor and available hypervisors hostname
hypers = self._list_hypervisors()
self.assertHypervisors(hypers)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_hypervisor_list_details(self):
# Display the details of the all hypervisor
resp, hypers = self.client.get_hypervisor_list_details()
self.assertEqual(200, resp.status)
self.assertHypervisors(hypers)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_hypervisor_show_details(self):
# Display the details of the specified hypervisor
hypers = self._list_hypervisors()
@@ -63,7 +63,7 @@
self.assertEqual(details['hypervisor_hostname'],
hypers[0]['hypervisor_hostname'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_hypervisor_show_servers(self):
# Show instances about the specific hypervisors
hypers = self._list_hypervisors()
@@ -74,14 +74,14 @@
self.assertEqual(200, resp.status)
self.assertTrue(len(hypervisors) > 0)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_hypervisor_stats(self):
# Verify the stats of the all hypervisor
resp, stats = self.client.get_hypervisor_stats()
self.assertEqual(200, resp.status)
self.assertTrue(len(stats) > 0)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_hypervisor_uptime(self):
# Verify that GET shows the specified hypervisor uptime
hypers = self._list_hypervisors()
@@ -101,7 +101,7 @@
has_valid_uptime,
"None of the hypervisors had a valid uptime: %s" % hypers)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_search_hypervisor(self):
hypers = self._list_hypervisors()
self.assertHypervisors(hypers)
diff --git a/tempest/api/compute/admin/test_hypervisor_negative.py b/tempest/api/compute/admin/test_hypervisor_negative.py
index be0153b..4ba8d30 100644
--- a/tempest/api/compute/admin/test_hypervisor_negative.py
+++ b/tempest/api/compute/admin/test_hypervisor_negative.py
@@ -18,7 +18,7 @@
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class HypervisorAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
@@ -39,7 +39,7 @@
self.assertEqual(200, resp.status)
return hypers
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_show_nonexistent_hypervisor(self):
nonexistent_hypervisor_id = str(uuid.uuid4())
@@ -48,7 +48,7 @@
self.client.get_hypervisor_show_details,
nonexistent_hypervisor_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_show_hypervisor_with_non_admin_user(self):
hypers = self._list_hypervisors()
self.assertTrue(len(hypers) > 0)
@@ -58,7 +58,7 @@
self.non_adm_client.get_hypervisor_show_details,
hypers[0]['id'])
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_show_servers_with_non_admin_user(self):
hypers = self._list_hypervisors()
self.assertTrue(len(hypers) > 0)
@@ -68,7 +68,7 @@
self.non_adm_client.get_hypervisor_servers,
hypers[0]['id'])
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_show_servers_with_nonexistent_hypervisor(self):
nonexistent_hypervisor_id = str(uuid.uuid4())
@@ -77,13 +77,13 @@
self.client.get_hypervisor_servers,
nonexistent_hypervisor_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_get_hypervisor_stats_with_non_admin_user(self):
self.assertRaises(
exceptions.Unauthorized,
self.non_adm_client.get_hypervisor_stats)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_get_nonexistent_hypervisor_uptime(self):
nonexistent_hypervisor_id = str(uuid.uuid4())
@@ -92,7 +92,7 @@
self.client.get_hypervisor_uptime,
nonexistent_hypervisor_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_get_hypervisor_uptime_with_non_admin_user(self):
hypers = self._list_hypervisors()
self.assertTrue(len(hypers) > 0)
@@ -102,21 +102,21 @@
self.non_adm_client.get_hypervisor_uptime,
hypers[0]['id'])
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_get_hypervisor_list_with_non_admin_user(self):
# List of hypervisor and available services with non admin user
self.assertRaises(
exceptions.Unauthorized,
self.non_adm_client.get_hypervisor_list)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_get_hypervisor_list_details_with_non_admin_user(self):
# List of hypervisor details and available services with non admin user
self.assertRaises(
exceptions.Unauthorized,
self.non_adm_client.get_hypervisor_list_details)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_search_nonexistent_hypervisor(self):
nonexistent_hypervisor_name = data_utils.rand_name('test_hypervisor')
@@ -125,7 +125,7 @@
self.client.search_hypervisor,
nonexistent_hypervisor_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_search_hypervisor_with_non_admin_user(self):
hypers = self._list_hypervisors()
self.assertTrue(len(hypers) > 0)
diff --git a/tempest/api/compute/admin/test_instance_usage_audit_log.py b/tempest/api/compute/admin/test_instance_usage_audit_log.py
index 13f504f..32c8656 100644
--- a/tempest/api/compute/admin/test_instance_usage_audit_log.py
+++ b/tempest/api/compute/admin/test_instance_usage_audit_log.py
@@ -16,7 +16,7 @@
import datetime
from tempest.api.compute import base
-from tempest.test import attr
+from tempest import test
import urllib
@@ -27,7 +27,7 @@
super(InstanceUsageAuditLogTestJSON, cls).setUpClass()
cls.adm_client = cls.os_adm.instance_usages_audit_log_client
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_instance_usage_audit_logs(self):
# list instance usage audit logs
resp, body = self.adm_client.list_instance_usage_audit_logs()
@@ -40,7 +40,7 @@
for item in expected_items:
self.assertIn(item, body)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_instance_usage_audit_log(self):
# Get instance usage audit log before specified time
now = datetime.datetime.now()
diff --git a/tempest/api/compute/admin/test_instance_usage_audit_log_negative.py b/tempest/api/compute/admin/test_instance_usage_audit_log_negative.py
index e128d0c..fe4a184 100644
--- a/tempest/api/compute/admin/test_instance_usage_audit_log_negative.py
+++ b/tempest/api/compute/admin/test_instance_usage_audit_log_negative.py
@@ -17,7 +17,7 @@
from tempest.api.compute import base
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
import urllib
@@ -28,7 +28,7 @@
super(InstanceUsageAuditLogNegativeTestJSON, cls).setUpClass()
cls.adm_client = cls.os_adm.instance_usages_audit_log_client
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_instance_usage_audit_logs_with_nonadmin_user(self):
# the instance_usage_audit_logs API just can be accessed by admin user
self.assertRaises(exceptions.Unauthorized,
@@ -40,7 +40,7 @@
get_instance_usage_audit_log,
urllib.quote(now.strftime("%Y-%m-%d %H:%M:%S")))
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_get_instance_usage_audit_logs_with_invalid_time(self):
self.assertRaises(exceptions.BadRequest,
self.adm_client.get_instance_usage_audit_log,
diff --git a/tempest/api/compute/admin/test_security_groups.py b/tempest/api/compute/admin/test_security_groups.py
index 69ba2c2..f728d68 100644
--- a/tempest/api/compute/admin/test_security_groups.py
+++ b/tempest/api/compute/admin/test_security_groups.py
@@ -18,7 +18,7 @@
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest import config
-from tempest.test import attr
+from tempest import test
CONF = config.CONF
@@ -42,7 +42,7 @@
@testtools.skipIf(CONF.service_available.neutron,
"Skipped because neutron do not support all_tenants"
"search filter.")
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_security_groups_list_all_tenants_filter(self):
# Admin can list security groups of all tenants
# List of all security groups created
diff --git a/tempest/api/compute/admin/test_servers_negative.py b/tempest/api/compute/admin/test_servers_negative.py
index dff4aaa..797b780 100644
--- a/tempest/api/compute/admin/test_servers_negative.py
+++ b/tempest/api/compute/admin/test_servers_negative.py
@@ -17,7 +17,7 @@
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class ServersAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
@@ -52,7 +52,7 @@
flavor_id = data_utils.rand_int_id(start=1000)
return flavor_id
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_resize_server_using_overlimit_ram(self):
flavor_name = data_utils.rand_name("flavor-")
flavor_id = self._get_unused_flavor_id()
@@ -70,7 +70,7 @@
self.servers[0]['id'],
flavor_ref['id'])
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_resize_server_using_overlimit_vcpus(self):
flavor_name = data_utils.rand_name("flavor-")
flavor_id = self._get_unused_flavor_id()
@@ -88,38 +88,38 @@
self.servers[0]['id'],
flavor_ref['id'])
- @attr(type=['negative', 'gate'])
+ @test.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'])
+ @test.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'])
+ @test.attr(type=['negative', 'gate'])
def test_reset_state_server_nonexistent_server(self):
self.assertRaises(exceptions.NotFound,
self.client.reset_state, '999')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_get_server_diagnostics_by_non_admin(self):
# Non-admin user can not view server diagnostics according to policy
self.assertRaises(exceptions.Unauthorized,
self.non_adm_client.get_server_diagnostics,
self.s1_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_migrate_non_existent_server(self):
# migrate a non existent server
self.assertRaises(exceptions.NotFound,
self.client.migrate_server,
str(uuid.uuid4()))
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_migrate_server_invalid_state(self):
# create server.
resp, server = self.create_test_server(wait_until='ACTIVE')
diff --git a/tempest/api/compute/admin/test_services.py b/tempest/api/compute/admin/test_services.py
index 3e45d65..9dd429b 100644
--- a/tempest/api/compute/admin/test_services.py
+++ b/tempest/api/compute/admin/test_services.py
@@ -14,8 +14,9 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest.api.compute.api_schema import services as schema
from tempest.api.compute import base
-from tempest.test import attr
+from tempest import test
class ServicesAdminTestJSON(base.BaseV2ComputeAdminTest):
@@ -29,30 +30,33 @@
super(ServicesAdminTestJSON, cls).setUpClass()
cls.client = cls.os_adm.services_client
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_services(self):
resp, services = self.client.list_services()
- self.assertEqual(200, resp.status)
+ self.validate_response(schema.list_services, resp, services)
self.assertNotEqual(0, len(services))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_service_by_service_binary_name(self):
binary_name = 'nova-compute'
params = {'binary': binary_name}
resp, services = self.client.list_services(params)
- self.assertEqual(200, resp.status)
+ self.validate_response(schema.list_services, resp, services)
self.assertNotEqual(0, len(services))
for service in services:
self.assertEqual(binary_name, service['binary'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_service_by_host_name(self):
resp, services = self.client.list_services()
+ self.validate_response(schema.list_services, resp, services)
host_name = services[0]['host']
services_on_host = [service for service in services if
service['host'] == host_name]
params = {'host': host_name}
+
resp, services = self.client.list_services(params)
+ self.validate_response(schema.list_services, resp, services)
# we could have a periodic job checkin between the 2 service
# lookups, so only compare binary lists.
@@ -63,14 +67,16 @@
# on order.
self.assertEqual(sorted(s1), sorted(s2))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_service_by_service_and_host_name(self):
resp, services = self.client.list_services()
+ self.validate_response(schema.list_services, resp, services)
host_name = services[0]['host']
binary_name = services[0]['binary']
params = {'host': host_name, 'binary': binary_name}
+
resp, services = self.client.list_services(params)
- self.assertEqual(200, resp.status)
+ self.validate_response(schema.list_services, resp, services)
self.assertEqual(1, len(services))
self.assertEqual(host_name, services[0]['host'])
self.assertEqual(binary_name, services[0]['binary'])
diff --git a/tempest/api/compute/admin/test_services_negative.py b/tempest/api/compute/admin/test_services_negative.py
index a4bf754..c78d70d 100644
--- a/tempest/api/compute/admin/test_services_negative.py
+++ b/tempest/api/compute/admin/test_services_negative.py
@@ -14,7 +14,7 @@
from tempest.api.compute import base
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class ServicesAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
@@ -29,12 +29,12 @@
cls.client = cls.os_adm.services_client
cls.non_admin_client = cls.services_client
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_list_services_with_non_admin_user(self):
self.assertRaises(exceptions.Unauthorized,
self.non_admin_client.list_services)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_get_service_by_invalid_params(self):
# return all services if send the request with invalid parameter
resp, services = self.client.list_services()
@@ -43,7 +43,7 @@
self.assertEqual(200, resp.status)
self.assertEqual(len(services), len(services_xxx))
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_get_service_by_invalid_service_and_valid_host(self):
resp, services = self.client.list_services()
host_name = services[0]['host']
@@ -52,7 +52,7 @@
self.assertEqual(200, resp.status)
self.assertEqual(0, len(services))
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_get_service_with_valid_service_and_invalid_host(self):
resp, services = self.client.list_services()
binary_name = services[0]['binary']
diff --git a/tempest/api/compute/admin/test_simple_tenant_usage.py b/tempest/api/compute/admin/test_simple_tenant_usage.py
index 2f1391b..cc8641f 100644
--- a/tempest/api/compute/admin/test_simple_tenant_usage.py
+++ b/tempest/api/compute/admin/test_simple_tenant_usage.py
@@ -16,7 +16,7 @@
import datetime
from tempest.api.compute import base
-from tempest.test import attr
+from tempest import test
import time
@@ -46,7 +46,7 @@
# Returns formatted datetime
return at.strftime('%Y-%m-%dT%H:%M:%S.%f')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_usage_all_tenants(self):
# Get usage for all tenants
params = {'start': self.start,
@@ -56,7 +56,7 @@
self.assertEqual(200, resp.status)
self.assertEqual(len(tenant_usage), 8)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_usage_tenant(self):
# Get usage for a specific tenant
params = {'start': self.start,
@@ -67,7 +67,7 @@
self.assertEqual(200, resp.status)
self.assertEqual(len(tenant_usage), 8)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_usage_tenant_with_non_admin_user(self):
# Get usage for a specific tenant with non admin user
params = {'start': self.start,
diff --git a/tempest/api/compute/admin/test_simple_tenant_usage_negative.py b/tempest/api/compute/admin/test_simple_tenant_usage_negative.py
index 4ad3e1a..a080f2e 100644
--- a/tempest/api/compute/admin/test_simple_tenant_usage_negative.py
+++ b/tempest/api/compute/admin/test_simple_tenant_usage_negative.py
@@ -17,7 +17,7 @@
from tempest.api.compute import base
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class TenantUsagesNegativeTestJSON(base.BaseV2ComputeAdminTest):
@@ -37,7 +37,7 @@
# Returns formatted datetime
return at.strftime('%Y-%m-%dT%H:%M:%S.%f')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_get_usage_tenant_with_empty_tenant_id(self):
# Get usage for a specific tenant empty
params = {'start': self.start,
@@ -46,7 +46,7 @@
self.adm_client.get_tenant_usage,
'', params)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_get_usage_tenant_with_invalid_date(self):
# Get usage for tenant with invalid date
params = {'start': self.end,
@@ -58,7 +58,7 @@
self.adm_client.get_tenant_usage,
tenant_id, params)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_list_usage_all_tenants_with_non_admin_user(self):
# Get usage for all tenants with non admin user
params = {'start': self.start,
diff --git a/tempest/api/compute/api_schema/__init__.py b/tempest/api/compute/api_schema/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/api/compute/api_schema/__init__.py
diff --git a/tempest/api/compute/api_schema/services.py b/tempest/api/compute/api_schema/services.py
new file mode 100644
index 0000000..ef5868c
--- /dev/null
+++ b/tempest/api/compute/api_schema/services.py
@@ -0,0 +1,38 @@
+# Copyright 2014 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.
+
+list_services = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'array',
+ 'items': {
+ 'type': 'object',
+ 'properties': {
+ # NOTE: Now the type of 'id' is integer, but here allows
+ # 'string' also because we will be able to change it to
+ # 'uuid' in the future.
+ 'id': {'type': ['integer', 'string']},
+ 'zone': {'type': 'string'},
+ 'host': {'type': 'string'},
+ 'state': {'type': 'string'},
+ 'binary': {'type': 'string'},
+ 'status': {'type': 'string'},
+ 'updated_at': {'type': 'string'},
+ 'disabled_reason': {'type': ['string', 'null']},
+ },
+ 'required': ['id', 'zone', 'host', 'state', 'binary', 'status',
+ 'updated_at', 'disabled_reason'],
+ },
+ }
+}
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index 28d50c9..e9b9efa 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -15,6 +15,8 @@
import time
+import jsonschema
+
from tempest import clients
from tempest.common.utils import data_utils
from tempest import config
@@ -176,6 +178,25 @@
return resp, body
+ @classmethod
+ def validate_response(cls, schema, resp, body):
+ response_code = schema['status_code']
+ if resp.status not in response_code:
+ msg = ("The status code(%s) is different than the expected "
+ "one(%s)") % (resp.status, response_code)
+ raise exceptions.InvalidHttpSuccessCode(msg)
+ response_schema = schema.get('response_body')
+ if response_schema:
+ try:
+ jsonschema.validate(body, response_schema)
+ except jsonschema.ValidationError as ex:
+ msg = ("HTTP response body is invalid (%s)") % ex
+ raise exceptions.InvalidHTTPResponseBody(msg)
+ else:
+ if body:
+ msg = ("HTTP response body should not exist (%s)") % body
+ raise exceptions.InvalidHTTPResponseBody(msg)
+
def wait_for(self, condition):
"""Repeatedly calls condition() until a timeout."""
start_time = int(time.time())
@@ -315,14 +336,14 @@
"%s will be removed shortly" % cls.__name__)
raise cls.skipException(skip_msg)
- cls.set_network_resources()
- super(BaseV3ComputeTest, cls).setUpClass()
if not CONF.compute_feature_enabled.api_v3:
- cls.tearDownClass()
skip_msg = ("%s skipped as nova v3 api is not available" %
cls.__name__)
raise cls.skipException(skip_msg)
+ cls.set_network_resources()
+ super(BaseV3ComputeTest, cls).setUpClass()
+
cls.servers_client = cls.os.servers_v3_client
cls.images_client = cls.os.image_client
cls.flavors_client = cls.os.flavors_v3_client
diff --git a/tempest/api/compute/certificates/test_certificates.py b/tempest/api/compute/certificates/test_certificates.py
index 01fdc7c..5299d13 100644
--- a/tempest/api/compute/certificates/test_certificates.py
+++ b/tempest/api/compute/certificates/test_certificates.py
@@ -14,12 +14,12 @@
# under the License.
from tempest.api.compute import base
-from tempest.test import attr
+from tempest import test
class CertificatesTestJSON(base.BaseV2ComputeTest):
- @attr(type='gate')
+ @test.attr(type='gate')
def test_create_and_get_root_certificate(self):
# create certificates
resp, create_body = self.certificates_client.create_certificate()
diff --git a/tempest/api/compute/flavors/test_flavors.py b/tempest/api/compute/flavors/test_flavors.py
index 98a8e29..6e202f6 100644
--- a/tempest/api/compute/flavors/test_flavors.py
+++ b/tempest/api/compute/flavors/test_flavors.py
@@ -14,7 +14,7 @@
# under the License.
from tempest.api.compute import base
-from tempest.test import attr
+from tempest import test
class FlavorsTestJSON(base.BaseV2ComputeTest):
@@ -24,7 +24,7 @@
super(FlavorsTestJSON, cls).setUpClass()
cls.client = cls.flavors_client
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_flavors(self):
# List of all flavors should contain the expected flavor
resp, flavors = self.client.list_flavors()
@@ -33,34 +33,34 @@
'name': flavor['name']}
self.assertIn(flavor_min_detail, flavors)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_flavors_with_detail(self):
# Detailed list of all flavors should contain the expected flavor
resp, flavors = self.client.list_flavors_with_detail()
resp, flavor = self.client.get_flavor_details(self.flavor_ref)
self.assertIn(flavor, flavors)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_get_flavor(self):
# The expected flavor details should be returned
resp, flavor = self.client.get_flavor_details(self.flavor_ref)
self.assertEqual(self.flavor_ref, flavor['id'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_flavors_limit_results(self):
# Only the expected number of flavors should be returned
params = {'limit': 1}
resp, flavors = self.client.list_flavors(params)
self.assertEqual(1, len(flavors))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_flavors_detailed_limit_results(self):
# Only the expected number of flavors (detailed) should be returned
params = {'limit': 1}
resp, flavors = self.client.list_flavors_with_detail(params)
self.assertEqual(1, len(flavors))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_flavors_using_marker(self):
# The list of flavors should start from the provided marker
resp, flavors = self.client.list_flavors()
@@ -71,7 +71,7 @@
self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]),
'The list of flavors did not start after the marker.')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_flavors_detailed_using_marker(self):
# The list of flavors should start from the provided marker
resp, flavors = self.client.list_flavors_with_detail()
@@ -82,7 +82,7 @@
self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]),
'The list of flavors did not start after the marker.')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_flavors_detailed_filter_by_min_disk(self):
# The detailed list of flavors should be filtered by disk space
resp, flavors = self.client.list_flavors_with_detail()
@@ -93,7 +93,7 @@
resp, flavors = self.client.list_flavors_with_detail(params)
self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_flavors_detailed_filter_by_min_ram(self):
# The detailed list of flavors should be filtered by RAM
resp, flavors = self.client.list_flavors_with_detail()
@@ -104,7 +104,7 @@
resp, flavors = self.client.list_flavors_with_detail(params)
self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_flavors_filter_by_min_disk(self):
# The list of flavors should be filtered by disk space
resp, flavors = self.client.list_flavors_with_detail()
@@ -115,7 +115,7 @@
resp, flavors = self.client.list_flavors(params)
self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_flavors_filter_by_min_ram(self):
# The list of flavors should be filtered by RAM
resp, flavors = self.client.list_flavors_with_detail()
diff --git a/tempest/api/compute/flavors/test_flavors_negative_xml.py b/tempest/api/compute/flavors/test_flavors_negative_xml.py
index c93c7c9..bf73c0e 100644
--- a/tempest/api/compute/flavors/test_flavors_negative_xml.py
+++ b/tempest/api/compute/flavors/test_flavors_negative_xml.py
@@ -17,7 +17,7 @@
from tempest.api.compute import base
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class FlavorsNegativeTestXML(base.BaseV2ComputeTest):
@@ -28,19 +28,19 @@
super(FlavorsNegativeTestXML, cls).setUpClass()
cls.client = cls.flavors_client
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_invalid_minRam_filter(self):
self.assertRaises(exceptions.BadRequest,
self.client.list_flavors_with_detail,
{'minRam': 'invalid'})
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_invalid_minDisk_filter(self):
self.assertRaises(exceptions.BadRequest,
self.client.list_flavors_with_detail,
{'minDisk': 'invalid'})
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_non_existent_flavor_id(self):
# flavor details are not returned for non-existent flavors
nonexistent_flavor_id = str(uuid.uuid4())
diff --git a/tempest/api/compute/floating_ips/test_floating_ips_actions_negative.py b/tempest/api/compute/floating_ips/test_floating_ips_actions_negative.py
index 0c3663e..9fc43e2 100644
--- a/tempest/api/compute/floating_ips/test_floating_ips_actions_negative.py
+++ b/tempest/api/compute/floating_ips/test_floating_ips_actions_negative.py
@@ -19,7 +19,7 @@
from tempest.common.utils import data_utils
from tempest import config
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
CONF = config.CONF
@@ -47,7 +47,7 @@
if cls.non_exist_id not in cls.floating_ip_ids:
break
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_allocate_floating_ip_from_nonexistent_pool(self):
# Negative test:Allocation of a new floating IP from a nonexistent_pool
# to a project should fail
@@ -55,7 +55,7 @@
self.client.create_floating_ip,
"non_exist_pool")
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_nonexistent_floating_ip(self):
# Negative test:Deletion of a nonexistent floating IP
# from project should fail
@@ -64,7 +64,7 @@
self.assertRaises(exceptions.NotFound, self.client.delete_floating_ip,
self.non_exist_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_associate_nonexistent_floating_ip(self):
# Negative test:Association of a non existent floating IP
# to specific server should fail
@@ -73,7 +73,7 @@
self.client.associate_floating_ip_to_server,
"0.0.0.0", self.server_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_dissociate_nonexistent_floating_ip(self):
# Negative test:Dissociation of a non existent floating IP should fail
# Dissociating non existent floating IP
@@ -81,7 +81,7 @@
self.client.disassociate_floating_ip_from_server,
"0.0.0.0", self.server_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_associate_ip_to_server_without_passing_floating_ip(self):
# Negative test:Association of empty floating IP to specific server
# should raise NotFound exception
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 d69e33c..94dcf61 100644
--- a/tempest/api/compute/floating_ips/test_list_floating_ips.py
+++ b/tempest/api/compute/floating_ips/test_list_floating_ips.py
@@ -14,7 +14,7 @@
# under the License.
from tempest.api.compute import base
-from tempest.test import attr
+from tempest import test
class FloatingIPDetailsTestJSON(base.BaseV2ComputeTest):
@@ -36,7 +36,7 @@
cls.client.delete_floating_ip(cls.floating_ip_id[i])
super(FloatingIPDetailsTestJSON, cls).tearDownClass()
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_floating_ips(self):
# Positive test:Should return the list of floating IPs
resp, body = self.client.list_floating_ips()
@@ -47,7 +47,7 @@
for i in range(3):
self.assertIn(self.floating_ip[i], floating_ips)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_floating_ip_details(self):
# Positive test:Should be able to GET the details of floatingIP
# Creating a floating IP for which details are to be checked
@@ -69,7 +69,7 @@
body['fixed_ip'])
self.assertEqual(floating_ip_id, body['id'])
- @attr(type='gate')
+ @test.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()
diff --git a/tempest/api/compute/floating_ips/test_list_floating_ips_negative.py b/tempest/api/compute/floating_ips/test_list_floating_ips_negative.py
index 5701be8..8cb2f08 100644
--- a/tempest/api/compute/floating_ips/test_list_floating_ips_negative.py
+++ b/tempest/api/compute/floating_ips/test_list_floating_ips_negative.py
@@ -19,7 +19,7 @@
from tempest.common.utils import data_utils
from tempest import config
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
CONF = config.CONF
@@ -31,7 +31,7 @@
super(FloatingIPDetailsNegativeTestJSON, cls).setUpClass()
cls.client = cls.floating_ips_client
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_get_nonexistent_floating_ip_details(self):
# Negative test:Should not be able to GET the details
# of non-existent floating IP
diff --git a/tempest/api/compute/images/test_image_metadata.py b/tempest/api/compute/images/test_image_metadata.py
index ad211ce..195a018 100644
--- a/tempest/api/compute/images/test_image_metadata.py
+++ b/tempest/api/compute/images/test_image_metadata.py
@@ -16,7 +16,7 @@
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest import config
-from tempest.test import attr
+from tempest import test
CONF = config.CONF
@@ -54,14 +54,14 @@
resp, _ = self.client.set_image_metadata(self.image_id, meta)
self.assertEqual(resp.status, 200)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_image_metadata(self):
# All metadata key/value pairs for an image should be returned
resp, resp_metadata = self.client.list_image_metadata(self.image_id)
expected = {'key1': 'value1', 'key2': 'value2'}
self.assertEqual(expected, resp_metadata)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_set_image_metadata(self):
# The metadata for the image should match the new values
req_metadata = {'meta2': 'value2', 'meta3': 'value3'}
@@ -71,7 +71,7 @@
resp, resp_metadata = self.client.list_image_metadata(self.image_id)
self.assertEqual(req_metadata, resp_metadata)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_update_image_metadata(self):
# The metadata for the image should match the updated values
req_metadata = {'key1': 'alt1', 'key3': 'value3'}
@@ -82,14 +82,14 @@
expected = {'key1': 'alt1', 'key2': 'value2', 'key3': 'value3'}
self.assertEqual(expected, resp_metadata)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_image_metadata_item(self):
# The value for a specific metadata key should be returned
resp, meta = self.client.get_image_metadata_item(self.image_id,
'key2')
self.assertEqual('value2', meta['key2'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_set_image_metadata_item(self):
# The value provided for the given meta item should be set for
# the image
@@ -100,7 +100,7 @@
expected = {'key1': 'alt', 'key2': 'value2'}
self.assertEqual(expected, resp_metadata)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_delete_image_metadata_item(self):
# The metadata value/key pair should be deleted from the image
resp, body = self.client.delete_image_metadata_item(self.image_id,
diff --git a/tempest/api/compute/images/test_image_metadata_negative.py b/tempest/api/compute/images/test_image_metadata_negative.py
index 7776c57..15bb66a 100644
--- a/tempest/api/compute/images/test_image_metadata_negative.py
+++ b/tempest/api/compute/images/test_image_metadata_negative.py
@@ -16,7 +16,7 @@
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class ImagesMetadataTestJSON(base.BaseV2ComputeTest):
@@ -26,14 +26,14 @@
super(ImagesMetadataTestJSON, cls).setUpClass()
cls.client = cls.images_client
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_list_nonexistent_image_metadata(self):
# Negative test: List on nonexistent image
# metadata should not happen
self.assertRaises(exceptions.NotFound, self.client.list_image_metadata,
data_utils.rand_uuid())
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_update_nonexistent_image_metadata(self):
# Negative test:An update should not happen for a non-existent image
meta = {'key1': 'alt1', 'key2': 'alt2'}
@@ -41,21 +41,21 @@
self.client.update_image_metadata,
data_utils.rand_uuid(), meta)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_get_nonexistent_image_metadata_item(self):
# Negative test: Get on non-existent image should not happen
self.assertRaises(exceptions.NotFound,
self.client.get_image_metadata_item,
data_utils.rand_uuid(), 'key2')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_set_nonexistent_image_metadata(self):
# Negative test: Metadata should not be set to a non-existent image
meta = {'key1': 'alt1', 'key2': 'alt2'}
self.assertRaises(exceptions.NotFound, self.client.set_image_metadata,
data_utils.rand_uuid(), meta)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_set_nonexistent_image_metadata_item(self):
# Negative test: Metadata item should not be set to a
# nonexistent image
@@ -65,7 +65,7 @@
data_utils.rand_uuid(), 'key1',
meta)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_nonexistent_image_metadata_item(self):
# Negative test: Shouldn't be able to delete metadata
# item from non-existent image
diff --git a/tempest/api/compute/images/test_images.py b/tempest/api/compute/images/test_images.py
index ed316ef..5de2436 100644
--- a/tempest/api/compute/images/test_images.py
+++ b/tempest/api/compute/images/test_images.py
@@ -32,22 +32,6 @@
cls.client = cls.images_client
cls.servers_client = cls.servers_client
- cls.image_ids = []
-
- def tearDown(self):
- """Terminate test instances created after a test is executed."""
- for image_id in self.image_ids:
- self.client.delete_image(image_id)
- self.image_ids.remove(image_id)
- super(ImagesTestJSON, self).tearDown()
-
- def __create_image__(self, server_id, name, meta=None):
- resp, body = self.client.create_image(server_id, name, meta)
- image_id = data_utils.parse_image_id(resp['location'])
- self.client.wait_for_image_status(image_id, 'ACTIVE')
- self.image_ids.append(image_id)
- return resp, body
-
@test.attr(type=['negative', 'gate'])
def test_create_image_from_deleted_server(self):
# An image should not be created if the server instance is removed
@@ -60,8 +44,8 @@
name = data_utils.rand_name('image')
meta = {'image_type': 'test'}
self.assertRaises(exceptions.NotFound,
- self.__create_image__,
- server['id'], name, meta)
+ self.create_image_from_server,
+ server['id'], name=name, meta=meta)
@test.attr(type=['negative', 'gate'])
def test_create_image_from_invalid_server(self):
@@ -71,8 +55,9 @@
meta = {'image_type': 'test'}
resp = {}
resp['status'] = None
- self.assertRaises(exceptions.NotFound, self.__create_image__,
- '!@#$%^&*()', name, meta)
+ self.assertRaises(exceptions.NotFound,
+ self.create_image_from_server,
+ '!@#$%^&*()', name=name, meta=meta)
@test.attr(type=['negative', 'gate'])
def test_create_image_from_stopped_server(self):
diff --git a/tempest/api/compute/images/test_list_images.py b/tempest/api/compute/images/test_list_images.py
index 4074a7a..eba331f 100644
--- a/tempest/api/compute/images/test_list_images.py
+++ b/tempest/api/compute/images/test_list_images.py
@@ -15,7 +15,7 @@
from tempest.api.compute import base
from tempest import config
-from tempest.test import attr
+from tempest import test
CONF = config.CONF
@@ -30,20 +30,20 @@
raise cls.skipException(skip_msg)
cls.client = cls.images_client
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_get_image(self):
# Returns the correct details for a single image
resp, image = self.client.get_image(self.image_ref)
self.assertEqual(self.image_ref, image['id'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_images(self):
# The list of all images should contain the image
resp, images = self.client.list_images()
found = any([i for i in images if i['id'] == self.image_ref])
self.assertTrue(found)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_images_with_detail(self):
# Detailed list of all images should contain the expected images
resp, images = self.client.list_images_with_detail()
diff --git a/tempest/api/compute/security_groups/test_security_groups.py b/tempest/api/compute/security_groups/test_security_groups.py
index c063a4e..538ebc6 100644
--- a/tempest/api/compute/security_groups/test_security_groups.py
+++ b/tempest/api/compute/security_groups/test_security_groups.py
@@ -26,7 +26,7 @@
super(SecurityGroupsTestJSON, cls).setUpClass()
cls.client = cls.security_groups_client
- @test.attr(type='gate')
+ @test.attr(type='smoke')
def test_security_groups_create_list_delete(self):
# Positive test:Should return the list of Security Groups
# Create 3 Security Groups
@@ -58,7 +58,7 @@
"list" % ', '.join(m_group['name']
for m_group in deleted_sgs))
- @test.attr(type='gate')
+ @test.attr(type='smoke')
def test_security_group_create_get_delete(self):
# Security Group should be created, fetched and deleted
s_name = data_utils.rand_name('securitygroup-')
@@ -76,7 +76,7 @@
"The fetched Security Group is different "
"from the created Group")
- @test.attr(type='gate')
+ @test.attr(type='smoke')
def test_server_security_groups(self):
# Checks that security groups may be added and linked to a server
# and not deleted if the server is active.
@@ -122,7 +122,7 @@
self.client.delete_security_group(sg2['id'])
self.assertEqual(202, resp.status)
- @test.attr(type='gate')
+ @test.attr(type='smoke')
def test_update_security_groups(self):
# Update security group name and description
# Create a security group
diff --git a/tempest/api/compute/security_groups/test_security_groups_negative.py b/tempest/api/compute/security_groups/test_security_groups_negative.py
index 735c7ce..aa2d32e 100644
--- a/tempest/api/compute/security_groups/test_security_groups_negative.py
+++ b/tempest/api/compute/security_groups/test_security_groups_negative.py
@@ -56,7 +56,7 @@
@test.skip_because(bug="1161411",
condition=CONF.service_available.neutron)
- @test.attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'smoke'])
def test_security_group_create_with_invalid_group_name(self):
# Negative test: Security Group should not be created with group name
# as an empty string/with white spaces/chars more than 255
@@ -76,7 +76,7 @@
@test.skip_because(bug="1161411",
condition=CONF.service_available.neutron)
- @test.attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'smoke'])
def test_security_group_create_with_invalid_group_description(self):
# Negative test:Security Group should not be created with description
# as an empty string/with white spaces/chars more than 255
@@ -95,7 +95,7 @@
@testtools.skipIf(CONF.service_available.neutron,
"Neutron allows duplicate names for security groups")
- @test.attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'smoke'])
def test_security_group_create_with_duplicate_name(self):
# Negative test:Security Group with duplicate name should not
# be created
@@ -109,7 +109,7 @@
self.client.create_security_group, s_name,
s_description)
- @test.attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'smoke'])
def test_delete_the_default_security_group(self):
# Negative test:Deletion of the "default" Security Group should Fail
default_security_group_id = None
@@ -130,7 +130,7 @@
self.assertRaises(exceptions.NotFound,
self.client.delete_security_group, non_exist_id)
- @test.attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'smoke'])
def test_delete_security_group_without_passing_id(self):
# Negative test:Deletion of a Security Group with out passing ID
# should Fail
@@ -139,7 +139,7 @@
@testtools.skipIf(CONF.service_available.neutron,
"Neutron not check the security_group_id")
- @test.attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'smoke'])
def test_update_security_group_with_invalid_sg_id(self):
# Update security_group with invalid sg_id should fail
s_name = data_utils.rand_name('sg-')
@@ -152,7 +152,7 @@
@testtools.skipIf(CONF.service_available.neutron,
"Neutron not check the security_group_name")
- @test.attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'smoke'])
def test_update_security_group_with_invalid_sg_name(self):
# Update security_group with invalid sg_name should fail
resp, securitygroup = self.create_security_group()
@@ -167,7 +167,7 @@
@testtools.skipIf(CONF.service_available.neutron,
"Neutron not check the security_group_description")
- @test.attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'smoke'])
def test_update_security_group_with_invalid_sg_des(self):
# Update security_group with invalid sg_des should fail
resp, securitygroup = self.create_security_group()
@@ -180,7 +180,7 @@
self.client.update_security_group,
securitygroup_id, description=s_new_des)
- @test.attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'smoke'])
def test_update_non_existent_security_group(self):
# Update a non-existent Security Group should Fail
non_exist_id = self._generate_a_non_existent_security_group_id()
diff --git a/tempest/api/compute/servers/test_attach_interfaces.py b/tempest/api/compute/servers/test_attach_interfaces.py
index a21c411..f6eed00 100644
--- a/tempest/api/compute/servers/test_attach_interfaces.py
+++ b/tempest/api/compute/servers/test_attach_interfaces.py
@@ -16,7 +16,7 @@
from tempest.api.compute import base
from tempest import config
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
import time
@@ -106,7 +106,7 @@
self.assertEqual(sorted(list1), sorted(list2))
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_create_list_show_delete_interfaces(self):
server, ifs = self._create_server_get_interfaces()
interface_count = len(ifs)
@@ -127,7 +127,7 @@
_ifs = self._test_delete_interface(server, ifs)
self.assertEqual(len(ifs) - 1, len(_ifs))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_add_remove_fixed_ip(self):
# Add and Remove the fixed IP to server.
server, ifs = self._create_server_get_interfaces()
diff --git a/tempest/api/compute/servers/test_disk_config.py b/tempest/api/compute/servers/test_disk_config.py
index 75a1234..332358c 100644
--- a/tempest/api/compute/servers/test_disk_config.py
+++ b/tempest/api/compute/servers/test_disk_config.py
@@ -17,7 +17,7 @@
from tempest.api.compute import base
from tempest import config
-from tempest.test import attr
+from tempest import test
CONF = config.CONF
@@ -44,7 +44,7 @@
resp, server = self.client.get_server(server['id'])
self.assertEqual(disk_config, server['OS-DCF:diskConfig'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_rebuild_server_with_manual_disk_config(self):
# A server should be rebuilt using the manual disk config option
self._update_server_with_disk_config(disk_config='AUTO')
@@ -60,7 +60,7 @@
resp, server = self.client.get_server(server['id'])
self.assertEqual('MANUAL', server['OS-DCF:diskConfig'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_rebuild_server_with_auto_disk_config(self):
# A server should be rebuilt using the auto disk config option
self._update_server_with_disk_config(disk_config='MANUAL')
@@ -86,7 +86,7 @@
@testtools.skipUnless(CONF.compute_feature_enabled.resize,
'Resize not available.')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_resize_server_from_manual_to_auto(self):
# A server should be resized from manual to auto disk config
self._update_server_with_disk_config(disk_config='MANUAL')
@@ -103,7 +103,7 @@
@testtools.skipUnless(CONF.compute_feature_enabled.resize,
'Resize not available.')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_resize_server_from_auto_to_manual(self):
# A server should be resized from auto to manual disk config
self._update_server_with_disk_config(disk_config='AUTO')
@@ -118,7 +118,7 @@
resp, server = self.client.get_server(self.server_id)
self.assertEqual('MANUAL', server['OS-DCF:diskConfig'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_update_server_from_auto_to_manual(self):
# A server should be updated from auto to manual disk config
self._update_server_with_disk_config(disk_config='AUTO')
diff --git a/tempest/api/compute/servers/test_list_servers_negative.py b/tempest/api/compute/servers/test_list_servers_negative.py
index 26c5887..c825fb9 100644
--- a/tempest/api/compute/servers/test_list_servers_negative.py
+++ b/tempest/api/compute/servers/test_list_servers_negative.py
@@ -19,7 +19,7 @@
from tempest.api.compute import base
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class ListServersNegativeTestJSON(base.BaseV2ComputeTest):
@@ -51,7 +51,7 @@
ignore_error=True)
cls.deleted_fixtures.append(srv)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_list_servers_with_a_deleted_server(self):
# Verify deleted servers do not show by default in list servers
# List servers and verify server not returned
@@ -63,7 +63,7 @@
self.assertEqual('200', resp['status'])
self.assertEqual([], actual)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_list_servers_by_non_existing_image(self):
# Listing servers for a non existing image returns empty list
non_existing_image = '1234abcd-zzz0-aaa9-ppp3-0987654abcde'
@@ -72,7 +72,7 @@
self.assertEqual('200', resp['status'])
self.assertEqual([], servers)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_list_servers_by_non_existing_flavor(self):
# Listing servers by non existing flavor returns empty list
non_existing_flavor = 1234
@@ -81,7 +81,7 @@
self.assertEqual('200', resp['status'])
self.assertEqual([], servers)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_list_servers_by_non_existing_server_name(self):
# Listing servers for a non existent server name returns empty list
non_existing_name = 'junk_server_1234'
@@ -90,7 +90,7 @@
self.assertEqual('200', resp['status'])
self.assertEqual([], servers)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_list_servers_status_non_existing(self):
# Return an empty list when invalid status is specified
non_existing_status = 'BALONEY'
@@ -99,7 +99,7 @@
self.assertEqual('200', resp['status'])
self.assertEqual([], servers)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_by_limits(self):
# List servers by specifying limits
resp, body = self.client.list_servers({'limit': 1})
@@ -107,26 +107,26 @@
# when _interface='xml', one element for servers_links in servers
self.assertEqual(1, len([x for x in body['servers'] if 'id' in x]))
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_list_servers_by_limits_greater_than_actual_count(self):
# List servers by specifying a greater value for limit
resp, body = self.client.list_servers({'limit': 100})
self.assertEqual('200', resp['status'])
self.assertEqual(len(self.existing_fixtures), len(body['servers']))
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_list_servers_by_limits_pass_string(self):
# Return an error if a string value is passed for limit
self.assertRaises(exceptions.BadRequest, self.client.list_servers,
{'limit': 'testing'})
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_list_servers_by_limits_pass_negative_value(self):
# Return an error if a negative value for limit is passed
self.assertRaises(exceptions.BadRequest, self.client.list_servers,
{'limit': -1})
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_by_changes_since(self):
# Servers are listed by specifying changes-since date
changes_since = {'changes-since': self.start_time.isoformat()}
@@ -139,13 +139,13 @@
"Number of servers %d is wrong in %s" %
(num_expected, body['servers']))
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_list_servers_by_changes_since_invalid_date(self):
# Return an error when invalid date format is passed
self.assertRaises(exceptions.BadRequest, self.client.list_servers,
{'changes-since': '2011/01/01'})
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_list_servers_by_changes_since_future_date(self):
# Return an empty list when a date in the future is passed
changes_since = {'changes-since': '2051-01-01T12:34:00Z'}
@@ -153,7 +153,7 @@
self.assertEqual('200', resp['status'])
self.assertEqual(0, len(body['servers']))
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_list_servers_detail_server_is_deleted(self):
# Server details are not listed for a deleted server
deleted_ids = [s['id'] for s in self.deleted_fixtures]
diff --git a/tempest/api/compute/servers/test_server_password.py b/tempest/api/compute/servers/test_server_password.py
index ad78f65..50c881a 100644
--- a/tempest/api/compute/servers/test_server_password.py
+++ b/tempest/api/compute/servers/test_server_password.py
@@ -15,7 +15,7 @@
from tempest.api.compute import base
-from tempest.test import attr
+from tempest import test
class ServerPasswordTestJSON(base.BaseV2ComputeTest):
@@ -26,12 +26,12 @@
cls.client = cls.servers_client
resp, cls.server = cls.create_test_server(wait_until="ACTIVE")
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_server_password(self):
resp, body = self.client.get_password(self.server['id'])
self.assertEqual(200, resp.status)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_delete_server_password(self):
resp, body = self.client.delete_password(self.server['id'])
self.assertEqual(204, resp.status)
diff --git a/tempest/api/compute/servers/test_server_personality.py b/tempest/api/compute/servers/test_server_personality.py
index b581faf..b7e4e38 100644
--- a/tempest/api/compute/servers/test_server_personality.py
+++ b/tempest/api/compute/servers/test_server_personality.py
@@ -17,7 +17,7 @@
from tempest.api.compute import base
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class ServerPersonalityTestJSON(base.BaseV2ComputeTest):
@@ -28,7 +28,7 @@
cls.client = cls.servers_client
cls.user_client = cls.limits_client
- @attr(type='gate')
+ @test.attr(type='gate')
def test_personality_files_exceed_limit(self):
# Server creation should fail if greater than the maximum allowed
# number of files are injected into the server.
@@ -43,7 +43,7 @@
self.assertRaises(exceptions.OverLimit, self.create_test_server,
personality=personality)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_can_create_server_with_max_number_personality_files(self):
# Server should be created successfully if maximum allowed number of
# files is injected into the server during creation.
diff --git a/tempest/api/compute/servers/test_servers.py b/tempest/api/compute/servers/test_servers.py
index 9674463..40b97d7 100644
--- a/tempest/api/compute/servers/test_servers.py
+++ b/tempest/api/compute/servers/test_servers.py
@@ -15,7 +15,7 @@
from tempest.api.compute import base
from tempest.common.utils import data_utils
-from tempest.test import attr
+from tempest import test
class ServersTestJSON(base.BaseV2ComputeTest):
@@ -29,7 +29,7 @@
self.clear_servers()
super(ServersTestJSON, self).tearDown()
- @attr(type='gate')
+ @test.attr(type='gate')
def test_create_server_with_admin_password(self):
# If an admin password is provided on server creation, the server's
# root password should be set to that password.
@@ -38,7 +38,7 @@
# Verify the password is set correctly in the response
self.assertEqual('testpassword', server['adminPass'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_create_with_existing_server_name(self):
# Creating a server with a name that already exists is allowed
@@ -57,7 +57,7 @@
name2 = server['name']
self.assertEqual(name1, name2)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_create_specify_keypair(self):
# Specify a keypair while creating a server
@@ -70,7 +70,7 @@
resp, server = self.client.get_server(server['id'])
self.assertEqual(key_name, server['key_name'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_update_server_name(self):
# The server name should be changed to the the provided value
resp, server = self.create_test_server(wait_until='ACTIVE')
@@ -85,7 +85,7 @@
resp, server = self.client.get_server(server['id'])
self.assertEqual('newname', server['name'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_update_access_server_address(self):
# The server's access addresses should reflect the provided values
resp, server = self.create_test_server(wait_until='ACTIVE')
@@ -102,7 +102,7 @@
self.assertEqual('1.1.1.1', server['accessIPv4'])
self.assertEqual('::babe:202:202', server['accessIPv6'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_create_server_with_ipv6_addr_only(self):
# Create a server without an IPv4 address(only IPv6 address).
resp, server = self.create_test_server(accessIPv6='2001:2001::3')
diff --git a/tempest/api/compute/test_authorization.py b/tempest/api/compute/test_authorization.py
index fd73cc5..7f909d7 100644
--- a/tempest/api/compute/test_authorization.py
+++ b/tempest/api/compute/test_authorization.py
@@ -19,7 +19,7 @@
from tempest import config
from tempest import exceptions
from tempest.openstack.common import log as logging
-from tempest.test import attr
+from tempest import test
CONF = config.CONF
@@ -89,31 +89,31 @@
cls.security_client.delete_security_group(cls.security_group['id'])
super(AuthorizationTestJSON, cls).tearDownClass()
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_server_for_alt_account_fails(self):
# A GET request for a server on another user's account should fail
self.assertRaises(exceptions.NotFound, self.alt_client.get_server,
self.server['id'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_delete_server_for_alt_account_fails(self):
# A DELETE request for another user's server should fail
self.assertRaises(exceptions.NotFound, self.alt_client.delete_server,
self.server['id'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_update_server_for_alt_account_fails(self):
# An update server request for another user's server should fail
self.assertRaises(exceptions.NotFound, self.alt_client.update_server,
self.server['id'], name='test')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_server_addresses_for_alt_account_fails(self):
# A list addresses request for another user's server should fail
self.assertRaises(exceptions.NotFound, self.alt_client.list_addresses,
self.server['id'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_server_addresses_by_network_for_alt_account_fails(self):
# A list address/network request for another user's server should fail
server_id = self.server['id']
@@ -121,7 +121,7 @@
self.alt_client.list_addresses_by_network, server_id,
'public')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_with_alternate_tenant(self):
# A list on servers from one tenant should not
# show on alternate tenant
@@ -131,44 +131,44 @@
alt_server_ids = [s['id'] for s in body['servers']]
self.assertNotIn(self.server['id'], alt_server_ids)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_change_password_for_alt_account_fails(self):
# A change password request for another user's server should fail
self.assertRaises(exceptions.NotFound, self.alt_client.change_password,
self.server['id'], 'newpass')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_reboot_server_for_alt_account_fails(self):
# A reboot request for another user's server should fail
self.assertRaises(exceptions.NotFound, self.alt_client.reboot,
self.server['id'], 'HARD')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_rebuild_server_for_alt_account_fails(self):
# A rebuild request for another user's server should fail
self.assertRaises(exceptions.NotFound, self.alt_client.rebuild,
self.server['id'], self.image_ref_alt)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_resize_server_for_alt_account_fails(self):
# A resize request for another user's server should fail
self.assertRaises(exceptions.NotFound, self.alt_client.resize,
self.server['id'], self.flavor_ref_alt)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_create_image_for_alt_account_fails(self):
# A create image request for another user's server should fail
self.assertRaises(exceptions.NotFound,
self.alt_images_client.create_image,
self.server['id'], 'testImage')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_create_server_with_unauthorized_image(self):
# Server creation with another user's image should fail
self.assertRaises(exceptions.BadRequest, self.alt_client.create_server,
'test', self.image['id'], self.flavor_ref)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_create_server_fails_when_tenant_incorrect(self):
# A create server request should fail if the tenant id does not match
# the current user
@@ -181,7 +181,7 @@
self.alt_client.create_server, 'test',
self.image['id'], self.flavor_ref)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_create_keypair_in_analt_user_tenant(self):
# A create keypair request should fail if the tenant id does not match
# the current user
@@ -204,34 +204,34 @@
LOG.error("Create keypair request should not happen "
"if the tenant id does not match the current user")
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_keypair_of_alt_account_fails(self):
# A GET request for another user's keypair should fail
self.assertRaises(exceptions.NotFound,
self.alt_keypairs_client.get_keypair,
self.keypairname)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_delete_keypair_of_alt_account_fails(self):
# A DELETE request for another user's keypair should fail
self.assertRaises(exceptions.NotFound,
self.alt_keypairs_client.delete_keypair,
self.keypairname)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_image_for_alt_account_fails(self):
# A GET request for an image on another user's account should fail
self.assertRaises(exceptions.NotFound,
self.alt_images_client.get_image, self.image['id'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_delete_image_for_alt_account_fails(self):
# A DELETE request for another user's image should fail
self.assertRaises(exceptions.NotFound,
self.alt_images_client.delete_image,
self.image['id'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_create_security_group_in_analt_user_tenant(self):
# A create security group request should fail if the tenant id does not
# match the current user
@@ -256,21 +256,21 @@
LOG.error("Create Security Group request should not happen if"
"the tenant id does not match the current user")
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_security_group_of_alt_account_fails(self):
# A GET request for another user's security group should fail
self.assertRaises(exceptions.NotFound,
self.alt_security_client.get_security_group,
self.security_group['id'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_delete_security_group_of_alt_account_fails(self):
# A DELETE request for another user's security group should fail
self.assertRaises(exceptions.NotFound,
self.alt_security_client.delete_security_group,
self.security_group['id'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_create_security_group_rule_in_analt_user_tenant(self):
# A create security group rule request should fail if the tenant id
# does not match the current user
@@ -300,7 +300,7 @@
"happen if the tenant id does not match the"
" current user")
- @attr(type='gate')
+ @test.attr(type='gate')
def test_delete_security_group_rule_of_alt_account_fails(self):
# A DELETE request for another user's security group rule
# should fail
@@ -308,7 +308,7 @@
self.alt_security_client.delete_security_group_rule,
self.rule['id'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_set_metadata_of_alt_account_server_fails(self):
# A set metadata for another user's server should fail
req_metadata = {'meta1': 'data1', 'meta2': 'data2'}
@@ -317,7 +317,7 @@
self.server['id'],
req_metadata)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_set_metadata_of_alt_account_image_fails(self):
# A set metadata for another user's image should fail
req_metadata = {'meta1': 'value1', 'meta2': 'value2'}
@@ -325,7 +325,7 @@
self.alt_images_client.set_image_metadata,
self.image['id'], req_metadata)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_metadata_of_alt_account_server_fails(self):
# A get metadata for another user's server should fail
req_metadata = {'meta1': 'data1'}
@@ -336,7 +336,7 @@
self.alt_client.get_server_metadata_item,
self.server['id'], 'meta1')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_metadata_of_alt_account_image_fails(self):
# A get metadata for another user's image should fail
req_metadata = {'meta1': 'value1'}
@@ -348,7 +348,7 @@
self.alt_images_client.get_image_metadata_item,
self.image['id'], 'meta1')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_delete_metadata_of_alt_account_server_fails(self):
# A delete metadata for another user's server should fail
req_metadata = {'meta1': 'data1'}
@@ -359,7 +359,7 @@
self.alt_client.delete_server_metadata_item,
self.server['id'], 'meta1')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_delete_metadata_of_alt_account_image_fails(self):
# A delete metadata for another user's image should fail
req_metadata = {'meta1': 'data1'}
@@ -371,7 +371,7 @@
self.alt_images_client.delete_image_metadata_item,
self.image['id'], 'meta1')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_console_output_of_alt_account_server_fails(self):
# A Get Console Output for another user's server should fail
self.assertRaises(exceptions.NotFound,
diff --git a/tempest/api/compute/test_live_block_migration.py b/tempest/api/compute/test_live_block_migration.py
index 1319f68..93ff4b0 100644
--- a/tempest/api/compute/test_live_block_migration.py
+++ b/tempest/api/compute/test_live_block_migration.py
@@ -18,7 +18,7 @@
from tempest.api.compute import base
from tempest import config
-from tempest.test import attr
+from tempest import test
CONF = config.CONF
@@ -85,7 +85,7 @@
@testtools.skipIf(not CONF.compute_feature_enabled.live_migration,
'Live migration not available')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_live_block_migration(self):
# Live block migrate an instance to another host
if len(self._get_compute_hostnames()) < 2:
@@ -105,7 +105,7 @@
@testtools.skipIf(not CONF.compute_feature_enabled.
block_migrate_cinder_iscsi,
'Block Live migration not configured for iSCSI')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_iscsi_volume(self):
# Live block migrate an instance to another host
if len(self._get_compute_hostnames()) < 2:
diff --git a/tempest/api/compute/test_quotas.py b/tempest/api/compute/test_quotas.py
index b97ab2c..230d433 100644
--- a/tempest/api/compute/test_quotas.py
+++ b/tempest/api/compute/test_quotas.py
@@ -14,7 +14,7 @@
# under the License.
from tempest.api.compute import base
-from tempest.test import attr
+from tempest import test
class QuotasTestJSON(base.BaseV2ComputeTest):
@@ -35,7 +35,7 @@
'instances', 'security_group_rules',
'cores', 'security_groups'))
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_get_quotas(self):
# User can get the quota set for it's tenant
expected_quota_set = self.default_quota_set | set(['id'])
@@ -45,7 +45,7 @@
sorted(quota_set.keys()))
self.assertEqual(quota_set['id'], self.tenant_id)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_get_default_quotas(self):
# User can get the default quota set for it's tenant
expected_quota_set = self.default_quota_set | set(['id'])
@@ -55,7 +55,7 @@
sorted(quota_set.keys()))
self.assertEqual(quota_set['id'], self.tenant_id)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_compare_tenant_quotas_with_default_quotas(self):
# Tenants are created with the default quota values
resp, defualt_quota_set = \
diff --git a/tempest/api/compute/v3/admin/test_services.py b/tempest/api/compute/v3/admin/test_services.py
index 914a2a4..0a7c7f1 100644
--- a/tempest/api/compute/v3/admin/test_services.py
+++ b/tempest/api/compute/v3/admin/test_services.py
@@ -14,6 +14,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest.api.compute.api_schema import services as schema
from tempest.api.compute import base
from tempest.test import attr
@@ -32,7 +33,7 @@
@attr(type='gate')
def test_list_services(self):
resp, services = self.client.list_services()
- self.assertEqual(200, resp.status)
+ self.validate_response(schema.list_services, resp, services)
self.assertNotEqual(0, len(services))
@attr(type='gate')
@@ -40,7 +41,7 @@
binary_name = 'nova-compute'
params = {'binary': binary_name}
resp, services = self.client.list_services(params)
- self.assertEqual(200, resp.status)
+ self.validate_response(schema.list_services, resp, services)
self.assertNotEqual(0, len(services))
for service in services:
self.assertEqual(binary_name, service['binary'])
@@ -48,11 +49,14 @@
@attr(type='gate')
def test_get_service_by_host_name(self):
resp, services = self.client.list_services()
+ self.validate_response(schema.list_services, resp, services)
host_name = services[0]['host']
services_on_host = [service for service in services if
service['host'] == host_name]
params = {'host': host_name}
+
resp, services = self.client.list_services(params)
+ self.validate_response(schema.list_services, resp, services)
# we could have a periodic job checkin between the 2 service
# lookups, so only compare binary lists.
@@ -66,11 +70,13 @@
@attr(type='gate')
def test_get_service_by_service_and_host_name(self):
resp, services = self.client.list_services()
+ self.validate_response(schema.list_services, resp, services)
host_name = services[0]['host']
binary_name = services[0]['binary']
params = {'host': host_name, 'binary': binary_name}
+
resp, services = self.client.list_services(params)
- self.assertEqual(200, resp.status)
+ self.validate_response(schema.list_services, resp, services)
self.assertEqual(1, len(services))
self.assertEqual(host_name, services[0]['host'])
self.assertEqual(binary_name, services[0]['binary'])
diff --git a/tempest/api/identity/admin/v3/test_users.py b/tempest/api/identity/admin/v3/test_users.py
index a78d542..e1d1543 100644
--- a/tempest/api/identity/admin/v3/test_users.py
+++ b/tempest/api/identity/admin/v3/test_users.py
@@ -120,6 +120,13 @@
', '.join(m_project for m_project
in missing_projects))
+ @attr(type='gate')
+ def test_get_user(self):
+ # Get a user detail
+ self.data.setup_test_v3_user()
+ resp, user = self.client.get_user(self.data.v3_user['id'])
+ self.assertEqual(self.data.v3_user['id'], user['id'])
+
class UsersV3TestXML(UsersV3TestJSON):
_interface = 'xml'
diff --git a/tempest/api/identity/base.py b/tempest/api/identity/base.py
index 10f5217..a5bf248 100644
--- a/tempest/api/identity/base.py
+++ b/tempest/api/identity/base.py
@@ -153,10 +153,11 @@
self.test_user = data_utils.rand_name('test_user_')
self.test_password = data_utils.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)
+ resp, self.v3_user = self.client.create_user(
+ self.test_user,
+ password=self.test_password,
+ project_id=self.project['id'],
+ email=self.test_email)
self.v3_users.append(self.v3_user)
def setup_test_project(self):
diff --git a/tempest/api/image/v1/test_image_members.py b/tempest/api/image/v1/test_image_members.py
index e6a078e..4cbb62f 100644
--- a/tempest/api/image/v1/test_image_members.py
+++ b/tempest/api/image/v1/test_image_members.py
@@ -14,12 +14,12 @@
from tempest.api.image import base
-from tempest.test import attr
+from tempest import test
class ImageMembersTest(base.BaseV1ImageMembersTest):
- @attr(type='gate')
+ @test.attr(type='gate')
def test_add_image_member(self):
image = self._create_image()
resp = self.client.add_member(self.alt_tenant_id, image)
@@ -33,7 +33,7 @@
resp, body = self.alt_img_cli.get_image(image)
self.assertEqual(200, resp.status)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_shared_images(self):
image = self._create_image()
resp = self.client.add_member(self.alt_tenant_id, image)
@@ -48,7 +48,7 @@
self.assertIn(share_image, images)
self.assertIn(image, images)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_remove_member(self):
image_id = self._create_image()
resp = self.client.add_member(self.alt_tenant_id, image_id)
diff --git a/tempest/api/image/v1/test_image_members_negative.py b/tempest/api/image/v1/test_image_members_negative.py
index d68ef03..aac63b4 100644
--- a/tempest/api/image/v1/test_image_members_negative.py
+++ b/tempest/api/image/v1/test_image_members_negative.py
@@ -16,26 +16,26 @@
from tempest.api.image import base
from tempest.common.utils import data_utils
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class ImageMembersNegativeTest(base.BaseV1ImageMembersTest):
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_add_member_with_non_existing_image(self):
# Add member with non existing image.
non_exist_image = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.add_member,
self.alt_tenant_id, non_exist_image)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_member_with_non_existing_image(self):
# Delete member with non existing image.
non_exist_image = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.delete_member,
self.alt_tenant_id, non_exist_image)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_member_with_non_existing_tenant(self):
# Delete member with non existing tenant.
image_id = self._create_image()
@@ -43,7 +43,7 @@
self.assertRaises(exceptions.NotFound, self.client.delete_member,
non_exist_tenant, image_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_get_image_without_membership(self):
# Image is hidden from another tenants.
image_id = self._create_image()
diff --git a/tempest/api/image/v1/test_images_negative.py b/tempest/api/image/v1/test_images_negative.py
index 5695884..66556e0 100644
--- a/tempest/api/image/v1/test_images_negative.py
+++ b/tempest/api/image/v1/test_images_negative.py
@@ -15,30 +15,30 @@
from tempest.api.image import base
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class CreateDeleteImagesNegativeTest(base.BaseV1ImageTest):
"""Here are negative tests for the deletion and creation of images."""
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_register_with_invalid_container_format(self):
# Negative tests for invalid data supplied to POST /images
self.assertRaises(exceptions.BadRequest, self.client.create_image,
'test', 'wrong', 'vhd')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_register_with_invalid_disk_format(self):
self.assertRaises(exceptions.BadRequest, self.client.create_image,
'test', 'bare', 'wrong')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_image_with_invalid_image_id(self):
# An image should not be deleted with invalid image id
self.assertRaises(exceptions.NotFound, self.client.delete_image,
'!@$%^&*()')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_non_existent_image(self):
# Return an error while trying to delete a non-existent image
@@ -46,24 +46,24 @@
self.assertRaises(exceptions.NotFound, self.client.delete_image,
non_existent_image_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_image_blank_id(self):
# Return an error while trying to delete an image with blank Id
self.assertRaises(exceptions.NotFound, self.client.delete_image, '')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_image_non_hex_string_id(self):
# Return an error while trying to delete an image with non hex id
image_id = '11a22b9-120q-5555-cc11-00ab112223gj'
self.assertRaises(exceptions.NotFound, self.client.delete_image,
image_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_image_negative_image_id(self):
# Return an error while trying to delete an image with negative id
self.assertRaises(exceptions.NotFound, self.client.delete_image, -1)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_image_id_is_over_35_character_limit(self):
# Return an error while trying to delete image with id over limit
self.assertRaises(exceptions.NotFound, self.client.delete_image,
diff --git a/tempest/api/image/v2/test_images.py b/tempest/api/image/v2/test_images.py
index d448c01..ce11911 100644
--- a/tempest/api/image/v2/test_images.py
+++ b/tempest/api/image/v2/test_images.py
@@ -19,7 +19,7 @@
from tempest.api.image import base
from tempest.common.utils import data_utils
-from tempest.test import attr
+from tempest import test
class BasicOperationsImagesTest(base.BaseV2ImageTest):
@@ -27,7 +27,7 @@
Here we test the basic operations of images
"""
- @attr(type='gate')
+ @test.attr(type='gate')
def test_register_upload_get_image_file(self):
"""
@@ -68,7 +68,7 @@
self.assertEqual(200, resp.status)
self.assertEqual(file_content, body)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_delete_image(self):
# Deletes an image by image_id
@@ -90,7 +90,7 @@
self.assertEqual(resp.status, 200)
self.assertNotIn(image_id, images)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_update_image(self):
# Updates an image by image_id
@@ -176,7 +176,7 @@
msg = "Failed to list images by %s" % key
self.assertEqual(params[key], image[key], msg)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_index_no_params(self):
# Simple test to see all fixture images returned
resp, images_list = self.client.image_list()
@@ -186,25 +186,25 @@
for image in self.created_images:
self.assertIn(image, image_list)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_images_param_container_format(self):
# Test to get all images with container_format='bare'
params = {"container_format": "bare"}
self._list_by_param_value_and_assert(params)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_images_param_disk_format(self):
# Test to get all images with disk_format = raw
params = {"disk_format": "raw"}
self._list_by_param_value_and_assert(params)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_images_param_visibility(self):
# Test to get all images with visibility = public
params = {"visibility": "public"}
self._list_by_param_value_and_assert(params)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_images_param_size(self):
# Test to get all images by size
image_id = self.created_images[1]
@@ -215,7 +215,7 @@
params = {"size": image['size']}
self._list_by_param_value_and_assert(params)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_images_param_min_max_size(self):
# Test to get all images with size between 2000 to 3000
image_id = self.created_images[1]
@@ -234,13 +234,13 @@
image_size <= params['size_max'],
"Failed to get images by size_min and size_max")
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_images_param_status(self):
# Test to get all active images
params = {"status": "active"}
self._list_by_param_value_and_assert(params)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_images_param_limit(self):
# Test to get images by limit
params = {"limit": 2}
@@ -250,7 +250,7 @@
self.assertEqual(len(images_list), params['limit'],
"Failed to get images by limit")
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_image_schema(self):
# Test to get image schema
schema = "image"
@@ -258,7 +258,7 @@
self.assertEqual(200, resp.status)
self.assertEqual("image", body['name'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_images_schema(self):
# Test to get images schema
schema = "images"
diff --git a/tempest/api/image/v2/test_images_member.py b/tempest/api/image/v2/test_images_member.py
index 530262f..f80c818 100644
--- a/tempest/api/image/v2/test_images_member.py
+++ b/tempest/api/image/v2/test_images_member.py
@@ -11,13 +11,13 @@
# under the License.
from tempest.api.image import base
-from tempest.test import attr
+from tempest import test
class ImagesMemberTest(base.BaseV2MemberImageTest):
_interface = 'json'
- @attr(type='gate')
+ @test.attr(type='gate')
def test_image_share_accept(self):
image_id = self._create_image()
resp, member = self.os_img_client.add_member(image_id,
@@ -40,7 +40,7 @@
self.assertEqual(member['image_id'], image_id)
self.assertEqual(member['status'], 'accepted')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_image_share_reject(self):
image_id = self._create_image()
resp, member = self.os_img_client.add_member(image_id,
@@ -56,7 +56,7 @@
self.assertEqual(200, resp.status)
self.assertNotIn(image_id, self._list_image_ids_as_alt())
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_image_member(self):
image_id = self._create_image()
self.os_img_client.add_member(image_id,
@@ -73,7 +73,7 @@
self.assertEqual(image_id, member['image_id'])
self.assertEqual('accepted', member['status'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_remove_image_member(self):
image_id = self._create_image()
self.os_img_client.add_member(image_id,
@@ -86,3 +86,15 @@
resp = self.os_img_client.remove_member(image_id, self.alt_tenant_id)
self.assertEqual(204, resp.status)
self.assertNotIn(image_id, self._list_image_ids_as_alt())
+
+ @test.attr(type='gate')
+ def test_get_image_member_schema(self):
+ resp, body = self.os_img_client.get_schema("member")
+ self.assertEqual(200, resp.status)
+ self.assertEqual("member", body['name'])
+
+ @test.attr(type='gate')
+ def test_get_image_members_schema(self):
+ resp, body = self.os_img_client.get_schema("members")
+ self.assertEqual(200, resp.status)
+ self.assertEqual("members", body['name'])
diff --git a/tempest/api/image/v2/test_images_member_negative.py b/tempest/api/image/v2/test_images_member_negative.py
index 4c7cc5a..98ef649 100644
--- a/tempest/api/image/v2/test_images_member_negative.py
+++ b/tempest/api/image/v2/test_images_member_negative.py
@@ -12,13 +12,13 @@
from tempest.api.image import base
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class ImagesMemberNegativeTest(base.BaseV2MemberImageTest):
_interface = 'json'
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_image_share_invalid_status(self):
image_id = self._create_image()
resp, member = self.os_img_client.add_member(image_id,
@@ -28,7 +28,7 @@
self.alt_img_client.update_member_status,
image_id, self.alt_tenant_id, 'notavalidstatus')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_image_share_owner_cannot_accept(self):
image_id = self._create_image()
resp, member = self.os_img_client.add_member(image_id,
diff --git a/tempest/api/image/v2/test_images_negative.py b/tempest/api/image/v2/test_images_negative.py
index b8ba868..27ba39c 100644
--- a/tempest/api/image/v2/test_images_negative.py
+++ b/tempest/api/image/v2/test_images_negative.py
@@ -18,7 +18,7 @@
from tempest.api.image import base
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class ImagesNegativeTest(base.BaseV2ImageTest):
@@ -35,20 +35,20 @@
** delete the deleted image
"""
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_get_non_existent_image(self):
# get the non-existent image
non_existent_id = str(uuid.uuid4())
self.assertRaises(exceptions.NotFound, self.client.get_image,
non_existent_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_get_image_null_id(self):
# get image with image_id = NULL
image_id = ""
self.assertRaises(exceptions.NotFound, self.client.get_image, image_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_get_delete_deleted_image(self):
# get and delete the deleted image
# create and delete image
@@ -67,27 +67,27 @@
self.assertRaises(exceptions.NotFound, self.client.delete_image,
image_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_non_existing_image(self):
# delete non-existent image
non_existent_image_id = str(uuid.uuid4())
self.assertRaises(exceptions.NotFound, self.client.delete_image,
non_existent_image_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_image_null_id(self):
# delete image with image_id=NULL
image_id = ""
self.assertRaises(exceptions.NotFound, self.client.delete_image,
image_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_register_with_invalid_container_format(self):
# Negative tests for invalid data supplied to POST /images
self.assertRaises(exceptions.BadRequest, self.client.create_image,
'test', 'wrong', 'vhd')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_register_with_invalid_disk_format(self):
self.assertRaises(exceptions.BadRequest, self.client.create_image,
'test', 'bare', 'wrong')
diff --git a/tempest/api/image/v2/test_images_tags.py b/tempest/api/image/v2/test_images_tags.py
index f0e343d..504c0e8 100644
--- a/tempest/api/image/v2/test_images_tags.py
+++ b/tempest/api/image/v2/test_images_tags.py
@@ -14,12 +14,12 @@
from tempest.api.image import base
from tempest.common.utils import data_utils
-from tempest.test import attr
+from tempest import test
class ImagesTagsTest(base.BaseV2ImageTest):
- @attr(type='gate')
+ @test.attr(type='gate')
def test_update_delete_tags_for_image(self):
resp, body = self.create_image(container_format='bare',
disk_format='raw',
diff --git a/tempest/api/image/v2/test_images_tags_negative.py b/tempest/api/image/v2/test_images_tags_negative.py
index 0628d29..3233db7 100644
--- a/tempest/api/image/v2/test_images_tags_negative.py
+++ b/tempest/api/image/v2/test_images_tags_negative.py
@@ -17,12 +17,12 @@
from tempest.api.image import base
from tempest.common.utils import data_utils
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class ImagesTagsNegativeTest(base.BaseV2ImageTest):
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_update_tags_for_non_existing_image(self):
# Update tag with non existing image.
tag = data_utils.rand_name('tag-')
@@ -30,7 +30,7 @@
self.assertRaises(exceptions.NotFound, self.client.add_image_tag,
non_exist_image, tag)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_non_existing_tag(self):
# Delete non existing tag.
resp, body = self.create_image(container_format='bare',
diff --git a/tempest/api/network/admin/test_l3_agent_scheduler.py b/tempest/api/network/admin/test_l3_agent_scheduler.py
index 7c02787..eb397ba 100644
--- a/tempest/api/network/admin/test_l3_agent_scheduler.py
+++ b/tempest/api/network/admin/test_l3_agent_scheduler.py
@@ -26,6 +26,7 @@
List routers that the given L3 agent is hosting.
List L3 agents hosting the given router.
+ Add and Remove Router to L3 agent
v2.0 of the Neutron API is assumed. It is also assumed that the following
options are defined in the [network] section of etc/tempest.conf:
@@ -37,28 +38,49 @@
if not test.is_extension_enabled('l3_agent_scheduler', 'network'):
msg = "L3 Agent Scheduler Extension not enabled."
raise cls.skipException(msg)
+ # Trying to get agent details for L3 Agent
+ resp, body = cls.admin_client.list_agents()
+ agents = body['agents']
+ for agent in agents:
+ if agent['agent_type'] == 'L3 agent':
+ cls.agent = agent
+ break
+ else:
+ msg = "L3 Agent not found"
+ raise cls.skipException(msg)
@test.attr(type='smoke')
def test_list_routers_on_l3_agent(self):
- resp, body = self.admin_client.list_agents()
- agents = body['agents']
- for a in agents:
- if a['agent_type'] == 'L3 agent':
- agent = a
resp, body = self.admin_client.list_routers_on_l3_agent(
- agent['id'])
+ self.agent['id'])
self.assertEqual('200', resp['status'])
@test.attr(type='smoke')
- def test_list_l3_agents_hosting_router(self):
- name = data_utils.rand_name('router-')
+ def test_add_list_remove_router_on_l3_agent(self):
+ l3_agent_ids = list()
+ name = data_utils.rand_name('router1-')
resp, router = self.client.create_router(name)
+ self.addCleanup(self.client.delete_router, router['router']['id'])
+ resp, body = self.admin_client.add_router_to_l3_agent(
+ self.agent['id'], router['router']['id'])
self.assertEqual('201', resp['status'])
resp, body = self.admin_client.list_l3_agents_hosting_router(
router['router']['id'])
self.assertEqual('200', resp['status'])
- resp, _ = self.client.delete_router(router['router']['id'])
- self.assertEqual(204, resp.status)
+ for agent in body['agents']:
+ l3_agent_ids.append(agent['id'])
+ self.assertIn('agent_type', agent)
+ self.assertEqual('L3 agent', agent['agent_type'])
+ self.assertIn(self.agent['id'], l3_agent_ids)
+ del l3_agent_ids[:]
+ resp, body = self.admin_client.remove_router_from_l3_agent(
+ self.agent['id'], router['router']['id'])
+ self.assertEqual('204', resp['status'])
+ resp, body = self.admin_client.list_l3_agents_hosting_router(
+ router['router']['id'])
+ for agent in body['agents']:
+ l3_agent_ids.append(agent['id'])
+ self.assertNotIn(self.agent['id'], l3_agent_ids)
class L3AgentSchedulerTestXML(L3AgentSchedulerTestJSON):
diff --git a/tempest/api/network/base.py b/tempest/api/network/base.py
index ba6a617..231c4bf 100644
--- a/tempest/api/network/base.py
+++ b/tempest/api/network/base.py
@@ -59,7 +59,6 @@
# Create no network resources for these test.
cls.set_network_resources()
super(BaseNetworkTest, cls).setUpClass()
- os = clients.Manager(interface=cls._interface)
if not CONF.service_available.neutron:
raise cls.skipException("Neutron support is required")
@@ -243,14 +242,20 @@
@classmethod
def create_member(cls, protocol_port, pool):
"""Wrapper utility that returns a test member."""
- resp, body = cls.client.create_member("10.0.9.46",
- protocol_port,
- pool['id'])
+ resp, body = cls.client.create_member(address="10.0.9.46",
+ protocol_port=protocol_port,
+ pool_id=pool['id'])
member = body['member']
cls.members.append(member)
return member
@classmethod
+ def update_member(cls, admin_state_up):
+ resp, body = cls.client.update_member(admin_state_up=admin_state_up)
+ member = body['member']
+ return member
+
+ @classmethod
def create_health_monitor(cls, delay, max_retries, Type, timeout):
"""Wrapper utility that returns a test health monitor."""
resp, body = cls.client.create_health_monitor(delay=delay,
diff --git a/tempest/api/network/common.py b/tempest/api/network/common.py
index d68ff1a..97e120f 100644
--- a/tempest/api/network/common.py
+++ b/tempest/api/network/common.py
@@ -61,6 +61,11 @@
super(DeletableSubnet, self).__init__(*args, **kwargs)
self._router_ids = set()
+ def update(self, *args, **kwargs):
+ body = dict(subnet=dict(*args, **kwargs))
+ result = self.client.update_subnet(subnet=self.id, body=body)
+ super(DeletableSubnet, self).update(**result['subnet'])
+
def add_to_router(self, router_id):
self._router_ids.add(router_id)
body = dict(subnet_id=self.id)
diff --git a/tempest/api/network/test_load_balancer.py b/tempest/api/network/test_load_balancer.py
index 03e095d..ba92199 100644
--- a/tempest/api/network/test_load_balancer.py
+++ b/tempest/api/network/test_load_balancer.py
@@ -61,19 +61,50 @@
Type="TCP",
timeout=1)
+ def _check_list_with_filter(self, obj_name, attr_exceptions, **kwargs):
+ create_obj = getattr(self.client, 'create_' + obj_name)
+ delete_obj = getattr(self.client, 'delete_' + obj_name)
+ list_objs = getattr(self.client, 'list_' + obj_name + 's')
+
+ resp, body = create_obj(**kwargs)
+ self.assertEqual('201', resp['status'])
+ obj = body[obj_name]
+ self.addCleanup(delete_obj, obj['id'])
+ for key, value in obj.iteritems():
+ # It is not relevant to filter by all arguments. That is why
+ # there is a list of attr to except
+ if key not in attr_exceptions:
+ resp, body = list_objs(**{key: value})
+ self.assertEqual('200', resp['status'])
+ objs = [v[key] for v in body[obj_name + 's']]
+ self.assertIn(value, objs)
+
@test.attr(type='smoke')
def test_list_vips(self):
# Verify the vIP exists in the list of all vIPs
resp, body = self.client.list_vips()
self.assertEqual('200', resp['status'])
vips = body['vips']
- found = None
- for n in vips:
- if (n['id'] == self.vip['id']):
- found = n['id']
- msg = "vIPs list doesn't contain created vip"
- self.assertIsNotNone(found, msg)
+ self.assertIn(self.vip['id'], [v['id'] for v in vips])
+ @test.attr(type='smoke')
+ def test_list_vips_with_filter(self):
+ name = data_utils.rand_name('vip-')
+ resp, body = self.client.create_pool(
+ name=data_utils.rand_name("pool-"), lb_method="ROUND_ROBIN",
+ protocol="HTTPS", subnet_id=self.subnet['id'])
+ self.assertEqual('201', resp['status'])
+ pool = body['pool']
+ self.addCleanup(self.client.delete_pool, pool['id'])
+ attr_exceptions = ['status', 'session_persistence',
+ 'status_description']
+ self._check_list_with_filter(
+ 'vip', attr_exceptions, name=name, protocol="HTTPS",
+ protocol_port=81, subnet_id=self.subnet['id'], pool_id=pool['id'],
+ description=data_utils.rand_name('description-'),
+ admin_state_up=False)
+
+ @test.attr(type='smoke')
def test_create_update_delete_pool_vip(self):
# Creates a vip
name = data_utils.rand_name('vip-')
@@ -117,17 +148,30 @@
resp, body = self.client.show_vip(self.vip['id'])
self.assertEqual('200', resp['status'])
vip = body['vip']
- self.assertEqual(self.vip['id'], vip['id'])
- self.assertEqual(self.vip['name'], vip['name'])
+ for key, value in vip.iteritems():
+ # 'status' should not be confirmed in api tests
+ if key != 'status':
+ self.assertEqual(self.vip[key], value)
@test.attr(type='smoke')
def test_show_pool(self):
- # Verifies the details of a pool
- resp, body = self.client.show_pool(self.pool['id'])
- self.assertEqual('200', resp['status'])
+ # Here we need to new pool without any dependence with vips
+ resp, body = self.client.create_pool(
+ name=data_utils.rand_name("pool-"),
+ lb_method='ROUND_ROBIN',
+ protocol='HTTP',
+ subnet_id=self.subnet['id'])
+ self.assertEqual('201', resp['status'])
pool = body['pool']
- self.assertEqual(self.pool['id'], pool['id'])
- self.assertEqual(self.pool['name'], pool['name'])
+ self.addCleanup(self.client.delete_pool, pool['id'])
+ # Verifies the details of a pool
+ resp, body = self.client.show_pool(pool['id'])
+ self.assertEqual('200', resp['status'])
+ shown_pool = body['pool']
+ for key, value in pool.iteritems():
+ # 'status' should not be confirmed in api tests
+ if key != 'status':
+ self.assertEqual(value, shown_pool[key])
@test.attr(type='smoke')
def test_list_pools(self):
@@ -138,6 +182,17 @@
self.assertIn(self.pool['id'], [p['id'] for p in pools])
@test.attr(type='smoke')
+ def test_list_pools_with_filters(self):
+ attr_exceptions = ['status', 'vip_id', 'members', 'provider',
+ 'status_description']
+ self._check_list_with_filter(
+ 'pool', attr_exceptions, name=data_utils.rand_name("pool-"),
+ lb_method="ROUND_ROBIN", protocol="HTTPS",
+ subnet_id=self.subnet['id'],
+ description=data_utils.rand_name('description-'),
+ admin_state_up=False)
+
+ @test.attr(type='smoke')
def test_list_members(self):
# Verify the member exists in the list of all members
resp, body = self.client.list_members()
@@ -146,14 +201,23 @@
self.assertIn(self.member['id'], [m['id'] for m in members])
@test.attr(type='smoke')
+ def test_list_members_with_filters(self):
+ attr_exceptions = ['status', 'status_description']
+ self._check_list_with_filter('member', attr_exceptions,
+ address="10.0.9.47", protocol_port=80,
+ pool_id=self.pool['id'])
+
+ @test.attr(type='smoke')
def test_create_update_delete_member(self):
# Creates a member
- resp, body = self.client.create_member("10.0.9.47", 80,
- self.pool['id'])
+ resp, body = self.client.create_member(address="10.0.9.47",
+ protocol_port=80,
+ pool_id=self.pool['id'])
self.assertEqual('201', resp['status'])
member = body['member']
# Verification of member update
- resp, body = self.client.update_member(False, member['id'])
+ resp, body = self.client.update_member(member['id'],
+ admin_state_up=False)
self.assertEqual('200', resp['status'])
updated_member = body['member']
self.assertFalse(updated_member['admin_state_up'])
@@ -167,9 +231,10 @@
resp, body = self.client.show_member(self.member['id'])
self.assertEqual('200', resp['status'])
member = body['member']
- self.assertEqual(self.member['id'], member['id'])
- self.assertEqual(self.member['admin_state_up'],
- member['admin_state_up'])
+ for key, value in member.iteritems():
+ # 'status' should not be confirmed in api tests
+ if key != 'status':
+ self.assertEqual(self.member[key], value)
@test.attr(type='smoke')
def test_list_health_monitors(self):
@@ -181,6 +246,13 @@
[h['id'] for h in health_monitors])
@test.attr(type='smoke')
+ def test_list_health_monitors_with_filters(self):
+ attr_exceptions = ['status', 'status_description', 'pools']
+ self._check_list_with_filter('health_monitor', attr_exceptions,
+ delay=5, max_retries=4, type="TCP",
+ timeout=2)
+
+ @test.attr(type='smoke')
def test_create_update_delete_health_monitor(self):
# Creates a health_monitor
resp, body = self.client.create_health_monitor(delay=4,
@@ -206,9 +278,10 @@
resp, body = self.client.show_health_monitor(self.health_monitor['id'])
self.assertEqual('200', resp['status'])
health_monitor = body['health_monitor']
- self.assertEqual(self.health_monitor['id'], health_monitor['id'])
- self.assertEqual(self.health_monitor['admin_state_up'],
- health_monitor['admin_state_up'])
+ for key, value in health_monitor.iteritems():
+ # 'status' should not be confirmed in api tests
+ if key != 'status':
+ self.assertEqual(self.health_monitor[key], value)
@test.attr(type='smoke')
def test_associate_disassociate_health_monitor_with_pool(self):
@@ -216,10 +289,26 @@
resp, body = (self.client.associate_health_monitor_with_pool
(self.health_monitor['id'], self.pool['id']))
self.assertEqual('201', resp['status'])
+ resp, body = self.client.show_health_monitor(
+ self.health_monitor['id'])
+ health_monitor = body['health_monitor']
+ resp, body = self.client.show_pool(self.pool['id'])
+ pool = body['pool']
+ self.assertIn(pool['id'],
+ [p['pool_id'] for p in health_monitor['pools']])
+ self.assertIn(health_monitor['id'], pool['health_monitors'])
# Verify that a health monitor can be disassociated from a pool
resp, body = (self.client.disassociate_health_monitor_with_pool
(self.health_monitor['id'], self.pool['id']))
self.assertEqual('204', resp['status'])
+ resp, body = self.client.show_pool(self.pool['id'])
+ pool = body['pool']
+ resp, body = self.client.show_health_monitor(
+ self.health_monitor['id'])
+ health_monitor = body['health_monitor']
+ self.assertNotIn(health_monitor['id'], pool['health_monitors'])
+ self.assertNotIn(pool['id'],
+ [p['pool_id'] for p in health_monitor['pools']])
@test.attr(type='smoke')
def test_get_lb_pool_stats(self):
diff --git a/tempest/api/orchestration/stacks/test_nova_keypair_resources.py b/tempest/api/orchestration/stacks/test_nova_keypair_resources.py
new file mode 100644
index 0000000..9d3bf13
--- /dev/null
+++ b/tempest/api/orchestration/stacks/test_nova_keypair_resources.py
@@ -0,0 +1,181 @@
+# 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 logging
+
+from tempest.api.orchestration import base
+from tempest.common.utils import data_utils
+from tempest.test import attr
+
+
+LOG = logging.getLogger(__name__)
+
+
+class NovaKeyPairResourcesYAMLTest(base.BaseOrchestrationTest):
+ _interface = 'json'
+ template = """
+heat_template_version: 2013-05-23
+
+description: >
+ Template which creates two key pairs.
+
+parameters:
+ KeyPairName1:
+ type: string
+ default: testkey
+
+ KeyPairName2:
+ type: string
+ default: testkey2
+
+resources:
+ KeyPairSavePrivate:
+ type: OS::Nova::KeyPair
+ properties:
+ name: { get_param: KeyPairName1 }
+ save_private_key: true
+
+ KeyPairDontSavePrivate:
+ type: OS::Nova::KeyPair
+ properties:
+ name: { get_param: KeyPairName2 }
+ save_private_key: false
+
+outputs:
+ KeyPair_PublicKey:
+ description: Public Key of generated keypair
+ value: { get_attr: [KeyPairSavePrivate, public_key] }
+
+ KeyPair_PrivateKey:
+ description: Private Key of generated keypair
+ value: { get_attr: [KeyPairSavePrivate, private_key] }
+
+ KeyPairDontSavePrivate_PublicKey:
+ description: Public Key of generated keypair
+ value: { get_attr: [KeyPairDontSavePrivate, public_key] }
+
+ KeyPairDontSavePrivate_PrivateKey:
+ description: Private Key of generated keypair
+ value: { get_attr: [KeyPairDontSavePrivate, private_key] }
+"""
+
+ @classmethod
+ def setUpClass(cls):
+ super(NovaKeyPairResourcesYAMLTest, cls).setUpClass()
+ cls.client = cls.orchestration_client
+ cls.stack_name = data_utils.rand_name('heat')
+
+ # create the stack, avoid any duplicated key.
+ cls.stack_identifier = cls.create_stack(
+ cls.stack_name,
+ cls.template,
+ parameters={
+ 'KeyPairName1': cls.stack_name + '_1',
+ 'KeyPairName2': cls.stack_name + '_2'
+ })
+
+ cls.stack_id = cls.stack_identifier.split('/')[1]
+ cls.client.wait_for_stack_status(cls.stack_id, 'CREATE_COMPLETE')
+ _, resources = cls.client.list_resources(cls.stack_identifier)
+ cls.test_resources = {}
+ for resource in resources:
+ cls.test_resources[resource['logical_resource_id']] = resource
+
+ @attr(type='slow')
+ def test_created_resources(self):
+ """Verifies created keypair resource."""
+ resources = [('KeyPairSavePrivate', 'OS::Nova::KeyPair'),
+ ('KeyPairDontSavePrivate', 'OS::Nova::KeyPair')]
+
+ for resource_name, resource_type in resources:
+ resource = self.test_resources.get(resource_name, None)
+ self.assertIsInstance(resource, dict)
+ self.assertEqual(resource_name, resource['logical_resource_id'])
+ self.assertEqual(resource_type, resource['resource_type'])
+ self.assertEqual('CREATE_COMPLETE', resource['resource_status'])
+
+ @attr(type='slow')
+ def test_stack_keypairs_output(self):
+ resp, stack = self.client.get_stack(self.stack_name)
+ self.assertEqual('200', resp['status'])
+ self.assertIsInstance(stack, dict)
+
+ output_map = {}
+ for outputs in stack['outputs']:
+ output_map[outputs['output_key']] = outputs['output_value']
+ #Test that first key generated public and private keys
+ self.assertTrue('KeyPair_PublicKey' in output_map)
+ self.assertTrue("Generated by" in output_map['KeyPair_PublicKey'])
+ self.assertTrue('KeyPair_PrivateKey' in output_map)
+ self.assertTrue('-----BEGIN' in output_map['KeyPair_PrivateKey'])
+ #Test that second key generated public key, and private key is not
+ #in the output due to save_private_key = false
+ self.assertTrue('KeyPairDontSavePrivate_PublicKey' in output_map)
+ self.assertTrue('Generated by' in
+ output_map['KeyPairDontSavePrivate_PublicKey'])
+ self.assertTrue(u'KeyPairDontSavePrivate_PrivateKey' in output_map)
+ private_key = output_map['KeyPairDontSavePrivate_PrivateKey']
+ self.assertTrue(len(private_key) == 0)
+
+
+class NovaKeyPairResourcesAWSTest(NovaKeyPairResourcesYAMLTest):
+ template = """
+{
+ "AWSTemplateFormatVersion" : "2010-09-09",
+ "Description" : "Template which create two key pairs.",
+ "Parameters" : {
+ "KeyPairName1": {
+ "Type": "String",
+ "Default": "testkey1"
+ },
+ "KeyPairName2": {
+ "Type": "String",
+ "Default": "testkey2"
+ }
+ },
+ "Resources" : {
+ "KeyPairSavePrivate": {
+ "Type": "OS::Nova::KeyPair",
+ "Properties": {
+ "name" : { "Ref" : "KeyPairName1" },
+ "save_private_key": true
+ }
+ },
+ "KeyPairDontSavePrivate": {
+ "Type": "OS::Nova::KeyPair",
+ "Properties": {
+ "name" : { "Ref" : "KeyPairName2" },
+ "save_private_key": false
+ }
+ }
+ },
+ "Outputs": {
+ "KeyPair_PublicKey": {
+ "Description": "Public Key of generated keypair.",
+ "Value": { "Fn::GetAtt" : ["KeyPairSavePrivate", "public_key"] }
+ },
+ "KeyPair_PrivateKey": {
+ "Description": "Private Key of generated keypair.",
+ "Value": { "Fn::GetAtt" : ["KeyPairSavePrivate", "private_key"] }
+ },
+ "KeyPairDontSavePrivate_PublicKey": {
+ "Description": "Public Key of generated keypair.",
+ "Value": { "Fn::GetAtt" : ["KeyPairDontSavePrivate", "public_key"] }
+ },
+ "KeyPairDontSavePrivate_PrivateKey": {
+ "Description": "Private Key of generated keypair.",
+ "Value": { "Fn::GetAtt" : ["KeyPairDontSavePrivate", "private_key"] }
+ }
+ }
+}
+"""
diff --git a/tempest/api/orchestration/stacks/test_server_cfn_init.py b/tempest/api/orchestration/stacks/test_server_cfn_init.py
index 5130f87..7e8bc2d 100644
--- a/tempest/api/orchestration/stacks/test_server_cfn_init.py
+++ b/tempest/api/orchestration/stacks/test_server_cfn_init.py
@@ -154,8 +154,8 @@
sid = self.stack_identifier
rid = 'SmokeServer'
- # wait for server resource create to complete.
- self.client.wait_for_resource_status(sid, rid, 'CREATE_COMPLETE')
+ # wait for create to complete.
+ self.client.wait_for_stack_status(sid, 'CREATE_COMPLETE')
resp, body = self.client.get_resource(sid, rid)
self.assertEqual('CREATE_COMPLETE', body['resource_status'])
diff --git a/tempest/api/queuing/__init__.py b/tempest/api/queuing/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/api/queuing/__init__.py
diff --git a/tempest/api/queuing/base.py b/tempest/api/queuing/base.py
new file mode 100644
index 0000000..5656850
--- /dev/null
+++ b/tempest/api/queuing/base.py
@@ -0,0 +1,49 @@
+# Copyright (c) 2014 Rackspace, Inc.
+#
+# 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 import config
+from tempest.openstack.common import log as logging
+from tempest import test
+
+CONF = config.CONF
+
+LOG = logging.getLogger(__name__)
+
+
+class BaseQueuingTest(test.BaseTestCase):
+
+ """
+ Base class for the Queuing tests that use the Tempest Marconi REST client
+
+ It is assumed that the following option is defined in the
+ [service_available] section of etc/tempest.conf
+
+ queuing as True
+ """
+
+ @classmethod
+ def setUpClass(cls):
+ super(BaseQueuingTest, cls).setUpClass()
+ if not CONF.service_available.marconi:
+ raise cls.skipException("Marconi support is required")
+ os = cls.get_client_manager()
+ cls.queuing_cfg = CONF.queuing
+ cls.client = os.queuing_client
+
+ @classmethod
+ def create_queue(cls, queue_name):
+ """Wrapper utility that returns a test queue."""
+ resp, body = cls.client.create_queue(queue_name)
+ return resp, body
diff --git a/tempest/api/queuing/test_queues.py b/tempest/api/queuing/test_queues.py
new file mode 100644
index 0000000..6934b46
--- /dev/null
+++ b/tempest/api/queuing/test_queues.py
@@ -0,0 +1,37 @@
+# Copyright (c) 2014 Rackspace, Inc.
+#
+# 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 logging
+
+from tempest.api.queuing import base
+from tempest.common.utils import data_utils
+from tempest import test
+
+
+LOG = logging.getLogger(__name__)
+
+
+class TestQueues(base.BaseQueuingTest):
+
+ @test.attr(type='smoke')
+ def test_create_queue(self):
+ # Create Queue
+ queue_name = data_utils.rand_name('test-')
+ resp, body = self.create_queue(queue_name)
+
+ self.addCleanup(self.client.delete_queue, queue_name)
+
+ self.assertEqual('201', resp['status'])
+ self.assertEqual('', body)
diff --git a/tempest/api/volume/admin/test_volume_quotas.py b/tempest/api/volume/admin/test_volume_quotas.py
new file mode 100644
index 0000000..31f6730
--- /dev/null
+++ b/tempest/api/volume/admin/test_volume_quotas.py
@@ -0,0 +1,99 @@
+# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
+#
+# Author: Sylvain Baubeau <sylvain.baubeau@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.
+
+from tempest.api.volume import base
+from tempest import test
+
+QUOTA_KEYS = ['gigabytes', 'snapshots', 'volumes']
+QUOTA_USAGE_KEYS = ['reserved', 'limit', 'in_use']
+
+
+class VolumeQuotasAdminTestJSON(base.BaseVolumeV1AdminTest):
+ _interface = "json"
+
+ @classmethod
+ def setUpClass(cls):
+ super(VolumeQuotasAdminTestJSON, cls).setUpClass()
+ cls.admin_volume_client = cls.os_adm.volumes_client
+ cls.demo_tenant_id = cls.isolated_creds.get_primary_user().get(
+ 'tenantId')
+
+ @test.attr(type='gate')
+ def test_list_quotas(self):
+ resp, quotas = self.quotas_client.get_quota_set(self.demo_tenant_id)
+ self.assertEqual(200, resp.status)
+ for key in QUOTA_KEYS:
+ self.assertIn(key, quotas)
+
+ @test.attr(type='gate')
+ def test_list_default_quotas(self):
+ resp, quotas = self.quotas_client.get_default_quota_set(
+ self.demo_tenant_id)
+ self.assertEqual(200, resp.status)
+ for key in QUOTA_KEYS:
+ self.assertIn(key, quotas)
+
+ @test.attr(type='gate')
+ def test_update_all_quota_resources_for_tenant(self):
+ # Admin can update all the resource quota limits for a tenant
+ resp, default_quota_set = self.quotas_client.get_default_quota_set(
+ self.demo_tenant_id)
+ new_quota_set = {'gigabytes': 1009,
+ 'volumes': 11,
+ 'snapshots': 11}
+
+ # Update limits for all quota resources
+ resp, quota_set = self.quotas_client.update_quota_set(
+ self.demo_tenant_id,
+ **new_quota_set)
+
+ default_quota_set.pop('id')
+ self.addCleanup(self.quotas_client.update_quota_set,
+ self.demo_tenant_id, **default_quota_set)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(new_quota_set, quota_set)
+
+ @test.attr(type='gate')
+ def test_show_quota_usage(self):
+ resp, quota_usage = self.quotas_client.get_quota_usage(self.adm_tenant)
+ self.assertEqual(200, resp.status)
+ for key in QUOTA_KEYS:
+ self.assertIn(key, quota_usage)
+ for usage_key in QUOTA_USAGE_KEYS:
+ self.assertIn(usage_key, quota_usage[key])
+
+ @test.attr(type='gate')
+ def test_quota_usage(self):
+ resp, quota_usage = self.quotas_client.get_quota_usage(
+ self.demo_tenant_id)
+
+ volume = self.create_volume(size=1)
+ self.addCleanup(self.admin_volume_client.delete_volume,
+ volume['id'])
+
+ resp, new_quota_usage = self.quotas_client.get_quota_usage(
+ self.demo_tenant_id)
+
+ self.assertEqual(200, resp.status)
+ self.assertEqual(quota_usage['volumes']['in_use'] + 1,
+ new_quota_usage['volumes']['in_use'])
+
+ self.assertEqual(quota_usage['gigabytes']['in_use'] + 1,
+ new_quota_usage['gigabytes']['in_use'])
+
+
+class VolumeQuotasAdminTestXML(VolumeQuotasAdminTestJSON):
+ _interface = "xml"
diff --git a/tempest/api/volume/admin/test_volumes_backup.py b/tempest/api/volume/admin/test_volumes_backup.py
index 9af4011..cd6d7a8 100644
--- a/tempest/api/volume/admin/test_volumes_backup.py
+++ b/tempest/api/volume/admin/test_volumes_backup.py
@@ -38,7 +38,8 @@
cls.volume = cls.create_volume()
@test.attr(type='smoke')
- def test_volume_backup_create_get_restore_delete(self):
+ def test_volume_backup_create_get_detailed_list_restore_delete(self):
+ # Create backup
backup_name = data_utils.rand_name('Backup')
create_backup = self.backups_adm_client.create_backup
resp, backup = create_backup(self.volume['id'],
@@ -46,21 +47,31 @@
self.assertEqual(202, resp.status)
self.addCleanup(self.backups_adm_client.delete_backup,
backup['id'])
- self.assertEqual(backup['name'], backup_name)
+ self.assertEqual(backup_name, backup['name'])
self.volumes_adm_client.wait_for_volume_status(self.volume['id'],
'available')
self.backups_adm_client.wait_for_backup_status(backup['id'],
'available')
+ # Get a given backup
resp, backup = self.backups_adm_client.get_backup(backup['id'])
self.assertEqual(200, resp.status)
- self.assertEqual(backup['name'], backup_name)
+ self.assertEqual(backup_name, backup['name'])
+ # Get all backups with detail
+ resp, backups = self.backups_adm_client.list_backups_with_detail()
+ self.assertEqual(200, resp.status)
+ self.assertIn((backup['name'], backup['id']),
+ [(m['name'], m['id']) for m in backups])
+
+ # Restore backup
resp, restore = self.backups_adm_client.restore_backup(backup['id'])
self.assertEqual(202, resp.status)
+
+ # Delete backup
self.addCleanup(self.volumes_adm_client.delete_volume,
restore['volume_id'])
- self.assertEqual(restore['backup_id'], backup['id'])
+ self.assertEqual(backup['id'], restore['backup_id'])
self.backups_adm_client.wait_for_backup_status(backup['id'],
'available')
self.volumes_adm_client.wait_for_volume_status(restore['volume_id'],
diff --git a/tempest/api/volume/base.py b/tempest/api/volume/base.py
index 8824977..2c6050c 100644
--- a/tempest/api/volume/base.py
+++ b/tempest/api/volume/base.py
@@ -145,6 +145,7 @@
cls.os_adm = clients.AdminManager(interface=cls._interface)
cls.client = cls.os_adm.volume_types_client
cls.hosts_client = cls.os_adm.volume_hosts_client
+ cls.quotas_client = cls.os_adm.volume_quotas_client
class BaseVolumeV2Test(BaseVolumeTest):
diff --git a/tempest/clients.py b/tempest/clients.py
index e16d0f4..ab7deb0 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -152,12 +152,15 @@
ObjectClientCustomizedHeader
from tempest.services.orchestration.json.orchestration_client import \
OrchestrationClient
+from tempest.services.queuing.json.queuing_client import QueuingClientJSON
from tempest.services.telemetry.json.telemetry_client import \
TelemetryClientJSON
from tempest.services.telemetry.xml.telemetry_client import \
TelemetryClientXML
from tempest.services.volume.json.admin.volume_hosts_client import \
VolumeHostsClientJSON
+from tempest.services.volume.json.admin.volume_quotas_client import \
+ VolumeQuotasClientJSON
from tempest.services.volume.json.admin.volume_types_client import \
VolumeTypesClientJSON
from tempest.services.volume.json.backups_client import BackupsClientJSON
@@ -169,6 +172,8 @@
from tempest.services.volume.v2.xml.volumes_client import VolumesV2ClientXML
from tempest.services.volume.xml.admin.volume_hosts_client import \
VolumeHostsClientXML
+from tempest.services.volume.xml.admin.volume_quotas_client import \
+ VolumeQuotasClientXML
from tempest.services.volume.xml.admin.volume_types_client import \
VolumeTypesClientXML
from tempest.services.volume.xml.backups_client import BackupsClientXML
@@ -249,6 +254,8 @@
InstanceUsagesAuditLogClientXML(self.auth_provider)
self.volume_hosts_client = VolumeHostsClientXML(
self.auth_provider)
+ self.volume_quotas_client = VolumeQuotasClientXML(
+ self.auth_provider)
self.volumes_extension_client = VolumeExtensionClientXML(
self.auth_provider)
if CONF.service_available.ceilometer:
@@ -329,11 +336,14 @@
InstanceUsagesAuditLogClientJSON(self.auth_provider)
self.volume_hosts_client = VolumeHostsClientJSON(
self.auth_provider)
+ self.volume_quotas_client = VolumeQuotasClientJSON(
+ self.auth_provider)
self.volumes_extension_client = VolumeExtensionClientJSON(
self.auth_provider)
self.hosts_v3_client = HostsV3ClientJSON(self.auth_provider)
self.database_flavors_client = DatabaseFlavorsClientJSON(
self.auth_provider)
+ self.queuing_client = QueuingClientJSON(self.auth_provider)
if CONF.service_available.ceilometer:
self.telemetry_client = TelemetryClientJSON(
self.auth_provider)
diff --git a/tempest/common/generate_json.py b/tempest/common/generate_json.py
deleted file mode 100644
index c8e86dc..0000000
--- a/tempest/common/generate_json.py
+++ /dev/null
@@ -1,265 +0,0 @@
-# Copyright 2014 Red Hat, Inc. & Deutsche Telekom AG
-# 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 copy
-import jsonschema
-
-from tempest.openstack.common import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def generate_valid(schema):
- """
- Create a valid dictionary based on the types in a json schema.
- """
- LOG.debug("generate_valid: %s" % schema)
- schema_type = schema["type"]
- if isinstance(schema_type, list):
- # Just choose the first one since all are valid.
- schema_type = schema_type[0]
- return type_map_valid[schema_type](schema)
-
-
-def generate_valid_string(schema):
- size = schema.get("minLength", 0)
- # TODO(dkr mko): handle format and pattern
- return "x" * size
-
-
-def generate_valid_integer(schema):
- # TODO(dkr mko): handle multipleOf
- if "minimum" in schema:
- minimum = schema["minimum"]
- if "exclusiveMinimum" not in schema:
- return minimum
- else:
- return minimum + 1
- if "maximum" in schema:
- maximum = schema["maximum"]
- if "exclusiveMaximum" not in schema:
- return maximum
- else:
- return maximum - 1
- return 0
-
-
-def generate_valid_object(schema):
- obj = {}
- for k, v in schema["properties"].iteritems():
- obj[k] = generate_valid(v)
- return obj
-
-
-def generate_invalid(schema):
- """
- Generate an invalid json dictionary based on a schema.
- Only one value is mis-generated for each dictionary created.
-
- Any generator must return a list of tuples or a single tuple.
- The values of this tuple are:
- result[0]: Name of the test
- result[1]: json schema for the test
- result[2]: expected result of the test (can be None)
- """
- LOG.debug("generate_invalid: %s" % schema)
- schema_type = schema["type"]
- if isinstance(schema_type, list):
- if "integer" in schema_type:
- schema_type = "integer"
- else:
- raise Exception("non-integer list types not supported")
- result = []
- for generator in type_map_invalid[schema_type]:
- ret = generator(schema)
- if ret is not None:
- if isinstance(ret, list):
- result.extend(ret)
- elif isinstance(ret, tuple):
- result.append(ret)
- else:
- raise Exception("generator (%s) returns invalid result"
- % generator)
- LOG.debug("result: %s" % result)
- return result
-
-
-def _check_for_expected_result(name, schema):
- expected_result = None
- if "results" in schema:
- if name in schema["results"]:
- expected_result = schema["results"][name]
- return expected_result
-
-
-def generator(fn):
- """
- Decorator for simple generators that simply return one value
- """
- def wrapped(schema):
- result = fn(schema)
- if result is not None:
- expected_result = _check_for_expected_result(fn.__name__, schema)
- return (fn.__name__, result, expected_result)
- return
- return wrapped
-
-
-@generator
-def gen_int(_):
- return 4
-
-
-@generator
-def gen_string(_):
- return "XXXXXX"
-
-
-def gen_none(schema):
- # Note(mkoderer): it's not using the decorator otherwise it'd be filtered
- expected_result = _check_for_expected_result('gen_none', schema)
- return ('gen_none', None, expected_result)
-
-
-@generator
-def gen_str_min_length(schema):
- min_length = schema.get("minLength", 0)
- if min_length > 0:
- return "x" * (min_length - 1)
-
-
-@generator
-def gen_str_max_length(schema):
- max_length = schema.get("maxLength", -1)
- if max_length > -1:
- return "x" * (max_length + 1)
-
-
-@generator
-def gen_int_min(schema):
- if "minimum" in schema:
- minimum = schema["minimum"]
- if "exclusiveMinimum" not in schema:
- minimum -= 1
- return minimum
-
-
-@generator
-def gen_int_max(schema):
- if "maximum" in schema:
- maximum = schema["maximum"]
- if "exclusiveMaximum" not in schema:
- maximum += 1
- return maximum
-
-
-def gen_obj_remove_attr(schema):
- invalids = []
- valid = generate_valid(schema)
- required = schema.get("required", [])
- for r in required:
- new_valid = copy.deepcopy(valid)
- del new_valid[r]
- invalids.append(("gen_obj_remove_attr", new_valid, None))
- return invalids
-
-
-@generator
-def gen_obj_add_attr(schema):
- valid = generate_valid(schema)
- if not schema.get("additionalProperties", True):
- new_valid = copy.deepcopy(valid)
- new_valid["$$$$$$$$$$"] = "xxx"
- return new_valid
-
-
-def gen_inv_prop_obj(schema):
- LOG.debug("generate_invalid_object: %s" % schema)
- valid = generate_valid(schema)
- invalids = []
- properties = schema["properties"]
-
- for k, v in properties.iteritems():
- for invalid in generate_invalid(v):
- LOG.debug(v)
- new_valid = copy.deepcopy(valid)
- new_valid[k] = invalid[1]
- name = "prop_%s_%s" % (k, invalid[0])
- invalids.append((name, new_valid, invalid[2]))
-
- LOG.debug("generate_invalid_object return: %s" % invalids)
- return invalids
-
-
-type_map_valid = {
- "string": generate_valid_string,
- "integer": generate_valid_integer,
- "object": generate_valid_object
-}
-
-type_map_invalid = {
- "string": [
- gen_int,
- gen_none,
- gen_str_min_length,
- gen_str_max_length],
- "integer": [
- gen_string,
- gen_none,
- gen_int_min,
- gen_int_max],
- "object": [
- gen_obj_remove_attr,
- gen_obj_add_attr,
- gen_inv_prop_obj]
-}
-
-schema = {
- "type": "object",
- "properties": {
- "name": {"type": "string"},
- "http-method": {
- "enum": ["GET", "PUT", "HEAD",
- "POST", "PATCH", "DELETE", 'COPY']
- },
- "url": {"type": "string"},
- "json-schema": jsonschema._utils.load_schema("draft4"),
- "resources": {
- "type": "array",
- "items": {
- "oneOf": [
- {"type": "string"},
- {
- "type": "object",
- "properties": {
- "name": {"type": "string"},
- "expected_result": {"type": "integer"}
- }
- }
- ]
- }
- },
- "results": {
- "type": "object",
- "properties": {}
- }
- },
- "required": ["name", "http-method", "url"],
- "additionalProperties": False,
-}
-
-
-def validate_negative_test_schema(nts):
- jsonschema.validate(nts, schema)
diff --git a/tempest/common/generator/__init__.py b/tempest/common/generator/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/common/generator/__init__.py
diff --git a/tempest/common/generator/base_generator.py b/tempest/common/generator/base_generator.py
new file mode 100644
index 0000000..7e7a2d6
--- /dev/null
+++ b/tempest/common/generator/base_generator.py
@@ -0,0 +1,143 @@
+# Copyright 2014 Deutsche Telekom AG
+# 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 jsonschema
+
+from tempest.openstack.common import log as logging
+
+LOG = logging.getLogger(__name__)
+
+
+def _check_for_expected_result(name, schema):
+ expected_result = None
+ if "results" in schema:
+ if name in schema["results"]:
+ expected_result = schema["results"][name]
+ return expected_result
+
+
+def generator_type(*args):
+ def wrapper(func):
+ func.types = args
+ return func
+ return wrapper
+
+
+def simple_generator(fn):
+ """
+ Decorator for simple generators that return one value
+ """
+ def wrapped(self, schema):
+ result = fn(self, schema)
+ if result is not None:
+ expected_result = _check_for_expected_result(fn.__name__, schema)
+ return (fn.__name__, result, expected_result)
+ return
+ return wrapped
+
+
+class BasicGeneratorSet(object):
+ _instance = None
+
+ schema = {
+ "type": "object",
+ "properties": {
+ "name": {"type": "string"},
+ "http-method": {
+ "enum": ["GET", "PUT", "HEAD",
+ "POST", "PATCH", "DELETE", 'COPY']
+ },
+ "admin_client": {"type": "boolean"},
+ "url": {"type": "string"},
+ "default_result_code": {"type": "integer"},
+ "json-schema": jsonschema._utils.load_schema("draft4"),
+ "resources": {
+ "type": "array",
+ "items": {
+ "oneOf": [
+ {"type": "string"},
+ {
+ "type": "object",
+ "properties": {
+ "name": {"type": "string"},
+ "expected_result": {"type": "integer"}
+ }
+ }
+ ]
+ }
+ },
+ "results": {
+ "type": "object",
+ "properties": {}
+ }
+ },
+ "required": ["name", "http-method", "url"],
+ "additionalProperties": False,
+ }
+
+ def __new__(cls, *args, **kwargs):
+ if not cls._instance:
+ cls._instance = super(BasicGeneratorSet, cls).__new__(cls, *args,
+ **kwargs)
+ return cls._instance
+
+ def __init__(self):
+ self.types_dict = {}
+ for m in dir(self):
+ if callable(getattr(self, m)) and not'__' in m:
+ method = getattr(self, m)
+ if hasattr(method, "types"):
+ for type in method.types:
+ if type not in self.types_dict:
+ self.types_dict[type] = []
+ self.types_dict[type].append(method)
+
+ def validate_schema(self, schema):
+ jsonschema.validate(schema, self.schema)
+
+ def generate(self, schema):
+ """
+ Generate an json dictionary based on a schema.
+ Only one value is mis-generated for each dictionary created.
+
+ Any generator must return a list of tuples or a single tuple.
+ The values of this tuple are:
+ result[0]: Name of the test
+ result[1]: json schema for the test
+ result[2]: expected result of the test (can be None)
+ """
+ LOG.debug("generate_invalid: %s" % schema)
+ schema_type = schema["type"]
+ if isinstance(schema_type, list):
+ if "integer" in schema_type:
+ schema_type = "integer"
+ else:
+ raise Exception("non-integer list types not supported")
+ result = []
+ if schema_type not in self.types_dict:
+ raise Exception("generator (%s) doesn't support type: %s"
+ % (self.__class__.__name__, schema_type))
+ for generator in self.types_dict[schema_type]:
+ ret = generator(schema)
+ if ret is not None:
+ if isinstance(ret, list):
+ result.extend(ret)
+ elif isinstance(ret, tuple):
+ result.append(ret)
+ else:
+ raise Exception("generator (%s) returns invalid result: %s"
+ % (generator, ret))
+ LOG.debug("result: %s" % result)
+ return result
diff --git a/tempest/common/generator/negative_generator.py b/tempest/common/generator/negative_generator.py
new file mode 100644
index 0000000..4f3d2cd
--- /dev/null
+++ b/tempest/common/generator/negative_generator.py
@@ -0,0 +1,111 @@
+# Copyright 2014 Deutsche Telekom AG
+# 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 copy
+
+import tempest.common.generator.base_generator as base
+import tempest.common.generator.valid_generator as valid
+from tempest.openstack.common import log as logging
+
+LOG = logging.getLogger(__name__)
+
+
+class NegativeTestGenerator(base.BasicGeneratorSet):
+ @base.generator_type("string")
+ @base.simple_generator
+ def gen_int(self, _):
+ return 4
+
+ @base.generator_type("integer")
+ @base.simple_generator
+ def gen_string(self, _):
+ return "XXXXXX"
+
+ @base.generator_type("integer", "string")
+ def gen_none(self, schema):
+ # Note(mkoderer): it's not using the decorator otherwise it'd be
+ # filtered
+ expected_result = base._check_for_expected_result('gen_none', schema)
+ return ('gen_none', None, expected_result)
+
+ @base.generator_type("string")
+ @base.simple_generator
+ def gen_str_min_length(self, schema):
+ min_length = schema.get("minLength", 0)
+ if min_length > 0:
+ return "x" * (min_length - 1)
+
+ @base.generator_type("string")
+ @base.simple_generator
+ def gen_str_max_length(self, schema):
+ max_length = schema.get("maxLength", -1)
+ if max_length > -1:
+ return "x" * (max_length + 1)
+
+ @base.generator_type("integer")
+ @base.simple_generator
+ def gen_int_min(self, schema):
+ if "minimum" in schema:
+ minimum = schema["minimum"]
+ if "exclusiveMinimum" not in schema:
+ minimum -= 1
+ return minimum
+
+ @base.generator_type("integer")
+ @base.simple_generator
+ def gen_int_max(self, schema):
+ if "maximum" in schema:
+ maximum = schema["maximum"]
+ if "exclusiveMaximum" not in schema:
+ maximum += 1
+ return maximum
+
+ @base.generator_type("object")
+ def gen_obj_remove_attr(self, schema):
+ invalids = []
+ valid_schema = valid.ValidTestGenerator().generate_valid(schema)
+ required = schema.get("required", [])
+ for r in required:
+ new_valid = copy.deepcopy(valid_schema)
+ del new_valid[r]
+ invalids.append(("gen_obj_remove_attr", new_valid, None))
+ return invalids
+
+ @base.generator_type("object")
+ @base.simple_generator
+ def gen_obj_add_attr(self, schema):
+ valid_schema = valid.ValidTestGenerator().generate_valid(schema)
+ if not schema.get("additionalProperties", True):
+ new_valid = copy.deepcopy(valid_schema)
+ new_valid["$$$$$$$$$$"] = "xxx"
+ return new_valid
+
+ @base.generator_type("object")
+ def gen_inv_prop_obj(self, schema):
+ LOG.debug("generate_invalid_object: %s" % schema)
+ valid_schema = valid.ValidTestGenerator().generate_valid(schema)
+ invalids = []
+ properties = schema["properties"]
+
+ for k, v in properties.iteritems():
+ for invalid in self.generate(v):
+ LOG.debug(v)
+ new_valid = copy.deepcopy(valid_schema)
+ new_valid[k] = invalid[1]
+ name = "prop_%s_%s" % (k, invalid[0])
+ invalids.append((name, new_valid, invalid[2]))
+
+ LOG.debug("generate_invalid_object return: %s" % invalids)
+ return invalids
diff --git a/tempest/common/generator/valid_generator.py b/tempest/common/generator/valid_generator.py
new file mode 100644
index 0000000..a99bbc0
--- /dev/null
+++ b/tempest/common/generator/valid_generator.py
@@ -0,0 +1,58 @@
+# Copyright 2014 Deutsche Telekom AG
+# 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 tempest.common.generator.base_generator as base
+from tempest.openstack.common import log as logging
+
+
+LOG = logging.getLogger(__name__)
+
+
+class ValidTestGenerator(base.BasicGeneratorSet):
+ @base.generator_type("string")
+ @base.simple_generator
+ def generate_valid_string(self, schema):
+ size = schema.get("minLength", 0)
+ # TODO(dkr mko): handle format and pattern
+ return "x" * size
+
+ @base.generator_type("integer")
+ @base.simple_generator
+ def generate_valid_integer(self, schema):
+ # TODO(dkr mko): handle multipleOf
+ if "minimum" in schema:
+ minimum = schema["minimum"]
+ if "exclusiveMinimum" not in schema:
+ return minimum
+ else:
+ return minimum + 1
+ if "maximum" in schema:
+ maximum = schema["maximum"]
+ if "exclusiveMaximum" not in schema:
+ return maximum
+ else:
+ return maximum - 1
+ return 0
+
+ @base.generator_type("object")
+ @base.simple_generator
+ def generate_valid_object(self, schema):
+ obj = {}
+ for k, v in schema["properties"].iteritems():
+ obj[k] = self.generate_valid(v)
+ return obj
+
+ def generate_valid(self, schema):
+ return self.generate(schema)[0][1]
diff --git a/tempest/common/rest_client.py b/tempest/common/rest_client.py
index 66b6fe7..36ddb40 100644
--- a/tempest/common/rest_client.py
+++ b/tempest/common/rest_client.py
@@ -409,7 +409,7 @@
elif ctype.lower() in TXT_ENC:
parse_resp = False
else:
- raise exceptions.RestClientException(str(resp.status))
+ raise exceptions.InvalidContentType(str(resp.status))
if resp.status == 401 or resp.status == 403:
raise exceptions.Unauthorized()
@@ -451,25 +451,26 @@
# exception.
raise exceptions.InvalidHTTPResponseBody(message)
else:
- # I'm seeing both computeFault
- # and cloudServersFault come back.
- # Will file a bug to fix, but leave as is for now.
- if 'cloudServersFault' in resp_body:
- message = resp_body['cloudServersFault']['message']
- elif 'computeFault' in resp_body:
- message = resp_body['computeFault']['message']
- elif 'error' in resp_body: # Keystone errors
- message = resp_body['error']['message']
- raise exceptions.IdentityError(message)
- elif 'message' in resp_body:
- message = resp_body['message']
+ if isinstance(resp_body, dict):
+ # I'm seeing both computeFault
+ # and cloudServersFault come back.
+ # Will file a bug to fix, but leave as is for now.
+ if 'cloudServersFault' in resp_body:
+ message = resp_body['cloudServersFault']['message']
+ elif 'computeFault' in resp_body:
+ message = resp_body['computeFault']['message']
+ elif 'error' in resp_body: # Keystone errors
+ message = resp_body['error']['message']
+ raise exceptions.IdentityError(message)
+ elif 'message' in resp_body:
+ message = resp_body['message']
+ else:
+ message = resp_body
raise exceptions.ServerFault(message)
if resp.status >= 400:
- if parse_resp:
- resp_body = self._parse_resp(resp_body)
- raise exceptions.RestClientException(str(resp.status))
+ raise exceptions.UnexpectedResponseCode(str(resp.status))
def is_absolute_limit(self, resp, resp_body):
if (not isinstance(resp_body, collections.Mapping) or
diff --git a/tempest/common/utils/data_utils.py b/tempest/common/utils/data_utils.py
index cd32720..a0a88dd 100644
--- a/tempest/common/utils/data_utils.py
+++ b/tempest/common/utils/data_utils.py
@@ -15,12 +15,8 @@
import itertools
import random
-import re
-import urllib
import uuid
-from tempest import exceptions
-
def rand_uuid():
return str(uuid.uuid4())
@@ -57,37 +53,6 @@
return ':'.join(["%02x" % x for x in mac])
-def build_url(host, port, api_version=None, path=None,
- params=None, use_ssl=False):
- """Build the request URL from given host, port, path and parameters."""
-
- pattern = 'v\d\.\d'
- if re.match(pattern, path):
- message = 'Version should not be included in path.'
- raise exceptions.InvalidConfiguration(message=message)
-
- if use_ssl:
- url = "https://" + host
- else:
- url = "http://" + host
-
- if port is not None:
- url += ":" + port
- url += "/"
-
- if api_version is not None:
- url += api_version + "/"
-
- if path is not None:
- url += path
-
- if params is not None:
- url += "?"
- url += urllib.urlencode(params)
-
- return url
-
-
def parse_image_id(image_ref):
"""Return the image id from a given image ref."""
return image_ref.rsplit('/')[-1]
diff --git a/tempest/config.py b/tempest/config.py
index 0c33233..46dcbcc 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -381,6 +381,15 @@
'entry all which indicates every extension is enabled'),
]
+queuing_group = cfg.OptGroup(name='queuing',
+ title='Queuing Service')
+
+QueuingGroup = [
+ cfg.StrOpt('catalog_type',
+ default='queuing',
+ help='Catalog type of the Queuing service.'),
+]
+
volume_group = cfg.OptGroup(name='volume',
title='Block Storage Options')
@@ -753,6 +762,9 @@
cfg.BoolOpt('trove',
default=False,
help="Whether or not Trove is expected to be available"),
+ cfg.BoolOpt('marconi',
+ default=False,
+ help="Whether or not Marconi is expected to be available"),
]
debug_group = cfg.OptGroup(name="debug",
@@ -820,6 +832,15 @@
help="Number of seconds to wait on a CLI timeout"),
]
+negative_group = cfg.OptGroup(name='negative', title="Negative Test Options")
+
+NegativeGroup = [
+ cfg.StrOpt('test_generator',
+ default='tempest.common.' +
+ 'generator.negative_generator.NegativeTestGenerator',
+ help="Test generator class for all negative tests"),
+]
+
def register_opts():
register_opt_group(cfg.CONF, compute_group, ComputeGroup)
@@ -833,6 +854,7 @@
register_opt_group(cfg.CONF, network_group, NetworkGroup)
register_opt_group(cfg.CONF, network_feature_group,
NetworkFeaturesGroup)
+ register_opt_group(cfg.CONF, queuing_group, QueuingGroup)
register_opt_group(cfg.CONF, volume_group, VolumeGroup)
register_opt_group(cfg.CONF, volume_feature_group,
VolumeFeaturesGroup)
@@ -855,6 +877,7 @@
register_opt_group(cfg.CONF, baremetal_group, BaremetalGroup)
register_opt_group(cfg.CONF, input_scenario_group, InputScenarioGroup)
register_opt_group(cfg.CONF, cli_group, CLIGroup)
+ register_opt_group(cfg.CONF, negative_group, NegativeGroup)
# this should never be called outside of this class
@@ -883,6 +906,7 @@
'object-storage-feature-enabled']
self.database = cfg.CONF.database
self.orchestration = cfg.CONF.orchestration
+ self.queuing = cfg.CONF.queuing
self.telemetry = cfg.CONF.telemetry
self.dashboard = cfg.CONF.dashboard
self.data_processing = cfg.CONF.data_processing
@@ -895,6 +919,7 @@
self.baremetal = cfg.CONF.baremetal
self.input_scenario = cfg.CONF['input-scenario']
self.cli = cfg.CONF.cli
+ self.negative = cfg.CONF.negative
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/exceptions/__init__.py b/tempest/exceptions/__init__.py
index c95f94f..06dee71 100644
--- a/tempest/exceptions/__init__.py
+++ b/tempest/exceptions/__init__.py
@@ -146,3 +146,11 @@
class InvalidHTTPResponseBody(base.RestClientException):
message = "HTTP response body is invalid json or xml"
+
+
+class InvalidContentType(base.RestClientException):
+ message = "Invalid content type provided"
+
+
+class UnexpectedResponseCode(base.RestClientException):
+ message = "Unexpected response code received"
diff --git a/tempest/scenario/test_network_basic_ops.py b/tempest/scenario/test_network_basic_ops.py
index e441415..489b271 100644
--- a/tempest/scenario/test_network_basic_ops.py
+++ b/tempest/scenario/test_network_basic_ops.py
@@ -276,24 +276,46 @@
ipatxt = ssh_client.get_ip_list()
return reg.findall(ipatxt)
- def _check_network_internal_connectivity(self):
+ def _check_network_internal_connectivity(self, network):
"""
via ssh check VM internal connectivity:
- - ping internal DHCP port, implying in-tenant connectivty
+ - ping internal gateway and DHCP port, implying in-tenant connectivity
+ pinging both, because L3 and DHCP agents might be on different nodes
"""
floating_ip, server = self.floating_ip_tuple
# get internal ports' ips:
# get all network ports in the new network
internal_ips = (p['fixed_ips'][0]['ip_address'] for p in
self._list_ports(tenant_id=server.tenant_id,
- network_id=self.new_net.id)
+ network_id=network.id)
if p['device_owner'].startswith('network'))
+ self._check_server_connectivity(floating_ip, internal_ips)
+
+ def _check_network_external_connectivity(self):
+ """
+ ping public network default gateway to imply external connectivity
+
+ """
+ if not CONF.network.public_network_id:
+ msg = 'public network not defined.'
+ LOG.info(msg)
+ return
+
+ subnet = self.network_client.list_subnets(
+ network_id=CONF.network.public_network_id)['subnets']
+ self.assertEqual(1, len(subnet), "Found %d subnets" % len(subnet))
+
+ external_ips = [subnet[0]['gateway_ip']]
+ self._check_server_connectivity(self.floating_ip_tuple.floating_ip,
+ external_ips)
+
+ def _check_server_connectivity(self, floating_ip, address_list):
ip_address = floating_ip.floating_ip_address
- private_key = self.servers[server].private_key
+ private_key = self.servers[self.floating_ip_tuple.server].private_key
ssh_source = self._ssh_to_server(ip_address, private_key)
- for remote_ip in internal_ips:
+ for remote_ip in address_list:
try:
self.assertTrue(self._check_remote_connectivity(ssh_source,
remote_ip),
@@ -322,14 +344,6 @@
ssh server hosted at the IP address. This check guarantees
that the IP address is associated with the target VM.
- - detach the floating-ip from the VM and verify that it becomes
- unreachable
-
- - associate detached floating ip to a new VM and verify connectivity.
- VMs are created with unique keypair so connectivity also asserts that
- floating IP is associated with the new VM instead of the old one
-
- # TODO(mnewby) - Need to implement the following:
- the Tempest host can ssh into the VM via the IP address and
successfully execute the following:
@@ -341,8 +355,18 @@
- ping an internal IP address, implying connectivity to another
VM on the same network.
+ - detach the floating-ip from the VM and verify that it becomes
+ unreachable
+
+ - associate detached floating ip to a new VM and verify connectivity.
+ VMs are created with unique keypair so connectivity also asserts that
+ floating IP is associated with the new VM instead of the old one
+
+
"""
self._check_public_network_connectivity(should_connect=True)
+ self._check_network_internal_connectivity(network=self.network)
+ self._check_network_external_connectivity()
self._disassociate_floating_ips()
self._check_public_network_connectivity(should_connect=False,
msg="after disassociate "
@@ -367,4 +391,4 @@
self._check_public_network_connectivity(should_connect=True)
self._create_new_network()
self._hotplug_server()
- self._check_network_internal_connectivity()
+ self._check_network_internal_connectivity(network=self.new_net)
diff --git a/tempest/services/compute/v3/json/aggregates_client.py b/tempest/services/compute/v3/json/aggregates_client.py
index 20ce87b..fddf5df 100644
--- a/tempest/services/compute/v3/json/aggregates_client.py
+++ b/tempest/services/compute/v3/json/aggregates_client.py
@@ -15,14 +15,14 @@
import json
-from tempest.common.rest_client import RestClient
+from tempest.common import rest_client
from tempest import config
from tempest import exceptions
CONF = config.CONF
-class AggregatesV3ClientJSON(RestClient):
+class AggregatesV3ClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(AggregatesV3ClientJSON, self).__init__(auth_provider)
diff --git a/tempest/services/compute/v3/json/availability_zone_client.py b/tempest/services/compute/v3/json/availability_zone_client.py
index 4a6db55..bad2de9 100644
--- a/tempest/services/compute/v3/json/availability_zone_client.py
+++ b/tempest/services/compute/v3/json/availability_zone_client.py
@@ -15,13 +15,13 @@
import json
-from tempest.common.rest_client import RestClient
+from tempest.common import rest_client
from tempest import config
CONF = config.CONF
-class AvailabilityZoneV3ClientJSON(RestClient):
+class AvailabilityZoneV3ClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(AvailabilityZoneV3ClientJSON, self).__init__(
diff --git a/tempest/services/compute/v3/json/certificates_client.py b/tempest/services/compute/v3/json/certificates_client.py
index 620eedf..f8beeb9 100644
--- a/tempest/services/compute/v3/json/certificates_client.py
+++ b/tempest/services/compute/v3/json/certificates_client.py
@@ -15,13 +15,13 @@
import json
-from tempest.common.rest_client import RestClient
+from tempest.common import rest_client
from tempest import config
CONF = config.CONF
-class CertificatesV3ClientJSON(RestClient):
+class CertificatesV3ClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(CertificatesV3ClientJSON, self).__init__(auth_provider)
diff --git a/tempest/services/compute/v3/json/extensions_client.py b/tempest/services/compute/v3/json/extensions_client.py
index 54f0aba..46f17a4 100644
--- a/tempest/services/compute/v3/json/extensions_client.py
+++ b/tempest/services/compute/v3/json/extensions_client.py
@@ -15,13 +15,13 @@
import json
-from tempest.common.rest_client import RestClient
+from tempest.common import rest_client
from tempest import config
CONF = config.CONF
-class ExtensionsV3ClientJSON(RestClient):
+class ExtensionsV3ClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(ExtensionsV3ClientJSON, self).__init__(auth_provider)
diff --git a/tempest/services/compute/v3/json/flavors_client.py b/tempest/services/compute/v3/json/flavors_client.py
index f9df2b8..656bd84 100644
--- a/tempest/services/compute/v3/json/flavors_client.py
+++ b/tempest/services/compute/v3/json/flavors_client.py
@@ -16,13 +16,13 @@
import json
import urllib
-from tempest.common.rest_client import RestClient
+from tempest.common import rest_client
from tempest import config
CONF = config.CONF
-class FlavorsV3ClientJSON(RestClient):
+class FlavorsV3ClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(FlavorsV3ClientJSON, self).__init__(auth_provider)
diff --git a/tempest/services/compute/v3/json/hosts_client.py b/tempest/services/compute/v3/json/hosts_client.py
index 76af626..e27c7c6 100644
--- a/tempest/services/compute/v3/json/hosts_client.py
+++ b/tempest/services/compute/v3/json/hosts_client.py
@@ -15,13 +15,13 @@
import json
import urllib
-from tempest.common.rest_client import RestClient
+from tempest.common import rest_client
from tempest import config
CONF = config.CONF
-class HostsV3ClientJSON(RestClient):
+class HostsV3ClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(HostsV3ClientJSON, self).__init__(auth_provider)
diff --git a/tempest/services/compute/v3/json/hypervisor_client.py b/tempest/services/compute/v3/json/hypervisor_client.py
index e07a1fb..30e391f 100644
--- a/tempest/services/compute/v3/json/hypervisor_client.py
+++ b/tempest/services/compute/v3/json/hypervisor_client.py
@@ -15,13 +15,13 @@
import json
-from tempest.common.rest_client import RestClient
+from tempest.common import rest_client
from tempest import config
CONF = config.CONF
-class HypervisorV3ClientJSON(RestClient):
+class HypervisorV3ClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(HypervisorV3ClientJSON, self).__init__(auth_provider)
diff --git a/tempest/services/compute/v3/json/interfaces_client.py b/tempest/services/compute/v3/json/interfaces_client.py
index f8b9d09..b45426c 100644
--- a/tempest/services/compute/v3/json/interfaces_client.py
+++ b/tempest/services/compute/v3/json/interfaces_client.py
@@ -16,14 +16,14 @@
import json
import time
-from tempest.common.rest_client import RestClient
+from tempest.common import rest_client
from tempest import config
from tempest import exceptions
CONF = config.CONF
-class InterfacesV3ClientJSON(RestClient):
+class InterfacesV3ClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(InterfacesV3ClientJSON, self).__init__(auth_provider)
diff --git a/tempest/services/compute/v3/json/keypairs_client.py b/tempest/services/compute/v3/json/keypairs_client.py
index 821b86f..9ca4885 100644
--- a/tempest/services/compute/v3/json/keypairs_client.py
+++ b/tempest/services/compute/v3/json/keypairs_client.py
@@ -15,13 +15,13 @@
import json
-from tempest.common.rest_client import RestClient
+from tempest.common import rest_client
from tempest import config
CONF = config.CONF
-class KeyPairsV3ClientJSON(RestClient):
+class KeyPairsV3ClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(KeyPairsV3ClientJSON, self).__init__(auth_provider)
diff --git a/tempest/services/compute/v3/json/quotas_client.py b/tempest/services/compute/v3/json/quotas_client.py
index aa8bfaf..32e31a3 100644
--- a/tempest/services/compute/v3/json/quotas_client.py
+++ b/tempest/services/compute/v3/json/quotas_client.py
@@ -15,13 +15,13 @@
import json
-from tempest.common.rest_client import RestClient
+from tempest.common import rest_client
from tempest import config
CONF = config.CONF
-class QuotasV3ClientJSON(RestClient):
+class QuotasV3ClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(QuotasV3ClientJSON, self).__init__(auth_provider)
diff --git a/tempest/services/compute/v3/json/servers_client.py b/tempest/services/compute/v3/json/servers_client.py
index b64495d..92eb09b 100644
--- a/tempest/services/compute/v3/json/servers_client.py
+++ b/tempest/services/compute/v3/json/servers_client.py
@@ -19,7 +19,7 @@
import time
import urllib
-from tempest.common.rest_client import RestClient
+from tempest.common import rest_client
from tempest.common import waiters
from tempest import config
from tempest import exceptions
@@ -27,7 +27,7 @@
CONF = config.CONF
-class ServersV3ClientJSON(RestClient):
+class ServersV3ClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(ServersV3ClientJSON, self).__init__(auth_provider)
diff --git a/tempest/services/compute/v3/json/services_client.py b/tempest/services/compute/v3/json/services_client.py
index e20dfde..b4e65a0 100644
--- a/tempest/services/compute/v3/json/services_client.py
+++ b/tempest/services/compute/v3/json/services_client.py
@@ -17,13 +17,13 @@
import json
import urllib
-from tempest.common.rest_client import RestClient
+from tempest.common import rest_client
from tempest import config
CONF = config.CONF
-class ServicesV3ClientJSON(RestClient):
+class ServicesV3ClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(ServicesV3ClientJSON, self).__init__(auth_provider)
diff --git a/tempest/services/image/v1/json/image_client.py b/tempest/services/image/v1/json/image_client.py
index 932fa14..e22cd9c 100644
--- a/tempest/services/image/v1/json/image_client.py
+++ b/tempest/services/image/v1/json/image_client.py
@@ -21,7 +21,7 @@
import urllib
from tempest.common import glance_http
-from tempest.common.rest_client import RestClient
+from tempest.common import rest_client
from tempest import config
from tempest import exceptions
from tempest.openstack.common import log as logging
@@ -31,7 +31,7 @@
LOG = logging.getLogger(__name__)
-class ImageClientJSON(RestClient):
+class ImageClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(ImageClientJSON, self).__init__(auth_provider)
diff --git a/tempest/services/network/json/network_client.py b/tempest/services/network/json/network_client.py
index 366ccee..a804e8e 100644
--- a/tempest/services/network/json/network_client.py
+++ b/tempest/services/network/json/network_client.py
@@ -12,7 +12,7 @@
import json
-from tempest.common.rest_client import RestClient
+from tempest.common import rest_client
from tempest.services.network import network_client_base
@@ -32,7 +32,7 @@
"""
def get_rest_client(self, auth_provider):
- return RestClient(auth_provider)
+ return rest_client.RestClient(auth_provider)
def deserialize_single(self, body):
return json.loads(body)
@@ -163,32 +163,6 @@
body = json.loads(body)
return resp, body
- def create_member(self, address, protocol_port, pool_id):
- post_body = {
- "member": {
- "protocol_port": protocol_port,
- "pool_id": pool_id,
- "address": address
- }
- }
- body = json.dumps(post_body)
- uri = '%s/lb/members' % (self.uri_prefix)
- resp, body = self.post(uri, body)
- body = json.loads(body)
- return resp, body
-
- def update_member(self, admin_state_up, member_id):
- put_body = {
- "member": {
- "admin_state_up": admin_state_up
- }
- }
- body = json.dumps(put_body)
- uri = '%s/lb/members/%s' % (self.uri_prefix, member_id)
- resp, body = self.put(uri, body)
- body = json.loads(body)
- return resp, body
-
def associate_health_monitor_with_pool(self, health_monitor_id,
pool_id):
post_body = {
@@ -280,6 +254,20 @@
body = json.loads(body)
return resp, body
+ def add_router_to_l3_agent(self, agent_id, router_id):
+ uri = '%s/agents/%s/l3-routers' % (self.uri_prefix, agent_id)
+ post_body = {"router_id": router_id}
+ body = json.dumps(post_body)
+ resp, body = self.post(uri, body)
+ body = json.loads(body)
+ return resp, body
+
+ def remove_router_from_l3_agent(self, agent_id, router_id):
+ uri = '%s/agents/%s/l3-routers/%s' % (
+ self.uri_prefix, agent_id, router_id)
+ resp, body = self.delete(uri)
+ return resp, body
+
def list_dhcp_agent_hosting_network(self, network_id):
uri = '%s/networks/%s/dhcp-agents' % (self.uri_prefix, network_id)
resp, body = self.get(uri)
diff --git a/tempest/services/network/xml/network_client.py b/tempest/services/network/xml/network_client.py
index 8152d71..2a5083c 100644
--- a/tempest/services/network/xml/network_client.py
+++ b/tempest/services/network/xml/network_client.py
@@ -23,7 +23,8 @@
# list of plurals used for xml serialization
PLURALS = ['dns_nameservers', 'host_routes', 'allocation_pools',
- 'fixed_ips', 'extensions', 'extra_dhcp_opts']
+ 'fixed_ips', 'extensions', 'extra_dhcp_opts', 'pools',
+ 'health_monitors', 'vips']
def get_rest_client(self, auth_provider):
rc = rest_client.RestClient(auth_provider)
@@ -92,28 +93,6 @@
root.add_attr('xmlns:%s' % element,
common.NEUTRON_NAMESPACES[element])
- def create_member(self, address, protocol_port, pool_id):
- uri = '%s/lb/members' % (self.uri_prefix)
- post_body = common.Element("member")
- p1 = common.Element("address", address)
- p2 = common.Element("protocol_port", protocol_port)
- p3 = common.Element("pool_id", pool_id)
- post_body.append(p1)
- post_body.append(p2)
- post_body.append(p3)
- resp, body = self.post(uri, str(common.Document(post_body)))
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def update_member(self, admin_state_up, member_id):
- uri = '%s/lb/members/%s' % (self.uri_prefix, str(member_id))
- put_body = common.Element("member")
- p2 = common.Element("admin_state_up", admin_state_up)
- put_body.append(p2)
- resp, body = self.put(uri, str(common.Document(put_body)))
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
def associate_health_monitor_with_pool(self, health_monitor_id,
pool_id):
uri = '%s/lb/pools/%s/health_monitors' % (self.uri_prefix,
@@ -248,15 +227,30 @@
def list_routers_on_l3_agent(self, agent_id):
uri = '%s/agents/%s/l3-routers' % (self.uri_prefix, agent_id)
resp, body = self.get(uri)
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
+ routers = common.parse_array(etree.fromstring(body))
+ body = {'routers': routers}
return resp, body
def list_l3_agents_hosting_router(self, router_id):
uri = '%s/routers/%s/l3-agents' % (self.uri_prefix, router_id)
resp, body = self.get(uri)
+ agents = common.parse_array(etree.fromstring(body))
+ body = {'agents': agents}
+ return resp, body
+
+ def add_router_to_l3_agent(self, agent_id, router_id):
+ uri = '%s/agents/%s/l3-routers' % (self.uri_prefix, agent_id)
+ router = (common.Element("router_id", router_id))
+ resp, body = self.post(uri, str(common.Document(router)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
+ def remove_router_from_l3_agent(self, agent_id, router_id):
+ uri = '%s/agents/%s/l3-routers/%s' % (
+ self.uri_prefix, agent_id, router_id)
+ resp, body = self.delete(uri)
+ return resp, body
+
def list_dhcp_agent_hosting_network(self, network_id):
uri = '%s/networks/%s/dhcp-agents' % (self.uri_prefix, network_id)
resp, body = self.get(uri)
diff --git a/tempest/services/object_storage/account_client.py b/tempest/services/object_storage/account_client.py
index be314cc..7c3fa85 100644
--- a/tempest/services/object_storage/account_client.py
+++ b/tempest/services/object_storage/account_client.py
@@ -17,7 +17,7 @@
import urllib
from tempest.common import http
-from tempest.common.rest_client import RestClient
+from tempest.common import rest_client
from tempest import config
from tempest import exceptions
from xml.etree import ElementTree as etree
@@ -25,7 +25,7 @@
CONF = config.CONF
-class AccountClient(RestClient):
+class AccountClient(rest_client.RestClient):
def __init__(self, auth_provider):
super(AccountClient, self).__init__(auth_provider)
self.service = CONF.object_storage.catalog_type
@@ -151,14 +151,14 @@
return resp, body
-class AccountClientCustomizedHeader(RestClient):
+class AccountClientCustomizedHeader(rest_client.RestClient):
# TODO(andreaf) This class is now redundant, to be removed in next patch
def __init__(self, auth_provider):
super(AccountClientCustomizedHeader, self).__init__(
auth_provider)
- # Overwrites json-specific header encoding in RestClient
+ # Overwrites json-specific header encoding in rest_client.RestClient
self.service = CONF.object_storage.catalog_type
self.format = 'json'
diff --git a/tempest/services/object_storage/container_client.py b/tempest/services/object_storage/container_client.py
index f224407..546b557 100644
--- a/tempest/services/object_storage/container_client.py
+++ b/tempest/services/object_storage/container_client.py
@@ -16,18 +16,18 @@
import json
import urllib
-from tempest.common.rest_client import RestClient
+from tempest.common import rest_client
from tempest import config
from xml.etree import ElementTree as etree
CONF = config.CONF
-class ContainerClient(RestClient):
+class ContainerClient(rest_client.RestClient):
def __init__(self, auth_provider):
super(ContainerClient, self).__init__(auth_provider)
- # Overwrites json-specific header encoding in RestClient
+ # Overwrites json-specific header encoding in rest_client.RestClient
self.headers = {}
self.service = CONF.object_storage.catalog_type
self.format = 'json'
diff --git a/tempest/services/object_storage/object_client.py b/tempest/services/object_storage/object_client.py
index 09e484e..77d29a5 100644
--- a/tempest/services/object_storage/object_client.py
+++ b/tempest/services/object_storage/object_client.py
@@ -16,14 +16,14 @@
import urllib
from tempest.common import http
-from tempest.common.rest_client import RestClient
+from tempest.common import rest_client
from tempest import config
from tempest import exceptions
CONF = config.CONF
-class ObjectClient(RestClient):
+class ObjectClient(rest_client.RestClient):
def __init__(self, auth_provider):
super(ObjectClient, self).__init__(auth_provider)
@@ -135,14 +135,14 @@
return resp, body
-class ObjectClientCustomizedHeader(RestClient):
+class ObjectClientCustomizedHeader(rest_client.RestClient):
# TODO(andreaf) This class is now redundant, to be removed in next patch
def __init__(self, auth_provider):
super(ObjectClientCustomizedHeader, self).__init__(
auth_provider)
- # Overwrites json-specific header encoding in RestClient
+ # Overwrites json-specific header encoding in rest_client.RestClient
self.service = CONF.object_storage.catalog_type
self.format = 'json'
diff --git a/tempest/services/queuing/__init__.py b/tempest/services/queuing/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/services/queuing/__init__.py
diff --git a/tempest/services/queuing/json/__init__.py b/tempest/services/queuing/json/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/services/queuing/json/__init__.py
diff --git a/tempest/services/queuing/json/queuing_client.py b/tempest/services/queuing/json/queuing_client.py
new file mode 100644
index 0000000..4a0c495
--- /dev/null
+++ b/tempest/services/queuing/json/queuing_client.py
@@ -0,0 +1,58 @@
+# Copyright (c) 2014 Rackspace, Inc.
+#
+# 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
+
+from tempest.common import rest_client
+from tempest import config
+
+CONF = config.CONF
+
+
+class QueuingClientJSON(rest_client.RestClient):
+
+ def __init__(self, auth_provider):
+ super(QueuingClientJSON, self).__init__(auth_provider)
+ self.service = CONF.queuing.catalog_type
+ self.version = '1'
+ self.uri_prefix = 'v{0}'.format(self.version)
+
+ def list_queues(self):
+ uri = '{0}/queues'.format(self.uri_prefix)
+ resp, body = self.get(uri)
+ body = json.loads(body)
+ return resp, body
+
+ def create_queue(self, queue_name):
+ uri = '{0}/queues/{1}'.format(self.uri_prefix, queue_name)
+ resp, body = self.put(uri, body=None)
+ return resp, body
+
+ def get_queue(self, queue_name):
+ uri = '{0}/queues/{1}'.format(self.uri_prefix, queue_name)
+ resp, body = self.get(uri)
+ body = json.loads(body)
+ return resp, body
+
+ def head_queue(self, queue_name):
+ uri = '{0}/queues/{1}'.format(self.uri_prefix, queue_name)
+ resp, body = self.head(uri)
+ body = json.loads(body)
+ return resp, body
+
+ def delete_queue(self, queue_name):
+ uri = '{0}/queues/{1}'.format(self.uri_prefix, queue_name)
+ resp = self.delete(uri)
+ return resp
diff --git a/tempest/services/telemetry/json/telemetry_client.py b/tempest/services/telemetry/json/telemetry_client.py
index e666475..996aceb 100644
--- a/tempest/services/telemetry/json/telemetry_client.py
+++ b/tempest/services/telemetry/json/telemetry_client.py
@@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest.common.rest_client import RestClient
+from tempest.common import rest_client
from tempest.openstack.common import jsonutils as json
import tempest.services.telemetry.telemetry_client_base as client
@@ -21,7 +21,7 @@
class TelemetryClientJSON(client.TelemetryClientBase):
def get_rest_client(self, auth_provider):
- return RestClient(auth_provider)
+ return rest_client.RestClient(auth_provider)
def deserialize(self, body):
return json.loads(body.replace("\n", ""))
diff --git a/tempest/services/telemetry/xml/telemetry_client.py b/tempest/services/telemetry/xml/telemetry_client.py
index 165f29a..673f98e 100644
--- a/tempest/services/telemetry/xml/telemetry_client.py
+++ b/tempest/services/telemetry/xml/telemetry_client.py
@@ -16,8 +16,7 @@
from lxml import etree
from tempest.common import rest_client
-from tempest.services.compute.xml.common import Document
-from tempest.services.compute.xml.common import xml_to_json
+from tempest.services.compute.xml import common
import tempest.services.telemetry.telemetry_client_base as client
@@ -32,11 +31,11 @@
def _parse_array(self, body):
array = []
for child in body.getchildren():
- array.append(xml_to_json(child))
+ array.append(common.xml_to_json(child))
return array
def serialize(self, body):
- return str(Document(body))
+ return str(common.Document(body))
def deserialize(self, body):
return self._parse_array(etree.fromstring(body))
diff --git a/tempest/services/volume/json/admin/volume_hosts_client.py b/tempest/services/volume/json/admin/volume_hosts_client.py
index 6efb258..84e4705 100644
--- a/tempest/services/volume/json/admin/volume_hosts_client.py
+++ b/tempest/services/volume/json/admin/volume_hosts_client.py
@@ -16,13 +16,13 @@
import json
import urllib
-from tempest.common.rest_client import RestClient
+from tempest.common import rest_client
from tempest import config
CONF = config.CONF
-class VolumeHostsClientJSON(RestClient):
+class VolumeHostsClientJSON(rest_client.RestClient):
"""
Client class to send CRUD Volume Hosts API requests to a Cinder endpoint
"""
diff --git a/tempest/services/volume/json/admin/volume_quotas_client.py b/tempest/services/volume/json/admin/volume_quotas_client.py
new file mode 100644
index 0000000..ea9c92e
--- /dev/null
+++ b/tempest/services/volume/json/admin/volume_quotas_client.py
@@ -0,0 +1,79 @@
+# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
+#
+# Author: Sylvain Baubeau <sylvain.baubeau@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 urllib
+
+from tempest.openstack.common import jsonutils
+
+from tempest.common import rest_client
+from tempest import config
+
+CONF = config.CONF
+
+
+class VolumeQuotasClientJSON(rest_client.RestClient):
+ """
+ Client class to send CRUD Volume Quotas API requests to a Cinder endpoint
+ """
+
+ TYPE = "json"
+
+ def __init__(self, auth_provider):
+ super(VolumeQuotasClientJSON, self).__init__(auth_provider)
+
+ self.service = CONF.volume.catalog_type
+ self.build_interval = CONF.volume.build_interval
+ self.build_timeout = CONF.volume.build_timeout
+
+ def get_default_quota_set(self, tenant_id):
+ """List the default volume quota set for a tenant."""
+
+ url = 'os-quota-sets/%s/defaults' % tenant_id
+ resp, body = self.get(url)
+ return resp, self._parse_resp(body)
+
+ def get_quota_set(self, tenant_id, params=None):
+ """List the quota set for a tenant."""
+
+ url = 'os-quota-sets/%s' % tenant_id
+ if params:
+ url += '?%s' % urllib.urlencode(params)
+
+ resp, body = self.get(url)
+ return resp, self._parse_resp(body)
+
+ def get_quota_usage(self, tenant_id):
+ """List the quota set for a tenant."""
+
+ resp, body = self.get_quota_set(tenant_id, params={'usage': True})
+ return resp, body
+
+ def update_quota_set(self, tenant_id, gigabytes=None, volumes=None,
+ snapshots=None):
+ post_body = {}
+
+ if gigabytes is not None:
+ post_body['gigabytes'] = gigabytes
+
+ if volumes is not None:
+ post_body['volumes'] = volumes
+
+ if snapshots is not None:
+ post_body['snapshots'] = snapshots
+
+ post_body = jsonutils.dumps({'quota_set': post_body})
+ resp, body = self.put('os-quota-sets/%s' % tenant_id, post_body)
+ return resp, self._parse_resp(body)
diff --git a/tempest/services/volume/json/admin/volume_types_client.py b/tempest/services/volume/json/admin/volume_types_client.py
index 0d50524..5554362 100644
--- a/tempest/services/volume/json/admin/volume_types_client.py
+++ b/tempest/services/volume/json/admin/volume_types_client.py
@@ -16,13 +16,13 @@
import json
import urllib
-from tempest.common.rest_client import RestClient
+from tempest.common import rest_client
from tempest import config
CONF = config.CONF
-class VolumeTypesClientJSON(RestClient):
+class VolumeTypesClientJSON(rest_client.RestClient):
"""
Client class to send CRUD Volume Types API requests to a Cinder endpoint
"""
diff --git a/tempest/services/volume/json/backups_client.py b/tempest/services/volume/json/backups_client.py
index baaf5a0..183d06b 100644
--- a/tempest/services/volume/json/backups_client.py
+++ b/tempest/services/volume/json/backups_client.py
@@ -69,6 +69,13 @@
body = json.loads(body)
return resp, body['backup']
+ def list_backups_with_detail(self):
+ """Information for all the tenant's backups."""
+ url = "backups/detail"
+ resp, body = self.get(url)
+ body = json.loads(body)
+ return resp, body['backups']
+
def wait_for_backup_status(self, backup_id, status):
"""Waits for a Backup to reach a given status."""
resp, body = self.get_backup(backup_id)
diff --git a/tempest/services/volume/json/extensions_client.py b/tempest/services/volume/json/extensions_client.py
index 257b7c8..9e182ea 100644
--- a/tempest/services/volume/json/extensions_client.py
+++ b/tempest/services/volume/json/extensions_client.py
@@ -15,13 +15,13 @@
import json
-from tempest.common.rest_client import RestClient
+from tempest.common import rest_client
from tempest import config
CONF = config.CONF
-class ExtensionsClientJSON(RestClient):
+class ExtensionsClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(ExtensionsClientJSON, self).__init__(auth_provider)
diff --git a/tempest/services/volume/json/snapshots_client.py b/tempest/services/volume/json/snapshots_client.py
index ba33c49..2dff63d 100644
--- a/tempest/services/volume/json/snapshots_client.py
+++ b/tempest/services/volume/json/snapshots_client.py
@@ -14,7 +14,7 @@
import time
import urllib
-from tempest.common.rest_client import RestClient
+from tempest.common import rest_client
from tempest import config
from tempest import exceptions
from tempest.openstack.common import log as logging
@@ -24,7 +24,7 @@
LOG = logging.getLogger(__name__)
-class SnapshotsClientJSON(RestClient):
+class SnapshotsClientJSON(rest_client.RestClient):
"""Client class to send CRUD Volume API requests."""
def __init__(self, auth_provider):
diff --git a/tempest/services/volume/json/volumes_client.py b/tempest/services/volume/json/volumes_client.py
index 2183c56..e4d2e8d 100644
--- a/tempest/services/volume/json/volumes_client.py
+++ b/tempest/services/volume/json/volumes_client.py
@@ -17,14 +17,14 @@
import time
import urllib
-from tempest.common.rest_client import RestClient
+from tempest.common import rest_client
from tempest import config
from tempest import exceptions
CONF = config.CONF
-class VolumesClientJSON(RestClient):
+class VolumesClientJSON(rest_client.RestClient):
"""
Client class to send CRUD Volume API requests to a Cinder endpoint
"""
diff --git a/tempest/services/volume/v2/json/volumes_client.py b/tempest/services/volume/v2/json/volumes_client.py
index bd98402..5bfa75f 100644
--- a/tempest/services/volume/v2/json/volumes_client.py
+++ b/tempest/services/volume/v2/json/volumes_client.py
@@ -17,14 +17,14 @@
import time
import urllib
-from tempest.common.rest_client import RestClient
+from tempest.common import rest_client
from tempest import config
from tempest import exceptions
CONF = config.CONF
-class VolumesV2ClientJSON(RestClient):
+class VolumesV2ClientJSON(rest_client.RestClient):
"""
Client class to send CRUD Volume V2 API requests to a Cinder endpoint
"""
diff --git a/tempest/services/volume/v2/xml/volumes_client.py b/tempest/services/volume/v2/xml/volumes_client.py
index bc57842..0b8f47c 100644
--- a/tempest/services/volume/v2/xml/volumes_client.py
+++ b/tempest/services/volume/v2/xml/volumes_client.py
@@ -21,11 +21,7 @@
from tempest.common import rest_client
from tempest import config
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
+from tempest.services.compute.xml import common
CONF = config.CONF
@@ -56,7 +52,7 @@
meta.text) for meta in
child.getchildren())
else:
- vol[tag] = xml_to_json(child)
+ vol[tag] = common.xml_to_json(child)
return vol
def get_attachment_from_volume(self, volume):
@@ -134,15 +130,15 @@
image
"""
# NOTE(afazekas): it should use a volume namespace
- volume = Element("volume", xmlns=XMLNS_11, size=size)
+ volume = common.Element("volume", xmlns=common.XMLNS_11, size=size)
if 'metadata' in kwargs:
- _metadata = Element('metadata')
+ _metadata = common.Element('metadata')
volume.append(_metadata)
for key, value in kwargs['metadata'].items():
- meta = Element('meta')
+ meta = common.Element('meta')
meta.add_attr('key', key)
- meta.append(Text(value))
+ meta.append(common.Text(value))
_metadata.append(meta)
attr_to_add = kwargs.copy()
del attr_to_add['metadata']
@@ -152,17 +148,17 @@
for key, value in attr_to_add.items():
volume.add_attr(key, value)
- resp, body = self.post('volumes', str(Document(volume)))
- body = xml_to_json(etree.fromstring(body))
+ resp, body = self.post('volumes', str(common.Document(volume)))
+ body = common.xml_to_json(etree.fromstring(body))
return resp, body
def update_volume(self, volume_id, **kwargs):
"""Updates the Specified Volume."""
- put_body = Element("volume", xmlns=XMLNS_11, **kwargs)
+ put_body = common.Element("volume", xmlns=common.XMLNS_11, **kwargs)
resp, body = self.put('volumes/%s' % volume_id,
- str(Document(put_body)))
- body = xml_to_json(etree.fromstring(body))
+ str(common.Document(put_body)))
+ body = common.xml_to_json(etree.fromstring(body))
return resp, body
def delete_volume(self, volume_id):
@@ -198,108 +194,107 @@
def attach_volume(self, volume_id, instance_uuid, mountpoint):
"""Attaches a volume to a given instance on a given mountpoint."""
- post_body = Element("os-attach",
- instance_uuid=instance_uuid,
- mountpoint=mountpoint
- )
+ post_body = common.Element("os-attach",
+ instance_uuid=instance_uuid,
+ mountpoint=mountpoint
+ )
url = 'volumes/%s/action' % str(volume_id)
- resp, body = self.post(url, str(Document(post_body)))
+ resp, body = self.post(url, str(common.Document(post_body)))
if body:
- body = xml_to_json(etree.fromstring(body))
+ body = common.xml_to_json(etree.fromstring(body))
return resp, body
def detach_volume(self, volume_id):
"""Detaches a volume from an instance."""
- post_body = Element("os-detach")
+ post_body = common.Element("os-detach")
url = 'volumes/%s/action' % str(volume_id)
- resp, body = self.post(url, str(Document(post_body)))
+ resp, body = self.post(url, str(common.Document(post_body)))
if body:
- body = xml_to_json(etree.fromstring(body))
+ body = common.xml_to_json(etree.fromstring(body))
return resp, body
def upload_volume(self, volume_id, image_name, disk_format):
"""Uploads a volume in Glance."""
- post_body = Element("os-volume_upload_image",
- image_name=image_name,
- disk_format=disk_format)
+ post_body = common.Element("os-volume_upload_image",
+ image_name=image_name,
+ disk_format=disk_format)
url = 'volumes/%s/action' % str(volume_id)
- resp, body = self.post(url, str(Document(post_body)))
- volume = xml_to_json(etree.fromstring(body))
+ resp, body = self.post(url, str(common.Document(post_body)))
+ volume = common.xml_to_json(etree.fromstring(body))
return resp, volume
def extend_volume(self, volume_id, extend_size):
"""Extend a volume."""
- post_body = Element("os-extend",
- new_size=extend_size)
+ post_body = common.Element("os-extend",
+ new_size=extend_size)
url = 'volumes/%s/action' % str(volume_id)
- resp, body = self.post(url, str(Document(post_body)))
+ resp, body = self.post(url, str(common.Document(post_body)))
if body:
- body = xml_to_json(etree.fromstring(body))
+ body = common.xml_to_json(etree.fromstring(body))
return resp, body
def reset_volume_status(self, volume_id, status):
"""Reset the Specified Volume's Status."""
- post_body = Element("os-reset_status",
- status=status
- )
+ post_body = common.Element("os-reset_status",
+ status=status
+ )
url = 'volumes/%s/action' % str(volume_id)
- resp, body = self.post(url, str(Document(post_body)))
+ resp, body = self.post(url, str(common.Document(post_body)))
if body:
- body = xml_to_json(etree.fromstring(body))
+ body = common.xml_to_json(etree.fromstring(body))
return resp, body
def volume_begin_detaching(self, volume_id):
"""Volume Begin Detaching."""
- post_body = Element("os-begin_detaching")
+ post_body = common.Element("os-begin_detaching")
url = 'volumes/%s/action' % str(volume_id)
- resp, body = self.post(url, str(Document(post_body)))
+ resp, body = self.post(url, str(common.Document(post_body)))
if body:
- body = xml_to_json(etree.fromstring(body))
+ body = common.xml_to_json(etree.fromstring(body))
return resp, body
def volume_roll_detaching(self, volume_id):
"""Volume Roll Detaching."""
- post_body = Element("os-roll_detaching")
+ post_body = common.Element("os-roll_detaching")
url = 'volumes/%s/action' % str(volume_id)
- resp, body = self.post(url, str(Document(post_body)))
+ resp, body = self.post(url, str(common.Document(post_body)))
if body:
- body = xml_to_json(etree.fromstring(body))
+ body = common.xml_to_json(etree.fromstring(body))
return resp, body
def reserve_volume(self, volume_id):
"""Reserves a volume."""
- post_body = Element("os-reserve")
+ post_body = common.Element("os-reserve")
url = 'volumes/%s/action' % str(volume_id)
- resp, body = self.post(url, str(Document(post_body)))
+ resp, body = self.post(url, str(common.Document(post_body)))
if body:
- body = xml_to_json(etree.fromstring(body))
+ body = common.xml_to_json(etree.fromstring(body))
return resp, body
def unreserve_volume(self, volume_id):
"""Restore a reserved volume ."""
- post_body = Element("os-unreserve")
+ post_body = common.Element("os-unreserve")
url = 'volumes/%s/action' % str(volume_id)
- resp, body = self.post(url, str(Document(post_body)))
+ resp, body = self.post(url, str(common.Document(post_body)))
if body:
- body = xml_to_json(etree.fromstring(body))
+ body = common.xml_to_json(etree.fromstring(body))
return resp, body
def create_volume_transfer(self, vol_id, name=None):
"""Create a volume transfer."""
- post_body = Element("transfer",
- volume_id=vol_id)
+ post_body = common.Element("transfer", volume_id=vol_id)
if name:
post_body.add_attr('name', name)
resp, body = self.post('os-volume-transfer',
- str(Document(post_body)))
- volume = xml_to_json(etree.fromstring(body))
+ str(common.Document(post_body)))
+ volume = common.xml_to_json(etree.fromstring(body))
return resp, volume
def get_volume_transfer(self, transfer_id):
"""Returns the details of a volume transfer."""
url = "os-volume-transfer/%s" % str(transfer_id)
resp, body = self.get(url)
- volume = xml_to_json(etree.fromstring(body))
+ volume = common.xml_to_json(etree.fromstring(body))
return resp, volume
def list_volume_transfers(self, params=None):
@@ -321,7 +316,7 @@
tag = child.tag
if tag.startswith("{"):
tag = tag.split("}", 1)
- vol[tag] = xml_to_json(child)
+ vol[tag] = common.xml_to_json(child)
return vol
def delete_volume_transfer(self, transfer_id):
@@ -330,36 +325,36 @@
def accept_volume_transfer(self, transfer_id, transfer_auth_key):
"""Accept a volume transfer."""
- post_body = Element("accept", auth_key=transfer_auth_key)
+ post_body = common.Element("accept", auth_key=transfer_auth_key)
url = 'os-volume-transfer/%s/accept' % transfer_id
- resp, body = self.post(url, str(Document(post_body)))
- volume = xml_to_json(etree.fromstring(body))
+ resp, body = self.post(url, str(common.Document(post_body)))
+ volume = common.xml_to_json(etree.fromstring(body))
return resp, volume
def update_volume_readonly(self, volume_id, readonly):
"""Update the Specified Volume readonly."""
- post_body = Element("os-update_readonly_flag",
- readonly=readonly)
+ post_body = common.Element("os-update_readonly_flag",
+ readonly=readonly)
url = 'volumes/%s/action' % str(volume_id)
- resp, body = self.post(url, str(Document(post_body)))
+ resp, body = self.post(url, str(common.Document(post_body)))
if body:
- body = xml_to_json(etree.fromstring(body))
+ body = common.xml_to_json(etree.fromstring(body))
return resp, body
def force_delete_volume(self, volume_id):
"""Force Delete Volume."""
- post_body = Element("os-force_delete")
+ post_body = common.Element("os-force_delete")
url = 'volumes/%s/action' % str(volume_id)
- resp, body = self.post(url, str(Document(post_body)))
+ resp, body = self.post(url, str(common.Document(post_body)))
if body:
- body = xml_to_json(etree.fromstring(body))
+ body = common.xml_to_json(etree.fromstring(body))
return resp, body
def _metadata_body(self, meta):
- post_body = Element('metadata')
+ post_body = common.Element('metadata')
for k, v in meta.items():
- data = Element('meta', key=k)
- data.append(Text(v))
+ data = common.Element('meta', key=k)
+ data.append(common.Text(v))
post_body.append(data)
return post_body
@@ -374,7 +369,7 @@
"""Create metadata for the volume."""
post_body = self._metadata_body(metadata)
resp, body = self.post('volumes/%s/metadata' % volume_id,
- str(Document(post_body)))
+ str(common.Document(post_body)))
body = self._parse_key_value(etree.fromstring(body))
return resp, body
@@ -389,18 +384,18 @@
"""Update metadata for the volume."""
put_body = self._metadata_body(metadata)
url = "volumes/%s/metadata" % str(volume_id)
- resp, body = self.put(url, str(Document(put_body)))
+ resp, body = self.put(url, str(common.Document(put_body)))
body = self._parse_key_value(etree.fromstring(body))
return resp, body
def update_volume_metadata_item(self, volume_id, id, meta_item):
"""Update metadata item for the volume."""
for k, v in meta_item.items():
- put_body = Element('meta', key=k)
- put_body.append(Text(v))
+ put_body = common.Element('meta', key=k)
+ put_body.append(common.Text(v))
url = "volumes/%s/metadata/%s" % (str(volume_id), str(id))
- resp, body = self.put(url, str(Document(put_body)))
- body = xml_to_json(etree.fromstring(body))
+ resp, body = self.put(url, str(common.Document(put_body)))
+ body = common.xml_to_json(etree.fromstring(body))
return resp, body
def delete_volume_metadata_item(self, volume_id, id):
diff --git a/tempest/services/volume/xml/admin/volume_hosts_client.py b/tempest/services/volume/xml/admin/volume_hosts_client.py
index fb84c83..e34b9f0 100644
--- a/tempest/services/volume/xml/admin/volume_hosts_client.py
+++ b/tempest/services/volume/xml/admin/volume_hosts_client.py
@@ -19,7 +19,7 @@
from tempest.common import rest_client
from tempest import config
-from tempest.services.compute.xml.common import xml_to_json
+from tempest.services.compute.xml import common
CONF = config.CONF
@@ -58,7 +58,7 @@
for child in node.getchildren():
tag_list = child.tag.split('}', 1)
if tag_list[0] == "host":
- array.append(xml_to_json(child))
+ array.append(common.xml_to_json(child))
return array
def list_hosts(self, params=None):
diff --git a/tempest/services/volume/xml/admin/volume_quotas_client.py b/tempest/services/volume/xml/admin/volume_quotas_client.py
new file mode 100644
index 0000000..d2eac34
--- /dev/null
+++ b/tempest/services/volume/xml/admin/volume_quotas_client.py
@@ -0,0 +1,70 @@
+# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
+#
+# Author: Sylvain Baubeau <sylvain.baubeau@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.
+
+from ast import literal_eval
+from lxml import etree
+
+from tempest import config
+from tempest.services.compute.xml import common as xml
+from tempest.services.volume.json.admin import volume_quotas_client
+
+CONF = config.CONF
+
+
+class VolumeQuotasClientXML(volume_quotas_client.VolumeQuotasClientJSON):
+ """
+ Client class to send CRUD Volume Quotas API requests to a Cinder endpoint
+ """
+
+ TYPE = "xml"
+
+ def _format_quota(self, q):
+ quota = {}
+ for k, v in q.items():
+ try:
+ v = literal_eval(v)
+ except (ValueError, SyntaxError):
+ pass
+
+ quota[k] = v
+
+ return quota
+
+ def get_quota_usage(self, tenant_id):
+ """List the quota set for a tenant."""
+
+ resp, body = self.get_quota_set(tenant_id, params={'usage': True})
+ return resp, self._format_quota(body)
+
+ def update_quota_set(self, tenant_id, gigabytes=None, volumes=None,
+ snapshots=None):
+ post_body = {}
+ element = xml.Element("quota_set")
+
+ if gigabytes is not None:
+ post_body['gigabytes'] = gigabytes
+
+ if volumes is not None:
+ post_body['volumes'] = volumes
+
+ if snapshots is not None:
+ post_body['snapshots'] = snapshots
+
+ xml.deep_dict_to_xml(element, post_body)
+ resp, body = self.put('os-quota-sets/%s' % tenant_id,
+ str(xml.Document(element)))
+ body = xml.xml_to_json(etree.fromstring(body))
+ return resp, self._format_quota(body)
diff --git a/tempest/services/volume/xml/admin/volume_types_client.py b/tempest/services/volume/xml/admin/volume_types_client.py
index 77bafec..1fa3e73 100644
--- a/tempest/services/volume/xml/admin/volume_types_client.py
+++ b/tempest/services/volume/xml/admin/volume_types_client.py
@@ -20,11 +20,7 @@
from tempest.common import rest_client
from tempest import config
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
+from tempest.services.compute.xml import common
CONF = config.CONF
@@ -53,7 +49,7 @@
meta.text)
for meta in list(child))
else:
- vol_type[tag] = xml_to_json(child)
+ vol_type[tag] = common.xml_to_json(child)
return vol_type
def _parse_volume_type_extra_specs(self, body):
@@ -64,7 +60,7 @@
if tag.startswith("{"):
ns, tag = tag.split("}", 1)
else:
- extra_spec[tag] = xml_to_json(child)
+ extra_spec[tag] = common.xml_to_json(child)
return extra_spec
def list_volume_types(self, params=None):
@@ -95,22 +91,22 @@
Following optional keyword arguments are accepted:
extra_specs: A dictionary of values to be used as extra_specs.
"""
- vol_type = Element("volume_type", xmlns=XMLNS_11)
+ vol_type = common.Element("volume_type", xmlns=common.XMLNS_11)
if name:
vol_type.add_attr('name', name)
extra_specs = kwargs.get('extra_specs')
if extra_specs:
- _extra_specs = Element('extra_specs')
+ _extra_specs = common.Element('extra_specs')
vol_type.append(_extra_specs)
for key, value in extra_specs.items():
- spec = Element('extra_spec')
+ spec = common.Element('extra_spec')
spec.add_attr('key', key)
- spec.append(Text(value))
+ spec.append(common.Text(value))
_extra_specs.append(spec)
- resp, body = self.post('types', str(Document(vol_type)))
- body = xml_to_json(etree.fromstring(body))
+ resp, body = self.post('types', str(common.Document(vol_type)))
+ body = common.xml_to_json(etree.fromstring(body))
return resp, body
def delete_volume_type(self, type_id):
@@ -147,21 +143,21 @@
extra_specs: A dictionary of values to be used as extra_specs.
"""
url = "types/%s/extra_specs" % str(vol_type_id)
- extra_specs = Element("extra_specs", xmlns=XMLNS_11)
+ extra_specs = common.Element("extra_specs", xmlns=common.XMLNS_11)
if extra_spec:
if isinstance(extra_spec, list):
extra_specs.append(extra_spec)
else:
for key, value in extra_spec.items():
- spec = Element('extra_spec')
+ spec = common.Element('extra_spec')
spec.add_attr('key', key)
- spec.append(Text(value))
+ spec.append(common.Text(value))
extra_specs.append(spec)
else:
extra_specs = None
- resp, body = self.post(url, str(Document(extra_specs)))
- body = xml_to_json(etree.fromstring(body))
+ resp, body = self.post(url, str(common.Document(extra_specs)))
+ body = common.xml_to_json(etree.fromstring(body))
return resp, body
def delete_volume_type_extra_specs(self, vol_id, extra_spec_name):
@@ -180,17 +176,17 @@
"""
url = "types/%s/extra_specs/%s" % (str(vol_type_id),
str(extra_spec_name))
- extra_specs = Element("extra_specs", xmlns=XMLNS_11)
+ extra_specs = common.Element("extra_specs", xmlns=common.XMLNS_11)
if extra_spec is not None:
for key, value in extra_spec.items():
- spec = Element('extra_spec')
+ spec = common.Element('extra_spec')
spec.add_attr('key', key)
- spec.append(Text(value))
+ spec.append(common.Text(value))
extra_specs.append(spec)
- resp, body = self.put(url, str(Document(extra_specs)))
- body = xml_to_json(etree.fromstring(body))
+ resp, body = self.put(url, str(common.Document(extra_specs)))
+ body = common.xml_to_json(etree.fromstring(body))
return resp, body
def is_resource_deleted(self, id):
diff --git a/tempest/services/volume/xml/extensions_client.py b/tempest/services/volume/xml/extensions_client.py
index 1ea974f..4861733 100644
--- a/tempest/services/volume/xml/extensions_client.py
+++ b/tempest/services/volume/xml/extensions_client.py
@@ -17,7 +17,7 @@
from tempest.common import rest_client
from tempest import config
-from tempest.services.compute.xml.common import xml_to_json
+from tempest.services.compute.xml import common
CONF = config.CONF
@@ -32,7 +32,7 @@
def _parse_array(self, node):
array = []
for child in node:
- array.append(xml_to_json(child))
+ array.append(common.xml_to_json(child))
return array
def list_extensions(self):
diff --git a/tempest/services/volume/xml/snapshots_client.py b/tempest/services/volume/xml/snapshots_client.py
index 458001b..9ad86d2 100644
--- a/tempest/services/volume/xml/snapshots_client.py
+++ b/tempest/services/volume/xml/snapshots_client.py
@@ -19,11 +19,7 @@
from tempest import config
from tempest import exceptions
from tempest.openstack.common import log as logging
-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
+from tempest.services.compute.xml import common
CONF = config.CONF
@@ -52,7 +48,7 @@
body = etree.fromstring(body)
snapshots = []
for snap in body:
- snapshots.append(xml_to_json(snap))
+ snapshots.append(common.xml_to_json(snap))
return resp, snapshots
def list_snapshots_with_detail(self, params=None):
@@ -66,7 +62,7 @@
body = etree.fromstring(body)
snapshots = []
for snap in body:
- snapshots.append(xml_to_json(snap))
+ snapshots.append(common.xml_to_json(snap))
return resp, snapshots
def get_snapshot(self, snapshot_id):
@@ -74,7 +70,7 @@
url = "snapshots/%s" % str(snapshot_id)
resp, body = self.get(url)
body = etree.fromstring(body)
- return resp, xml_to_json(body)
+ return resp, common.xml_to_json(body)
def create_snapshot(self, volume_id, **kwargs):
"""Creates a new snapshot.
@@ -84,20 +80,22 @@
display_description: User friendly snapshot description.
"""
# NOTE(afazekas): it should use the volume namespace
- snapshot = Element("snapshot", xmlns=XMLNS_11, volume_id=volume_id)
+ snapshot = common.Element("snapshot", xmlns=common.XMLNS_11,
+ volume_id=volume_id)
for key, value in kwargs.items():
snapshot.add_attr(key, value)
- resp, body = self.post('snapshots', str(Document(snapshot)))
- body = xml_to_json(etree.fromstring(body))
+ resp, body = self.post('snapshots',
+ str(common.Document(snapshot)))
+ body = common.xml_to_json(etree.fromstring(body))
return resp, body
def update_snapshot(self, snapshot_id, **kwargs):
"""Updates a snapshot."""
- put_body = Element("snapshot", xmlns=XMLNS_11, **kwargs)
+ put_body = common.Element("snapshot", xmlns=common.XMLNS_11, **kwargs)
resp, body = self.put('snapshots/%s' % snapshot_id,
- str(Document(put_body)))
- body = xml_to_json(etree.fromstring(body))
+ str(common.Document(put_body)))
+ body = common.xml_to_json(etree.fromstring(body))
return resp, body
# NOTE(afazekas): just for the wait function
@@ -150,32 +148,30 @@
def reset_snapshot_status(self, snapshot_id, status):
"""Reset the specified snapshot's status."""
- post_body = Element("os-reset_status",
- status=status
- )
+ post_body = common.Element("os-reset_status", status=status)
url = 'snapshots/%s/action' % str(snapshot_id)
- resp, body = self.post(url, str(Document(post_body)))
+ resp, body = self.post(url, str(common.Document(post_body)))
if body:
- body = xml_to_json(etree.fromstring(body))
+ body = common.xml_to_json(etree.fromstring(body))
return resp, body
def update_snapshot_status(self, snapshot_id, status, progress):
"""Update the specified snapshot's status."""
- post_body = Element("os-update_snapshot_status",
- status=status,
- progress=progress
- )
+ post_body = common.Element("os-update_snapshot_status",
+ status=status,
+ progress=progress
+ )
url = 'snapshots/%s/action' % str(snapshot_id)
- resp, body = self.post(url, str(Document(post_body)))
+ resp, body = self.post(url, str(common.Document(post_body)))
if body:
- body = xml_to_json(etree.fromstring(body))
+ body = common.xml_to_json(etree.fromstring(body))
return resp, body
def _metadata_body(self, meta):
- post_body = Element('metadata')
+ post_body = common.Element('metadata')
for k, v in meta.items():
- data = Element('meta', key=k)
- data.append(Text(v))
+ data = common.Element('meta', key=k)
+ data.append(common.Text(v))
post_body.append(data)
return post_body
@@ -190,7 +186,7 @@
"""Create metadata for the snapshot."""
post_body = self._metadata_body(metadata)
resp, body = self.post('snapshots/%s/metadata' % snapshot_id,
- str(Document(post_body)))
+ str(common.Document(post_body)))
body = self._parse_key_value(etree.fromstring(body))
return resp, body
@@ -205,18 +201,18 @@
"""Update metadata for the snapshot."""
put_body = self._metadata_body(metadata)
url = "snapshots/%s/metadata" % str(snapshot_id)
- resp, body = self.put(url, str(Document(put_body)))
+ resp, body = self.put(url, str(common.Document(put_body)))
body = self._parse_key_value(etree.fromstring(body))
return resp, body
def update_snapshot_metadata_item(self, snapshot_id, id, meta_item):
"""Update metadata item for the snapshot."""
for k, v in meta_item.items():
- put_body = Element('meta', key=k)
- put_body.append(Text(v))
+ put_body = common.Element('meta', key=k)
+ put_body.append(common.Text(v))
url = "snapshots/%s/metadata/%s" % (str(snapshot_id), str(id))
- resp, body = self.put(url, str(Document(put_body)))
- body = xml_to_json(etree.fromstring(body))
+ resp, body = self.put(url, str(common.Document(put_body)))
+ body = common.xml_to_json(etree.fromstring(body))
return resp, body
def delete_snapshot_metadata_item(self, snapshot_id, id):
@@ -226,9 +222,9 @@
def force_delete_snapshot(self, snapshot_id):
"""Force Delete Snapshot."""
- post_body = Element("os-force_delete")
+ post_body = common.Element("os-force_delete")
url = 'snapshots/%s/action' % str(snapshot_id)
- resp, body = self.post(url, str(Document(post_body)))
+ resp, body = self.post(url, str(common.Document(post_body)))
if body:
- body = xml_to_json(etree.fromstring(body))
+ body = common.xml_to_json(etree.fromstring(body))
return resp, body
diff --git a/tempest/services/volume/xml/volumes_client.py b/tempest/services/volume/xml/volumes_client.py
index aef1e3c..8e886ce 100644
--- a/tempest/services/volume/xml/volumes_client.py
+++ b/tempest/services/volume/xml/volumes_client.py
@@ -17,16 +17,12 @@
import urllib
from lxml import etree
-from xml.sax.saxutils import escape
+from xml.sax import saxutils
from tempest.common import rest_client
from tempest import config
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
+from tempest.services.compute.xml import common
CONF = config.CONF
@@ -55,7 +51,7 @@
meta.text) for meta in
child.getchildren())
else:
- vol[tag] = xml_to_json(child)
+ vol[tag] = common.xml_to_json(child)
return vol
def get_attachment_from_volume(self, volume):
@@ -135,15 +131,15 @@
image
"""
# NOTE(afazekas): it should use a volume namespace
- volume = Element("volume", xmlns=XMLNS_11, size=size)
+ volume = common.Element("volume", xmlns=common.XMLNS_11, size=size)
if 'metadata' in kwargs:
- _metadata = Element('metadata')
+ _metadata = common.Element('metadata')
volume.append(_metadata)
for key, value in kwargs['metadata'].items():
- meta = Element('meta')
+ meta = common.Element('meta')
meta.add_attr('key', key)
- meta.append(Text(value))
+ meta.append(common.Text(value))
_metadata.append(meta)
attr_to_add = kwargs.copy()
del attr_to_add['metadata']
@@ -153,17 +149,17 @@
for key, value in attr_to_add.items():
volume.add_attr(key, value)
- resp, body = self.post('volumes', str(Document(volume)))
- body = xml_to_json(etree.fromstring(body))
+ resp, body = self.post('volumes', str(common.Document(volume)))
+ body = common.xml_to_json(etree.fromstring(body))
return resp, body
def update_volume(self, volume_id, **kwargs):
"""Updates the Specified Volume."""
- put_body = Element("volume", xmlns=XMLNS_11, **kwargs)
+ put_body = common.Element("volume", xmlns=common.XMLNS_11, **kwargs)
resp, body = self.put('volumes/%s' % volume_id,
- str(Document(put_body)))
- body = xml_to_json(etree.fromstring(body))
+ str(common.Document(put_body)))
+ body = common.xml_to_json(etree.fromstring(body))
return resp, body
def delete_volume(self, volume_id):
@@ -199,108 +195,108 @@
def attach_volume(self, volume_id, instance_uuid, mountpoint):
"""Attaches a volume to a given instance on a given mountpoint."""
- post_body = Element("os-attach",
- instance_uuid=instance_uuid,
- mountpoint=mountpoint
- )
+ post_body = common.Element("os-attach",
+ instance_uuid=instance_uuid,
+ mountpoint=mountpoint
+ )
url = 'volumes/%s/action' % str(volume_id)
- resp, body = self.post(url, str(Document(post_body)))
+ resp, body = self.post(url, str(common.Document(post_body)))
if body:
- body = xml_to_json(etree.fromstring(body))
+ body = common.xml_to_json(etree.fromstring(body))
return resp, body
def detach_volume(self, volume_id):
"""Detaches a volume from an instance."""
- post_body = Element("os-detach")
+ post_body = common.Element("os-detach")
url = 'volumes/%s/action' % str(volume_id)
- resp, body = self.post(url, str(Document(post_body)))
+ resp, body = self.post(url, str(common.Document(post_body)))
if body:
- body = xml_to_json(etree.fromstring(body))
+ body = common.xml_to_json(etree.fromstring(body))
return resp, body
def upload_volume(self, volume_id, image_name, disk_format):
"""Uploads a volume in Glance."""
- post_body = Element("os-volume_upload_image",
- image_name=image_name,
- disk_format=disk_format)
+ post_body = common.Element("os-volume_upload_image",
+ image_name=image_name,
+ disk_format=disk_format)
url = 'volumes/%s/action' % str(volume_id)
- resp, body = self.post(url, str(Document(post_body)))
- volume = xml_to_json(etree.fromstring(body))
+ resp, body = self.post(url, str(common.Document(post_body)))
+ volume = common.xml_to_json(etree.fromstring(body))
return resp, volume
def extend_volume(self, volume_id, extend_size):
"""Extend a volume."""
- post_body = Element("os-extend",
- new_size=extend_size)
+ post_body = common.Element("os-extend",
+ new_size=extend_size)
url = 'volumes/%s/action' % str(volume_id)
- resp, body = self.post(url, str(Document(post_body)))
+ resp, body = self.post(url, str(common.Document(post_body)))
if body:
- body = xml_to_json(etree.fromstring(body))
+ body = common.xml_to_json(etree.fromstring(body))
return resp, body
def reset_volume_status(self, volume_id, status):
"""Reset the Specified Volume's Status."""
- post_body = Element("os-reset_status",
- status=status
- )
+ post_body = common.Element("os-reset_status",
+ status=status
+ )
url = 'volumes/%s/action' % str(volume_id)
- resp, body = self.post(url, str(Document(post_body)))
+ resp, body = self.post(url, str(common.Document(post_body)))
if body:
- body = xml_to_json(etree.fromstring(body))
+ body = common.xml_to_json(etree.fromstring(body))
return resp, body
def volume_begin_detaching(self, volume_id):
"""Volume Begin Detaching."""
- post_body = Element("os-begin_detaching")
+ post_body = common.Element("os-begin_detaching")
url = 'volumes/%s/action' % str(volume_id)
- resp, body = self.post(url, str(Document(post_body)))
+ resp, body = self.post(url, str(common.Document(post_body)))
if body:
- body = xml_to_json(etree.fromstring(body))
+ body = common.xml_to_json(etree.fromstring(body))
return resp, body
def volume_roll_detaching(self, volume_id):
"""Volume Roll Detaching."""
- post_body = Element("os-roll_detaching")
+ post_body = common.Element("os-roll_detaching")
url = 'volumes/%s/action' % str(volume_id)
- resp, body = self.post(url, str(Document(post_body)))
+ resp, body = self.post(url, str(common.Document(post_body)))
if body:
- body = xml_to_json(etree.fromstring(body))
+ body = common.xml_to_json(etree.fromstring(body))
return resp, body
def reserve_volume(self, volume_id):
"""Reserves a volume."""
- post_body = Element("os-reserve")
+ post_body = common.Element("os-reserve")
url = 'volumes/%s/action' % str(volume_id)
- resp, body = self.post(url, str(Document(post_body)))
+ resp, body = self.post(url, str(common.Document(post_body)))
if body:
- body = xml_to_json(etree.fromstring(body))
+ body = common.xml_to_json(etree.fromstring(body))
return resp, body
def unreserve_volume(self, volume_id):
"""Restore a reserved volume ."""
- post_body = Element("os-unreserve")
+ post_body = common.Element("os-unreserve")
url = 'volumes/%s/action' % str(volume_id)
- resp, body = self.post(url, str(Document(post_body)))
+ resp, body = self.post(url, str(common.Document(post_body)))
if body:
- body = xml_to_json(etree.fromstring(body))
+ body = common.xml_to_json(etree.fromstring(body))
return resp, body
def create_volume_transfer(self, vol_id, display_name=None):
"""Create a volume transfer."""
- post_body = Element("transfer",
- volume_id=vol_id)
+ post_body = common.Element("transfer",
+ volume_id=vol_id)
if display_name:
post_body.add_attr('name', display_name)
resp, body = self.post('os-volume-transfer',
- str(Document(post_body)))
- volume = xml_to_json(etree.fromstring(body))
+ str(common.Document(post_body)))
+ volume = common.xml_to_json(etree.fromstring(body))
return resp, volume
def get_volume_transfer(self, transfer_id):
"""Returns the details of a volume transfer."""
url = "os-volume-transfer/%s" % str(transfer_id)
resp, body = self.get(url)
- volume = xml_to_json(etree.fromstring(body))
+ volume = common.xml_to_json(etree.fromstring(body))
return resp, volume
def list_volume_transfers(self, params=None):
@@ -322,7 +318,7 @@
tag = child.tag
if tag.startswith("{"):
tag = tag.split("}", 1)
- vol[tag] = xml_to_json(child)
+ vol[tag] = common.xml_to_json(child)
return vol
def delete_volume_transfer(self, transfer_id):
@@ -331,37 +327,37 @@
def accept_volume_transfer(self, transfer_id, transfer_auth_key):
"""Accept a volume transfer."""
- post_body = Element("accept", auth_key=transfer_auth_key)
+ post_body = common.Element("accept", auth_key=transfer_auth_key)
url = 'os-volume-transfer/%s/accept' % transfer_id
- resp, body = self.post(url, str(Document(post_body)))
- volume = xml_to_json(etree.fromstring(body))
+ resp, body = self.post(url, str(common.Document(post_body)))
+ volume = common.xml_to_json(etree.fromstring(body))
return resp, volume
def update_volume_readonly(self, volume_id, readonly):
"""Update the Specified Volume readonly."""
- post_body = Element("os-update_readonly_flag",
- readonly=readonly)
+ post_body = common.Element("os-update_readonly_flag",
+ readonly=readonly)
url = 'volumes/%s/action' % str(volume_id)
- resp, body = self.post(url, str(Document(post_body)))
+ resp, body = self.post(url, str(common.Document(post_body)))
if body:
- body = xml_to_json(etree.fromstring(body))
+ body = common.xml_to_json(etree.fromstring(body))
return resp, body
def force_delete_volume(self, volume_id):
"""Force Delete Volume."""
- post_body = Element("os-force_delete")
+ post_body = common.Element("os-force_delete")
url = 'volumes/%s/action' % str(volume_id)
- resp, body = self.post(url, str(Document(post_body)))
+ resp, body = self.post(url, str(common.Document(post_body)))
if body:
- body = xml_to_json(etree.fromstring(body))
+ body = common.xml_to_json(etree.fromstring(body))
return resp, body
def _metadata_body(self, meta):
- post_body = Element('metadata')
+ post_body = common.Element('metadata')
for k, v in meta.items():
- data = Element('meta', key=k)
+ data = common.Element('meta', key=k)
# Escape value to allow for special XML chars
- data.append(Text(escape(v)))
+ data.append(common.Text(saxutils.escape(v)))
post_body.append(data)
return post_body
@@ -376,7 +372,7 @@
"""Create metadata for the volume."""
post_body = self._metadata_body(metadata)
resp, body = self.post('volumes/%s/metadata' % volume_id,
- str(Document(post_body)))
+ str(common.Document(post_body)))
body = self._parse_key_value(etree.fromstring(body))
return resp, body
@@ -391,18 +387,18 @@
"""Update metadata for the volume."""
put_body = self._metadata_body(metadata)
url = "volumes/%s/metadata" % str(volume_id)
- resp, body = self.put(url, str(Document(put_body)))
+ resp, body = self.put(url, str(common.Document(put_body)))
body = self._parse_key_value(etree.fromstring(body))
return resp, body
def update_volume_metadata_item(self, volume_id, id, meta_item):
"""Update metadata item for the volume."""
for k, v in meta_item.items():
- put_body = Element('meta', key=k)
- put_body.append(Text(v))
+ put_body = common.Element('meta', key=k)
+ put_body.append(common.Text(v))
url = "volumes/%s/metadata/%s" % (str(volume_id), str(id))
- resp, body = self.put(url, str(Document(put_body)))
- body = xml_to_json(etree.fromstring(body))
+ resp, body = self.put(url, str(common.Document(put_body)))
+ body = common.xml_to_json(etree.fromstring(body))
return resp, body
def delete_volume_metadata_item(self, volume_id, id):
diff --git a/tempest/test.py b/tempest/test.py
index c6e3d6e..20581ab 100644
--- a/tempest/test.py
+++ b/tempest/test.py
@@ -27,10 +27,11 @@
import testtools
from tempest import clients
-from tempest.common import generate_json
+import tempest.common.generator.valid_generator as valid
from tempest.common import isolated_creds
from tempest import config
from tempest import exceptions
+from tempest.openstack.common import importutils
from tempest.openstack.common import log as logging
LOG = logging.getLogger(__name__)
@@ -362,6 +363,9 @@
super(NegativeAutoTest, cls).setUpClass()
os = cls.get_client_manager()
cls.client = os.negative_client
+ os_admin = clients.AdminManager(interface=cls._interface,
+ service=cls._service)
+ cls.admin_client = os_admin.negative_client
@staticmethod
def load_schema(file):
@@ -400,7 +404,8 @@
"""
description = NegativeAutoTest.load_schema(description_file)
LOG.debug(description)
- generate_json.validate_negative_test_schema(description)
+ generator = importutils.import_class(CONF.negative.test_generator)()
+ generator.validate_schema(description)
schema = description.get("json-schema", None)
resources = description.get("resources", [])
scenario_list = []
@@ -416,10 +421,13 @@
"expected_result": expected_result
}))
if schema is not None:
- for invalid in generate_json.generate_invalid(schema):
- scenario_list.append((invalid[0],
- {"schema": invalid[1],
- "expected_result": invalid[2]}))
+ for name, schema, expected_result in generator.generate(schema):
+ if (expected_result is None and
+ "default_result_code" in description):
+ expected_result = description["default_result_code"]
+ scenario_list.append((name,
+ {"schema": schema,
+ "expected_result": expected_result}))
LOG.debug(scenario_list)
return scenario_list
@@ -459,16 +467,21 @@
# Note(mkoderer): The resources list already contains an invalid
# entry (see get_resource).
# We just send a valid json-schema with it
- valid = None
+ valid_schema = None
schema = description.get("json-schema", None)
if schema:
- valid = generate_json.generate_valid(schema)
- new_url, body = self._http_arguments(valid, url, method)
+ valid_schema = \
+ valid.ValidTestGenerator().generate_valid(schema)
+ new_url, body = self._http_arguments(valid_schema, url, method)
elif hasattr(self, "schema"):
new_url, body = self._http_arguments(self.schema, url, method)
- resp, resp_body = self.client.send_request(method, new_url,
- resources, body=body)
+ if "admin_client" in description and description["admin_client"]:
+ client = self.admin_client
+ else:
+ client = self.client
+ resp, resp_body = client.send_request(method, new_url,
+ resources, body=body)
self._check_negative_response(resp.status, resp_body)
def _http_arguments(self, json_dict, url, method):
diff --git a/tempest/tests/fake_config.py b/tempest/tests/fake_config.py
index 41b0558..e941606 100644
--- a/tempest/tests/fake_config.py
+++ b/tempest/tests/fake_config.py
@@ -43,6 +43,10 @@
swift = True
horizon = True
+ class fake_negative(object):
+ test_generator = 'tempest.common.' \
+ 'generator.negative_generator.NegativeTestGenerator'
+
compute_feature_enabled = fake_compute_feature_enabled()
volume_feature_enabled = fake_default_feature_enabled()
network_feature_enabled = fake_default_feature_enabled()
@@ -52,3 +56,5 @@
compute = fake_compute()
identity = fake_identity()
+
+ negative = fake_negative()
diff --git a/tempest/tests/negative/test_generate_json.py b/tempest/tests/negative/test_generate_json.py
index a0aa088..e09fcdf 100644
--- a/tempest/tests/negative/test_generate_json.py
+++ b/tempest/tests/negative/test_generate_json.py
@@ -13,11 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest.common import generate_json as gen
+from tempest.common.generator import negative_generator
import tempest.test
-class TestGenerateJson(tempest.test.BaseTestCase):
+class TestNegativeGenerator(tempest.test.BaseTestCase):
fake_input_str = {"type": "string",
"minLength": 2,
@@ -35,19 +35,23 @@
}
}
+ def setUp(self):
+ super(TestNegativeGenerator, self).setUp()
+ self.negative = negative_generator.NegativeTestGenerator()
+
def _validate_result(self, data):
self.assertTrue(isinstance(data, list))
for t in data:
self.assertTrue(isinstance(t, tuple))
def test_generate_invalid_string(self):
- result = gen.generate_invalid(self.fake_input_str)
+ result = self.negative.generate(self.fake_input_str)
self._validate_result(result)
def test_generate_invalid_integer(self):
- result = gen.generate_invalid(self.fake_input_int)
+ result = self.negative.generate(self.fake_input_int)
self._validate_result(result)
def test_generate_invalid_obj(self):
- result = gen.generate_invalid(self.fake_input_obj)
+ result = self.negative.generate(self.fake_input_obj)
self._validate_result(result)
diff --git a/tempest/tests/negative/test_negative_auto_test.py b/tempest/tests/negative/test_negative_auto_test.py
index 4c59383..27ddc95 100644
--- a/tempest/tests/negative/test_negative_auto_test.py
+++ b/tempest/tests/negative/test_negative_auto_test.py
@@ -16,9 +16,11 @@
import mock
import tempest.test as test
+from tempest.tests import base
+from tempest.tests import fake_config
-class TestNegativeAutoTest(test.BaseTestCase):
+class TestNegativeAutoTest(base.TestCase):
# Fake entries
_interface = 'json'
_service = 'compute'
@@ -34,6 +36,10 @@
"resources": ["flavor", "volume", "image"]
}
+ def setUp(self):
+ super(TestNegativeAutoTest, self).setUp()
+ self.stubs.Set(test, 'CONF', fake_config.FakeConfig)
+
def _check_prop_entries(self, result, entry):
entries = [a for a in result if entry in a[0]]
self.assertIsNotNone(entries)
diff --git a/tempest/tests/test_rest_client.py b/tempest/tests/test_rest_client.py
index 9f07972..827b5c9 100644
--- a/tempest/tests/test_rest_client.py
+++ b/tempest/tests/test_rest_client.py
@@ -230,3 +230,114 @@
data = {"one_top_key": "not_list_or_dict_value"}
body = self.rest_client._parse_resp(json.dumps(data))
self.assertEqual(data, body)
+
+
+class TestRestClientErrorCheckerJSON(base.TestCase):
+ c_type = "application/json"
+
+ def set_data(self, r_code, enc=None, r_body=None):
+ if enc is None:
+ enc = self.c_type
+ resp_dict = {'status': r_code, 'content-type': enc}
+ resp = httplib2.Response(resp_dict)
+ data = {
+ "method": "fake_method",
+ "url": "fake_url",
+ "headers": "fake_headers",
+ "body": "fake_body",
+ "resp": resp,
+ "resp_body": '{"resp_body": "fake_resp_body"}',
+ }
+ if r_body is not None:
+ data.update({"resp_body": r_body})
+ return data
+
+ def setUp(self):
+ super(TestRestClientErrorCheckerJSON, self).setUp()
+ self.stubs.Set(config, 'TempestConfigPrivate', fake_config.FakeConfig)
+ self.rest_client = rest_client.RestClient(
+ fake_auth_provider.FakeAuthProvider())
+
+ def test_response_less_than_400(self):
+ self.rest_client._error_checker(**self.set_data("399"))
+
+ def test_response_400(self):
+ self.assertRaises(exceptions.BadRequest,
+ self.rest_client._error_checker,
+ **self.set_data("400"))
+
+ def test_response_401(self):
+ self.assertRaises(exceptions.Unauthorized,
+ self.rest_client._error_checker,
+ **self.set_data("401"))
+
+ def test_response_403(self):
+ self.assertRaises(exceptions.Unauthorized,
+ self.rest_client._error_checker,
+ **self.set_data("403"))
+
+ def test_response_404(self):
+ self.assertRaises(exceptions.NotFound,
+ self.rest_client._error_checker,
+ **self.set_data("404"))
+
+ def test_response_409(self):
+ self.assertRaises(exceptions.Conflict,
+ self.rest_client._error_checker,
+ **self.set_data("409"))
+
+ def test_response_413(self):
+ self.assertRaises(exceptions.OverLimit,
+ self.rest_client._error_checker,
+ **self.set_data("413"))
+
+ def test_response_422(self):
+ self.assertRaises(exceptions.UnprocessableEntity,
+ self.rest_client._error_checker,
+ **self.set_data("422"))
+
+ def test_response_500_with_text(self):
+ # _parse_resp is expected to return 'str'
+ self.assertRaises(exceptions.ServerFault,
+ self.rest_client._error_checker,
+ **self.set_data("500"))
+
+ def test_response_501_with_text(self):
+ self.assertRaises(exceptions.ServerFault,
+ self.rest_client._error_checker,
+ **self.set_data("501"))
+
+ def test_response_500_with_dict(self):
+ r_body = '{"resp_body": {"err": "fake_resp_body"}}'
+ self.assertRaises(exceptions.ServerFault,
+ self.rest_client._error_checker,
+ **self.set_data("500", r_body=r_body))
+
+ def test_response_501_with_dict(self):
+ r_body = '{"resp_body": {"err": "fake_resp_body"}}'
+ self.assertRaises(exceptions.ServerFault,
+ self.rest_client._error_checker,
+ **self.set_data("501", r_body=r_body))
+
+ def test_response_bigger_than_400(self):
+ # Any response code, that bigger than 400, and not in
+ # (401, 403, 404, 409, 413, 422, 500, 501)
+ self.assertRaises(exceptions.UnexpectedResponseCode,
+ self.rest_client._error_checker,
+ **self.set_data("402"))
+
+
+class TestRestClientErrorCheckerXML(TestRestClientErrorCheckerJSON):
+ c_type = "application/xml"
+
+
+class TestRestClientErrorCheckerTEXT(TestRestClientErrorCheckerJSON):
+ c_type = "text/plain"
+
+ def test_fake_content_type(self):
+ # This test is required only in one exemplar
+ # Any response code, that bigger than 400, and not in
+ # (401, 403, 404, 409, 413, 422, 500, 501)
+ self.assertRaises(exceptions.InvalidContentType,
+ self.rest_client._error_checker,
+ **self.set_data("405", enc="fake_enc"))
diff --git a/tools/check_logs.py b/tools/check_logs.py
index 98e079a..edf95a1 100755
--- a/tools/check_logs.py
+++ b/tools/check_logs.py
@@ -25,20 +25,24 @@
import yaml
-is_neutron = os.environ.get('DEVSTACK_GATE_NEUTRON', "0") == "1"
is_grenade = (os.environ.get('DEVSTACK_GATE_GRENADE', "0") == "1" or
os.environ.get('DEVSTACK_GATE_GRENADE_FORWARD', "0") == "1")
dump_all_errors = True
+# As logs are made clean, add to this set
+must_be_clean = set(['c-sch', 'g-reg', 'ceilometer-alarm-notifier',
+ 'ceilometer-collector', 'horizon', 'n-crt', 'n-obj',
+ 'q-vpn'])
+
def process_files(file_specs, url_specs, whitelists):
regexp = re.compile(r"^.* (ERROR|CRITICAL|TRACE) .*\[.*\-.*\]")
- had_errors = False
+ logs_with_errors = []
for (name, filename) in file_specs:
whitelist = whitelists.get(name, [])
with open(filename) as content:
if scan_content(name, content, regexp, whitelist):
- had_errors = True
+ logs_with_errors.append(name)
for (name, url) in url_specs:
whitelist = whitelists.get(name, [])
req = urllib2.Request(url)
@@ -47,8 +51,8 @@
buf = StringIO.StringIO(page.read())
f = gzip.GzipFile(fileobj=buf)
if scan_content(name, f.read().splitlines(), regexp, whitelist):
- had_errors = True
- return had_errors
+ logs_with_errors.append(name)
+ return logs_with_errors
def scan_content(name, content, regexp, whitelist):
@@ -122,19 +126,22 @@
assert 'module' in w, 'no module in %s' % name
assert 'message' in w, 'no message in %s' % name
whitelists = loaded
- if process_files(files_to_process, urls_to_process, whitelists):
+ logs_with_errors = process_files(files_to_process, urls_to_process,
+ whitelists)
+ if logs_with_errors:
print("Logs have errors")
- if is_neutron:
- print("Currently not failing neutron builds with errors")
- return 0
- if is_grenade:
- print("Currently not failing grenade runs with errors")
- return 0
- print("FAILED")
- return 1
- else:
- print("ok")
+ if is_grenade:
+ print("Currently not failing grenade runs with errors")
return 0
+ failed = False
+ for log in logs_with_errors:
+ if log in must_be_clean:
+ print("FAILED: %s" % log)
+ failed = True
+ if failed:
+ return 1
+ print("ok")
+ return 0
usage = """
Find non-white-listed log errors in log files from a devstack-gate run.