Merge "Add nova migration-list CLI test"
diff --git a/.gitignore b/.gitignore
index 0f4880f..28a9b9c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,3 +15,5 @@
dist
build
.testrepository
+.coverage*
+cover/
diff --git a/HACKING.rst b/HACKING.rst
index 3fa1ff5..c0df0fb 100644
--- a/HACKING.rst
+++ b/HACKING.rst
@@ -11,6 +11,7 @@
- [T102] Cannot import OpenStack python clients in tempest/api tests
- [T104] Scenario tests require a services decorator
- [T105] Unit tests cannot use setUpClass
+- [T106] vim configuration should not be kept in source files.
Test Data/Configuration
-----------------------
@@ -107,16 +108,36 @@
Negative Tests
--------------
-When adding negative tests to tempest there are 2 requirements. First the tests
-must be marked with a negative attribute. For example::
+Newly added negative tests should use the negative test framework. First step
+is to create an interface description in a json file under `etc/schemas`.
+These descriptions consists of two important sections for the test
+(one of those is mandatory):
- @attr(type=negative)
- def test_resource_no_uuid(self):
- ...
+ - A resource (part of the URL of the request): Resources needed for a test
+ must be created in `setUpClass` and registered with `set_resource` e.g.:
+ `cls.set_resource("server", server['id'])`
-The second requirement is that all negative tests must be added to a negative
-test file. If such a file doesn't exist for the particular resource being
-tested a new test file should be added.
+ - A json schema: defines properties for a request.
+
+After that a test class must be added to automatically generate test scenarios
+out of the given interface description:
+
+ class SampeTestNegativeTestJSON(<your base class>, test.NegativeAutoTest):
+ _interface = 'json'
+ _service = 'compute'
+ _schema_file = 'compute/servers/get_console_output.json'
+ scenarios = test.NegativeAutoTest.generate_scenario(_schema_file)
+
+Negative tests must be marked with a negative attribute::
+
+ @test.attr(type=['negative', 'gate'])
+ def test_get_console_output(self):
+ self.execute(self._schema_file)
+
+All negative tests should be added into a separate negative test file.
+If such a file doesn't exist for the particular resource being tested a new
+test file should be added. Old XML based negative tests can be kept but should
+be renamed to `_xml.py`.
Test skips because of Known Bugs
--------------------------------
diff --git a/README.rst b/README.rst
index bff2bf8..9daf873 100644
--- a/README.rst
+++ b/README.rst
@@ -118,3 +118,15 @@
Alternatively, you can use the run_tests.sh script which will create a venv and
run the unit tests. There are also the py26, py27, or py33 tox jobs which will
run the unit tests with the corresponding version of python.
+
+Python 2.6
+----------
+
+Tempest can be run with Python 2.6 however the unit tests and the gate
+currently only run with Python 2.7, so there are no guarantees about the state
+of tempest when running with Python 2.6. Additionally, to enable testr to work
+with tempest using python 2.6 the discover module from the unittest-ext
+project has to be patched to switch the unittest.TestSuite to use
+unittest2.TestSuite instead. See::
+
+https://code.google.com/p/unittest-ext/issues/detail?id=79
diff --git a/doc/source/conf.py b/doc/source/conf.py
index e5444ae..bd4e553 100644
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -30,7 +30,7 @@
'sphinx.ext.intersphinx',
'sphinx.ext.todo',
'sphinx.ext.viewcode',
- 'oslo.sphinx'
+ 'oslosphinx'
]
todo_include_todos = True
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/schemas/compute/flavors/flavor_details.json b/etc/schemas/compute/flavors/flavor_details.json
index d1c1077..c16075c 100644
--- a/etc/schemas/compute/flavors/flavor_details.json
+++ b/etc/schemas/compute/flavors/flavor_details.json
@@ -2,5 +2,7 @@
"name": "get-flavor-details",
"http-method": "GET",
"url": "flavors/%s",
- "resources": ["flavor"]
+ "resources": [
+ {"name": "flavor", "expected_result": 404}
+ ]
}
diff --git a/etc/schemas/compute/flavors/flavor_details_v3.json b/etc/schemas/compute/flavors/flavor_details_v3.json
new file mode 100644
index 0000000..d1c1077
--- /dev/null
+++ b/etc/schemas/compute/flavors/flavor_details_v3.json
@@ -0,0 +1,6 @@
+{
+ "name": "get-flavor-details",
+ "http-method": "GET",
+ "url": "flavors/%s",
+ "resources": ["flavor"]
+}
diff --git a/etc/schemas/compute/flavors/flavors_list_v3.json b/etc/schemas/compute/flavors/flavors_list_v3.json
new file mode 100644
index 0000000..d5388b3
--- /dev/null
+++ b/etc/schemas/compute/flavors/flavors_list_v3.json
@@ -0,0 +1,24 @@
+{
+ "name": "list-flavors-with-detail",
+ "http-method": "GET",
+ "url": "flavors/detail",
+ "json-schema": {
+ "type": "object",
+ "properties": {
+ "min_ram": {
+ "type": "integer",
+ "results": {
+ "gen_none": 400,
+ "gen_string": 400
+ }
+ },
+ "min_disk": {
+ "type": "integer",
+ "results": {
+ "gen_none": 400,
+ "gen_string": 400
+ }
+ }
+ }
+ }
+}
diff --git a/etc/schemas/compute/servers/get_console_output.json b/etc/schemas/compute/servers/get_console_output.json
index 7c3860f..8d974ba 100644
--- a/etc/schemas/compute/servers/get_console_output.json
+++ b/etc/schemas/compute/servers/get_console_output.json
@@ -2,7 +2,9 @@
"name": "get-console-output",
"http-method": "POST",
"url": "servers/%s/action",
- "resources": ["server"],
+ "resources": [
+ {"name":"server", "expected_result": 404}
+ ],
"json-schema": {
"type": "object",
"properties": {
diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample
index 990cb37..8ab3505 100644
--- a/etc/tempest.conf.sample
+++ b/etc/tempest.conf.sample
@@ -105,6 +105,10 @@
# value)
#catalog_type=baremetal
+# The endpoint type to use for the baremetal provisioning
+# service. (string value)
+#endpoint_type=publicURL
+
[boto]
@@ -124,6 +128,9 @@
# AWS Access Key (string value)
#aws_access=<None>
+# AWS Zone for EC2 tests (string value)
+#aws_zone=nova
+
# S3 Materials Path (string value)
#s3_materials_path=/opt/stack/devstack/files/images/s3-materials/cirros-0.3.0
@@ -165,6 +172,11 @@
# value)
#cli_dir=/usr/local/bin
+# Whether the tempest run location has access to the *-manage
+# commands. In a pure blackbox environment it will not.
+# (boolean value)
+#has_manage=true
+
# Number of seconds to wait on a CLI timeout (integer value)
#timeout=15
@@ -261,6 +273,10 @@
# value)
#region=
+# The endpoint type to use for the compute service. (string
+# value)
+#endpoint_type=publicURL
+
# Catalog type of the Compute v3 service. (string value)
#catalog_v3_type=computev3
@@ -294,14 +310,14 @@
# Administrative Username to use for Nova API requests.
# (string value)
-#username=admin
+#username=<None>
# Administrative Tenant name to use for Nova API requests.
# (string value)
-#tenant_name=admin
+#tenant_name=<None>
# API key to use when authenticating as admin. (string value)
-#password=pass
+#password=<None>
[compute-feature-enabled]
@@ -316,6 +332,10 @@
# If false, skip disk config tests (boolean value)
#disk_config=true
+# A list of enabled compute extensions with a special entry
+# all which indicates every extension is enabled (list value)
+#api_extensions=all
+
# A list of enabled v3 extensions with a special entry all
# which indicates every extension is enabled (list value)
#api_v3_extensions=all
@@ -324,9 +344,6 @@
# password? (boolean value)
#change_password=false
-# Does the test environment support snapshots? (boolean value)
-#create_image=false
-
# Does the test environment support resizing? (boolean value)
#resize=false
@@ -342,6 +359,10 @@
# iSCSI volumes (boolean value)
#block_migrate_cinder_iscsi=false
+# Enable VNC console. This configuration value should be same
+# as [nova.vnc]->vnc_enabled in nova.conf (boolean value)
+#vnc_console=false
+
[dashboard]
@@ -365,6 +386,24 @@
# Catalog type of the data processing service. (string value)
#catalog_type=data_processing
+# The endpoint type to use for the data processing service.
+# (string value)
+#endpoint_type=publicURL
+
+
+[database]
+
+#
+# Options defined in tempest.config
+#
+
+# Catalog type of the Database service. (string value)
+#catalog_type=database
+
+# Valid primary flavor to use in database tests. (string
+# value)
+#db_flavor_ref=1
+
[debug]
@@ -398,8 +437,7 @@
#uri_v3=<None>
# Identity API version to be used for authentication for API
-# tests. Planned to extend to tenant isolation, scenario tests
-# and CLI tests. (string value)
+# tests. (string value)
#auth_version=v2
# The identity region name to use. Also used as the other
@@ -408,17 +446,21 @@
# one is used. (string value)
#region=RegionOne
+# The endpoint type to use for the identity service. (string
+# value)
+#endpoint_type=publicURL
+
# Username to use for Nova API requests. (string value)
-#username=demo
+#username=<None>
# Tenant name to use for Nova API requests. (string value)
-#tenant_name=demo
+#tenant_name=<None>
# Role required to administrate keystone. (string value)
#admin_role=admin
# API key to use when authenticating. (string value)
-#password=pass
+#password=<None>
# Username of alternate user to use for Nova API requests.
# (string value)
@@ -434,14 +476,14 @@
# Administrative Username to use for Keystone API requests.
# (string value)
-#admin_username=admin
+#admin_username=<None>
# Administrative Tenant name to use for Keystone API requests.
# (string value)
-#admin_tenant_name=admin
+#admin_tenant_name=<None>
# API key to use when authenticating as admin. (string value)
-#admin_password=pass
+#admin_password=<None>
[identity-feature-enabled]
@@ -454,6 +496,12 @@
# enabled (boolean value)
#trust=true
+# Is the v2 identity API enabled (boolean value)
+#api_v2=true
+
+# Is the v3 identity API enabled (boolean value)
+#api_v3=true
+
[image]
@@ -470,6 +518,10 @@
# value)
#region=
+# The endpoint type to use for the image service. (string
+# value)
+#endpoint_type=publicURL
+
# http accessible image (string value)
#http_image=http://download.cirros-cloud.net/0.3.1/cirros-0.3.1-x86_64-uec.tar.gz
@@ -510,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]
#
@@ -525,13 +587,24 @@
# value)
#region=
-# The cidr block to allocate tenant networks from (string
+# The endpoint type to use for the network service. (string
+# value)
+#endpoint_type=publicURL
+
+# The cidr block to allocate tenant ipv4 subnets from (string
# value)
#tenant_network_cidr=10.100.0.0/16
-# The mask bits for tenant networks (integer value)
+# The mask bits for tenant ipv4 subnets (integer value)
#tenant_network_mask_bits=28
+# The cidr block to allocate tenant ipv6 subnets from (string
+# value)
+#tenant_network_v6_cidr=2003::/64
+
+# The mask bits for tenant ipv6 subnets (integer value)
+#tenant_network_v6_mask_bits=96
+
# Whether tenant network connectivity should be evaluated
# directly (boolean value)
#tenant_networks_reachable=false
@@ -544,6 +617,14 @@
# (string value)
#public_router_id=
+# Timeout in seconds to wait for network operation to
+# complete. (integer value)
+#build_timeout=300
+
+# Time in seconds between network operation status checks.
+# (integer value)
+#build_interval=10
+
[network-feature-enabled]
@@ -551,16 +632,11 @@
# Options defined in tempest.config
#
-# A list of enabled extensions with a special entry all which
-# indicates every extension is enabled (list value)
-#api_extensions=all
+# Allow the execution of IPv6 tests (boolean value)
+#ipv6=true
-# A list of enabled extensions with a special entry all which
-# indicates every extension is enabled (list value)
-#api_extensions=all
-
-# A list of enabled extensions with a special entry all which
-# indicates every extension is enabled (list value)
+# A list of enabled network extensions with a special entry
+# all which indicates every extension is enabled (list value)
#api_extensions=all
@@ -579,6 +655,10 @@
# (string value)
#region=
+# The endpoint type to use for the object-store service.
+# (string value)
+#endpoint_type=publicURL
+
# Number of seconds to time on waiting for a container to
# container synchronization complete. (integer value)
#container_sync_timeout=120
@@ -591,6 +671,9 @@
# creating containers (string value)
#operator_role=Member
+# User role that has reseller admin (string value)
+#reseller_admin_role=ResellerAdmin
+
[object-storage-feature-enabled]
@@ -619,12 +702,16 @@
# value)
#region=
+# The endpoint type to use for the orchestration service.
+# (string value)
+#endpoint_type=publicURL
+
# Time in seconds between build status checks. (integer value)
#build_interval=1
# Timeout in seconds to wait for a stack to build. (integer
# value)
-#build_timeout=300
+#build_timeout=600
# Instance type for tests. Needs to be big enough for a full
# OS plus the test workload (string value)
@@ -643,6 +730,16 @@
#max_template_size=524288
+[queuing]
+
+#
+# Options defined in tempest.config
+#
+
+# Catalog type of the Queuing service. (string value)
+#catalog_type=queuing
+
+
[scenario]
#
@@ -652,6 +749,9 @@
# Directory containing image files (string value)
#img_dir=/opt/stack/new/devstack/files/images/cirros-0.3.1-x86_64-uec
+# QCOW2 image file name (string value)
+#qcow2_img_file=cirros-0.3.1-x86_64-disk.img
+
# AMI image file name (string value)
#ami_img_file=cirros-0.3.1-x86_64-blank.img
@@ -707,14 +807,22 @@
# value)
#horizon=true
-# Whether or not Savanna is expected to be available (boolean
+# Whether or not Sahara is expected to be available (boolean
# value)
-#savanna=false
+#sahara=false
# Whether or not Ironic is expected to be available (boolean
# value)
#ironic=false
+# Whether or not Trove is expected to be available (boolean
+# value)
+#trove=false
+
+# Whether or not Marconi is expected to be available (boolean
+# value)
+#marconi=false
+
[stress]
@@ -758,6 +866,11 @@
# value)
#leave_dirty_stack=false
+# Allows a full cleaning process after a stress test. Caution
+# : this cleanup will remove every objects of every tenant.
+# (boolean value)
+#full_clean_stack=false
+
[telemetry]
@@ -768,6 +881,10 @@
# Catalog type of the Telemetry service. (string value)
#catalog_type=metering
+# The endpoint type to use for the telemetry service. (string
+# value)
+#endpoint_type=publicURL
+
[volume]
@@ -792,6 +909,10 @@
# value)
#region=
+# The endpoint type to use for the volume service. (string
+# value)
+#endpoint_type=publicURL
+
# Name of the backend1 (must be declared in cinder.conf)
# (string value)
#backend1_name=BACKEND_1
@@ -823,7 +944,17 @@
# (boolean value)
#multi_backend=false
+# Runs Cinder volumes backup test (boolean value)
+#backup=true
+
+# A list of enabled volume extensions with a special entry all
+# which indicates every extension is enabled (list value)
+#api_extensions=all
+
# Is the v1 volume API enabled (boolean value)
#api_v1=true
+# Is the v2 volume API enabled (boolean value)
+#api_v2=true
+
diff --git a/etc/whitelist.yaml b/etc/whitelist.yaml
deleted file mode 100644
index 2d8b741..0000000
--- a/etc/whitelist.yaml
+++ /dev/null
@@ -1,233 +0,0 @@
-n-cpu:
- - module: "nova.virt.libvirt.driver"
- message: "During wait destroy, instance disappeared"
- - module: "glanceclient.common.http"
- message: "Request returned failure status"
- - module: "nova.openstack.common.periodic_task"
- message: "Error during ComputeManager\\.update_available_resource: \
- 'NoneType' object is not iterable"
- - module: "nova.compute.manager"
- message: "Possibly task preempted"
- - module: "nova.openstack.common.rpc.amqp"
- message: "Exception during message handling"
- - module: "nova.network.api"
- message: "Failed storing info cache"
- - module: "nova.compute.manager"
- message: "Error while trying to clean up image"
- - module: "nova.virt.libvirt.driver"
- message: "Error injecting data into image.*\\(Unexpected error while \
- running command"
- - module: "nova.compute.manager"
- message: "Instance failed to spawn"
- - module: "nova.compute.manager"
- message: "Error: Unexpected error while running command"
- - module: "nova.virt.libvirt.driver"
- message: "Error from libvirt during destroy"
- - module: "nova.virt.libvirt.vif"
- message: "Failed while unplugging vif"
- - module: "nova.openstack.common.loopingcal"
- message: "in fixed duration looping call"
- - module: "nova.virt.libvirt.driver"
- message: "Getting disk size of instance"
- - module: "nova.virt.libvirt.driver"
- message: "No such file or directory: '/opt/stack/data/nova/instances"
- - module: "nova.virt.libvirt.driver"
- message: "Nova requires libvirt version 0\\.9\\.11 or greater"
- - module: "nova.compute.manager"
- message: "error during stop\\(\\) in sync_power_state"
- - module: "nova.compute.manager"
- message: "Instance failed network setup after 1 attempt"
- - module: "nova.compute.manager"
- message: "Periodic sync_power_state task had an error"
- - module: "nova.virt.driver"
- message: "Info cache for instance .* could not be found"
-
-g-api:
- - module: "glance.store.sheepdog"
- message: "Error in store configuration: Unexpected error while \
- running command"
- - module: "swiftclient"
- message: "Container HEAD failed: .*404 Not Found"
- - module: "glance.api.middleware.cache"
- message: "however the registry did not contain metadata for that image"
- - module: "oslo.messaging.notify._impl_messaging"
- message: ".*"
-
-ceilometer-acompute:
- - module: "ceilometer.compute.pollsters.disk"
- message: "Unable to read from monitor: Connection reset by peer"
- - module: "ceilometer.compute.pollsters.disk"
- message: "Requested operation is not valid: domain is not running"
- - module: "ceilometer.compute.pollsters.net"
- message: "Requested operation is not valid: domain is not running"
- - module: "ceilometer.compute.pollsters.disk"
- message: "Domain not found: no domain with matching uuid"
- - module: "ceilometer.compute.pollsters.net"
- message: "Domain not found: no domain with matching uuid"
- - module: "ceilometer.compute.pollsters.net"
- message: "No module named libvirt"
- - module: "ceilometer.compute.pollsters.net"
- message: "Unable to write to monitor: Broken pipe"
- - module: "ceilometer.compute.pollsters.cpu"
- message: "Domain not found: no domain with matching uuid"
- - module: "ceilometer.compute.pollsters.net"
- message: ".*"
- - module: "ceilometer.compute.pollsters.disk"
- message: ".*"
-
-ceilometer-acentral:
- - module: "ceilometer.central.manager"
- message: "403 Forbidden"
- - module: "ceilometer.central.manager"
- message: "get_samples\\(\\) got an unexpected keyword argument 'resources'"
-
-ceilometer-alarm-evaluator:
- - module: "ceilometer.alarm.service"
- message: "alarm evaluation cycle failed"
- - module: "ceilometer.alarm.evaluator.threshold"
- message: ".*"
-
-ceilometer-api:
- - module: "wsme.api"
- message: ".*"
-
-h-api:
- - module: "root"
- message: "Returning 400 to user: The server could not comply with \
- the request since it is either malformed or otherwise incorrect"
- - module: "root"
- message: "Unexpected error occurred serving API: Request limit \
- exceeded: Template exceeds maximum allowed size"
- - module: "root"
- message: "Unexpected error occurred serving API: The Stack \
- .*could not be found"
-
-h-eng:
- - module: "heat.openstack.common.rpc.amqp"
- message: "Exception during message handling"
- - module: "heat.openstack.common.rpc.common"
- message: "The Stack .* could not be found"
-
-n-api:
- - module: "glanceclient.common.http"
- message: "Request returned failure status"
- - module: "nova.api.openstack"
- message: "Caught error: Quota exceeded for"
- - module: "nova.compute.api"
- message: "ServerDiskConfigTest"
- - module: "nova.compute.api"
- message: "ServersTest"
- - module: "nova.compute.api"
- message: "\\{u'kernel_id'.*u'ramdisk_id':"
- - module: "nova.api.openstack.wsgi"
- message: "takes exactly 4 arguments"
- - module: "nova.api.openstack"
- message: "Caught error: Instance .* could not be found"
- - module: "nova.api.metadata.handler"
- message: "Failed to get metadata for instance id:"
-
-n-cond:
- - module: "nova.notifications"
- message: "Failed to send state update notification"
- - module: "nova.openstack.common.rpc.amqp"
- message: "Exception during message handling"
- - module: "nova.openstack.common.rpc.common"
- message: "but the actual state is deleting to caller"
- - module: "nova.openstack.common.rpc.common"
- message: "Traceback \\(most recent call last"
- - module: "nova.openstack.common.threadgroup"
- message: "Service with host .* topic conductor exists."
-
-n-sch:
- - module: "nova.scheduler.filter_scheduler"
- message: "Error from last host: "
-
-n-net:
- - module: "nova.openstack.common.rpc.amqp"
- message: "Exception during message handling"
- - module: "nova.openstack.common.rpc.common"
- message: "'NoneType' object has no attribute '__getitem__'"
- - module: "nova.openstack.common.rpc.common"
- message: "Instance .* could not be found"
-
-c-api:
- - module: "cinder.api.middleware.fault"
- message: "Caught error: Volume .* could not be found"
- - module: "cinder.api.middleware.fault"
- message: "Caught error: Snapshot .* could not be found"
- - module: "cinder.api.openstack.wsgi"
- message: "argument must be a string or a number, not 'NoneType'"
- - module: "cinder.volume.api"
- message: "Volume status must be available to reserve"
-
-c-vol:
- - module: "cinder.brick.iscsi.iscsi"
- message: "Failed to create iscsi target for volume id"
- - module: "cinder.brick.local_dev.lvm"
- message: "stat failed: No such file or directory"
- - module: "cinder.brick.local_dev.lvm"
- message: "LV stack-volumes.*in use: not deactivating"
- - module: "cinder.brick.local_dev.lvm"
- message: "Can't remove open logical volume"
-
-ceilometer-collector:
- - module: "stevedore.extension"
- message: ".*"
- - module: "ceilometer.collector.dispatcher.database"
- message: "duplicate key value violates unique constraint"
- - module: "ceilometer.collector.dispatcher.database"
- message: "Failed to record metering data: QueuePool limit"
- - module: "ceilometer.dispatcher.database"
- message: "\\(DataError\\) integer out of range"
- - module: "ceilometer.collector.dispatcher.database"
- message: "Failed to record metering data: .* integer out of range"
- - module: "ceilometer.collector.dispatcher.database"
- message: "Failed to record metering data: .* integer out of range"
- - module: "ceilometer.openstack.common.db.sqlalchemy.session"
- message: "DB exception wrapped"
-
-q-agt:
- - module: "neutron.agent.linux.ovs_lib"
- message: "Unable to execute.*Exception:"
-
-q-dhcp:
- - module: "neutron.common.legacy"
- message: "Skipping unknown group key: firewall_driver"
- - module: "neutron.agent.dhcp_agent"
- message: "Unable to enable dhcp"
- - module: "neutron.agent.dhcp_agent"
- message: "Network .* RPC info call failed"
-
-q-l3:
- - module: "neutron.common.legacy"
- message: "Skipping unknown group key: firewall_driver"
- - module: "neutron.agent.l3_agent"
- message: "Failed synchronizing routers"
-
-q-vpn:
- - module: "neutron.common.legacy"
- message: "Skipping unknown group key: firewall_driver"
-
-q-lbaas:
- - module: "neutron.common.legacy"
- message: "Skipping unknown group key: firewall_driver"
- - module: "neutron.services.loadbalancer.drivers.haproxy.agent_manager"
- message: "Error upating stats"
- - module: "neutron.services.loadbalancer.drivers.haproxy.agent_manager"
- message: "Unable to destroy device for pool"
-
-q-svc:
- - module: "neutron.common.legacy"
- message: "Skipping unknown group key: firewall_driver"
- - module: "neutron.openstack.common.rpc.amqp"
- message: "Exception during message handling"
- - module: "neutron.openstack.common.rpc.common"
- message: "(Network|Pool|Subnet|Agent|Port) .* could not be found"
- - module: "neutron.api.v2.resource"
- message: ".* failed"
- - module: ".*"
- message: ".*"
-
-s-proxy:
- - module: "proxy-server"
- message: "Timeout talking to memcached"
diff --git a/requirements.txt b/requirements.txt
index 8c0f872..434e12e 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,6 +1,5 @@
-pbr>=0.5.21,<1.0
+pbr>=0.6,<1.0
anyjson>=0.3.3
-nose
httplib2>=0.7.5
jsonschema>=2.0.0,<3.0.0
testtools>=0.9.34
@@ -9,17 +8,18 @@
paramiko>=1.9.0
netaddr>=0.7.6
python-glanceclient>=0.9.0
-python-keystoneclient>=0.4.2
-python-novaclient>=2.15.0
-python-neutronclient>=2.3.3,<3
+python-keystoneclient>=0.6.0
+python-novaclient>=2.17.0
+python-neutronclient>=2.3.4,<3
python-cinderclient>=1.0.6
python-heatclient>=0.2.3
-python-swiftclient>=1.5
+python-savannaclient>=0.5.0
+python-swiftclient>=1.6
testresources>=0.2.4
keyring>=1.6.1,<2.0,>=2.1
-testrepository>=0.0.17
+testrepository>=0.0.18
oslo.config>=1.2.0
-six>=1.4.1
-iso8601>=0.1.8
+six>=1.5.2
+iso8601>=0.1.9
fixtures>=0.3.14
testscenarios>=0.4
diff --git a/run_tempest.sh b/run_tempest.sh
index f6c330d..bdd1f69 100755
--- a/run_tempest.sh
+++ b/run_tempest.sh
@@ -53,12 +53,12 @@
-u|--update) update=1;;
-d|--debug) debug=1;;
-C|--config) config_file=$2; shift;;
- -s|--smoke) testrargs+="smoke"; noseargs+="--attr=type=smoke";;
+ -s|--smoke) testrargs+="smoke";;
-t|--serial) serial=1;;
-l|--logging) logging=1;;
-L|--logging-config) logging_config=$2; shift;;
--) [ "yes" == "$first_uu" ] || testrargs="$testrargs $1"; first_uu=no ;;
- *) testrargs="$testrargs $1"; noseargs+=" $1" ;;
+ *) testrargs+="$testrargs $1";;
esac
shift
done
@@ -110,22 +110,6 @@
fi
}
-function run_tests_nose {
- export NOSE_WITH_OPENSTACK=1
- export NOSE_OPENSTACK_COLOR=1
- export NOSE_OPENSTACK_RED=15.00
- export NOSE_OPENSTACK_YELLOW=3.00
- export NOSE_OPENSTACK_SHOW_ELAPSED=1
- export NOSE_OPENSTACK_STDOUT=1
- export TEMPEST_PY26_NOSE_COMPAT=1
- if [[ "x$noseargs" =~ "tempest" ]]; then
- noseargs="$testrargs"
- else
- noseargs="$noseargs tempest"
- fi
- ${wrapper} nosetests $noseargs
-}
-
if [ $never_venv -eq 0 ]
then
# Remove the virtual environment if --force used
@@ -156,12 +140,7 @@
fi
fi
-py_version=`${wrapper} python --version 2>&1`
-if [[ $py_version =~ "2.6" ]] ; then
- run_tests_nose
-else
- run_tests
-fi
+run_tests
retval=$?
exit $retval
diff --git a/run_tests.sh b/run_tests.sh
index eaa7fd7..a12bf46 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -54,7 +54,7 @@
-c|--coverage) coverage=1;;
-t|--serial) serial=1;;
--) [ "yes" == "$first_uu" ] || testrargs="$testrargs $1"; first_uu=no ;;
- *) testrargs="$testrargs $1"; noseargs+=" $1" ;;
+ *) testrargs="$testrargs $1";;
esac
shift
done
@@ -84,6 +84,11 @@
return $?
fi
+ if [ $coverage -eq 1 ]; then
+ ${wrapper} python setup.py test --coverage
+ return $?
+ fi
+
if [ $serial -eq 1 ]; then
${wrapper} testr run --subunit $testrargs | ${wrapper} subunit-2to1 | ${wrapper} tools/colorizer.py
else
@@ -98,6 +103,8 @@
echo "Running flake8 without virtual env may miss OpenStack HACKING detection" >&2
fi
${wrapper} flake8
+ export MODULEPATH=tempest.common.generate_sample_tempest
+ ${wrapper} tools/config/check_uptodate.sh
}
if [ $never_venv -eq 0 ]
@@ -135,10 +142,6 @@
exit
fi
-if [ $coverage -eq 1 ]; then
- $testrargs = "--coverage $testrargs"
-fi
-
run_tests
retval=$?
diff --git a/setup.cfg b/setup.cfg
index 23a97ff..a701572 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -4,8 +4,8 @@
summary = OpenStack Integration Testing
description-file =
README.rst
-author = OpenStack QA
-author-email = openstack-qa@lists.openstack.org
+author = OpenStack
+author-email = openstack-dev@lists.openstack.org
home-page = http://www.openstack.org/
classifier =
Intended Audience :: Information Technology
@@ -21,3 +21,6 @@
all_files = 1
build-dir = doc/build
source-dir = doc/source
+
+[wheel]
+universal = 1
diff --git a/tempest/api/compute/admin/test_aggregates.py b/tempest/api/compute/admin/test_aggregates.py
index 08d8a0d..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):
@@ -26,7 +26,6 @@
"""
_host_key = 'OS-EXT-SRV-ATTR:host'
- _interface = 'json'
@classmethod
def setUpClass(cls):
@@ -40,20 +39,20 @@
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)
resp, aggregate = self.client.create_aggregate(name=aggregate_name)
self.assertEqual(200, resp.status)
self.assertEqual(aggregate_name, aggregate['name'])
- self.assertEqual(None, aggregate['availability_zone'])
+ self.assertIsNone(aggregate['availability_zone'])
resp, _ = self.client.delete_aggregate(aggregate['id'])
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)
@@ -68,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)
@@ -81,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)
@@ -106,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)
@@ -138,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'))
@@ -160,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'))
@@ -175,10 +174,10 @@
self.assertEqual(1, len(aggs))
agg = aggs[0]
self.assertEqual(aggregate_name, agg['name'])
- self.assertEqual(None, agg['availability_zone'])
+ 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'))
@@ -190,10 +189,10 @@
resp, body = self.client.get_aggregate(aggregate['id'])
self.assertEqual(aggregate_name, body['name'])
- self.assertEqual(None, body['availability_zone'])
+ 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 7d92532..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):
@@ -26,8 +26,6 @@
Tests Aggregates API that require admin privileges
"""
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
super(AggregatesAdminNegativeTestJSON, cls).setUpClass()
@@ -41,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)
@@ -49,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
@@ -64,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)
@@ -76,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)
@@ -88,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)
@@ -106,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()
@@ -135,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)
@@ -147,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)
@@ -162,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'))
@@ -178,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 18e4452..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):
@@ -23,22 +23,19 @@
Tests Availability Zone API List
"""
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
super(AZAdminTestJSON, cls).setUpClass()
cls.client = cls.os_adm.availability_zone_client
- cls.non_adm_client = cls.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 = \
@@ -46,14 +43,6 @@
self.assertEqual(200, resp.status)
self.assertTrue(len(availability_zone) > 0)
- @attr(type='gate')
- def test_get_availability_zone_list_with_non_admin_user(self):
- # List of availability zone with non-administrator user
- resp, availability_zone = \
- self.non_adm_client.get_availability_zone_list()
- self.assertEqual(200, resp.status)
- self.assertTrue(len(availability_zone) > 0)
-
class AZAdminTestXML(AZAdminTestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/admin/test_availability_zone_negative.py b/tempest/api/compute/admin/test_availability_zone_negative.py
index d13618c..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):
@@ -23,14 +23,12 @@
Tests Availability Zone API List
"""
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
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 cfb2f0e..b0692b1 100644
--- a/tempest/api/compute/admin/test_fixed_ips.py
+++ b/tempest/api/compute/admin/test_fixed_ips.py
@@ -15,13 +15,12 @@
from tempest.api.compute import base
from tempest import config
-from tempest.test import attr
+from tempest import test
CONF = config.CONF
class FixedIPsTestJson(base.BaseV2ComputeAdminTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
@@ -40,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 def9810..3fb3829 100644
--- a/tempest/api/compute/admin/test_fixed_ips_negative.py
+++ b/tempest/api/compute/admin/test_fixed_ips_negative.py
@@ -15,13 +15,12 @@
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
class FixedIPsNegativeTestJson(base.BaseV2ComputeAdminTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
@@ -41,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
@@ -69,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.py b/tempest/api/compute/admin/test_flavors.py
index 252f4be..05b763a 100644
--- a/tempest/api/compute/admin/test_flavors.py
+++ b/tempest/api/compute/admin/test_flavors.py
@@ -27,8 +27,6 @@
Tests Flavors API Create and Delete that require admin privileges
"""
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
super(FlavorsAdminTestJSON, cls).setUpClass()
@@ -172,7 +170,6 @@
flag = True
self.assertTrue(flag)
- @test.skip_because(bug="1209101")
@test.attr(type='gate')
def test_list_non_public_flavor(self):
# Create a flavor with os-flavor-access:is_public false should
diff --git a/tempest/api/compute/admin/test_flavors_access.py b/tempest/api/compute/admin/test_flavors_access.py
index da11ab5..4804ce4 100644
--- a/tempest/api/compute/admin/test_flavors_access.py
+++ b/tempest/api/compute/admin/test_flavors_access.py
@@ -25,8 +25,6 @@
Add and remove Flavor Access require admin privileges.
"""
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
super(FlavorsAccessTestJSON, cls).setUpClass()
diff --git a/tempest/api/compute/admin/test_flavors_access_negative.py b/tempest/api/compute/admin/test_flavors_access_negative.py
index c4d54b6..8fe3331 100644
--- a/tempest/api/compute/admin/test_flavors_access_negative.py
+++ b/tempest/api/compute/admin/test_flavors_access_negative.py
@@ -28,8 +28,6 @@
Add and remove Flavor Access require admin privileges.
"""
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
super(FlavorsAccessNegativeTestJSON, cls).setUpClass()
diff --git a/tempest/api/compute/admin/test_flavors_extra_specs.py b/tempest/api/compute/admin/test_flavors_extra_specs.py
index 1afa693..91145ec 100644
--- a/tempest/api/compute/admin/test_flavors_extra_specs.py
+++ b/tempest/api/compute/admin/test_flavors_extra_specs.py
@@ -26,8 +26,6 @@
GET Flavor Extra specs can be performed even by without admin privileges.
"""
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
super(FlavorsExtraSpecsTestJSON, cls).setUpClass()
diff --git a/tempest/api/compute/admin/test_flavors_extra_specs_negative.py b/tempest/api/compute/admin/test_flavors_extra_specs_negative.py
index cdf97cc..a139c2f 100644
--- a/tempest/api/compute/admin/test_flavors_extra_specs_negative.py
+++ b/tempest/api/compute/admin/test_flavors_extra_specs_negative.py
@@ -27,8 +27,6 @@
SET, UNSET, UPDATE Flavor Extra specs require admin privileges.
"""
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
super(FlavorsExtraSpecsNegativeTestJSON, cls).setUpClass()
diff --git a/tempest/api/compute/admin/test_flavors_negative.py b/tempest/api/compute/admin/test_flavors_negative.py
index ad4ceeb..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):
@@ -27,8 +30,6 @@
Tests Flavors API Create and Delete that require admin privileges
"""
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
super(FlavorsAdminNegativeTestJSON, cls).setUpClass()
@@ -46,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
@@ -87,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)
@@ -112,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 a3b4b47..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):
@@ -23,20 +23,18 @@
Tests hosts API using admin privileges.
"""
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
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()
@@ -48,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
@@ -57,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
@@ -66,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_hosts_negative.py b/tempest/api/compute/admin/test_hosts_negative.py
index cb034c9..0f26e84 100644
--- a/tempest/api/compute/admin/test_hosts_negative.py
+++ b/tempest/api/compute/admin/test_hosts_negative.py
@@ -24,8 +24,6 @@
Tests hosts API using admin privileges.
"""
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
super(HostsAdminNegativeTestJSON, cls).setUpClass()
diff --git a/tempest/api/compute/admin/test_hypervisor.py b/tempest/api/compute/admin/test_hypervisor.py
index 989c0d8..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):
@@ -23,8 +23,6 @@
Tests Hypervisors API that require admin privileges
"""
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
super(HypervisorAdminTestJSON, cls).setUpClass()
@@ -39,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()
@@ -65,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()
@@ -76,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()
@@ -103,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 e41bd18..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):
@@ -27,8 +27,6 @@
Tests Hypervisors API that require admin privileges
"""
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
super(HypervisorAdminNegativeTestJSON, cls).setUpClass()
@@ -41,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())
@@ -50,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)
@@ -60,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)
@@ -70,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())
@@ -79,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())
@@ -94,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)
@@ -104,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')
@@ -127,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 c617178..055a177 100644
--- a/tempest/api/compute/admin/test_instance_usage_audit_log.py
+++ b/tempest/api/compute/admin/test_instance_usage_audit_log.py
@@ -14,22 +14,20 @@
# under the License.
import datetime
+import urllib
from tempest.api.compute import base
-from tempest.test import attr
-import urllib
+from tempest import test
class InstanceUsageAuditLogTestJSON(base.BaseV2ComputeAdminTest):
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
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()
@@ -42,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 10bb1aa..6a5fc96 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
@@ -14,23 +14,21 @@
# under the License.
import datetime
+import urllib
from tempest.api.compute import base
from tempest import exceptions
-from tempest.test import attr
-import urllib
+from tempest import test
class InstanceUsageAuditLogNegativeTestJSON(base.BaseV2ComputeAdminTest):
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
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,
@@ -42,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_quotas.py b/tempest/api/compute/admin/test_quotas.py
index d4a32e6..09c7274 100644
--- a/tempest/api/compute/admin/test_quotas.py
+++ b/tempest/api/compute/admin/test_quotas.py
@@ -19,13 +19,11 @@
class QuotasAdminTestJSON(base.BaseV2ComputeAdminTest):
- _interface = 'json'
force_tenant_isolation = True
@classmethod
def setUpClass(cls):
super(QuotasAdminTestJSON, cls).setUpClass()
- cls.client = cls.os.quotas_client
cls.adm_client = cls.os_adm.quotas_client
# NOTE(afazekas): these test cases should always create and use a new
@@ -45,7 +43,7 @@
def test_get_default_quotas(self):
# Admin can get the default resource quota set for a tenant
expected_quota_set = self.default_quota_set | set(['id'])
- resp, quota_set = self.client.get_default_quota_set(
+ resp, quota_set = self.adm_client.get_default_quota_set(
self.demo_tenant_id)
self.assertEqual(200, resp.status)
self.assertEqual(sorted(expected_quota_set),
@@ -55,7 +53,7 @@
@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.client.get_default_quota_set(
+ resp, default_quota_set = self.adm_client.get_default_quota_set(
self.demo_tenant_id)
new_quota_set = {'injected_file_content_bytes': 20480,
'metadata_items': 256, 'injected_files': 10,
@@ -94,6 +92,29 @@
self.assertEqual(200, resp.status)
self.assertEqual(quota_set['ram'], 5120)
+ @test.attr(type='gate')
+ def test_delete_quota(self):
+ # Admin can delete the resource quota set for a tenant
+ tenant_name = data_utils.rand_name('ram_quota_tenant_')
+ tenant_desc = tenant_name + '-desc'
+ identity_client = self.os_adm.identity_client
+ _, tenant = identity_client.create_tenant(name=tenant_name,
+ description=tenant_desc)
+ tenant_id = tenant['id']
+ self.addCleanup(identity_client.delete_tenant, tenant_id)
+ resp, quota_set_default = self.adm_client.get_quota_set(tenant_id)
+ ram_default = quota_set_default['ram']
+
+ resp, body = self.adm_client.update_quota_set(tenant_id, ram='5120')
+ self.assertEqual(200, resp.status)
+
+ resp, body = self.adm_client.delete_quota_set(tenant_id)
+ self.assertEqual(202, resp.status)
+
+ resp, quota_set_new = self.adm_client.get_quota_set(tenant_id)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(ram_default, quota_set_new['ram'])
+
class QuotasAdminTestXML(QuotasAdminTestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/admin/test_quotas_negative.py b/tempest/api/compute/admin/test_quotas_negative.py
index d3696a1..5b2b5fd 100644
--- a/tempest/api/compute/admin/test_quotas_negative.py
+++ b/tempest/api/compute/admin/test_quotas_negative.py
@@ -22,7 +22,6 @@
class QuotasAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
- _interface = 'json'
force_tenant_isolation = True
@classmethod
@@ -49,7 +48,7 @@
@test.attr(type=['negative', 'gate'])
def test_create_server_when_cpu_quota_is_full(self):
# Disallow server creation when tenant's vcpu quota is full
- resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
+ resp, quota_set = self.adm_client.get_quota_set(self.demo_tenant_id)
default_vcpu_quota = quota_set['cores']
vcpu_quota = 0 # Set the quota to zero to conserve resources
@@ -64,7 +63,7 @@
@test.attr(type=['negative', 'gate'])
def test_create_server_when_memory_quota_is_full(self):
# Disallow server creation when tenant's memory quota is full
- resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
+ resp, quota_set = self.adm_client.get_quota_set(self.demo_tenant_id)
default_mem_quota = quota_set['ram']
mem_quota = 0 # Set the quota to zero to conserve resources
@@ -79,7 +78,7 @@
@test.attr(type=['negative', 'gate'])
def test_create_server_when_instances_quota_is_full(self):
# Once instances quota limit is reached, disallow server creation
- resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
+ resp, quota_set = self.adm_client.get_quota_set(self.demo_tenant_id)
default_instances_quota = quota_set['instances']
instances_quota = 0 # Set quota to zero to disallow server creation
@@ -96,7 +95,7 @@
def test_security_groups_exceed_limit(self):
# Negative test: Creation Security Groups over limit should FAIL
- resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
+ resp, quota_set = self.adm_client.get_quota_set(self.demo_tenant_id)
default_sg_quota = quota_set['security_groups']
sg_quota = 0 # Set the quota to zero to conserve resources
@@ -121,7 +120,7 @@
# Negative test: Creation of Security Group Rules should FAIL
# when we reach limit maxSecurityGroupRules
- resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
+ resp, quota_set = self.adm_client.get_quota_set(self.demo_tenant_id)
default_sg_rules_quota = quota_set['security_group_rules']
sg_rules_quota = 0 # Set the quota to zero to conserve resources
diff --git a/tempest/api/compute/admin/test_security_groups.py b/tempest/api/compute/admin/test_security_groups.py
index 0cfa344..f728d68 100644
--- a/tempest/api/compute/admin/test_security_groups.py
+++ b/tempest/api/compute/admin/test_security_groups.py
@@ -18,13 +18,12 @@
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
class SecurityGroupsTestAdminJSON(base.BaseV2ComputeAdminTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
@@ -43,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.py b/tempest/api/compute/admin/test_servers.py
index 2cee78a..77431bb 100644
--- a/tempest/api/compute/admin/test_servers.py
+++ b/tempest/api/compute/admin/test_servers.py
@@ -15,8 +15,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.test import skip_because
+from tempest import test
class ServersAdminTestJSON(base.BaseV2ComputeAdminTest):
@@ -25,9 +24,10 @@
Tests Servers API using admin privileges
"""
- _interface = 'json'
+ _host_key = 'OS-EXT-SRV-ATTR:host'
@classmethod
+ @test.safe_setup
def setUpClass(cls):
super(ServersAdminTestJSON, cls).setUpClass()
cls.client = cls.os_adm.servers_client
@@ -54,7 +54,7 @@
flavor_id = data_utils.rand_int_id(start=1000)
return flavor_id
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_by_admin(self):
# Listing servers by admin user returns empty list by default
resp, body = self.client.list_servers_with_detail()
@@ -62,7 +62,7 @@
self.assertEqual('200', resp['status'])
self.assertEqual([], servers)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_filter_by_error_status(self):
# Filter the list of servers by server error status
params = {'status': 'error'}
@@ -78,7 +78,7 @@
self.assertIn(self.s1_id, map(lambda x: x['id'], servers))
self.assertNotIn(self.s2_id, map(lambda x: x['id'], servers))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_by_admin_with_all_tenants(self):
# Listing servers by admin user with all tenants parameter
# Here should be listed all servers
@@ -90,27 +90,34 @@
self.assertIn(self.s1_name, servers_name)
self.assertIn(self.s2_name, servers_name)
- @attr(type='gate')
- def test_admin_delete_servers_of_others(self):
- # Administrator can delete servers of others
- _, server = self.create_test_server()
- resp, _ = self.client.delete_server(server['id'])
- self.assertEqual('204', resp['status'])
- self.servers_client.wait_for_server_termination(server['id'])
+ @test.attr(type='gate')
+ def test_list_servers_filter_by_exist_host(self):
+ # Filter the list of servers by existent host
+ name = data_utils.rand_name('server')
+ flavor = self.flavor_ref
+ image_id = self.image_ref
+ resp, test_server = self.client.create_server(
+ name, image_id, flavor)
+ self.assertEqual('202', resp['status'])
+ self.addCleanup(self.client.delete_server, test_server['id'])
+ self.client.wait_for_server_status(test_server['id'], 'ACTIVE')
+ resp, server = self.client.get_server(test_server['id'])
+ self.assertEqual(server['status'], 'ACTIVE')
+ hostname = server[self._host_key]
+ params = {'host': hostname}
+ resp, body = self.client.list_servers(params)
+ self.assertEqual('200', resp['status'])
+ servers = body['servers']
+ nonexistent_params = {'host': 'nonexistent_host'}
+ resp, nonexistent_body = self.client.list_servers(
+ nonexistent_params)
+ self.assertEqual('200', resp['status'])
+ nonexistent_servers = nonexistent_body['servers']
+ self.assertIn(test_server['id'], map(lambda x: x['id'], servers))
+ self.assertNotIn(test_server['id'],
+ map(lambda x: x['id'], nonexistent_servers))
- @attr(type='gate')
- def test_delete_server_while_in_error_state(self):
- # Delete a server while it's VM state is error
- resp, server = self.create_test_server(wait_until='ACTIVE')
- resp, body = self.client.reset_state(server['id'], state='error')
- self.assertEqual(202, resp.status)
- # Verify server's state
- resp, server = self.client.get_server(server['id'])
- self.assertEqual(server['status'], 'ERROR')
- resp, _ = self.client.delete_server(server['id'])
- self.assertEqual('204', resp['status'])
-
- @attr(type='gate')
+ @test.attr(type='gate')
def test_reset_state_server(self):
# Reset server's state to 'error'
resp, server = self.client.reset_state(self.s1_id)
@@ -128,8 +135,8 @@
resp, server = self.client.get_server(self.s1_id)
self.assertEqual(server['status'], 'ACTIVE')
- @attr(type='gate')
- @skip_because(bug="1240043")
+ @test.attr(type='gate')
+ @test.skip_because(bug="1240043")
def test_get_server_diagnostics_by_admin(self):
# Retrieve server diagnostics by admin user
resp, diagnostic = self.client.get_server_diagnostics(self.s1_id)
@@ -140,12 +147,12 @@
for key in basic_attrs:
self.assertIn(key, str(diagnostic.keys()))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_rebuild_server_in_error_state(self):
# The server in error state should be rebuilt using the provided
# image and changed to ACTIVE state
- # resetting vm state require admin priviledge
+ # resetting vm state require admin privilege
resp, server = self.client.reset_state(self.s1_id, state='error')
self.assertEqual(202, resp.status)
resp, rebuilt_server = self.non_admin_client.rebuild(
@@ -168,6 +175,18 @@
rebuilt_image_id = server['image']['id']
self.assertEqual(self.image_ref_alt, rebuilt_image_id)
+ @test.attr(type='gate')
+ def test_reset_network_inject_network_info(self):
+ # Reset Network of a Server
+ resp, server = self.create_test_server(wait_until='ACTIVE')
+ resp, server_body = self.client.reset_network(server['id'])
+ self.assertEqual(202, resp.status)
+ # Inject the Network Info into Server
+ resp, server_body = self.client.inject_network_info(server['id'])
+ self.assertEqual(202, resp.status)
+
class ServersAdminTestXML(ServersAdminTestJSON):
+ _host_key = (
+ '{http://docs.openstack.org/compute/ext/extended_status/api/v1.1}host')
_interface = 'xml'
diff --git a/tempest/api/compute/admin/test_servers_negative.py b/tempest/api/compute/admin/test_servers_negative.py
index 9580a06..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):
@@ -26,8 +26,6 @@
Tests Servers API using admin privileges
"""
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
super(ServersAdminNegativeTestJSON, cls).setUpClass()
@@ -54,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()
@@ -72,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()
@@ -90,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 16dcfcc..2feb825 100644
--- a/tempest/api/compute/admin/test_services.py
+++ b/tempest/api/compute/admin/test_services.py
@@ -15,7 +15,7 @@
# under the License.
from tempest.api.compute import base
-from tempest.test import attr
+from tempest import test
class ServicesAdminTestJSON(base.BaseV2ComputeAdminTest):
@@ -24,21 +24,18 @@
Tests Services API. List and Enable/Disable require admin privileges.
"""
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
super(ServicesAdminTestJSON, cls).setUpClass()
cls.client = cls.os_adm.services_client
- cls.non_admin_client = cls.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.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}
@@ -48,13 +45,14 @@
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()
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)
# we could have a periodic job checkin between the 2 service
@@ -66,12 +64,13 @@
# 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()
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.assertEqual(1, len(services))
diff --git a/tempest/api/compute/admin/test_services_negative.py b/tempest/api/compute/admin/test_services_negative.py
index a1809c4..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):
@@ -23,20 +23,18 @@
Tests Services API. List and Enable/Disable require admin privileges.
"""
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
super(ServicesAdminNegativeTestJSON, cls).setUpClass()
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()
@@ -45,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']
@@ -54,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 dcb9aed..33cd6f3 100644
--- a/tempest/api/compute/admin/test_simple_tenant_usage.py
+++ b/tempest/api/compute/admin/test_simple_tenant_usage.py
@@ -14,16 +14,14 @@
# under the License.
import datetime
+import time
from tempest.api.compute import base
-from tempest.test import attr
-import time
+from tempest import test
class TenantUsagesTestJSON(base.BaseV2ComputeAdminTest):
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
super(TenantUsagesTestJSON, cls).setUpClass()
@@ -48,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,
@@ -58,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,
@@ -69,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 2a30348..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,13 +17,11 @@
from tempest.api.compute import base
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class TenantUsagesNegativeTestJSON(base.BaseV2ComputeAdminTest):
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
super(TenantUsagesNegativeTestJSON, cls).setUpClass()
@@ -39,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,
@@ -48,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,
@@ -60,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/base.py b/tempest/api/compute/base.py
index fd069e7..abd36a6 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -51,6 +51,7 @@
cls.servers = []
cls.images = []
cls.multi_user = cls.get_multi_user()
+ cls.security_groups = []
@classmethod
def get_multi_user(cls):
@@ -102,9 +103,25 @@
pass
@classmethod
+ def clear_security_groups(cls):
+ for sg in cls.security_groups:
+ try:
+ resp, body =\
+ cls.security_groups_client.delete_security_group(sg['id'])
+ except exceptions.NotFound:
+ # The security group may have already been deleted which is OK.
+ pass
+ except Exception as exc:
+ LOG.info('Exception raised deleting security group %s',
+ sg['id'])
+ LOG.exception(exc)
+ pass
+
+ @classmethod
def tearDownClass(cls):
cls.clear_images()
cls.clear_servers()
+ cls.clear_security_groups()
cls.clear_isolated_creds()
super(BaseComputeTest, cls).tearDownClass()
@@ -146,6 +163,19 @@
return resp, body
+ @classmethod
+ def create_security_group(cls, name=None, description=None):
+ if name is None:
+ name = data_utils.rand_name(cls.__name__ + "-securitygroup")
+ if description is None:
+ description = data_utils.rand_name('description-')
+ resp, body = \
+ cls.security_groups_client.create_security_group(name,
+ description)
+ cls.security_groups.append(body)
+
+ return resp, body
+
def wait_for(self, condition):
"""Repeatedly calls condition() until a timeout."""
start_time = int(time.time())
@@ -176,6 +206,8 @@
class BaseV2ComputeTest(BaseComputeTest):
+ _interface = "json"
+
@classmethod
def setUpClass(cls):
# By default compute tests do not create network resources
@@ -273,6 +305,8 @@
class BaseV3ComputeTest(BaseComputeTest):
+ _interface = "json"
+
@classmethod
def setUpClass(cls):
# By default compute tests do not create network resources
@@ -281,14 +315,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
@@ -296,11 +330,8 @@
cls.extensions_client = cls.os.extensions_v3_client
cls.availability_zone_client = cls.os.availability_zone_v3_client
cls.interfaces_client = cls.os.interfaces_v3_client
- cls.instance_usages_audit_log_client = \
- cls.os.instance_usages_audit_log_v3_client
cls.hypervisor_client = cls.os.hypervisor_v3_client
cls.keypairs_client = cls.os.keypairs_v3_client
- cls.tenant_usages_client = cls.os.tenant_usages_v3_client
cls.volumes_client = cls.os.volumes_client
cls.certificates_client = cls.os.certificates_v3_client
cls.keypairs_client = cls.os.keypairs_v3_client
@@ -372,14 +403,12 @@
cls.os_adm = os_adm
cls.servers_admin_client = cls.os_adm.servers_v3_client
- cls.instance_usages_audit_log_admin_client = \
- cls.os_adm.instance_usages_audit_log_v3_client
cls.services_admin_client = cls.os_adm.services_v3_client
cls.availability_zone_admin_client = \
cls.os_adm.availability_zone_v3_client
cls.hypervisor_admin_client = cls.os_adm.hypervisor_v3_client
- cls.tenant_usages_admin_client = cls.os_adm.tenant_usages_v3_client
cls.flavors_admin_client = cls.os_adm.flavors_v3_client
cls.aggregates_admin_client = cls.os_adm.aggregates_v3_client
cls.hosts_admin_client = cls.os_adm.hosts_v3_client
cls.quotas_admin_client = cls.os_adm.quotas_v3_client
+ cls.agents_admin_client = cls.os_adm.agents_v3_client
diff --git a/tempest/api/compute/certificates/test_certificates.py b/tempest/api/compute/certificates/test_certificates.py
index 79619bc..5299d13 100644
--- a/tempest/api/compute/certificates/test_certificates.py
+++ b/tempest/api/compute/certificates/test_certificates.py
@@ -14,13 +14,12 @@
# under the License.
from tempest.api.compute import base
-from tempest.test import attr
+from tempest import test
class CertificatesTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
- @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 b0a7fed..6e202f6 100644
--- a/tempest/api/compute/flavors/test_flavors.py
+++ b/tempest/api/compute/flavors/test_flavors.py
@@ -14,18 +14,17 @@
# under the License.
from tempest.api.compute import base
-from tempest.test import attr
+from tempest import test
class FlavorsTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
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()
@@ -34,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()
@@ -72,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()
@@ -83,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()
@@ -94,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()
@@ -105,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()
@@ -116,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.py b/tempest/api/compute/flavors/test_flavors_negative.py
index 8ac6182..4ba5023 100644
--- a/tempest/api/compute/flavors/test_flavors_negative.py
+++ b/tempest/api/compute/flavors/test_flavors_negative.py
@@ -24,7 +24,6 @@
class FlavorsListNegativeTestJSON(base.BaseV2ComputeTest,
test.NegativeAutoTest):
- _interface = 'json'
_service = 'compute'
_schema_file = 'compute/flavors/flavors_list.json'
@@ -37,7 +36,6 @@
class FlavorDetailsNegativeTestJSON(base.BaseV2ComputeTest,
test.NegativeAutoTest):
- _interface = 'json'
_service = 'compute'
_schema_file = 'compute/flavors/flavor_details.json'
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.py b/tempest/api/compute/floating_ips/test_floating_ips_actions.py
index 56bd291..abd8a4c 100644
--- a/tempest/api/compute/floating_ips/test_floating_ips_actions.py
+++ b/tempest/api/compute/floating_ips/test_floating_ips_actions.py
@@ -14,21 +14,21 @@
# under the License.
from tempest.api.compute.floating_ips import base
-from tempest.common.utils.data_utils import rand_name
+from tempest.common.utils import data_utils
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class FloatingIPsTestJSON(base.BaseFloatingIPsTest):
- _interface = 'json'
server_id = None
floating_ip = None
@classmethod
+ @test.safe_setup
def setUpClass(cls):
super(FloatingIPsTestJSON, cls).setUpClass()
cls.client = cls.floating_ips_client
- #cls.servers_client = cls.servers_client
+ cls.floating_ip_id = None
# Server creation
resp, server = cls.create_test_server(wait_until='ACTIVE')
@@ -41,10 +41,11 @@
@classmethod
def tearDownClass(cls):
# Deleting the floating IP which is created in this method
- resp, body = cls.client.delete_floating_ip(cls.floating_ip_id)
+ if cls.floating_ip_id:
+ resp, body = cls.client.delete_floating_ip(cls.floating_ip_id)
super(FloatingIPsTestJSON, cls).tearDownClass()
- @attr(type='gate')
+ @test.attr(type='gate')
def test_allocate_floating_ip(self):
# Positive test:Allocation of a new floating IP to a project
# should be successful
@@ -59,7 +60,7 @@
resp, body = self.client.list_floating_ips()
self.assertIn(floating_ip_details, body)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_delete_floating_ip(self):
# Positive test:Deletion of valid floating IP from project
# should be successful
@@ -74,7 +75,7 @@
# Check it was really deleted.
self.client.wait_for_resource_deletion(floating_ip_body['id'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_associate_disassociate_floating_ip(self):
# Positive test:Associate and disassociate the provided floating IP
# to a specific server should be successful
@@ -90,12 +91,12 @@
self.server_id)
self.assertEqual(202, resp.status)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_associate_already_associated_floating_ip(self):
# positive test:Association of an already associated floating IP
# to specific server should change the association of the Floating IP
# Create server so as to use for Multiple association
- new_name = rand_name('floating_server')
+ new_name = data_utils.rand_name('floating_server')
resp, body = self.create_test_server(name=new_name)
self.servers_client.wait_for_server_status(body['id'], 'ACTIVE')
self.new_server_id = body['id']
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 f24343b..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,13 +19,12 @@
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
class FloatingIPsNegativeTestJSON(base.BaseFloatingIPsTest):
- _interface = 'json'
server_id = None
@classmethod
@@ -48,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
@@ -56,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
@@ -65,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
@@ -74,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
@@ -82,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 fa2d558..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,11 +14,10 @@
# under the License.
from tempest.api.compute import base
-from tempest.test import attr
+from tempest import test
class FloatingIPDetailsTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
@@ -37,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()
@@ -48,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
@@ -70,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 8d60e7d..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,20 +19,19 @@
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
class FloatingIPDetailsNegativeTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
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 4115d65..91eb4c5 100644
--- a/tempest/api/compute/images/test_image_metadata.py
+++ b/tempest/api/compute/images/test_image_metadata.py
@@ -16,23 +16,23 @@
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
class ImagesMetadataTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
@classmethod
+ @test.safe_setup
def setUpClass(cls):
super(ImagesMetadataTestJSON, cls).setUpClass()
if not CONF.service_available.glance:
skip_msg = ("%s skipped as glance is not available" % cls.__name__)
raise cls.skipException(skip_msg)
- cls.servers_client = cls.servers_client
cls.client = cls.images_client
+ cls.image_id = None
resp, server = cls.create_test_server(wait_until='ACTIVE')
cls.server_id = server['id']
@@ -46,7 +46,8 @@
@classmethod
def tearDownClass(cls):
- cls.client.delete_image(cls.image_id)
+ if cls.image_id:
+ cls.client.delete_image(cls.image_id)
super(ImagesMetadataTestJSON, cls).tearDownClass()
def setUp(self):
@@ -55,14 +56,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'}
@@ -72,7 +73,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'}
@@ -83,14 +84,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
@@ -101,7 +102,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 4878936..15bb66a 100644
--- a/tempest/api/compute/images/test_image_metadata_negative.py
+++ b/tempest/api/compute/images/test_image_metadata_negative.py
@@ -16,25 +16,24 @@
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):
- _interface = 'json'
@classmethod
def setUpClass(cls):
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'}
@@ -42,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
@@ -66,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 4cc36c9..5de2436 100644
--- a/tempest/api/compute/images/test_images.py
+++ b/tempest/api/compute/images/test_images.py
@@ -13,17 +13,15 @@
# under the License.
from tempest.api.compute import base
-from tempest import clients
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
class ImagesTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
@@ -34,35 +32,7 @@
cls.client = cls.images_client
cls.servers_client = cls.servers_client
- cls.image_ids = []
-
- if cls.multi_user:
- if CONF.compute.allow_tenant_isolation:
- creds = cls.isolated_creds.get_alt_creds()
- username, tenant_name, password = creds
- cls.alt_manager = clients.Manager(username=username,
- password=password,
- tenant_name=tenant_name)
- else:
- # Use the alt_XXX credentials in the config file
- cls.alt_manager = clients.AltManager()
- cls.alt_client = cls.alt_manager.images_client
-
- 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
-
- @attr(type=['negative', 'gate'])
+ @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
resp, server = self.create_test_server(wait_until='ACTIVE')
@@ -74,10 +44,10 @@
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)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_image_from_invalid_server(self):
# An image should not be created with invalid server id
# Create a new image with invalid server id
@@ -85,10 +55,11 @@
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)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_image_from_stopped_server(self):
resp, server = self.create_test_server(wait_until='ACTIVE')
self.servers_client.stop(server['id'])
@@ -103,7 +74,7 @@
self.addCleanup(self.client.delete_image, image['id'])
self.assertEqual(snapshot_name, image['name'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_delete_saving_image(self):
snapshot_name = data_utils.rand_name('test-snap-')
resp, server = self.create_test_server(wait_until='ACTIVE')
@@ -114,7 +85,7 @@
resp, body = self.client.delete_image(image['id'])
self.assertEqual('204', resp['status'])
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_image_specify_uuid_35_characters_or_less(self):
# Return an error if Image ID passed is 35 characters or less
snapshot_name = data_utils.rand_name('test-snap-')
@@ -122,7 +93,7 @@
self.assertRaises(exceptions.NotFound, self.client.create_image,
test_uuid, snapshot_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_image_specify_uuid_37_characters_or_more(self):
# Return an error if Image ID passed is 37 characters or more
snapshot_name = data_utils.rand_name('test-snap-')
@@ -130,13 +101,13 @@
self.assertRaises(exceptions.NotFound, self.client.create_image,
test_uuid, snapshot_name)
- @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
@@ -144,24 +115,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/compute/images/test_images_oneserver.py b/tempest/api/compute/images/test_images_oneserver.py
index 8d60623..d2fd970 100644
--- a/tempest/api/compute/images/test_images_oneserver.py
+++ b/tempest/api/compute/images/test_images_oneserver.py
@@ -13,28 +13,18 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
from tempest.api.compute import base
-from tempest import clients
from tempest.common.utils import data_utils
from tempest import config
from tempest.openstack.common import log as logging
-from tempest.test import attr
+from tempest import test
CONF = config.CONF
LOG = logging.getLogger(__name__)
class ImagesOneServerTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
-
- 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(ImagesOneServerTestJSON, self).tearDown()
def setUp(self):
# NOTE(afazekas): Normally we use the same server with all test cases,
@@ -66,27 +56,11 @@
cls.tearDownClass()
raise
- cls.image_ids = []
-
- if cls.multi_user:
- if CONF.compute.allow_tenant_isolation:
- creds = cls.isolated_creds.get_alt_creds()
- username, tenant_name, password = creds
- cls.alt_manager = clients.Manager(username=username,
- password=password,
- tenant_name=tenant_name)
- else:
- # Use the alt_XXX credentials in the config file
- cls.alt_manager = clients.AltManager()
- cls.alt_client = cls.alt_manager.images_client
-
def _get_default_flavor_disk_size(self, flavor_id):
resp, flavor = self.flavors_client.get_flavor_details(flavor_id)
return flavor['disk']
- @testtools.skipUnless(CONF.compute_feature_enabled.create_image,
- 'Environment unable to create images.')
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_create_delete_image(self):
# Create a new image
@@ -117,7 +91,7 @@
self.assertEqual('204', resp['status'])
self.client.wait_for_resource_deletion(image_id)
- @attr(type=['gate'])
+ @test.attr(type=['gate'])
def test_create_image_specify_multibyte_character_image_name(self):
if self.__class__._interface == "xml":
# NOTE(sdague): not entirely accurage, but we'd need a ton of work
diff --git a/tempest/api/compute/images/test_images_oneserver_negative.py b/tempest/api/compute/images/test_images_oneserver_negative.py
index c96c4a4..41a0590 100644
--- a/tempest/api/compute/images/test_images_oneserver_negative.py
+++ b/tempest/api/compute/images/test_images_oneserver_negative.py
@@ -15,13 +15,11 @@
# under the License.
from tempest.api.compute import base
-from tempest import clients
from tempest.common.utils import data_utils
from tempest import config
from tempest import exceptions
from tempest.openstack.common import log as logging
-from tempest.test import attr
-from tempest.test import skip_because
+from tempest import test
CONF = config.CONF
@@ -29,7 +27,6 @@
class ImagesOneServerNegativeTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
def tearDown(self):
"""Terminate test instances created after a test is executed."""
@@ -73,20 +70,8 @@
cls.image_ids = []
- if cls.multi_user:
- if CONF.compute.allow_tenant_isolation:
- creds = cls.isolated_creds.get_alt_creds()
- username, tenant_name, password = creds
- cls.alt_manager = clients.Manager(username=username,
- password=password,
- tenant_name=tenant_name)
- else:
- # Use the alt_XXX credentials in the config file
- cls.alt_manager = clients.AltManager()
- cls.alt_client = cls.alt_manager.images_client
-
- @skip_because(bug="1006725")
- @attr(type=['negative', 'gate'])
+ @test.skip_because(bug="1006725")
+ @test.attr(type=['negative', 'gate'])
def test_create_image_specify_multibyte_character_image_name(self):
if self.__class__._interface == "xml":
raise self.skipException("Not testable in XML")
@@ -98,7 +83,7 @@
self.client.create_image, self.server_id,
invalid_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_image_specify_invalid_metadata(self):
# Return an error when creating image with invalid metadata
snapshot_name = data_utils.rand_name('test-snap-')
@@ -106,7 +91,7 @@
self.assertRaises(exceptions.BadRequest, self.client.create_image,
self.server_id, snapshot_name, meta)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_image_specify_metadata_over_limits(self):
# Return an error when creating image with meta data over 256 chars
snapshot_name = data_utils.rand_name('test-snap-')
@@ -114,7 +99,7 @@
self.assertRaises(exceptions.BadRequest, self.client.create_image,
self.server_id, snapshot_name, meta)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_second_image_when_first_image_is_being_saved(self):
# Disallow creating another image when first image is being saved
@@ -132,7 +117,7 @@
self.assertRaises(exceptions.Conflict, self.client.create_image,
self.server_id, alt_snapshot_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_image_specify_name_over_256_chars(self):
# Return an error if snapshot name over 256 characters is passed
@@ -140,7 +125,7 @@
self.assertRaises(exceptions.BadRequest, self.client.create_image,
self.server_id, snapshot_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_image_that_is_not_yet_active(self):
# Return an error while trying to delete an image what is creating
diff --git a/tempest/api/compute/images/test_list_image_filters.py b/tempest/api/compute/images/test_list_image_filters.py
index f82143e..86ee4a4 100644
--- a/tempest/api/compute/images/test_list_image_filters.py
+++ b/tempest/api/compute/images/test_list_image_filters.py
@@ -15,9 +15,8 @@
from tempest.api.compute import base
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
@@ -25,7 +24,6 @@
class ListImageFiltersTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
@@ -34,7 +32,6 @@
skip_msg = ("%s skipped as glance is not available" % cls.__name__)
raise cls.skipException(skip_msg)
cls.client = cls.images_client
- cls.image_ids = []
try:
resp, cls.server1 = cls.create_test_server()
@@ -64,13 +61,7 @@
cls.tearDownClass()
raise
- @attr(type=['negative', 'gate'])
- def test_get_image_not_existing(self):
- # Check raises a NotFound
- self.assertRaises(exceptions.NotFound, self.client.get_image,
- "nonexistingimageid")
-
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_images_filter_by_status(self):
# The list of images should contain only images with the
# provided status
@@ -81,7 +72,7 @@
self.assertTrue(any([i for i in images if i['id'] == self.image2_id]))
self.assertTrue(any([i for i in images if i['id'] == self.image3_id]))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_images_filter_by_name(self):
# List of all images should contain the expected images filtered
# by name
@@ -92,7 +83,7 @@
self.assertFalse(any([i for i in images if i['id'] == self.image2_id]))
self.assertFalse(any([i for i in images if i['id'] == self.image3_id]))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_images_filter_by_server_id(self):
# The images should contain images filtered by server id
params = {'server': self.server1['id']}
@@ -104,7 +95,7 @@
self.assertTrue(any([i for i in images if i['id'] == self.image2_id]))
self.assertFalse(any([i for i in images if i['id'] == self.image3_id]))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_images_filter_by_server_ref(self):
# The list of servers should be filtered by server ref
server_links = self.server2['links']
@@ -121,7 +112,7 @@
self.assertTrue(any([i for i in images
if i['id'] == self.image3_id]))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_images_filter_by_type(self):
# The list of servers should be filtered by image type
params = {'type': 'snapshot'}
@@ -132,7 +123,7 @@
self.assertTrue(any([i for i in images if i['id'] == self.image3_id]))
self.assertFalse(any([i for i in images if i['id'] == self.image_ref]))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_images_limit_results(self):
# Verify only the expected number of results are returned
params = {'limit': '1'}
@@ -141,7 +132,7 @@
# ref: Question #224349
self.assertEqual(1, len([x for x in images if 'id' in x]))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_images_filter_by_changes_since(self):
# Verify only updated images are returned in the detailed list
@@ -152,7 +143,7 @@
found = any([i for i in images if i['id'] == self.image3_id])
self.assertTrue(found)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_images_with_detail_filter_by_status(self):
# Detailed list of all images should only contain images
# with the provided status
@@ -163,7 +154,7 @@
self.assertTrue(any([i for i in images if i['id'] == self.image2_id]))
self.assertTrue(any([i for i in images if i['id'] == self.image3_id]))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_images_with_detail_filter_by_name(self):
# Detailed list of all images should contain the expected
# images filtered by name
@@ -174,7 +165,7 @@
self.assertFalse(any([i for i in images if i['id'] == self.image2_id]))
self.assertFalse(any([i for i in images if i['id'] == self.image3_id]))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_images_with_detail_limit_results(self):
# Verify only the expected number of results (with full details)
# are returned
@@ -182,7 +173,7 @@
resp, images = self.client.list_images_with_detail(params)
self.assertEqual(1, len(images))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_images_with_detail_filter_by_server_ref(self):
# Detailed list of servers should be filtered by server ref
server_links = self.server2['links']
@@ -199,7 +190,7 @@
self.assertTrue(any([i for i in images
if i['id'] == self.image3_id]))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_images_with_detail_filter_by_type(self):
# The detailed list of servers should be filtered by image type
params = {'type': 'snapshot'}
@@ -211,7 +202,7 @@
self.assertTrue(any([i for i in images if i['id'] == self.image3_id]))
self.assertFalse(any([i for i in images if i['id'] == self.image_ref]))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_images_with_detail_filter_by_changes_since(self):
# Verify an update image is returned
@@ -221,11 +212,6 @@
resp, images = self.client.list_images_with_detail(params)
self.assertTrue(any([i for i in images if i['id'] == self.image1_id]))
- @attr(type=['negative', 'gate'])
- def test_get_nonexistent_image(self):
- # Negative test: GET on non-existent image should fail
- self.assertRaises(exceptions.NotFound, self.client.get_image, 999)
-
class ListImageFiltersTestXML(ListImageFiltersTestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/images/test_list_image_filters_negative.py b/tempest/api/compute/images/test_list_image_filters_negative.py
new file mode 100644
index 0000000..80d59a7
--- /dev/null
+++ b/tempest/api/compute/images/test_list_image_filters_negative.py
@@ -0,0 +1,43 @@
+# 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.
+
+from tempest.api.compute import base
+from tempest.common.utils import data_utils
+from tempest import config
+from tempest import exceptions
+from tempest import test
+
+CONF = config.CONF
+
+
+class ListImageFiltersNegativeTestJSON(base.BaseV2ComputeTest):
+
+ @classmethod
+ def setUpClass(cls):
+ super(ListImageFiltersNegativeTestJSON, cls).setUpClass()
+ if not CONF.service_available.glance:
+ skip_msg = ("%s skipped as glance is not available" % cls.__name__)
+ raise cls.skipException(skip_msg)
+ cls.client = cls.images_client
+
+ @test.attr(type=['negative', 'gate'])
+ def test_get_nonexistent_image(self):
+ # Check raises a NotFound
+ nonexistent_image = data_utils.rand_uuid()
+ self.assertRaises(exceptions.NotFound, self.client.get_image,
+ nonexistent_image)
+
+
+class ListImageFiltersNegativeTestXML(ListImageFiltersNegativeTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/images/test_list_images.py b/tempest/api/compute/images/test_list_images.py
index ed38442..eba331f 100644
--- a/tempest/api/compute/images/test_list_images.py
+++ b/tempest/api/compute/images/test_list_images.py
@@ -15,13 +15,12 @@
from tempest.api.compute import base
from tempest import config
-from tempest.test import attr
+from tempest import test
CONF = config.CONF
class ListImagesTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
@@ -31,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/keypairs/test_keypairs.py b/tempest/api/compute/keypairs/test_keypairs.py
index d4554bc..67fafed 100644
--- a/tempest/api/compute/keypairs/test_keypairs.py
+++ b/tempest/api/compute/keypairs/test_keypairs.py
@@ -19,7 +19,6 @@
class KeyPairsTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
diff --git a/tempest/api/compute/keypairs/test_keypairs_negative.py b/tempest/api/compute/keypairs/test_keypairs_negative.py
index 93b0692..a91a9c2 100644
--- a/tempest/api/compute/keypairs/test_keypairs_negative.py
+++ b/tempest/api/compute/keypairs/test_keypairs_negative.py
@@ -21,7 +21,6 @@
class KeyPairsNegativeTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
diff --git a/tempest/api/compute/limits/test_absolute_limits.py b/tempest/api/compute/limits/test_absolute_limits.py
index 0e234fb..d64fd57 100644
--- a/tempest/api/compute/limits/test_absolute_limits.py
+++ b/tempest/api/compute/limits/test_absolute_limits.py
@@ -18,7 +18,6 @@
class AbsoluteLimitsTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
diff --git a/tempest/api/compute/limits/test_absolute_limits_negative.py b/tempest/api/compute/limits/test_absolute_limits_negative.py
index ac8af3b..f88699b 100644
--- a/tempest/api/compute/limits/test_absolute_limits_negative.py
+++ b/tempest/api/compute/limits/test_absolute_limits_negative.py
@@ -19,7 +19,6 @@
class AbsoluteLimitsNegativeTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
diff --git a/tempest/api/compute/security_groups/test_security_group_rules.py b/tempest/api/compute/security_groups/test_security_group_rules.py
index 375105e..b04ab8a 100644
--- a/tempest/api/compute/security_groups/test_security_group_rules.py
+++ b/tempest/api/compute/security_groups/test_security_group_rules.py
@@ -14,15 +14,13 @@
# under the License.
from tempest.api.compute.security_groups 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
class SecurityGroupRulesTestJSON(base.BaseSecurityGroupsTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
@@ -30,17 +28,13 @@
cls.client = cls.security_groups_client
cls.neutron_available = CONF.service_available.neutron
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_security_group_rules_create(self):
# Positive test: Creation of Security Group rule
# should be successful
# Creating a Security Group to add rules to it
- s_name = data_utils.rand_name('securitygroup-')
- s_description = data_utils.rand_name('description-')
- resp, securitygroup = \
- self.client.create_security_group(s_name, s_description)
- securitygroup_id = securitygroup['id']
- self.addCleanup(self.client.delete_security_group, securitygroup_id)
+ resp, security_group = self.create_security_group()
+ securitygroup_id = security_group['id']
# Adding rules to the created Security Group
ip_protocol = 'tcp'
from_port = 22
@@ -53,7 +47,7 @@
self.addCleanup(self.client.delete_security_group_rule, rule['id'])
self.assertEqual(200, resp.status)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_security_group_rules_create_with_optional_arguments(self):
# Positive test: Creation of Security Group rule
# with optional arguments
@@ -62,19 +56,11 @@
secgroup1 = None
secgroup2 = None
# Creating a Security Group to add rules to it
- s_name = data_utils.rand_name('securitygroup-')
- s_description = data_utils.rand_name('description-')
- resp, securitygroup = \
- self.client.create_security_group(s_name, s_description)
- secgroup1 = securitygroup['id']
- self.addCleanup(self.client.delete_security_group, secgroup1)
+ resp, security_group = self.create_security_group()
+ secgroup1 = security_group['id']
# Creating a Security Group so as to assign group_id to the rule
- s_name2 = data_utils.rand_name('securitygroup-')
- s_description2 = data_utils.rand_name('description-')
- resp, securitygroup = \
- self.client.create_security_group(s_name2, s_description2)
- secgroup2 = securitygroup['id']
- self.addCleanup(self.client.delete_security_group, secgroup2)
+ resp, security_group = self.create_security_group()
+ secgroup2 = security_group['id']
# Adding rules to the created Security Group with optional arguments
parent_group_id = secgroup1
ip_protocol = 'tcp'
@@ -92,18 +78,13 @@
self.addCleanup(self.client.delete_security_group_rule, rule['id'])
self.assertEqual(200, resp.status)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_security_group_rules_list(self):
# Positive test: Created Security Group rules should be
# in the list of all rules
# Creating a Security Group to add rules to it
- s_name = data_utils.rand_name('securitygroup-')
- s_description = data_utils.rand_name('description-')
- resp, securitygroup = \
- self.client.create_security_group(s_name, s_description)
- securitygroup_id = securitygroup['id']
- # Delete the Security Group at the end of this method
- self.addCleanup(self.client.delete_security_group, securitygroup_id)
+ resp, security_group = self.create_security_group()
+ securitygroup_id = security_group['id']
# Add a first rule to the created Security Group
ip_protocol1 = 'tcp'
@@ -135,29 +116,21 @@
self.assertTrue(any([i for i in rules if i['id'] == rule1_id]))
self.assertTrue(any([i for i in rules if i['id'] == rule2_id]))
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_security_group_rules_delete_when_peer_group_deleted(self):
# Positive test:rule will delete when peer group deleting
# Creating a Security Group to add rules to it
- s1_name = data_utils.rand_name('securitygroup1-')
- s1_description = data_utils.rand_name('description1-')
- resp, sg1 = \
- self.client.create_security_group(s1_name, s1_description)
- self.addCleanup(self.client.delete_security_group, sg1['id'])
- self.assertEqual(200, resp.status)
+ resp, security_group = self.create_security_group()
+ sg1_id = security_group['id']
# Creating other Security Group to access to group1
- s2_name = data_utils.rand_name('securitygroup2-')
- s2_description = data_utils.rand_name('description2-')
- resp, sg2 = \
- self.client.create_security_group(s2_name, s2_description)
- self.assertEqual(200, resp.status)
- sg2_id = sg2['id']
+ resp, security_group = self.create_security_group()
+ sg2_id = security_group['id']
# Adding rules to the Group1
ip_protocol = 'tcp'
from_port = 22
to_port = 22
resp, rule = \
- self.client.create_security_group_rule(sg1['id'],
+ self.client.create_security_group_rule(sg1_id,
ip_protocol,
from_port,
to_port,
@@ -169,7 +142,7 @@
self.assertEqual(202, resp.status)
# Get rules of the Group1
resp, rules = \
- self.client.list_security_group_rules(sg1['id'])
+ self.client.list_security_group_rules(sg1_id)
# The group1 has no rules because group2 has deleted
self.assertEqual(0, len(rules))
diff --git a/tempest/api/compute/security_groups/test_security_group_rules_negative.py b/tempest/api/compute/security_groups/test_security_group_rules_negative.py
index 4831939..0b53037 100644
--- a/tempest/api/compute/security_groups/test_security_group_rules_negative.py
+++ b/tempest/api/compute/security_groups/test_security_group_rules_negative.py
@@ -13,34 +13,35 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-
from tempest.api.compute.security_groups import base
from tempest.common.utils import data_utils
from tempest import config
from tempest import exceptions
-from tempest.test import attr
-from tempest.test import skip_because
+from tempest import test
CONF = config.CONF
+def not_existing_id():
+ if CONF.service_available.neutron:
+ return data_utils.rand_uuid()
+ else:
+ return data_utils.rand_int_id(start=999)
+
+
class SecurityGroupRulesNegativeTestJSON(base.BaseSecurityGroupsTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
super(SecurityGroupRulesNegativeTestJSON, cls).setUpClass()
cls.client = cls.security_groups_client
- @skip_because(bug="1182384",
- condition=CONF.service_available.neutron)
- @attr(type=['negative', 'smoke'])
+ @test.attr(type=['negative', 'smoke'])
def test_create_security_group_rule_with_non_existent_id(self):
# Negative test: Creation of Security Group rule should FAIL
# with non existent Parent group id
# Adding rules to the non existent Security Group id
- parent_group_id = data_utils.rand_int_id(start=999)
+ parent_group_id = not_existing_id()
ip_protocol = 'tcp'
from_port = 22
to_port = 22
@@ -48,9 +49,7 @@
self.client.create_security_group_rule,
parent_group_id, ip_protocol, from_port, to_port)
- @testtools.skipIf(CONF.service_available.neutron,
- "Neutron not check the security_group_id")
- @attr(type=['negative', 'smoke'])
+ @test.attr(type=['negative', 'smoke'])
def test_create_security_group_rule_with_invalid_id(self):
# Negative test: Creation of Security Group rule should FAIL
# with Parent group id which is not integer
@@ -63,21 +62,17 @@
self.client.create_security_group_rule,
parent_group_id, ip_protocol, from_port, to_port)
- @attr(type=['negative', 'smoke'])
+ @test.attr(type=['negative', 'smoke'])
def test_create_security_group_rule_duplicate(self):
# Negative test: Create Security Group rule duplicate should fail
# Creating a Security Group to add rule to it
- s_name = data_utils.rand_name('securitygroup-')
- s_description = data_utils.rand_name('description-')
- resp, sg = self.client.create_security_group(s_name, s_description)
- self.assertEqual(200, resp.status)
+ resp, sg = self.create_security_group()
# Adding rules to the created Security Group
parent_group_id = sg['id']
ip_protocol = 'tcp'
from_port = 22
to_port = 22
- self.addCleanup(self.client.delete_security_group, sg['id'])
resp, rule = \
self.client.create_security_group_rule(parent_group_id,
ip_protocol,
@@ -90,90 +85,72 @@
self.client.create_security_group_rule,
parent_group_id, ip_protocol, from_port, to_port)
- @attr(type=['negative', 'smoke'])
+ @test.attr(type=['negative', 'smoke'])
def test_create_security_group_rule_with_invalid_ip_protocol(self):
# Negative test: Creation of Security Group rule should FAIL
# with invalid ip_protocol
# Creating a Security Group to add rule to it
- s_name = data_utils.rand_name('securitygroup-')
- s_description = data_utils.rand_name('description-')
- resp, securitygroup = self.client.create_security_group(s_name,
- s_description)
+ resp, sg = self.create_security_group()
# Adding rules to the created Security Group
- parent_group_id = securitygroup['id']
+ parent_group_id = sg['id']
ip_protocol = data_utils.rand_name('999')
from_port = 22
to_port = 22
- self.addCleanup(self.client.delete_security_group, securitygroup['id'])
self.assertRaises(exceptions.BadRequest,
self.client.create_security_group_rule,
parent_group_id, ip_protocol, from_port, to_port)
- @attr(type=['negative', 'smoke'])
+ @test.attr(type=['negative', 'smoke'])
def test_create_security_group_rule_with_invalid_from_port(self):
# Negative test: Creation of Security Group rule should FAIL
# with invalid from_port
# Creating a Security Group to add rule to it
- s_name = data_utils.rand_name('securitygroup-')
- s_description = data_utils.rand_name('description-')
- resp, securitygroup = self.client.create_security_group(s_name,
- s_description)
+ resp, sg = self.create_security_group()
# Adding rules to the created Security Group
- parent_group_id = securitygroup['id']
+ parent_group_id = sg['id']
ip_protocol = 'tcp'
from_port = data_utils.rand_int_id(start=65536)
to_port = 22
- self.addCleanup(self.client.delete_security_group, securitygroup['id'])
self.assertRaises(exceptions.BadRequest,
self.client.create_security_group_rule,
parent_group_id, ip_protocol, from_port, to_port)
- @attr(type=['negative', 'smoke'])
+ @test.attr(type=['negative', 'smoke'])
def test_create_security_group_rule_with_invalid_to_port(self):
# Negative test: Creation of Security Group rule should FAIL
# with invalid to_port
# Creating a Security Group to add rule to it
- s_name = data_utils.rand_name('securitygroup-')
- s_description = data_utils.rand_name('description-')
- resp, securitygroup = self.client.create_security_group(s_name,
- s_description)
+ resp, sg = self.create_security_group()
# Adding rules to the created Security Group
- parent_group_id = securitygroup['id']
+ parent_group_id = sg['id']
ip_protocol = 'tcp'
from_port = 22
to_port = data_utils.rand_int_id(start=65536)
- self.addCleanup(self.client.delete_security_group, securitygroup['id'])
self.assertRaises(exceptions.BadRequest,
self.client.create_security_group_rule,
parent_group_id, ip_protocol, from_port, to_port)
- @attr(type=['negative', 'smoke'])
+ @test.attr(type=['negative', 'smoke'])
def test_create_security_group_rule_with_invalid_port_range(self):
# Negative test: Creation of Security Group rule should FAIL
# with invalid port range.
# Creating a Security Group to add rule to it.
- s_name = data_utils.rand_name('securitygroup-')
- s_description = data_utils.rand_name('description-')
- resp, securitygroup = self.client.create_security_group(s_name,
- s_description)
+ resp, sg = self.create_security_group()
# Adding a rule to the created Security Group
- secgroup_id = securitygroup['id']
+ secgroup_id = sg['id']
ip_protocol = 'tcp'
from_port = 22
to_port = 21
- self.addCleanup(self.client.delete_security_group, securitygroup['id'])
self.assertRaises(exceptions.BadRequest,
self.client.create_security_group_rule,
secgroup_id, ip_protocol, from_port, to_port)
- @skip_because(bug="1182384",
- condition=CONF.service_available.neutron)
- @attr(type=['negative', 'smoke'])
+ @test.attr(type=['negative', 'smoke'])
def test_delete_security_group_rule_with_non_existent_id(self):
# Negative test: Deletion of Security Group rule should be FAIL
# with non existent id
- non_existent_rule_id = data_utils.rand_int_id(start=999)
+ non_existent_rule_id = not_existing_id()
self.assertRaises(exceptions.NotFound,
self.client.delete_security_group_rule,
non_existent_rule_id)
diff --git a/tempest/api/compute/security_groups/test_security_groups.py b/tempest/api/compute/security_groups/test_security_groups.py
index 2c67581..538ebc6 100644
--- a/tempest/api/compute/security_groups/test_security_groups.py
+++ b/tempest/api/compute/security_groups/test_security_groups.py
@@ -20,75 +20,49 @@
class SecurityGroupsTestJSON(base.BaseSecurityGroupsTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
super(SecurityGroupsTestJSON, cls).setUpClass()
cls.client = cls.security_groups_client
- def _delete_security_group(self, securitygroup_id):
- resp, _ = self.client.delete_security_group(securitygroup_id)
- self.assertEqual(202, resp.status)
-
- @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
- security_group_list = list()
for i in range(3):
- s_name = data_utils.rand_name('securitygroup-')
- s_description = data_utils.rand_name('description-')
- resp, securitygroup = \
- self.client.create_security_group(s_name, s_description)
+ resp, securitygroup = self.create_security_group()
self.assertEqual(200, resp.status)
- self.addCleanup(self._delete_security_group,
- securitygroup['id'])
- security_group_list.append(securitygroup)
# Fetch all Security Groups and verify the list
# has all created Security Groups
resp, fetched_list = self.client.list_security_groups()
self.assertEqual(200, resp.status)
# Now check if all the created Security Groups are in fetched list
missing_sgs = \
- [sg for sg in security_group_list if sg not in fetched_list]
+ [sg for sg in self.security_groups if sg not in fetched_list]
self.assertFalse(missing_sgs,
"Failed to find Security Group %s in fetched "
"list" % ', '.join(m_group['name']
for m_group in missing_sgs))
+ # Delete all security groups
+ for sg in self.security_groups:
+ resp, _ = self.client.delete_security_group(sg['id'])
+ self.assertEqual(202, resp.status)
+ self.client.wait_for_resource_deletion(sg['id'])
+ # Now check if all the created Security Groups are deleted
+ resp, fetched_list = self.client.list_security_groups()
+ deleted_sgs = \
+ [sg for sg in self.security_groups if sg in fetched_list]
+ self.assertFalse(deleted_sgs,
+ "Failed to delete Security Group %s "
+ "list" % ', '.join(m_group['name']
+ for m_group in deleted_sgs))
- # TODO(afazekas): scheduled for delete,
- # test_security_group_create_get_delete covers it
- @test.attr(type='gate')
- def test_security_group_create_delete(self):
- # Security Group should be created, verified and deleted
- s_name = data_utils.rand_name('securitygroup-')
- s_description = data_utils.rand_name('description-')
- resp, securitygroup = \
- self.client.create_security_group(s_name, s_description)
- self.assertIn('id', securitygroup)
- securitygroup_id = securitygroup['id']
- self.addCleanup(self._delete_security_group,
- securitygroup_id)
- self.assertEqual(200, resp.status)
- self.assertFalse(securitygroup_id is None)
- self.assertIn('name', securitygroup)
- securitygroup_name = securitygroup['name']
- self.assertEqual(securitygroup_name, s_name,
- "The created Security Group name is "
- "not equal to the requested name")
-
- @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-')
- s_description = data_utils.rand_name('description-')
- resp, securitygroup = \
- self.client.create_security_group(s_name, s_description)
- self.addCleanup(self._delete_security_group,
- securitygroup['id'])
-
- self.assertEqual(200, resp.status)
+ resp, securitygroup = self.create_security_group(name=s_name)
self.assertIn('name', securitygroup)
securitygroup_name = securitygroup['name']
self.assertEqual(securitygroup_name, s_name,
@@ -102,21 +76,14 @@
"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.
# Create a couple security groups that we will use
# for the server resource this test creates
- sg_name = data_utils.rand_name('sg')
- sg_desc = data_utils.rand_name('sg-desc')
- resp, sg = self.client.create_security_group(sg_name, sg_desc)
- sg_id = sg['id']
-
- sg2_name = data_utils.rand_name('sg')
- sg2_desc = data_utils.rand_name('sg-desc')
- resp, sg2 = self.client.create_security_group(sg2_name, sg2_desc)
- sg2_id = sg2['id']
+ resp, sg = self.create_security_group()
+ resp, sg2 = self.create_security_group()
# Create server and add the security group created
# above to the server we just created
@@ -125,50 +92,44 @@
server_id = server['id']
self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
resp, body = self.servers_client.add_security_group(server_id,
- sg_name)
+ sg['name'])
# Check that we are not able to delete the security
# group since it is in use by an active server
self.assertRaises(exceptions.BadRequest,
self.client.delete_security_group,
- sg_id)
+ sg['id'])
# Reboot and add the other security group
resp, body = self.servers_client.reboot(server_id, 'HARD')
self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
resp, body = self.servers_client.add_security_group(server_id,
- sg2_name)
+ sg2['name'])
# Check that we are not able to delete the other security
# group since it is in use by an active server
self.assertRaises(exceptions.BadRequest,
self.client.delete_security_group,
- sg2_id)
+ sg2['id'])
# Shutdown the server and then verify we can destroy the
# security groups, since no active server instance is using them
self.servers_client.delete_server(server_id)
self.servers_client.wait_for_server_termination(server_id)
- self.client.delete_security_group(sg_id)
+ self.client.delete_security_group(sg['id'])
+ self.assertEqual(202, resp.status)
+ self.client.delete_security_group(sg2['id'])
self.assertEqual(202, resp.status)
- 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
- s_name = data_utils.rand_name('sg-')
- s_description = data_utils.rand_name('description-')
- resp, securitygroup = \
- self.client.create_security_group(s_name, s_description)
+ resp, securitygroup = self.create_security_group()
self.assertEqual(200, resp.status)
self.assertIn('id', securitygroup)
securitygroup_id = securitygroup['id']
- self.addCleanup(self._delete_security_group,
- securitygroup_id)
# Update the name and description
s_new_name = data_utils.rand_name('sg-hth-')
s_new_des = data_utils.rand_name('description-hth-')
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 ce1eada..aa2d32e 100644
--- a/tempest/api/compute/security_groups/test_security_groups_negative.py
+++ b/tempest/api/compute/security_groups/test_security_groups_negative.py
@@ -25,7 +25,6 @@
class SecurityGroupsNegativeTestJSON(base.BaseSecurityGroupsTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
@@ -33,10 +32,6 @@
cls.client = cls.security_groups_client
cls.neutron_available = CONF.service_available.neutron
- def _delete_security_group(self, securitygroup_id):
- resp, _ = self.client.delete_security_group(securitygroup_id)
- self.assertEqual(202, resp.status)
-
def _generate_a_non_existent_security_group_id(self):
security_group_id = []
resp, body = self.client.list_security_groups()
@@ -61,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
@@ -81,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
@@ -100,24 +95,21 @@
@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
s_name = data_utils.rand_name('securitygroup-')
s_description = data_utils.rand_name('description-')
resp, security_group =\
- self.client.create_security_group(s_name, s_description)
+ self.create_security_group(s_name, s_description)
self.assertEqual(200, resp.status)
-
- self.addCleanup(self.client.delete_security_group,
- security_group['id'])
# Now try the Security Group with the same 'Name'
self.assertRaises(exceptions.BadRequest,
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
@@ -138,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
@@ -147,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-')
@@ -160,18 +152,13 @@
@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
- s_name = data_utils.rand_name('sg-')
- s_description = data_utils.rand_name('description-')
- resp, securitygroup = \
- self.client.create_security_group(s_name, s_description)
+ resp, securitygroup = self.create_security_group()
self.assertEqual(200, resp.status)
self.assertIn('id', securitygroup)
securitygroup_id = securitygroup['id']
- self.addCleanup(self._delete_security_group,
- securitygroup_id)
# Update Security Group with group name longer than 255 chars
s_new_name = 'securitygroup-'.ljust(260, '0')
self.assertRaises(exceptions.BadRequest,
@@ -180,25 +167,20 @@
@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
- s_name = data_utils.rand_name('sg-')
- s_description = data_utils.rand_name('description-')
- resp, securitygroup = \
- self.client.create_security_group(s_name, s_description)
+ resp, securitygroup = self.create_security_group()
self.assertEqual(200, resp.status)
self.assertIn('id', securitygroup)
securitygroup_id = securitygroup['id']
- self.addCleanup(self._delete_security_group,
- securitygroup_id)
# Update Security Group with group description longer than 255 chars
s_new_des = 'des-'.ljust(260, '0')
self.assertRaises(exceptions.BadRequest,
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 9cdac55..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
@@ -24,7 +24,6 @@
class AttachInterfacesTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
@@ -48,6 +47,7 @@
def _create_server_get_interfaces(self):
resp, server = self.create_test_server(wait_until='ACTIVE')
resp, ifs = self.client.list_interfaces(server['id'])
+ self.assertEqual(200, resp.status)
resp, body = self.client.wait_for_interface_status(
server['id'], ifs[0]['port_id'], 'ACTIVE')
ifs[0]['port_state'] = body['port_state']
@@ -55,6 +55,7 @@
def _test_create_interface(self, server):
resp, iface = self.client.create_interface(server['id'])
+ self.assertEqual(200, resp.status)
resp, iface = self.client.wait_for_interface_status(
server['id'], iface['port_id'], 'ACTIVE')
self._check_interface(iface)
@@ -64,6 +65,7 @@
network_id = ifs[0]['net_id']
resp, iface = self.client.create_interface(server['id'],
network_id=network_id)
+ self.assertEqual(200, resp.status)
resp, iface = self.client.wait_for_interface_status(
server['id'], iface['port_id'], 'ACTIVE')
self._check_interface(iface, network_id=network_id)
@@ -73,12 +75,14 @@
iface = ifs[0]
resp, _iface = self.client.show_interface(server['id'],
iface['port_id'])
+ self.assertEqual(200, resp.status)
self.assertEqual(iface, _iface)
def _test_delete_interface(self, server, ifs):
# NOTE(danms): delete not the first or last, but one in the middle
iface = ifs[1]
- self.client.delete_interface(server['id'], iface['port_id'])
+ resp, _ = self.client.delete_interface(server['id'], iface['port_id'])
+ self.assertEqual(202, resp.status)
_ifs = self.client.list_interfaces(server['id'])[1]
start = int(time.time())
@@ -102,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)
@@ -123,6 +127,33 @@
_ifs = self._test_delete_interface(server, ifs)
self.assertEqual(len(ifs) - 1, len(_ifs))
+ @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()
+ interface_count = len(ifs)
+ self.assertTrue(interface_count > 0)
+ self._check_interface(ifs[0])
+ network_id = ifs[0]['net_id']
+ resp, body = self.client.add_fixed_ip(server['id'],
+ network_id)
+ self.assertEqual(202, resp.status)
+ # Remove the fixed IP from server.
+ server_resp, server_detail = self.os.servers_client.get_server(
+ server['id'])
+ # Get the Fixed IP from server.
+ fixed_ip = None
+ for ip_set in server_detail['addresses']:
+ for ip in server_detail['addresses'][ip_set]:
+ if ip['OS-EXT-IPS:type'] == 'fixed':
+ fixed_ip = ip['addr']
+ break
+ if fixed_ip is not None:
+ break
+ resp, body = self.client.remove_fixed_ip(server['id'],
+ fixed_ip)
+ self.assertEqual(202, resp.status)
+
class AttachInterfacesTestXML(AttachInterfacesTestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/servers/test_availability_zone.py b/tempest/api/compute/servers/test_availability_zone.py
new file mode 100644
index 0000000..7b12555
--- /dev/null
+++ b/tempest/api/compute/servers/test_availability_zone.py
@@ -0,0 +1,40 @@
+# 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.
+
+from tempest.api.compute import base
+from tempest import test
+
+
+class AZTestJSON(base.BaseV2ComputeTest):
+
+ """
+ Tests Availability Zone API List
+ """
+
+ @classmethod
+ def setUpClass(cls):
+ super(AZTestJSON, cls).setUpClass()
+ cls.client = cls.availability_zone_client
+
+ @test.attr(type='gate')
+ def test_get_availability_zone_list_with_non_admin_user(self):
+ # List of availability zone with non-administrator user
+ resp, availability_zone = self.client.get_availability_zone_list()
+ self.assertEqual(200, resp.status)
+ self.assertTrue(len(availability_zone) > 0)
+
+
+class AZTestXML(AZTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/servers/test_create_server.py b/tempest/api/compute/servers/test_create_server.py
index 887608f..778294e 100644
--- a/tempest/api/compute/servers/test_create_server.py
+++ b/tempest/api/compute/servers/test_create_server.py
@@ -20,15 +20,14 @@
from tempest.api.compute import base
from tempest.common.utils import data_utils
-from tempest.common.utils.linux.remote_client import RemoteClient
+from tempest.common.utils.linux import remote_client
from tempest import config
-from tempest.test import attr
+from tempest import test
CONF = config.CONF
class ServersTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
run_ssh = CONF.compute.run_ssh
disk_config = 'AUTO'
@@ -54,14 +53,14 @@
cls.client.wait_for_server_status(cls.server_initial['id'], 'ACTIVE')
resp, cls.server = cls.client.get_server(cls.server_initial['id'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_create_server_response(self):
# Check that the required fields are returned with values
self.assertEqual(202, self.resp.status)
self.assertTrue(self.server_initial['id'] is not None)
self.assertTrue(self.server_initial['adminPass'] is not None)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_verify_server_details(self):
# Verify the specified server attributes are set correctly
self.assertEqual(self.accessIPv4, self.server['accessIPv4'])
@@ -74,7 +73,7 @@
self.assertEqual(self.flavor_ref, self.server['flavor']['id'])
self.assertEqual(self.meta, self.server['metadata'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_servers(self):
# The created server should be in the list of all servers
resp, body = self.client.list_servers()
@@ -82,7 +81,7 @@
found = any([i for i in servers if i['id'] == self.server['id']])
self.assertTrue(found)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_servers_with_detail(self):
# The created server should be in the detailed list of all servers
resp, body = self.client.list_servers_with_detail()
@@ -91,24 +90,25 @@
self.assertTrue(found)
@testtools.skipIf(not run_ssh, 'Instance validation tests are disabled.')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_verify_created_server_vcpus(self):
# Verify that the number of vcpus reported by the instance matches
# the amount stated by the flavor
resp, flavor = self.flavors_client.get_flavor_details(self.flavor_ref)
- linux_client = RemoteClient(self.server, self.ssh_user, self.password)
+ linux_client = remote_client.RemoteClient(self.server, self.ssh_user,
+ self.password)
self.assertEqual(flavor['vcpus'], linux_client.get_number_of_vcpus())
@testtools.skipIf(not run_ssh, 'Instance validation tests are disabled.')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_host_name_is_same_as_server_name(self):
# Verify the instance host name is the same as the server name
- linux_client = RemoteClient(self.server, self.ssh_user, self.password)
+ linux_client = remote_client.RemoteClient(self.server, self.ssh_user,
+ self.password)
self.assertTrue(linux_client.hostname_equals_servername(self.name))
class ServersWithSpecificFlavorTestJSON(base.BaseV2ComputeAdminTest):
- _interface = 'json'
run_ssh = CONF.compute.run_ssh
disk_config = 'AUTO'
@@ -136,7 +136,7 @@
resp, cls.server = cls.client.get_server(cls.server_initial['id'])
@testtools.skipIf(not run_ssh, 'Instance validation tests are disabled.')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_verify_created_server_ephemeral_disk(self):
# Verify that the ephemeral disk is created when creating server
@@ -186,8 +186,7 @@
admin_pass = self.image_ssh_password
- resp, server_no_eph_disk = (self.
- create_test_server(
+ resp, server_no_eph_disk = (self.create_test_server(
wait_until='ACTIVE',
adminPass=admin_pass,
flavor=flavor_no_eph_disk_id))
@@ -196,12 +195,12 @@
adminPass=admin_pass,
flavor=flavor_with_eph_disk_id))
# Get partition number of server without extra specs.
- linux_client = RemoteClient(server_no_eph_disk,
- self.ssh_user, self.password)
+ linux_client = remote_client.RemoteClient(server_no_eph_disk,
+ self.ssh_user, self.password)
partition_num = len(linux_client.get_partitions())
- linux_client = RemoteClient(server_with_eph_disk,
- self.ssh_user, self.password)
+ linux_client = remote_client.RemoteClient(server_with_eph_disk,
+ self.ssh_user, self.password)
self.assertEqual(partition_num + 1, linux_client.get_partitions())
diff --git a/tempest/api/compute/servers/test_delete_server.py b/tempest/api/compute/servers/test_delete_server.py
new file mode 100644
index 0000000..5e011dd
--- /dev/null
+++ b/tempest/api/compute/servers/test_delete_server.py
@@ -0,0 +1,141 @@
+# 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 testtools
+
+from tempest.api.compute import base
+from tempest import config
+from tempest import test
+
+CONF = config.CONF
+
+
+class DeleteServersTestJSON(base.BaseV2ComputeTest):
+ # NOTE: Server creations of each test class should be under 10
+ # for preventing "Quota exceeded for instances"
+
+ @classmethod
+ def setUpClass(cls):
+ super(DeleteServersTestJSON, cls).setUpClass()
+ cls.client = cls.servers_client
+
+ @test.attr(type='gate')
+ def test_delete_server_while_in_building_state(self):
+ # Delete a server while it's VM state is Building
+ resp, server = self.create_test_server(wait_until='BUILD')
+ resp, _ = self.client.delete_server(server['id'])
+ self.assertEqual('204', resp['status'])
+ self.client.wait_for_server_termination(server['id'])
+
+ @test.attr(type='gate')
+ def test_delete_active_server(self):
+ # Delete a server while it's VM state is Active
+ resp, server = self.create_test_server(wait_until='ACTIVE')
+ resp, _ = self.client.delete_server(server['id'])
+ self.assertEqual('204', resp['status'])
+ self.client.wait_for_server_termination(server['id'])
+
+ @test.attr(type='gate')
+ def test_delete_server_while_in_shutoff_state(self):
+ # Delete a server while it's VM state is Shutoff
+ resp, server = self.create_test_server(wait_until='ACTIVE')
+ resp, body = self.client.stop(server['id'])
+ self.client.wait_for_server_status(server['id'], 'SHUTOFF')
+ resp, _ = self.client.delete_server(server['id'])
+ self.assertEqual('204', resp['status'])
+ self.client.wait_for_server_termination(server['id'])
+
+ @test.attr(type='gate')
+ def test_delete_server_while_in_pause_state(self):
+ # Delete a server while it's VM state is Pause
+ resp, server = self.create_test_server(wait_until='ACTIVE')
+ resp, body = self.client.pause_server(server['id'])
+ self.client.wait_for_server_status(server['id'], 'PAUSED')
+ resp, _ = self.client.delete_server(server['id'])
+ self.assertEqual('204', resp['status'])
+ self.client.wait_for_server_termination(server['id'])
+
+ @test.attr(type='gate')
+ def test_delete_server_while_in_shelved_state(self):
+ # Delete a server while it's VM state is Shelved
+ resp, server = self.create_test_server(wait_until='ACTIVE')
+ resp, body = self.client.shelve_server(server['id'])
+ self.assertEqual(202, resp.status)
+
+ offload_time = CONF.compute.shelved_offload_time
+ if offload_time >= 0:
+ self.client.wait_for_server_status(server['id'],
+ 'SHELVED_OFFLOADED',
+ extra_timeout=offload_time)
+ else:
+ self.client.wait_for_server_status(server['id'],
+ 'SHELVED')
+ resp, _ = self.client.delete_server(server['id'])
+ self.assertEqual('204', resp['status'])
+ self.client.wait_for_server_termination(server['id'])
+
+ @testtools.skipIf(not CONF.compute_feature_enabled.resize,
+ 'Resize not available.')
+ @test.attr(type='gate')
+ def test_delete_server_while_in_verify_resize_state(self):
+ # Delete a server while it's VM state is VERIFY_RESIZE
+ resp, server = self.create_test_server(wait_until='ACTIVE')
+ resp, body = self.client.resize(server['id'], self.flavor_ref_alt)
+ self.assertEqual(202, resp.status)
+ self.client.wait_for_server_status(server['id'], 'VERIFY_RESIZE')
+ resp, _ = self.client.delete_server(server['id'])
+ self.assertEqual('204', resp['status'])
+ self.client.wait_for_server_termination(server['id'])
+
+
+class DeleteServersAdminTestJSON(base.BaseV2ComputeAdminTest):
+ # NOTE: Server creations of each test class should be under 10
+ # for preventing "Quota exceeded for instances".
+
+ @classmethod
+ def setUpClass(cls):
+ super(DeleteServersAdminTestJSON, cls).setUpClass()
+ cls.non_admin_client = cls.servers_client
+ cls.admin_client = cls.os_adm.servers_client
+
+ @test.attr(type='gate')
+ def test_delete_server_while_in_error_state(self):
+ # Delete a server while it's VM state is error
+ resp, server = self.create_test_server(wait_until='ACTIVE')
+ resp, body = self.admin_client.reset_state(server['id'], state='error')
+ self.assertEqual(202, resp.status)
+ # Verify server's state
+ resp, server = self.non_admin_client.get_server(server['id'])
+ self.assertEqual(server['status'], 'ERROR')
+ resp, _ = self.non_admin_client.delete_server(server['id'])
+ self.assertEqual('204', resp['status'])
+ self.servers_client.wait_for_server_termination(server['id'],
+ ignore_error=True)
+
+ @test.attr(type='gate')
+ def test_admin_delete_servers_of_others(self):
+ # Administrator can delete servers of others
+ resp, server = self.create_test_server(wait_until='ACTIVE')
+ resp, _ = self.admin_client.delete_server(server['id'])
+ self.assertEqual('204', resp['status'])
+ self.servers_client.wait_for_server_termination(server['id'])
+
+
+class DeleteServersTestXML(DeleteServersTestJSON):
+ _interface = 'xml'
+
+
+class DeleteServersAdminTestXML(DeleteServersAdminTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/servers/test_disk_config.py b/tempest/api/compute/servers/test_disk_config.py
index 0d79161..332358c 100644
--- a/tempest/api/compute/servers/test_disk_config.py
+++ b/tempest/api/compute/servers/test_disk_config.py
@@ -17,13 +17,12 @@
from tempest.api.compute import base
from tempest import config
-from tempest.test import attr
+from tempest import test
CONF = config.CONF
class ServerDiskConfigTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
@@ -45,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')
@@ -61,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')
@@ -87,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')
@@ -104,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')
@@ -119,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_instance_actions.py b/tempest/api/compute/servers/test_instance_actions.py
index 667b84f..dd31165 100644
--- a/tempest/api/compute/servers/test_instance_actions.py
+++ b/tempest/api/compute/servers/test_instance_actions.py
@@ -18,7 +18,6 @@
class InstanceActionsTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
diff --git a/tempest/api/compute/servers/test_instance_actions_negative.py b/tempest/api/compute/servers/test_instance_actions_negative.py
index 2503eb2..e67b69d 100644
--- a/tempest/api/compute/servers/test_instance_actions_negative.py
+++ b/tempest/api/compute/servers/test_instance_actions_negative.py
@@ -20,7 +20,6 @@
class InstanceActionsNegativeTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
diff --git a/tempest/api/compute/servers/test_list_server_filters.py b/tempest/api/compute/servers/test_list_server_filters.py
index 15b7b9e..f0913f1 100644
--- a/tempest/api/compute/servers/test_list_server_filters.py
+++ b/tempest/api/compute/servers/test_list_server_filters.py
@@ -18,16 +18,15 @@
from tempest.common.utils import data_utils
from tempest import config
from tempest import exceptions
-from tempest.test import attr
-from tempest.test import skip_because
+from tempest import test
CONF = config.CONF
class ListServerFiltersTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
@classmethod
+ @test.safe_setup
def setUpClass(cls):
super(ListServerFiltersTestJSON, cls).setUpClass()
cls.client = cls.servers_client
@@ -74,7 +73,7 @@
cls.fixed_network_name = CONF.compute.fixed_network_name
@utils.skip_unless_attr('multiple_images', 'Only one image found')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_filter_by_image(self):
# Filter the list of servers by image
params = {'image': self.image_ref}
@@ -85,7 +84,7 @@
self.assertNotIn(self.s2['id'], map(lambda x: x['id'], servers))
self.assertIn(self.s3['id'], map(lambda x: x['id'], servers))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_filter_by_flavor(self):
# Filter the list of servers by flavor
params = {'flavor': self.flavor_ref_alt}
@@ -96,7 +95,7 @@
self.assertNotIn(self.s2['id'], map(lambda x: x['id'], servers))
self.assertIn(self.s3['id'], map(lambda x: x['id'], servers))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_filter_by_server_name(self):
# Filter the list of servers by server name
params = {'name': self.s1_name}
@@ -107,7 +106,7 @@
self.assertNotIn(self.s2_name, map(lambda x: x['name'], servers))
self.assertNotIn(self.s3_name, map(lambda x: x['name'], servers))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_filter_by_server_status(self):
# Filter the list of servers by server status
params = {'status': 'active'}
@@ -118,7 +117,7 @@
self.assertIn(self.s2['id'], map(lambda x: x['id'], servers))
self.assertIn(self.s3['id'], map(lambda x: x['id'], servers))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_filter_by_shutoff_status(self):
# Filter the list of servers by server shutoff status
params = {'status': 'shutoff'}
@@ -135,7 +134,7 @@
self.assertNotIn(self.s2['id'], map(lambda x: x['id'], servers))
self.assertNotIn(self.s3['id'], map(lambda x: x['id'], servers))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_filter_by_limit(self):
# Verify only the expected number of servers are returned
params = {'limit': 1}
@@ -143,14 +142,14 @@
# when _interface='xml', one element for servers_links in servers
self.assertEqual(1, len([x for x in servers['servers'] if 'id' in x]))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_filter_by_zero_limit(self):
# Verify only the expected number of servers are returned
params = {'limit': 0}
resp, servers = self.client.list_servers(params)
self.assertEqual(0, len(servers['servers']))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_filter_by_exceed_limit(self):
# Verify only the expected number of servers are returned
params = {'limit': 100000}
@@ -160,7 +159,7 @@
len([x for x in servers['servers'] if 'id' in x]))
@utils.skip_unless_attr('multiple_images', 'Only one image found')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_detailed_filter_by_image(self):
# Filter the detailed list of servers by image
params = {'image': self.image_ref}
@@ -171,7 +170,7 @@
self.assertNotIn(self.s2['id'], map(lambda x: x['id'], servers))
self.assertIn(self.s3['id'], map(lambda x: x['id'], servers))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_detailed_filter_by_flavor(self):
# Filter the detailed list of servers by flavor
params = {'flavor': self.flavor_ref_alt}
@@ -182,7 +181,7 @@
self.assertNotIn(self.s2['id'], map(lambda x: x['id'], servers))
self.assertIn(self.s3['id'], map(lambda x: x['id'], servers))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_detailed_filter_by_server_name(self):
# Filter the detailed list of servers by server name
params = {'name': self.s1_name}
@@ -193,7 +192,7 @@
self.assertNotIn(self.s2_name, map(lambda x: x['name'], servers))
self.assertNotIn(self.s3_name, map(lambda x: x['name'], servers))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_detailed_filter_by_server_status(self):
# Filter the detailed list of servers by server status
params = {'status': 'active'}
@@ -205,7 +204,7 @@
self.assertIn(self.s3['id'], map(lambda x: x['id'], servers))
self.assertEqual(['ACTIVE'] * 3, [x['status'] for x in servers])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_filtered_by_name_wildcard(self):
# List all servers that contains '-instance' in name
params = {'name': '-instance'}
@@ -227,8 +226,8 @@
self.assertNotIn(self.s2_name, map(lambda x: x['name'], servers))
self.assertNotIn(self.s3_name, map(lambda x: x['name'], servers))
- @skip_because(bug="1170718")
- @attr(type='gate')
+ @test.skip_because(bug="1170718")
+ @test.attr(type='gate')
def test_list_servers_filtered_by_ip(self):
# Filter servers by ip
# Here should be listed 1 server
@@ -242,9 +241,9 @@
self.assertNotIn(self.s2_name, map(lambda x: x['name'], servers))
self.assertNotIn(self.s3_name, map(lambda x: x['name'], servers))
- @skip_because(bug="1182883",
- condition=CONF.service_available.neutron)
- @attr(type='gate')
+ @test.skip_because(bug="1182883",
+ condition=CONF.service_available.neutron)
+ @test.attr(type='gate')
def test_list_servers_filtered_by_ip_regex(self):
# Filter servers by regex ip
# List all servers filtered by part of ip address.
@@ -259,7 +258,7 @@
self.assertIn(self.s2_name, map(lambda x: x['name'], servers))
self.assertIn(self.s3_name, map(lambda x: x['name'], servers))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_detailed_limit_results(self):
# Verify only the expected number of detailed results are returned
params = {'limit': 1}
diff --git a/tempest/api/compute/servers/test_list_servers_negative.py b/tempest/api/compute/servers/test_list_servers_negative.py
index a0aefd8..768cc11 100644
--- a/tempest/api/compute/servers/test_list_servers_negative.py
+++ b/tempest/api/compute/servers/test_list_servers_negative.py
@@ -15,16 +15,18 @@
import datetime
+from six import moves
+
from tempest.api.compute import base
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class ListServersNegativeTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
force_tenant_isolation = True
@classmethod
+ @test.safe_setup
def setUpClass(cls):
super(ListServersNegativeTestJSON, cls).setUpClass()
cls.client = cls.servers_client
@@ -36,7 +38,7 @@
cls.existing_fixtures = []
cls.deleted_fixtures = []
cls.start_time = datetime.datetime.utcnow()
- for x in xrange(2):
+ for x in moves.xrange(2):
resp, srv = cls.create_test_server()
cls.existing_fixtures.append(srv)
@@ -50,7 +52,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
@@ -62,7 +64,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'
@@ -71,7 +73,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
@@ -80,7 +82,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'
@@ -89,7 +91,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'
@@ -98,7 +100,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})
@@ -106,26 +108,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()}
@@ -138,13 +140,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'}
@@ -152,7 +154,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_multiple_create.py b/tempest/api/compute/servers/test_multiple_create.py
index cf4d646..40b9c16 100644
--- a/tempest/api/compute/servers/test_multiple_create.py
+++ b/tempest/api/compute/servers/test_multiple_create.py
@@ -19,7 +19,6 @@
class MultipleCreateTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
_name = 'multiple-create-test'
def _generate_name(self):
diff --git a/tempest/api/compute/servers/test_multiple_create_negative.py b/tempest/api/compute/servers/test_multiple_create_negative.py
index e289717..3dea521 100644
--- a/tempest/api/compute/servers/test_multiple_create_negative.py
+++ b/tempest/api/compute/servers/test_multiple_create_negative.py
@@ -20,7 +20,6 @@
class MultipleCreateNegativeTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
_name = 'multiple-create-test'
def _generate_name(self):
diff --git a/tempest/api/compute/servers/test_server_actions.py b/tempest/api/compute/servers/test_server_actions.py
index f113047..21465d8 100644
--- a/tempest/api/compute/servers/test_server_actions.py
+++ b/tempest/api/compute/servers/test_server_actions.py
@@ -17,20 +17,19 @@
import time
import testtools
+import urlparse
from tempest.api.compute import base
from tempest.common.utils import data_utils
-from tempest.common.utils.linux.remote_client import RemoteClient
+from tempest.common.utils.linux import remote_client
from tempest import config
from tempest import exceptions
-from tempest.test import attr
-from tempest.test import skip_because
+from tempest import test
CONF = config.CONF
class ServerActionsTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
resize_available = CONF.compute_feature_enabled.resize
run_ssh = CONF.compute.run_ssh
@@ -53,7 +52,7 @@
@testtools.skipUnless(CONF.compute_feature_enabled.change_password,
'Change password not available.')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_change_server_password(self):
# The server's password should be set to the provided password
new_password = 'Newpass1234'
@@ -64,16 +63,18 @@
if self.run_ssh:
# Verify that the user can authenticate with the new password
resp, server = self.client.get_server(self.server_id)
- linux_client = RemoteClient(server, self.ssh_user, new_password)
+ linux_client = remote_client.RemoteClient(server, self.ssh_user,
+ new_password)
linux_client.validate_authentication()
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_reboot_server_hard(self):
# The server should be power cycled
if self.run_ssh:
# Get the time the server was last rebooted,
resp, server = self.client.get_server(self.server_id)
- linux_client = RemoteClient(server, self.ssh_user, self.password)
+ linux_client = remote_client.RemoteClient(server, self.ssh_user,
+ self.password)
boot_time = linux_client.get_boot_time()
resp, body = self.client.reboot(self.server_id, 'HARD')
@@ -82,19 +83,21 @@
if self.run_ssh:
# Log in and verify the boot time has changed
- linux_client = RemoteClient(server, self.ssh_user, self.password)
+ linux_client = remote_client.RemoteClient(server, self.ssh_user,
+ self.password)
new_boot_time = linux_client.get_boot_time()
self.assertTrue(new_boot_time > boot_time,
'%s > %s' % (new_boot_time, boot_time))
- @skip_because(bug="1014647")
- @attr(type='smoke')
+ @test.skip_because(bug="1014647")
+ @test.attr(type='smoke')
def test_reboot_server_soft(self):
# The server should be signaled to reboot gracefully
if self.run_ssh:
# Get the time the server was last rebooted,
resp, server = self.client.get_server(self.server_id)
- linux_client = RemoteClient(server, self.ssh_user, self.password)
+ linux_client = remote_client.RemoteClient(server, self.ssh_user,
+ self.password)
boot_time = linux_client.get_boot_time()
resp, body = self.client.reboot(self.server_id, 'SOFT')
@@ -103,12 +106,13 @@
if self.run_ssh:
# Log in and verify the boot time has changed
- linux_client = RemoteClient(server, self.ssh_user, self.password)
+ linux_client = remote_client.RemoteClient(server, self.ssh_user,
+ self.password)
new_boot_time = linux_client.get_boot_time()
self.assertTrue(new_boot_time > boot_time,
'%s > %s' % (new_boot_time, boot_time))
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_rebuild_server(self):
# The server should be rebuilt using the provided image and data
meta = {'rebuild': 'server'}
@@ -140,10 +144,11 @@
if self.run_ssh:
# Verify that the user can authenticate with the provided password
- linux_client = RemoteClient(server, self.ssh_user, password)
+ linux_client = remote_client.RemoteClient(server, self.ssh_user,
+ password)
linux_client.validate_authentication()
- @attr(type='gate')
+ @test.attr(type='gate')
def test_rebuild_server_in_stop_state(self):
# The server in stop state should be rebuilt using the provided
# image and remain in SHUTOFF state
@@ -181,7 +186,7 @@
return current_flavor, new_flavor_ref
@testtools.skipIf(not resize_available, 'Resize not available.')
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_resize_server_confirm(self):
# The server's RAM and disk space should be modified to that of
# the provided flavor
@@ -200,7 +205,7 @@
self.assertEqual(new_flavor_ref, server['flavor']['id'])
@testtools.skipIf(not resize_available, 'Resize not available.')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_resize_server_revert(self):
# The server's RAM and disk space should return to its original
# values after a resize is reverted
@@ -228,7 +233,7 @@
required time (%s s).' % (self.server_id, self.build_timeout)
raise exceptions.TimeoutException(message)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_create_backup(self):
# Positive test:create backup successfully and rotate backups correctly
# create the first and the second backup
@@ -313,7 +318,7 @@
lines = len(output.split('\n'))
self.assertEqual(lines, 10)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_console_output(self):
# Positive test:Should be able to GET the console output
# for a given server_id and number of lines
@@ -329,7 +334,7 @@
self.wait_for(self._get_output)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_console_output_server_id_in_shutoff_status(self):
# Positive test:Should be able to GET the console output
# for a given server_id in SHUTOFF status
@@ -346,7 +351,7 @@
self.wait_for(self._get_output)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_pause_unpause_server(self):
resp, server = self.client.pause_server(self.server_id)
self.assertEqual(202, resp.status)
@@ -355,7 +360,7 @@
self.assertEqual(202, resp.status)
self.client.wait_for_server_status(self.server_id, 'ACTIVE')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_suspend_resume_server(self):
resp, server = self.client.suspend_server(self.server_id)
self.assertEqual(202, resp.status)
@@ -364,7 +369,7 @@
self.assertEqual(202, resp.status)
self.client.wait_for_server_status(self.server_id, 'ACTIVE')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_shelve_unshelve_server(self):
resp, server = self.client.shelve_server(self.server_id)
self.assertEqual(202, resp.status)
@@ -378,6 +383,11 @@
self.client.wait_for_server_status(self.server_id,
'SHELVED')
+ resp, server = self.client.shelve_offload_server(self.server_id)
+ self.assertEqual(202, resp.status)
+ self.client.wait_for_server_status(self.server_id,
+ 'SHELVED_OFFLOADED')
+
resp, server = self.client.get_server(self.server_id)
image_name = server['name'] + '-shelved'
params = {'name': image_name}
@@ -389,7 +399,7 @@
self.assertEqual(202, resp.status)
self.client.wait_for_server_status(self.server_id, 'ACTIVE')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_stop_start_server(self):
resp, server = self.servers_client.stop(self.server_id)
self.assertEqual(202, resp.status)
@@ -398,7 +408,7 @@
self.assertEqual(202, resp.status)
self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_lock_unlock_server(self):
# Lock the server,try server stop(exceptions throw),unlock it and retry
resp, server = self.servers_client.lock_server(self.server_id)
@@ -418,6 +428,29 @@
self.assertEqual(202, resp.status)
self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
+ def _validate_url(self, url):
+ valid_scheme = ['http', 'https']
+ parsed_url = urlparse.urlparse(url)
+ self.assertNotEqual('None', parsed_url.port)
+ self.assertNotEqual('None', parsed_url.hostname)
+ self.assertIn(parsed_url.scheme, valid_scheme)
+
+ @testtools.skipUnless(CONF.compute_feature_enabled.vnc_console,
+ 'VNC Console feature is disabled.')
+ @test.attr(type='gate')
+ def test_get_vnc_console(self):
+ # Get the VNC console of type 'novnc' and 'xvpvnc'
+ console_types = ['novnc', 'xvpvnc']
+ for console_type in console_types:
+ resp, body = self.servers_client.get_vnc_console(self.server_id,
+ console_type)
+ self.assertEqual(
+ 200, resp.status,
+ "Failed to get Console Type: %s" % (console_types))
+ self.assertEqual(console_type, body['type'])
+ self.assertNotEqual('', body['url'])
+ self._validate_url(body['url'])
+
class ServerActionsTestXML(ServerActionsTestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/servers/test_server_addresses.py b/tempest/api/compute/servers/test_server_addresses.py
index 8e432c4..0c14dc2 100644
--- a/tempest/api/compute/servers/test_server_addresses.py
+++ b/tempest/api/compute/servers/test_server_addresses.py
@@ -14,11 +14,13 @@
# under the License.
from tempest.api.compute import base
+from tempest import config
from tempest import test
+CONF = config.CONF
+
class ServerAddressesTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
@@ -29,6 +31,8 @@
resp, cls.server = cls.create_test_server(wait_until='ACTIVE')
+ @test.skip_because(bug="1210483",
+ condition=CONF.service_available.neutron)
@test.attr(type='smoke')
def test_list_server_addresses(self):
# All public and private addresses for
diff --git a/tempest/api/compute/servers/test_server_addresses_negative.py b/tempest/api/compute/servers/test_server_addresses_negative.py
index c69c5eb..d37f7fa 100644
--- a/tempest/api/compute/servers/test_server_addresses_negative.py
+++ b/tempest/api/compute/servers/test_server_addresses_negative.py
@@ -19,7 +19,6 @@
class ServerAddressesNegativeTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
diff --git a/tempest/api/compute/servers/test_server_metadata.py b/tempest/api/compute/servers/test_server_metadata.py
index ad4931c..448b8ff 100644
--- a/tempest/api/compute/servers/test_server_metadata.py
+++ b/tempest/api/compute/servers/test_server_metadata.py
@@ -18,7 +18,6 @@
class ServerMetadataTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
diff --git a/tempest/api/compute/servers/test_server_metadata_negative.py b/tempest/api/compute/servers/test_server_metadata_negative.py
index e52ea4a..8b69c78 100644
--- a/tempest/api/compute/servers/test_server_metadata_negative.py
+++ b/tempest/api/compute/servers/test_server_metadata_negative.py
@@ -20,7 +20,6 @@
class ServerMetadataNegativeTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
diff --git a/tempest/api/compute/servers/test_server_password.py b/tempest/api/compute/servers/test_server_password.py
index 06697a5..50c881a 100644
--- a/tempest/api/compute/servers/test_server_password.py
+++ b/tempest/api/compute/servers/test_server_password.py
@@ -15,11 +15,10 @@
from tempest.api.compute import base
-from tempest.test import attr
+from tempest import test
class ServerPasswordTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
@@ -27,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 bb14a4c..b7e4e38 100644
--- a/tempest/api/compute/servers/test_server_personality.py
+++ b/tempest/api/compute/servers/test_server_personality.py
@@ -17,11 +17,10 @@
from tempest.api.compute import base
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class ServerPersonalityTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
@@ -29,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.
@@ -44,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_server_rescue.py b/tempest/api/compute/servers/test_server_rescue.py
index 0bf604c..093e9e2 100644
--- a/tempest/api/compute/servers/test_server_rescue.py
+++ b/tempest/api/compute/servers/test_server_rescue.py
@@ -15,18 +15,16 @@
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 ServerRescueTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
@classmethod
+ @test.safe_setup
def setUpClass(cls):
cls.set_network_resources(network=True, subnet=True, router=True)
super(ServerRescueTestJSON, cls).setUpClass()
- cls.device = 'vdf'
# Floating IP creation
resp, body = cls.floating_ips_client.create_floating_ip()
@@ -54,14 +52,6 @@
cls.password = server['adminPass']
cls.servers_client.wait_for_server_status(cls.server_id, 'ACTIVE')
- # Server for negative tests
- cls.rescue_id = resc_server['id']
- cls.rescue_password = resc_server['adminPass']
-
- cls.servers_client.rescue_server(
- cls.rescue_id, adminPass=cls.rescue_password)
- cls.servers_client.wait_for_server_status(cls.rescue_id, 'RESCUE')
-
def setUp(self):
super(ServerRescueTestJSON, self).setUp()
@@ -77,22 +67,12 @@
def tearDown(self):
super(ServerRescueTestJSON, self).tearDown()
- def _detach(self, server_id, volume_id):
- self.servers_client.detach_volume(server_id, volume_id)
- self.volumes_extensions_client.wait_for_volume_status(volume_id,
- 'available')
-
def _unrescue(self, server_id):
resp, body = self.servers_client.unrescue_server(server_id)
self.assertEqual(202, resp.status)
self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
- def _unpause(self, server_id):
- resp, body = self.servers_client.unpause_server(server_id)
- self.assertEqual(202, resp.status)
- self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
-
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_rescue_unrescue_instance(self):
resp, body = self.servers_client.rescue_server(
self.server_id, adminPass=self.password)
@@ -102,76 +82,7 @@
self.assertEqual(202, resp.status)
self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
- @attr(type=['negative', 'gate'])
- def test_rescue_paused_instance(self):
- # Rescue a paused server
- resp, body = self.servers_client.pause_server(
- self.server_id)
- self.addCleanup(self._unpause, self.server_id)
- self.assertEqual(202, resp.status)
- self.servers_client.wait_for_server_status(self.server_id, 'PAUSED')
- self.assertRaises(exceptions.Conflict,
- self.servers_client.rescue_server,
- self.server_id)
-
- @attr(type=['negative', 'gate'])
- def test_rescued_vm_reboot(self):
- self.assertRaises(exceptions.Conflict, self.servers_client.reboot,
- self.rescue_id, 'HARD')
-
- @attr(type=['negative', 'gate'])
- def test_rescue_non_existent_server(self):
- # Rescue a non-existing server
- self.assertRaises(exceptions.NotFound,
- self.servers_client.rescue_server,
- '999erra43')
-
- @attr(type=['negative', 'gate'])
- def test_rescued_vm_rebuild(self):
- self.assertRaises(exceptions.Conflict,
- self.servers_client.rebuild,
- self.rescue_id,
- self.image_ref_alt)
-
- @attr(type=['negative', 'gate'])
- def test_rescued_vm_attach_volume(self):
- # Rescue the server
- self.servers_client.rescue_server(self.server_id,
- adminPass=self.password)
- self.servers_client.wait_for_server_status(self.server_id, 'RESCUE')
- self.addCleanup(self._unrescue, self.server_id)
-
- # Attach the volume to the server
- self.assertRaises(exceptions.Conflict,
- self.servers_client.attach_volume,
- self.server_id,
- self.volume['id'],
- device='/dev/%s' % self.device)
-
- @attr(type=['negative', 'gate'])
- def test_rescued_vm_detach_volume(self):
- # Attach the volume to the server
- self.servers_client.attach_volume(self.server_id,
- self.volume['id'],
- device='/dev/%s' % self.device)
- self.volumes_extensions_client.wait_for_volume_status(
- self.volume['id'], 'in-use')
-
- # Rescue the server
- self.servers_client.rescue_server(self.server_id,
- adminPass=self.password)
- self.servers_client.wait_for_server_status(self.server_id, 'RESCUE')
- # addCleanup is a LIFO queue
- self.addCleanup(self._detach, self.server_id, self.volume['id'])
- self.addCleanup(self._unrescue, self.server_id)
-
- # Detach the volume from the server expecting failure
- self.assertRaises(exceptions.Conflict,
- self.servers_client.detach_volume,
- self.server_id,
- self.volume['id'])
-
- @attr(type='gate')
+ @test.attr(type='gate')
def test_rescued_vm_associate_dissociate_floating_ip(self):
# Rescue the server
self.servers_client.rescue_server(
@@ -191,7 +102,7 @@
self.server_id)
self.assertEqual(202, resp.status)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_rescued_vm_add_remove_security_group(self):
# Rescue the server
self.servers_client.rescue_server(
diff --git a/tempest/api/compute/servers/test_server_rescue_negative.py b/tempest/api/compute/servers/test_server_rescue_negative.py
new file mode 100644
index 0000000..ef45585
--- /dev/null
+++ b/tempest/api/compute/servers/test_server_rescue_negative.py
@@ -0,0 +1,140 @@
+# Copyright 2013 Hewlett-Packard Development Company, L.P.
+# 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.
+
+from tempest.api.compute import base
+from tempest.common.utils import data_utils
+from tempest import exceptions
+from tempest import test
+
+
+class ServerRescueNegativeTestJSON(base.BaseV2ComputeTest):
+
+ @classmethod
+ @test.safe_setup
+ def setUpClass(cls):
+ cls.set_network_resources(network=True, subnet=True, router=True)
+ super(ServerRescueNegativeTestJSON, cls).setUpClass()
+ cls.device = 'vdf'
+
+ # Create a volume and wait for it to become ready for attach
+ resp, cls.volume = cls.volumes_extensions_client.create_volume(
+ 1, display_name=data_utils.rand_name(cls.__name__ + '_volume'))
+ cls.volumes_extensions_client.wait_for_volume_status(
+ cls.volume['id'], 'available')
+
+ # Server for negative tests
+ resp, server = cls.create_test_server(wait_until='BUILD')
+ resp, resc_server = cls.create_test_server(wait_until='ACTIVE')
+ cls.server_id = server['id']
+ cls.password = server['adminPass']
+ cls.rescue_id = resc_server['id']
+ rescue_password = resc_server['adminPass']
+
+ cls.servers_client.rescue_server(
+ cls.rescue_id, adminPass=rescue_password)
+ cls.servers_client.wait_for_server_status(cls.rescue_id, 'RESCUE')
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.delete_volume(cls.volume['id'])
+ super(ServerRescueNegativeTestJSON, cls).tearDownClass()
+
+ def _detach(self, server_id, volume_id):
+ self.servers_client.detach_volume(server_id, volume_id)
+ self.volumes_extensions_client.wait_for_volume_status(volume_id,
+ 'available')
+
+ def _unrescue(self, server_id):
+ resp, body = self.servers_client.unrescue_server(server_id)
+ self.assertEqual(202, resp.status)
+ self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
+
+ def _unpause(self, server_id):
+ resp, body = self.servers_client.unpause_server(server_id)
+ self.assertEqual(202, resp.status)
+ self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_rescue_paused_instance(self):
+ # Rescue a paused server
+ resp, body = self.servers_client.pause_server(self.server_id)
+ self.addCleanup(self._unpause, self.server_id)
+ self.assertEqual(202, resp.status)
+ self.servers_client.wait_for_server_status(self.server_id, 'PAUSED')
+ self.assertRaises(exceptions.Conflict,
+ self.servers_client.rescue_server,
+ self.server_id)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_rescued_vm_reboot(self):
+ self.assertRaises(exceptions.Conflict, self.servers_client.reboot,
+ self.rescue_id, 'HARD')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_rescue_non_existent_server(self):
+ # Rescue a non-existing server
+ non_existent_server = data_utils.rand_uuid()
+ self.assertRaises(exceptions.NotFound,
+ self.servers_client.rescue_server,
+ non_existent_server)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_rescued_vm_rebuild(self):
+ self.assertRaises(exceptions.Conflict,
+ self.servers_client.rebuild,
+ self.rescue_id,
+ self.image_ref_alt)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_rescued_vm_attach_volume(self):
+ # Rescue the server
+ self.servers_client.rescue_server(self.server_id,
+ adminPass=self.password)
+ self.servers_client.wait_for_server_status(self.server_id, 'RESCUE')
+ self.addCleanup(self._unrescue, self.server_id)
+
+ # Attach the volume to the server
+ self.assertRaises(exceptions.Conflict,
+ self.servers_client.attach_volume,
+ self.server_id,
+ self.volume['id'],
+ device='/dev/%s' % self.device)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_rescued_vm_detach_volume(self):
+ # Attach the volume to the server
+ self.servers_client.attach_volume(self.server_id,
+ self.volume['id'],
+ device='/dev/%s' % self.device)
+ self.volumes_extensions_client.wait_for_volume_status(
+ self.volume['id'], 'in-use')
+
+ # Rescue the server
+ self.servers_client.rescue_server(self.server_id,
+ adminPass=self.password)
+ self.servers_client.wait_for_server_status(self.server_id, 'RESCUE')
+ # addCleanup is a LIFO queue
+ self.addCleanup(self._detach, self.server_id, self.volume['id'])
+ self.addCleanup(self._unrescue, self.server_id)
+
+ # Detach the volume from the server expecting failure
+ self.assertRaises(exceptions.Conflict,
+ self.servers_client.detach_volume,
+ self.server_id,
+ self.volume['id'])
+
+
+class ServerRescueNegativeTestXML(ServerRescueNegativeTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/servers/test_servers.py b/tempest/api/compute/servers/test_servers.py
index 203832e..40b97d7 100644
--- a/tempest/api/compute/servers/test_servers.py
+++ b/tempest/api/compute/servers/test_servers.py
@@ -15,11 +15,10 @@
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):
- _interface = 'json'
@classmethod
def setUpClass(cls):
@@ -30,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.
@@ -39,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
@@ -58,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
@@ -71,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')
@@ -86,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')
@@ -103,39 +102,7 @@
self.assertEqual('1.1.1.1', server['accessIPv4'])
self.assertEqual('::babe:202:202', server['accessIPv6'])
- @attr(type='gate')
- def test_delete_server_while_in_shutoff_state(self):
- # Delete a server while it's VM state is Shutoff
- resp, server = self.create_test_server(wait_until='ACTIVE')
- resp, body = self.client.stop(server['id'])
- self.client.wait_for_server_status(server['id'], 'SHUTOFF')
- resp, _ = self.client.delete_server(server['id'])
- self.assertEqual('204', resp['status'])
-
- @attr(type='gate')
- def test_delete_server_while_in_pause_state(self):
- # Delete a server while it's VM state is Pause
- resp, server = self.create_test_server(wait_until='ACTIVE')
- resp, body = self.client.pause_server(server['id'])
- self.client.wait_for_server_status(server['id'], 'PAUSED')
- resp, _ = self.client.delete_server(server['id'])
- self.assertEqual('204', resp['status'])
-
- @attr(type='gate')
- def test_delete_server_while_in_building_state(self):
- # Delete a server while it's VM state is Building
- resp, server = self.create_test_server(wait_until='BUILD')
- resp, _ = self.client.delete_server(server['id'])
- self.assertEqual('204', resp['status'])
-
- @attr(type='gate')
- def test_delete_active_server(self):
- # Delete a server while it's VM state is Active
- resp, server = self.create_test_server(wait_until='ACTIVE')
- resp, _ = self.client.delete_server(server['id'])
- self.assertEqual('204', resp['status'])
-
- @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/servers/test_servers_negative.py b/tempest/api/compute/servers/test_servers_negative.py
index e0181b9..4cccbd6 100644
--- a/tempest/api/compute/servers/test_servers_negative.py
+++ b/tempest/api/compute/servers/test_servers_negative.py
@@ -27,7 +27,6 @@
class ServersNegativeTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
def setUp(self):
super(ServersNegativeTestJSON, self).setUp()
diff --git a/tempest/api/compute/servers/test_servers_negative_new.py b/tempest/api/compute/servers/test_servers_negative_new.py
index 2b2fcf1..42ace76 100644
--- a/tempest/api/compute/servers/test_servers_negative_new.py
+++ b/tempest/api/compute/servers/test_servers_negative_new.py
@@ -24,7 +24,6 @@
class GetConsoleOutputNegativeTestJSON(base.BaseV2ComputeTest,
test.NegativeAutoTest):
- _interface = 'json'
_service = 'compute'
_schema_file = 'compute/servers/get_console_output.json'
diff --git a/tempest/api/compute/servers/test_virtual_interfaces.py b/tempest/api/compute/servers/test_virtual_interfaces.py
index 95703d4..6354996 100644
--- a/tempest/api/compute/servers/test_virtual_interfaces.py
+++ b/tempest/api/compute/servers/test_virtual_interfaces.py
@@ -23,7 +23,6 @@
class VirtualInterfacesTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
diff --git a/tempest/api/compute/servers/test_virtual_interfaces_negative.py b/tempest/api/compute/servers/test_virtual_interfaces_negative.py
index f73218c..87289d8 100644
--- a/tempest/api/compute/servers/test_virtual_interfaces_negative.py
+++ b/tempest/api/compute/servers/test_virtual_interfaces_negative.py
@@ -21,7 +21,6 @@
class VirtualInterfacesNegativeTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
diff --git a/tempest/api/compute/test_authorization.py b/tempest/api/compute/test_authorization.py
index ed72061..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
@@ -27,7 +27,6 @@
class AuthorizationTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
@@ -90,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']
@@ -122,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
@@ -132,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
@@ -182,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
@@ -205,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
@@ -257,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
@@ -301,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
@@ -309,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'}
@@ -318,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'}
@@ -326,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'}
@@ -337,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'}
@@ -349,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'}
@@ -360,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'}
@@ -372,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_extensions.py b/tempest/api/compute/test_extensions.py
index 55146e5..674ca9a 100644
--- a/tempest/api/compute/test_extensions.py
+++ b/tempest/api/compute/test_extensions.py
@@ -26,7 +26,6 @@
class ExtensionsTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
@test.attr(type='gate')
def test_list_extensions(self):
diff --git a/tempest/api/compute/test_live_block_migration.py b/tempest/api/compute/test_live_block_migration.py
index fcd055b..93ff4b0 100644
--- a/tempest/api/compute/test_live_block_migration.py
+++ b/tempest/api/compute/test_live_block_migration.py
@@ -13,22 +13,18 @@
# License for the specific language governing permissions and limitations
# under the License.
-import random
-import string
import testtools
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
class LiveBlockMigrationTestJSON(base.BaseV2ComputeAdminTest):
_host_key = 'OS-EXT-SRV-ATTR:host'
- _interface = 'json'
@classmethod
def setUpClass(cls):
@@ -65,14 +61,6 @@
if host != target_host:
return target_host
- def _get_non_existing_host_name(self):
- random_name = ''.join(
- random.choice(string.ascii_uppercase) for x in range(20))
-
- self.assertNotIn(random_name, self._get_compute_hostnames())
-
- return random_name
-
def _get_server_status(self, server_id):
return self._get_server_details(server_id)['status']
@@ -97,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:
@@ -110,18 +98,6 @@
self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
self.assertEqual(target_host, self._get_host_for_server(server_id))
- @testtools.skipIf(not CONF.compute_feature_enabled.live_migration,
- 'Live migration not available')
- @attr(type='gate')
- def test_invalid_host_for_migration(self):
- # Migrating to an invalid host should not change the status
- server_id = self._get_an_active_server()
- target_host = self._get_non_existing_host_name()
-
- self.assertRaises(exceptions.BadRequest, self._migrate_server_to,
- server_id, target_host)
- self.assertEqual('ACTIVE', self._get_server_status(server_id))
-
@testtools.skipIf(not CONF.compute_feature_enabled.live_migration or not
CONF.compute_feature_enabled.
block_migration_for_live_migration,
@@ -129,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:
@@ -155,13 +131,6 @@
self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
self.assertEqual(target_host, self._get_host_for_server(server_id))
- @classmethod
- def tearDownClass(cls):
- for server_id in cls.created_server_ids:
- cls.servers_client.delete_server(server_id)
-
- super(LiveBlockMigrationTestJSON, cls).tearDownClass()
-
class LiveBlockMigrationTestXML(LiveBlockMigrationTestJSON):
_host_key = (
diff --git a/tempest/api/compute/test_live_block_migration_negative.py b/tempest/api/compute/test_live_block_migration_negative.py
new file mode 100644
index 0000000..c10818e
--- /dev/null
+++ b/tempest/api/compute/test_live_block_migration_negative.py
@@ -0,0 +1,59 @@
+# 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.
+
+
+from tempest.api.compute import base
+from tempest.common.utils import data_utils
+from tempest import config
+from tempest import exceptions
+from tempest import test
+
+CONF = config.CONF
+
+
+class LiveBlockMigrationNegativeTestJSON(base.BaseV2ComputeAdminTest):
+ _host_key = 'OS-EXT-SRV-ATTR:host'
+
+ @classmethod
+ def setUpClass(cls):
+ super(LiveBlockMigrationNegativeTestJSON, cls).setUpClass()
+ if not CONF.compute_feature_enabled.live_migration:
+ raise cls.skipException("Live migration is not enabled")
+ cls.admin_hosts_client = cls.os_adm.hosts_client
+ cls.admin_servers_client = cls.os_adm.servers_client
+
+ def _migrate_server_to(self, server_id, dest_host):
+ _resp, body = self.admin_servers_client.live_migrate_server(
+ server_id, dest_host,
+ CONF.compute_feature_enabled.
+ block_migration_for_live_migration)
+ return body
+
+ @test.attr(type=['negative', 'gate'])
+ def test_invalid_host_for_migration(self):
+ # Migrating to an invalid host should not change the status
+ target_host = data_utils.rand_name('host-')
+ _, server = self.create_test_server(wait_until="ACTIVE")
+ server_id = server['id']
+
+ self.assertRaises(exceptions.BadRequest, self._migrate_server_to,
+ server_id, target_host)
+ self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
+
+
+class LiveBlockMigrationNegativeTestXML(LiveBlockMigrationNegativeTestJSON):
+ _host_key = (
+ '{http://docs.openstack.org/compute/ext/extended_status/api/v1.1}host')
+ _interface = 'xml'
diff --git a/tempest/api/compute/test_quotas.py b/tempest/api/compute/test_quotas.py
index 112e4fb..4db8c56 100644
--- a/tempest/api/compute/test_quotas.py
+++ b/tempest/api/compute/test_quotas.py
@@ -14,11 +14,10 @@
# under the License.
from tempest.api.compute import base
-from tempest.test import attr
+from tempest import test
class QuotasTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
@@ -28,6 +27,9 @@
resp, tenants = cls.admin_client.list_tenants()
cls.tenant_id = [tnt['id'] for tnt in tenants if tnt['name'] ==
cls.client.tenant_name][0]
+ resp, users = cls.admin_client.list_users_for_tenant(cls.tenant_id)
+ cls.user_id = [user['id'] for user in users if user['name'] ==
+ cls.client.user][0]
cls.default_quota_set = set(('injected_file_content_bytes',
'metadata_items', 'injected_files',
'ram', 'floating_ips',
@@ -36,7 +38,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'])
@@ -46,7 +48,15 @@
sorted(quota_set.keys()))
self.assertEqual(quota_set['id'], self.tenant_id)
- @attr(type='smoke')
+ # get the quota set using user id
+ resp, quota_set = self.client.get_quota_set(self.tenant_id,
+ self.user_id)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(sorted(expected_quota_set),
+ sorted(quota_set.keys()))
+ self.assertEqual(quota_set['id'], self.tenant_id)
+
+ @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'])
@@ -56,7 +66,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_agents.py b/tempest/api/compute/v3/admin/test_agents.py
new file mode 100644
index 0000000..9d01b71
--- /dev/null
+++ b/tempest/api/compute/v3/admin/test_agents.py
@@ -0,0 +1,91 @@
+# 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.
+
+from tempest.api.compute import base
+from tempest import test
+
+
+class AgentsAdminV3Test(base.BaseV3ComputeAdminTest):
+
+ """
+ Tests Agents API that require admin privileges
+ """
+
+ @classmethod
+ def setUpClass(cls):
+ super(AgentsAdminV3Test, cls).setUpClass()
+ cls.client = cls.agents_admin_client
+
+ @test.attr(type='gate')
+ def test_create_update_list_delete_agents(self):
+
+ """
+ 1. Create 2 agents.
+ 2. Update one of the agents.
+ 3. List all agent builds.
+ 4. List the agent builds by the filter.
+ 5. Delete agents.
+ """
+ params_kvm = expected_kvm = {'hypervisor': 'kvm',
+ 'os': 'win',
+ 'architecture': 'x86',
+ 'version': '7.0',
+ 'url': 'xxx://xxxx/xxx/xxx',
+ 'md5hash': ("""add6bb58e139be103324d04d"""
+ """82d8f545""")}
+
+ resp, agent_kvm = self.client.create_agent(**params_kvm)
+ self.assertEqual(201, resp.status)
+ for expected_item, value in expected_kvm.items():
+ self.assertEqual(value, agent_kvm[expected_item])
+
+ params_xen = expected_xen = {'hypervisor': 'xen',
+ 'os': 'linux',
+ 'architecture': 'x86',
+ 'version': '7.0',
+ 'url': 'xxx://xxxx/xxx/xxx1',
+ 'md5hash': """add6bb58e139be103324d04d8"""
+ """2d8f546"""}
+
+ resp, agent_xen = self.client.create_agent(**params_xen)
+ self.assertEqual(201, resp.status)
+
+ for expected_item, value in expected_xen.items():
+ self.assertEqual(value, agent_xen[expected_item])
+
+ params_kvm_new = expected_kvm_new = {'version': '8.0',
+ 'url': 'xxx://xxxx/xxx/xxx2',
+ 'md5hash': """add6bb58e139be103"""
+ """324d04d82d8f547"""}
+
+ resp, resp_agent_kvm = self.client.update_agent(agent_kvm['agent_id'],
+ **params_kvm_new)
+ self.assertEqual(200, resp.status)
+ for expected_item, value in expected_kvm_new.items():
+ self.assertEqual(value, resp_agent_kvm[expected_item])
+
+ resp, agents = self.client.list_agents()
+ self.assertEqual(200, resp.status)
+ self.assertTrue(len(agents) > 1)
+
+ params_filter = {'hypervisor': 'kvm'}
+ resp, agent = self.client.list_agents(params_filter)
+ self.assertEqual(200, resp.status)
+ self.assertTrue(len(agent) > 0)
+ self.assertEqual('kvm', agent[0]['hypervisor'])
+
+ resp, _ = self.client.delete_agent(agent_kvm['agent_id'])
+ self.assertEqual(204, resp.status)
+ resp, _ = self.client.delete_agent(agent_xen['agent_id'])
+ self.assertEqual(204, resp.status)
diff --git a/tempest/api/compute/v3/admin/test_aggregates.py b/tempest/api/compute/v3/admin/test_aggregates.py
index b8b478d..e5ec08b 100644
--- a/tempest/api/compute/v3/admin/test_aggregates.py
+++ b/tempest/api/compute/v3/admin/test_aggregates.py
@@ -26,13 +26,11 @@
"""
_host_key = 'os-extended-server-attributes:host'
- _interface = 'json'
@classmethod
def setUpClass(cls):
super(AggregatesAdminV3Test, cls).setUpClass()
cls.client = cls.aggregates_admin_client
- cls.user_client = cls.aggregates_client
cls.aggregate_name_prefix = 'test_aggregate_'
cls.az_name_prefix = 'test_az_'
@@ -48,7 +46,7 @@
resp, aggregate = self.client.create_aggregate(name=aggregate_name)
self.assertEqual(201, resp.status)
self.assertEqual(aggregate_name, aggregate['name'])
- self.assertEqual(None, aggregate['availability_zone'])
+ self.assertIsNone(aggregate['availability_zone'])
resp, _ = self.client.delete_aggregate(aggregate['id'])
self.assertEqual(204, resp.status)
@@ -177,7 +175,7 @@
self.assertEqual(1, len(aggs))
agg = aggs[0]
self.assertEqual(aggregate_name, agg['name'])
- self.assertEqual(None, agg['availability_zone'])
+ self.assertIsNone(agg['availability_zone'])
self.assertIn(self.host, agg['hosts'])
@test.attr(type='gate')
@@ -192,7 +190,7 @@
resp, body = self.client.get_aggregate(aggregate['id'])
self.assertEqual(aggregate_name, body['name'])
- self.assertEqual(None, body['availability_zone'])
+ self.assertIsNone(body['availability_zone'])
self.assertIn(self.host, body['hosts'])
@test.attr(type='gate')
diff --git a/tempest/api/compute/v3/admin/test_aggregates_negative.py b/tempest/api/compute/v3/admin/test_aggregates_negative.py
index 5700460..1505f74 100644
--- a/tempest/api/compute/v3/admin/test_aggregates_negative.py
+++ b/tempest/api/compute/v3/admin/test_aggregates_negative.py
@@ -26,8 +26,6 @@
Tests Aggregates API that require admin privileges
"""
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
super(AggregatesAdminNegativeV3Test, cls).setUpClass()
diff --git a/tempest/api/compute/v3/admin/test_availability_zone.py b/tempest/api/compute/v3/admin/test_availability_zone.py
index 57ac869..9ca8953 100644
--- a/tempest/api/compute/v3/admin/test_availability_zone.py
+++ b/tempest/api/compute/v3/admin/test_availability_zone.py
@@ -23,13 +23,10 @@
Tests Availability Zone API List
"""
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
super(AZAdminV3Test, cls).setUpClass()
cls.client = cls.availability_zone_admin_client
- cls.non_adm_client = cls.availability_zone_client
@attr(type='gate')
def test_get_availability_zone_list(self):
@@ -45,11 +42,3 @@
self.client.get_availability_zone_list_detail()
self.assertEqual(200, resp.status)
self.assertTrue(len(availability_zone) > 0)
-
- @attr(type='gate')
- def test_get_availability_zone_list_with_non_admin_user(self):
- # List of availability zone with non-administrator user
- resp, availability_zone = \
- self.non_adm_client.get_availability_zone_list()
- self.assertEqual(200, resp.status)
- self.assertTrue(len(availability_zone) > 0)
diff --git a/tempest/api/compute/v3/admin/test_availability_zone_negative.py b/tempest/api/compute/v3/admin/test_availability_zone_negative.py
index 180f298..f3af6df 100644
--- a/tempest/api/compute/v3/admin/test_availability_zone_negative.py
+++ b/tempest/api/compute/v3/admin/test_availability_zone_negative.py
@@ -24,8 +24,6 @@
Tests Availability Zone API List
"""
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
super(AZAdminNegativeV3Test, cls).setUpClass()
diff --git a/tempest/api/compute/v3/admin/test_flavors.py b/tempest/api/compute/v3/admin/test_flavors.py
new file mode 100644
index 0000000..401eb85
--- /dev/null
+++ b/tempest/api/compute/v3/admin/test_flavors.py
@@ -0,0 +1,309 @@
+# 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 import base
+from tempest.common.utils import data_utils
+from tempest import exceptions
+from tempest import test
+
+
+class FlavorsAdminV3Test(base.BaseV3ComputeAdminTest):
+
+ """
+ Tests Flavors API Create and Delete that require admin privileges
+ """
+
+ @classmethod
+ def setUpClass(cls):
+ super(FlavorsAdminV3Test, cls).setUpClass()
+
+ cls.client = cls.flavors_admin_client
+ cls.user_client = cls.flavors_client
+ cls.flavor_name_prefix = 'test_flavor_'
+ cls.ram = 512
+ cls.vcpus = 1
+ cls.disk = 10
+ cls.ephemeral = 10
+ 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, 204)
+ self.client.wait_for_resource_deletion(flavor_id)
+
+ def _create_flavor(self, flavor_id):
+ # Create a flavor and ensure it is listed
+ # This operation requires the user to have 'admin' role
+ flavor_name = data_utils.rand_name(self.flavor_name_prefix)
+
+ # Create the flavor
+ resp, flavor = self.client.create_flavor(flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ flavor_id,
+ ephemeral=self.ephemeral,
+ swap=self.swap,
+ rxtx=self.rxtx)
+ self.addCleanup(self.flavor_clean_up, flavor['id'])
+ self.assertEqual(201, resp.status)
+ self.assertEqual(flavor['name'], flavor_name)
+ self.assertEqual(flavor['vcpus'], self.vcpus)
+ self.assertEqual(flavor['disk'], self.disk)
+ self.assertEqual(flavor['ram'], self.ram)
+ self.assertEqual(flavor['swap'], self.swap)
+ if test.is_extension_enabled("os-flavor-rxtx", "compute_v3"):
+ self.assertEqual(flavor['os-flavor-rxtx:rxtx_factor'], self.rxtx)
+ self.assertEqual(flavor['ephemeral'],
+ self.ephemeral)
+ self.assertEqual(flavor['flavor-access:is_public'], True)
+
+ # Verify flavor is retrieved
+ resp, flavor = self.client.get_flavor_details(flavor['id'])
+ self.assertEqual(resp.status, 200)
+ self.assertEqual(flavor['name'], flavor_name)
+
+ return flavor['id']
+
+ @test.attr(type='gate')
+ def test_create_flavor_with_int_id(self):
+ flavor_id = data_utils.rand_int_id(start=1000)
+ new_flavor_id = self._create_flavor(flavor_id)
+ self.assertEqual(new_flavor_id, str(flavor_id))
+
+ @test.attr(type='gate')
+ def test_create_flavor_with_uuid_id(self):
+ flavor_id = str(uuid.uuid4())
+ new_flavor_id = self._create_flavor(flavor_id)
+ self.assertEqual(new_flavor_id, flavor_id)
+
+ @test.attr(type='gate')
+ def test_create_flavor_with_none_id(self):
+ # If nova receives a request with None as flavor_id,
+ # nova generates flavor_id of uuid.
+ flavor_id = None
+ new_flavor_id = self._create_flavor(flavor_id)
+ self.assertEqual(new_flavor_id, str(uuid.UUID(new_flavor_id)))
+
+ @test.attr(type='gate')
+ def test_create_flavor_verify_entry_in_list_details(self):
+ # Create a flavor and ensure it's details are listed
+ # This operation requires the user to have 'admin' role
+ flavor_name = data_utils.rand_name(self.flavor_name_prefix)
+ new_flavor_id = data_utils.rand_int_id(start=1000)
+
+ # Create the flavor
+ 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.addCleanup(self.flavor_clean_up, flavor['id'])
+ flag = False
+ # Verify flavor is retrieved
+ resp, flavors = self.client.list_flavors_with_detail()
+ self.assertEqual(resp.status, 200)
+ for flavor in flavors:
+ if flavor['name'] == flavor_name:
+ flag = True
+ self.assertTrue(flag)
+
+ @test.attr(type='gate')
+ def test_create_list_flavor_without_extra_data(self):
+ # Create a flavor and ensure it is listed
+ # This operation requires the user to have 'admin' role
+
+ def verify_flavor_response_extension(flavor):
+ # check some extensions for the flavor create/show/detail response
+ self.assertEqual(flavor['swap'], 0)
+ if test.is_extension_enabled("os-flavor-rxtx", "compute_v3"):
+ self.assertEqual(int(flavor['os-flavor-rxtx:rxtx_factor']), 1)
+ self.assertEqual(int(flavor['ephemeral']), 0)
+ self.assertEqual(flavor['flavor-access:is_public'], True)
+
+ flavor_name = data_utils.rand_name(self.flavor_name_prefix)
+ new_flavor_id = data_utils.rand_int_id(start=1000)
+
+ # Create the flavor
+ resp, flavor = self.client.create_flavor(flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ new_flavor_id)
+ self.addCleanup(self.flavor_clean_up, flavor['id'])
+ self.assertEqual(201, resp.status)
+ self.assertEqual(flavor['name'], flavor_name)
+ self.assertEqual(flavor['ram'], self.ram)
+ self.assertEqual(flavor['vcpus'], self.vcpus)
+ self.assertEqual(flavor['disk'], self.disk)
+ self.assertEqual(int(flavor['id']), new_flavor_id)
+ verify_flavor_response_extension(flavor)
+
+ # Verify flavor is retrieved
+ resp, flavor = self.client.get_flavor_details(new_flavor_id)
+ self.assertEqual(resp.status, 200)
+ self.assertEqual(flavor['name'], flavor_name)
+ verify_flavor_response_extension(flavor)
+
+ # Check if flavor is present in list
+ resp, flavors = self.user_client.list_flavors_with_detail()
+ self.assertEqual(resp.status, 200)
+ for flavor in flavors:
+ if flavor['name'] == flavor_name:
+ verify_flavor_response_extension(flavor)
+ flag = True
+ self.assertTrue(flag)
+
+ @test.skip_because(bug="1209101")
+ @test.attr(type='gate')
+ def test_list_non_public_flavor(self):
+ # Create a flavor with os-flavor-access:is_public false should
+ # be present in list_details.
+ # This operation requires the user to have 'admin' role
+ flavor_name = data_utils.rand_name(self.flavor_name_prefix)
+ new_flavor_id = data_utils.rand_int_id(start=1000)
+
+ # Create the flavor
+ resp, flavor = self.client.create_flavor(flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ new_flavor_id,
+ is_public="False")
+ self.addCleanup(self.flavor_clean_up, flavor['id'])
+ # Verify flavor is retrieved
+ flag = False
+ resp, flavors = self.client.list_flavors_with_detail()
+ self.assertEqual(resp.status, 200)
+ for flavor in flavors:
+ if flavor['name'] == flavor_name:
+ flag = True
+ self.assertTrue(flag)
+
+ # Verify flavor is not retrieved with other user
+ flag = False
+ resp, flavors = self.user_client.list_flavors_with_detail()
+ self.assertEqual(resp.status, 200)
+ for flavor in flavors:
+ if flavor['name'] == flavor_name:
+ flag = True
+ self.assertFalse(flag)
+
+ @test.attr(type='gate')
+ def test_create_server_with_non_public_flavor(self):
+ # Create a flavor with os-flavor-access:is_public false
+ flavor_name = data_utils.rand_name(self.flavor_name_prefix)
+ new_flavor_id = data_utils.rand_int_id(start=1000)
+
+ # Create the flavor
+ resp, flavor = self.client.create_flavor(flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ new_flavor_id,
+ is_public="False")
+ self.addCleanup(self.flavor_clean_up, flavor['id'])
+ self.assertEqual(201, resp.status)
+
+ # Verify flavor is not used by other user
+ self.assertRaises(exceptions.BadRequest,
+ self.servers_client.create_server,
+ 'test', self.image_ref, flavor['id'])
+
+ @test.attr(type='gate')
+ def test_list_public_flavor_with_other_user(self):
+ # Create a Flavor with public access.
+ # Try to List/Get flavor with another user
+ flavor_name = data_utils.rand_name(self.flavor_name_prefix)
+ new_flavor_id = data_utils.rand_int_id(start=1000)
+
+ # Create the flavor
+ resp, flavor = self.client.create_flavor(flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ new_flavor_id,
+ is_public="True")
+ self.addCleanup(self.flavor_clean_up, flavor['id'])
+ flag = False
+ self.new_client = self.flavors_client
+ # Verify flavor is retrieved with new user
+ resp, flavors = self.new_client.list_flavors_with_detail()
+ self.assertEqual(resp.status, 200)
+ for flavor in flavors:
+ if flavor['name'] == flavor_name:
+ flag = True
+ self.assertTrue(flag)
+
+ @test.attr(type='gate')
+ def test_is_public_string_variations(self):
+ flavor_id_not_public = data_utils.rand_int_id(start=1000)
+ flavor_name_not_public = data_utils.rand_name(self.flavor_name_prefix)
+ flavor_id_public = data_utils.rand_int_id(start=1000)
+ flavor_name_public = data_utils.rand_name(self.flavor_name_prefix)
+
+ # Create a non public flavor
+ resp, flavor = self.client.create_flavor(flavor_name_not_public,
+ self.ram, self.vcpus,
+ self.disk,
+ flavor_id_not_public,
+ is_public="False")
+ self.addCleanup(self.flavor_clean_up, flavor['id'])
+
+ # Create a public flavor
+ resp, flavor = self.client.create_flavor(flavor_name_public,
+ self.ram, self.vcpus,
+ self.disk,
+ flavor_id_public,
+ is_public="True")
+ self.addCleanup(self.flavor_clean_up, flavor['id'])
+
+ def _flavor_lookup(flavors, flavor_name):
+ for flavor in flavors:
+ if flavor['name'] == flavor_name:
+ return flavor
+ return None
+
+ def _test_string_variations(variations, flavor_name):
+ for string in variations:
+ params = {'is_public': string}
+ r, flavors = self.client.list_flavors_with_detail(params)
+ self.assertEqual(r.status, 200)
+ flavor = _flavor_lookup(flavors, flavor_name)
+ self.assertIsNotNone(flavor)
+
+ _test_string_variations(['f', 'false', 'no', '0'],
+ flavor_name_not_public)
+
+ _test_string_variations(['t', 'true', 'yes', '1'],
+ flavor_name_public)
+
+ @test.attr(type='gate')
+ def test_create_flavor_using_string_ram(self):
+ flavor_name = data_utils.rand_name(self.flavor_name_prefix)
+ new_flavor_id = data_utils.rand_int_id(start=1000)
+
+ ram = " 1024 "
+ resp, flavor = self.client.create_flavor(flavor_name,
+ ram, self.vcpus,
+ self.disk,
+ new_flavor_id)
+ self.addCleanup(self.flavor_clean_up, flavor['id'])
+ self.assertEqual(201, resp.status)
+ self.assertEqual(flavor['name'], flavor_name)
+ self.assertEqual(flavor['vcpus'], self.vcpus)
+ self.assertEqual(flavor['disk'], self.disk)
+ self.assertEqual(flavor['ram'], int(ram))
+ self.assertEqual(int(flavor['id']), new_flavor_id)
diff --git a/tempest/api/compute/v3/admin/test_flavors_access.py b/tempest/api/compute/v3/admin/test_flavors_access.py
index 43dc726..03305ff 100644
--- a/tempest/api/compute/v3/admin/test_flavors_access.py
+++ b/tempest/api/compute/v3/admin/test_flavors_access.py
@@ -25,8 +25,6 @@
Add and remove Flavor Access require admin privileges.
"""
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
super(FlavorsAccessV3Test, cls).setUpClass()
diff --git a/tempest/api/compute/v3/admin/test_flavors_access_negative.py b/tempest/api/compute/v3/admin/test_flavors_access_negative.py
index 6a2e826..334d124 100644
--- a/tempest/api/compute/v3/admin/test_flavors_access_negative.py
+++ b/tempest/api/compute/v3/admin/test_flavors_access_negative.py
@@ -28,8 +28,6 @@
Add and remove Flavor Access require admin privileges.
"""
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
super(FlavorsAccessNegativeV3Test, cls).setUpClass()
diff --git a/tempest/api/compute/v3/admin/test_flavors_extra_specs.py b/tempest/api/compute/v3/admin/test_flavors_extra_specs.py
index 4d22027..29cd8db 100644
--- a/tempest/api/compute/v3/admin/test_flavors_extra_specs.py
+++ b/tempest/api/compute/v3/admin/test_flavors_extra_specs.py
@@ -26,8 +26,6 @@
GET Flavor Extra specs can be performed even by without admin privileges.
"""
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
super(FlavorsExtraSpecsV3Test, cls).setUpClass()
diff --git a/tempest/api/compute/v3/admin/test_flavors_extra_specs_negative.py b/tempest/api/compute/v3/admin/test_flavors_extra_specs_negative.py
index 98e6e3d..e9c04a3 100644
--- a/tempest/api/compute/v3/admin/test_flavors_extra_specs_negative.py
+++ b/tempest/api/compute/v3/admin/test_flavors_extra_specs_negative.py
@@ -27,8 +27,6 @@
SET, UNSET, UPDATE Flavor Extra specs require admin privileges.
"""
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
super(FlavorsExtraSpecsNegativeV3Test, cls).setUpClass()
diff --git a/tempest/api/compute/v3/admin/test_flavors_negative.py b/tempest/api/compute/v3/admin/test_flavors_negative.py
new file mode 100644
index 0000000..3f8a2da
--- /dev/null
+++ b/tempest/api/compute/v3/admin/test_flavors_negative.py
@@ -0,0 +1,333 @@
+# 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 import base
+from tempest.common.utils import data_utils
+from tempest import exceptions
+from tempest import test
+
+
+class FlavorsAdminNegativeV3Test(base.BaseV3ComputeAdminTest):
+
+ """
+ Tests Flavors API Create and Delete that require admin privileges
+ """
+
+ @classmethod
+ def setUpClass(cls):
+ super(FlavorsAdminNegativeV3Test, cls).setUpClass()
+
+ cls.client = cls.flavors_admin_client
+ cls.user_client = cls.flavors_client
+ cls.flavor_name_prefix = 'test_flavor_'
+ cls.ram = 512
+ cls.vcpus = 1
+ cls.disk = 10
+ cls.ephemeral = 10
+ 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, 204)
+ 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
+ # Create a test flavor
+ flavor_name = data_utils.rand_name(self.flavor_name_prefix)
+
+ # no need to specify flavor_id, we can get the flavor_id from a
+ # response of create_flavor() call.
+ resp, flavor = self.client.create_flavor(flavor_name,
+ self.ram,
+ self.vcpus, self.disk,
+ '',
+ ephemeral=self.ephemeral,
+ swap=self.swap,
+ rxtx=self.rxtx)
+ # Delete the flavor
+ new_flavor_id = flavor['id']
+ resp_delete, body = self.client.delete_flavor(new_flavor_id)
+ self.assertEqual(201, resp.status)
+ self.assertEqual(204, resp_delete.status)
+
+ # Deleted flavors can be seen via detailed GET
+ resp, flavor = self.client.get_flavor_details(new_flavor_id)
+ self.assertEqual(resp.status, 200)
+ self.assertEqual(flavor['name'], flavor_name)
+
+ # Deleted flavors should not show up in a list however
+ resp, flavors = self.client.list_flavors_with_detail()
+ self.assertEqual(resp.status, 200)
+ flag = True
+ for flavor in flavors:
+ if flavor['name'] == flavor_name:
+ flag = False
+ 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)
+ new_flavor_id = str(uuid.uuid4())
+
+ self.assertRaises(exceptions.Unauthorized,
+ self.user_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_flavor_as_user(self):
+ # only admin user can delete a flavor
+ self.assertRaises(exceptions.Unauthorized,
+ 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)
+
+ @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(201, 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/v3/admin/test_hosts.py b/tempest/api/compute/v3/admin/test_hosts.py
index 2c9369f..8cb1f23 100644
--- a/tempest/api/compute/v3/admin/test_hosts.py
+++ b/tempest/api/compute/v3/admin/test_hosts.py
@@ -23,8 +23,6 @@
Tests hosts API using admin privileges.
"""
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
super(HostsAdminV3Test, cls).setUpClass()
diff --git a/tempest/api/compute/v3/admin/test_hosts_negative.py b/tempest/api/compute/v3/admin/test_hosts_negative.py
index ac5d7de..79cd97f 100644
--- a/tempest/api/compute/v3/admin/test_hosts_negative.py
+++ b/tempest/api/compute/v3/admin/test_hosts_negative.py
@@ -24,8 +24,6 @@
Tests hosts API using admin privileges.
"""
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
super(HostsAdminNegativeV3Test, cls).setUpClass()
diff --git a/tempest/api/compute/v3/admin/test_hypervisor.py b/tempest/api/compute/v3/admin/test_hypervisor.py
index 0f96bba..93d4441 100644
--- a/tempest/api/compute/v3/admin/test_hypervisor.py
+++ b/tempest/api/compute/v3/admin/test_hypervisor.py
@@ -23,8 +23,6 @@
Tests Hypervisors API that require admin privileges
"""
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
super(HypervisorAdminV3Test, cls).setUpClass()
diff --git a/tempest/api/compute/v3/admin/test_hypervisor_negative.py b/tempest/api/compute/v3/admin/test_hypervisor_negative.py
index aee354a..45642b7 100644
--- a/tempest/api/compute/v3/admin/test_hypervisor_negative.py
+++ b/tempest/api/compute/v3/admin/test_hypervisor_negative.py
@@ -27,8 +27,6 @@
Tests Hypervisors API that require admin privileges
"""
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
super(HypervisorAdminNegativeV3Test, cls).setUpClass()
diff --git a/tempest/api/compute/v3/admin/test_instance_usage_audit_log.py b/tempest/api/compute/v3/admin/test_instance_usage_audit_log.py
deleted file mode 100644
index a86b7f5..0000000
--- a/tempest/api/compute/v3/admin/test_instance_usage_audit_log.py
+++ /dev/null
@@ -1,59 +0,0 @@
-# Copyright 2013 IBM Corporation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import datetime
-import urllib
-
-from tempest.api.compute import base
-from tempest import test
-
-
-class InstanceUsageAuditLogV3Test(base.BaseV3ComputeAdminTest):
-
- _interface = 'json'
-
- @classmethod
- def setUpClass(cls):
- super(InstanceUsageAuditLogV3Test, cls).setUpClass()
- cls.adm_client = cls.instance_usages_audit_log_admin_client
-
- @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()
- self.assertEqual(200, resp.status)
- expected_items = ['total_errors', 'total_instances', 'log',
- 'num_hosts_running', 'num_hosts_done',
- 'num_hosts', 'hosts_not_run', 'overall_status',
- 'period_ending', 'period_beginning',
- 'num_hosts_not_run']
- for item in expected_items:
- self.assertIn(item, body)
-
- @test.attr(type='gate')
- def test_list_instance_usage_audit_logs_with_filter_before(self):
- # Get instance usage audit log before specified time
- ending_time = datetime.datetime(2012, 12, 24)
- resp, body = self.adm_client.list_instance_usage_audit_logs(
- urllib.quote(ending_time.strftime("%Y-%m-%d %H:%M:%S")))
-
- self.assertEqual(200, resp.status)
- expected_items = ['total_errors', 'total_instances', 'log',
- 'num_hosts_running', 'num_hosts_done', 'num_hosts',
- 'hosts_not_run', 'overall_status', 'period_ending',
- 'period_beginning', 'num_hosts_not_run']
- for item in expected_items:
- self.assertIn(item, body)
- self.assertEqual(body['period_ending'], "2012-12-23 23:00:00")
diff --git a/tempest/api/compute/v3/admin/test_instance_usage_audit_log_negative.py b/tempest/api/compute/v3/admin/test_instance_usage_audit_log_negative.py
deleted file mode 100644
index 0438825..0000000
--- a/tempest/api/compute/v3/admin/test_instance_usage_audit_log_negative.py
+++ /dev/null
@@ -1,41 +0,0 @@
-# Copyright 2013 IBM 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.
-
-from tempest.api.compute import base
-from tempest import exceptions
-from tempest import test
-
-
-class InstanceUsageLogNegativeV3Test(base.BaseV3ComputeAdminTest):
-
- _interface = 'json'
-
- @classmethod
- def setUpClass(cls):
- super(InstanceUsageLogNegativeV3Test, cls).setUpClass()
- cls.adm_client = cls.instance_usages_audit_log_admin_client
-
- @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,
- self.instance_usages_audit_log_client.
- list_instance_usage_audit_logs)
-
- @test.attr(type=['negative', 'gate'])
- def test_get_instance_usage_audit_logs_with_invalid_time(self):
- self.assertRaises(exceptions.BadRequest,
- self.adm_client.list_instance_usage_audit_logs,
- "invalid_time")
diff --git a/tempest/api/compute/v3/admin/test_quotas.py b/tempest/api/compute/v3/admin/test_quotas.py
index ccb9d8e..917c115 100644
--- a/tempest/api/compute/v3/admin/test_quotas.py
+++ b/tempest/api/compute/v3/admin/test_quotas.py
@@ -16,23 +16,19 @@
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest import config
-from tempest import exceptions
from tempest import test
CONF = config.CONF
class QuotasAdminV3Test(base.BaseV3ComputeAdminTest):
- _interface = 'json'
force_tenant_isolation = True
@classmethod
def setUpClass(cls):
super(QuotasAdminV3Test, cls).setUpClass()
- cls.auth_url = CONF.identity.uri
cls.client = cls.quotas_client
cls.adm_client = cls.quotas_admin_client
- cls.identity_admin_client = cls._get_identity_admin_client()
# NOTE(afazekas): these test cases should always create and use a new
# tenant most of them should be skipped if we can't do that
@@ -49,17 +45,33 @@
def test_get_default_quotas(self):
# Admin can get the default resource quota set for a tenant
expected_quota_set = self.default_quota_set | set(['id'])
- resp, quota_set = self.client.get_default_quota_set(
+ resp, quota_set = self.adm_client.get_default_quota_set(
self.demo_tenant_id)
self.assertEqual(200, resp.status)
self.assertEqual(sorted(expected_quota_set),
sorted(quota_set.keys()))
self.assertEqual(quota_set['id'], self.demo_tenant_id)
+ @test.attr(type='smoke')
+ def test_get_quota_set_detail(self):
+ # Admin can get the detail of resource quota set for a tenant
+ expected_quota_set = self.default_quota_set | set(['id'])
+ expected_detail = ['reserved', 'limit', 'in_use']
+ resp, quota_set = self.adm_client.get_quota_set_detail(
+ self.demo_tenant_id)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(sorted(expected_quota_set), sorted(quota_set.keys()))
+ self.assertEqual(quota_set['id'], self.demo_tenant_id)
+ for quota in quota_set:
+ if quota == 'id':
+ continue
+ self.assertEqual(sorted(expected_detail),
+ sorted(quota_set[quota].keys()))
+
@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.client.get_default_quota_set(
+ resp, default_quota_set = self.adm_client.get_default_quota_set(
self.demo_tenant_id)
new_quota_set = {'metadata_items': 256,
'ram': 10240, 'floating_ips': 20, 'fixed_ips': 10,
@@ -98,55 +110,25 @@
self.assertEqual(200, resp.status)
self.assertEqual(quota_set['ram'], 5120)
- # TODO(afazekas): Add dedicated tenant to the skiped quota tests
- # it can be moved into the setUpClass as well
@test.attr(type='gate')
- def test_create_server_when_cpu_quota_is_full(self):
- # Disallow server creation when tenant's vcpu quota is full
- resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
- default_vcpu_quota = quota_set['cores']
- vcpu_quota = 0 # Set the quota to zero to conserve resources
+ def test_delete_quota(self):
+ # Admin can delete the resource quota set for a tenant
+ tenant_name = data_utils.rand_name('cpu_quota_tenant_')
+ tenant_desc = tenant_name + '-desc'
+ identity_client = self.os_adm.identity_client
+ _, tenant = identity_client.create_tenant(name=tenant_name,
+ description=tenant_desc)
+ tenant_id = tenant['id']
+ self.addCleanup(identity_client.delete_tenant, tenant_id)
+ resp, quota_set_default = self.adm_client.get_quota_set(tenant_id)
+ self.assertEqual(200, resp.status)
+ ram_default = quota_set_default['ram']
- resp, quota_set = self.adm_client.update_quota_set(self.demo_tenant_id,
- force=True,
- cores=vcpu_quota)
+ self.adm_client.update_quota_set(tenant_id, ram='5120')
+ self.assertEqual(200, resp.status)
+ resp, _ = self.adm_client.delete_quota_set(tenant_id)
+ self.assertEqual(204, resp.status)
- self.addCleanup(self.adm_client.update_quota_set, self.demo_tenant_id,
- cores=default_vcpu_quota)
- self.assertRaises(exceptions.OverLimit, self.create_test_server)
-
- @test.attr(type='gate')
- def test_create_server_when_memory_quota_is_full(self):
- # Disallow server creation when tenant's memory quota is full
- resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
- default_mem_quota = quota_set['ram']
- mem_quota = 0 # Set the quota to zero to conserve resources
-
- self.adm_client.update_quota_set(self.demo_tenant_id,
- force=True,
- ram=mem_quota)
-
- self.addCleanup(self.adm_client.update_quota_set, self.demo_tenant_id,
- ram=default_mem_quota)
- self.assertRaises(exceptions.OverLimit, self.create_test_server)
-
- @test.attr(type='gate')
- def test_update_quota_normal_user(self):
- self.assertRaises(exceptions.Unauthorized,
- self.client.update_quota_set,
- self.demo_tenant_id,
- ram=0)
-
- @test.attr(type=['negative', 'gate'])
- def test_create_server_when_instances_quota_is_full(self):
- # Once instances quota limit is reached, disallow server creation
- resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
- default_instances_quota = quota_set['instances']
- instances_quota = 0 # Set quota to zero to disallow server creation
-
- self.adm_client.update_quota_set(self.demo_tenant_id,
- force=True,
- instances=instances_quota)
- self.addCleanup(self.adm_client.update_quota_set, self.demo_tenant_id,
- instances=default_instances_quota)
- self.assertRaises(exceptions.OverLimit, self.create_test_server)
+ resp, quota_set_new = self.adm_client.get_quota_set(tenant_id)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(ram_default, quota_set_new['ram'])
diff --git a/tempest/api/compute/v3/admin/test_quotas_negative.py b/tempest/api/compute/v3/admin/test_quotas_negative.py
new file mode 100644
index 0000000..d138e80
--- /dev/null
+++ b/tempest/api/compute/v3/admin/test_quotas_negative.py
@@ -0,0 +1,87 @@
+# Copyright 2013 OpenStack Foundation
+# 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.
+
+from tempest.api.compute import base
+from tempest import exceptions
+from tempest import test
+
+
+class QuotasAdminNegativeV3Test(base.BaseV3ComputeAdminTest):
+ force_tenant_isolation = True
+
+ @classmethod
+ def setUpClass(cls):
+ super(QuotasAdminNegativeV3Test, cls).setUpClass()
+ cls.client = cls.quotas_client
+ cls.adm_client = cls.quotas_admin_client
+
+ # NOTE(afazekas): these test cases should always create and use a new
+ # tenant most of them should be skipped if we can't do that
+ cls.demo_tenant_id = cls.isolated_creds.get_primary_user().get(
+ 'tenantId')
+
+ # TODO(afazekas): Add dedicated tenant to the skiped quota tests
+ # it can be moved into the setUpClass as well
+ @test.attr(type=['negative', 'gate'])
+ def test_create_server_when_cpu_quota_is_full(self):
+ # Disallow server creation when tenant's vcpu quota is full
+ resp, quota_set = self.adm_client.get_quota_set(self.demo_tenant_id)
+ default_vcpu_quota = quota_set['cores']
+ vcpu_quota = 0 # Set the quota to zero to conserve resources
+
+ resp, quota_set = self.adm_client.update_quota_set(self.demo_tenant_id,
+ force=True,
+ cores=vcpu_quota)
+
+ self.addCleanup(self.adm_client.update_quota_set, self.demo_tenant_id,
+ cores=default_vcpu_quota)
+ self.assertRaises(exceptions.OverLimit, self.create_test_server)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_server_when_memory_quota_is_full(self):
+ # Disallow server creation when tenant's memory quota is full
+ resp, quota_set = self.adm_client.get_quota_set(self.demo_tenant_id)
+ default_mem_quota = quota_set['ram']
+ mem_quota = 0 # Set the quota to zero to conserve resources
+
+ self.adm_client.update_quota_set(self.demo_tenant_id,
+ force=True,
+ ram=mem_quota)
+
+ self.addCleanup(self.adm_client.update_quota_set, self.demo_tenant_id,
+ ram=default_mem_quota)
+ self.assertRaises(exceptions.OverLimit, self.create_test_server)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_update_quota_normal_user(self):
+ self.assertRaises(exceptions.Unauthorized,
+ self.client.update_quota_set,
+ self.demo_tenant_id,
+ ram=0)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_server_when_instances_quota_is_full(self):
+ # Once instances quota limit is reached, disallow server creation
+ resp, quota_set = self.adm_client.get_quota_set(self.demo_tenant_id)
+ default_instances_quota = quota_set['instances']
+ instances_quota = 0 # Set quota to zero to disallow server creation
+
+ self.adm_client.update_quota_set(self.demo_tenant_id,
+ force=True,
+ instances=instances_quota)
+ self.addCleanup(self.adm_client.update_quota_set, self.demo_tenant_id,
+ instances=default_instances_quota)
+ self.assertRaises(exceptions.OverLimit, self.create_test_server)
diff --git a/tempest/api/compute/v3/admin/test_servers.py b/tempest/api/compute/v3/admin/test_servers.py
index ef9eedc..579a535 100644
--- a/tempest/api/compute/v3/admin/test_servers.py
+++ b/tempest/api/compute/v3/admin/test_servers.py
@@ -16,8 +16,6 @@
from tempest.common.utils import data_utils
from tempest import exceptions
from tempest import test
-from tempest.test import attr
-from tempest.test import skip_because
class ServersAdminV3Test(base.BaseV3ComputeAdminTest):
@@ -26,9 +24,10 @@
Tests Servers API using admin privileges
"""
- _interface = 'json'
+ _host_key = 'os-extended-server-attributes:host'
@classmethod
+ @test.safe_setup
def setUpClass(cls):
super(ServersAdminV3Test, cls).setUpClass()
cls.client = cls.servers_admin_client
@@ -55,7 +54,7 @@
flavor_id = data_utils.rand_int_id(start=1000)
return flavor_id
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_by_admin(self):
# Listing servers by admin user returns empty list by default
resp, body = self.client.list_servers_with_detail()
@@ -64,7 +63,7 @@
self.assertEqual([], servers)
@test.skip_because(bug='1265416')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_by_admin_with_all_tenants(self):
# Listing servers by admin user with all tenants parameter
# Here should be listed all servers
@@ -76,27 +75,34 @@
self.assertIn(self.s1_name, servers_name)
self.assertIn(self.s2_name, servers_name)
- @attr(type='gate')
- def test_admin_delete_servers_of_others(self):
- # Administrator can delete servers of others
- _, server = self.create_test_server()
- resp, _ = self.client.delete_server(server['id'])
- self.assertEqual('204', resp['status'])
- self.servers_client.wait_for_server_termination(server['id'])
+ @test.attr(type='gate')
+ def test_list_servers_filter_by_existent_host(self):
+ # Filter the list of servers by existent host
+ name = data_utils.rand_name('server')
+ flavor = self.flavor_ref
+ image_id = self.image_ref
+ resp, test_server = self.client.create_server(
+ name, image_id, flavor)
+ self.assertEqual('202', resp['status'])
+ self.addCleanup(self.client.delete_server, test_server['id'])
+ self.client.wait_for_server_status(test_server['id'], 'ACTIVE')
+ resp, server = self.client.get_server(test_server['id'])
+ self.assertEqual(server['status'], 'ACTIVE')
+ hostname = server[self._host_key]
+ params = {'host': hostname}
+ resp, body = self.client.list_servers(params)
+ self.assertEqual('200', resp['status'])
+ servers = body['servers']
+ nonexistent_params = {'host': 'nonexistent_host'}
+ resp, nonexistent_body = self.client.list_servers(
+ nonexistent_params)
+ self.assertEqual('200', resp['status'])
+ nonexistent_servers = nonexistent_body['servers']
+ self.assertIn(test_server['id'], map(lambda x: x['id'], servers))
+ self.assertNotIn(test_server['id'],
+ map(lambda x: x['id'], nonexistent_servers))
- @attr(type='gate')
- def test_delete_server_while_in_error_state(self):
- # Delete a server while it's VM state is error
- resp, server = self.create_test_server(wait_until='ACTIVE')
- resp, body = self.client.reset_state(server['id'], state='error')
- self.assertEqual(202, resp.status)
- # Verify server's state
- resp, server = self.client.get_server(server['id'])
- self.assertEqual(server['status'], 'ERROR')
- resp, _ = self.client.delete_server(server['id'])
- self.assertEqual('204', resp['status'])
-
- @attr(type='gate')
+ @test.attr(type='gate')
def test_reset_state_server(self):
# Reset server's state to 'error'
resp, server = self.client.reset_state(self.s1_id)
@@ -114,8 +120,8 @@
resp, server = self.client.get_server(self.s1_id)
self.assertEqual(server['status'], 'ACTIVE')
- @attr(type='gate')
- @skip_because(bug="1240043")
+ @test.attr(type='gate')
+ @test.skip_because(bug="1240043")
def test_get_server_diagnostics_by_admin(self):
# Retrieve server diagnostics by admin user
resp, diagnostic = self.client.get_server_diagnostics(self.s1_id)
@@ -126,7 +132,7 @@
for key in basic_attrs:
self.assertIn(key, str(diagnostic.keys()))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_filter_by_error_status(self):
# Filter the list of servers by server error status
params = {'status': 'error'}
@@ -142,12 +148,12 @@
self.assertIn(self.s1_id, map(lambda x: x['id'], servers))
self.assertNotIn(self.s2_id, map(lambda x: x['id'], servers))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_rebuild_server_in_error_state(self):
# The server in error state should be rebuilt using the provided
# image and changed to ACTIVE state
- # resetting vm state require admin priviledge
+ # resetting vm state require admin privilege
resp, server = self.client.reset_state(self.s1_id, state='error')
self.assertEqual(202, resp.status)
resp, rebuilt_server = self.non_admin_client.rebuild(
@@ -169,3 +175,13 @@
resp, server = self.non_admin_client.get_server(rebuilt_server['id'])
rebuilt_image_id = server['image']['id']
self.assertEqual(self.image_ref_alt, rebuilt_image_id)
+
+ @test.attr(type='gate')
+ def test_reset_network_inject_network_info(self):
+ resp, server = self.create_test_server(wait_until='ACTIVE')
+ # Reset Network of a Server
+ resp, server_body = self.client.reset_network(server['id'])
+ self.assertEqual(202, resp.status)
+ # Inject the Network Info into Server
+ resp, server = self.client.inject_network_info(server['id'])
+ self.assertEqual(202, resp.status)
diff --git a/tempest/api/compute/v3/admin/test_servers_negative.py b/tempest/api/compute/v3/admin/test_servers_negative.py
index a6a5736..cc1be4e 100644
--- a/tempest/api/compute/v3/admin/test_servers_negative.py
+++ b/tempest/api/compute/v3/admin/test_servers_negative.py
@@ -26,8 +26,6 @@
Tests Servers API using admin privileges
"""
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
super(ServersAdminNegativeV3Test, cls).setUpClass()
diff --git a/tempest/api/compute/v3/admin/test_services.py b/tempest/api/compute/v3/admin/test_services.py
index 8d6e549..b367dad 100644
--- a/tempest/api/compute/v3/admin/test_services.py
+++ b/tempest/api/compute/v3/admin/test_services.py
@@ -24,8 +24,6 @@
Tests Services API. List and Enable/Disable require admin privileges.
"""
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
super(ServicesAdminV3Test, cls).setUpClass()
@@ -50,10 +48,12 @@
@attr(type='gate')
def test_get_service_by_host_name(self):
resp, services = self.client.list_services()
+ self.assertEqual(200, resp.status)
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)
# we could have a periodic job checkin between the 2 service
@@ -71,6 +71,7 @@
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.assertEqual(1, len(services))
diff --git a/tempest/api/compute/v3/admin/test_services_negative.py b/tempest/api/compute/v3/admin/test_services_negative.py
index c270842..3168af2 100644
--- a/tempest/api/compute/v3/admin/test_services_negative.py
+++ b/tempest/api/compute/v3/admin/test_services_negative.py
@@ -25,8 +25,6 @@
Tests Services API. List and Enable/Disable require admin privileges.
"""
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
super(ServicesAdminNegativeV3Test, cls).setUpClass()
diff --git a/tempest/api/compute/v3/admin/test_simple_tenant_usage.py b/tempest/api/compute/v3/admin/test_simple_tenant_usage.py
deleted file mode 100644
index e16332f..0000000
--- a/tempest/api/compute/v3/admin/test_simple_tenant_usage.py
+++ /dev/null
@@ -1,85 +0,0 @@
-# Copyright 2013 NEC Corporation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import datetime
-
-from tempest.api.compute import base
-from tempest import test
-from tempest.test import attr
-import time
-
-
-class TenantUsagesV3Test(base.BaseV3ComputeAdminTest):
-
- _interface = 'json'
-
- @classmethod
- def setUpClass(cls):
- super(TenantUsagesV3Test, cls).setUpClass()
- cls.adm_client = cls.tenant_usages_admin_client
- cls.client = cls.tenant_usages_client
- cls.identity_client = cls._get_identity_admin_client()
-
- resp, tenants = cls.identity_client.list_tenants()
- cls.tenant_id = [tnt['id'] for tnt in tenants if tnt['name'] ==
- cls.client.tenant_name][0]
-
- # Create a server in the demo tenant
- resp, server = cls.create_test_server(wait_until='ACTIVE')
- time.sleep(2)
-
- now = datetime.datetime.now()
- cls.start = cls._parse_strtime(now - datetime.timedelta(days=1))
- cls.end = cls._parse_strtime(now + datetime.timedelta(days=1))
-
- @classmethod
- def _parse_strtime(cls, at):
- # Returns formatted datetime
- return at.strftime('%Y-%m-%dT%H:%M:%S.%f')
-
- @test.skip_because(bug='1265416')
- @attr(type='gate')
- def test_list_usage_all_tenants(self):
- # Get usage for all tenants
- params = {'start': self.start,
- 'end': self.end,
- 'detailed': int(bool(True))}
- resp, tenant_usage = self.adm_client.list_tenant_usages(params)
- self.assertEqual(200, resp.status)
- self.assertEqual(len(tenant_usage), 8)
-
- @test.skip_because(bug='1265416')
- @attr(type='gate')
- def test_get_usage_tenant(self):
- # Get usage for a specific tenant
- params = {'start': self.start,
- 'end': self.end}
- resp, tenant_usage = self.adm_client.get_tenant_usage(
- self.tenant_id, params)
-
- self.assertEqual(200, resp.status)
- self.assertEqual(len(tenant_usage), 8)
-
- @test.skip_because(bug='1265416')
- @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,
- 'end': self.end}
- resp, tenant_usage = self.client.get_tenant_usage(
- self.tenant_id, params)
-
- self.assertEqual(200, resp.status)
- self.assertEqual(len(tenant_usage), 8)
diff --git a/tempest/api/compute/v3/admin/test_simple_tenant_usage_negative.py b/tempest/api/compute/v3/admin/test_simple_tenant_usage_negative.py
deleted file mode 100644
index 17849c5..0000000
--- a/tempest/api/compute/v3/admin/test_simple_tenant_usage_negative.py
+++ /dev/null
@@ -1,73 +0,0 @@
-# Copyright 2013 NEC Corporation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import datetime
-
-from tempest.api.compute import base
-from tempest import exceptions
-from tempest import test
-from tempest.test import attr
-
-
-class TenantUsagesNegativeV3Test(base.BaseV3ComputeAdminTest):
-
- _interface = 'json'
-
- @classmethod
- def setUpClass(cls):
- super(TenantUsagesNegativeV3Test, cls).setUpClass()
- cls.adm_client = cls.os_adm.tenant_usages_client
- cls.client = cls.os.tenant_usages_client
- cls.identity_client = cls._get_identity_admin_client()
- now = datetime.datetime.now()
- cls.start = cls._parse_strtime(now - datetime.timedelta(days=1))
- cls.end = cls._parse_strtime(now + datetime.timedelta(days=1))
-
- @classmethod
- def _parse_strtime(cls, at):
- # Returns formatted datetime
- return at.strftime('%Y-%m-%dT%H:%M:%S.%f')
-
- @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,
- 'end': self.end}
- self.assertRaises(exceptions.NotFound,
- self.adm_client.get_tenant_usage,
- '', params)
-
- @test.skip_because(bug='1265416')
- @attr(type=['negative', 'gate'])
- def test_get_usage_tenant_with_invalid_date(self):
- # Get usage for tenant with invalid date
- params = {'start': self.end,
- 'end': self.start}
- resp, tenants = self.identity_client.list_tenants()
- tenant_id = [tnt['id'] for tnt in tenants if tnt['name'] ==
- self.client.tenant_name][0]
- self.assertRaises(exceptions.BadRequest,
- self.adm_client.get_tenant_usage,
- tenant_id, params)
-
- @test.skip_because(bug='1265416')
- @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,
- 'end': self.end,
- 'detailed': int(bool(True))}
- self.assertRaises(exceptions.Unauthorized,
- self.client.list_tenant_usages, params)
diff --git a/tempest/api/compute/v3/certificates/test_certificates.py b/tempest/api/compute/v3/certificates/test_certificates.py
index 5c980c0..ce025fc 100644
--- a/tempest/api/compute/v3/certificates/test_certificates.py
+++ b/tempest/api/compute/v3/certificates/test_certificates.py
@@ -18,7 +18,6 @@
class CertificatesV3Test(base.BaseV3ComputeTest):
- _interface = 'json'
@attr(type='gate')
def test_create_and_get_root_certificate(self):
diff --git a/tempest/api/compute/v3/flavors/__init__.py b/tempest/api/compute/v3/flavors/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/api/compute/v3/flavors/__init__.py
diff --git a/tempest/api/compute/v3/flavors/test_flavors.py b/tempest/api/compute/v3/flavors/test_flavors.py
new file mode 100644
index 0000000..a0bbba6
--- /dev/null
+++ b/tempest/api/compute/v3/flavors/test_flavors.py
@@ -0,0 +1,127 @@
+# 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.
+
+from tempest.api.compute import base
+from tempest import test
+
+
+class FlavorsV3Test(base.BaseV3ComputeTest):
+
+ @classmethod
+ def setUpClass(cls):
+ super(FlavorsV3Test, cls).setUpClass()
+ cls.client = cls.flavors_client
+
+ @test.attr(type='smoke')
+ def test_list_flavors(self):
+ # List of all flavors should contain the expected flavor
+ resp, flavors = self.client.list_flavors()
+ resp, flavor = self.client.get_flavor_details(self.flavor_ref)
+ flavor_min_detail = {'id': flavor['id'], 'links': flavor['links'],
+ 'name': flavor['name']}
+ self.assertIn(flavor_min_detail, flavors)
+
+ @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)
+
+ @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'])
+
+ @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))
+
+ @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))
+
+ @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()
+ flavor_id = flavors[0]['id']
+
+ params = {'marker': flavor_id}
+ resp, flavors = self.client.list_flavors(params)
+ self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]),
+ 'The list of flavors did not start after the marker.')
+
+ @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()
+ flavor_id = flavors[0]['id']
+
+ params = {'marker': flavor_id}
+ resp, flavors = self.client.list_flavors_with_detail(params)
+ self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]),
+ 'The list of flavors did not start after the marker.')
+
+ @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()
+ flavors = sorted(flavors, key=lambda k: k['disk'])
+ flavor_id = flavors[0]['id']
+
+ params = {'min_disk': flavors[0]['disk'] + 1}
+ resp, flavors = self.client.list_flavors_with_detail(params)
+ self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]))
+
+ @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()
+ flavors = sorted(flavors, key=lambda k: k['ram'])
+ flavor_id = flavors[0]['id']
+
+ params = {'min_ram': flavors[0]['ram'] + 1}
+ resp, flavors = self.client.list_flavors_with_detail(params)
+ self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]))
+
+ @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()
+ flavors = sorted(flavors, key=lambda k: k['disk'])
+ flavor_id = flavors[0]['id']
+
+ params = {'min_disk': flavors[0]['disk'] + 1}
+ resp, flavors = self.client.list_flavors(params)
+ self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]))
+
+ @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()
+ flavors = sorted(flavors, key=lambda k: k['ram'])
+ flavor_id = flavors[0]['id']
+
+ params = {'min_ram': flavors[0]['ram'] + 1}
+ resp, flavors = self.client.list_flavors(params)
+ self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]))
diff --git a/tempest/api/compute/v3/flavors/test_flavors_negative.py b/tempest/api/compute/v3/flavors/test_flavors_negative.py
new file mode 100644
index 0000000..346f6d6
--- /dev/null
+++ b/tempest/api/compute/v3/flavors/test_flavors_negative.py
@@ -0,0 +1,52 @@
+# Copyright 2013 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 testscenarios
+
+from tempest.api.compute import base
+from tempest import test
+
+
+load_tests = testscenarios.load_tests_apply_scenarios
+
+
+class FlavorsListNegativeV3Test(base.BaseV3ComputeTest,
+ test.NegativeAutoTest):
+ _service = 'computev3'
+ _schema_file = 'compute/flavors/flavors_list_v3.json'
+
+ scenarios = test.NegativeAutoTest.generate_scenario(_schema_file)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_list_flavors_with_detail(self):
+ self.execute(self._schema_file)
+
+
+class FlavorDetailsNegativeV3Test(base.BaseV3ComputeTest,
+ test.NegativeAutoTest):
+ _service = 'computev3'
+ _schema_file = 'compute/flavors/flavor_details_v3.json'
+
+ scenarios = test.NegativeAutoTest.generate_scenario(_schema_file)
+
+ @classmethod
+ def setUpClass(cls):
+ super(FlavorDetailsNegativeV3Test, cls).setUpClass()
+ cls.set_resource("flavor", cls.flavor_ref)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_get_flavor_details(self):
+ # flavor details are not returned for non-existent flavors
+ self.execute(self._schema_file)
diff --git a/tempest/api/compute/v3/images/test_image_metadata.py b/tempest/api/compute/v3/images/test_image_metadata.py
deleted file mode 100644
index cd4e5e7..0000000
--- a/tempest/api/compute/v3/images/test_image_metadata.py
+++ /dev/null
@@ -1,111 +0,0 @@
-# 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.
-
-from tempest.api.compute import base
-from tempest.common.utils import data_utils
-from tempest import config
-from tempest.test import attr
-
-CONF = config.CONF
-
-
-class ImagesMetadataTest(base.BaseV2ComputeTest):
- _interface = 'json'
-
- @classmethod
- def setUpClass(cls):
- super(ImagesMetadataTest, cls).setUpClass()
- if not CONF.service_available.glance:
- skip_msg = ("%s skipped as glance is not available" % cls.__name__)
- raise cls.skipException(skip_msg)
-
- cls.servers_client = cls.servers_client
- cls.client = cls.images_client
-
- resp, server = cls.create_test_server(wait_until='ACTIVE')
- cls.server_id = server['id']
-
- # Snapshot the server once to save time
- name = data_utils.rand_name('image')
- resp, _ = cls.client.create_image(cls.server_id, name, {})
- cls.image_id = resp['location'].rsplit('/', 1)[1]
-
- cls.client.wait_for_image_status(cls.image_id, 'ACTIVE')
-
- @classmethod
- def tearDownClass(cls):
- cls.client.delete_image(cls.image_id)
- super(ImagesMetadataTest, cls).tearDownClass()
-
- def setUp(self):
- super(ImagesMetadataTest, self).setUp()
- meta = {'key1': 'value1', 'key2': 'value2'}
- resp, _ = self.client.set_image_metadata(self.image_id, meta)
- self.assertEqual(resp.status, 200)
-
- @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')
- def test_set_image_metadata(self):
- # The metadata for the image should match the new values
- req_metadata = {'meta2': 'value2', 'meta3': 'value3'}
- resp, body = self.client.set_image_metadata(self.image_id,
- req_metadata)
-
- resp, resp_metadata = self.client.list_image_metadata(self.image_id)
- self.assertEqual(req_metadata, resp_metadata)
-
- @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'}
- resp, metadata = self.client.update_image_metadata(self.image_id,
- req_metadata)
-
- resp, resp_metadata = self.client.list_image_metadata(self.image_id)
- expected = {'key1': 'alt1', 'key2': 'value2', 'key3': 'value3'}
- self.assertEqual(expected, resp_metadata)
-
- @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')
- def test_set_image_metadata_item(self):
- # The value provided for the given meta item should be set for
- # the image
- meta = {'key1': 'alt'}
- resp, body = self.client.set_image_metadata_item(self.image_id,
- 'key1', meta)
- resp, resp_metadata = self.client.list_image_metadata(self.image_id)
- expected = {'key1': 'alt', 'key2': 'value2'}
- self.assertEqual(expected, resp_metadata)
-
- @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,
- 'key1')
- resp, resp_metadata = self.client.list_image_metadata(self.image_id)
- expected = {'key2': 'value2'}
- self.assertEqual(expected, resp_metadata)
diff --git a/tempest/api/compute/v3/images/test_image_metadata_negative.py b/tempest/api/compute/v3/images/test_image_metadata_negative.py
deleted file mode 100644
index e76af2c..0000000
--- a/tempest/api/compute/v3/images/test_image_metadata_negative.py
+++ /dev/null
@@ -1,75 +0,0 @@
-# Copyright 2013 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.
-
-from tempest.api.compute import base
-from tempest.common.utils import data_utils
-from tempest import exceptions
-from tempest.test import attr
-
-
-class ImagesMetadataTest(base.BaseV2ComputeTest):
- _interface = 'json'
-
- @classmethod
- def setUpClass(cls):
- super(ImagesMetadataTest, cls).setUpClass()
- cls.client = cls.images_client
-
- @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'])
- def test_update_nonexistent_image_metadata(self):
- # Negative test:An update should not happen for a non-existent image
- meta = {'key1': 'alt1', 'key2': 'alt2'}
- self.assertRaises(exceptions.NotFound,
- self.client.update_image_metadata,
- data_utils.rand_uuid(), meta)
-
- @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'])
- 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'])
- def test_set_nonexistent_image_metadata_item(self):
- # Negative test: Metadata item should not be set to a
- # nonexistent image
- meta = {'key1': 'alt'}
- self.assertRaises(exceptions.NotFound,
- self.client.set_image_metadata_item,
- data_utils.rand_uuid(), 'key1',
- meta)
-
- @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
- self.assertRaises(exceptions.NotFound,
- self.client.delete_image_metadata_item,
- data_utils.rand_uuid(), 'key1')
diff --git a/tempest/api/compute/v3/images/test_images.py b/tempest/api/compute/v3/images/test_images.py
index bbb84fb..bb81626 100644
--- a/tempest/api/compute/v3/images/test_images.py
+++ b/tempest/api/compute/v3/images/test_images.py
@@ -13,17 +13,14 @@
# under the License.
from tempest.api.compute import base
-from tempest import clients
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
class ImagesV3Test(base.BaseV3ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
@@ -32,54 +29,8 @@
skip_msg = ("%s skipped as glance is not available" % cls.__name__)
raise cls.skipException(skip_msg)
cls.client = cls.images_client
- cls.servers_client = cls.servers_client
- if cls.multi_user:
- if CONF.compute.allow_tenant_isolation:
- creds = cls.isolated_creds.get_alt_creds()
- username, tenant_name, password = creds
- cls.alt_manager = clients.Manager(username=username,
- password=password,
- tenant_name=tenant_name)
- else:
- # Use the alt_XXX credentials in the config file
- cls.alt_manager = clients.AltManager()
- cls.alt_client = cls.alt_manager.images_client
-
- def __create_image__(self, server_id, name, meta=None):
- resp, body = self.servers_client.create_image(server_id, name, meta)
- image_id = data_utils.parse_image_id(resp['location'])
- self.addCleanup(self.client.delete_image, image_id)
- self.client.wait_for_image_status(image_id, 'ACTIVE')
- return resp, body
-
- @attr(type=['negative', 'gate'])
- def test_create_image_from_deleted_server(self):
- # An image should not be created if the server instance is removed
- resp, server = self.create_test_server(wait_until='ACTIVE')
-
- # Delete server before trying to create server
- self.servers_client.delete_server(server['id'])
- self.servers_client.wait_for_server_termination(server['id'])
- # Create a new image after server is deleted
- name = data_utils.rand_name('image')
- meta = {'image_type': 'test'}
- self.assertRaises(exceptions.NotFound,
- self.__create_image__,
- server['id'], name, meta)
-
- @attr(type=['negative', 'gate'])
- def test_create_image_from_invalid_server(self):
- # An image should not be created with invalid server id
- # Create a new image with invalid server id
- name = data_utils.rand_name('image')
- meta = {'image_type': 'test'}
- resp = {}
- resp['status'] = None
- self.assertRaises(exceptions.NotFound, self.__create_image__,
- '!@#$%^&*()', name, meta)
-
- @attr(type=['negative', 'gate'])
+ @test.attr(type='gate')
def test_create_image_from_stopped_server(self):
resp, server = self.create_test_server(wait_until='ACTIVE')
self.servers_client.stop(server['id'])
@@ -93,7 +44,7 @@
self.addCleanup(self.client.delete_image, image['id'])
self.assertEqual(snapshot_name, image['name'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_delete_queued_image(self):
snapshot_name = data_utils.rand_name('test-snap-')
resp, server = self.create_test_server(wait_until='ACTIVE')
@@ -103,21 +54,3 @@
wait_until='queued')
resp, body = self.client.delete_image(image['id'])
self.assertEqual('200', resp['status'])
-
- @attr(type=['negative', 'gate'])
- def test_create_image_specify_uuid_35_characters_or_less(self):
- # Return an error if Image ID passed is 35 characters or less
- snapshot_name = data_utils.rand_name('test-snap-')
- test_uuid = ('a' * 35)
- self.assertRaises(exceptions.NotFound,
- self.servers_client.create_image,
- test_uuid, snapshot_name)
-
- @attr(type=['negative', 'gate'])
- def test_create_image_specify_uuid_37_characters_or_more(self):
- # Return an error if Image ID passed is 37 characters or more
- snapshot_name = data_utils.rand_name('test-snap-')
- test_uuid = ('a' * 37)
- self.assertRaises(exceptions.NotFound,
- self.servers_client.create_image,
- test_uuid, snapshot_name)
diff --git a/tempest/api/compute/v3/images/test_images_negative.py b/tempest/api/compute/v3/images/test_images_negative.py
new file mode 100644
index 0000000..0705bdc
--- /dev/null
+++ b/tempest/api/compute/v3/images/test_images_negative.py
@@ -0,0 +1,82 @@
+# 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.
+
+from tempest.api.compute import base
+from tempest.common.utils import data_utils
+from tempest import config
+from tempest import exceptions
+from tempest import test
+
+CONF = config.CONF
+
+
+class ImagesNegativeV3Test(base.BaseV3ComputeTest):
+
+ @classmethod
+ def setUpClass(cls):
+ super(ImagesNegativeV3Test, cls).setUpClass()
+ if not CONF.service_available.glance:
+ skip_msg = ("%s skipped as glance is not available" % cls.__name__)
+ raise cls.skipException(skip_msg)
+ cls.client = cls.images_client
+
+ def __create_image__(self, server_id, name, meta=None):
+ resp, body = self.servers_client.create_image(server_id, name, meta)
+ image_id = data_utils.parse_image_id(resp['location'])
+ self.addCleanup(self.client.delete_image, image_id)
+ self.client.wait_for_image_status(image_id, 'active')
+ 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
+ resp, server = self.create_test_server(wait_until='ACTIVE')
+
+ # Delete server before trying to create server
+ self.servers_client.delete_server(server['id'])
+ self.servers_client.wait_for_server_termination(server['id'])
+ # Create a new image after server is deleted
+ name = data_utils.rand_name('image')
+ meta = {'image_type': 'test'}
+ self.assertRaises(exceptions.NotFound,
+ self.__create_image__,
+ server['id'], name, meta)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_image_from_nonexistent_server(self):
+ # An image should not be created with invalid server id
+ # Create a new image with invalid server id
+ nonexistent_server_id = data_utils.rand_uuid()
+ name = data_utils.rand_name('image')
+ meta = {'image_type': 'test'}
+ self.assertRaises(exceptions.NotFound, self.__create_image__,
+ nonexistent_server_id, name, meta)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_image_specify_uuid_35_characters_or_less(self):
+ # Return an error if Image ID passed is 35 characters or less
+ snapshot_name = data_utils.rand_name('test-snap-')
+ test_uuid = ('a' * 35)
+ self.assertRaises(exceptions.NotFound,
+ self.servers_client.create_image,
+ test_uuid, snapshot_name)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_image_specify_uuid_37_characters_or_more(self):
+ # Return an error if Image ID passed is 37 characters or more
+ snapshot_name = data_utils.rand_name('test-snap-')
+ test_uuid = ('a' * 37)
+ self.assertRaises(exceptions.NotFound,
+ self.servers_client.create_image,
+ test_uuid, snapshot_name)
diff --git a/tempest/api/compute/v3/images/test_images_oneserver.py b/tempest/api/compute/v3/images/test_images_oneserver.py
index 18772df..3aab1e1 100644
--- a/tempest/api/compute/v3/images/test_images_oneserver.py
+++ b/tempest/api/compute/v3/images/test_images_oneserver.py
@@ -13,33 +13,23 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
from tempest.api.compute import base
-from tempest import clients
from tempest.common.utils import data_utils
from tempest import config
from tempest.openstack.common import log as logging
-from tempest.test import attr
+from tempest import test
CONF = config.CONF
LOG = logging.getLogger(__name__)
-class ImagesOneServerTest(base.BaseV2ComputeTest):
- _interface = 'json'
-
- 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(ImagesOneServerTest, self).tearDown()
+class ImagesOneServerV3Test(base.BaseV3ComputeTest):
def setUp(self):
# NOTE(afazekas): Normally we use the same server with all test cases,
# but if it has an issue, we build a new one
- super(ImagesOneServerTest, self).setUp()
+ super(ImagesOneServerV3Test, self).setUp()
# Check if the server is in a clean state after test
try:
self.servers_client.wait_for_server_status(self.server_id,
@@ -53,7 +43,7 @@
@classmethod
def setUpClass(cls):
- super(ImagesOneServerTest, cls).setUpClass()
+ super(ImagesOneServerV3Test, cls).setUpClass()
cls.client = cls.images_client
if not CONF.service_available.glance:
skip_msg = ("%s skipped as glance is not available" % cls.__name__)
@@ -66,63 +56,49 @@
cls.tearDownClass()
raise
- cls.image_ids = []
-
- if cls.multi_user:
- if CONF.compute.allow_tenant_isolation:
- creds = cls.isolated_creds.get_alt_creds()
- username, tenant_name, password = creds
- cls.alt_manager = clients.Manager(username=username,
- password=password,
- tenant_name=tenant_name)
- else:
- # Use the alt_XXX credentials in the config file
- cls.alt_manager = clients.AltManager()
- cls.alt_client = cls.alt_manager.images_client
-
def _get_default_flavor_disk_size(self, flavor_id):
resp, flavor = self.flavors_client.get_flavor_details(flavor_id)
return flavor['disk']
- @testtools.skipUnless(CONF.compute_feature_enabled.create_image,
- 'Environment unable to create images.')
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_create_delete_image(self):
# Create a new image
name = data_utils.rand_name('image')
meta = {'image_type': 'test'}
- resp, body = self.client.create_image(self.server_id, name, meta)
+ resp, body = self.servers_client.create_image(self.server_id,
+ name, meta)
self.assertEqual(202, resp.status)
image_id = data_utils.parse_image_id(resp['location'])
- self.client.wait_for_image_status(image_id, 'ACTIVE')
+ self.client.wait_for_image_status(image_id, 'active')
# Verify the image was created correctly
- resp, image = self.client.get_image(image_id)
+ resp, image = self.client.get_image_meta(image_id)
self.assertEqual(name, image['name'])
- self.assertEqual('test', image['metadata']['image_type'])
+ self.assertEqual('test', image['properties']['image_type'])
- resp, original_image = self.client.get_image(self.image_ref)
+ resp, original_image = self.client.get_image_meta(self.image_ref)
# Verify minRAM is the same as the original image
- self.assertEqual(image['minRam'], original_image['minRam'])
+ self.assertEqual(image['min_ram'], original_image['min_ram'])
# Verify minDisk is the same as the original image or the flavor size
flavor_disk_size = self._get_default_flavor_disk_size(self.flavor_ref)
- self.assertIn(str(image['minDisk']),
- (str(original_image['minDisk']), str(flavor_disk_size)))
+ self.assertIn(str(image['min_disk']),
+ (str(original_image['min_disk']), str(flavor_disk_size)))
# Verify the image was deleted correctly
resp, body = self.client.delete_image(image_id)
- self.assertEqual('204', resp['status'])
+ self.assertEqual('200', resp['status'])
self.client.wait_for_resource_deletion(image_id)
- @attr(type=['gate'])
+ @test.attr(type=['gate'])
def test_create_image_specify_multibyte_character_image_name(self):
# prefix character is:
# http://www.fileformat.info/info/unicode/char/1F4A9/index.htm
utf8_name = data_utils.rand_name(u'\xF0\x9F\x92\xA9')
- resp, body = self.client.create_image(self.server_id, utf8_name)
+ resp, body = self.servers_client.create_image(self.server_id,
+ utf8_name)
image_id = data_utils.parse_image_id(resp['location'])
self.addCleanup(self.client.delete_image, image_id)
self.assertEqual('202', resp['status'])
diff --git a/tempest/api/compute/v3/images/test_images_oneserver_negative.py b/tempest/api/compute/v3/images/test_images_oneserver_negative.py
index bc276d1..7679eee 100644
--- a/tempest/api/compute/v3/images/test_images_oneserver_negative.py
+++ b/tempest/api/compute/v3/images/test_images_oneserver_negative.py
@@ -15,33 +15,30 @@
# under the License.
from tempest.api.compute import base
-from tempest import clients
from tempest.common.utils import data_utils
from tempest import config
from tempest import exceptions
from tempest.openstack.common import log as logging
-from tempest.test import attr
-from tempest.test import skip_because
+from tempest import test
CONF = config.CONF
LOG = logging.getLogger(__name__)
-class ImagesOneServerNegativeTest(base.BaseV2ComputeTest):
- _interface = 'json'
+class ImagesOneServerNegativeV3Test(base.BaseV3ComputeTest):
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(ImagesOneServerNegativeTest, self).tearDown()
+ super(ImagesOneServerNegativeV3Test, self).tearDown()
def setUp(self):
# NOTE(afazekas): Normally we use the same server with all test cases,
# but if it has an issue, we build a new one
- super(ImagesOneServerNegativeTest, self).setUp()
+ super(ImagesOneServerNegativeV3Test, self).setUp()
# Check if the server is in a clean state after test
try:
self.servers_client.wait_for_server_status(self.server_id,
@@ -58,7 +55,7 @@
@classmethod
def setUpClass(cls):
- super(ImagesOneServerNegativeTest, cls).setUpClass()
+ super(ImagesOneServerNegativeV3Test, cls).setUpClass()
cls.client = cls.images_client
if not CONF.service_available.glance:
skip_msg = ("%s skipped as glance is not available" % cls.__name__)
@@ -73,53 +70,44 @@
cls.image_ids = []
- if cls.multi_user:
- if CONF.compute.allow_tenant_isolation:
- creds = cls.isolated_creds.get_alt_creds()
- username, tenant_name, password = creds
- cls.alt_manager = clients.Manager(username=username,
- password=password,
- tenant_name=tenant_name)
- else:
- # Use the alt_XXX credentials in the config file
- cls.alt_manager = clients.AltManager()
- cls.alt_client = cls.alt_manager.images_client
-
- @skip_because(bug="1006725")
- @attr(type=['negative', 'gate'])
+ @test.skip_because(bug="1006725")
+ @test.attr(type=['negative', 'gate'])
def test_create_image_specify_multibyte_character_image_name(self):
# invalid multibyte sequence from:
# http://stackoverflow.com/questions/1301402/
# example-invalid-utf8-string
invalid_name = data_utils.rand_name(u'\xc3\x28')
self.assertRaises(exceptions.BadRequest,
- self.client.create_image, self.server_id,
+ self.servers_client.create_image,
+ self.server_id,
invalid_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_image_specify_invalid_metadata(self):
# Return an error when creating image with invalid metadata
snapshot_name = data_utils.rand_name('test-snap-')
meta = {'': ''}
- self.assertRaises(exceptions.BadRequest, self.client.create_image,
+ self.assertRaises(exceptions.BadRequest,
+ self.servers_client.create_image,
self.server_id, snapshot_name, meta)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_image_specify_metadata_over_limits(self):
# Return an error when creating image with meta data over 256 chars
snapshot_name = data_utils.rand_name('test-snap-')
meta = {'a' * 260: 'b' * 260}
- self.assertRaises(exceptions.BadRequest, self.client.create_image,
+ self.assertRaises(exceptions.BadRequest,
+ self.servers_client.create_image,
self.server_id, snapshot_name, meta)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_second_image_when_first_image_is_being_saved(self):
# Disallow creating another image when first image is being saved
# Create first snapshot
snapshot_name = data_utils.rand_name('test-snap-')
- resp, body = self.client.create_image(self.server_id,
- snapshot_name)
+ resp, body = self.servers_client.create_image(self.server_id,
+ snapshot_name)
self.assertEqual(202, resp.status)
image_id = data_utils.parse_image_id(resp['location'])
self.image_ids.append(image_id)
@@ -127,23 +115,26 @@
# Create second snapshot
alt_snapshot_name = data_utils.rand_name('test-snap-')
- self.assertRaises(exceptions.Conflict, self.client.create_image,
+ self.assertRaises(exceptions.Conflict,
+ self.servers_client.create_image,
self.server_id, alt_snapshot_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_image_specify_name_over_256_chars(self):
# Return an error if snapshot name over 256 characters is passed
snapshot_name = data_utils.rand_name('a' * 260)
- self.assertRaises(exceptions.BadRequest, self.client.create_image,
+ self.assertRaises(exceptions.BadRequest,
+ self.servers_client.create_image,
self.server_id, snapshot_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_image_that_is_not_yet_active(self):
# Return an error while trying to delete an image what is creating
snapshot_name = data_utils.rand_name('test-snap-')
- resp, body = self.client.create_image(self.server_id, snapshot_name)
+ resp, body = self.servers_client.create_image(self.server_id,
+ snapshot_name)
self.assertEqual(202, resp.status)
image_id = data_utils.parse_image_id(resp['location'])
self.image_ids.append(image_id)
@@ -151,7 +142,7 @@
# Do not wait, attempt to delete the image, ensure it's successful
resp, body = self.client.delete_image(image_id)
- self.assertEqual('204', resp['status'])
+ self.assertEqual('200', resp['status'])
self.image_ids.remove(image_id)
self.assertRaises(exceptions.NotFound, self.client.get_image, image_id)
diff --git a/tempest/api/compute/v3/images/test_list_image_filters.py b/tempest/api/compute/v3/images/test_list_image_filters.py
deleted file mode 100644
index 457ca53..0000000
--- a/tempest/api/compute/v3/images/test_list_image_filters.py
+++ /dev/null
@@ -1,225 +0,0 @@
-# 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.
-
-from tempest.api.compute import base
-from tempest import config
-from tempest import exceptions
-from tempest.openstack.common import log as logging
-from tempest.test import attr
-
-CONF = config.CONF
-
-LOG = logging.getLogger(__name__)
-
-
-class ListImageFiltersTest(base.BaseV2ComputeTest):
- _interface = 'json'
-
- @classmethod
- def setUpClass(cls):
- super(ListImageFiltersTest, cls).setUpClass()
- if not CONF.service_available.glance:
- skip_msg = ("%s skipped as glance is not available" % cls.__name__)
- raise cls.skipException(skip_msg)
- cls.client = cls.images_client
- cls.image_ids = []
-
- try:
- resp, cls.server1 = cls.create_test_server()
- resp, cls.server2 = cls.create_test_server(wait_until='ACTIVE')
- # NOTE(sdague) this is faster than doing the sync wait_util on both
- cls.servers_client.wait_for_server_status(cls.server1['id'],
- 'ACTIVE')
-
- # Create images to be used in the filter tests
- resp, cls.image1 = cls.create_image_from_server(
- cls.server1['id'], wait_until='ACTIVE')
- cls.image1_id = cls.image1['id']
-
- # Servers have a hidden property for when they are being imaged
- # Performing back-to-back create image calls on a single
- # server will sometimes cause failures
- resp, cls.image3 = cls.create_image_from_server(
- cls.server2['id'], wait_until='ACTIVE')
- cls.image3_id = cls.image3['id']
-
- # Wait for the server to be active after the image upload
- resp, cls.image2 = cls.create_image_from_server(
- cls.server1['id'], wait_until='ACTIVE')
- cls.image2_id = cls.image2['id']
- except Exception:
- LOG.exception('setUpClass failed')
- cls.tearDownClass()
- raise
-
- @attr(type=['negative', 'gate'])
- def test_get_image_not_existing(self):
- # Check raises a NotFound
- self.assertRaises(exceptions.NotFound, self.client.get_image,
- "nonexistingimageid")
-
- @attr(type='gate')
- def test_list_images_filter_by_status(self):
- # The list of images should contain only images with the
- # provided status
- params = {'status': 'ACTIVE'}
- resp, images = self.client.list_images(params)
-
- self.assertTrue(any([i for i in images if i['id'] == self.image1_id]))
- self.assertTrue(any([i for i in images if i['id'] == self.image2_id]))
- self.assertTrue(any([i for i in images if i['id'] == self.image3_id]))
-
- @attr(type='gate')
- def test_list_images_filter_by_name(self):
- # List of all images should contain the expected images filtered
- # by name
- params = {'name': self.image1['name']}
- resp, images = self.client.list_images(params)
-
- self.assertTrue(any([i for i in images if i['id'] == self.image1_id]))
- self.assertFalse(any([i for i in images if i['id'] == self.image2_id]))
- self.assertFalse(any([i for i in images if i['id'] == self.image3_id]))
-
- @attr(type='gate')
- def test_list_images_filter_by_server_id(self):
- # The images should contain images filtered by server id
- params = {'server': self.server1['id']}
- resp, images = self.client.list_images(params)
-
- self.assertTrue(any([i for i in images if i['id'] == self.image1_id]),
- "Failed to find image %s in images. Got images %s" %
- (self.image1_id, images))
- self.assertTrue(any([i for i in images if i['id'] == self.image2_id]))
- self.assertFalse(any([i for i in images if i['id'] == self.image3_id]))
-
- @attr(type='gate')
- def test_list_images_filter_by_server_ref(self):
- # The list of servers should be filtered by server ref
- server_links = self.server2['links']
-
- # Try all server link types
- for link in server_links:
- params = {'server': link['href']}
- resp, images = self.client.list_images(params)
-
- self.assertFalse(any([i for i in images
- if i['id'] == self.image1_id]))
- self.assertFalse(any([i for i in images
- if i['id'] == self.image2_id]))
- self.assertTrue(any([i for i in images
- if i['id'] == self.image3_id]))
-
- @attr(type='gate')
- def test_list_images_filter_by_type(self):
- # The list of servers should be filtered by image type
- params = {'type': 'snapshot'}
- resp, images = self.client.list_images(params)
-
- self.assertTrue(any([i for i in images if i['id'] == self.image1_id]))
- self.assertTrue(any([i for i in images if i['id'] == self.image2_id]))
- self.assertTrue(any([i for i in images if i['id'] == self.image3_id]))
- self.assertFalse(any([i for i in images if i['id'] == self.image_ref]))
-
- @attr(type='gate')
- def test_list_images_limit_results(self):
- # Verify only the expected number of results are returned
- params = {'limit': '1'}
- resp, images = self.client.list_images(params)
- self.assertEqual(1, len([x for x in images if 'id' in x]))
-
- @attr(type='gate')
- def test_list_images_filter_by_changes_since(self):
- # Verify only updated images are returned in the detailed list
-
- # Becoming ACTIVE will modify the updated time
- # Filter by the image's created time
- params = {'changes-since': self.image3['created']}
- resp, images = self.client.list_images(params)
- found = any([i for i in images if i['id'] == self.image3_id])
- self.assertTrue(found)
-
- @attr(type='gate')
- def test_list_images_with_detail_filter_by_status(self):
- # Detailed list of all images should only contain images
- # with the provided status
- params = {'status': 'ACTIVE'}
- resp, images = self.client.list_images_with_detail(params)
-
- self.assertTrue(any([i for i in images if i['id'] == self.image1_id]))
- self.assertTrue(any([i for i in images if i['id'] == self.image2_id]))
- self.assertTrue(any([i for i in images if i['id'] == self.image3_id]))
-
- @attr(type='gate')
- def test_list_images_with_detail_filter_by_name(self):
- # Detailed list of all images should contain the expected
- # images filtered by name
- params = {'name': self.image1['name']}
- resp, images = self.client.list_images_with_detail(params)
-
- self.assertTrue(any([i for i in images if i['id'] == self.image1_id]))
- self.assertFalse(any([i for i in images if i['id'] == self.image2_id]))
- self.assertFalse(any([i for i in images if i['id'] == self.image3_id]))
-
- @attr(type='gate')
- def test_list_images_with_detail_limit_results(self):
- # Verify only the expected number of results (with full details)
- # are returned
- params = {'limit': '1'}
- resp, images = self.client.list_images_with_detail(params)
- self.assertEqual(1, len(images))
-
- @attr(type='gate')
- def test_list_images_with_detail_filter_by_server_ref(self):
- # Detailed list of servers should be filtered by server ref
- server_links = self.server2['links']
-
- # Try all server link types
- for link in server_links:
- params = {'server': link['href']}
- resp, images = self.client.list_images_with_detail(params)
-
- self.assertFalse(any([i for i in images
- if i['id'] == self.image1_id]))
- self.assertFalse(any([i for i in images
- if i['id'] == self.image2_id]))
- self.assertTrue(any([i for i in images
- if i['id'] == self.image3_id]))
-
- @attr(type='gate')
- def test_list_images_with_detail_filter_by_type(self):
- # The detailed list of servers should be filtered by image type
- params = {'type': 'snapshot'}
- resp, images = self.client.list_images_with_detail(params)
- resp, image4 = self.client.get_image(self.image_ref)
-
- self.assertTrue(any([i for i in images if i['id'] == self.image1_id]))
- self.assertTrue(any([i for i in images if i['id'] == self.image2_id]))
- self.assertTrue(any([i for i in images if i['id'] == self.image3_id]))
- self.assertFalse(any([i for i in images if i['id'] == self.image_ref]))
-
- @attr(type='gate')
- def test_list_images_with_detail_filter_by_changes_since(self):
- # Verify an update image is returned
-
- # Becoming ACTIVE will modify the updated time
- # Filter by the image's created time
- params = {'changes-since': self.image1['created']}
- resp, images = self.client.list_images_with_detail(params)
- self.assertTrue(any([i for i in images if i['id'] == self.image1_id]))
-
- @attr(type=['negative', 'gate'])
- def test_get_nonexistent_image(self):
- # Negative test: GET on non-existent image should fail
- self.assertRaises(exceptions.NotFound, self.client.get_image, 999)
diff --git a/tempest/api/compute/v3/keypairs/test_keypairs.py b/tempest/api/compute/v3/keypairs/test_keypairs.py
index 8eef811..668a295 100644
--- a/tempest/api/compute/v3/keypairs/test_keypairs.py
+++ b/tempest/api/compute/v3/keypairs/test_keypairs.py
@@ -19,7 +19,6 @@
class KeyPairsV3Test(base.BaseV3ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
diff --git a/tempest/api/compute/v3/keypairs/test_keypairs_negative.py b/tempest/api/compute/v3/keypairs/test_keypairs_negative.py
index ae22ccc..e426b85 100644
--- a/tempest/api/compute/v3/keypairs/test_keypairs_negative.py
+++ b/tempest/api/compute/v3/keypairs/test_keypairs_negative.py
@@ -21,7 +21,6 @@
class KeyPairsNegativeV3Test(base.BaseV3ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
diff --git a/tempest/api/compute/v3/servers/test_attach_interfaces.py b/tempest/api/compute/v3/servers/test_attach_interfaces.py
index 272cb53..e1c69d9 100644
--- a/tempest/api/compute/v3/servers/test_attach_interfaces.py
+++ b/tempest/api/compute/v3/servers/test_attach_interfaces.py
@@ -24,7 +24,6 @@
class AttachInterfacesV3Test(base.BaseV3ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
@@ -48,6 +47,7 @@
def _create_server_get_interfaces(self):
resp, server = self.create_test_server(wait_until='ACTIVE')
resp, ifs = self.client.list_interfaces(server['id'])
+ self.assertEqual(200, resp.status)
resp, body = self.client.wait_for_interface_status(
server['id'], ifs[0]['port_id'], 'ACTIVE')
ifs[0]['port_state'] = body['port_state']
@@ -55,6 +55,7 @@
def _test_create_interface(self, server):
resp, iface = self.client.create_interface(server['id'])
+ self.assertEqual(200, resp.status)
resp, iface = self.client.wait_for_interface_status(
server['id'], iface['port_id'], 'ACTIVE')
self._check_interface(iface)
@@ -64,6 +65,7 @@
network_id = ifs[0]['net_id']
resp, iface = self.client.create_interface(server['id'],
network_id=network_id)
+ self.assertEqual(200, resp.status)
resp, iface = self.client.wait_for_interface_status(
server['id'], iface['port_id'], 'ACTIVE')
self._check_interface(iface, network_id=network_id)
@@ -73,12 +75,14 @@
iface = ifs[0]
resp, _iface = self.client.show_interface(server['id'],
iface['port_id'])
+ self.assertEqual(200, resp.status)
self.assertEqual(iface, _iface)
def _test_delete_interface(self, server, ifs):
# NOTE(danms): delete not the first or last, but one in the middle
iface = ifs[1]
- self.client.delete_interface(server['id'], iface['port_id'])
+ resp, _ = self.client.delete_interface(server['id'], iface['port_id'])
+ self.assertEqual(202, resp.status)
_ifs = self.client.list_interfaces(server['id'])[1]
start = int(time.time())
@@ -122,3 +126,30 @@
_ifs = self._test_delete_interface(server, ifs)
self.assertEqual(len(ifs) - 1, len(_ifs))
+
+ @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()
+ interface_count = len(ifs)
+ self.assertGreater(interface_count, 0)
+ self._check_interface(ifs[0])
+ network_id = ifs[0]['net_id']
+ resp, body = self.client.add_fixed_ip(server['id'],
+ network_id)
+ self.assertEqual(202, resp.status)
+ server_resp, server_detail = self.servers_client.get_server(
+ server['id'])
+ # Get the Fixed IP from server.
+ fixed_ip = None
+ for ip_set in server_detail['addresses']:
+ for ip in server_detail['addresses'][ip_set]:
+ if ip['type'] == 'fixed':
+ fixed_ip = ip['addr']
+ break
+ if fixed_ip is not None:
+ break
+ # Remove the fixed IP from server.
+ resp, body = self.client.remove_fixed_ip(server['id'],
+ fixed_ip)
+ self.assertEqual(202, resp.status)
diff --git a/tempest/api/compute/v3/servers/test_attach_volume.py b/tempest/api/compute/v3/servers/test_attach_volume.py
index d693be5..8577aab 100644
--- a/tempest/api/compute/v3/servers/test_attach_volume.py
+++ b/tempest/api/compute/v3/servers/test_attach_volume.py
@@ -16,15 +16,14 @@
import testtools
from tempest.api.compute import base
-from tempest.common.utils.linux.remote_client import RemoteClient
+from tempest.common.utils.linux import remote_client
from tempest import config
-from tempest.test import attr
+from tempest import test
CONF = config.CONF
class AttachVolumeV3Test(base.BaseV3ComputeTest):
- _interface = 'json'
run_ssh = CONF.compute.run_ssh
def __init__(self, *args, **kwargs):
@@ -78,7 +77,7 @@
self.addCleanup(self._detach, server['id'], volume['id'])
@testtools.skipIf(not run_ssh, 'SSH required for this test')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_attach_detach_volume(self):
# Stop and Start a server with an attached volume, ensuring that
# the volume remains attached.
@@ -92,9 +91,8 @@
self.servers_client.start(server['id'])
self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
- linux_client = RemoteClient(server,
- self.image_ssh_user,
- server['admin_password'])
+ linux_client = remote_client.RemoteClient(server, self.image_ssh_user,
+ server['admin_password'])
partitions = linux_client.get_partitions()
self.assertIn(self.device, partitions)
@@ -107,8 +105,7 @@
self.servers_client.start(server['id'])
self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
- linux_client = RemoteClient(server,
- self.image_ssh_user,
- server['admin_password'])
+ linux_client = remote_client.RemoteClient(server, self.image_ssh_user,
+ server['admin_password'])
partitions = linux_client.get_partitions()
self.assertNotIn(self.device, partitions)
diff --git a/tempest/api/compute/v3/servers/test_availability_zone.py b/tempest/api/compute/v3/servers/test_availability_zone.py
new file mode 100644
index 0000000..5a1e07e
--- /dev/null
+++ b/tempest/api/compute/v3/servers/test_availability_zone.py
@@ -0,0 +1,36 @@
+# 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.
+
+from tempest.api.compute import base
+from tempest import test
+
+
+class AZV3Test(base.BaseV3ComputeTest):
+
+ """
+ Tests Availability Zone API List
+ """
+
+ @classmethod
+ def setUpClass(cls):
+ super(AZV3Test, cls).setUpClass()
+ cls.client = cls.availability_zone_client
+
+ @test.attr(type='gate')
+ def test_get_availability_zone_list_with_non_admin_user(self):
+ # List of availability zone with non-administrator user
+ resp, availability_zone = self.client.get_availability_zone_list()
+ self.assertEqual(200, resp.status)
+ self.assertTrue(len(availability_zone) > 0)
diff --git a/tempest/api/compute/v3/servers/test_create_server.py b/tempest/api/compute/v3/servers/test_create_server.py
index 7a4c877..14a4338 100644
--- a/tempest/api/compute/v3/servers/test_create_server.py
+++ b/tempest/api/compute/v3/servers/test_create_server.py
@@ -20,7 +20,7 @@
from tempest.api.compute import base
from tempest.common.utils import data_utils
-from tempest.common.utils.linux.remote_client import RemoteClient
+from tempest.common.utils.linux import remote_client
from tempest import config
from tempest import test
@@ -28,7 +28,6 @@
class ServersV3Test(base.BaseV3ComputeTest):
- _interface = 'json'
run_ssh = CONF.compute.run_ssh
disk_config = 'AUTO'
@@ -93,30 +92,24 @@
@testtools.skipIf(not run_ssh, 'Instance validation tests are disabled.')
@test.attr(type='gate')
- def test_can_log_into_created_server(self):
- # Check that the user can authenticate with the generated password
- linux_client = RemoteClient(self.server, self.ssh_user, self.password)
- self.assertTrue(linux_client.can_authenticate())
-
- @testtools.skipIf(not run_ssh, 'Instance validation tests are disabled.')
- @test.attr(type='gate')
def test_verify_created_server_vcpus(self):
# Verify that the number of vcpus reported by the instance matches
# the amount stated by the flavor
resp, flavor = self.flavors_client.get_flavor_details(self.flavor_ref)
- linux_client = RemoteClient(self.server, self.ssh_user, self.password)
+ linux_client = remote_client.RemoteClient(self.server,
+ self.ssh_user, self.password)
self.assertEqual(flavor['vcpus'], linux_client.get_number_of_vcpus())
@testtools.skipIf(not run_ssh, 'Instance validation tests are disabled.')
@test.attr(type='gate')
def test_host_name_is_same_as_server_name(self):
# Verify the instance host name is the same as the server name
- linux_client = RemoteClient(self.server, self.ssh_user, self.password)
+ linux_client = remote_client.RemoteClient(self.server,
+ self.ssh_user, self.password)
self.assertTrue(linux_client.hostname_equals_servername(self.name))
class ServersWithSpecificFlavorV3Test(base.BaseV3ComputeAdminTest):
- _interface = 'json'
run_ssh = CONF.compute.run_ssh
disk_config = 'AUTO'
@@ -194,8 +187,7 @@
admin_pass = self.image_ssh_password
- resp, server_no_eph_disk = (self.
- create_test_server(
+ resp, server_no_eph_disk = (self.create_test_server(
wait_until='ACTIVE',
adminPass=admin_pass,
flavor=flavor_no_eph_disk_id))
@@ -204,12 +196,12 @@
adminPass=admin_pass,
flavor=flavor_with_eph_disk_id))
# Get partition number of server without extra specs.
- linux_client = RemoteClient(server_no_eph_disk,
- self.ssh_user, self.password)
+ linux_client = remote_client.RemoteClient(server_no_eph_disk,
+ self.ssh_user, self.password)
partition_num = len(linux_client.get_partitions())
- linux_client = RemoteClient(server_with_eph_disk,
- self.ssh_user, self.password)
+ linux_client = remote_client.RemoteClient(server_with_eph_disk,
+ self.ssh_user, self.password)
self.assertEqual(partition_num + 1, linux_client.get_partitions())
diff --git a/tempest/api/compute/v3/servers/test_delete_server.py b/tempest/api/compute/v3/servers/test_delete_server.py
new file mode 100644
index 0000000..d694a33
--- /dev/null
+++ b/tempest/api/compute/v3/servers/test_delete_server.py
@@ -0,0 +1,133 @@
+# Copyright 2012 OpenStack Foundation
+#
+# 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 testtools
+
+from tempest.api.compute import base
+from tempest import config
+from tempest import test
+
+CONF = config.CONF
+
+
+class DeleteServersV3Test(base.BaseV3ComputeTest):
+ # NOTE: Server creations of each test class should be under 10
+ # for preventing "Quota exceeded for instances".
+
+ @classmethod
+ def setUpClass(cls):
+ super(DeleteServersV3Test, cls).setUpClass()
+ cls.client = cls.servers_client
+
+ @test.attr(type='gate')
+ def test_delete_server_while_in_building_state(self):
+ # Delete a server while it's VM state is Building
+ resp, server = self.create_test_server(wait_until='BUILD')
+ resp, _ = self.client.delete_server(server['id'])
+ self.assertEqual('204', resp['status'])
+ self.client.wait_for_server_termination(server['id'])
+
+ @test.attr(type='gate')
+ def test_delete_active_server(self):
+ # Delete a server while it's VM state is Active
+ resp, server = self.create_test_server(wait_until='ACTIVE')
+ resp, _ = self.client.delete_server(server['id'])
+ self.assertEqual('204', resp['status'])
+ self.client.wait_for_server_termination(server['id'])
+
+ @test.attr(type='gate')
+ def test_delete_server_while_in_shutoff_state(self):
+ # Delete a server while it's VM state is Shutoff
+ resp, server = self.create_test_server(wait_until='ACTIVE')
+ resp, body = self.client.stop(server['id'])
+ self.client.wait_for_server_status(server['id'], 'SHUTOFF')
+ resp, _ = self.client.delete_server(server['id'])
+ self.assertEqual('204', resp['status'])
+ self.client.wait_for_server_termination(server['id'])
+
+ @test.attr(type='gate')
+ def test_delete_server_while_in_pause_state(self):
+ # Delete a server while it's VM state is Pause
+ resp, server = self.create_test_server(wait_until='ACTIVE')
+ resp, body = self.client.pause_server(server['id'])
+ self.client.wait_for_server_status(server['id'], 'PAUSED')
+ resp, _ = self.client.delete_server(server['id'])
+ self.assertEqual('204', resp['status'])
+ self.client.wait_for_server_termination(server['id'])
+
+ @test.attr(type='gate')
+ def test_delete_server_while_in_shelved_state(self):
+ # Delete a server while it's VM state is Shelved
+ resp, server = self.create_test_server(wait_until='ACTIVE')
+ resp, body = self.client.shelve_server(server['id'])
+ self.assertEqual(202, resp.status)
+
+ offload_time = CONF.compute.shelved_offload_time
+ if offload_time >= 0:
+ self.client.wait_for_server_status(server['id'],
+ 'SHELVED_OFFLOADED',
+ extra_timeout=offload_time)
+ else:
+ self.client.wait_for_server_status(server['id'],
+ 'SHELVED')
+
+ resp, _ = self.client.delete_server(server['id'])
+ self.assertEqual('204', resp['status'])
+ self.client.wait_for_server_termination(server['id'])
+
+ @testtools.skipIf(not CONF.compute_feature_enabled.resize,
+ 'Resize not available.')
+ @test.attr(type='gate')
+ def test_delete_server_while_in_verify_resize_state(self):
+ # Delete a server while it's VM state is VERIFY_RESIZE
+ resp, server = self.create_test_server(wait_until='ACTIVE')
+ resp, body = self.client.resize(server['id'], self.flavor_ref_alt)
+ self.assertEqual(202, resp.status)
+ self.client.wait_for_server_status(server['id'], 'VERIFY_RESIZE')
+ resp, _ = self.client.delete_server(server['id'])
+ self.assertEqual('204', resp['status'])
+ self.client.wait_for_server_termination(server['id'])
+
+
+class DeleteServersAdminV3Test(base.BaseV3ComputeAdminTest):
+ # NOTE: Server creations of each test class should be under 10
+ # for preventing "Quota exceeded for instances".
+
+ @classmethod
+ def setUpClass(cls):
+ super(DeleteServersAdminV3Test, cls).setUpClass()
+ cls.non_admin_client = cls.servers_client
+ cls.admin_client = cls.servers_admin_client
+
+ @test.attr(type='gate')
+ def test_delete_server_while_in_error_state(self):
+ # Delete a server while it's VM state is error
+ resp, server = self.create_test_server(wait_until='ACTIVE')
+ resp, body = self.admin_client.reset_state(server['id'], state='error')
+ self.assertEqual(202, resp.status)
+ # Verify server's state
+ resp, server = self.non_admin_client.get_server(server['id'])
+ self.assertEqual(server['status'], 'ERROR')
+ resp, _ = self.non_admin_client.delete_server(server['id'])
+ self.assertEqual('204', resp['status'])
+ self.servers_client.wait_for_server_termination(server['id'],
+ ignore_error=True)
+
+ @test.attr(type='gate')
+ def test_admin_delete_servers_of_others(self):
+ # Administrator can delete servers of others
+ resp, server = self.create_test_server(wait_until='ACTIVE')
+ resp, _ = self.admin_client.delete_server(server['id'])
+ self.assertEqual('204', resp['status'])
+ self.servers_client.wait_for_server_termination(server['id'])
diff --git a/tempest/api/compute/v3/servers/test_instance_actions.py b/tempest/api/compute/v3/servers/test_instance_actions.py
index d536871..7d25100 100644
--- a/tempest/api/compute/v3/servers/test_instance_actions.py
+++ b/tempest/api/compute/v3/servers/test_instance_actions.py
@@ -14,22 +14,20 @@
# under the License.
from tempest.api.compute import base
-from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class InstanceActionsV3Test(base.BaseV3ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
super(InstanceActionsV3Test, cls).setUpClass()
cls.client = cls.servers_client
resp, server = cls.create_test_server(wait_until='ACTIVE')
- cls.request_id = resp['x-compute-request-id']
+ cls.resp = resp
cls.server_id = server['id']
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_instance_actions(self):
# List actions of the provided server
resp, body = self.client.reboot(self.server_id, 'HARD')
@@ -41,23 +39,13 @@
self.assertTrue(any([i for i in body if i['action'] == 'create']))
self.assertTrue(any([i for i in body if i['action'] == 'reboot']))
- @attr(type='gate')
+ @test.attr(type='gate')
+ @test.skip_because(bug="1281915")
def test_get_instance_action(self):
# Get the action details of the provided server
+ request_id = self.resp['x-compute-request-id']
resp, body = self.client.get_instance_action(self.server_id,
- self.request_id)
+ request_id)
self.assertEqual(200, resp.status)
self.assertEqual(self.server_id, body['instance_uuid'])
self.assertEqual('create', body['action'])
-
- @attr(type=['negative', 'gate'])
- def test_list_instance_actions_invalid_server(self):
- # List actions of the invalid server id
- self.assertRaises(exceptions.NotFound,
- self.client.list_instance_actions, 'server-999')
-
- @attr(type=['negative', 'gate'])
- def test_get_instance_action_invalid_request(self):
- # Get the action details of the provided server with invalid request
- self.assertRaises(exceptions.NotFound, self.client.get_instance_action,
- self.server_id, '999')
diff --git a/tempest/api/compute/v3/servers/test_instance_actions_negative.py b/tempest/api/compute/v3/servers/test_instance_actions_negative.py
new file mode 100644
index 0000000..b0a7050
--- /dev/null
+++ b/tempest/api/compute/v3/servers/test_instance_actions_negative.py
@@ -0,0 +1,43 @@
+# 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.
+
+from tempest.api.compute import base
+from tempest.common.utils import data_utils
+from tempest import exceptions
+from tempest import test
+
+
+class InstanceActionsNegativeV3Test(base.BaseV3ComputeTest):
+
+ @classmethod
+ def setUpClass(cls):
+ super(InstanceActionsNegativeV3Test, cls).setUpClass()
+ cls.client = cls.servers_client
+ resp, server = cls.create_test_server(wait_until='ACTIVE')
+ cls.server_id = server['id']
+
+ @test.attr(type=['negative', 'gate'])
+ def test_list_instance_actions_invalid_server(self):
+ # List actions of the invalid server id
+ invalid_server_id = data_utils.rand_uuid()
+ self.assertRaises(exceptions.NotFound,
+ self.client.list_instance_actions, invalid_server_id)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_get_instance_action_invalid_request(self):
+ # Get the action details of the provided server with invalid request
+ invalid_request_id = 'req-' + data_utils.rand_uuid()
+ self.assertRaises(exceptions.NotFound, self.client.get_instance_action,
+ self.server_id, invalid_request_id)
diff --git a/tempest/api/compute/v3/servers/test_list_server_filters.py b/tempest/api/compute/v3/servers/test_list_server_filters.py
index 9082eda..2cb176c 100644
--- a/tempest/api/compute/v3/servers/test_list_server_filters.py
+++ b/tempest/api/compute/v3/servers/test_list_server_filters.py
@@ -18,16 +18,15 @@
from tempest.common.utils import data_utils
from tempest import config
from tempest import exceptions
-from tempest.test import attr
-from tempest.test import skip_because
+from tempest import test
CONF = config.CONF
class ListServerFiltersV3Test(base.BaseV3ComputeTest):
- _interface = 'json'
@classmethod
+ @test.safe_setup
def setUpClass(cls):
super(ListServerFiltersV3Test, cls).setUpClass()
cls.client = cls.servers_client
@@ -74,7 +73,7 @@
cls.fixed_network_name = CONF.compute.fixed_network_name
@utils.skip_unless_attr('multiple_images', 'Only one image found')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_filter_by_image(self):
# Filter the list of servers by image
params = {'image': self.image_ref}
@@ -85,7 +84,7 @@
self.assertNotIn(self.s2['id'], map(lambda x: x['id'], servers))
self.assertIn(self.s3['id'], map(lambda x: x['id'], servers))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_filter_by_flavor(self):
# Filter the list of servers by flavor
params = {'flavor': self.flavor_ref_alt}
@@ -96,7 +95,7 @@
self.assertNotIn(self.s2['id'], map(lambda x: x['id'], servers))
self.assertIn(self.s3['id'], map(lambda x: x['id'], servers))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_filter_by_server_name(self):
# Filter the list of servers by server name
params = {'name': self.s1_name}
@@ -107,7 +106,7 @@
self.assertNotIn(self.s2_name, map(lambda x: x['name'], servers))
self.assertNotIn(self.s3_name, map(lambda x: x['name'], servers))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_filter_by_server_status(self):
# Filter the list of servers by server status
params = {'status': 'active'}
@@ -118,21 +117,21 @@
self.assertIn(self.s2['id'], map(lambda x: x['id'], servers))
self.assertIn(self.s3['id'], map(lambda x: x['id'], servers))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_filter_by_limit(self):
# Verify only the expected number of servers are returned
params = {'limit': 1}
resp, servers = self.client.list_servers(params)
self.assertEqual(1, len([x for x in servers['servers'] if 'id' in x]))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_filter_by_zero_limit(self):
# Verify only the expected number of servers are returned
params = {'limit': 0}
resp, servers = self.client.list_servers(params)
self.assertEqual(0, len(servers['servers']))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_filter_by_exceed_limit(self):
# Verify only the expected number of servers are returned
params = {'limit': 100000}
@@ -142,7 +141,7 @@
len([x for x in servers['servers'] if 'id' in x]))
@utils.skip_unless_attr('multiple_images', 'Only one image found')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_detailed_filter_by_image(self):
# Filter the detailed list of servers by image
params = {'image': self.image_ref}
@@ -153,7 +152,7 @@
self.assertNotIn(self.s2['id'], map(lambda x: x['id'], servers))
self.assertIn(self.s3['id'], map(lambda x: x['id'], servers))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_detailed_filter_by_flavor(self):
# Filter the detailed list of servers by flavor
params = {'flavor': self.flavor_ref_alt}
@@ -164,7 +163,7 @@
self.assertNotIn(self.s2['id'], map(lambda x: x['id'], servers))
self.assertIn(self.s3['id'], map(lambda x: x['id'], servers))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_detailed_filter_by_server_name(self):
# Filter the detailed list of servers by server name
params = {'name': self.s1_name}
@@ -175,7 +174,7 @@
self.assertNotIn(self.s2_name, map(lambda x: x['name'], servers))
self.assertNotIn(self.s3_name, map(lambda x: x['name'], servers))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_detailed_filter_by_server_status(self):
# Filter the detailed list of servers by server status
params = {'status': 'active'}
@@ -188,7 +187,7 @@
self.assertIn(self.s3['id'], map(lambda x: x['id'], servers))
self.assertEqual(['ACTIVE'] * 3, [x['status'] for x in servers])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_filter_by_shutoff_status(self):
# Filter the list of servers by server shutoff status
params = {'status': 'shutoff'}
@@ -205,7 +204,7 @@
self.assertNotIn(self.s2['id'], map(lambda x: x['id'], servers))
self.assertNotIn(self.s3['id'], map(lambda x: x['id'], servers))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_filtered_by_name_wildcard(self):
# List all servers that contains '-instance' in name
params = {'name': '-instance'}
@@ -227,8 +226,8 @@
self.assertNotIn(self.s2_name, map(lambda x: x['name'], servers))
self.assertNotIn(self.s3_name, map(lambda x: x['name'], servers))
- @skip_because(bug="1170718")
- @attr(type='gate')
+ @test.skip_because(bug="1170718")
+ @test.attr(type='gate')
def test_list_servers_filtered_by_ip(self):
# Filter servers by ip
# Here should be listed 1 server
@@ -242,9 +241,9 @@
self.assertNotIn(self.s2_name, map(lambda x: x['name'], servers))
self.assertNotIn(self.s3_name, map(lambda x: x['name'], servers))
- @skip_because(bug="1182883",
- condition=CONF.service_available.neutron)
- @attr(type='gate')
+ @test.skip_because(bug="1182883",
+ condition=CONF.service_available.neutron)
+ @test.attr(type='gate')
def test_list_servers_filtered_by_ip_regex(self):
# Filter servers by regex ip
# List all servers filtered by part of ip address.
@@ -259,7 +258,7 @@
self.assertIn(self.s2_name, map(lambda x: x['name'], servers))
self.assertIn(self.s3_name, map(lambda x: x['name'], servers))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_servers_detailed_limit_results(self):
# Verify only the expected number of detailed results are returned
params = {'limit': 1}
diff --git a/tempest/api/compute/v3/servers/test_list_servers_negative.py b/tempest/api/compute/v3/servers/test_list_servers_negative.py
index 09e1bb6..9cbc4e0 100644
--- a/tempest/api/compute/v3/servers/test_list_servers_negative.py
+++ b/tempest/api/compute/v3/servers/test_list_servers_negative.py
@@ -15,16 +15,18 @@
import datetime
+from six import moves
+
from tempest.api.compute import base
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class ListServersNegativeV3Test(base.BaseV3ComputeTest):
- _interface = 'json'
force_tenant_isolation = True
@classmethod
+ @test.safe_setup
def setUpClass(cls):
super(ListServersNegativeV3Test, cls).setUpClass()
cls.client = cls.servers_client
@@ -36,7 +38,7 @@
cls.existing_fixtures = []
cls.deleted_fixtures = []
cls.start_time = datetime.datetime.utcnow()
- for x in xrange(2):
+ for x in moves.xrange(2):
resp, srv = cls.create_test_server()
cls.existing_fixtures.append(srv)
@@ -50,7 +52,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
@@ -62,7 +64,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'
@@ -71,7 +73,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
@@ -80,7 +82,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'
@@ -89,7 +91,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'
@@ -98,33 +100,33 @@
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})
self.assertEqual('200', resp['status'])
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()}
@@ -137,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'}
@@ -151,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/v3/servers/test_multiple_create.py b/tempest/api/compute/v3/servers/test_multiple_create.py
index f1ae5f8..23e0854 100644
--- a/tempest/api/compute/v3/servers/test_multiple_create.py
+++ b/tempest/api/compute/v3/servers/test_multiple_create.py
@@ -15,12 +15,10 @@
from tempest.api.compute import base
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
class MultipleCreateV3Test(base.BaseV3ComputeTest):
- _interface = 'json'
_name = 'multiple-create-test'
def _generate_name(self):
@@ -47,38 +45,6 @@
self.assertEqual('202', resp['status'])
self.assertNotIn('reservation_id', body)
- @test.attr(type=['negative', 'gate'])
- def test_min_count_less_than_one(self):
- invalid_min_count = 0
- self.assertRaises(exceptions.BadRequest, self._create_multiple_servers,
- min_count=invalid_min_count)
-
- @test.attr(type=['negative', 'gate'])
- def test_min_count_non_integer(self):
- invalid_min_count = 2.5
- self.assertRaises(exceptions.BadRequest, self._create_multiple_servers,
- min_count=invalid_min_count)
-
- @test.attr(type=['negative', 'gate'])
- def test_max_count_less_than_one(self):
- invalid_max_count = 0
- self.assertRaises(exceptions.BadRequest, self._create_multiple_servers,
- max_count=invalid_max_count)
-
- @test.attr(type=['negative', 'gate'])
- def test_max_count_non_integer(self):
- invalid_max_count = 2.5
- self.assertRaises(exceptions.BadRequest, self._create_multiple_servers,
- max_count=invalid_max_count)
-
- @test.attr(type=['negative', 'gate'])
- def test_max_count_less_than_min_count(self):
- min_count = 3
- max_count = 2
- self.assertRaises(exceptions.BadRequest, self._create_multiple_servers,
- min_count=min_count,
- max_count=max_count)
-
@test.attr(type='gate')
def test_multiple_create_with_reservation_return(self):
resp, body = self._create_multiple_servers(wait_until='ACTIVE',
diff --git a/tempest/api/compute/v3/servers/test_multiple_create_negative.py b/tempest/api/compute/v3/servers/test_multiple_create_negative.py
new file mode 100644
index 0000000..f208bc0
--- /dev/null
+++ b/tempest/api/compute/v3/servers/test_multiple_create_negative.py
@@ -0,0 +1,68 @@
+# Copyright 2013 IBM Corp
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.api.compute import base
+from tempest.common.utils import data_utils
+from tempest import exceptions
+from tempest import test
+
+
+class MultipleCreateV3NegativeTest(base.BaseV3ComputeTest):
+ _name = 'multiple-create-negative-test'
+
+ def _generate_name(self):
+ return data_utils.rand_name(self._name)
+
+ def _create_multiple_servers(self, name=None, wait_until=None, **kwargs):
+ """
+ This is the right way to create_multiple servers and manage to get the
+ created servers into the servers list to be cleaned up after all.
+ """
+ kwargs['name'] = kwargs.get('name', self._generate_name())
+ resp, body = self.create_test_server(**kwargs)
+
+ return resp, body
+
+ @test.attr(type=['negative', 'gate'])
+ def test_min_count_less_than_one(self):
+ invalid_min_count = 0
+ self.assertRaises(exceptions.BadRequest, self._create_multiple_servers,
+ min_count=invalid_min_count)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_min_count_non_integer(self):
+ invalid_min_count = 2.5
+ self.assertRaises(exceptions.BadRequest, self._create_multiple_servers,
+ min_count=invalid_min_count)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_max_count_less_than_one(self):
+ invalid_max_count = 0
+ self.assertRaises(exceptions.BadRequest, self._create_multiple_servers,
+ max_count=invalid_max_count)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_max_count_non_integer(self):
+ invalid_max_count = 2.5
+ self.assertRaises(exceptions.BadRequest, self._create_multiple_servers,
+ max_count=invalid_max_count)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_max_count_less_than_min_count(self):
+ min_count = 3
+ max_count = 2
+ self.assertRaises(exceptions.BadRequest, self._create_multiple_servers,
+ min_count=min_count,
+ max_count=max_count)
diff --git a/tempest/api/compute/v3/servers/test_server_actions.py b/tempest/api/compute/v3/servers/test_server_actions.py
index 0dae796..555d028 100644
--- a/tempest/api/compute/v3/servers/test_server_actions.py
+++ b/tempest/api/compute/v3/servers/test_server_actions.py
@@ -19,17 +19,15 @@
from tempest.api.compute import base
from tempest.common.utils import data_utils
-from tempest.common.utils.linux.remote_client import RemoteClient
+from tempest.common.utils.linux import remote_client
from tempest import config
from tempest import exceptions
-from tempest.test import attr
-from tempest.test import skip_because
+from tempest import test
CONF = config.CONF
class ServerActionsV3Test(base.BaseV3ComputeTest):
- _interface = 'json'
resize_available = CONF.compute_feature_enabled.resize
run_ssh = CONF.compute.run_ssh
@@ -52,7 +50,7 @@
@testtools.skipUnless(CONF.compute_feature_enabled.change_password,
'Change password not available.')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_change_server_password(self):
# The server's password should be set to the provided password
new_password = 'Newpass1234'
@@ -63,16 +61,18 @@
if self.run_ssh:
# Verify that the user can authenticate with the new password
resp, server = self.client.get_server(self.server_id)
- linux_client = RemoteClient(server, self.ssh_user, new_password)
+ linux_client = remote_client.RemoteClient(server, self.ssh_user,
+ new_password)
linux_client.validate_authentication()
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_reboot_server_hard(self):
# The server should be power cycled
if self.run_ssh:
# Get the time the server was last rebooted,
resp, server = self.client.get_server(self.server_id)
- linux_client = RemoteClient(server, self.ssh_user, self.password)
+ linux_client = remote_client.RemoteClient(server, self.ssh_user,
+ self.password)
boot_time = linux_client.get_boot_time()
resp, body = self.client.reboot(self.server_id, 'HARD')
@@ -81,18 +81,20 @@
if self.run_ssh:
# Log in and verify the boot time has changed
- linux_client = RemoteClient(server, self.ssh_user, self.password)
+ linux_client = remote_client.RemoteClient(server, self.ssh_user,
+ self.password)
new_boot_time = linux_client.get_boot_time()
self.assertGreater(new_boot_time, boot_time)
- @skip_because(bug="1014647")
- @attr(type='smoke')
+ @test.skip_because(bug="1014647")
+ @test.attr(type='smoke')
def test_reboot_server_soft(self):
# The server should be signaled to reboot gracefully
if self.run_ssh:
# Get the time the server was last rebooted,
resp, server = self.client.get_server(self.server_id)
- linux_client = RemoteClient(server, self.ssh_user, self.password)
+ linux_client = remote_client.RemoteClient(server, self.ssh_user,
+ self.password)
boot_time = linux_client.get_boot_time()
resp, body = self.client.reboot(self.server_id, 'SOFT')
@@ -101,11 +103,12 @@
if self.run_ssh:
# Log in and verify the boot time has changed
- linux_client = RemoteClient(server, self.ssh_user, self.password)
+ linux_client = remote_client.RemoteClient(server, self.ssh_user,
+ self.password)
new_boot_time = linux_client.get_boot_time()
self.assertGreater(new_boot_time, boot_time)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_rebuild_server(self):
# The server should be rebuilt using the provided image and data
meta = {'rebuild': 'server'}
@@ -133,10 +136,11 @@
if self.run_ssh:
# Verify that the user can authenticate with the provided password
- linux_client = RemoteClient(server, self.ssh_user, password)
+ linux_client = remote_client.RemoteClient(server, self.ssh_user,
+ password)
linux_client.validate_authentication()
- @attr(type='gate')
+ @test.attr(type='gate')
def test_rebuild_server_in_stop_state(self):
# The server in stop state should be rebuilt using the provided
# image and remain in SHUTOFF state
@@ -174,7 +178,7 @@
return current_flavor, new_flavor_ref
@testtools.skipIf(not resize_available, 'Resize not available.')
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_resize_server_confirm(self):
# The server's RAM and disk space should be modified to that of
# the provided flavor
@@ -193,7 +197,7 @@
self.assertEqual(new_flavor_ref, server['flavor']['id'])
@testtools.skipIf(not resize_available, 'Resize not available.')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_resize_server_revert(self):
# The server's RAM and disk space should return to its original
# values after a resize is reverted
@@ -221,7 +225,7 @@
required time (%s s).' % (self.server_id, self.build_timeout)
raise exceptions.TimeoutException(message)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_create_backup(self):
# Positive test:create backup successfully and rotate backups correctly
# create the first and the second backup
@@ -303,7 +307,7 @@
lines = len(output.split('\n'))
self.assertEqual(lines, 10)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_console_output(self):
# Positive test:Should be able to GET the console output
# for a given server_id and number of lines
@@ -319,7 +323,7 @@
self.wait_for(self._get_output)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_console_output_server_id_in_shutoff_status(self):
# Positive test:Should be able to GET the console output
# for a given server_id in SHUTOFF status
@@ -336,7 +340,7 @@
self.wait_for(self._get_output)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_pause_unpause_server(self):
resp, server = self.client.pause_server(self.server_id)
self.assertEqual(202, resp.status)
@@ -345,7 +349,7 @@
self.assertEqual(202, resp.status)
self.client.wait_for_server_status(self.server_id, 'ACTIVE')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_suspend_resume_server(self):
resp, server = self.client.suspend_server(self.server_id)
self.assertEqual(202, resp.status)
@@ -354,7 +358,7 @@
self.assertEqual(202, resp.status)
self.client.wait_for_server_status(self.server_id, 'ACTIVE')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_shelve_unshelve_server(self):
resp, server = self.client.shelve_server(self.server_id)
self.assertEqual(202, resp.status)
@@ -368,6 +372,11 @@
self.client.wait_for_server_status(self.server_id,
'SHELVED')
+ resp, server = self.client.shelve_offload_server(self.server_id)
+ self.assertEqual(202, resp.status)
+ self.client.wait_for_server_status(self.server_id,
+ 'SHELVED_OFFLOADED')
+
resp, server = self.client.get_server(self.server_id)
image_name = server['name'] + '-shelved'
resp, images = self.images_client.image_list(name=image_name)
@@ -378,7 +387,7 @@
self.assertEqual(202, resp.status)
self.client.wait_for_server_status(self.server_id, 'ACTIVE')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_stop_start_server(self):
resp, server = self.servers_client.stop(self.server_id)
self.assertEqual(202, resp.status)
@@ -387,7 +396,7 @@
self.assertEqual(202, resp.status)
self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_lock_unlock_server(self):
# Lock the server,try server stop(exceptions throw),unlock it and retry
resp, server = self.servers_client.lock_server(self.server_id)
@@ -406,3 +415,16 @@
resp, server = self.servers_client.start(self.server_id)
self.assertEqual(202, resp.status)
self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
+
+ @testtools.skipUnless(CONF.compute_feature_enabled.vnc_console,
+ 'VNC Console feature is disabled')
+ @test.attr(type='gate')
+ def test_get_vnc_console(self):
+ # Get the VNC console
+ console_types = ['novnc', 'xvpvnc']
+ for console_type in console_types:
+ resp, body = self.servers_client.get_vnc_console(self.server_id,
+ console_type)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(console_type, body['type'])
+ self.assertNotEqual('', body['url'])
diff --git a/tempest/api/compute/v3/servers/test_server_addresses.py b/tempest/api/compute/v3/servers/test_server_addresses.py
index bffa7c4..efd7500 100644
--- a/tempest/api/compute/v3/servers/test_server_addresses.py
+++ b/tempest/api/compute/v3/servers/test_server_addresses.py
@@ -14,12 +14,13 @@
# under the License.
from tempest.api.compute import base
-from tempest import exceptions
-from tempest.test import attr
+from tempest import config
+from tempest import test
+
+CONF = config.CONF
class ServerAddressesV3Test(base.BaseV3ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
@@ -30,20 +31,9 @@
resp, cls.server = cls.create_test_server(wait_until='ACTIVE')
- @attr(type=['negative', 'gate'])
- def test_list_server_addresses_invalid_server_id(self):
- # List addresses request should fail if server id not in system
- self.assertRaises(exceptions.NotFound, self.client.list_addresses,
- '999')
-
- @attr(type=['negative', 'gate'])
- def test_list_server_addresses_by_network_neg(self):
- # List addresses by network should fail if network name not valid
- self.assertRaises(exceptions.NotFound,
- self.client.list_addresses_by_network,
- self.server['id'], 'invalid')
-
- @attr(type='smoke')
+ @test.skip_because(bug="1210483",
+ condition=CONF.service_available.neutron)
+ @test.attr(type='smoke')
def test_list_server_addresses(self):
# All public and private addresses for
# a server should be returned
@@ -60,7 +50,7 @@
self.assertTrue(address['addr'])
self.assertTrue(address['version'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_server_addresses_by_network(self):
# Providing a network type should filter
# the addresses return by that type
diff --git a/tempest/api/compute/v3/servers/test_server_addresses_negative.py b/tempest/api/compute/v3/servers/test_server_addresses_negative.py
new file mode 100644
index 0000000..8a9877b
--- /dev/null
+++ b/tempest/api/compute/v3/servers/test_server_addresses_negative.py
@@ -0,0 +1,46 @@
+# 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.
+
+from tempest.api.compute import base
+from tempest.common.utils import data_utils
+from tempest import exceptions
+from tempest import test
+
+
+class ServerAddressesV3NegativeTest(base.BaseV3ComputeTest):
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ # This test module might use a network and a subnet
+ cls.set_network_resources(network=True, subnet=True)
+ super(ServerAddressesV3NegativeTest, cls).setUpClass()
+ cls.client = cls.servers_client
+
+ resp, cls.server = cls.create_test_server(wait_until='ACTIVE')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_list_server_addresses_nonexistent_server_id(self):
+ # List addresses request should fail if server id not in system
+ non_existent_server_id = data_utils.rand_uuid()
+ self.assertRaises(exceptions.NotFound, self.client.list_addresses,
+ non_existent_server_id)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_list_server_addresses_by_network_neg(self):
+ # List addresses by network should fail if network name not valid
+ self.assertRaises(exceptions.NotFound,
+ self.client.list_addresses_by_network,
+ self.server['id'], 'invalid')
diff --git a/tempest/api/compute/v3/servers/test_server_metadata.py b/tempest/api/compute/v3/servers/test_server_metadata.py
index 13c82dd..0e4ef07 100644
--- a/tempest/api/compute/v3/servers/test_server_metadata.py
+++ b/tempest/api/compute/v3/servers/test_server_metadata.py
@@ -18,7 +18,6 @@
class ServerMetadataV3Test(base.BaseV3ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
diff --git a/tempest/api/compute/v3/servers/test_server_metadata_negative.py b/tempest/api/compute/v3/servers/test_server_metadata_negative.py
index ce6c340..ec2bc8c 100644
--- a/tempest/api/compute/v3/servers/test_server_metadata_negative.py
+++ b/tempest/api/compute/v3/servers/test_server_metadata_negative.py
@@ -19,7 +19,6 @@
class ServerMetadataV3NegativeTest(base.BaseV3ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
diff --git a/tempest/api/compute/v3/servers/test_server_password.py b/tempest/api/compute/v3/servers/test_server_password.py
new file mode 100644
index 0000000..fc0b145
--- /dev/null
+++ b/tempest/api/compute/v3/servers/test_server_password.py
@@ -0,0 +1,37 @@
+# Copyright 2013 IBM 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.
+
+
+from tempest.api.compute import base
+from tempest import test
+
+
+class ServerPasswordV3Test(base.BaseV3ComputeTest):
+
+ @classmethod
+ def setUpClass(cls):
+ super(ServerPasswordV3Test, cls).setUpClass()
+ cls.client = cls.servers_client
+ resp, cls.server = cls.create_test_server(wait_until="ACTIVE")
+
+ @test.attr(type='gate')
+ def test_get_server_password(self):
+ resp, body = self.client.get_password(self.server['id'])
+ self.assertEqual(200, resp.status)
+
+ @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/v3/servers/test_server_rescue.py b/tempest/api/compute/v3/servers/test_server_rescue.py
index fa7def0..b3dcb51 100644
--- a/tempest/api/compute/v3/servers/test_server_rescue.py
+++ b/tempest/api/compute/v3/servers/test_server_rescue.py
@@ -14,67 +14,22 @@
# under the License.
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 ServerRescueV3Test(base.BaseV3ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
super(ServerRescueV3Test, cls).setUpClass()
- cls.device = 'vdf'
-
- # Create a volume and wait for it to become ready for attach
- resp, cls.volume = cls.volumes_client.create_volume(
- 1, display_name=data_utils.rand_name(cls.__name__ + '_volume'))
- cls.volumes_client.wait_for_volume_status(
- cls.volume['id'], 'available')
# Server for positive tests
resp, server = cls.create_test_server(wait_until='BUILD')
- resp, resc_server = cls.create_test_server(wait_until='ACTIVE')
cls.server_id = server['id']
cls.password = server['admin_password']
cls.servers_client.wait_for_server_status(cls.server_id, 'ACTIVE')
- # Server for negative tests
- cls.rescue_id = resc_server['id']
- cls.rescue_password = resc_server['admin_password']
-
- cls.servers_client.rescue_server(
- cls.rescue_id, admin_password=cls.rescue_password)
- cls.servers_client.wait_for_server_status(cls.rescue_id, 'RESCUE')
-
- def setUp(self):
- super(ServerRescueV3Test, self).setUp()
-
- @classmethod
- def tearDownClass(cls):
- cls.delete_volume(cls.volume['id'])
- super(ServerRescueV3Test, cls).tearDownClass()
-
- def tearDown(self):
- super(ServerRescueV3Test, self).tearDown()
-
- def _detach(self, server_id, volume_id):
- self.servers_client.detach_volume(server_id, volume_id)
- self.volumes_client.wait_for_volume_status(volume_id,
- 'available')
-
- def _unrescue(self, server_id):
- resp, body = self.servers_client.unrescue_server(server_id)
- self.assertEqual(202, resp.status)
- self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
-
- def _unpause(self, server_id):
- resp, body = self.servers_client.unpause_server(server_id)
- self.assertEqual(202, resp.status)
- self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
-
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_rescue_unrescue_instance(self):
resp, body = self.servers_client.rescue_server(
self.server_id, admin_password=self.password)
@@ -83,71 +38,3 @@
resp, body = self.servers_client.unrescue_server(self.server_id)
self.assertEqual(202, resp.status)
self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
-
- @attr(type=['negative', 'gate'])
- def test_rescue_paused_instance(self):
- # Rescue a paused server
- resp, body = self.servers_client.pause_server(
- self.server_id)
- self.addCleanup(self._unpause, self.server_id)
- self.assertEqual(202, resp.status)
- self.servers_client.wait_for_server_status(self.server_id, 'PAUSED')
- self.assertRaises(exceptions.Conflict,
- self.servers_client.rescue_server,
- self.server_id)
-
- @attr(type=['negative', 'gate'])
- def test_rescued_vm_reboot(self):
- self.assertRaises(exceptions.Conflict, self.servers_client.reboot,
- self.rescue_id, 'HARD')
-
- @attr(type=['negative', 'gate'])
- def test_rescue_non_existent_server(self):
- # Rescue a non-existing server
- self.assertRaises(exceptions.NotFound,
- self.servers_client.rescue_server,
- '999erra43')
-
- @attr(type=['negative', 'gate'])
- def test_rescued_vm_rebuild(self):
- self.assertRaises(exceptions.Conflict,
- self.servers_client.rebuild,
- self.rescue_id,
- self.image_ref_alt)
-
- @attr(type=['negative', 'gate'])
- def test_rescued_vm_attach_volume(self):
- # Rescue the server
- self.servers_client.rescue_server(self.server_id,
- admin_password=self.password)
- self.servers_client.wait_for_server_status(self.server_id, 'RESCUE')
- self.addCleanup(self._unrescue, self.server_id)
-
- # Attach the volume to the server
- self.assertRaises(exceptions.Conflict,
- self.servers_client.attach_volume,
- self.server_id,
- self.volume['id'],
- device='/dev/%s' % self.device)
-
- @attr(type=['negative', 'gate'])
- def test_rescued_vm_detach_volume(self):
- # Attach the volume to the server
- self.servers_client.attach_volume(self.server_id,
- self.volume['id'],
- device='/dev/%s' % self.device)
- self.volumes_client.wait_for_volume_status(self.volume['id'], 'in-use')
-
- # Rescue the server
- self.servers_client.rescue_server(self.server_id,
- admin_password=self.password)
- self.servers_client.wait_for_server_status(self.server_id, 'RESCUE')
- # addCleanup is a LIFO queue
- self.addCleanup(self._detach, self.server_id, self.volume['id'])
- self.addCleanup(self._unrescue, self.server_id)
-
- # Detach the volume from the server expecting failure
- self.assertRaises(exceptions.Conflict,
- self.servers_client.detach_volume,
- self.server_id,
- self.volume['id'])
diff --git a/tempest/api/compute/v3/servers/test_server_rescue_negative.py b/tempest/api/compute/v3/servers/test_server_rescue_negative.py
new file mode 100644
index 0000000..6bb441c
--- /dev/null
+++ b/tempest/api/compute/v3/servers/test_server_rescue_negative.py
@@ -0,0 +1,134 @@
+# Copyright 2013 Hewlett-Packard Development Company, L.P.
+# 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.
+
+from tempest.api.compute import base
+from tempest.common.utils import data_utils
+from tempest import exceptions
+from tempest import test
+
+
+class ServerRescueNegativeV3Test(base.BaseV3ComputeTest):
+
+ @classmethod
+ @test.safe_setup
+ def setUpClass(cls):
+ super(ServerRescueNegativeV3Test, cls).setUpClass()
+ cls.device = 'vdf'
+
+ # Create a volume and wait for it to become ready for attach
+ resp, cls.volume = cls.volumes_client.create_volume(
+ 1, display_name=data_utils.rand_name(cls.__name__ + '_volume'))
+ cls.volumes_client.wait_for_volume_status(
+ cls.volume['id'], 'available')
+
+ # Server for negative tests
+ resp, server = cls.create_test_server(wait_until='BUILD')
+ resp, resc_server = cls.create_test_server(wait_until='ACTIVE')
+ cls.server_id = server['id']
+ cls.password = server['admin_password']
+ cls.rescue_id = resc_server['id']
+ cls.rescue_password = resc_server['admin_password']
+
+ cls.servers_client.rescue_server(
+ cls.rescue_id, admin_password=cls.rescue_password)
+ cls.servers_client.wait_for_server_status(cls.rescue_id, 'RESCUE')
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.delete_volume(cls.volume['id'])
+ super(ServerRescueNegativeV3Test, cls).tearDownClass()
+
+ def _detach(self, server_id, volume_id):
+ self.servers_client.detach_volume(server_id, volume_id)
+ self.volumes_client.wait_for_volume_status(volume_id,
+ 'available')
+
+ def _unrescue(self, server_id):
+ resp, body = self.servers_client.unrescue_server(server_id)
+ self.assertEqual(202, resp.status)
+ self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
+
+ def _unpause(self, server_id):
+ resp, body = self.servers_client.unpause_server(server_id)
+ self.assertEqual(202, resp.status)
+ self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_rescue_paused_instance(self):
+ # Rescue a paused server
+ resp, body = self.servers_client.pause_server(
+ self.server_id)
+ self.addCleanup(self._unpause, self.server_id)
+ self.assertEqual(202, resp.status)
+ self.servers_client.wait_for_server_status(self.server_id, 'PAUSED')
+ self.assertRaises(exceptions.Conflict,
+ self.servers_client.rescue_server,
+ self.server_id)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_rescued_vm_reboot(self):
+ self.assertRaises(exceptions.Conflict, self.servers_client.reboot,
+ self.rescue_id, 'HARD')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_rescue_non_existent_server(self):
+ # Rescue a non-existing server
+ self.assertRaises(exceptions.NotFound,
+ self.servers_client.rescue_server,
+ data_utils.rand_uuid())
+
+ @test.attr(type=['negative', 'gate'])
+ def test_rescued_vm_rebuild(self):
+ self.assertRaises(exceptions.Conflict,
+ self.servers_client.rebuild,
+ self.rescue_id,
+ self.image_ref_alt)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_rescued_vm_attach_volume(self):
+ # Rescue the server
+ self.servers_client.rescue_server(self.server_id,
+ admin_password=self.password)
+ self.servers_client.wait_for_server_status(self.server_id, 'RESCUE')
+ self.addCleanup(self._unrescue, self.server_id)
+
+ # Attach the volume to the server
+ self.assertRaises(exceptions.Conflict,
+ self.servers_client.attach_volume,
+ self.server_id,
+ self.volume['id'],
+ device='/dev/%s' % self.device)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_rescued_vm_detach_volume(self):
+ # Attach the volume to the server
+ self.servers_client.attach_volume(self.server_id,
+ self.volume['id'],
+ device='/dev/%s' % self.device)
+ self.volumes_client.wait_for_volume_status(self.volume['id'], 'in-use')
+
+ # Rescue the server
+ self.servers_client.rescue_server(self.server_id,
+ admin_password=self.password)
+ self.servers_client.wait_for_server_status(self.server_id, 'RESCUE')
+ # addCleanup is a LIFO queue
+ self.addCleanup(self._detach, self.server_id, self.volume['id'])
+ self.addCleanup(self._unrescue, self.server_id)
+
+ # Detach the volume from the server expecting failure
+ self.assertRaises(exceptions.Conflict,
+ self.servers_client.detach_volume,
+ self.server_id,
+ self.volume['id'])
diff --git a/tempest/api/compute/v3/servers/test_servers.py b/tempest/api/compute/v3/servers/test_servers.py
index dc64c40..426ee8d 100644
--- a/tempest/api/compute/v3/servers/test_servers.py
+++ b/tempest/api/compute/v3/servers/test_servers.py
@@ -19,7 +19,6 @@
class ServersV3Test(base.BaseV3ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
@@ -105,38 +104,6 @@
server['os-access-ips:access_ip_v6'])
@test.attr(type='gate')
- def test_delete_server_while_in_shutoff_state(self):
- # Delete a server while it's VM state is Shutoff
- resp, server = self.create_test_server(wait_until='ACTIVE')
- resp, body = self.client.stop(server['id'])
- self.client.wait_for_server_status(server['id'], 'SHUTOFF')
- resp, _ = self.client.delete_server(server['id'])
- self.assertEqual('204', resp['status'])
-
- @test.attr(type='gate')
- def test_delete_server_while_in_pause_state(self):
- # Delete a server while it's VM state is Pause
- resp, server = self.create_test_server(wait_until='ACTIVE')
- resp, body = self.client.pause_server(server['id'])
- self.client.wait_for_server_status(server['id'], 'PAUSED')
- resp, _ = self.client.delete_server(server['id'])
- self.assertEqual('204', resp['status'])
-
- @test.attr(type='gate')
- def test_delete_server_while_in_building_state(self):
- # Delete a server while it's VM state is Building
- resp, server = self.create_test_server(wait_until='BUILD')
- resp, _ = self.client.delete_server(server['id'])
- self.assertEqual('204', resp['status'])
-
- @test.attr(type='gate')
- def test_delete_active_server(self):
- # Delete a server while it's VM state is Active
- resp, server = self.create_test_server(wait_until='ACTIVE')
- resp, _ = self.client.delete_server(server['id'])
- self.assertEqual('204', resp['status'])
-
- @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(access_ip_v6='2001:2001::3')
diff --git a/tempest/api/compute/v3/servers/test_servers_negative.py b/tempest/api/compute/v3/servers/test_servers_negative.py
index 12e0ad8..cb5e93d 100644
--- a/tempest/api/compute/v3/servers/test_servers_negative.py
+++ b/tempest/api/compute/v3/servers/test_servers_negative.py
@@ -27,7 +27,6 @@
class ServersNegativeV3Test(base.BaseV3ComputeTest):
- _interface = 'json'
def setUp(self):
super(ServersNegativeV3Test, self).setUp()
diff --git a/tempest/api/compute/v3/test_extensions.py b/tempest/api/compute/v3/test_extensions.py
index 09f5ab4..3c612df 100644
--- a/tempest/api/compute/v3/test_extensions.py
+++ b/tempest/api/compute/v3/test_extensions.py
@@ -25,7 +25,6 @@
class ExtensionsV3Test(base.BaseV3ComputeTest):
- _interface = 'json'
@test.attr(type='gate')
def test_list_extensions(self):
diff --git a/tempest/api/compute/v3/test_live_block_migration.py b/tempest/api/compute/v3/test_live_block_migration.py
index 144cadb..33d2bd9 100644
--- a/tempest/api/compute/v3/test_live_block_migration.py
+++ b/tempest/api/compute/v3/test_live_block_migration.py
@@ -13,14 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-import random
-import string
-
import testtools
from tempest.api.compute import base
from tempest import config
-from tempest import exceptions
from tempest.test import attr
CONF = config.CONF
@@ -28,7 +24,6 @@
class LiveBlockMigrationV3Test(base.BaseV3ComputeAdminTest):
_host_key = 'os-extended-server-attributes:host'
- _interface = 'json'
@classmethod
def setUpClass(cls):
@@ -66,14 +61,6 @@
if host != target_host:
return target_host
- def _get_non_existing_host_name(self):
- random_name = ''.join(
- random.choice(string.ascii_uppercase) for x in range(20))
-
- self.assertNotIn(random_name, self._get_compute_hostnames())
-
- return random_name
-
def _get_server_status(self, server_id):
return self._get_server_details(server_id)['status']
@@ -111,18 +98,6 @@
self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
self.assertEqual(target_host, self._get_host_for_server(server_id))
- @testtools.skipIf(not CONF.compute_feature_enabled.live_migration,
- 'Live migration not available')
- @attr(type='gate')
- def test_invalid_host_for_migration(self):
- # Migrating to an invalid host should not change the status
- server_id = self._get_an_active_server()
- target_host = self._get_non_existing_host_name()
-
- self.assertRaises(exceptions.BadRequest, self._migrate_server_to,
- server_id, target_host)
- self.assertEqual('ACTIVE', self._get_server_status(server_id))
-
@testtools.skipIf(not CONF.compute_feature_enabled.live_migration or not
CONF.compute_feature_enabled.
block_migration_for_live_migration,
@@ -155,10 +130,3 @@
self._migrate_server_to(server_id, target_host)
self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
self.assertEqual(target_host, self._get_host_for_server(server_id))
-
- @classmethod
- def tearDownClass(cls):
- for server_id in cls.created_server_ids:
- cls.servers_client.delete_server(server_id)
-
- super(LiveBlockMigrationV3Test, cls).tearDownClass()
diff --git a/tempest/api/compute/v3/test_live_block_migration_negative.py b/tempest/api/compute/v3/test_live_block_migration_negative.py
new file mode 100644
index 0000000..b4ec505
--- /dev/null
+++ b/tempest/api/compute/v3/test_live_block_migration_negative.py
@@ -0,0 +1,53 @@
+# 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.
+
+
+from tempest.api.compute import base
+from tempest.common.utils import data_utils
+from tempest import config
+from tempest import exceptions
+from tempest import test
+
+CONF = config.CONF
+
+
+class LiveBlockMigrationV3NegativeTest(base.BaseV3ComputeAdminTest):
+ _host_key = 'os-extended-server-attributes:host'
+
+ @classmethod
+ def setUpClass(cls):
+ super(LiveBlockMigrationV3NegativeTest, cls).setUpClass()
+ if not CONF.compute_feature_enabled.live_migration:
+ raise cls.skipException("Live migration is not enabled")
+
+ cls.admin_hosts_client = cls.hosts_admin_client
+ cls.admin_servers_client = cls.servers_admin_client
+
+ def _migrate_server_to(self, server_id, dest_host):
+ _resp, body = self.admin_servers_client.live_migrate_server(
+ server_id, dest_host,
+ CONF.compute_feature_enabled.
+ block_migration_for_live_migration)
+ return body
+
+ @test.attr(type=['negative', 'gate'])
+ def test_invalid_host_for_migration(self):
+ # Migrating to an invalid host should not change the status
+ target_host = data_utils.rand_name('host-')
+ _, server = self.create_test_server(wait_until="ACTIVE")
+ server_id = server['id']
+ self.assertRaises(exceptions.BadRequest, self._migrate_server_to,
+ server_id, target_host)
+ self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
diff --git a/tempest/api/compute/v3/test_quotas.py b/tempest/api/compute/v3/test_quotas.py
index 33b90ff..3fe62e9 100644
--- a/tempest/api/compute/v3/test_quotas.py
+++ b/tempest/api/compute/v3/test_quotas.py
@@ -18,7 +18,6 @@
class QuotasV3Test(base.BaseV3ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
@@ -28,6 +27,9 @@
resp, tenants = cls.admin_client.list_tenants()
cls.tenant_id = [tnt['id'] for tnt in tenants if tnt['name'] ==
cls.client.tenant_name][0]
+ resp, users = cls.admin_client.list_users_for_tenant(cls.tenant_id)
+ cls.user_id = [user['id'] for user in users if user['name'] ==
+ cls.client.user][0]
cls.default_quota_set = set(('metadata_items',
'ram', 'floating_ips',
'fixed_ips', 'key_pairs',
@@ -44,6 +46,14 @@
sorted(quota_set.keys()))
self.assertEqual(quota_set['id'], self.tenant_id)
+ # get the quota set using user id
+ resp, quota_set = self.client.get_quota_set(self.tenant_id,
+ self.user_id)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(sorted(expected_quota_set),
+ sorted(quota_set.keys()))
+ self.assertEqual(quota_set['id'], self.tenant_id)
+
@test.attr(type='smoke')
def test_get_default_quotas(self):
# User can get the default quota set for it's tenant
diff --git a/tempest/api/compute/v3/test_version.py b/tempest/api/compute/v3/test_version.py
index 9161d4d..1a74e35 100644
--- a/tempest/api/compute/v3/test_version.py
+++ b/tempest/api/compute/v3/test_version.py
@@ -19,7 +19,6 @@
class VersionV3Test(base.BaseV3ComputeTest):
- _interface = 'json'
@test.attr(type='gate')
def test_version(self):
diff --git a/tempest/api/compute/volumes/test_attach_volume.py b/tempest/api/compute/volumes/test_attach_volume.py
index 8d8e3ec..3c5feed 100644
--- a/tempest/api/compute/volumes/test_attach_volume.py
+++ b/tempest/api/compute/volumes/test_attach_volume.py
@@ -16,15 +16,14 @@
import testtools
from tempest.api.compute import base
-from tempest.common.utils.linux.remote_client import RemoteClient
+from tempest.common.utils.linux import remote_client
from tempest import config
-from tempest.test import attr
+from tempest import test
CONF = config.CONF
class AttachVolumeTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
run_ssh = CONF.compute.run_ssh
def __init__(self, *args, **kwargs):
@@ -78,7 +77,7 @@
self.addCleanup(self._detach, server['id'], volume['id'])
@testtools.skipIf(not run_ssh, 'SSH required for this test')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_attach_detach_volume(self):
# Stop and Start a server with an attached volume, ensuring that
# the volume remains attached.
@@ -92,8 +91,8 @@
self.servers_client.start(server['id'])
self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
- linux_client = RemoteClient(server,
- self.image_ssh_user, server['adminPass'])
+ linux_client = remote_client.RemoteClient(server, self.image_ssh_user,
+ server['adminPass'])
partitions = linux_client.get_partitions()
self.assertIn(self.device, partitions)
@@ -106,8 +105,8 @@
self.servers_client.start(server['id'])
self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
- linux_client = RemoteClient(server,
- self.image_ssh_user, server['adminPass'])
+ linux_client = remote_client.RemoteClient(server, self.image_ssh_user,
+ server['adminPass'])
partitions = linux_client.get_partitions()
self.assertNotIn(self.device, partitions)
diff --git a/tempest/api/compute/volumes/test_volumes_get.py b/tempest/api/compute/volumes/test_volumes_get.py
index bcab891..c3d6ba6 100644
--- a/tempest/api/compute/volumes/test_volumes_get.py
+++ b/tempest/api/compute/volumes/test_volumes_get.py
@@ -16,16 +16,14 @@
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest import config
-from tempest.test import attr
-from testtools.matchers import ContainsAll
+from tempest import test
+from testtools import matchers
CONF = config.CONF
class VolumesGetTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
super(VolumesGetTestJSON, cls).setUpClass()
@@ -34,7 +32,7 @@
skip_msg = ("%s skipped as Cinder is not available" % cls.__name__)
raise cls.skipException(skip_msg)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_volume_create_get_delete(self):
# CREATE, GET, DELETE Volume
volume = None
@@ -68,7 +66,7 @@
'The fetched Volume is different '
'from the created Volume')
self.assertThat(fetched_volume['metadata'].items(),
- ContainsAll(metadata.items()),
+ matchers.ContainsAll(metadata.items()),
'The fetched Volume metadata misses data '
'from the created Volume')
diff --git a/tempest/api/compute/volumes/test_volumes_list.py b/tempest/api/compute/volumes/test_volumes_list.py
index 48b1b7e..9867c64 100644
--- a/tempest/api/compute/volumes/test_volumes_list.py
+++ b/tempest/api/compute/volumes/test_volumes_list.py
@@ -31,8 +31,6 @@
VOLUME_BACKING_FILE_SIZE is atleast 4G in your localrc
"""
- _interface = 'json'
-
@classmethod
def setUpClass(cls):
super(VolumesTestJSON, cls).setUpClass()
diff --git a/tempest/api/compute/volumes/test_volumes_negative.py b/tempest/api/compute/volumes/test_volumes_negative.py
index 85b30e2..cecaf62 100644
--- a/tempest/api/compute/volumes/test_volumes_negative.py
+++ b/tempest/api/compute/volumes/test_volumes_negative.py
@@ -25,7 +25,6 @@
class VolumesNegativeTest(base.BaseV2ComputeTest):
- _interface = 'json'
@classmethod
def setUpClass(cls):
diff --git a/tempest/api/data_processing/base.py b/tempest/api/data_processing/base.py
index ab882cd..73ad22b 100644
--- a/tempest/api/data_processing/base.py
+++ b/tempest/api/data_processing/base.py
@@ -27,8 +27,8 @@
def setUpClass(cls):
super(BaseDataProcessingTest, cls).setUpClass()
os = cls.get_client_manager()
- if not CONF.service_available.savanna:
- raise cls.skipException("Savanna support is required")
+ if not CONF.service_available.sahara:
+ raise cls.skipException("Sahara support is required")
cls.client = os.data_processing_client
# set some constants
@@ -63,7 +63,7 @@
except Exception:
# ignore errors while auto removing created resource
pass
-
+ cls.clear_isolated_creds()
super(BaseDataProcessingTest, cls).tearDownClass()
@classmethod
diff --git a/tempest/api/data_processing/test_node_group_templates.py b/tempest/api/data_processing/test_node_group_templates.py
index ff4fa6a..a64c345 100644
--- a/tempest/api/data_processing/test_node_group_templates.py
+++ b/tempest/api/data_processing/test_node_group_templates.py
@@ -28,7 +28,7 @@
if template_name is None:
# generate random name if it's not specified
- template_name = data_utils.rand_name('savanna')
+ template_name = data_utils.rand_name('sahara')
# create simple node group template
resp, body, template_id = self.create_node_group_template(
diff --git a/tempest/api/data_processing/test_plugins.py b/tempest/api/data_processing/test_plugins.py
new file mode 100644
index 0000000..3b941d8
--- /dev/null
+++ b/tempest/api/data_processing/test_plugins.py
@@ -0,0 +1,58 @@
+# Copyright (c) 2013 Mirantis 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.api.data_processing import base as dp_base
+from tempest.test import attr
+
+
+class PluginsTest(dp_base.BaseDataProcessingTest):
+ def _list_all_plugin_names(self):
+ """Returns all enabled plugin names.
+
+ It ensures response status and main plugins availability.
+ """
+ resp, plugins = self.client.list_plugins()
+
+ self.assertEqual(200, resp.status)
+
+ plugins_names = list([plugin['name'] for plugin in plugins])
+ self.assertIn('vanilla', plugins_names)
+ self.assertIn('hdp', plugins_names)
+
+ return plugins_names
+
+ @attr(type='smoke')
+ def test_plugin_list(self):
+ self._list_all_plugin_names()
+
+ @attr(type='smoke')
+ def test_plugin_get(self):
+ for plugin_name in self._list_all_plugin_names():
+ resp, plugin = self.client.get_plugin(plugin_name)
+
+ self.assertEqual(200, resp.status)
+ self.assertEqual(plugin_name, plugin['name'])
+
+ for plugin_version in plugin['versions']:
+ resp, detailed_plugin = self.client.get_plugin(plugin_name,
+ plugin_version)
+
+ self.assertEqual(200, resp.status)
+ self.assertEqual(plugin_name, detailed_plugin['name'])
+
+ # check that required image tags contains name and version
+ image_tags = detailed_plugin['required_image_tags']
+ self.assertIn(plugin_name, image_tags)
+ self.assertIn(plugin_version, image_tags)
diff --git a/tempest/api/database/__init__.py b/tempest/api/database/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/api/database/__init__.py
diff --git a/tempest/api/database/base.py b/tempest/api/database/base.py
new file mode 100644
index 0000000..8add9ba
--- /dev/null
+++ b/tempest/api/database/base.py
@@ -0,0 +1,42 @@
+# Copyright 2014 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.
+
+from tempest import config
+from tempest.openstack.common import log as logging
+import tempest.test
+
+CONF = config.CONF
+LOG = logging.getLogger(__name__)
+
+
+class BaseDatabaseTest(tempest.test.BaseTestCase):
+ """Base test case class for all Database API tests."""
+
+ _interface = 'json'
+ force_tenant_isolation = False
+
+ @classmethod
+ def setUpClass(cls):
+ super(BaseDatabaseTest, cls).setUpClass()
+ if not CONF.service_available.trove:
+ skip_msg = ("%s skipped as trove is not available" % cls.__name__)
+ raise cls.skipException(skip_msg)
+
+ cls.catalog_type = CONF.database.catalog_type
+ cls.db_flavor_ref = CONF.database.db_flavor_ref
+
+ os = cls.get_client_manager()
+ cls.os = os
+ cls.database_flavors_client = cls.os.database_flavors_client
diff --git a/tempest/api/database/flavors/__init__.py b/tempest/api/database/flavors/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/api/database/flavors/__init__.py
diff --git a/tempest/api/database/flavors/test_flavors.py b/tempest/api/database/flavors/test_flavors.py
new file mode 100644
index 0000000..a591e8e
--- /dev/null
+++ b/tempest/api/database/flavors/test_flavors.py
@@ -0,0 +1,41 @@
+# Copyright 2014 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.
+
+from tempest.api.database import base
+from tempest import test
+
+
+class DatabaseFlavorsTest(base.BaseDatabaseTest):
+
+ @classmethod
+ def setUpClass(cls):
+ super(DatabaseFlavorsTest, cls).setUpClass()
+ cls.client = cls.database_flavors_client
+
+ @test.attr(type='smoke')
+ def test_get_db_flavor(self):
+ # The expected flavor details should be returned
+ resp, flavor = self.client.get_db_flavor_details(self.db_flavor_ref)
+ self.assertEqual(self.db_flavor_ref, str(flavor['id']))
+ self.assertIn('ram', flavor)
+ self.assertIn('links', flavor)
+ self.assertIn('name', flavor)
+
+ @test.attr(type='smoke')
+ def test_list_db_flavors(self):
+ resp, flavor = self.client.get_db_flavor_details(self.db_flavor_ref)
+ # List of all flavors should contain the expected flavor
+ resp, flavors = self.client.list_db_flavors()
+ self.assertIn(flavor, flavors)
diff --git a/tempest/api/database/flavors/test_flavors_negative.py b/tempest/api/database/flavors/test_flavors_negative.py
new file mode 100644
index 0000000..202dc48
--- /dev/null
+++ b/tempest/api/database/flavors/test_flavors_negative.py
@@ -0,0 +1,32 @@
+# Copyright 2014 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.
+
+from tempest.api.database import base
+from tempest import exceptions
+from tempest import test
+
+
+class DatabaseFlavorsNegativeTest(base.BaseDatabaseTest):
+
+ @classmethod
+ def setUpClass(cls):
+ super(DatabaseFlavorsNegativeTest, cls).setUpClass()
+ cls.client = cls.database_flavors_client
+
+ @test.attr(type=['negative', 'gate'])
+ def test_get_non_existent_db_flavor(self):
+ # flavor details are not returned for non-existent flavors
+ self.assertRaises(exceptions.NotFound,
+ self.client.get_db_flavor_details, -1)
diff --git a/tempest/api/identity/admin/test_roles.py b/tempest/api/identity/admin/test_roles.py
index f1124e4..5e78cce 100644
--- a/tempest/api/identity/admin/test_roles.py
+++ b/tempest/api/identity/admin/test_roles.py
@@ -13,18 +13,20 @@
# License for the specific language governing permissions and limitations
# under the License.
+from six import moves
+
from tempest.api.identity import base
from tempest.common.utils import data_utils
from tempest.test import attr
-class RolesTestJSON(base.BaseIdentityAdminTest):
+class RolesTestJSON(base.BaseIdentityV2AdminTest):
_interface = 'json'
@classmethod
def setUpClass(cls):
super(RolesTestJSON, cls).setUpClass()
- for _ in xrange(5):
+ for _ in moves.xrange(5):
role_name = data_utils.rand_name(name='role-')
resp, role = cls.client.create_role(role_name)
cls.data.roles.append(role)
diff --git a/tempest/api/identity/admin/test_roles_negative.py b/tempest/api/identity/admin/test_roles_negative.py
index e5c04de..7a0bdea 100644
--- a/tempest/api/identity/admin/test_roles_negative.py
+++ b/tempest/api/identity/admin/test_roles_negative.py
@@ -21,7 +21,7 @@
from tempest.test import attr
-class RolesNegativeTestJSON(base.BaseIdentityAdminTest):
+class RolesNegativeTestJSON(base.BaseIdentityV2AdminTest):
_interface = 'json'
def _get_role_params(self):
diff --git a/tempest/api/identity/admin/test_services.py b/tempest/api/identity/admin/test_services.py
index 8ba333f..459c44c 100644
--- a/tempest/api/identity/admin/test_services.py
+++ b/tempest/api/identity/admin/test_services.py
@@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+from six import moves
from tempest.api.identity import base
from tempest.common.utils import data_utils
@@ -20,7 +21,7 @@
from tempest.test import attr
-class ServicesTestJSON(base.BaseIdentityAdminTest):
+class ServicesTestJSON(base.BaseIdentityV2AdminTest):
_interface = 'json'
def _del_service(self, service_id):
@@ -69,7 +70,7 @@
def test_list_services(self):
# Create, List, Verify and Delete Services
services = []
- for _ in xrange(3):
+ for _ in moves.xrange(3):
name = data_utils.rand_name('service-')
type = data_utils.rand_name('type--')
description = data_utils.rand_name('description-')
diff --git a/tempest/api/identity/admin/test_tenant_negative.py b/tempest/api/identity/admin/test_tenant_negative.py
index e9eddc8..44b54b8 100644
--- a/tempest/api/identity/admin/test_tenant_negative.py
+++ b/tempest/api/identity/admin/test_tenant_negative.py
@@ -21,7 +21,7 @@
from tempest.test import attr
-class TenantsNegativeTestJSON(base.BaseIdentityAdminTest):
+class TenantsNegativeTestJSON(base.BaseIdentityV2AdminTest):
_interface = 'json'
@attr(type=['negative', 'gate'])
diff --git a/tempest/api/identity/admin/test_tenants.py b/tempest/api/identity/admin/test_tenants.py
index 46fa7a9..257a6d7 100644
--- a/tempest/api/identity/admin/test_tenants.py
+++ b/tempest/api/identity/admin/test_tenants.py
@@ -13,19 +13,21 @@
# License for the specific language governing permissions and limitations
# under the License.
+from six import moves
+
from tempest.api.identity import base
from tempest.common.utils import data_utils
from tempest.test import attr
-class TenantsTestJSON(base.BaseIdentityAdminTest):
+class TenantsTestJSON(base.BaseIdentityV2AdminTest):
_interface = 'json'
@attr(type='gate')
def test_tenant_list_delete(self):
# Create several tenants and delete them
tenants = []
- for _ in xrange(3):
+ for _ in moves.xrange(3):
tenant_name = data_utils.rand_name(name='tenant-new')
resp, tenant = self.client.create_tenant(tenant_name)
self.assertEqual(200, resp.status)
diff --git a/tempest/api/identity/admin/test_tokens.py b/tempest/api/identity/admin/test_tokens.py
index 620e293..c931bcf 100644
--- a/tempest/api/identity/admin/test_tokens.py
+++ b/tempest/api/identity/admin/test_tokens.py
@@ -18,11 +18,11 @@
from tempest.test import attr
-class TokensTestJSON(base.BaseIdentityAdminTest):
+class TokensTestJSON(base.BaseIdentityV2AdminTest):
_interface = 'json'
@attr(type='gate')
- def test_create_delete_token(self):
+ def test_create_get_delete_token(self):
# get a token by username and password
user_name = data_utils.rand_name(name='user-')
user_password = data_utils.rand_name(name='pass-')
@@ -43,11 +43,62 @@
self.assertEqual(rsp['status'], '200')
self.assertEqual(body['token']['tenant']['name'],
tenant['name'])
- # then delete the token
+ # Perform GET Token
token_id = body['token']['id']
+ resp, token_details = self.client.get_token(token_id)
+ self.assertEqual(resp['status'], '200')
+ self.assertEqual(token_id, token_details['token']['id'])
+ self.assertEqual(user['id'], token_details['user']['id'])
+ self.assertEqual(user_name, token_details['user']['name'])
+ self.assertEqual(tenant['name'],
+ token_details['token']['tenant']['name'])
+ # then delete the token
resp, body = self.client.delete_token(token_id)
self.assertEqual(resp['status'], '204')
+ @attr(type='gate')
+ def test_rescope_token(self):
+ """An unscoped token can be requested, that token can be used to
+ request a scoped token.
+ """
+
+ # Create a user.
+ user_name = data_utils.rand_name(name='user-')
+ user_password = data_utils.rand_name(name='pass-')
+ tenant_id = None # No default tenant so will get unscoped token.
+ email = ''
+ resp, user = self.client.create_user(user_name, user_password,
+ tenant_id, email)
+ self.assertEqual(200, resp.status)
+ self.data.users.append(user)
+
+ # Create a tenant.
+ tenant_name = data_utils.rand_name(name='tenant-')
+ resp, tenant = self.client.create_tenant(tenant_name)
+ self.assertEqual(200, resp.status)
+ self.data.tenants.append(tenant)
+
+ # Create a role
+ role_name = data_utils.rand_name(name='role-')
+ resp, role = self.client.create_role(role_name)
+ self.assertEqual(200, resp.status)
+ self.data.roles.append(role)
+
+ # Grant the user the role on the tenant.
+ resp, _ = self.client.assign_user_role(tenant['id'], user['id'],
+ role['id'])
+ self.assertEqual(200, resp.status)
+
+ # Get an unscoped token.
+ rsp, body = self.token_client.auth(user_name, user_password)
+ self.assertEqual(200, resp.status)
+
+ token_id = body['token']['id']
+
+ # Use the unscoped token to get a scoped token.
+ rsp, body = self.token_client.auth_token(token_id, tenant=tenant_name)
+ self.assertEqual(200, resp.status)
+
class TokensTestXML(TokensTestJSON):
_interface = 'xml'
diff --git a/tempest/api/identity/admin/test_users.py b/tempest/api/identity/admin/test_users.py
index 39ef947..a4e6c17 100644
--- a/tempest/api/identity/admin/test_users.py
+++ b/tempest/api/identity/admin/test_users.py
@@ -13,14 +13,14 @@
# License for the specific language governing permissions and limitations
# under the License.
-from testtools.matchers import Contains
+from testtools import matchers
from tempest.api.identity import base
from tempest.common.utils import data_utils
-from tempest.test import attr
+from tempest import test
-class UsersTestJSON(base.BaseIdentityAdminTest):
+class UsersTestJSON(base.BaseIdentityV2AdminTest):
_interface = 'json'
@classmethod
@@ -30,7 +30,7 @@
cls.alt_password = data_utils.rand_name('pass_')
cls.alt_email = cls.alt_user + '@testmail.tm'
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_create_user(self):
# Create a user
self.data.setup_test_tenant()
@@ -41,7 +41,7 @@
self.assertEqual('200', resp['status'])
self.assertEqual(self.alt_user, user['name'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_create_user_with_enabled(self):
# Create a user with enabled : False
self.data.setup_test_tenant()
@@ -55,7 +55,7 @@
self.assertEqual('false', str(user['enabled']).lower())
self.assertEqual(self.alt_email, user['email'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_update_user(self):
# Test case to check if updating of user attributes is successful.
test_user = data_utils.rand_name('test_user_')
@@ -83,7 +83,7 @@
self.assertEqual(u_email2, updated_user['email'])
self.assertEqual('false', str(updated_user['enabled']).lower())
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_delete_user(self):
# Delete a user
test_user = data_utils.rand_name('test_user_')
@@ -95,7 +95,7 @@
resp, body = self.client.delete_user(user['id'])
self.assertEqual('204', resp['status'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_user_authentication(self):
# Valid user's token is authenticated
self.data.setup_test_user()
@@ -108,7 +108,7 @@
self.data.test_tenant)
self.assertEqual('200', resp['status'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_authentication_request_without_token(self):
# Request for token authentication with a valid token in header
self.data.setup_test_user()
@@ -125,16 +125,16 @@
self.assertEqual('200', resp['status'])
self.client.auth_provider.clear_auth()
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_get_users(self):
# Get a list of users and find the test user
self.data.setup_test_user()
resp, users = self.client.get_users()
self.assertThat([u['name'] for u in users],
- Contains(self.data.test_user),
+ matchers.Contains(self.data.test_user),
"Could not find %s" % self.data.test_user)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_users_for_tenant(self):
# Return a list of all users for a tenant
self.data.setup_test_tenant()
@@ -167,7 +167,7 @@
"Failed to find user %s in fetched list" %
', '.join(m_user for m_user in missing_users))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_users_with_roles_for_tenant(self):
# Return list of users on tenant when roles are assigned to users
self.data.setup_test_user()
diff --git a/tempest/api/identity/admin/test_users_negative.py b/tempest/api/identity/admin/test_users_negative.py
index e9e7818..4e8ebe5 100644
--- a/tempest/api/identity/admin/test_users_negative.py
+++ b/tempest/api/identity/admin/test_users_negative.py
@@ -13,14 +13,15 @@
# License for the specific language governing permissions and limitations
# under the License.
+import uuid
+
from tempest.api.identity import base
from tempest.common.utils import data_utils
from tempest import exceptions
from tempest.test import attr
-import uuid
-class UsersNegativeTestJSON(base.BaseIdentityAdminTest):
+class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest):
_interface = 'json'
@classmethod
@@ -207,7 +208,7 @@
@attr(type=['negative', 'gate'])
def test_get_users_request_without_token(self):
# Request to get list of users without a valid token should fail
- token = self.client.auth_provider.auth_data[0]
+ token = self.client.auth_provider.get_token()
self.client.delete_token(token)
self.assertRaises(exceptions.Unauthorized, self.client.get_users)
self.client.auth_provider.clear_auth()
diff --git a/tempest/api/identity/admin/v3/test_credentials.py b/tempest/api/identity/admin/v3/test_credentials.py
index 753eaa6..5f22d43 100644
--- a/tempest/api/identity/admin/v3/test_credentials.py
+++ b/tempest/api/identity/admin/v3/test_credentials.py
@@ -18,7 +18,7 @@
from tempest.test import attr
-class CredentialsTestJSON(base.BaseIdentityAdminTest):
+class CredentialsTestJSON(base.BaseIdentityV3AdminTest):
_interface = 'json'
@classmethod
@@ -32,23 +32,23 @@
u_email = '%s@testmail.tm' % u_name
u_password = data_utils.rand_name('pass-')
for i in range(2):
- resp, cls.project = cls.v3_client.create_project(
+ resp, cls.project = cls.client.create_project(
data_utils.rand_name('project-'),
description=data_utils.rand_name('project-desc-'))
assert resp['status'] == '201', "Expected %s" % resp['status']
cls.projects.append(cls.project['id'])
- resp, cls.user_body = cls.v3_client.create_user(
+ resp, cls.user_body = cls.client.create_user(
u_name, description=u_desc, password=u_password,
email=u_email, project_id=cls.projects[0])
assert resp['status'] == '201', "Expected: %s" % resp['status']
@classmethod
def tearDownClass(cls):
- resp, _ = cls.v3_client.delete_user(cls.user_body['id'])
+ resp, _ = cls.client.delete_user(cls.user_body['id'])
assert resp['status'] == '204', "Expected: %s" % resp['status']
for p in cls.projects:
- resp, _ = cls.v3_client.delete_project(p)
+ resp, _ = cls.client.delete_project(p)
assert resp['status'] == '204', "Expected: %s" % resp['status']
super(CredentialsTestJSON, cls).tearDownClass()
diff --git a/tempest/api/identity/admin/v3/test_domains.py b/tempest/api/identity/admin/v3/test_domains.py
index 4017b62..086d235 100644
--- a/tempest/api/identity/admin/v3/test_domains.py
+++ b/tempest/api/identity/admin/v3/test_domains.py
@@ -19,14 +19,14 @@
from tempest.test import attr
-class DomainsTestJSON(base.BaseIdentityAdminTest):
+class DomainsTestJSON(base.BaseIdentityV3AdminTest):
_interface = 'json'
def _delete_domain(self, domain_id):
# It is necessary to disable the domain before deleting,
# or else it would result in unauthorized error
- _, body = self.v3_client.update_domain(domain_id, enabled=False)
- resp, _ = self.v3_client.delete_domain(domain_id)
+ _, body = self.client.update_domain(domain_id, enabled=False)
+ resp, _ = self.client.delete_domain(domain_id)
self.assertEqual(204, resp.status)
@attr(type='smoke')
@@ -35,14 +35,14 @@
domain_ids = list()
fetched_ids = list()
for _ in range(3):
- _, domain = self.v3_client.create_domain(
+ _, domain = self.client.create_domain(
data_utils.rand_name('domain-'),
description=data_utils.rand_name('domain-desc-'))
# Delete the domain at the end of this method
self.addCleanup(self._delete_domain, domain['id'])
domain_ids.append(domain['id'])
# List and Verify Domains
- resp, body = self.v3_client.list_domains()
+ resp, body = self.client.list_domains()
self.assertEqual(resp['status'], '200')
for d in body:
fetched_ids.append(d['id'])
@@ -53,7 +53,7 @@
def test_create_update_delete_domain(self):
d_name = data_utils.rand_name('domain-')
d_desc = data_utils.rand_name('domain-desc-')
- resp_1, domain = self.v3_client.create_domain(
+ resp_1, domain = self.client.create_domain(
d_name, description=d_desc)
self.assertEqual(resp_1['status'], '201')
self.addCleanup(self._delete_domain, domain['id'])
@@ -72,7 +72,7 @@
new_desc = data_utils.rand_name('new-desc-')
new_name = data_utils.rand_name('new-name-')
- resp_2, updated_domain = self.v3_client.update_domain(
+ resp_2, updated_domain = self.client.update_domain(
domain['id'], name=new_name, description=new_desc)
self.assertEqual(resp_2['status'], '200')
self.assertIn('id', updated_domain)
@@ -85,7 +85,7 @@
self.assertEqual(new_desc, updated_domain['description'])
self.assertEqual('true', str(updated_domain['enabled']).lower())
- resp_3, fetched_domain = self.v3_client.get_domain(domain['id'])
+ resp_3, fetched_domain = self.client.get_domain(domain['id'])
self.assertEqual(resp_3['status'], '200')
self.assertEqual(new_name, fetched_domain['name'])
self.assertEqual(new_desc, fetched_domain['description'])
diff --git a/tempest/api/identity/admin/v3/test_endpoints.py b/tempest/api/identity/admin/v3/test_endpoints.py
index 4ae7884..0e4d66b 100644
--- a/tempest/api/identity/admin/v3/test_endpoints.py
+++ b/tempest/api/identity/admin/v3/test_endpoints.py
@@ -18,7 +18,7 @@
from tempest.test import attr
-class EndPointsTestJSON(base.BaseIdentityAdminTest):
+class EndPointsTestJSON(base.BaseIdentityV3AdminTest):
_interface = 'json'
@classmethod
@@ -31,8 +31,8 @@
s_type = data_utils.rand_name('type--')
s_description = data_utils.rand_name('description-')
resp, cls.service_data =\
- cls.identity_client.create_service(s_name, s_type,
- description=s_description)
+ cls.service_client.create_service(s_name, s_type,
+ description=s_description)
cls.service_id = cls.service_data['id']
cls.service_ids.append(cls.service_id)
# Create endpoints so as to use for LIST and GET test cases
@@ -50,7 +50,7 @@
for e in cls.setup_endpoints:
cls.client.delete_endpoint(e['id'])
for s in cls.service_ids:
- cls.identity_client.delete_service(s)
+ cls.service_client.delete_service(s)
super(EndPointsTestJSON, cls).tearDownClass()
@attr(type='gate')
@@ -102,13 +102,14 @@
self.client.create_endpoint(self.service_id, interface1,
url1, region=region1,
enabled=True)
+ self.addCleanup(self.client.delete_endpoint, endpoint_for_update['id'])
# Creating service so as update endpoint with new service ID
s_name = data_utils.rand_name('service-')
s_type = data_utils.rand_name('type--')
s_description = data_utils.rand_name('description-')
resp, self.service2 =\
- self.identity_client.create_service(s_name, s_type,
- description=s_description)
+ self.service_client.create_service(s_name, s_type,
+ description=s_description)
self.service_ids.append(self.service2['id'])
# Updating endpoint with new values
region2 = data_utils.rand_name('region')
@@ -125,8 +126,7 @@
self.assertEqual(interface2, endpoint['interface'])
self.assertEqual(url2, endpoint['url'])
self.assertEqual(region2, endpoint['region'])
- self.assertEqual('False', str(endpoint['enabled']))
- self.addCleanup(self.client.delete_endpoint, endpoint_for_update['id'])
+ self.assertEqual('false', str(endpoint['enabled']).lower())
class EndPointsTestXML(EndPointsTestJSON):
diff --git a/tempest/api/identity/admin/v3/test_endpoints_negative.py b/tempest/api/identity/admin/v3/test_endpoints_negative.py
new file mode 100644
index 0000000..28615a4
--- /dev/null
+++ b/tempest/api/identity/admin/v3/test_endpoints_negative.py
@@ -0,0 +1,94 @@
+
+# Copyright 2013 IBM Corp.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+
+from tempest.api.identity import base
+from tempest.common.utils import data_utils
+from tempest import exceptions
+from tempest.test import attr
+
+
+class EndpointsNegativeTestJSON(base.BaseIdentityV3AdminTest):
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(EndpointsNegativeTestJSON, cls).setUpClass()
+ cls.identity_client = cls.client
+ cls.client = cls.endpoints_client
+ cls.service_ids = list()
+ s_name = data_utils.rand_name('service-')
+ s_type = data_utils.rand_name('type--')
+ s_description = data_utils.rand_name('description-')
+ resp, cls.service_data = (
+ cls.service_client.create_service(s_name, s_type,
+ description=s_description))
+ cls.service_id = cls.service_data['id']
+ cls.service_ids.append(cls.service_id)
+
+ @classmethod
+ def tearDownClass(cls):
+ for s in cls.service_ids:
+ cls.service_client.delete_service(s)
+ super(EndpointsNegativeTestJSON, cls).tearDownClass()
+
+ @attr(type=['negative', 'gate'])
+ def test_create_with_enabled_False(self):
+ # Enabled should be a boolean, not a string like 'False'
+ interface = 'public'
+ url = data_utils.rand_name('url')
+ region = data_utils.rand_name('region')
+ self.assertRaises(exceptions.BadRequest, self.client.create_endpoint,
+ self.service_id, interface, url, region=region,
+ force_enabled='False')
+
+ @attr(type=['negative', 'gate'])
+ def test_create_with_enabled_True(self):
+ # Enabled should be a boolean, not a string like 'True'
+ interface = 'public'
+ url = data_utils.rand_name('url')
+ region = data_utils.rand_name('region')
+ self.assertRaises(exceptions.BadRequest, self.client.create_endpoint,
+ self.service_id, interface, url, region=region,
+ force_enabled='True')
+
+ def _assert_update_raises_bad_request(self, enabled):
+
+ # Create an endpoint
+ region1 = data_utils.rand_name('region')
+ url1 = data_utils.rand_name('url')
+ interface1 = 'public'
+ resp, endpoint_for_update = (
+ self.client.create_endpoint(self.service_id, interface1,
+ url1, region=region1, enabled=True))
+ self.addCleanup(self.client.delete_endpoint, endpoint_for_update['id'])
+
+ self.assertRaises(exceptions.BadRequest, self.client.update_endpoint,
+ endpoint_for_update['id'], force_enabled=enabled)
+
+ @attr(type=['negative', 'gate'])
+ def test_update_with_enabled_False(self):
+ # Enabled should be a boolean, not a string like 'False'
+ self._assert_update_raises_bad_request('False')
+
+ @attr(type=['negative', 'gate'])
+ def test_update_with_enabled_True(self):
+ # Enabled should be a boolean, not a string like 'True'
+ self._assert_update_raises_bad_request('True')
+
+
+class EndpointsNegativeTestXML(EndpointsNegativeTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/identity/admin/v3/test_groups.py b/tempest/api/identity/admin/v3/test_groups.py
index 70afec7..6e898b2 100644
--- a/tempest/api/identity/admin/v3/test_groups.py
+++ b/tempest/api/identity/admin/v3/test_groups.py
@@ -18,7 +18,7 @@
from tempest import test
-class GroupsV3TestJSON(base.BaseIdentityAdminTest):
+class GroupsV3TestJSON(base.BaseIdentityV3AdminTest):
_interface = 'json'
@classmethod
@@ -29,23 +29,23 @@
def test_group_create_update_get(self):
name = data_utils.rand_name('Group')
description = data_utils.rand_name('Description')
- resp, group = self.v3_client.create_group(name,
- description=description)
- self.addCleanup(self.v3_client.delete_group, group['id'])
+ resp, group = self.client.create_group(name,
+ description=description)
+ self.addCleanup(self.client.delete_group, group['id'])
self.assertEqual(resp['status'], '201')
self.assertEqual(group['name'], name)
self.assertEqual(group['description'], description)
new_name = data_utils.rand_name('UpdateGroup')
new_desc = data_utils.rand_name('UpdateDescription')
- resp, updated_group = self.v3_client.update_group(group['id'],
- name=new_name,
- description=new_desc)
+ resp, updated_group = self.client.update_group(group['id'],
+ name=new_name,
+ description=new_desc)
self.assertEqual(resp['status'], '200')
self.assertEqual(updated_group['name'], new_name)
self.assertEqual(updated_group['description'], new_desc)
- resp, new_group = self.v3_client.get_group(group['id'])
+ resp, new_group = self.client.get_group(group['id'])
self.assertEqual(resp['status'], '200')
self.assertEqual(group['id'], new_group['id'])
self.assertEqual(new_name, new_group['name'])
@@ -54,27 +54,27 @@
@test.attr(type='smoke')
def test_group_users_add_list_delete(self):
name = data_utils.rand_name('Group')
- resp, group = self.v3_client.create_group(name)
- self.addCleanup(self.v3_client.delete_group, group['id'])
+ resp, group = self.client.create_group(name)
+ self.addCleanup(self.client.delete_group, group['id'])
# add user into group
users = []
for i in range(3):
name = data_utils.rand_name('User')
- resp, user = self.v3_client.create_user(name)
+ resp, user = self.client.create_user(name)
users.append(user)
- self.addCleanup(self.v3_client.delete_user, user['id'])
- self.v3_client.add_group_user(group['id'], user['id'])
+ self.addCleanup(self.client.delete_user, user['id'])
+ self.client.add_group_user(group['id'], user['id'])
# list users in group
- resp, group_users = self.v3_client.list_group_users(group['id'])
+ resp, group_users = self.client.list_group_users(group['id'])
self.assertEqual(resp['status'], '200')
self.assertEqual(users.sort(), group_users.sort())
# delete user in group
for user in users:
- resp, body = self.v3_client.delete_group_user(group['id'],
- user['id'])
+ resp, body = self.client.delete_group_user(group['id'],
+ user['id'])
self.assertEqual(resp['status'], '204')
- resp, group_users = self.v3_client.list_group_users(group['id'])
+ resp, group_users = self.client.list_group_users(group['id'])
self.assertEqual(len(group_users), 0)
diff --git a/tempest/api/identity/admin/v3/test_policies.py b/tempest/api/identity/admin/v3/test_policies.py
index 0e8e4c3..3e04b5f 100644
--- a/tempest/api/identity/admin/v3/test_policies.py
+++ b/tempest/api/identity/admin/v3/test_policies.py
@@ -18,7 +18,7 @@
from tempest.test import attr
-class PoliciesTestJSON(base.BaseIdentityAdminTest):
+class PoliciesTestJSON(base.BaseIdentityV3AdminTest):
_interface = 'json'
def _delete_policy(self, policy_id):
diff --git a/tempest/api/identity/admin/v3/test_projects.py b/tempest/api/identity/admin/v3/test_projects.py
index 1fc5a6a..31a0ddd 100644
--- a/tempest/api/identity/admin/v3/test_projects.py
+++ b/tempest/api/identity/admin/v3/test_projects.py
@@ -13,182 +13,184 @@
# License for the specific language governing permissions and limitations
# under the License.
+from six import moves
+
from tempest.api.identity import base
from tempest.common.utils import data_utils
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
-class ProjectsTestJSON(base.BaseIdentityAdminTest):
+class ProjectsTestJSON(base.BaseIdentityV3AdminTest):
_interface = 'json'
def _delete_project(self, project_id):
- resp, _ = self.v3_client.delete_project(project_id)
+ resp, _ = self.client.delete_project(project_id)
self.assertEqual(resp['status'], '204')
self.assertRaises(
- exceptions.NotFound, self.v3_client.get_project, project_id)
+ exceptions.NotFound, self.client.get_project, project_id)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_project_list_delete(self):
# Create several projects and delete them
- for _ in xrange(3):
- resp, project = self.v3_client.create_project(
+ for _ in moves.xrange(3):
+ resp, project = self.client.create_project(
data_utils.rand_name('project-new'))
self.addCleanup(self._delete_project, project['id'])
- resp, list_projects = self.v3_client.list_projects()
+ resp, list_projects = self.client.list_projects()
self.assertEqual(resp['status'], '200')
- resp, get_project = self.v3_client.get_project(project['id'])
+ resp, get_project = self.client.get_project(project['id'])
self.assertIn(get_project, list_projects)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_project_create_with_description(self):
# Create project with a description
project_name = data_utils.rand_name('project-')
project_desc = data_utils.rand_name('desc-')
- resp, project = self.v3_client.create_project(
+ resp, project = self.client.create_project(
project_name, description=project_desc)
- self.v3data.projects.append(project)
+ self.data.projects.append(project)
st1 = resp['status']
project_id = project['id']
desc1 = project['description']
self.assertEqual(st1, '201')
self.assertEqual(desc1, project_desc, 'Description should have '
'been sent in response for create')
- resp, body = self.v3_client.get_project(project_id)
+ resp, body = self.client.get_project(project_id)
desc2 = body['description']
self.assertEqual(desc2, project_desc, 'Description does not appear'
'to be set')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_project_create_enabled(self):
# Create a project that is enabled
project_name = data_utils.rand_name('project-')
- resp, project = self.v3_client.create_project(
+ resp, project = self.client.create_project(
project_name, enabled=True)
- self.v3data.projects.append(project)
+ self.data.projects.append(project)
project_id = project['id']
st1 = resp['status']
en1 = project['enabled']
self.assertEqual(st1, '201')
self.assertTrue(en1, 'Enable should be True in response')
- resp, body = self.v3_client.get_project(project_id)
+ resp, body = self.client.get_project(project_id)
en2 = body['enabled']
self.assertTrue(en2, 'Enable should be True in lookup')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_project_create_not_enabled(self):
# Create a project that is not enabled
project_name = data_utils.rand_name('project-')
- resp, project = self.v3_client.create_project(
+ resp, project = self.client.create_project(
project_name, enabled=False)
- self.v3data.projects.append(project)
+ self.data.projects.append(project)
st1 = resp['status']
en1 = project['enabled']
self.assertEqual(st1, '201')
self.assertEqual('false', str(en1).lower(),
'Enable should be False in response')
- resp, body = self.v3_client.get_project(project['id'])
+ resp, body = self.client.get_project(project['id'])
en2 = body['enabled']
self.assertEqual('false', str(en2).lower(),
'Enable should be False in lookup')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_project_update_name(self):
# Update name attribute of a project
p_name1 = data_utils.rand_name('project-')
- resp, project = self.v3_client.create_project(p_name1)
- self.v3data.projects.append(project)
+ resp, project = self.client.create_project(p_name1)
+ self.data.projects.append(project)
resp1_name = project['name']
p_name2 = data_utils.rand_name('project2-')
- resp, body = self.v3_client.update_project(project['id'], name=p_name2)
+ resp, body = self.client.update_project(project['id'], name=p_name2)
st2 = resp['status']
resp2_name = body['name']
self.assertEqual(st2, '200')
self.assertNotEqual(resp1_name, resp2_name)
- resp, body = self.v3_client.get_project(project['id'])
+ resp, body = self.client.get_project(project['id'])
resp3_name = body['name']
self.assertNotEqual(resp1_name, resp3_name)
self.assertEqual(p_name1, resp1_name)
self.assertEqual(resp2_name, resp3_name)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_project_update_desc(self):
# Update description attribute of a project
p_name = data_utils.rand_name('project-')
p_desc = data_utils.rand_name('desc-')
- resp, project = self.v3_client.create_project(
+ resp, project = self.client.create_project(
p_name, description=p_desc)
- self.v3data.projects.append(project)
+ self.data.projects.append(project)
resp1_desc = project['description']
p_desc2 = data_utils.rand_name('desc2-')
- resp, body = self.v3_client.update_project(
+ resp, body = self.client.update_project(
project['id'], description=p_desc2)
st2 = resp['status']
resp2_desc = body['description']
self.assertEqual(st2, '200')
self.assertNotEqual(resp1_desc, resp2_desc)
- resp, body = self.v3_client.get_project(project['id'])
+ resp, body = self.client.get_project(project['id'])
resp3_desc = body['description']
self.assertNotEqual(resp1_desc, resp3_desc)
self.assertEqual(p_desc, resp1_desc)
self.assertEqual(resp2_desc, resp3_desc)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_project_update_enable(self):
# Update the enabled attribute of a project
p_name = data_utils.rand_name('project-')
p_en = False
- resp, project = self.v3_client.create_project(p_name, enabled=p_en)
- self.v3data.projects.append(project)
+ resp, project = self.client.create_project(p_name, enabled=p_en)
+ self.data.projects.append(project)
resp1_en = project['enabled']
p_en2 = True
- resp, body = self.v3_client.update_project(
+ resp, body = self.client.update_project(
project['id'], enabled=p_en2)
st2 = resp['status']
resp2_en = body['enabled']
self.assertEqual(st2, '200')
self.assertNotEqual(resp1_en, resp2_en)
- resp, body = self.v3_client.get_project(project['id'])
+ resp, body = self.client.get_project(project['id'])
resp3_en = body['enabled']
self.assertNotEqual(resp1_en, resp3_en)
self.assertEqual('false', str(resp1_en).lower())
self.assertEqual(resp2_en, resp3_en)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_associate_user_to_project(self):
#Associate a user to a project
#Create a Project
p_name = data_utils.rand_name('project-')
- resp, project = self.v3_client.create_project(p_name)
- self.v3data.projects.append(project)
+ resp, project = self.client.create_project(p_name)
+ self.data.projects.append(project)
#Create a User
u_name = data_utils.rand_name('user-')
u_desc = u_name + 'description'
u_email = u_name + '@testmail.tm'
u_password = data_utils.rand_name('pass-')
- resp, user = self.v3_client.create_user(
+ resp, user = self.client.create_user(
u_name, description=u_desc, password=u_password,
email=u_email, project_id=project['id'])
self.assertEqual(resp['status'], '201')
# Delete the User at the end of this method
- self.addCleanup(self.v3_client.delete_user, user['id'])
+ self.addCleanup(self.client.delete_user, user['id'])
# Get User To validate the user details
- resp, new_user_get = self.v3_client.get_user(user['id'])
+ resp, new_user_get = self.client.get_user(user['id'])
#Assert response body of GET
self.assertEqual(u_name, new_user_get['name'])
self.assertEqual(u_desc, new_user_get['description'])
@@ -196,59 +198,6 @@
new_user_get['project_id'])
self.assertEqual(u_email, new_user_get['email'])
- @attr(type=['negative', 'gate'])
- def test_list_projects_by_unauthorized_user(self):
- # Non-admin user should not be able to list projects
- self.assertRaises(exceptions.Unauthorized,
- self.v3_non_admin_client.list_projects)
-
- @attr(type=['negative', 'gate'])
- def test_project_create_duplicate(self):
- # Project names should be unique
- project_name = data_utils.rand_name('project-dup-')
- resp, project = self.v3_client.create_project(project_name)
- self.v3data.projects.append(project)
-
- self.assertRaises(
- exceptions.Conflict, self.v3_client.create_project, project_name)
-
- @attr(type=['negative', 'gate'])
- def test_create_project_by_unauthorized_user(self):
- # Non-admin user should not be authorized to create a project
- project_name = data_utils.rand_name('project-')
- self.assertRaises(
- exceptions.Unauthorized, self.v3_non_admin_client.create_project,
- project_name)
-
- @attr(type=['negative', 'gate'])
- def test_create_project_with_empty_name(self):
- # Project name should not be empty
- self.assertRaises(exceptions.BadRequest, self.v3_client.create_project,
- name='')
-
- @attr(type=['negative', 'gate'])
- def test_create_projects_name_length_over_64(self):
- # Project name length should not be greater than 64 characters
- project_name = 'a' * 65
- self.assertRaises(exceptions.BadRequest, self.v3_client.create_project,
- project_name)
-
- @attr(type=['negative', 'gate'])
- def test_project_delete_by_unauthorized_user(self):
- # Non-admin user should not be able to delete a project
- project_name = data_utils.rand_name('project-')
- resp, project = self.v3_client.create_project(project_name)
- self.v3data.projects.append(project)
- self.assertRaises(
- exceptions.Unauthorized, self.v3_non_admin_client.delete_project,
- project['id'])
-
- @attr(type=['negative', 'gate'])
- def test_delete_non_existent_project(self):
- # Attempt to delete a non existent project should fail
- self.assertRaises(exceptions.NotFound, self.v3_client.delete_project,
- 'junk_Project_123456abc')
-
class ProjectsTestXML(ProjectsTestJSON):
_interface = 'xml'
diff --git a/tempest/api/identity/admin/v3/test_projects_negative.py b/tempest/api/identity/admin/v3/test_projects_negative.py
new file mode 100644
index 0000000..6b60d04
--- /dev/null
+++ b/tempest/api/identity/admin/v3/test_projects_negative.py
@@ -0,0 +1,80 @@
+# Copyright 2013 OpenStack, LLC
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.api.identity import base
+from tempest.common.utils import data_utils
+from tempest import exceptions
+from tempest import test
+
+
+class ProjectsNegativeTestJSON(base.BaseIdentityV3AdminTest):
+ _interface = 'json'
+
+ @test.attr(type=['negative', 'gate'])
+ def test_list_projects_by_unauthorized_user(self):
+ # Non-admin user should not be able to list projects
+ self.assertRaises(exceptions.Unauthorized,
+ self.non_admin_client.list_projects)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_project_create_duplicate(self):
+ # Project names should be unique
+ project_name = data_utils.rand_name('project-dup-')
+ resp, project = self.client.create_project(project_name)
+ self.data.projects.append(project)
+
+ self.assertRaises(
+ exceptions.Conflict, self.client.create_project, project_name)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_project_by_unauthorized_user(self):
+ # Non-admin user should not be authorized to create a project
+ project_name = data_utils.rand_name('project-')
+ self.assertRaises(
+ exceptions.Unauthorized, self.non_admin_client.create_project,
+ project_name)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_project_with_empty_name(self):
+ # Project name should not be empty
+ self.assertRaises(exceptions.BadRequest, self.client.create_project,
+ name='')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_projects_name_length_over_64(self):
+ # Project name length should not be greater than 64 characters
+ project_name = 'a' * 65
+ self.assertRaises(exceptions.BadRequest, self.client.create_project,
+ project_name)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_project_delete_by_unauthorized_user(self):
+ # Non-admin user should not be able to delete a project
+ project_name = data_utils.rand_name('project-')
+ resp, project = self.client.create_project(project_name)
+ self.data.projects.append(project)
+ self.assertRaises(
+ exceptions.Unauthorized, self.non_admin_client.delete_project,
+ project['id'])
+
+ @test.attr(type=['negative', 'gate'])
+ def test_delete_non_existent_project(self):
+ # Attempt to delete a non existent project should fail
+ self.assertRaises(exceptions.NotFound, self.client.delete_project,
+ data_utils.rand_uuid_hex())
+
+
+class ProjectsNegativeTestXML(ProjectsNegativeTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/identity/admin/v3/test_roles.py b/tempest/api/identity/admin/v3/test_roles.py
index efaed39..467d28b 100644
--- a/tempest/api/identity/admin/v3/test_roles.py
+++ b/tempest/api/identity/admin/v3/test_roles.py
@@ -18,7 +18,7 @@
from tempest.test import attr
-class RolesV3TestJSON(base.BaseIdentityAdminTest):
+class RolesV3TestJSON(base.BaseIdentityV3AdminTest):
_interface = 'json'
@classmethod
@@ -30,20 +30,20 @@
u_email = '%s@testmail.tm' % u_name
u_password = data_utils.rand_name('pass-')
resp = [None] * 5
- resp[0], cls.project = cls.v3_client.create_project(
+ resp[0], cls.project = cls.client.create_project(
data_utils.rand_name('project-'),
description=data_utils.rand_name('project-desc-'))
- resp[1], cls.domain = cls.v3_client.create_domain(
+ resp[1], cls.domain = cls.client.create_domain(
data_utils.rand_name('domain-'),
description=data_utils.rand_name('domain-desc-'))
- resp[2], cls.group_body = cls.v3_client.create_group(
+ resp[2], cls.group_body = cls.client.create_group(
data_utils.rand_name('Group-'), project_id=cls.project['id'],
domain_id=cls.domain['id'])
- resp[3], cls.user_body = cls.v3_client.create_user(
+ resp[3], cls.user_body = cls.client.create_user(
u_name, description=u_desc, password=u_password,
email=u_email, project_id=cls.project['id'],
domain_id=cls.domain['id'])
- resp[4], cls.role = cls.v3_client.create_role(
+ resp[4], cls.role = cls.client.create_role(
data_utils.rand_name('Role-'))
for r in resp:
assert r['status'] == '201', "Expected: %s" % r['status']
@@ -51,14 +51,14 @@
@classmethod
def tearDownClass(cls):
resp = [None] * 5
- resp[0], _ = cls.v3_client.delete_role(cls.role['id'])
- resp[1], _ = cls.v3_client.delete_group(cls.group_body['id'])
- resp[2], _ = cls.v3_client.delete_user(cls.user_body['id'])
- resp[3], _ = cls.v3_client.delete_project(cls.project['id'])
+ resp[0], _ = cls.client.delete_role(cls.role['id'])
+ resp[1], _ = cls.client.delete_group(cls.group_body['id'])
+ resp[2], _ = cls.client.delete_user(cls.user_body['id'])
+ resp[3], _ = cls.client.delete_project(cls.project['id'])
# NOTE(harika-vakadi): It is necessary to disable the domain
# before deleting,or else it would result in unauthorized error
- cls.v3_client.update_domain(cls.domain['id'], enabled=False)
- resp[4], _ = cls.v3_client.delete_domain(cls.domain['id'])
+ cls.client.update_domain(cls.domain['id'], enabled=False)
+ resp[4], _ = cls.client.delete_domain(cls.domain['id'])
for r in resp:
assert r['status'] == '204', "Expected: %s" % r['status']
super(RolesV3TestJSON, cls).tearDownClass()
@@ -71,32 +71,32 @@
@attr(type='smoke')
def test_role_create_update_get(self):
r_name = data_utils.rand_name('Role-')
- resp, role = self.v3_client.create_role(r_name)
- self.addCleanup(self.v3_client.delete_role, role['id'])
+ resp, role = self.client.create_role(r_name)
+ self.addCleanup(self.client.delete_role, role['id'])
self.assertEqual(resp['status'], '201')
self.assertIn('name', role)
self.assertEqual(role['name'], r_name)
new_name = data_utils.rand_name('NewRole-')
- resp, updated_role = self.v3_client.update_role(new_name, role['id'])
+ resp, updated_role = self.client.update_role(new_name, role['id'])
self.assertEqual(resp['status'], '200')
self.assertIn('name', updated_role)
self.assertIn('id', updated_role)
self.assertIn('links', updated_role)
self.assertNotEqual(r_name, updated_role['name'])
- resp, new_role = self.v3_client.get_role(role['id'])
+ resp, new_role = self.client.get_role(role['id'])
self.assertEqual(resp['status'], '200')
self.assertEqual(new_name, new_role['name'])
self.assertEqual(updated_role['id'], new_role['id'])
@attr(type='smoke')
def test_grant_list_revoke_role_to_user_on_project(self):
- resp, _ = self.v3_client.assign_user_role_on_project(
+ resp, _ = self.client.assign_user_role_on_project(
self.project['id'], self.user_body['id'], self.role['id'])
self.assertEqual(resp['status'], '204')
- resp, roles = self.v3_client.list_user_roles_on_project(
+ resp, roles = self.client.list_user_roles_on_project(
self.project['id'], self.user_body['id'])
for i in roles:
@@ -105,17 +105,17 @@
self._list_assertions(resp, roles, self.fetched_role_ids,
self.role['id'])
- resp, _ = self.v3_client.revoke_role_from_user_on_project(
+ resp, _ = self.client.revoke_role_from_user_on_project(
self.project['id'], self.user_body['id'], self.role['id'])
self.assertEqual(resp['status'], '204')
@attr(type='smoke')
def test_grant_list_revoke_role_to_user_on_domain(self):
- resp, _ = self.v3_client.assign_user_role_on_domain(
+ resp, _ = self.client.assign_user_role_on_domain(
self.domain['id'], self.user_body['id'], self.role['id'])
self.assertEqual(resp['status'], '204')
- resp, roles = self.v3_client.list_user_roles_on_domain(
+ resp, roles = self.client.list_user_roles_on_domain(
self.domain['id'], self.user_body['id'])
for i in roles:
@@ -124,17 +124,17 @@
self._list_assertions(resp, roles, self.fetched_role_ids,
self.role['id'])
- resp, _ = self.v3_client.revoke_role_from_user_on_domain(
+ resp, _ = self.client.revoke_role_from_user_on_domain(
self.domain['id'], self.user_body['id'], self.role['id'])
self.assertEqual(resp['status'], '204')
@attr(type='smoke')
def test_grant_list_revoke_role_to_group_on_project(self):
- resp, _ = self.v3_client.assign_group_role_on_project(
+ resp, _ = self.client.assign_group_role_on_project(
self.project['id'], self.group_body['id'], self.role['id'])
self.assertEqual(resp['status'], '204')
- resp, roles = self.v3_client.list_group_roles_on_project(
+ resp, roles = self.client.list_group_roles_on_project(
self.project['id'], self.group_body['id'])
for i in roles:
@@ -143,17 +143,17 @@
self._list_assertions(resp, roles, self.fetched_role_ids,
self.role['id'])
- resp, _ = self.v3_client.revoke_role_from_group_on_project(
+ resp, _ = self.client.revoke_role_from_group_on_project(
self.project['id'], self.group_body['id'], self.role['id'])
self.assertEqual(resp['status'], '204')
@attr(type='smoke')
def test_grant_list_revoke_role_to_group_on_domain(self):
- resp, _ = self.v3_client.assign_group_role_on_domain(
+ resp, _ = self.client.assign_group_role_on_domain(
self.domain['id'], self.group_body['id'], self.role['id'])
self.assertEqual(resp['status'], '204')
- resp, roles = self.v3_client.list_group_roles_on_domain(
+ resp, roles = self.client.list_group_roles_on_domain(
self.domain['id'], self.group_body['id'])
for i in roles:
@@ -162,7 +162,7 @@
self._list_assertions(resp, roles, self.fetched_role_ids,
self.role['id'])
- resp, _ = self.v3_client.revoke_role_from_group_on_domain(
+ resp, _ = self.client.revoke_role_from_group_on_domain(
self.domain['id'], self.group_body['id'], self.role['id'])
self.assertEqual(resp['status'], '204')
diff --git a/tempest/api/identity/admin/v3/test_services.py b/tempest/api/identity/admin/v3/test_services.py
index 4d6c22f..c5d4ddf 100644
--- a/tempest/api/identity/admin/v3/test_services.py
+++ b/tempest/api/identity/admin/v3/test_services.py
@@ -19,20 +19,20 @@
from tempest.test import attr
-class ServicesTestJSON(base.BaseIdentityAdminTest):
+class ServicesTestJSON(base.BaseIdentityV3AdminTest):
_interface = 'json'
@attr(type='gate')
def test_update_service(self):
# Update description attribute of service
name = data_utils.rand_name('service-')
- type = data_utils.rand_name('type--')
- description = data_utils.rand_name('description-')
- resp, body = self.client.create_service(
- name, type, description=description)
- self.assertEqual('200', resp['status'])
+ serv_type = data_utils.rand_name('type--')
+ desc = data_utils.rand_name('description-')
+ resp, body = self.service_client.create_service(name, serv_type,
+ description=desc)
+ self.assertEqual('201', resp['status'])
# Deleting the service created in this method
- self.addCleanup(self.client.delete_service, body['id'])
+ self.addCleanup(self.service_client.delete_service, body['id'])
s_id = body['id']
resp1_desc = body['description']
@@ -45,7 +45,7 @@
self.assertNotEqual(resp1_desc, resp2_desc)
# Get service
- resp, body = self.client.get_service(s_id)
+ resp, body = self.service_client.get_service(s_id)
resp3_desc = body['description']
self.assertNotEqual(resp1_desc, resp3_desc)
diff --git a/tempest/api/identity/admin/v3/test_tokens.py b/tempest/api/identity/admin/v3/test_tokens.py
index d17dc4a..9629213 100644
--- a/tempest/api/identity/admin/v3/test_tokens.py
+++ b/tempest/api/identity/admin/v3/test_tokens.py
@@ -19,7 +19,7 @@
from tempest.test import attr
-class UsersTestJSON(base.BaseIdentityAdminTest):
+class TokensV3TestJSON(base.BaseIdentityV3AdminTest):
_interface = 'json'
@attr(type='smoke')
@@ -30,26 +30,26 @@
u_desc = '%s-description' % u_name
u_email = '%s@testmail.tm' % u_name
u_password = data_utils.rand_name('pass-')
- resp, user = self.v3_client.create_user(
+ resp, user = self.client.create_user(
u_name, description=u_desc, password=u_password,
email=u_email)
self.assertTrue(resp['status'].startswith('2'))
- self.addCleanup(self.v3_client.delete_user, user['id'])
+ self.addCleanup(self.client.delete_user, user['id'])
# Perform Authentication
- resp, body = self.v3_token.auth(user['id'], u_password)
+ resp, body = self.token.auth(user['id'], u_password)
self.assertEqual(resp['status'], '201')
subject_token = resp['x-subject-token']
# Perform GET Token
- resp, token_details = self.v3_client.get_token(subject_token)
+ resp, token_details = self.client.get_token(subject_token)
self.assertEqual(resp['status'], '200')
self.assertEqual(resp['x-subject-token'], subject_token)
self.assertEqual(token_details['user']['id'], user['id'])
self.assertEqual(token_details['user']['name'], u_name)
# Perform Delete Token
- resp, _ = self.v3_client.delete_token(subject_token)
- self.assertRaises(exceptions.NotFound, self.v3_client.get_token,
+ resp, _ = self.client.delete_token(subject_token)
+ self.assertRaises(exceptions.NotFound, self.client.get_token,
subject_token)
-class UsersTestXML(UsersTestJSON):
+class TokensV3TestXML(TokensV3TestJSON):
_interface = 'xml'
diff --git a/tempest/api/identity/admin/v3/test_trusts.py b/tempest/api/identity/admin/v3/test_trusts.py
index 1bebad4..cae20ad 100644
--- a/tempest/api/identity/admin/v3/test_trusts.py
+++ b/tempest/api/identity/admin/v3/test_trusts.py
@@ -14,16 +14,16 @@
import re
from tempest.api.identity import base
from tempest import clients
-from tempest.common.utils.data_utils import rand_name
+from tempest.common.utils import data_utils
from tempest import config
from tempest import exceptions
from tempest.openstack.common import timeutils
-from tempest.test import attr
+from tempest import test
CONF = config.CONF
-class BaseTrustsV3Test(base.BaseIdentityAdminTest):
+class BaseTrustsV3Test(base.BaseIdentityV3AdminTest):
def setUp(self):
super(BaseTrustsV3Test, self).setUp()
@@ -43,17 +43,17 @@
def create_trustor_and_roles(self):
# Get trustor project ID, use the admin project
- self.trustor_project_name = self.v3_client.tenant_name
+ self.trustor_project_name = self.client.tenant_name
self.trustor_project_id = self.get_tenant_by_name(
self.trustor_project_name)['id']
self.assertIsNotNone(self.trustor_project_id)
# Create a trustor User
- self.trustor_username = rand_name('user-')
+ self.trustor_username = data_utils.rand_name('user-')
u_desc = self.trustor_username + 'description'
u_email = self.trustor_username + '@testmail.xx'
- self.trustor_password = rand_name('pass-')
- resp, user = self.v3_client.create_user(
+ self.trustor_password = data_utils.rand_name('pass-')
+ resp, user = self.client.create_user(
self.trustor_username,
description=u_desc,
password=self.trustor_password,
@@ -63,27 +63,27 @@
self.trustor_user_id = user['id']
# And two roles, one we'll delegate and one we won't
- self.delegated_role = rand_name('DelegatedRole-')
- self.not_delegated_role = rand_name('NotDelegatedRole-')
+ self.delegated_role = data_utils.rand_name('DelegatedRole-')
+ self.not_delegated_role = data_utils.rand_name('NotDelegatedRole-')
- resp, role = self.v3_client.create_role(self.delegated_role)
+ resp, role = self.client.create_role(self.delegated_role)
self.assertEqual(resp['status'], '201')
self.delegated_role_id = role['id']
- resp, role = self.v3_client.create_role(self.not_delegated_role)
+ resp, role = self.client.create_role(self.not_delegated_role)
self.assertEqual(resp['status'], '201')
self.not_delegated_role_id = role['id']
# Assign roles to trustor
- self.v3_client.assign_user_role(self.trustor_project_id,
- self.trustor_user_id,
- self.delegated_role_id)
- self.v3_client.assign_user_role(self.trustor_project_id,
- self.trustor_user_id,
- self.not_delegated_role_id)
+ self.client.assign_user_role(self.trustor_project_id,
+ self.trustor_user_id,
+ self.delegated_role_id)
+ self.client.assign_user_role(self.trustor_project_id,
+ self.trustor_user_id,
+ self.not_delegated_role_id)
# Get trustee user ID, use the demo user
- trustee_username = self.v3_non_admin_client.user
+ trustee_username = self.non_admin_client.user
self.trustee_user_id = self.get_user_by_name(trustee_username)['id']
self.assertIsNotNone(self.trustee_user_id)
@@ -92,19 +92,19 @@
password=self.trustor_password,
tenant_name=self.trustor_project_name,
interface=self._interface)
- self.trustor_v3_client = os.identity_v3_client
+ self.trustor_client = os.identity_v3_client
def cleanup_user_and_roles(self):
if self.trustor_user_id:
- self.v3_client.delete_user(self.trustor_user_id)
+ self.client.delete_user(self.trustor_user_id)
if self.delegated_role_id:
- self.v3_client.delete_role(self.delegated_role_id)
+ self.client.delete_role(self.delegated_role_id)
if self.not_delegated_role_id:
- self.v3_client.delete_role(self.not_delegated_role_id)
+ self.client.delete_role(self.not_delegated_role_id)
def create_trust(self, impersonate=True, expires=None):
- resp, trust_create = self.trustor_v3_client.create_trust(
+ resp, trust_create = self.trustor_client.create_trust(
trustor_user_id=self.trustor_user_id,
trustee_user_id=self.trustee_user_id,
project_id=self.trustor_project_id,
@@ -137,7 +137,7 @@
self.assertEqual(1, len(trust['roles']))
def get_trust(self):
- resp, trust_get = self.trustor_v3_client.get_trust(self.trust_id)
+ resp, trust_get = self.trustor_client.get_trust(self.trust_id)
self.assertEqual('200', resp['status'])
return trust_get
@@ -153,37 +153,37 @@
def check_trust_roles(self):
# Check we find the delegated role
- resp, roles_get = self.trustor_v3_client.get_trust_roles(
+ resp, roles_get = self.trustor_client.get_trust_roles(
self.trust_id)
self.assertEqual('200', resp['status'])
self.assertEqual(1, len(roles_get))
self.validate_role(roles_get[0])
- resp, role_get = self.trustor_v3_client.get_trust_role(
+ resp, role_get = self.trustor_client.get_trust_role(
self.trust_id, self.delegated_role_id)
self.assertEqual('200', resp['status'])
self.validate_role(role_get)
- resp, role_get = self.trustor_v3_client.check_trust_role(
+ resp, role_get = self.trustor_client.check_trust_role(
self.trust_id, self.delegated_role_id)
self.assertEqual('204', resp['status'])
# And that we don't find not_delegated_role
self.assertRaises(exceptions.NotFound,
- self.trustor_v3_client.get_trust_role,
+ self.trustor_client.get_trust_role,
self.trust_id,
self.not_delegated_role_id)
self.assertRaises(exceptions.NotFound,
- self.trustor_v3_client.check_trust_role,
+ self.trustor_client.check_trust_role,
self.trust_id,
self.not_delegated_role_id)
def delete_trust(self):
- resp, trust_delete = self.trustor_v3_client.delete_trust(self.trust_id)
+ resp, trust_delete = self.trustor_client.delete_trust(self.trust_id)
self.assertEqual('204', resp['status'])
self.assertRaises(exceptions.NotFound,
- self.trustor_v3_client.get_trust,
+ self.trustor_client.get_trust,
self.trust_id)
self.trust_id = None
@@ -196,7 +196,7 @@
self.create_trustor_and_roles()
self.addCleanup(self.cleanup_user_and_roles)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_trust_impersonate(self):
# Test case to check we can create, get and delete a trust
# updates are not supported for trusts
@@ -208,7 +208,7 @@
self.check_trust_roles()
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_trust_noimpersonate(self):
# Test case to check we can create, get and delete a trust
# with impersonation=False
@@ -220,7 +220,7 @@
self.check_trust_roles()
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_trust_expire(self):
# Test case to check we can create, get and delete a trust
# with an expiry specified
@@ -236,7 +236,7 @@
self.check_trust_roles()
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_trust_expire_invalid(self):
# Test case to check we can check an invlaid expiry time
# is rejected with the correct error
@@ -246,19 +246,19 @@
self.create_trust,
expires=expires_str)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_get_trusts_query(self):
self.create_trust()
- resp, trusts_get = self.trustor_v3_client.get_trusts(
+ resp, trusts_get = self.trustor_client.get_trusts(
trustor_user_id=self.trustor_user_id)
self.assertEqual('200', resp['status'])
self.assertEqual(1, len(trusts_get))
self.validate_trust(trusts_get[0], summary=True)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_get_trusts_all(self):
self.create_trust()
- resp, trusts_get = self.v3_client.get_trusts()
+ resp, trusts_get = self.client.get_trusts()
self.assertEqual('200', resp['status'])
trusts = [t for t in trusts_get
if t['id'] == self.trust_id]
diff --git a/tempest/api/identity/admin/v3/test_users.py b/tempest/api/identity/admin/v3/test_users.py
index 7cae856..e1d1543 100644
--- a/tempest/api/identity/admin/v3/test_users.py
+++ b/tempest/api/identity/admin/v3/test_users.py
@@ -18,7 +18,7 @@
from tempest.test import attr
-class UsersV3TestJSON(base.BaseIdentityAdminTest):
+class UsersV3TestJSON(base.BaseIdentityV3AdminTest):
_interface = 'json'
@attr(type='gate')
@@ -29,22 +29,22 @@
u_desc = u_name + 'description'
u_email = u_name + '@testmail.tm'
u_password = data_utils.rand_name('pass-')
- resp, user = self.v3_client.create_user(
+ resp, user = self.client.create_user(
u_name, description=u_desc, password=u_password,
email=u_email, enabled=False)
# Delete the User at the end of this method
- self.addCleanup(self.v3_client.delete_user, user['id'])
+ self.addCleanup(self.client.delete_user, user['id'])
# Creating second project for updation
- resp, project = self.v3_client.create_project(
+ resp, project = self.client.create_project(
data_utils.rand_name('project-'),
description=data_utils.rand_name('project-desc-'))
# Delete the Project at the end of this method
- self.addCleanup(self.v3_client.delete_project, project['id'])
+ self.addCleanup(self.client.delete_project, project['id'])
# Updating user details with new values
u_name2 = data_utils.rand_name('user2-')
u_email2 = u_name2 + '@testmail.tm'
u_description2 = u_name2 + ' description'
- resp, update_user = self.v3_client.update_user(
+ resp, update_user = self.client.update_user(
user['id'], name=u_name2, description=u_description2,
project_id=project['id'],
email=u_email2, enabled=False)
@@ -57,7 +57,7 @@
self.assertEqual(u_email2, update_user['email'])
self.assertEqual('false', str(update_user['enabled']).lower())
# GET by id after updation
- resp, new_user_get = self.v3_client.get_user(user['id'])
+ resp, new_user_get = self.client.get_user(user['id'])
# Assert response body of GET after updation
self.assertEqual(u_name2, new_user_get['name'])
self.assertEqual(u_description2, new_user_get['description'])
@@ -71,43 +71,43 @@
# List the projects that a user has access upon
assigned_project_ids = list()
fetched_project_ids = list()
- _, u_project = self.v3_client.create_project(
+ _, u_project = self.client.create_project(
data_utils.rand_name('project-'),
description=data_utils.rand_name('project-desc-'))
# Delete the Project at the end of this method
- self.addCleanup(self.v3_client.delete_project, u_project['id'])
+ self.addCleanup(self.client.delete_project, u_project['id'])
# Create a user.
u_name = data_utils.rand_name('user-')
u_desc = u_name + 'description'
u_email = u_name + '@testmail.tm'
u_password = data_utils.rand_name('pass-')
- _, user_body = self.v3_client.create_user(
+ _, user_body = self.client.create_user(
u_name, description=u_desc, password=u_password,
email=u_email, enabled=False, project_id=u_project['id'])
# Delete the User at the end of this method
- self.addCleanup(self.v3_client.delete_user, user_body['id'])
+ self.addCleanup(self.client.delete_user, user_body['id'])
# Creating Role
- _, role_body = self.v3_client.create_role(
+ _, role_body = self.client.create_role(
data_utils.rand_name('role-'))
# Delete the Role at the end of this method
- self.addCleanup(self.v3_client.delete_role, role_body['id'])
+ self.addCleanup(self.client.delete_role, role_body['id'])
- _, user = self.v3_client.get_user(user_body['id'])
- _, role = self.v3_client.get_role(role_body['id'])
+ _, user = self.client.get_user(user_body['id'])
+ _, role = self.client.get_role(role_body['id'])
for i in range(2):
# Creating project so as to assign role
- _, project_body = self.v3_client.create_project(
+ _, project_body = self.client.create_project(
data_utils.rand_name('project-'),
description=data_utils.rand_name('project-desc-'))
- _, project = self.v3_client.get_project(project_body['id'])
+ _, project = self.client.get_project(project_body['id'])
# Delete the Project at the end of this method
- self.addCleanup(self.v3_client.delete_project, project_body['id'])
+ self.addCleanup(self.client.delete_project, project_body['id'])
# Assigning roles to user on project
- self.v3_client.assign_user_role(project['id'],
- user['id'],
- role['id'])
+ self.client.assign_user_role(project['id'],
+ user['id'],
+ role['id'])
assigned_project_ids.append(project['id'])
- resp, body = self.v3_client.list_user_projects(user['id'])
+ resp, body = self.client.list_user_projects(user['id'])
self.assertEqual(200, resp.status)
for i in body:
fetched_project_ids.append(i['id'])
@@ -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 a3fc65a..a5bf248 100644
--- a/tempest/api/identity/base.py
+++ b/tempest/api/identity/base.py
@@ -16,67 +16,98 @@
from tempest import clients
from tempest.common.utils import data_utils
+from tempest import config
import tempest.test
+CONF = config.CONF
+
class BaseIdentityAdminTest(tempest.test.BaseTestCase):
@classmethod
def setUpClass(cls):
super(BaseIdentityAdminTest, cls).setUpClass()
- os = clients.AdminManager(interface=cls._interface)
- cls.client = os.identity_client
- cls.token_client = os.token_client
- cls.endpoints_client = os.endpoints_client
- cls.v3_client = os.identity_v3_client
- cls.service_client = os.service_client
- cls.policy_client = os.policy_client
- cls.v3_token = os.token_v3_client
- cls.creds_client = os.credentials_client
-
- if not cls.client.has_admin_extensions():
- raise cls.skipException("Admin extensions disabled")
-
- cls.data = DataGenerator(cls.client)
- cls.v3data = DataGenerator(cls.v3_client)
-
- os = clients.Manager(interface=cls._interface)
- cls.non_admin_client = os.identity_client
- cls.v3_non_admin_client = os.identity_v3_client
+ cls.os_adm = clients.AdminManager(interface=cls._interface)
+ cls.os = clients.Manager(interface=cls._interface)
@classmethod
- def tearDownClass(cls):
- cls.data.teardown_all()
- cls.v3data.teardown_all()
- super(BaseIdentityAdminTest, cls).tearDownClass()
+ def disable_user(cls, user_name):
+ user = cls.get_user_by_name(user_name)
+ cls.client.enable_disable_user(user['id'], False)
- def disable_user(self, user_name):
- user = self.get_user_by_name(user_name)
- self.client.enable_disable_user(user['id'], False)
+ @classmethod
+ def disable_tenant(cls, tenant_name):
+ tenant = cls.get_tenant_by_name(tenant_name)
+ cls.client.update_tenant(tenant['id'], enabled=False)
- def disable_tenant(self, tenant_name):
- tenant = self.get_tenant_by_name(tenant_name)
- self.client.update_tenant(tenant['id'], enabled=False)
-
- def get_user_by_name(self, name):
- _, users = self.client.get_users()
+ @classmethod
+ def get_user_by_name(cls, name):
+ _, users = cls.client.get_users()
user = [u for u in users if u['name'] == name]
if len(user) > 0:
return user[0]
- def get_tenant_by_name(self, name):
- _, tenants = self.client.list_tenants()
+ @classmethod
+ def get_tenant_by_name(cls, name):
+ try:
+ _, tenants = cls.client.list_tenants()
+ except AttributeError:
+ _, tenants = cls.client.list_projects()
tenant = [t for t in tenants if t['name'] == name]
if len(tenant) > 0:
return tenant[0]
- def get_role_by_name(self, name):
- _, roles = self.client.list_roles()
+ @classmethod
+ def get_role_by_name(cls, name):
+ _, roles = cls.client.list_roles()
role = [r for r in roles if r['name'] == name]
if len(role) > 0:
return role[0]
+class BaseIdentityV2AdminTest(BaseIdentityAdminTest):
+
+ @classmethod
+ def setUpClass(cls):
+ if not CONF.identity_feature_enabled.api_v2:
+ raise cls.skipException("Identity api v2 is not enabled")
+ super(BaseIdentityV2AdminTest, cls).setUpClass()
+ cls.client = cls.os_adm.identity_client
+ cls.token_client = cls.os_adm.token_client
+ if not cls.client.has_admin_extensions():
+ raise cls.skipException("Admin extensions disabled")
+ cls.data = DataGenerator(cls.client)
+ cls.non_admin_client = cls.os.identity_client
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.data.teardown_all()
+ super(BaseIdentityV2AdminTest, cls).tearDownClass()
+
+
+class BaseIdentityV3AdminTest(BaseIdentityAdminTest):
+
+ @classmethod
+ def setUpClass(cls):
+ if not CONF.identity_feature_enabled.api_v3:
+ raise cls.skipException("Identity api v3 is not enabled")
+ super(BaseIdentityV3AdminTest, cls).setUpClass()
+ cls.client = cls.os_adm.identity_v3_client
+ cls.token = cls.os_adm.token_v3_client
+ cls.endpoints_client = cls.os_adm.endpoints_client
+ cls.data = DataGenerator(cls.client)
+ cls.non_admin_client = cls.os.identity_v3_client
+ cls.service_client = cls.os_adm.service_client
+ cls.policy_client = cls.os_adm.policy_client
+ cls.creds_client = cls.os_adm.credentials_client
+ cls.non_admin_client = cls.os.identity_v3_client
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.data.teardown_all()
+ super(BaseIdentityV3AdminTest, cls).tearDownClass()
+
+
class DataGenerator(object):
def __init__(self, client):
@@ -122,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/base.py b/tempest/api/image/base.py
index 37b848c..e439238 100644
--- a/tempest/api/image/base.py
+++ b/tempest/api/image/base.py
@@ -106,7 +106,7 @@
cls.os_alt = clients.AltManager()
identity_client = cls._get_identity_admin_client()
cls.alt_tenant_id = identity_client.get_tenant_by_name(
- cls.os_alt.tenant_name)['id']
+ cls.os_alt.credentials['tenant_name'])['id']
cls.alt_img_cli = cls.os_alt.image_client
@@ -147,7 +147,7 @@
cls.alt_tenant_id = cls.isolated_creds.get_alt_tenant()['id']
else:
cls.os_alt = clients.AltManager()
- alt_tenant_name = cls.os_alt.tenant_name
+ alt_tenant_name = cls.os_alt.credentials['tenant_name']
identity_client = cls._get_identity_admin_client()
cls.alt_tenant_id = identity_client.get_tenant_by_name(
alt_tenant_name)['id']
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.py b/tempest/api/image/v1/test_images.py
index 8c62c05..517123d 100644
--- a/tempest/api/image/v1/test_images.py
+++ b/tempest/api/image/v1/test_images.py
@@ -16,8 +16,9 @@
import cStringIO as StringIO
from tempest.api.image 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
@@ -25,7 +26,7 @@
class CreateRegisterImagesTest(base.BaseV1ImageTest):
"""Here we test the registration and creation of images."""
- @attr(type='gate')
+ @test.attr(type='gate')
def test_register_then_upload(self):
# Register, then upload an image
properties = {'prop1': 'val1'}
@@ -48,7 +49,7 @@
self.assertIn('size', body)
self.assertEqual(1024, body.get('size'))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_register_remote_image(self):
# Register a new remote image
resp, body = self.create_image(name='New Remote Image',
@@ -66,12 +67,12 @@
self.assertEqual(properties['key1'], 'value1')
self.assertEqual(properties['key2'], 'value2')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_register_http_image(self):
resp, body = self.create_image(name='New Http Image',
container_format='bare',
disk_format='raw', is_public=True,
- copy_from=CONF.images.http_image)
+ copy_from=CONF.image.http_image)
self.assertIn('id', body)
image_id = body.get('id')
self.assertEqual('New Http Image', body.get('name'))
@@ -80,7 +81,7 @@
resp, body = self.client.get_image(image_id)
self.assertEqual(resp['status'], '200')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_register_image_with_min_ram(self):
# Register an image with min ram
properties = {'prop1': 'val1'}
@@ -110,7 +111,6 @@
@classmethod
def setUpClass(cls):
super(ListImagesTest, cls).setUpClass()
-
# We add a few images here to test the listing functionality of
# the images API
img1 = cls._create_remote_image('one', 'bare', 'raw')
@@ -131,7 +131,7 @@
# 1x with size 42
cls.size42_set = set((img5,))
# 3x with size 142
- cls.size142_set = set((img6, img7, img8))
+ cls.size142_set = set((img6, img7, img8,))
# dup named
cls.dup_set = set((img3, img4))
@@ -168,7 +168,7 @@
image_id = image['id']
return image_id
- @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()
@@ -177,7 +177,7 @@
for image_id in self.created_images:
self.assertIn(image_id, image_list)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_index_disk_format(self):
resp, images_list = self.client.image_list(disk_format='ami')
self.assertEqual(resp['status'], '200')
@@ -187,7 +187,7 @@
self.assertTrue(self.ami_set <= result_set)
self.assertFalse(self.created_set - self.ami_set <= result_set)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_index_container_format(self):
resp, images_list = self.client.image_list(container_format='bare')
self.assertEqual(resp['status'], '200')
@@ -197,7 +197,7 @@
self.assertTrue(self.bare_set <= result_set)
self.assertFalse(self.created_set - self.bare_set <= result_set)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_index_max_size(self):
resp, images_list = self.client.image_list(size_max=42)
self.assertEqual(resp['status'], '200')
@@ -207,7 +207,7 @@
self.assertTrue(self.size42_set <= result_set)
self.assertFalse(self.created_set - self.size42_set <= result_set)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_index_min_size(self):
resp, images_list = self.client.image_list(size_min=142)
self.assertEqual(resp['status'], '200')
@@ -217,7 +217,7 @@
self.assertTrue(self.size142_set <= result_set)
self.assertFalse(self.size42_set <= result_set)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_index_status_active_detail(self):
resp, images_list = self.client.image_list_detail(status='active',
sort_key='size',
@@ -230,7 +230,7 @@
top_size = size
self.assertEqual(image['status'], 'active')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_index_name(self):
resp, images_list = self.client.image_list_detail(
name='New Remote Image dup')
@@ -240,3 +240,139 @@
self.assertEqual(image['name'], 'New Remote Image dup')
self.assertTrue(self.dup_set <= result_set)
self.assertFalse(self.created_set - self.dup_set <= result_set)
+
+
+class ListSnapshotImagesTest(base.BaseV1ImageTest):
+ @classmethod
+ def setUpClass(cls):
+ super(ListSnapshotImagesTest, cls).setUpClass()
+ if not CONF.compute_feature_enabled.api_v3:
+ cls.servers_client = cls.os.servers_client
+ else:
+ cls.servers_client = cls.os.servers_v3_client
+ cls.servers = []
+ # We add a few images here to test the listing functionality of
+ # the images API
+ cls.snapshot = cls._create_snapshot(
+ 'snapshot', CONF.compute.image_ref,
+ CONF.compute.flavor_ref)
+ cls.snapshot_set = set((cls.snapshot,))
+
+ image_file = StringIO.StringIO('*' * 42)
+ resp, image = cls.create_image(name="Standard Image",
+ container_format='ami',
+ disk_format='ami',
+ is_public=True, data=image_file)
+ cls.image_id = image['id']
+ cls.client.wait_for_image_status(image['id'], 'active')
+
+ @classmethod
+ def tearDownClass(cls):
+ for server in cls.servers:
+ cls.servers_client.delete_server(server['id'])
+ super(ListSnapshotImagesTest, cls).tearDownClass()
+
+ @classmethod
+ def _create_snapshot(cls, name, image_id, flavor, **kwargs):
+ resp, server = cls.servers_client.create_server(
+ name, image_id, flavor, **kwargs)
+ cls.servers.append(server)
+ cls.servers_client.wait_for_server_status(
+ server['id'], 'ACTIVE')
+ resp, image = cls.servers_client.create_image(
+ server['id'], name)
+ image_id = data_utils.parse_image_id(resp['location'])
+ cls.created_images.append(image_id)
+ cls.client.wait_for_image_status(image_id,
+ 'active')
+ return image_id
+
+ @test.attr(type='gate')
+ def test_index_server_id(self):
+ # The images should contain images filtered by server id
+ resp, images = self.client.image_list_detail(
+ {'instance_uuid': self.servers[0]['id']})
+ self.assertEqual(200, resp.status)
+ result_set = set(map(lambda x: x['id'], images))
+ self.assertEqual(self.snapshot_set, result_set)
+
+ @test.attr(type='gate')
+ def test_index_type(self):
+ # The list of servers should be filtered by image type
+ params = {'image_type': 'snapshot'}
+ resp, images = self.client.image_list_detail(params)
+
+ self.assertEqual(200, resp.status)
+ result_set = set(map(lambda x: x['id'], images))
+ self.assertIn(self.snapshot, result_set)
+
+ @test.attr(type='gate')
+ def test_index_limit(self):
+ # Verify only the expected number of results are returned
+ resp, images = self.client.image_list_detail(limit=1)
+
+ self.assertEqual(200, resp.status)
+ self.assertEqual(1, len(images))
+
+ @test.attr(type='gate')
+ def test_index_by_change_since(self):
+ # Verify an update image is returned
+ # Becoming ACTIVE will modify the updated time
+ # Filter by the image's created time
+ resp, image = self.client.get_image_meta(self.snapshot)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(self.snapshot, image['id'])
+ resp, images = self.client.image_list_detail(
+ changes_since=image['updated_at'])
+
+ self.assertEqual(200, resp.status)
+ result_set = set(map(lambda x: x['id'], images))
+ self.assertIn(self.image_id, result_set)
+ self.assertNotIn(self.snapshot, result_set)
+
+
+class UpdateImageMetaTest(base.BaseV1ImageTest):
+ @classmethod
+ def setUpClass(cls):
+ super(UpdateImageMetaTest, cls).setUpClass()
+ cls.image_id = cls._create_standard_image('1', 'ami', 'ami', 42)
+
+ @classmethod
+ def _create_standard_image(cls, name, container_format,
+ disk_format, size):
+ """
+ Create a new standard image and return the ID of the newly-registered
+ image. Note that the size of the new image is a random number between
+ 1024 and 4096
+ """
+ image_file = StringIO.StringIO('*' * size)
+ name = 'New Standard Image %s' % name
+ resp, image = cls.create_image(name=name,
+ container_format=container_format,
+ disk_format=disk_format,
+ is_public=True, data=image_file,
+ properties={'key1': 'value1'})
+ image_id = image['id']
+ return image_id
+
+ @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.get_image_meta(self.image_id)
+ expected = {'key1': 'value1'}
+ self.assertEqual(expected, resp_metadata['properties'])
+
+ @test.attr(type='gate')
+ def test_update_image_metadata(self):
+ # The metadata for the image should match the updated values
+ req_metadata = {'key1': 'alt1', 'key2': 'value2'}
+ resp, metadata = self.client.get_image_meta(self.image_id)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(metadata['properties'], {'key1': 'value1'})
+ metadata['properties'].update(req_metadata)
+ resp, metadata = self.client.update_image(
+ self.image_id, properties=metadata['properties'])
+
+ resp, resp_metadata = self.client.get_image_meta(self.image_id)
+ expected = {'key1': 'alt1', 'key2': 'value2'}
+ self.assertEqual(expected, resp_metadata['properties'])
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 2a5401f..abde8f7 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,9 +68,9 @@
self.assertEqual(200, resp.status)
self.assertEqual(file_content, body)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_delete_image(self):
- # Deletes a image by image_id
+ # Deletes an image by image_id
# Create image
image_name = data_utils.rand_name('image')
@@ -90,6 +90,44 @@
self.assertEqual(resp.status, 200)
self.assertNotIn(image_id, images)
+ @test.attr(type='gate')
+ def test_update_image(self):
+ # Updates an image by image_id
+
+ # Create image
+ image_name = data_utils.rand_name('image')
+ resp, body = self.client.create_image(name=image_name,
+ container_format='bare',
+ disk_format='iso',
+ visibility='public')
+ self.assertEqual(201, resp.status)
+ self.addCleanup(self.client.delete_image, body['id'])
+ self.assertEqual('queued', body['status'])
+ image_id = body['id']
+
+ # Now try uploading an image file
+ file_content = '*' * 1024
+ image_file = StringIO.StringIO(file_content)
+ resp, body = self.client.store_image(image_id, image_file)
+ self.assertEqual(204, resp.status)
+
+ # Update Image
+ new_image_name = data_utils.rand_name('new-image')
+ new_visibility = 'private'
+ resp, body = self.client.update_image(image_id, [
+ dict(replace='/name', value=new_image_name),
+ dict(replace='/visibility', value=new_visibility)])
+
+ self.assertEqual(200, resp.status)
+
+ # Verifying updating
+
+ resp, body = self.client.get_image(image_id)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(image_id, body['id'])
+ self.assertEqual(new_image_name, body['name'])
+ self.assertEqual(new_visibility, body['visibility'])
+
class ListImagesTest(base.BaseV2ImageTest):
"""
@@ -139,7 +177,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()
@@ -149,25 +187,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]
@@ -178,7 +216,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]
@@ -197,13 +235,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}
@@ -212,3 +250,19 @@
self.assertEqual(len(images_list), params['limit'],
"Failed to get images by limit")
+
+ @test.attr(type='gate')
+ def test_get_image_schema(self):
+ # Test to get image schema
+ schema = "image"
+ resp, body = self.client.get_schema(schema)
+ self.assertEqual(200, resp.status)
+ self.assertEqual("image", body['name'])
+
+ @test.attr(type='gate')
+ def test_get_images_schema(self):
+ # Test to get images schema
+ schema = "images"
+ resp, body = self.client.get_schema(schema)
+ self.assertEqual(200, resp.status)
+ self.assertEqual("images", body['name'])
diff --git a/tempest/api/image/v2/test_images_member.py b/tempest/api/image/v2/test_images_member.py
index 41fc49d..f80c818 100644
--- a/tempest/api/image/v2/test_images_member.py
+++ b/tempest/api/image/v2/test_images_member.py
@@ -11,17 +11,18 @@
# 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,
self.alt_tenant_id)
+ self.assertEqual(200, resp.status)
self.assertEqual(member['member_id'], self.alt_tenant_id)
self.assertEqual(member['image_id'], image_id)
self.assertEqual(member['status'], 'pending')
@@ -30,7 +31,8 @@
self.alt_tenant_id,
'accepted')
self.assertIn(image_id, self._list_image_ids_as_alt())
- _, body = self.os_img_client.get_image_membership(image_id)
+ resp, body = self.os_img_client.get_image_membership(image_id)
+ self.assertEqual(200, resp.status)
members = body['members']
member = members[0]
self.assertEqual(len(members), 1, str(members))
@@ -38,16 +40,61 @@
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,
self.alt_tenant_id)
+ self.assertEqual(200, resp.status)
self.assertEqual(member['member_id'], self.alt_tenant_id)
self.assertEqual(member['image_id'], image_id)
self.assertEqual(member['status'], 'pending')
self.assertNotIn(image_id, self._list_image_ids_as_alt())
+ resp, _ = self.alt_img_client.update_member_status(image_id,
+ self.alt_tenant_id,
+ 'rejected')
+ self.assertEqual(200, resp.status)
+ self.assertNotIn(image_id, self._list_image_ids_as_alt())
+
+ @test.attr(type='gate')
+ def test_get_image_member(self):
+ image_id = self._create_image()
+ self.os_img_client.add_member(image_id,
+ self.alt_tenant_id)
self.alt_img_client.update_member_status(image_id,
self.alt_tenant_id,
- 'rejected')
+ 'accepted')
+
+ self.assertIn(image_id, self._list_image_ids_as_alt())
+ resp, member = self.os_img_client.get_member(image_id,
+ self.alt_tenant_id)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(self.alt_tenant_id, member['member_id'])
+ self.assertEqual(image_id, member['image_id'])
+ self.assertEqual('accepted', member['status'])
+
+ @test.attr(type='gate')
+ def test_remove_image_member(self):
+ image_id = self._create_image()
+ self.os_img_client.add_member(image_id,
+ self.alt_tenant_id)
+ self.alt_img_client.update_member_status(image_id,
+ self.alt_tenant_id,
+ 'accepted')
+
+ self.assertIn(image_id, self._list_image_ids_as_alt())
+ 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_agent_management.py b/tempest/api/network/admin/test_agent_management.py
index b05f275..342bc6a 100644
--- a/tempest/api/network/admin/test_agent_management.py
+++ b/tempest/api/network/admin/test_agent_management.py
@@ -14,7 +14,7 @@
from tempest.api.network import base
from tempest.common import tempest_fixtures as fixtures
-from tempest.test import attr
+from tempest import test
class AgentManagementTestJSON(base.BaseAdminNetworkTest):
@@ -23,11 +23,14 @@
@classmethod
def setUpClass(cls):
super(AgentManagementTestJSON, cls).setUpClass()
+ if not test.is_extension_enabled('agent', 'network'):
+ msg = "agent extension not enabled."
+ raise cls.skipException(msg)
resp, body = cls.admin_client.list_agents()
agents = body['agents']
cls.agent = agents[0]
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_agent(self):
resp, body = self.admin_client.list_agents()
self.assertEqual('200', resp['status'])
@@ -38,20 +41,20 @@
agent.pop('heartbeat_timestamp', None)
self.assertIn(self.agent, agents)
- @attr(type=['smoke'])
+ @test.attr(type=['smoke'])
def test_list_agents_non_admin(self):
resp, body = self.client.list_agents()
self.assertEqual('200', resp['status'])
self.assertEqual(len(body["agents"]), 0)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_show_agent(self):
resp, body = self.admin_client.show_agent(self.agent['id'])
agent = body['agent']
self.assertEqual('200', resp['status'])
self.assertEqual(agent['id'], self.agent['id'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_update_agent_status(self):
origin_status = self.agent['admin_state_up']
# Try to update the 'admin_state_up' to the original
@@ -63,7 +66,7 @@
self.assertEqual('200', resp['status'])
self.assertEqual(origin_status, updated_status)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_update_agent_description(self):
self.useFixture(fixtures.LockFixture('agent_description'))
description = 'description for update agent.'
diff --git a/tempest/api/network/admin/test_dhcp_agent_scheduler.py b/tempest/api/network/admin/test_dhcp_agent_scheduler.py
index 13309cd..0e601d1 100644
--- a/tempest/api/network/admin/test_dhcp_agent_scheduler.py
+++ b/tempest/api/network/admin/test_dhcp_agent_scheduler.py
@@ -13,7 +13,7 @@
# under the License.
from tempest.api.network import base
-from tempest.test import attr
+from tempest import test
class DHCPAgentSchedulersTestJSON(base.BaseAdminNetworkTest):
@@ -22,20 +22,23 @@
@classmethod
def setUpClass(cls):
super(DHCPAgentSchedulersTestJSON, cls).setUpClass()
+ if not test.is_extension_enabled('dhcp_agent_scheduler', 'network'):
+ msg = "dhcp_agent_scheduler extension not enabled."
+ raise cls.skipException(msg)
# Create a network and make sure it will be hosted by a
- # dhcp agent.
+ # dhcp agent: this is done by creating a regular port
cls.network = cls.create_network()
cls.subnet = cls.create_subnet(cls.network)
cls.cidr = cls.subnet['cidr']
cls.port = cls.create_port(cls.network)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_dhcp_agent_hosting_network(self):
resp, body = self.admin_client.list_dhcp_agent_hosting_network(
self.network['id'])
self.assertEqual(resp['status'], '200')
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_networks_hosted_by_one_dhcp(self):
resp, body = self.admin_client.list_dhcp_agent_hosting_network(
self.network['id'])
@@ -55,8 +58,11 @@
network_ids.append(network['id'])
return network_id in network_ids
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_remove_network_from_dhcp_agent(self):
+ # The agent is now bound to the network, we can free the port
+ self.client.delete_port(self.port['id'])
+ self.ports.remove(self.port)
resp, body = self.admin_client.list_dhcp_agent_hosting_network(
self.network['id'])
agents = body['agents']
diff --git a/tempest/api/network/admin/test_l3_agent_scheduler.py b/tempest/api/network/admin/test_l3_agent_scheduler.py
index bfb7b48..f4050c5 100644
--- a/tempest/api/network/admin/test_l3_agent_scheduler.py
+++ b/tempest/api/network/admin/test_l3_agent_scheduler.py
@@ -17,7 +17,7 @@
from tempest import test
-class L3AgentSchedulerJSON(base.BaseAdminNetworkTest):
+class L3AgentSchedulerTestJSON(base.BaseAdminNetworkTest):
_interface = 'json'
"""
@@ -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:
@@ -33,33 +34,51 @@
@classmethod
def setUpClass(cls):
- super(L3AgentSchedulerJSON, cls).setUpClass()
+ super(L3AgentSchedulerTestJSON, cls).setUpClass()
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'])
+ # NOTE(afazekas): The deletion not asserted, because neutron
+ # is not forbidden to reschedule the router to the same agent
-class L3AgentSchedulerXML(L3AgentSchedulerJSON):
+class L3AgentSchedulerTestXML(L3AgentSchedulerTestJSON):
_interface = 'xml'
diff --git a/tempest/api/network/admin/test_lbaas_agent_scheduler.py b/tempest/api/network/admin/test_lbaas_agent_scheduler.py
new file mode 100644
index 0000000..a5ba90f
--- /dev/null
+++ b/tempest/api/network/admin/test_lbaas_agent_scheduler.py
@@ -0,0 +1,78 @@
+# Copyright 2013 IBM Corp.
+#
+# 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.network import base
+from tempest.common.utils import data_utils
+from tempest import test
+
+
+class LBaaSAgentSchedulerTestJSON(base.BaseAdminNetworkTest):
+ _interface = 'json'
+
+ """
+ Tests the following operations in the Neutron API using the REST client for
+ Neutron:
+
+ List pools the given LBaaS agent is hosting.
+ Show a LBaaS agent hosting the given pool.
+
+ v2.0 of the Neutron API is assumed. It is also assumed that the following
+ options are defined in the [networki-feature-enabled] section of
+ etc/tempest.conf:
+
+ api_extensions
+ """
+
+ @classmethod
+ def setUpClass(cls):
+ super(LBaaSAgentSchedulerTestJSON, cls).setUpClass()
+ if not test.is_extension_enabled('lbaas_agent_scheduler', 'network'):
+ msg = "LBaaS Agent Scheduler Extension not enabled."
+ raise cls.skipException(msg)
+ cls.network = cls.create_network()
+ cls.subnet = cls.create_subnet(cls.network)
+ pool_name = data_utils.rand_name('pool-')
+ cls.pool = cls.create_pool(pool_name, "ROUND_ROBIN",
+ "HTTP", cls.subnet)
+
+ @test.attr(type='smoke')
+ def test_list_pools_on_lbaas_agent(self):
+ found = False
+ resp, body = self.admin_client.list_agents(
+ agent_type="Loadbalancer agent")
+ self.assertEqual('200', resp['status'])
+ agents = body['agents']
+ for a in agents:
+ msg = 'Load Balancer agent expected'
+ self.assertEqual(a['agent_type'], 'Loadbalancer agent', msg)
+ resp, body = (
+ self.admin_client.list_pools_hosted_by_one_lbaas_agent(
+ a['id']))
+ self.assertEqual('200', resp['status'])
+ pools = body['pools']
+ if self.pool['id'] in [p['id'] for p in pools]:
+ found = True
+ msg = 'Unable to find Load Balancer agent hosting pool'
+ self.assertTrue(found, msg)
+
+ @test.attr(type='smoke')
+ def test_show_lbaas_agent_hosting_pool(self):
+ resp, body = self.admin_client.show_lbaas_agent_hosting_pool(
+ self.pool['id'])
+ self.assertEqual('200', resp['status'])
+ self.assertEqual('Loadbalancer agent', body['agent']['agent_type'])
+
+
+class LBaaSAgentSchedulerTestXML(LBaaSAgentSchedulerTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/network/admin/test_load_balancer_admin_actions.py b/tempest/api/network/admin/test_load_balancer_admin_actions.py
new file mode 100644
index 0000000..34a8e32
--- /dev/null
+++ b/tempest/api/network/admin/test_load_balancer_admin_actions.py
@@ -0,0 +1,94 @@
+# Copyright 2014 Mirantis.inc
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.api.network import base
+from tempest.common.utils import data_utils
+from tempest import test
+
+
+class LoadBalancerAdminTestJSON(base.BaseAdminNetworkTest):
+ _interface = 'json'
+
+ """
+ Test admin actions for load balancer.
+
+ Create VIP for another tenant
+ Create health monitor for another tenant
+ """
+
+ @classmethod
+ def setUpClass(cls):
+ super(LoadBalancerAdminTestJSON, cls).setUpClass()
+ if not test.is_extension_enabled('lbaas', 'network'):
+ msg = "lbaas extension not enabled."
+ raise cls.skipException(msg)
+ cls.force_tenant_isolation = True
+ manager = cls.get_client_manager()
+ cls.client = manager.network_client
+ username, tenant_name, passwd = cls.isolated_creds.get_primary_creds()
+ cls.tenant_id = cls.os_adm.identity_client.get_tenant_by_name(
+ tenant_name)['id']
+ cls.network = cls.create_network()
+ cls.subnet = cls.create_subnet(cls.network)
+
+ @test.attr(type='smoke')
+ def test_create_vip_as_admin_for_another_tenant(self):
+ name = data_utils.rand_name('vip-')
+ resp, body = self.admin_client.create_pool(
+ name=data_utils.rand_name('pool-'), lb_method="ROUND_ROBIN",
+ protocol="HTTP", subnet_id=self.subnet['id'],
+ tenant_id=self.tenant_id)
+ self.assertEqual('201', resp['status'])
+ pool = body['pool']
+ self.addCleanup(self.admin_client.delete_pool, pool['id'])
+ resp, body = self.admin_client.create_vip(name=name,
+ protocol="HTTP",
+ protocol_port=80,
+ subnet_id=self.subnet['id'],
+ pool_id=pool['id'],
+ tenant_id=self.tenant_id)
+ self.assertEqual('201', resp['status'])
+ vip = body['vip']
+ self.addCleanup(self.admin_client.delete_vip, vip['id'])
+ self.assertIsNotNone(vip['id'])
+ self.assertEqual(self.tenant_id, vip['tenant_id'])
+ resp, body = self.client.show_vip(vip['id'])
+ self.assertEqual('200', resp['status'])
+ show_vip = body['vip']
+ self.assertEqual(vip['id'], show_vip['id'])
+ self.assertEqual(vip['name'], show_vip['name'])
+
+ @test.attr(type='smoke')
+ def test_create_health_monitor_as_admin_for_another_tenant(self):
+ resp, body = (
+ self.admin_client.create_health_monitor(delay=4,
+ max_retries=3,
+ type="TCP",
+ timeout=1,
+ tenant_id=self.tenant_id))
+ self.assertEqual('201', resp['status'])
+ health_monitor = body['health_monitor']
+ self.addCleanup(self.admin_client.delete_health_monitor,
+ health_monitor['id'])
+ self.assertIsNotNone(health_monitor['id'])
+ self.assertEqual(self.tenant_id, health_monitor['tenant_id'])
+ resp, body = self.client.show_health_monitor(health_monitor['id'])
+ self.assertEqual('200', resp['status'])
+ show_health_monitor = body['health_monitor']
+ self.assertEqual(health_monitor['id'], show_health_monitor['id'])
+
+
+class LoadBalancerAdminTestXML(LoadBalancerAdminTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/network/base.py b/tempest/api/network/base.py
index b129786..231c4bf 100644
--- a/tempest/api/network/base.py
+++ b/tempest/api/network/base.py
@@ -51,12 +51,14 @@
force_tenant_isolation = False
+ # Default to ipv4.
+ _ip_version = 4
+
@classmethod
def setUpClass(cls):
# 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")
@@ -75,6 +77,8 @@
cls.vpnservices = []
cls.ikepolicies = []
cls.floating_ips = []
+ cls.metering_labels = []
+ cls.metering_label_rules = []
@classmethod
def tearDownClass(cls):
@@ -107,6 +111,13 @@
# Clean up pools
for pool in cls.pools:
cls.client.delete_pool(pool['id'])
+ # Clean up metering label rules
+ for metering_label_rule in cls.metering_label_rules:
+ cls.admin_client.delete_metering_label_rule(
+ metering_label_rule['id'])
+ # Clean up metering labels
+ for metering_label in cls.metering_labels:
+ cls.admin_client.delete_metering_label(metering_label['id'])
# Clean up ports
for port in cls.ports:
cls.client.delete_port(port['id'])
@@ -130,30 +141,30 @@
return network
@classmethod
- def create_subnet(cls, network, ip_version=4):
+ def create_subnet(cls, network):
"""Wrapper utility that returns a test subnet."""
- cidr = netaddr.IPNetwork(CONF.network.tenant_network_cidr)
- mask_bits = CONF.network.tenant_network_mask_bits
+ # The cidr and mask_bits depend on the ip version.
+ if cls._ip_version == 4:
+ cidr = netaddr.IPNetwork(CONF.network.tenant_network_cidr)
+ mask_bits = CONF.network.tenant_network_mask_bits
+ elif cls._ip_version == 6:
+ cidr = netaddr.IPNetwork(CONF.network.tenant_network_v6_cidr)
+ mask_bits = CONF.network.tenant_network_v6_mask_bits
# Find a cidr that is not in use yet and create a subnet with it
- body = None
- failure = None
for subnet_cidr in cidr.subnet(mask_bits):
try:
resp, body = cls.client.create_subnet(
network_id=network['id'],
cidr=str(subnet_cidr),
- ip_version=ip_version)
+ ip_version=cls._ip_version)
break
except exceptions.BadRequest as e:
is_overlapping_cidr = 'overlaps with another subnet' in str(e)
if not is_overlapping_cidr:
raise
- # save the failure in case all of the CIDRs are overlapping
- failure = e
-
- if not body and failure:
- raise failure
-
+ else:
+ message = 'Available CIDR for subnet creation could not be found'
+ raise exceptions.BuildErrorException(message)
subnet = body['subnet']
cls.subnets.append(subnet)
return subnet
@@ -213,33 +224,55 @@
@classmethod
def create_vip(cls, name, protocol, protocol_port, subnet, pool):
"""Wrapper utility that returns a test vip."""
- resp, body = cls.client.create_vip(name, protocol, protocol_port,
- subnet['id'], pool['id'])
+ resp, body = cls.client.create_vip(name=name,
+ protocol=protocol,
+ protocol_port=protocol_port,
+ subnet_id=subnet['id'],
+ pool_id=pool['id'])
vip = body['vip']
cls.vips.append(vip)
return vip
@classmethod
+ def update_vip(cls, name):
+ resp, body = cls.client.update_vip(name=name)
+ vip = body['vip']
+ return vip
+
+ @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,
- max_retries,
- Type, timeout)
+ resp, body = cls.client.create_health_monitor(delay=delay,
+ max_retries=max_retries,
+ type=Type,
+ timeout=timeout)
health_monitor = body['health_monitor']
cls.health_monitors.append(health_monitor)
return health_monitor
@classmethod
+ def update_health_monitor(cls, admin_state_up):
+ resp, body = cls.client.update_vip(admin_state_up=admin_state_up)
+ health_monitor = body['health_monitor']
+ return health_monitor
+
+ @classmethod
def create_router_interface(cls, router_id, subnet_id):
"""Wrapper utility that returns a router interface."""
resp, interface = cls.client.add_router_interface_with_subnet_id(
@@ -287,3 +320,24 @@
else:
cls.os_adm = clients.ComputeAdminManager(interface=cls._interface)
cls.admin_client = cls.os_adm.network_client
+
+ @classmethod
+ def create_metering_label(cls, name, description):
+ """Wrapper utility that returns a test metering label."""
+ resp, body = cls.admin_client.create_metering_label(
+ description=description,
+ name=data_utils.rand_name("metering-label"))
+ metering_label = body['metering_label']
+ cls.metering_labels.append(metering_label)
+ return metering_label
+
+ @classmethod
+ def create_metering_label_rule(cls, remote_ip_prefix, direction,
+ metering_label_id):
+ """Wrapper utility that returns a test metering label rule."""
+ resp, body = cls.admin_client.create_metering_label_rule(
+ remote_ip_prefix=remote_ip_prefix, direction=direction,
+ metering_label_id=metering_label_id)
+ metering_label_rule = body['metering_label_rule']
+ cls.metering_label_rules.append(metering_label_rule)
+ return metering_label_rule
diff --git a/tempest/api/network/base_routers.py b/tempest/api/network/base_routers.py
index 304b2ca..b278002 100644
--- a/tempest/api/network/base_routers.py
+++ b/tempest/api/network/base_routers.py
@@ -38,11 +38,13 @@
self.assertNotIn(router_id, routers_list)
def _remove_router_interface_with_subnet_id(self, router_id, subnet_id):
- resp, _ = self.client.remove_router_interface_with_subnet_id(
+ resp, body = self.client.remove_router_interface_with_subnet_id(
router_id, subnet_id)
self.assertEqual('200', resp['status'])
+ self.assertEqual(subnet_id, body['subnet_id'])
def _remove_router_interface_with_port_id(self, router_id, port_id):
- resp, _ = self.client.remove_router_interface_with_port_id(
+ resp, body = self.client.remove_router_interface_with_port_id(
router_id, port_id)
self.assertEqual('200', resp['status'])
+ self.assertEqual(port_id, body['port_id'])
diff --git a/tempest/api/network/base_security_groups.py b/tempest/api/network/base_security_groups.py
index 38ae4ac..90be454 100644
--- a/tempest/api/network/base_security_groups.py
+++ b/tempest/api/network/base_security_groups.py
@@ -26,7 +26,7 @@
def _create_security_group(self):
# Create a security group
name = data_utils.rand_name('secgroup-')
- resp, group_create_body = self.client.create_security_group(name)
+ resp, group_create_body = self.client.create_security_group(name=name)
self.assertEqual('201', resp['status'])
self.addCleanup(self._delete_security_group,
group_create_body['security_group']['id'])
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_extensions.py b/tempest/api/network/test_extensions.py
index a177d65..529f8e9 100644
--- a/tempest/api/network/test_extensions.py
+++ b/tempest/api/network/test_extensions.py
@@ -44,6 +44,8 @@
'agent', 'dhcp_agent_scheduler', 'provider',
'router', 'extraroute', 'external-net',
'allowed-address-pairs', 'extra_dhcp_opt']
+ expected_alias = [ext for ext in expected_alias if
+ test.is_extension_enabled(ext, 'network')]
actual_alias = list()
resp, extensions = self.client.list_extensions()
self.assertEqual('200', resp['status'])
diff --git a/tempest/api/network/test_extra_dhcp_options.py b/tempest/api/network/test_extra_dhcp_options.py
new file mode 100644
index 0000000..ed86d75
--- /dev/null
+++ b/tempest/api/network/test_extra_dhcp_options.py
@@ -0,0 +1,99 @@
+# Copyright 2013 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.
+
+from tempest.api.network import base
+from tempest.common.utils import data_utils
+from tempest import test
+
+
+class ExtraDHCPOptionsTestJSON(base.BaseNetworkTest):
+ _interface = 'json'
+
+ """
+ Tests the following operations with the Extra DHCP Options Neutron API
+ extension:
+
+ port create
+ port list
+ port show
+ port update
+
+ v2.0 of the Neutron API is assumed. It is also assumed that the Extra
+ DHCP Options extension is enabled in the [network-feature-enabled]
+ section of etc/tempest.conf
+ """
+
+ @classmethod
+ def setUpClass(cls):
+ super(ExtraDHCPOptionsTestJSON, cls).setUpClass()
+ if not test.is_extension_enabled('extra_dhcp_opt', 'network'):
+ msg = "Extra DHCP Options extension not enabled."
+ raise cls.skipException(msg)
+ cls.network = cls.create_network()
+ cls.subnet = cls.create_subnet(cls.network)
+ cls.port = cls.create_port(cls.network)
+
+ @test.attr(type='smoke')
+ def test_create_list_port_with_extra_dhcp_options(self):
+ # Create a port with Extra DHCP Options
+ extra_dhcp_opts = [
+ {'opt_value': 'pxelinux.0', 'opt_name': 'bootfile-name'},
+ {'opt_value': '123.123.123.123', 'opt_name': 'tftp-server'},
+ {'opt_value': '123.123.123.45', 'opt_name': 'server-ip-address'}
+ ]
+ resp, body = self.client.create_port(
+ network_id=self.network['id'],
+ extra_dhcp_opts=extra_dhcp_opts)
+ self.assertEqual('201', resp['status'])
+ port_id = body['port']['id']
+ self.addCleanup(self.client.delete_port, port_id)
+
+ # Confirm port created has Extra DHCP Options
+ resp, body = self.client.list_ports()
+ self.assertEqual('200', resp['status'])
+ ports = body['ports']
+ port = [p for p in ports if p['id'] == port_id]
+ self.assertTrue(port)
+ self._confirm_extra_dhcp_options(port[0], extra_dhcp_opts)
+
+ @test.attr(type='smoke')
+ def test_update_show_port_with_extra_dhcp_options(self):
+ # Update port with extra dhcp options
+ extra_dhcp_opts = [
+ {'opt_value': 'pxelinux.0', 'opt_name': 'bootfile-name'},
+ {'opt_value': '123.123.123.123', 'opt_name': 'tftp-server'},
+ {'opt_value': '123.123.123.45', 'opt_name': 'server-ip-address'}
+ ]
+ name = data_utils.rand_name('new-port-name')
+ resp, body = self.client.update_port(
+ self.port['id'], name=name, extra_dhcp_opts=extra_dhcp_opts)
+ self.assertEqual('200', resp['status'])
+
+ # Confirm extra dhcp options were added to the port
+ resp, body = self.client.show_port(self.port['id'])
+ self.assertEqual('200', resp['status'])
+ self._confirm_extra_dhcp_options(body['port'], extra_dhcp_opts)
+
+ def _confirm_extra_dhcp_options(self, port, extra_dhcp_opts):
+ retrieved = port['extra_dhcp_opts']
+ self.assertEqual(len(retrieved), len(extra_dhcp_opts))
+ for retrieved_option in retrieved:
+ for option in extra_dhcp_opts:
+ if (retrieved_option['opt_value'] == option['opt_value'] and
+ retrieved_option['opt_name'] == option['opt_name']):
+ break
+ else:
+ self.fail('Extra DHCP option not found in port %s' %
+ str(retrieved_option))
diff --git a/tempest/api/network/test_floating_ips.py b/tempest/api/network/test_floating_ips.py
index 69367ab..b31c090 100644
--- a/tempest/api/network/test_floating_ips.py
+++ b/tempest/api/network/test_floating_ips.py
@@ -16,7 +16,7 @@
from tempest.api.network 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
@@ -46,6 +46,9 @@
@classmethod
def setUpClass(cls):
super(FloatingIPTestJSON, cls).setUpClass()
+ if not test.is_extension_enabled('router', 'network'):
+ msg = "router extension not enabled."
+ raise cls.skipException(msg)
cls.ext_net_id = CONF.network.public_network_id
# Create network, subnet, router and add interface
@@ -59,7 +62,7 @@
for i in range(2):
cls.create_port(cls.network)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_create_list_show_update_delete_floating_ip(self):
# Creates a floating IP
created_floating_ip = self.create_floating_ip(
@@ -110,7 +113,7 @@
self.assertIsNone(updated_floating_ip['fixed_ip_address'])
self.assertIsNone(updated_floating_ip['router_id'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_floating_ip_delete_port(self):
# Create a floating IP
created_floating_ip = self.create_floating_ip(self.ext_net_id)
@@ -133,7 +136,7 @@
self.assertIsNone(shown_floating_ip['fixed_ip_address'])
self.assertIsNone(shown_floating_ip['router_id'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_floating_ip_update_different_router(self):
# Associate a floating IP to a port on a router
created_floating_ip = self.create_floating_ip(
diff --git a/tempest/api/network/test_load_balancer.py b/tempest/api/network/test_load_balancer.py
index 65eebf2..792d61d 100644
--- a/tempest/api/network/test_load_balancer.py
+++ b/tempest/api/network/test_load_balancer.py
@@ -18,7 +18,7 @@
from tempest import test
-class LoadBalancerJSON(base.BaseNetworkTest):
+class LoadBalancerTestJSON(base.BaseNetworkTest):
_interface = 'json'
"""
@@ -39,7 +39,7 @@
@classmethod
def setUpClass(cls):
- super(LoadBalancerJSON, cls).setUpClass()
+ super(LoadBalancerTestJSON, cls).setUpClass()
if not test.is_extension_enabled('lbaas', 'network'):
msg = "lbaas extension not enabled."
raise cls.skipException(msg)
@@ -50,9 +50,34 @@
vip_name = data_utils.rand_name('vip-')
cls.pool = cls.create_pool(pool_name, "ROUND_ROBIN",
"HTTP", cls.subnet)
- cls.vip = cls.create_vip(vip_name, "HTTP", 80, cls.subnet, cls.pool)
+ cls.vip = cls.create_vip(name=vip_name,
+ protocol="HTTP",
+ protocol_port=80,
+ subnet=cls.subnet,
+ pool=cls.pool)
cls.member = cls.create_member(80, cls.pool)
- cls.health_monitor = cls.create_health_monitor(4, 3, "TCP", 1)
+ cls.health_monitor = cls.create_health_monitor(delay=4,
+ max_retries=3,
+ 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):
@@ -60,36 +85,74 @@
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-')
+ address = self.subnet['allocation_pools'][0]['end']
resp, body = self.client.create_pool(
name=data_utils.rand_name("pool-"),
lb_method='ROUND_ROBIN',
protocol='HTTP',
subnet_id=self.subnet['id'])
pool = body['pool']
- resp, body = self.client.create_vip(name, "HTTP", 80,
- self.subnet['id'], pool['id'])
+ resp, body = self.client.create_vip(name=name,
+ protocol="HTTP",
+ protocol_port=80,
+ subnet_id=self.subnet['id'],
+ pool_id=pool['id'],
+ address=address)
self.assertEqual('201', resp['status'])
vip = body['vip']
vip_id = vip['id']
+ # Confirm VIP's address correctness with a show
+ resp, body = self.client.show_vip(vip_id)
+ self.assertEqual('200', resp['status'])
+ vip = body['vip']
+ self.assertEqual(address, vip['address'])
# Verification of vip update
new_name = "New_vip"
- resp, body = self.client.update_vip(vip_id, new_name)
+ new_description = "New description"
+ persistence_type = "HTTP_COOKIE"
+ update_data = {"session_persistence": {
+ "type": persistence_type}}
+ resp, body = self.client.update_vip(vip_id,
+ name=new_name,
+ description=new_description,
+ connection_limit=10,
+ admin_state_up=False,
+ **update_data)
self.assertEqual('200', resp['status'])
updated_vip = body['vip']
- self.assertEqual(updated_vip['name'], new_name)
+ self.assertEqual(new_name, updated_vip['name'])
+ self.assertEqual(new_description, updated_vip['description'])
+ self.assertEqual(10, updated_vip['connection_limit'])
+ self.assertFalse(updated_vip['admin_state_up'])
+ self.assertEqual(persistence_type,
+ updated_vip['session_persistence']['type'])
# Verification of vip delete
resp, body = self.client.delete_vip(vip['id'])
self.assertEqual('204', resp['status'])
+ self.client.wait_for_resource_deletion('vip', vip['id'])
# Verification of pool update
new_name = "New_pool"
resp, body = self.client.update_pool(pool['id'],
@@ -107,17 +170,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):
@@ -128,6 +204,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()
@@ -136,18 +223,26 @@
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
- admin_state = [False, 'False']
- resp, body = self.client.update_member(admin_state[0], member['id'])
+ resp, body = self.client.update_member(member['id'],
+ admin_state_up=False)
self.assertEqual('200', resp['status'])
updated_member = body['member']
- self.assertIn(updated_member['admin_state_up'], admin_state)
+ self.assertFalse(updated_member['admin_state_up'])
# Verification of member delete
resp, body = self.client.delete_member(member['id'])
self.assertEqual('204', resp['status'])
@@ -158,9 +253,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):
@@ -172,31 +268,76 @@
[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(4, 3, "TCP", 1)
+ resp, body = self.client.create_health_monitor(delay=4,
+ max_retries=3,
+ type="TCP",
+ timeout=1)
self.assertEqual('201', resp['status'])
health_monitor = body['health_monitor']
# Verification of health_monitor update
- admin_state = [False, 'False']
- resp, body = self.client.update_health_monitor(admin_state[0],
- health_monitor['id'])
+ resp, body = (self.client.update_health_monitor
+ (health_monitor['id'],
+ admin_state_up=False))
self.assertEqual('200', resp['status'])
updated_health_monitor = body['health_monitor']
- self.assertIn(updated_health_monitor['admin_state_up'], admin_state)
+ self.assertFalse(updated_health_monitor['admin_state_up'])
# Verification of health_monitor delete
resp, body = self.client.delete_health_monitor(health_monitor['id'])
self.assertEqual('204', resp['status'])
@test.attr(type='smoke')
+ def test_create_health_monitor_http_type(self):
+ hm_type = "HTTP"
+ resp, body = self.client.create_health_monitor(delay=4,
+ max_retries=3,
+ type=hm_type,
+ timeout=1)
+ self.assertEqual('201', resp['status'])
+ health_monitor = body['health_monitor']
+ self.addCleanup(self.client.delete_health_monitor,
+ health_monitor['id'])
+ self.assertEqual(hm_type, health_monitor['type'])
+
+ @test.attr(type='smoke')
+ def test_update_health_monitor_http_method(self):
+ resp, body = self.client.create_health_monitor(delay=4,
+ max_retries=3,
+ type="HTTP",
+ timeout=1)
+ self.assertEqual('201', resp['status'])
+ health_monitor = body['health_monitor']
+ self.addCleanup(self.client.delete_health_monitor,
+ health_monitor['id'])
+ resp, body = (self.client.update_health_monitor
+ (health_monitor['id'],
+ http_method="POST",
+ url_path="/home/user",
+ expected_codes="290"))
+ self.assertEqual('200', resp['status'])
+ updated_health_monitor = body['health_monitor']
+ self.assertEqual("POST", updated_health_monitor['http_method'])
+ self.assertEqual("/home/user", updated_health_monitor['url_path'])
+ self.assertEqual("290", updated_health_monitor['expected_codes'])
+
+ @test.attr(type='smoke')
def test_show_health_monitor(self):
# Verifies the details of a health_monitor
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):
@@ -204,11 +345,38 @@
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):
+ # Verify the details of pool stats
+ resp, body = self.client.list_lb_pool_stats(self.pool['id'])
+ self.assertEqual('200', resp['status'])
+ stats = body['stats']
+ self.assertIn("bytes_in", stats)
+ self.assertIn("total_connections", stats)
+ self.assertIn("active_connections", stats)
+ self.assertIn("bytes_out", stats)
-class LoadBalancerXML(LoadBalancerJSON):
+class LoadBalancerTestXML(LoadBalancerTestJSON):
_interface = 'xml'
diff --git a/tempest/api/network/test_metering_extensions.py b/tempest/api/network/test_metering_extensions.py
new file mode 100644
index 0000000..08ccbfe
--- /dev/null
+++ b/tempest/api/network/test_metering_extensions.py
@@ -0,0 +1,159 @@
+# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
+#
+# Author: Emilien Macchi <emilien.macchi@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.network import base
+from tempest.common.utils import data_utils
+from tempest.openstack.common import log as logging
+from tempest import test
+
+
+LOG = logging.getLogger(__name__)
+
+
+class MeteringJSON(base.BaseAdminNetworkTest):
+ _interface = 'json'
+
+ """
+ Tests the following operations in the Neutron API using the REST client for
+ Neutron:
+
+ List, Show, Create, Delete Metering labels
+ List, Show, Create, Delete Metering labels rules
+ """
+
+ @classmethod
+ def setUpClass(cls):
+ super(MeteringJSON, cls).setUpClass()
+ if not test.is_extension_enabled('metering', 'network'):
+ msg = "metering extension not enabled."
+ raise cls.skipException(msg)
+ description = "metering label created by tempest"
+ name = data_utils.rand_name("metering-label")
+ try:
+ cls.metering_label = cls.create_metering_label(name, description)
+ remote_ip_prefix = "10.0.0.0/24"
+ direction = "ingress"
+ cls.metering_label_rule = cls.create_metering_label_rule(
+ remote_ip_prefix, direction,
+ metering_label_id=cls.metering_label['id'])
+ except Exception:
+ LOG.exception('setUpClass failed')
+ cls.tearDownClass()
+ raise
+
+ def _delete_metering_label(self, metering_label_id):
+ # Deletes a label and verifies if it is deleted or not
+ resp, body = self.admin_client.delete_metering_label(metering_label_id)
+ self.assertEqual(204, resp.status)
+ # Asserting that the label is not found in list after deletion
+ resp, labels = (self.admin_client.list_metering_labels(
+ id=metering_label_id))
+ self.assertEqual(len(labels['metering_labels']), 0)
+
+ def _delete_metering_label_rule(self, metering_label_rule_id):
+ # Deletes a rule and verifies if it is deleted or not
+ resp, body = (self.admin_client.delete_metering_label_rule(
+ metering_label_rule_id))
+ self.assertEqual(204, resp.status)
+ # Asserting that the rule is not found in list after deletion
+ resp, rules = (self.admin_client.list_metering_label_rules(
+ id=metering_label_rule_id))
+ self.assertEqual(len(rules['metering_label_rules']), 0)
+
+ @test.attr(type='smoke')
+ def test_list_metering_labels(self):
+ # Verify label filtering
+ resp, body = self.admin_client.list_metering_labels(id=33)
+ self.assertEqual('200', resp['status'])
+ metering_labels = body['metering_labels']
+ self.assertEqual(0, len(metering_labels))
+
+ @test.attr(type='smoke')
+ def test_create_delete_metering_label_with_filters(self):
+ # Creates a label
+ name = data_utils.rand_name('metering-label-')
+ description = "label created by tempest"
+ resp, body = (self.admin_client.create_metering_label(name=name,
+ description=description))
+ self.assertEqual('201', resp['status'])
+ metering_label = body['metering_label']
+ self.addCleanup(self._delete_metering_label,
+ metering_label['id'])
+ # Assert whether created labels are found in labels list or fail
+ # if created labels are not found in labels list
+ resp, labels = (self.admin_client.list_metering_labels(
+ id=metering_label['id']))
+ self.assertEqual(len(labels['metering_labels']), 1)
+
+ @test.attr(type='smoke')
+ def test_show_metering_label(self):
+ # Verifies the details of a label
+ resp, body = (self.admin_client.show_metering_label(
+ self.metering_label['id']))
+ self.assertEqual('200', resp['status'])
+ metering_label = body['metering_label']
+ self.assertEqual(self.metering_label['id'], metering_label['id'])
+ self.assertEqual(self.metering_label['tenant_id'],
+ metering_label['tenant_id'])
+ self.assertEqual(self.metering_label['name'], metering_label['name'])
+ self.assertEqual(self.metering_label['description'],
+ metering_label['description'])
+
+ @test.attr(type='smoke')
+ def test_list_metering_label_rules(self):
+ # Verify rule filtering
+ resp, body = self.admin_client.list_metering_label_rules(id=33)
+ self.assertEqual('200', resp['status'])
+ metering_label_rules = body['metering_label_rules']
+ self.assertEqual(0, len(metering_label_rules))
+
+ @test.attr(type='smoke')
+ def test_create_delete_metering_label_rule_with_filters(self):
+ # Creates a rule
+ resp, body = (self.admin_client.create_metering_label_rule(
+ remote_ip_prefix="10.0.1.0/24",
+ direction="ingress",
+ metering_label_id=self.metering_label['id']))
+ self.assertEqual('201', resp['status'])
+ metering_label_rule = body['metering_label_rule']
+ self.addCleanup(self._delete_metering_label_rule,
+ metering_label_rule['id'])
+ # Assert whether created rules are found in rules list or fail
+ # if created rules are not found in rules list
+ resp, rules = (self.admin_client.list_metering_label_rules(
+ id=metering_label_rule['id']))
+ self.assertEqual(len(rules['metering_label_rules']), 1)
+
+ @test.attr(type='smoke')
+ def test_show_metering_label_rule(self):
+ # Verifies the details of a rule
+ resp, body = (self.admin_client.show_metering_label_rule(
+ self.metering_label_rule['id']))
+ self.assertEqual('200', resp['status'])
+ metering_label_rule = body['metering_label_rule']
+ self.assertEqual(self.metering_label_rule['id'],
+ metering_label_rule['id'])
+ self.assertEqual(self.metering_label_rule['remote_ip_prefix'],
+ metering_label_rule['remote_ip_prefix'])
+ self.assertEqual(self.metering_label_rule['direction'],
+ metering_label_rule['direction'])
+ self.assertEqual(self.metering_label_rule['metering_label_id'],
+ metering_label_rule['metering_label_id'])
+ self.assertFalse(metering_label_rule['excluded'])
+
+
+class MeteringXML(MeteringJSON):
+ interface = 'xml'
diff --git a/tempest/api/network/test_networks.py b/tempest/api/network/test_networks.py
index 3aa765c..70fb00a 100644
--- a/tempest/api/network/test_networks.py
+++ b/tempest/api/network/test_networks.py
@@ -18,7 +18,6 @@
from tempest.api.network import base
from tempest.common.utils import data_utils
from tempest import config
-from tempest import exceptions
from tempest.test import attr
CONF = config.CONF
@@ -45,14 +44,20 @@
network update
subnet update
+ All subnet tests are run once with ipv4 and once with ipv6.
+
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:
tenant_network_cidr with a block of cidr's from which smaller blocks
- can be allocated for tenant networks
+ can be allocated for tenant ipv4 subnets
+
+ tenant_network_v6_cidr is the equivalent for ipv6 subnets
tenant_network_mask_bits with the mask bits to be used to partition the
- block defined by tenant-network_cidr
+ block defined by tenant_network_cidr
+
+ tenant_network_v6_mask_bits is the equivalent for ipv6 subnets
"""
@classmethod
@@ -62,184 +67,128 @@
cls.name = cls.network['name']
cls.subnet = cls.create_subnet(cls.network)
cls.cidr = cls.subnet['cidr']
- cls.port = cls.create_port(cls.network)
@attr(type='smoke')
def test_create_update_delete_network_subnet(self):
- # Creates a network
+ # Create a network
name = data_utils.rand_name('network-')
resp, body = self.client.create_network(name=name)
self.assertEqual('201', resp['status'])
network = body['network']
net_id = network['id']
- # Verification of network update
+ # Verify network update
new_name = "New_network"
resp, body = self.client.update_network(net_id, name=new_name)
self.assertEqual('200', resp['status'])
updated_net = body['network']
self.assertEqual(updated_net['name'], new_name)
# Find a cidr that is not in use yet and create a subnet with it
- cidr = netaddr.IPNetwork(CONF.network.tenant_network_cidr)
- mask_bits = CONF.network.tenant_network_mask_bits
- for subnet_cidr in cidr.subnet(mask_bits):
- try:
- resp, body = self.client.create_subnet(
- network_id=net_id,
- cidr=str(subnet_cidr),
- ip_version=4)
- break
- except exceptions.BadRequest as e:
- is_overlapping_cidr = 'overlaps with another subnet' in str(e)
- if not is_overlapping_cidr:
- raise
- self.assertEqual('201', resp['status'])
- subnet = body['subnet']
+ subnet = self.create_subnet(network)
subnet_id = subnet['id']
- # Verification of subnet update
- new_subnet = "New_subnet"
- resp, body = self.client.update_subnet(subnet_id,
- name=new_subnet)
+ # Verify subnet update
+ new_name = "New_subnet"
+ resp, body = self.client.update_subnet(subnet_id, name=new_name)
self.assertEqual('200', resp['status'])
updated_subnet = body['subnet']
- self.assertEqual(updated_subnet['name'], new_subnet)
+ self.assertEqual(updated_subnet['name'], new_name)
# Delete subnet and network
resp, body = self.client.delete_subnet(subnet_id)
self.assertEqual('204', resp['status'])
+ # Remove subnet from cleanup list
+ self.subnets.pop()
resp, body = self.client.delete_network(net_id)
self.assertEqual('204', resp['status'])
@attr(type='smoke')
def test_show_network(self):
- # Verifies the details of a network
+ # Verify the details of a network
resp, body = self.client.show_network(self.network['id'])
self.assertEqual('200', resp['status'])
network = body['network']
- self.assertEqual(self.network['id'], network['id'])
- self.assertEqual(self.name, network['name'])
+ for key in ['id', 'name']:
+ self.assertEqual(network[key], self.network[key])
+
+ @attr(type='smoke')
+ def test_show_network_fields(self):
+ # Verify specific fields of a network
+ field_list = [('fields', 'id'), ('fields', 'name'), ]
+ resp, body = self.client.show_network(self.network['id'],
+ field_list=field_list)
+ self.assertEqual('200', resp['status'])
+ network = body['network']
+ self.assertEqual(len(network), len(field_list))
+ for label, field_name in field_list:
+ self.assertEqual(network[field_name], self.network[field_name])
@attr(type='smoke')
def test_list_networks(self):
# Verify the network exists in the list of all networks
resp, body = self.client.list_networks()
self.assertEqual('200', resp['status'])
- networks = body['networks']
- found = None
- for n in networks:
- if (n['id'] == self.network['id']):
- found = n['id']
- msg = "Network list doesn't contain created network"
- self.assertIsNotNone(found, msg)
+ networks = [network['id'] for network in body['networks']
+ if network['id'] == self.network['id']]
+ self.assertNotEmpty(networks, "Created network not found in the list")
@attr(type='smoke')
def test_list_networks_fields(self):
- # Verify listing some fields of the networks
+ # Verify specific fields of the networks
resp, body = self.client.list_networks(fields='id')
self.assertEqual('200', resp['status'])
networks = body['networks']
- found = None
- for n in networks:
- self.assertEqual(len(n), 1)
- self.assertIn('id', n)
- if (n['id'] == self.network['id']):
- found = n['id']
- self.assertIsNotNone(found,
- "Created network id not found in the list")
+ self.assertNotEmpty(networks, "Network list returned is empty")
+ for network in networks:
+ self.assertEqual(len(network), 1)
+ self.assertIn('id', network)
@attr(type='smoke')
def test_show_subnet(self):
- # Verifies the details of a subnet
+ # Verify the details of a subnet
resp, body = self.client.show_subnet(self.subnet['id'])
self.assertEqual('200', resp['status'])
subnet = body['subnet']
- self.assertEqual(self.subnet['id'], subnet['id'])
- self.assertEqual(self.cidr, subnet['cidr'])
+ self.assertNotEmpty(subnet, "Subnet returned has no fields")
+ for key in ['id', 'cidr']:
+ self.assertIn(key, subnet)
+ self.assertEqual(subnet[key], self.subnet[key])
+
+ @attr(type='smoke')
+ def test_show_subnet_fields(self):
+ # Verify specific fields of a subnet
+ field_list = [('fields', 'id'), ('fields', 'cidr'), ]
+ resp, body = self.client.show_subnet(self.subnet['id'],
+ field_list=field_list)
+ self.assertEqual('200', resp['status'])
+ subnet = body['subnet']
+ self.assertEqual(len(subnet), len(field_list))
+ for label, field_name in field_list:
+ self.assertEqual(subnet[field_name], self.subnet[field_name])
@attr(type='smoke')
def test_list_subnets(self):
# Verify the subnet exists in the list of all subnets
resp, body = self.client.list_subnets()
self.assertEqual('200', resp['status'])
- subnets = body['subnets']
- found = None
- for n in subnets:
- if (n['id'] == self.subnet['id']):
- found = n['id']
- msg = "Subnet list doesn't contain created subnet"
- self.assertIsNotNone(found, msg)
+ subnets = [subnet['id'] for subnet in body['subnets']
+ if subnet['id'] == self.subnet['id']]
+ self.assertNotEmpty(subnets, "Created subnet not found in the list")
@attr(type='smoke')
def test_list_subnets_fields(self):
- # Verify listing some fields of the subnets
+ # Verify specific fields of subnets
resp, body = self.client.list_subnets(fields='id')
self.assertEqual('200', resp['status'])
subnets = body['subnets']
- found = None
- for n in subnets:
- self.assertEqual(len(n), 1)
- self.assertIn('id', n)
- if (n['id'] == self.subnet['id']):
- found = n['id']
- self.assertIsNotNone(found,
- "Created subnet id not found in the list")
-
- @attr(type='smoke')
- def test_create_update_delete_port(self):
- # Verify that successful port creation, update & deletion
- resp, body = self.client.create_port(
- network_id=self.network['id'])
- self.assertEqual('201', resp['status'])
- port = body['port']
- # Verification of port update
- new_port = "New_Port"
- resp, body = self.client.update_port(port['id'], name=new_port)
- self.assertEqual('200', resp['status'])
- updated_port = body['port']
- self.assertEqual(updated_port['name'], new_port)
- # Verification of port delete
- resp, body = self.client.delete_port(port['id'])
- self.assertEqual('204', resp['status'])
-
- @attr(type='smoke')
- def test_show_port(self):
- # Verify the details of port
- resp, body = self.client.show_port(self.port['id'])
- self.assertEqual('200', resp['status'])
- port = body['port']
- self.assertEqual(self.port['id'], port['id'])
-
- @attr(type='smoke')
- def test_list_ports(self):
- # Verify the port exists in the list of all ports
- resp, body = self.client.list_ports()
- self.assertEqual('200', resp['status'])
- ports_list = body['ports']
- found = None
- for n in ports_list:
- if (n['id'] == self.port['id']):
- found = n['id']
- self.assertIsNotNone(found, "Port list doesn't contain created port")
-
- @attr(type='smoke')
- def test_list_ports_fields(self):
- # Verify listing some fields of the ports
- resp, body = self.client.list_ports(fields='id')
- self.assertEqual('200', resp['status'])
- ports_list = body['ports']
- found = None
- for n in ports_list:
- self.assertEqual(len(n), 1)
- self.assertIn('id', n)
- if (n['id'] == self.port['id']):
- found = n['id']
- self.assertIsNotNone(found,
- "Created port id not found in the list")
+ self.assertNotEmpty(subnets, "Subnet list returned is empty")
+ for subnet in subnets:
+ self.assertEqual(len(subnet), 1)
+ self.assertIn('id', subnet)
class NetworksTestXML(NetworksTestJSON):
_interface = 'xml'
-class BulkNetworkOpsJSON(base.BaseNetworkTest):
+class BulkNetworkOpsTestJSON(base.BaseNetworkTest):
_interface = 'json'
"""
@@ -263,7 +212,7 @@
@classmethod
def setUpClass(cls):
- super(BulkNetworkOpsJSON, cls).setUpClass()
+ super(BulkNetworkOpsTestJSON, cls).setUpClass()
cls.network1 = cls.create_network()
cls.network2 = cls.create_network()
@@ -273,9 +222,7 @@
self.assertEqual(204, resp.status)
# Asserting that the networks are not found in the list after deletion
resp, body = self.client.list_networks()
- networks_list = list()
- for network in body['networks']:
- networks_list.append(network['id'])
+ networks_list = [network['id'] for network in body['networks']]
for n in created_networks:
self.assertNotIn(n['id'], networks_list)
@@ -285,9 +232,7 @@
self.assertEqual(204, resp.status)
# Asserting that the subnets are not found in the list after deletion
resp, body = self.client.list_subnets()
- subnets_list = list()
- for subnet in body['subnets']:
- subnets_list.append(subnet['id'])
+ subnets_list = [subnet['id'] for subnet in body['subnets']]
for n in created_subnets:
self.assertNotIn(n['id'], subnets_list)
@@ -297,9 +242,7 @@
self.assertEqual(204, resp.status)
# Asserting that the ports are not found in the list after deletion
resp, body = self.client.list_ports()
- ports_list = list()
- for port in body['ports']:
- ports_list.append(port['id'])
+ ports_list = [port['id'] for port in body['ports']]
for n in created_ports:
self.assertNotIn(n['id'], ports_list)
@@ -314,9 +257,7 @@
self.addCleanup(self._delete_networks, created_networks)
# Asserting that the networks are found in the list after creation
resp, body = self.client.list_networks()
- networks_list = list()
- for network in body['networks']:
- networks_list.append(network['id'])
+ networks_list = [network['id'] for network in body['networks']]
for n in created_networks:
self.assertIsNotNone(n['id'])
self.assertIn(n['id'], networks_list)
@@ -326,14 +267,10 @@
# Creates 2 subnets in one request
cidr = netaddr.IPNetwork(CONF.network.tenant_network_cidr)
mask_bits = CONF.network.tenant_network_mask_bits
- cidrs = []
- for subnet_cidr in cidr.subnet(mask_bits):
- cidrs.append(subnet_cidr)
- names = []
+ cidrs = [subnet_cidr for subnet_cidr in cidr.subnet(mask_bits)]
networks = [self.network1['id'], self.network2['id']]
- for i in range(len(networks)):
- names.append(data_utils.rand_name('subnet-'))
- subnet_list = []
+ names = [data_utils.rand_name('subnet-') for i in range(len(networks))]
+ subnets_list = []
# TODO(raies): "for IPv6, version list [4, 6] will be used.
# and cidr for IPv6 will be of IPv6"
ip_version = [4, 4]
@@ -344,17 +281,15 @@
'name': names[i],
'ip_version': ip_version[i]
}
- subnet_list.append(p1)
- del subnet_list[1]['name']
- resp, body = self.client.create_bulk_subnet(subnet_list)
+ subnets_list.append(p1)
+ del subnets_list[1]['name']
+ resp, body = self.client.create_bulk_subnet(subnets_list)
created_subnets = body['subnets']
self.addCleanup(self._delete_subnets, created_subnets)
self.assertEqual('201', resp['status'])
# Asserting that the subnets are found in the list after creation
resp, body = self.client.list_subnets()
- subnets_list = list()
- for subnet in body['subnets']:
- subnets_list.append(subnet['id'])
+ subnets_list = [subnet['id'] for subnet in body['subnets']]
for n in created_subnets:
self.assertIsNotNone(n['id'])
self.assertIn(n['id'], subnets_list)
@@ -362,10 +297,8 @@
@attr(type='smoke')
def test_bulk_create_delete_port(self):
# Creates 2 ports in one request
- names = []
networks = [self.network1['id'], self.network2['id']]
- for i in range(len(networks)):
- names.append(data_utils.rand_name('port-'))
+ names = [data_utils.rand_name('port-') for i in range(len(networks))]
port_list = []
state = [True, False]
for i in range(len(names)):
@@ -382,13 +315,27 @@
self.assertEqual('201', resp['status'])
# Asserting that the ports are found in the list after creation
resp, body = self.client.list_ports()
- ports_list = list()
- for port in body['ports']:
- ports_list.append(port['id'])
+ ports_list = [port['id'] for port in body['ports']]
for n in created_ports:
self.assertIsNotNone(n['id'])
self.assertIn(n['id'], ports_list)
-class BulkNetworkOpsXML(BulkNetworkOpsJSON):
+class BulkNetworkOpsTestXML(BulkNetworkOpsTestJSON):
+ _interface = 'xml'
+
+
+class NetworksIpV6TestJSON(NetworksTestJSON):
+ _ip_version = 6
+
+ @classmethod
+ def setUpClass(cls):
+ super(NetworksIpV6TestJSON, cls).setUpClass()
+ if not CONF.network_feature_enabled.ipv6:
+ cls.tearDownClass()
+ skip_msg = "IPv6 Tests are disabled."
+ raise cls.skipException(skip_msg)
+
+
+class NetworksIpV6TestXML(NetworksIpV6TestJSON):
_interface = 'xml'
diff --git a/tempest/api/network/test_ports.py b/tempest/api/network/test_ports.py
new file mode 100644
index 0000000..fbb25a8
--- /dev/null
+++ b/tempest/api/network/test_ports.py
@@ -0,0 +1,249 @@
+# Copyright 2014 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 socket
+
+from tempest.api.network import base
+from tempest.common.utils import data_utils
+from tempest import config
+from tempest import test
+
+CONF = config.CONF
+
+
+class PortsTestJSON(base.BaseNetworkTest):
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(PortsTestJSON, cls).setUpClass()
+ cls.network = cls.create_network()
+ cls.port = cls.create_port(cls.network)
+
+ def _delete_port(self, port_id):
+ resp, body = self.client.delete_port(port_id)
+ self.assertEqual('204', resp['status'])
+ resp, body = self.client.list_ports()
+ self.assertEqual('200', resp['status'])
+ ports_list = body['ports']
+ self.assertFalse(port_id in [n['id'] for n in ports_list])
+
+ @test.attr(type='smoke')
+ def test_create_update_delete_port(self):
+ # Verify port creation
+ resp, body = self.client.create_port(network_id=self.network['id'])
+ self.assertEqual('201', resp['status'])
+ port = body['port']
+ self.assertTrue(port['admin_state_up'])
+ # Verify port update
+ new_name = "New_Port"
+ resp, body = self.client.update_port(
+ port['id'],
+ name=new_name,
+ admin_state_up=False)
+ self.assertEqual('200', resp['status'])
+ updated_port = body['port']
+ self.assertEqual(updated_port['name'], new_name)
+ self.assertFalse(updated_port['admin_state_up'])
+ # Verify port deletion
+ resp, body = self.client.delete_port(port['id'])
+ self.assertEqual('204', resp['status'])
+
+ @test.attr(type='smoke')
+ def test_show_port(self):
+ # Verify the details of port
+ resp, body = self.client.show_port(self.port['id'])
+ self.assertEqual('200', resp['status'])
+ port = body['port']
+ self.assertIn('id', port)
+ self.assertEqual(port['id'], self.port['id'])
+ self.assertEqual(self.port['admin_state_up'], port['admin_state_up'])
+ self.assertEqual(self.port['device_id'], port['device_id'])
+ self.assertEqual(self.port['device_owner'], port['device_owner'])
+ self.assertEqual(self.port['mac_address'], port['mac_address'])
+ self.assertEqual(self.port['name'], port['name'])
+ self.assertEqual(self.port['security_groups'],
+ port['security_groups'])
+ self.assertEqual(self.port['network_id'], port['network_id'])
+ self.assertEqual(self.port['security_groups'],
+ port['security_groups'])
+
+ @test.attr(type='smoke')
+ def test_show_port_fields(self):
+ # Verify specific fields of a port
+ field_list = [('fields', 'id'), ]
+ resp, body = self.client.show_port(self.port['id'],
+ field_list=field_list)
+ self.assertEqual('200', resp['status'])
+ port = body['port']
+ self.assertEqual(len(port), len(field_list))
+ for label, field_name in field_list:
+ self.assertEqual(port[field_name], self.port[field_name])
+
+ @test.attr(type='smoke')
+ def test_list_ports(self):
+ # Verify the port exists in the list of all ports
+ resp, body = self.client.list_ports()
+ self.assertEqual('200', resp['status'])
+ ports = [port['id'] for port in body['ports']
+ if port['id'] == self.port['id']]
+ self.assertNotEmpty(ports, "Created port not found in the list")
+
+ @test.attr(type='smoke')
+ def test_port_list_filter_by_router_id(self):
+ # Create a router
+ network = self.create_network()
+ self.create_subnet(network)
+ router = self.create_router(data_utils.rand_name('router-'))
+ resp, port = self.client.create_port(network_id=network['id'])
+ # Add router interface to port created above
+ resp, interface = self.client.add_router_interface_with_port_id(
+ router['id'], port['port']['id'])
+ self.addCleanup(self.client.remove_router_interface_with_port_id,
+ router['id'], port['port']['id'])
+ # List ports filtered by router_id
+ resp, port_list = self.client.list_ports(
+ device_id=router['id'])
+ self.assertEqual('200', resp['status'])
+ ports = port_list['ports']
+ self.assertEqual(len(ports), 1)
+ self.assertEqual(ports[0]['id'], port['port']['id'])
+ self.assertEqual(ports[0]['device_id'], router['id'])
+
+ @test.attr(type='smoke')
+ def test_list_ports_fields(self):
+ # Verify specific fields of ports
+ resp, body = self.client.list_ports(fields='id')
+ self.assertEqual('200', resp['status'])
+ ports = body['ports']
+ self.assertNotEmpty(ports, "Port list returned is empty")
+ # Asserting the fields returned are correct
+ for port in ports:
+ self.assertEqual(len(port), 1)
+ self.assertIn('id', port)
+
+
+class PortsTestXML(PortsTestJSON):
+ _interface = 'xml'
+
+
+class PortsAdminExtendedAttrsTestJSON(base.BaseAdminNetworkTest):
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(PortsAdminExtendedAttrsTestJSON, cls).setUpClass()
+ cls.identity_client = cls._get_identity_admin_client()
+ cls.tenant = cls.identity_client.get_tenant_by_name(
+ CONF.identity.tenant_name)
+ cls.network = cls.create_network()
+ cls.host_id = socket.gethostname()
+
+ @test.attr(type='smoke')
+ def test_create_port_binding_ext_attr(self):
+ post_body = {"network_id": self.network['id'],
+ "binding:host_id": self.host_id}
+ resp, body = self.admin_client.create_port(**post_body)
+ self.assertEqual('201', resp['status'])
+ port = body['port']
+ self.addCleanup(self.admin_client.delete_port, port['id'])
+ host_id = port['binding:host_id']
+ self.assertIsNotNone(host_id)
+ self.assertEqual(self.host_id, host_id)
+
+ @test.attr(type='smoke')
+ def test_update_port_binding_ext_attr(self):
+ post_body = {"network_id": self.network['id']}
+ resp, body = self.admin_client.create_port(**post_body)
+ self.assertEqual('201', resp['status'])
+ port = body['port']
+ self.addCleanup(self.admin_client.delete_port, port['id'])
+ update_body = {"binding:host_id": self.host_id}
+ resp, body = self.admin_client.update_port(port['id'], **update_body)
+ self.assertEqual('200', resp['status'])
+ updated_port = body['port']
+ host_id = updated_port['binding:host_id']
+ self.assertIsNotNone(host_id)
+ self.assertEqual(self.host_id, host_id)
+
+ @test.attr(type='smoke')
+ def test_list_ports_binding_ext_attr(self):
+ resp, body = self.admin_client.list_ports(
+ **{'tenant_id': self.tenant['id']})
+ self.assertEqual('200', resp['status'])
+ ports_list = body['ports']
+ for port in ports_list:
+ vif_type = port['binding:vif_type']
+ self.assertIsNotNone(vif_type)
+ vif_details = port['binding:vif_details']['port_filter']
+ self.assertIsNotNone(vif_details)
+
+ @test.attr(type='smoke')
+ def test_show_port_binding_ext_attr(self):
+ resp, body = self.admin_client.create_port(
+ network_id=self.network['id'])
+ self.assertEqual('201', resp['status'])
+ port = body['port']
+ self.addCleanup(self.admin_client.delete_port, port['id'])
+ resp, body = self.admin_client.show_port(port['id'])
+ self.assertEqual('200', resp['status'])
+ show_port = body['port']
+ self.assertEqual(port['binding:host_id'],
+ show_port['binding:host_id'])
+ self.assertEqual(port['binding:vif_type'],
+ show_port['binding:vif_type'])
+ self.assertEqual(port['binding:vif_details'],
+ show_port['binding:vif_details'])
+
+
+class PortsAdminExtendedAttrsTestXML(PortsAdminExtendedAttrsTestJSON):
+ _interface = 'xml'
+
+
+class PortsIpV6TestJSON(PortsTestJSON):
+ _ip_version = 6
+ _tenant_network_cidr = CONF.network.tenant_network_v6_cidr
+ _tenant_network_mask_bits = CONF.network.tenant_network_v6_mask_bits
+
+ @classmethod
+ def setUpClass(cls):
+ super(PortsIpV6TestJSON, cls).setUpClass()
+ if not CONF.network_feature_enabled.ipv6:
+ cls.tearDownClass()
+ skip_msg = "IPv6 Tests are disabled."
+ raise cls.skipException(skip_msg)
+
+
+class PortsIpV6TestXML(PortsIpV6TestJSON):
+ _interface = 'xml'
+
+
+class PortsAdminExtendedAttrsIpV6TestJSON(PortsAdminExtendedAttrsTestJSON):
+ _ip_version = 6
+ _tenant_network_cidr = CONF.network.tenant_network_v6_cidr
+ _tenant_network_mask_bits = CONF.network.tenant_network_v6_mask_bits
+
+ @classmethod
+ def setUpClass(cls):
+ super(PortsAdminExtendedAttrsIpV6TestJSON, cls).setUpClass()
+ if not CONF.network_feature_enabled.ipv6:
+ cls.tearDownClass()
+ skip_msg = "IPv6 Tests are disabled."
+ raise cls.skipException(skip_msg)
+
+
+class PortsAdminExtendedAttrsIpV6TestXML(
+ PortsAdminExtendedAttrsIpV6TestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/network/test_quotas.py b/tempest/api/network/test_quotas.py
index a5be395..38784d8 100644
--- a/tempest/api/network/test_quotas.py
+++ b/tempest/api/network/test_quotas.py
@@ -17,7 +17,7 @@
from tempest.api.network import base
from tempest import clients
from tempest.common.utils import data_utils
-from tempest.test import attr
+from tempest import test
class QuotasTest(base.BaseNetworkTest):
@@ -46,11 +46,14 @@
@classmethod
def setUpClass(cls):
super(QuotasTest, cls).setUpClass()
+ if not test.is_extension_enabled('quotas', 'network'):
+ msg = "quotas extension not enabled."
+ raise cls.skipException(msg)
admin_manager = clients.AdminManager()
cls.admin_client = admin_manager.network_client
cls.identity_admin_client = admin_manager.identity_client
- @attr(type='gate')
+ @test.attr(type='gate')
def test_quotas(self):
# Add a tenant to conduct the test
test_tenant = data_utils.rand_name('test_tenant_')
diff --git a/tempest/api/network/test_routers.py b/tempest/api/network/test_routers.py
index f3fac93..2657031 100644
--- a/tempest/api/network/test_routers.py
+++ b/tempest/api/network/test_routers.py
@@ -16,6 +16,7 @@
import netaddr
from tempest.api.network import base_routers as base
+from tempest import clients
from tempest.common.utils import data_utils
from tempest import config
from tempest import test
@@ -29,6 +30,11 @@
@classmethod
def setUpClass(cls):
super(RoutersTest, cls).setUpClass()
+ if not test.is_extension_enabled('router', 'network'):
+ msg = "router extension not enabled."
+ raise cls.skipException(msg)
+ admin_manager = clients.AdminManager()
+ cls.identity_admin_client = admin_manager.identity_client
@test.attr(type='smoke')
def test_create_show_list_update_delete_router(self):
@@ -74,6 +80,25 @@
self.assertEqual(show_body['router']['name'], updated_name)
@test.attr(type='smoke')
+ def test_create_router_setting_tenant_id(self):
+ # Test creating router from admin user setting tenant_id.
+ test_tenant = data_utils.rand_name('test_tenant_')
+ test_description = data_utils.rand_name('desc_')
+ _, tenant = self.identity_admin_client.create_tenant(
+ name=test_tenant,
+ description=test_description)
+ tenant_id = tenant['id']
+ self.addCleanup(self.identity_admin_client.delete_tenant, tenant_id)
+
+ name = data_utils.rand_name('router-')
+ resp, create_body = self.admin_client.create_router(
+ name, tenant_id=tenant_id)
+ self.assertEqual('201', resp['status'])
+ self.addCleanup(self.admin_client.delete_router,
+ create_body['router']['id'])
+ self.assertEqual(tenant_id, create_body['router']['tenant_id'])
+
+ @test.attr(type='smoke')
def test_add_remove_router_interface_with_subnet_id(self):
network = self.create_network()
subnet = self.create_subnet(network)
@@ -231,3 +256,48 @@
def _delete_extra_routes(self, router_id):
resp, _ = self.client.delete_extra_routes(router_id)
+
+ @test.attr(type='smoke')
+ def test_update_router_admin_state(self):
+ self.router = self.create_router(data_utils.rand_name('router-'))
+ self.assertFalse(self.router['admin_state_up'])
+ # Update router admin state
+ resp, update_body = self.client.update_router(self.router['id'],
+ admin_state_up=True)
+ self.assertEqual('200', resp['status'])
+ self.assertTrue(update_body['router']['admin_state_up'])
+ resp, show_body = self.client.show_router(self.router['id'])
+ self.assertEqual('200', resp['status'])
+ self.assertTrue(show_body['router']['admin_state_up'])
+
+ @test.attr(type='smoke')
+ def test_add_multiple_router_interfaces(self):
+ network = self.create_network()
+ subnet01 = self.create_subnet(network)
+ subnet02 = self.create_subnet(network)
+ router = self.create_router(data_utils.rand_name('router-'))
+ interface01 = self._add_router_interface_with_subnet_id(router['id'],
+ subnet01['id'])
+ self._verify_router_interface(router['id'], subnet01['id'],
+ interface01['port_id'])
+ interface02 = self._add_router_interface_with_subnet_id(router['id'],
+ subnet02['id'])
+ self._verify_router_interface(router['id'], subnet02['id'],
+ interface02['port_id'])
+
+ def _add_router_interface_with_subnet_id(self, router_id, subnet_id):
+ resp, interface = self.client.add_router_interface_with_subnet_id(
+ router_id, subnet_id)
+ self.assertEqual('200', resp['status'])
+ self.addCleanup(self._remove_router_interface_with_subnet_id,
+ router_id, subnet_id)
+ self.assertEqual(subnet_id, interface['subnet_id'])
+ return interface
+
+ def _verify_router_interface(self, router_id, subnet_id, port_id):
+ resp, show_port_body = self.client.show_port(port_id)
+ self.assertEqual('200', resp['status'])
+ interface_port = show_port_body['port']
+ self.assertEqual(router_id, interface_port['device_id'])
+ self.assertEqual(subnet_id,
+ interface_port['fixed_ips'][0]['subnet_id'])
diff --git a/tempest/api/network/test_routers_negative.py b/tempest/api/network/test_routers_negative.py
index 0d65b64..e6ad4de 100644
--- a/tempest/api/network/test_routers_negative.py
+++ b/tempest/api/network/test_routers_negative.py
@@ -16,7 +16,7 @@
from tempest.api.network import base_routers as base
from tempest.common.utils import data_utils
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class RoutersNegativeTest(base.BaseRouterTest):
@@ -25,11 +25,14 @@
@classmethod
def setUpClass(cls):
super(RoutersNegativeTest, cls).setUpClass()
+ if not test.is_extension_enabled('router', 'network'):
+ msg = "router extension not enabled."
+ raise cls.skipException(msg)
cls.router = cls.create_router(data_utils.rand_name('router-'))
cls.network = cls.create_network()
cls.subnet = cls.create_subnet(cls.network)
- @attr(type=['negative', 'smoke'])
+ @test.attr(type=['negative', 'smoke'])
def test_router_add_gateway_invalid_network_returns_404(self):
self.assertRaises(exceptions.NotFound,
self.client.update_router,
@@ -37,7 +40,7 @@
external_gateway_info={
'network_id': self.router['id']})
- @attr(type=['negative', 'smoke'])
+ @test.attr(type=['negative', 'smoke'])
def test_router_add_gateway_net_not_external_returns_400(self):
self.create_subnet(self.network)
self.assertRaises(exceptions.BadRequest,
@@ -46,7 +49,7 @@
external_gateway_info={
'network_id': self.network['id']})
- @attr(type=['negative', 'smoke'])
+ @test.attr(type=['negative', 'smoke'])
def test_router_remove_interface_in_use_returns_409(self):
self.client.add_router_interface_with_subnet_id(
self.router['id'], self.subnet['id'])
diff --git a/tempest/api/network/test_security_groups.py b/tempest/api/network/test_security_groups.py
index b95182d..3e26f46 100644
--- a/tempest/api/network/test_security_groups.py
+++ b/tempest/api/network/test_security_groups.py
@@ -14,13 +14,21 @@
# under the License.
from tempest.api.network import base_security_groups as base
-from tempest.test import attr
+from tempest.common.utils import data_utils
+from tempest import test
class SecGroupTest(base.BaseSecGroupTest):
_interface = 'json'
- @attr(type='smoke')
+ @classmethod
+ def setUpClass(cls):
+ super(SecGroupTest, cls).setUpClass()
+ if not test.is_extension_enabled('security-group', 'network'):
+ msg = "security-group extension not enabled."
+ raise cls.skipException(msg)
+
+ @test.attr(type='smoke')
def test_list_security_groups(self):
# Verify the that security group belonging to tenant exist in list
resp, body = self.client.list_security_groups()
@@ -33,16 +41,10 @@
msg = "Security-group list doesn't contain default security-group"
self.assertIsNotNone(found, msg)
- @attr(type='smoke')
- def test_create_show_delete_security_group(self):
+ @test.attr(type='smoke')
+ def test_create_list_update_show_delete_security_group(self):
group_create_body, name = self._create_security_group()
- # Show details of the created security group
- resp, show_body = self.client.show_security_group(
- group_create_body['security_group']['id'])
- self.assertEqual('200', resp['status'])
- self.assertEqual(show_body['security_group']['name'], name)
-
# List security groups and verify if created group is there in response
resp, list_body = self.client.list_security_groups()
self.assertEqual('200', resp['status'])
@@ -50,8 +52,26 @@
for secgroup in list_body['security_groups']:
secgroup_list.append(secgroup['id'])
self.assertIn(group_create_body['security_group']['id'], secgroup_list)
+ # Update the security group
+ new_name = data_utils.rand_name('security-')
+ new_description = data_utils.rand_name('security-description')
+ resp, update_body = self.client.update_security_group(
+ group_create_body['security_group']['id'],
+ name=new_name,
+ description=new_description)
+ # Verify if security group is updated
+ self.assertEqual('200', resp['status'])
+ self.assertEqual(update_body['security_group']['name'], new_name)
+ self.assertEqual(update_body['security_group']['description'],
+ new_description)
+ # Show details of the updated security group
+ resp, show_body = self.client.show_security_group(
+ group_create_body['security_group']['id'])
+ self.assertEqual(show_body['security_group']['name'], new_name)
+ self.assertEqual(show_body['security_group']['description'],
+ new_description)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_create_show_delete_security_group_rule(self):
group_create_body, _ = self._create_security_group()
@@ -59,8 +79,9 @@
protocols = ['tcp', 'udp', 'icmp']
for protocol in protocols:
resp, rule_create_body = self.client.create_security_group_rule(
- group_create_body['security_group']['id'],
- protocol=protocol
+ security_group_id=group_create_body['security_group']['id'],
+ protocol=protocol,
+ direction='ingress'
)
self.assertEqual('201', resp['status'])
self.addCleanup(self._delete_security_group_rule,
@@ -80,7 +101,7 @@
for rule in rule_list_body['security_group_rules']]
self.assertIn(rule_create_body['security_group_rule']['id'], rule_list)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_create_security_group_rule_with_additional_args(self):
# Verify creating security group rule with the following
# arguments works: "protocol": "tcp", "port_range_max": 77,
@@ -92,7 +113,7 @@
port_range_min = 77
port_range_max = 77
resp, rule_create_body = self.client.create_security_group_rule(
- group_create_body['security_group']['id'],
+ security_group_id=group_create_body['security_group']['id'],
direction=direction,
protocol=protocol,
port_range_min=port_range_min,
diff --git a/tempest/api/network/test_security_groups_negative.py b/tempest/api/network/test_security_groups_negative.py
index 98e109e..0b86398 100644
--- a/tempest/api/network/test_security_groups_negative.py
+++ b/tempest/api/network/test_security_groups_negative.py
@@ -17,26 +17,33 @@
from tempest.api.network import base_security_groups as base
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class NegativeSecGroupTest(base.BaseSecGroupTest):
_interface = 'json'
- @attr(type=['negative', 'gate'])
+ @classmethod
+ def setUpClass(cls):
+ super(NegativeSecGroupTest, cls).setUpClass()
+ if not test.is_extension_enabled('security-group', 'network'):
+ msg = "security-group extension not enabled."
+ raise cls.skipException(msg)
+
+ @test.attr(type=['negative', 'gate'])
def test_show_non_existent_security_group(self):
non_exist_id = str(uuid.uuid4())
self.assertRaises(exceptions.NotFound, self.client.show_security_group,
non_exist_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_show_non_existent_security_group_rule(self):
non_exist_id = str(uuid.uuid4())
self.assertRaises(exceptions.NotFound,
self.client.show_security_group_rule,
non_exist_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_non_existent_security_group(self):
non_exist_id = str(uuid.uuid4())
self.assertRaises(exceptions.NotFound,
@@ -44,18 +51,18 @@
non_exist_id
)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_security_group_rule_with_bad_protocol(self):
group_create_body, _ = self._create_security_group()
#Create rule with bad protocol name
pname = 'bad_protocol_name'
- self.assertRaises(exceptions.BadRequest,
- self.client.create_security_group_rule,
- group_create_body['security_group']['id'],
- protocol=pname)
+ self.assertRaises(
+ exceptions.BadRequest, self.client.create_security_group_rule,
+ security_group_id=group_create_body['security_group']['id'],
+ protocol=pname, direction='ingress')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_security_group_rule_with_invalid_ports(self):
group_create_body, _ = self._create_security_group()
@@ -65,29 +72,29 @@
(80, 65536, 'Invalid value for port 65536'),
(-16, 65536, 'Invalid value for port')]
for pmin, pmax, msg in states:
- ex = self.assertRaises(exceptions.BadRequest,
- self.client.create_security_group_rule,
- group_create_body['security_group']['id'],
- protocol='tcp',
- port_range_min=pmin,
- port_range_max=pmax)
+ ex = self.assertRaises(
+ exceptions.BadRequest, self.client.create_security_group_rule,
+ security_group_id=group_create_body['security_group']['id'],
+ protocol='tcp', port_range_min=pmin, port_range_max=pmax,
+ direction='ingress')
self.assertIn(msg, str(ex))
- @attr(type=['negative', 'smoke'])
+ @test.attr(type=['negative', 'smoke'])
def test_create_additional_default_security_group_fails(self):
# Create security group named 'default', it should be failed.
name = 'default'
self.assertRaises(exceptions.Conflict,
self.client.create_security_group,
- name)
+ name=name)
- @attr(type=['negative', 'smoke'])
+ @test.attr(type=['negative', 'smoke'])
def test_create_security_group_rule_with_non_existent_security_group(self):
# Create security group rules with not existing security group.
non_existent_sg = str(uuid.uuid4())
self.assertRaises(exceptions.NotFound,
self.client.create_security_group_rule,
- non_existent_sg)
+ security_group_id=non_existent_sg,
+ direction='ingress')
class NegativeSecGroupTestXML(NegativeSecGroupTest):
diff --git a/tempest/api/object_storage/base.py b/tempest/api/object_storage/base.py
index ef36c3d..45c895b 100644
--- a/tempest/api/object_storage/base.py
+++ b/tempest/api/object_storage/base.py
@@ -14,7 +14,7 @@
# under the License.
-from tempest.api.identity.base import DataGenerator
+from tempest.api.identity import base
from tempest import clients
from tempest.common import custom_matchers
from tempest.common import isolated_creds
@@ -83,7 +83,7 @@
cls.object_client_alt.auth_provider.clear_auth()
cls.container_client_alt.auth_provider.clear_auth()
- cls.data = DataGenerator(cls.identity_admin_client)
+ cls.data = base.DataGenerator(cls.identity_admin_client)
@classmethod
def tearDownClass(cls):
@@ -130,7 +130,10 @@
objlist = container_client.list_all_container_objects(cont)
# delete every object in the container
for obj in objlist:
- object_client.delete_object(cont, obj['name'])
+ try:
+ object_client.delete_object(cont, obj['name'])
+ except exceptions.NotFound:
+ pass
container_client.delete_container(cont)
except exceptions.NotFound:
pass
diff --git a/tempest/api/object_storage/test_account_bulk.py b/tempest/api/object_storage/test_account_bulk.py
index 5fde76a..a94c883 100644
--- a/tempest/api/object_storage/test_account_bulk.py
+++ b/tempest/api/object_storage/test_account_bulk.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 NTT Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/tempest/api/object_storage/test_account_quotas.py b/tempest/api/object_storage/test_account_quotas.py
index 788292d..a3098a5 100644
--- a/tempest/api/object_storage/test_account_quotas.py
+++ b/tempest/api/object_storage/test_account_quotas.py
@@ -17,9 +17,12 @@
from tempest.api.object_storage import base
from tempest import clients
from tempest.common.utils import data_utils
+from tempest import config
from tempest import exceptions
from tempest import test
+CONF = config.CONF
+
class AccountQuotasTest(base.BaseObjectTest):
@@ -41,7 +44,7 @@
try:
_, roles = cls.os_admin.identity_client.list_roles()
reseller_role_id = next(r['id'] for r in roles if r['name']
- == 'ResellerAdmin')
+ == CONF.object_storage.reseller_admin_role)
except StopIteration:
msg = "No ResellerAdmin role found"
raise exceptions.NotFound(msg)
@@ -65,7 +68,7 @@
# Retrieve a ResellerAdmin auth data and use it to set a quota
# on the client's account
cls.reselleradmin_auth_data = \
- cls.os_reselleradmin.get_auth_provider().auth_data
+ cls.os_reselleradmin.auth_provider.auth_data
def setUp(self):
super(AccountQuotasTest, self).setUp()
diff --git a/tempest/api/object_storage/test_account_quotas_negative.py b/tempest/api/object_storage/test_account_quotas_negative.py
index cab307d..7648ea1 100644
--- a/tempest/api/object_storage/test_account_quotas_negative.py
+++ b/tempest/api/object_storage/test_account_quotas_negative.py
@@ -17,9 +17,12 @@
from tempest.api.object_storage import base
from tempest import clients
from tempest.common.utils import data_utils
+from tempest import config
from tempest import exceptions
from tempest import test
+CONF = config.CONF
+
class AccountQuotasNegativeTest(base.BaseObjectTest):
@@ -41,7 +44,7 @@
try:
_, roles = cls.os_admin.identity_client.list_roles()
reseller_role_id = next(r['id'] for r in roles if r['name']
- == 'ResellerAdmin')
+ == CONF.object_storage.reseller_admin_role)
except StopIteration:
msg = "No ResellerAdmin role found"
raise exceptions.NotFound(msg)
@@ -65,7 +68,7 @@
# Retrieve a ResellerAdmin auth data and use it to set a quota
# on the client's account
cls.reselleradmin_auth_data = \
- cls.os_reselleradmin.get_auth_provider().auth_data
+ cls.os_reselleradmin.auth_provider.auth_data
def setUp(self):
super(AccountQuotasNegativeTest, self).setUp()
diff --git a/tempest/api/object_storage/test_account_services.py b/tempest/api/object_storage/test_account_services.py
index 79fd99d..4b895d8 100644
--- a/tempest/api/object_storage/test_account_services.py
+++ b/tempest/api/object_storage/test_account_services.py
@@ -15,11 +15,17 @@
import random
+from six import moves
+
from tempest.api.object_storage import base
+from tempest import clients
from tempest.common import custom_matchers
from tempest.common.utils import data_utils
-from tempest.test import attr
-from tempest.test import HTTP_SUCCESS
+from tempest import config
+from tempest import exceptions
+from tempest import test
+
+CONF = config.CONF
class AccountTest(base.BaseObjectTest):
@@ -27,7 +33,7 @@
def setUpClass(cls):
super(AccountTest, cls).setUpClass()
cls.containers = []
- for i in xrange(ord('a'), ord('f') + 1):
+ for i in moves.xrange(ord('a'), ord('f') + 1):
name = data_utils.rand_name(name='%s-' % chr(i))
cls.container_client.create_container(name)
cls.containers.append(name)
@@ -36,29 +42,118 @@
@classmethod
def tearDownClass(cls):
cls.delete_containers(cls.containers)
+ cls.data.teardown_all()
super(AccountTest, cls).tearDownClass()
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_containers(self):
# list of all containers should not be empty
- params = {'format': 'json'}
- resp, container_list = \
- self.account_client.list_account_containers(params=params)
+ resp, container_list = self.account_client.list_account_containers()
self.assertHeaders(resp, 'Account', 'GET')
self.assertIsNotNone(container_list)
- container_names = [c['name'] for c in container_list]
for container_name in self.containers:
- self.assertIn(container_name, container_names)
+ self.assertIn(container_name, container_list)
- @attr(type='smoke')
+ @test.attr(type='smoke')
+ def test_list_no_containers(self):
+ # List request to empty account
+
+ # To test listing no containers, create new user other than
+ # the base user of this instance.
+ self.data.setup_test_user()
+
+ os_test_user = clients.Manager(
+ self.data.test_user,
+ self.data.test_password,
+ self.data.test_tenant)
+
+ # Retrieve the id of an operator role of object storage
+ test_role_id = None
+ swift_role = CONF.object_storage.operator_role
+ try:
+ _, roles = self.os_admin.identity_client.list_roles()
+ test_role_id = next(r['id'] for r in roles if r['name']
+ == swift_role)
+ except StopIteration:
+ msg = "%s role found" % swift_role
+ raise exceptions.NotFound(msg)
+
+ # Retrieve the test_user id
+ _, users = self.os_admin.identity_client.get_users()
+ test_user_id = next(usr['id'] for usr in users if usr['name']
+ == self.data.test_user)
+
+ # Retrieve the test_tenant id
+ _, tenants = self.os_admin.identity_client.list_tenants()
+ test_tenant_id = next(tnt['id'] for tnt in tenants if tnt['name']
+ == self.data.test_tenant)
+
+ # Assign the newly created user the appropriate operator role
+ self.os_admin.identity_client.assign_user_role(
+ test_tenant_id,
+ test_user_id,
+ test_role_id)
+
+ resp, container_list = \
+ os_test_user.account_client.list_account_containers()
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
+
+ # When sending a request to an account which has not received a PUT
+ # container request, the response does not contain 'accept-ranges'
+ # header. This is a special case, therefore the existence of response
+ # headers is checked without custom matcher.
+ self.assertIn('content-length', resp)
+ self.assertIn('x-timestamp', resp)
+ self.assertIn('x-account-bytes-used', resp)
+ self.assertIn('x-account-container-count', resp)
+ self.assertIn('x-account-object-count', resp)
+ self.assertIn('content-type', resp)
+ self.assertIn('x-trans-id', resp)
+ self.assertIn('date', resp)
+
+ # Check only the format of common headers with custom matcher
+ self.assertThat(resp, custom_matchers.AreAllWellFormatted())
+
+ self.assertEqual(len(container_list), 0)
+
+ @test.attr(type='smoke')
+ def test_list_containers_with_format_json(self):
+ # list containers setting format parameter to 'json'
+ params = {'format': 'json'}
+ resp, container_list = self.account_client.list_account_containers(
+ params=params)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
+ self.assertHeaders(resp, 'Account', 'GET')
+ self.assertIsNotNone(container_list)
+ self.assertTrue([c['name'] for c in container_list])
+ self.assertTrue([c['count'] for c in container_list])
+ self.assertTrue([c['bytes'] for c in container_list])
+
+ @test.attr(type='smoke')
+ def test_list_containers_with_format_xml(self):
+ # list containers setting format parameter to 'xml'
+ params = {'format': 'xml'}
+ resp, container_list = self.account_client.list_account_containers(
+ params=params)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
+ self.assertHeaders(resp, 'Account', 'GET')
+ self.assertIsNotNone(container_list)
+ self.assertEqual(container_list.tag, 'account')
+ self.assertTrue('name' in container_list.keys())
+ self.assertEqual(container_list.find(".//container").tag, 'container')
+ self.assertEqual(container_list.find(".//name").tag, 'name')
+ self.assertEqual(container_list.find(".//count").tag, 'count')
+ self.assertEqual(container_list.find(".//bytes").tag, 'bytes')
+
+ @test.attr(type='smoke')
def test_list_extensions(self):
resp, extensions = self.account_client.list_extensions()
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertThat(resp, custom_matchers.AreAllWellFormatted())
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_containers_with_limit(self):
# list containers one of them, half of them then all of them
for limit in (1, self.containers_count / 2, self.containers_count):
@@ -69,7 +164,7 @@
self.assertEqual(len(container_list), limit)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_containers_with_marker(self):
# list containers using marker param
# first expect to get 0 container as we specified last
@@ -89,7 +184,7 @@
self.assertEqual(len(container_list), self.containers_count / 2 - 1)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_containers_with_end_marker(self):
# list containers using end_marker param
# first expect to get 0 container as we specified first container as
@@ -107,7 +202,18 @@
self.assertHeaders(resp, 'Account', 'GET')
self.assertEqual(len(container_list), self.containers_count / 2)
- @attr(type='smoke')
+ @test.attr(type='smoke')
+ def test_list_containers_with_marker_and_end_marker(self):
+ # list containers combining marker and end_marker param
+ params = {'marker': self.containers[0],
+ 'end_marker': self.containers[self.containers_count - 1]}
+ resp, container_list = self.account_client.list_account_containers(
+ params=params)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
+ self.assertHeaders(resp, 'Account', 'GET')
+ self.assertEqual(len(container_list), self.containers_count - 2)
+
+ @test.attr(type='smoke')
def test_list_containers_with_limit_and_marker(self):
# list containers combining marker and limit param
# result are always limitated by the limit whatever the marker
@@ -121,35 +227,126 @@
self.assertTrue(len(container_list) <= limit, str(container_list))
- @attr(type='smoke')
+ @test.attr(type='smoke')
+ def test_list_containers_with_limit_and_end_marker(self):
+ # list containers combining limit and end_marker param
+ limit = random.randint(1, self.containers_count)
+ params = {'limit': limit,
+ 'end_marker': self.containers[self.containers_count / 2]}
+ resp, container_list = self.account_client.list_account_containers(
+ params=params)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
+ self.assertHeaders(resp, 'Account', 'GET')
+ self.assertEqual(len(container_list),
+ min(limit, self.containers_count / 2))
+
+ @test.attr(type='smoke')
+ def test_list_containers_with_limit_and_marker_and_end_marker(self):
+ # list containers combining limit, marker and end_marker param
+ limit = random.randint(1, self.containers_count)
+ params = {'limit': limit,
+ 'marker': self.containers[0],
+ 'end_marker': self.containers[self.containers_count - 1]}
+ resp, container_list = self.account_client.list_account_containers(
+ params=params)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
+ self.assertHeaders(resp, 'Account', 'GET')
+ self.assertEqual(len(container_list),
+ min(limit, self.containers_count - 2))
+
+ @test.attr(type='smoke')
def test_list_account_metadata(self):
# list all account metadata
- resp, metadata = self.account_client.list_account_metadata()
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
- self.assertHeaders(resp, 'Account', 'HEAD')
- @attr(type='smoke')
- def test_create_and_delete_account_metadata(self):
- header = 'test-account-meta'
- data = 'Meta!'
+ # set metadata to account
+ metadata = {'test-account-meta1': 'Meta1',
+ 'test-account-meta2': 'Meta2'}
+ resp, _ = self.account_client.create_account_metadata(metadata)
+
+ resp, _ = self.account_client.list_account_metadata()
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
+ self.assertHeaders(resp, 'Account', 'HEAD')
+ self.assertIn('x-account-meta-test-account-meta1', resp)
+ self.assertIn('x-account-meta-test-account-meta2', resp)
+ self.account_client.delete_account_metadata(metadata)
+
+ @test.attr(type='smoke')
+ def test_list_no_account_metadata(self):
+ # list no account metadata
+ resp, _ = self.account_client.list_account_metadata()
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
+ self.assertHeaders(resp, 'Account', 'HEAD')
+ self.assertNotIn('x-account-meta-', str(resp))
+
+ @test.attr(type='smoke')
+ def test_update_account_metadata_with_create_metadata(self):
# add metadata to account
- resp, _ = self.account_client.create_account_metadata(
- metadata={header: data})
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ metadata = {'test-account-meta1': 'Meta1'}
+ resp, _ = self.account_client.create_account_metadata(metadata)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, 'Account', 'POST')
- resp, _ = self.account_client.list_account_metadata()
- self.assertHeaders(resp, 'Account', 'HEAD')
+ resp, body = self.account_client.list_account_metadata()
+ self.assertIn('x-account-meta-test-account-meta1', resp)
+ self.assertEqual(resp['x-account-meta-test-account-meta1'],
+ metadata['test-account-meta1'])
- self.assertIn('x-account-meta-' + header, resp)
- self.assertEqual(resp['x-account-meta-' + header], data)
+ self.account_client.delete_account_metadata(metadata)
+ @test.attr(type='smoke')
+ def test_update_account_metadata_with_delete_matadata(self):
# delete metadata from account
- resp, _ = \
- self.account_client.delete_account_metadata(metadata=[header])
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ metadata = {'test-account-meta1': 'Meta1'}
+ self.account_client.create_account_metadata(metadata)
+ resp, _ = self.account_client.delete_account_metadata(metadata)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, 'Account', 'POST')
resp, _ = self.account_client.list_account_metadata()
- self.assertHeaders(resp, 'Account', 'HEAD')
- self.assertNotIn('x-account-meta-' + header, resp)
+ self.assertNotIn('x-account-meta-test-account-meta1', resp)
+
+ @test.attr(type='smoke')
+ def test_update_account_metadata_with_create_matadata_key(self):
+ # if the value of metadata is not set, the metadata is not
+ # registered at a server
+ metadata = {'test-account-meta1': ''}
+ resp, _ = self.account_client.create_account_metadata(metadata)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
+ self.assertHeaders(resp, 'Account', 'POST')
+
+ resp, _ = self.account_client.list_account_metadata()
+ self.assertNotIn('x-account-meta-test-account-meta1', resp)
+
+ @test.attr(type='smoke')
+ def test_update_account_metadata_with_delete_matadata_key(self):
+ # Although the value of metadata is not set, the feature of
+ # deleting metadata is valid
+ metadata_1 = {'test-account-meta1': 'Meta1'}
+ self.account_client.create_account_metadata(metadata_1)
+ metadata_2 = {'test-account-meta1': ''}
+ resp, _ = self.account_client.delete_account_metadata(metadata_2)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
+ self.assertHeaders(resp, 'Account', 'POST')
+
+ resp, _ = self.account_client.list_account_metadata()
+ self.assertNotIn('x-account-meta-test-account-meta1', resp)
+
+ @test.attr(type='smoke')
+ def test_update_account_metadata_with_create_and_delete_metadata(self):
+ # Send a request adding and deleting metadata requests simultaneously
+ metadata_1 = {'test-account-meta1': 'Meta1'}
+ self.account_client.create_account_metadata(metadata_1)
+ metadata_2 = {'test-account-meta2': 'Meta2'}
+ resp, body = self.account_client.create_and_delete_account_metadata(
+ metadata_2,
+ metadata_1)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
+ self.assertHeaders(resp, 'Account', 'POST')
+
+ resp, _ = self.account_client.list_account_metadata()
+ self.assertNotIn('x-account-meta-test-account-meta1', resp)
+ self.assertIn('x-account-meta-test-account-meta2', resp)
+ self.assertEqual(resp['x-account-meta-test-account-meta2'],
+ metadata_2['test-account-meta2'])
+
+ self.account_client.delete_account_metadata(metadata_2)
diff --git a/tempest/api/object_storage/test_account_services_negative.py b/tempest/api/object_storage/test_account_services_negative.py
index ea93aa3..71eaab5 100644
--- a/tempest/api/object_storage/test_account_services_negative.py
+++ b/tempest/api/object_storage/test_account_services_negative.py
@@ -31,7 +31,7 @@
test_os = clients.Manager(self.data.test_user,
self.data.test_password,
self.data.test_tenant)
- test_auth_provider = test_os.get_auth_provider()
+ test_auth_provider = test_os.auth_provider
# Get auth for the test user
test_auth_provider.auth_data
diff --git a/tempest/api/object_storage/test_container_acl.py b/tempest/api/object_storage/test_container_acl.py
index aae6b4d..c865ee1 100644
--- a/tempest/api/object_storage/test_container_acl.py
+++ b/tempest/api/object_storage/test_container_acl.py
@@ -16,8 +16,7 @@
from tempest.api.object_storage import base
from tempest import clients
from tempest.common.utils import data_utils
-from tempest.test import attr
-from tempest.test import HTTP_SUCCESS
+from tempest import test
class ObjectTestACLs(base.BaseObjectTest):
@@ -28,7 +27,7 @@
test_os = clients.Manager(cls.data.test_user,
cls.data.test_password,
cls.data.test_tenant)
- cls.test_auth_data = test_os.get_auth_provider().auth_data
+ cls.test_auth_data = test_os.auth_provider.auth_data
@classmethod
def tearDownClass(cls):
@@ -44,7 +43,7 @@
self.delete_containers([self.container_name])
super(ObjectTestACLs, self).tearDown()
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_read_object_with_rights(self):
# attempt to read object using authorized user
# update X-Container-Read metadata ACL
@@ -53,7 +52,7 @@
resp_meta, body = self.container_client.update_container_metadata(
self.container_name, metadata=cont_headers,
metadata_prefix='')
- self.assertIn(int(resp_meta['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp_meta['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp_meta, 'Container', 'POST')
# create object
object_name = data_utils.rand_name(name='Object')
@@ -68,10 +67,10 @@
)
resp, _ = self.custom_object_client.get_object(
self.container_name, object_name)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, 'Object', 'GET')
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_write_object_with_rights(self):
# attempt to write object using authorized user
# update X-Container-Write metadata ACL
@@ -80,7 +79,7 @@
resp_meta, body = self.container_client.update_container_metadata(
self.container_name, metadata=cont_headers,
metadata_prefix='')
- self.assertIn(int(resp_meta['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp_meta['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp_meta, 'Container', 'POST')
# Trying to write the object with rights
self.custom_object_client.auth_provider.set_alt_auth_data(
@@ -91,5 +90,5 @@
resp, _ = self.custom_object_client.create_object(
self.container_name,
object_name, 'data')
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, 'Object', 'PUT')
diff --git a/tempest/api/object_storage/test_container_acl_negative.py b/tempest/api/object_storage/test_container_acl_negative.py
index 1dc9bb5..547bf87 100644
--- a/tempest/api/object_storage/test_container_acl_negative.py
+++ b/tempest/api/object_storage/test_container_acl_negative.py
@@ -18,8 +18,7 @@
from tempest import clients
from tempest.common.utils import data_utils
from tempest import exceptions
-from tempest.test import attr
-from tempest.test import HTTP_SUCCESS
+from tempest import test
class ObjectACLsNegativeTest(base.BaseObjectTest):
@@ -30,7 +29,7 @@
test_os = clients.Manager(cls.data.test_user,
cls.data.test_password,
cls.data.test_tenant)
- cls.test_auth_data = test_os.get_auth_provider().auth_data
+ cls.test_auth_data = test_os.auth_provider.auth_data
@classmethod
def tearDownClass(cls):
@@ -46,7 +45,7 @@
self.delete_containers([self.container_name])
super(ObjectACLsNegativeTest, self).tearDown()
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_write_object_without_using_creds(self):
# trying to create object with empty headers
# X-Auth-Token is not provided
@@ -59,7 +58,7 @@
self.custom_object_client.create_object,
self.container_name, object_name, 'data')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_object_without_using_creds(self):
# create object
object_name = data_utils.rand_name(name='Object')
@@ -75,7 +74,7 @@
self.custom_object_client.delete_object,
self.container_name, object_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_write_object_with_non_authorized_user(self):
# attempt to upload another file using non-authorized user
# User provided token is forbidden. ACL are not set
@@ -89,7 +88,7 @@
self.custom_object_client.create_object,
self.container_name, object_name, 'data')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_read_object_with_non_authorized_user(self):
# attempt to read object using non-authorized user
# User provided token is forbidden. ACL are not set
@@ -107,7 +106,7 @@
self.custom_object_client.get_object,
self.container_name, object_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_object_with_non_authorized_user(self):
# attempt to delete object using non-authorized user
# User provided token is forbidden. ACL are not set
@@ -125,7 +124,7 @@
self.custom_object_client.delete_object,
self.container_name, object_name)
- @attr(type=['negative', 'smoke'])
+ @test.attr(type=['negative', 'smoke'])
def test_read_object_without_rights(self):
# attempt to read object using non-authorized user
# update X-Container-Read metadata ACL
@@ -133,7 +132,7 @@
resp_meta, body = self.container_client.update_container_metadata(
self.container_name, metadata=cont_headers,
metadata_prefix='')
- self.assertIn(int(resp_meta['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp_meta['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp_meta, 'Container', 'POST')
# create object
object_name = data_utils.rand_name(name='Object')
@@ -150,7 +149,7 @@
self.custom_object_client.get_object,
self.container_name, object_name)
- @attr(type=['negative', 'smoke'])
+ @test.attr(type=['negative', 'smoke'])
def test_write_object_without_rights(self):
# attempt to write object using non-authorized user
# update X-Container-Write metadata ACL
@@ -158,7 +157,7 @@
resp_meta, body = self.container_client.update_container_metadata(
self.container_name, metadata=cont_headers,
metadata_prefix='')
- self.assertIn(int(resp_meta['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp_meta['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp_meta, 'Container', 'POST')
# Trying to write the object without rights
self.custom_object_client.auth_provider.set_alt_auth_data(
@@ -171,7 +170,7 @@
self.container_name,
object_name, 'data')
- @attr(type=['negative', 'smoke'])
+ @test.attr(type=['negative', 'smoke'])
def test_write_object_without_write_rights(self):
# attempt to write object using non-authorized user
# update X-Container-Read and X-Container-Write metadata ACL
@@ -181,7 +180,7 @@
resp_meta, body = self.container_client.update_container_metadata(
self.container_name, metadata=cont_headers,
metadata_prefix='')
- self.assertIn(int(resp_meta['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp_meta['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp_meta, 'Container', 'POST')
# Trying to write the object without write rights
self.custom_object_client.auth_provider.set_alt_auth_data(
@@ -194,7 +193,7 @@
self.container_name,
object_name, 'data')
- @attr(type=['negative', 'smoke'])
+ @test.attr(type=['negative', 'smoke'])
def test_delete_object_without_write_rights(self):
# attempt to delete object using non-authorized user
# update X-Container-Read and X-Container-Write metadata ACL
@@ -204,7 +203,7 @@
resp_meta, body = self.container_client.update_container_metadata(
self.container_name, metadata=cont_headers,
metadata_prefix='')
- self.assertIn(int(resp_meta['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp_meta['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp_meta, 'Container', 'POST')
# create object
object_name = data_utils.rand_name(name='Object')
diff --git a/tempest/api/object_storage/test_container_services.py b/tempest/api/object_storage/test_container_services.py
index 84cc91e..8689d10 100644
--- a/tempest/api/object_storage/test_container_services.py
+++ b/tempest/api/object_storage/test_container_services.py
@@ -15,8 +15,7 @@
from tempest.api.object_storage import base
from tempest.common.utils import data_utils
-from tempest.test import attr
-from tempest.test import HTTP_SUCCESS
+from tempest import test
class ContainerTest(base.BaseObjectTest):
@@ -47,7 +46,7 @@
return object_name
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_create_container(self):
container_name = data_utils.rand_name(name='TestContainer')
resp, body = self.container_client.create_container(container_name)
@@ -55,7 +54,7 @@
self.assertIn(resp['status'], ('202', '201'))
self.assertHeaders(resp, 'Container', 'PUT')
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_create_container_overwrite(self):
# overwrite container with the same name
container_name = data_utils.rand_name(name='TestContainer')
@@ -66,7 +65,7 @@
self.assertIn(resp['status'], ('202', '201'))
self.assertHeaders(resp, 'Container', 'PUT')
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_create_container_with_metadata_key(self):
# create container with the blank value of metadata
container_name = data_utils.rand_name(name='TestContainer')
@@ -84,7 +83,7 @@
# in the server
self.assertNotIn('x-container-meta-test-container-meta', resp)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_create_container_with_metadata_value(self):
# create container with metadata value
container_name = data_utils.rand_name(name='TestContainer')
@@ -103,7 +102,7 @@
self.assertEqual(resp['x-container-meta-test-container-meta'],
metadata['test-container-meta'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_create_container_with_remove_metadata_key(self):
# create container with the blank value of remove metadata
container_name = data_utils.rand_name(name='TestContainer')
@@ -124,7 +123,7 @@
container_name)
self.assertNotIn('x-container-meta-test-container-meta', resp)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_create_container_with_remove_metadata_value(self):
# create container with remove metadata
container_name = data_utils.rand_name(name='TestContainer')
@@ -143,18 +142,18 @@
container_name)
self.assertNotIn('x-container-meta-test-container-meta', resp)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_delete_container(self):
# create a container
container_name = self._create_container()
# delete container
resp, _ = self.container_client.delete_container(container_name)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, 'Container', 'DELETE')
self.containers.remove(container_name)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_container_contents(self):
# get container contents list
container_name = self._create_container()
@@ -162,22 +161,22 @@
resp, object_list = self.container_client.list_container_contents(
container_name)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, 'Container', 'GET')
self.assertEqual(object_name, object_list.strip('\n'))
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_container_contents_with_no_object(self):
# get empty container contents list
container_name = self._create_container()
resp, object_list = self.container_client.list_container_contents(
container_name)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, 'Container', 'GET')
self.assertEqual('', object_list.strip('\n'))
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_container_contents_with_delimiter(self):
# get container contents list using delimiter param
container_name = self._create_container()
@@ -188,11 +187,11 @@
resp, object_list = self.container_client.list_container_contents(
container_name,
params=params)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, 'Container', 'GET')
self.assertEqual(object_name.split('/')[0], object_list.strip('/\n'))
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_container_contents_with_end_marker(self):
# get container contents list using end_marker param
container_name = self._create_container()
@@ -202,11 +201,11 @@
resp, object_list = self.container_client.list_container_contents(
container_name,
params=params)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, 'Container', 'GET')
self.assertEqual(object_name, object_list.strip('\n'))
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_container_contents_with_format_json(self):
# get container contents list using format_json param
container_name = self._create_container()
@@ -216,7 +215,7 @@
resp, object_list = self.container_client.list_container_contents(
container_name,
params=params)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, 'Container', 'GET')
self.assertIsNotNone(object_list)
@@ -226,7 +225,7 @@
self.assertTrue([c['content_type'] for c in object_list])
self.assertTrue([c['last_modified'] for c in object_list])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_container_contents_with_format_xml(self):
# get container contents list using format_xml param
container_name = self._create_container()
@@ -236,7 +235,7 @@
resp, object_list = self.container_client.list_container_contents(
container_name,
params=params)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, 'Container', 'GET')
self.assertIsNotNone(object_list)
@@ -251,7 +250,7 @@
self.assertEqual(object_list.find(".//last_modified").tag,
'last_modified')
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_container_contents_with_limit(self):
# get container contents list using limit param
container_name = self._create_container()
@@ -261,11 +260,11 @@
resp, object_list = self.container_client.list_container_contents(
container_name,
params=params)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, 'Container', 'GET')
self.assertEqual(object_name, object_list.strip('\n'))
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_container_contents_with_marker(self):
# get container contents list using marker param
container_name = self._create_container()
@@ -275,11 +274,11 @@
resp, object_list = self.container_client.list_container_contents(
container_name,
params=params)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, 'Container', 'GET')
self.assertEqual(object_name, object_list.strip('\n'))
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_container_contents_with_path(self):
# get container contents list using path param
container_name = self._create_container()
@@ -290,11 +289,11 @@
resp, object_list = self.container_client.list_container_contents(
container_name,
params=params)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, 'Container', 'GET')
self.assertEqual(object_name, object_list.strip('\n'))
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_container_contents_with_prefix(self):
# get container contents list using prefix param
container_name = self._create_container()
@@ -305,11 +304,11 @@
resp, object_list = self.container_client.list_container_contents(
container_name,
params=params)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, 'Container', 'GET')
self.assertEqual(object_name, object_list.strip('\n'))
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_container_metadata(self):
# List container metadata
container_name = self._create_container()
@@ -321,23 +320,23 @@
resp, _ = self.container_client.list_container_metadata(
container_name)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, 'Container', 'HEAD')
self.assertIn('x-container-meta-name', resp)
self.assertEqual(resp['x-container-meta-name'], metadata['name'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_no_container_metadata(self):
# HEAD container without metadata
container_name = self._create_container()
resp, _ = self.container_client.list_container_metadata(
container_name)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, 'Container', 'HEAD')
self.assertNotIn('x-container-meta-', str(resp))
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_update_container_metadata_with_create_and_delete_matadata(self):
# Send one request of adding and deleting metadata
container_name = data_utils.rand_name(name='TestContainer')
@@ -351,7 +350,7 @@
container_name,
metadata=metadata_2,
remove_metadata=metadata_1)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, 'Container', 'POST')
resp, _ = self.container_client.list_container_metadata(
@@ -361,7 +360,7 @@
self.assertEqual(resp['x-container-meta-test-container-meta2'],
metadata_2['test-container-meta2'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_update_container_metadata_with_create_metadata(self):
# update container metadata using add metadata
container_name = self._create_container()
@@ -370,7 +369,7 @@
resp, _ = self.container_client.update_container_metadata(
container_name,
metadata=metadata)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, 'Container', 'POST')
resp, _ = self.container_client.list_container_metadata(
@@ -379,7 +378,7 @@
self.assertEqual(resp['x-container-meta-test-container-meta1'],
metadata['test-container-meta1'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_update_container_metadata_with_delete_metadata(self):
# update container metadata using delete metadata
container_name = data_utils.rand_name(name='TestContainer')
@@ -391,14 +390,14 @@
resp, _ = self.container_client.delete_container_metadata(
container_name,
metadata=metadata)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, 'Container', 'POST')
resp, _ = self.container_client.list_container_metadata(
container_name)
self.assertNotIn('x-container-meta-test-container-meta1', resp)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_update_container_metadata_with_create_matadata_key(self):
# update container metadata with a blenk value of metadata
container_name = self._create_container()
@@ -407,14 +406,14 @@
resp, _ = self.container_client.update_container_metadata(
container_name,
metadata=metadata)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, 'Container', 'POST')
resp, _ = self.container_client.list_container_metadata(
container_name)
self.assertNotIn('x-container-meta-test-container-meta1', resp)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_update_container_metadata_with_delete_metadata_key(self):
# update container metadata with a blank value of matadata
container_name = data_utils.rand_name(name='TestContainer')
@@ -427,7 +426,7 @@
resp, _ = self.container_client.delete_container_metadata(
container_name,
metadata=metadata)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, 'Container', 'POST')
resp, _ = self.container_client.list_container_metadata(container_name)
diff --git a/tempest/api/object_storage/test_container_staticweb.py b/tempest/api/object_storage/test_container_staticweb.py
index 197e7fa..6c71340 100644
--- a/tempest/api/object_storage/test_container_staticweb.py
+++ b/tempest/api/object_storage/test_container_staticweb.py
@@ -49,6 +49,7 @@
cls.data.teardown_all()
super(StaticWebTest, cls).tearDownClass()
+ @test.requires_ext(extension='staticweb', service='object')
@test.attr('gate')
def test_web_index(self):
headers = {'web-index': self.object_name}
@@ -79,6 +80,7 @@
self.container_name)
self.assertNotIn('x-container-meta-web-index', body)
+ @test.requires_ext(extension='staticweb', service='object')
@test.attr('gate')
def test_web_listing(self):
headers = {'web-listings': 'true'}
@@ -110,6 +112,7 @@
self.container_name)
self.assertNotIn('x-container-meta-web-listings', body)
+ @test.requires_ext(extension='staticweb', service='object')
@test.attr('gate')
def test_web_listing_css(self):
headers = {'web-listings': 'true',
@@ -133,6 +136,7 @@
css = '<link rel="stylesheet" type="text/css" href="listings.css" />'
self.assertIn(css, body)
+ @test.requires_ext(extension='staticweb', service='object')
@test.attr('gate')
def test_web_error(self):
headers = {'web-listings': 'true',
diff --git a/tempest/api/object_storage/test_container_sync.py b/tempest/api/object_storage/test_container_sync.py
index 207fced..9bd986f 100644
--- a/tempest/api/object_storage/test_container_sync.py
+++ b/tempest/api/object_storage/test_container_sync.py
@@ -19,8 +19,7 @@
from tempest.api.object_storage import base
from tempest.common.utils import data_utils
from tempest import config
-from tempest.test import attr
-from tempest.test import HTTP_SUCCESS
+from tempest import test
CONF = config.CONF
@@ -66,7 +65,7 @@
cls.delete_containers(cls.containers, client[0], client[1])
super(ContainerSyncTest, cls).tearDownClass()
- @attr(type='slow')
+ @test.attr(type='slow')
def test_container_synchronization(self):
# container to container synchronization
# to allow/accept sync requests to/from other accounts
@@ -86,12 +85,12 @@
(client_base_url, str(cont[1]))}
resp, body = \
cont_client[0].put(str(cont[0]), body=None, headers=headers)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
# create object in container
object_name = data_utils.rand_name(name='TestSyncObject')
data = object_name[::-1] # data_utils.arbitrary_string()
resp, _ = obj_client[0].create_object(cont[0], object_name, data)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.objects.append(object_name)
# wait until container contents list is not empty
@@ -104,7 +103,7 @@
cont_client[client_index].\
list_container_contents(self.containers[client_index],
params=params)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
object_lists.append(dict(
(obj['name'], obj) for obj in object_list))
# check that containers are not empty and have equal keys()
@@ -124,5 +123,5 @@
for obj_client, cont in obj_clients:
for obj_name in object_lists[0]:
resp, object_content = obj_client.get_object(cont, obj_name)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertEqual(object_content, obj_name[::-1])
diff --git a/tempest/api/object_storage/test_healthcheck.py b/tempest/api/object_storage/test_healthcheck.py
index 35aee2a..e27c7ef 100644
--- a/tempest/api/object_storage/test_healthcheck.py
+++ b/tempest/api/object_storage/test_healthcheck.py
@@ -17,8 +17,7 @@
from tempest.api.object_storage import base
from tempest.common import custom_matchers
-from tempest.test import attr
-from tempest.test import HTTP_SUCCESS
+from tempest import test
class HealthcheckTest(base.BaseObjectTest):
@@ -32,13 +31,13 @@
# Turning http://.../v1/foobar into http://.../
self.account_client.skip_path()
- @attr('gate')
+ @test.attr('gate')
def test_get_healthcheck(self):
resp, _ = self.account_client.get("healthcheck", {})
# The status is expected to be 200
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
# The target of the request is not any Swift resource. Therefore, the
# existence of response header is checked without a custom matcher.
diff --git a/tempest/api/object_storage/test_object_expiry.py b/tempest/api/object_storage/test_object_expiry.py
index 3aae0a1..53ca20d 100644
--- a/tempest/api/object_storage/test_object_expiry.py
+++ b/tempest/api/object_storage/test_object_expiry.py
@@ -18,7 +18,7 @@
from tempest.api.object_storage import base
from tempest.common.utils import data_utils
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class ObjectExpiryTest(base.BaseObjectTest):
@@ -67,12 +67,12 @@
self.assertRaises(exceptions.NotFound, self.object_client.get_object,
self.container_name, self.object_name)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_object_after_expiry_time(self):
metadata = {'X-Delete-After': '3'}
self._test_object_expiry(metadata)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_object_at_expiry_time(self):
metadata = {'X-Delete-At': str(int(time.time()) + 3)}
self._test_object_expiry(metadata)
diff --git a/tempest/api/object_storage/test_object_formpost.py b/tempest/api/object_storage/test_object_formpost.py
index 6f46ec9..e0d15ac 100644
--- a/tempest/api/object_storage/test_object_formpost.py
+++ b/tempest/api/object_storage/test_object_formpost.py
@@ -21,8 +21,7 @@
from tempest.api.object_storage import base
from tempest.common.utils import data_utils
-from tempest.test import attr
-from tempest.test import HTTP_SUCCESS
+from tempest import test
class ObjectFormPostTest(base.BaseObjectTest):
@@ -93,7 +92,8 @@
content_type = 'multipart/form-data; boundary=%s' % boundary
return body, content_type
- @attr(type='gate')
+ @test.requires_ext(extension='formpost', service='object')
+ @test.attr(type='gate')
def test_post_object_using_form(self):
body, content_type = self.get_multipart_form()
@@ -107,12 +107,12 @@
# Use a raw request, otherwise authentication headers are used
resp, body = self.object_client.http_obj.request(url, "POST",
body, headers=headers)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, "Object", "POST")
# Ensure object is available
resp, body = self.object_client.get("%s/%s%s" % (
self.container_name, self.object_name, "testfile"))
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, "Object", "GET")
self.assertEqual(body, "hello world")
diff --git a/tempest/api/object_storage/test_object_formpost_negative.py b/tempest/api/object_storage/test_object_formpost_negative.py
index e02a058..a52c248 100644
--- a/tempest/api/object_storage/test_object_formpost_negative.py
+++ b/tempest/api/object_storage/test_object_formpost_negative.py
@@ -20,7 +20,7 @@
from tempest.api.object_storage import base
from tempest.common.utils import data_utils
-from tempest.test import attr
+from tempest import test
class ObjectFormPostNegativeTest(base.BaseObjectTest):
@@ -91,7 +91,8 @@
content_type = 'multipart/form-data; boundary=%s' % boundary
return body, content_type
- @attr(type=['gate', 'negative'])
+ @test.requires_ext(extension='formpost', service='object')
+ @test.attr(type=['gate', 'negative'])
def test_post_object_using_form_expired(self):
body, content_type = self.get_multipart_form(expires=1)
time.sleep(2)
diff --git a/tempest/api/object_storage/test_object_services.py b/tempest/api/object_storage/test_object_services.py
index 6f349b6..91df292 100644
--- a/tempest/api/object_storage/test_object_services.py
+++ b/tempest/api/object_storage/test_object_services.py
@@ -14,12 +14,12 @@
# under the License.
import hashlib
+from six import moves
from tempest.api.object_storage import base
from tempest.common import custom_matchers
from tempest.common.utils import data_utils
-from tempest.test import attr
-from tempest.test import HTTP_SUCCESS
+from tempest import test
class ObjectTest(base.BaseObjectTest):
@@ -35,7 +35,7 @@
cls.delete_containers(cls.containers)
super(ObjectTest, cls).tearDownClass()
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_create_object(self):
# create object
object_name = data_utils.rand_name(name='TestObject')
@@ -50,7 +50,7 @@
self.assertEqual(resp['status'], '201')
self.assertHeaders(resp, 'Object', 'PUT')
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_delete_object(self):
# create object
object_name = data_utils.rand_name(name='TestObject')
@@ -60,10 +60,10 @@
# delete object
resp, _ = self.object_client.delete_object(self.container_name,
object_name)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, 'Object', 'DELETE')
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_object_metadata(self):
# add metadata to storage object, test if metadata is retrievable
@@ -78,20 +78,20 @@
orig_metadata = {meta_key: meta_value}
resp, _ = self.object_client.update_object_metadata(
self.container_name, object_name, orig_metadata)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, 'Object', 'POST')
# get object metadata
resp, resp_metadata = self.object_client.list_object_metadata(
self.container_name, object_name)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, 'Object', 'HEAD')
actual_meta_key = 'x-object-meta-' + meta_key
self.assertIn(actual_meta_key, resp)
self.assertEqual(resp[actual_meta_key], meta_value)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_get_object(self):
# retrieve object's data (in response body)
@@ -103,12 +103,12 @@
# get object
resp, body = self.object_client.get_object(self.container_name,
object_name)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, 'Object', 'GET')
self.assertEqual(body, data)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_copy_object_in_same_container(self):
# create source object
src_object_name = data_utils.rand_name(name='SrcObject')
@@ -135,7 +135,7 @@
dst_object_name)
self.assertEqual(body, src_data)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_copy_object_to_itself(self):
# change the content type of an existing object
@@ -160,7 +160,7 @@
object_name)
self.assertEqual(resp['content-type'], metadata['content-type'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_copy_object_2d_way(self):
# create source object
src_object_name = data_utils.rand_name(name='SrcObject')
@@ -195,7 +195,7 @@
dst_object_name)
self.assertEqual(body, src_data)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_copy_object_across_containers(self):
# create a container to use as asource container
src_container_name = data_utils.rand_name(name='TestSourceContainer')
@@ -219,7 +219,7 @@
resp, _ = self.object_client.update_object_metadata(src_container_name,
object_name,
orig_metadata)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, 'Object', 'POST')
# copy object from source container to destination container
@@ -237,15 +237,15 @@
self.assertIn(actual_meta_key, resp)
self.assertEqual(resp[actual_meta_key], meta_value)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_object_upload_in_segments(self):
# create object
object_name = data_utils.rand_name(name='LObject')
data = data_utils.arbitrary_string()
segments = 10
- data_segments = [data + str(i) for i in xrange(segments)]
+ data_segments = [data + str(i) for i in moves.xrange(segments)]
# uploading segments
- for i in xrange(segments):
+ for i in moves.xrange(segments):
resp, _ = self.object_client.create_object_segments(
self.container_name, object_name, i, data_segments[i])
self.assertEqual(resp['status'], '201')
@@ -280,7 +280,7 @@
self.container_name, object_name)
self.assertEqual(''.join(data_segments), body)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_object_if_different(self):
# http://en.wikipedia.org/wiki/HTTP_ETag
# Make a conditional request for an object using the If-None-Match
@@ -312,7 +312,7 @@
md5 = hashlib.md5(local_data).hexdigest()
headers = {'If-None-Match': md5}
resp, body = self.object_client.get(url, headers=headers)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, 'Object', 'GET')
@@ -326,7 +326,7 @@
self.delete_containers([self.container_name])
super(PublicObjectTest, self).tearDown()
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_access_public_container_object_without_using_creds(self):
# make container public-readable and access an object in it object
# anonymously, without using credentials
@@ -335,7 +335,7 @@
cont_headers = {'X-Container-Read': '.r:*,.rlistings'}
resp_meta, body = self.container_client.update_container_metadata(
self.container_name, metadata=cont_headers, metadata_prefix='')
- self.assertIn(int(resp_meta['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp_meta['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp_meta, 'Container', 'POST')
# create object
@@ -350,7 +350,7 @@
# list container metadata
resp_meta, _ = self.container_client.list_container_metadata(
self.container_name)
- self.assertIn(int(resp_meta['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp_meta['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp_meta, 'Container', 'HEAD')
self.assertIn('x-container-read', resp_meta)
@@ -367,7 +367,7 @@
self.assertEqual(body, data)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_access_public_object_with_another_user_creds(self):
# make container public-readable and access an object in it using
# another user's credentials
@@ -375,7 +375,7 @@
resp_meta, body = self.container_client.update_container_metadata(
self.container_name, metadata=cont_headers,
metadata_prefix='')
- self.assertIn(int(resp_meta['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp_meta['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp_meta, 'Container', 'POST')
# create object
@@ -390,7 +390,7 @@
# list container metadata
resp, _ = self.container_client.list_container_metadata(
self.container_name)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, 'Container', 'HEAD')
self.assertIn('x-container-read', resp)
diff --git a/tempest/api/object_storage/test_object_temp_url.py b/tempest/api/object_storage/test_object_temp_url.py
index 47c270e..c597255 100644
--- a/tempest/api/object_storage/test_object_temp_url.py
+++ b/tempest/api/object_storage/test_object_temp_url.py
@@ -40,9 +40,9 @@
# update account metadata
cls.key = 'Meta'
cls.metadatas = []
- cls.metadata = {'Temp-URL-Key': cls.key}
- cls.metadatas.append(cls.metadata)
- cls.account_client.create_account_metadata(metadata=cls.metadata)
+ metadata = {'Temp-URL-Key': cls.key}
+ cls.metadatas.append(metadata)
+ cls.account_client.create_account_metadata(metadata=metadata)
# create an object
cls.object_name = data_utils.rand_name(name='ObjectTemp')
@@ -53,7 +53,7 @@
@classmethod
def tearDownClass(cls):
- for metadata in cls.metadata:
+ for metadata in cls.metadatas:
cls.account_client.delete_account_metadata(
metadata=metadata)
diff --git a/tempest/api/object_storage/test_object_version.py b/tempest/api/object_storage/test_object_version.py
index 75293d2..8d2ff9b 100644
--- a/tempest/api/object_storage/test_object_version.py
+++ b/tempest/api/object_storage/test_object_version.py
@@ -15,7 +15,7 @@
from tempest.api.object_storage import base
from tempest.common.utils import data_utils
-from tempest.test import attr
+from tempest import test
class ContainerTest(base.BaseObjectTest):
@@ -40,7 +40,7 @@
header_value = resp.get('x-versions-location', 'Missing Header')
self.assertEqual(header_value, versioned)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_versioned_container(self):
# create container
vers_container_name = data_utils.rand_name(name='TestVersionContainer')
diff --git a/tempest/api/orchestration/stacks/test_neutron_resources.py b/tempest/api/orchestration/stacks/test_neutron_resources.py
index 243c3ce..18ba37b 100644
--- a/tempest/api/orchestration/stacks/test_neutron_resources.py
+++ b/tempest/api/orchestration/stacks/test_neutron_resources.py
@@ -17,6 +17,7 @@
from tempest import clients
from tempest.common.utils import data_utils
from tempest import config
+from tempest import exceptions
from tempest.test import attr
CONF = config.CONF
@@ -28,25 +29,28 @@
_interface = 'json'
template = """
-HeatTemplateFormatVersion: '2012-12-12'
-Description: |
+heat_template_version: '2013-05-23'
+description: |
Template which creates single EC2 instance
-Parameters:
+parameters:
KeyName:
- Type: String
+ type: string
InstanceType:
- Type: String
+ type: string
ImageId:
- Type: String
+ type: string
ExternalRouterId:
- Type: String
-Resources:
+ type: string
+ ExternalNetworkId:
+ type: string
+resources:
Network:
- Type: OS::Quantum::Net
- Properties: {name: NewNetwork}
+ type: OS::Neutron::Net
+ properties:
+ name: NewNetwork
Subnet:
- Type: OS::Quantum::Subnet
- Properties:
+ type: OS::Neutron::Subnet
+ properties:
network_id: {Ref: Network}
name: NewSubnet
ip_version: 4
@@ -54,39 +58,44 @@
dns_nameservers: ["8.8.8.8"]
allocation_pools:
- {end: 10.0.3.150, start: 10.0.3.20}
+ Router:
+ type: OS::Neutron::Router
+ properties:
+ name: NewRouter
+ admin_state_up: false
+ external_gateway_info:
+ network: {get_param: ExternalNetworkId}
+ enable_snat: false
RouterInterface:
- Type: OS::Quantum::RouterInterface
- Properties:
- router_id: {Ref: ExternalRouterId}
- subnet_id: {Ref: Subnet}
+ type: OS::Neutron::RouterInterface
+ properties:
+ router_id: {get_param: ExternalRouterId}
+ subnet_id: {get_resource: Subnet}
Server:
- Type: AWS::EC2::Instance
- Metadata:
- Name: SmokeServer
- Properties:
- ImageId: {Ref: ImageId}
- InstanceType: {Ref: InstanceType}
- KeyName: {Ref: KeyName}
- SubnetId: {Ref: Subnet}
+ type: AWS::EC2::Instance
+ metadata:
+ Name: SmokeServerNeutron
+ properties:
+ ImageId: {get_param: ImageId}
+ InstanceType: {get_param: InstanceType}
+ KeyName: {get_param: KeyName}
+ SubnetId: {get_resource: Subnet}
UserData:
- Fn::Base64:
- Fn::Join:
- - ''
- - - '#!/bin/bash -v
+ str_replace:
+ template: |
+ #!/bin/bash -v
- '
- - /opt/aws/bin/cfn-signal -e 0 -r "SmokeServer created" '
- - {Ref: WaitHandle}
- - '''
-
- '
- WaitHandle:
- Type: AWS::CloudFormation::WaitConditionHandle
+ /opt/aws/bin/cfn-signal -e 0 -r "SmokeServerNeutron created" \
+ 'wait_handle'
+ params:
+ wait_handle: {get_resource: WaitHandleNeutron}
+ WaitHandleNeutron:
+ type: AWS::CloudFormation::WaitConditionHandle
WaitCondition:
- Type: AWS::CloudFormation::WaitCondition
- DependsOn: Server
- Properties:
- Handle: {Ref: WaitHandle}
+ type: AWS::CloudFormation::WaitCondition
+ depends_on: Server
+ properties:
+ Handle: {get_resource: WaitHandleNeutron}
Timeout: '600'
"""
@@ -104,6 +113,7 @@
cls.keypair_name = (CONF.orchestration.keypair_name or
cls._create_keypair()['name'])
cls.external_router_id = cls._get_external_router_id()
+ cls.external_network_id = CONF.network.public_network_id
# create the stack
cls.stack_identifier = cls.create_stack(
@@ -113,11 +123,26 @@
'KeyName': cls.keypair_name,
'InstanceType': CONF.orchestration.instance_type,
'ImageId': CONF.orchestration.image_ref,
- 'ExternalRouterId': cls.external_router_id
+ 'ExternalRouterId': cls.external_router_id,
+ 'ExternalNetworkId': cls.external_network_id
})
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)
+ try:
+ cls.client.wait_for_stack_status(cls.stack_id, 'CREATE_COMPLETE')
+ _, resources = cls.client.list_resources(cls.stack_identifier)
+ except exceptions.TimeoutException as e:
+ # attempt to log the server console to help with debugging
+ # the cause of the server not signalling the waitcondition
+ # to heat.
+ resp, body = cls.client.get_resource(cls.stack_identifier,
+ 'Server')
+ server_id = body['physical_resource_id']
+ LOG.debug('Console output for %s', server_id)
+ resp, output = cls.servers_client.get_console_output(
+ server_id, None)
+ LOG.debug(output)
+ raise e
+
cls.test_resources = {}
for resource in resources:
cls.test_resources[resource['logical_resource_id']] = resource
@@ -133,9 +158,9 @@
@attr(type='slow')
def test_created_resources(self):
"""Verifies created neutron resources."""
- resources = [('Network', 'OS::Quantum::Net'),
- ('Subnet', 'OS::Quantum::Subnet'),
- ('RouterInterface', 'OS::Quantum::RouterInterface'),
+ resources = [('Network', 'OS::Neutron::Net'),
+ ('Subnet', 'OS::Neutron::Subnet'),
+ ('RouterInterface', 'OS::Neutron::RouterInterface'),
('Server', 'AWS::EC2::Instance')]
for resource_name, resource_type in resources:
resource = self.test_resources.get(resource_name, None)
@@ -173,6 +198,20 @@
self.assertEqual('10.0.3.0/24', subnet['cidr'])
@attr(type='slow')
+ def test_created_router(self):
+ """Verifies created router."""
+ router_id = self.test_resources.get('Router')['physical_resource_id']
+ resp, body = self.network_client.show_router(router_id)
+ self.assertEqual('200', resp['status'])
+ router = body['router']
+ self.assertEqual('NewRouter', router['name'])
+ self.assertEqual(self.external_network_id,
+ router['external_gateway_info']['network_id'])
+ self.assertEqual(False,
+ router['external_gateway_info']['enable_snat'])
+ self.assertEqual(False, router['admin_state_up'])
+
+ @attr(type='slow')
def test_created_router_interface(self):
"""Verifies created router interface."""
network_id = self.test_resources.get('Network')['physical_resource_id']
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 4267c1d..95deaf5 100644
--- a/tempest/api/orchestration/stacks/test_server_cfn_init.py
+++ b/tempest/api/orchestration/stacks/test_server_cfn_init.py
@@ -15,10 +15,11 @@
from tempest.api.orchestration import base
from tempest.common.utils import data_utils
-from tempest.common.utils.linux.remote_client import RemoteClient
+from tempest.common.utils.linux import remote_client
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
LOG = logging.getLogger(__name__)
@@ -66,18 +67,13 @@
content: smoke test complete
/etc/cfn/cfn-credentials:
content:
- Fn::Join:
- - ''
- - - AWSAccessKeyId=
- - {Ref: SmokeKeys}
- - '
-
- '
- - AWSSecretKey=
- - Fn::GetAtt: [SmokeKeys, SecretAccessKey]
- - '
-
- '
+ Fn::Replace:
+ - SmokeKeys: {Ref: SmokeKeys}
+ SecretAccessKey:
+ 'Fn::GetAtt': [SmokeKeys, SecretAccessKey]
+ - |
+ AWSAccessKeyId=SmokeKeys
+ AWSSecretKey=SecretAccessKey
mode: '000400'
owner: root
group: root
@@ -90,19 +86,13 @@
networks:
- uuid: {Ref: network}
user_data:
- Fn::Base64:
- Fn::Join:
- - ''
- - - |-
- #!/bin/bash -v
- /opt/aws/bin/cfn-init
- - |-
- || error_exit ''Failed to run cfn-init''
- /opt/aws/bin/cfn-signal -e 0 --data "`cat /tmp/smoke-status`" '
- - {Ref: WaitHandle}
- - '''
-
- '
+ Fn::Replace:
+ - WaitHandle: {Ref: WaitHandle}
+ - |
+ #!/bin/bash -v
+ /opt/aws/bin/cfn-init
+ /opt/aws/bin/cfn-signal -e 0 --data "`cat /tmp/smoke-status`" \
+ "WaitHandle"
WaitHandle:
Type: AWS::CloudFormation::WaitConditionHandle
WaitCondition:
@@ -147,15 +137,15 @@
'network': cls._get_default_network()['id']
})
- @attr(type='slow')
+ @test.attr(type='slow')
@testtools.skipIf(existing_keypair, 'Server ssh tests are disabled.')
def test_can_log_into_created_server(self):
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'])
@@ -166,14 +156,38 @@
body['physical_resource_id'])
# Check that the user can authenticate with the generated password
- linux_client = RemoteClient(server, 'ec2-user',
- pkey=self.keypair['private_key'])
+ linux_client = remote_client.RemoteClient(server, 'ec2-user',
+ pkey=self.keypair[
+ 'private_key'])
linux_client.validate_authentication()
- @attr(type='slow')
- def test_stack_wait_condition_data(self):
-
+ @test.attr(type='slow')
+ def test_all_resources_created(self):
sid = self.stack_identifier
+ self.client.wait_for_resource_status(
+ sid, 'WaitHandle', 'CREATE_COMPLETE')
+ self.client.wait_for_resource_status(
+ sid, 'SmokeSecurityGroup', 'CREATE_COMPLETE')
+ self.client.wait_for_resource_status(
+ sid, 'SmokeKeys', 'CREATE_COMPLETE')
+ self.client.wait_for_resource_status(
+ sid, 'CfnUser', 'CREATE_COMPLETE')
+ self.client.wait_for_resource_status(
+ sid, 'SmokeServer', 'CREATE_COMPLETE')
+ try:
+ self.client.wait_for_resource_status(
+ sid, 'WaitCondition', 'CREATE_COMPLETE')
+ except exceptions.TimeoutException as e:
+ # attempt to log the server console to help with debugging
+ # the cause of the server not signalling the waitcondition
+ # to heat.
+ resp, body = self.client.get_resource(sid, 'SmokeServer')
+ server_id = body['physical_resource_id']
+ LOG.debug('Console output for %s', server_id)
+ resp, output = self.servers_client.get_console_output(
+ server_id, None)
+ LOG.debug(output)
+ raise e
# wait for create to complete.
self.client.wait_for_stack_status(sid, 'CREATE_COMPLETE')
diff --git a/tempest/api/orchestration/stacks/test_swift_resources.py b/tempest/api/orchestration/stacks/test_swift_resources.py
new file mode 100644
index 0000000..713cfd4
--- /dev/null
+++ b/tempest/api/orchestration/stacks/test_swift_resources.py
@@ -0,0 +1,125 @@
+# -*- coding: utf-8 -*-
+# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
+#
+# Author: Chmouel Boudjnah <chmouel@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.orchestration import base
+from tempest import clients
+from tempest.common.utils import data_utils
+from tempest import config
+
+
+CONF = config.CONF
+
+
+class SwiftResourcesTestJSON(base.BaseOrchestrationTest):
+ _interface = 'json'
+ template = """
+heat_template_version: 2013-05-23
+description: Template which creates a Swift container resource
+
+resources:
+ SwiftContainerWebsite:
+ deletion_policy: "Delete"
+ type: OS::Swift::Container
+ properties:
+ X-Container-Read: ".r:*"
+ X-Container-Meta:
+ web-index: "index.html"
+ web-error: "error.html"
+
+ SwiftContainer:
+ type: OS::Swift::Container
+
+outputs:
+ WebsiteURL:
+ description: "URL for website hosted on S3"
+ value: { get_attr: [SwiftContainer, WebsiteURL] }
+ DomainName:
+ description: "Domain of Swift host"
+ value: { get_attr: [SwiftContainer, DomainName] }
+
+"""
+
+ @classmethod
+ def setUpClass(cls):
+ super(SwiftResourcesTestJSON, cls).setUpClass()
+ cls.client = cls.orchestration_client
+ cls.stack_name = data_utils.rand_name('heat')
+ os = clients.Manager()
+ if not CONF.service_available.swift:
+ raise cls.skipException("Swift support is required")
+ cls.account_client = os.account_client
+ cls.container_client = os.container_client
+ # create the stack
+ cls.stack_identifier = cls.create_stack(
+ cls.stack_name,
+ cls.template)
+ cls.stack_id = cls.stack_identifier.split('/')[1]
+ cls.client.wait_for_stack_status(cls.stack_id, 'CREATE_COMPLETE')
+ cls.test_resources = {}
+ _, resources = cls.client.list_resources(cls.stack_identifier)
+ for resource in resources:
+ cls.test_resources[resource['logical_resource_id']] = resource
+
+ def test_created_resources(self):
+ """Created stack should be on the list of existing stacks."""
+ resources = [('SwiftContainer', 'OS::Swift::Container'),
+ ('SwiftContainerWebsite', 'OS::Swift::Container')]
+ for resource_name, resource_type in resources:
+ resource = self.test_resources.get(resource_name)
+ self.assertIsInstance(resource, dict)
+ self.assertEqual(resource_type, resource['resource_type'])
+ self.assertEqual(resource_name, resource['logical_resource_id'])
+ self.assertEqual('CREATE_COMPLETE', resource['resource_status'])
+
+ def test_created_containers(self):
+ params = {'format': 'json'}
+ resp, container_list = \
+ self.account_client.list_account_containers(params=params)
+ self.assertEqual('200', resp['status'])
+ self.assertEqual(2, len(container_list))
+ for cont in container_list:
+ self.assertTrue(cont['name'].startswith(self.stack_name))
+
+ def test_acl(self):
+ acl_headers = ('x-container-meta-web-index', 'x-container-read')
+
+ swcont = self.test_resources.get(
+ 'SwiftContainer')['physical_resource_id']
+ swcont_website = self.test_resources.get(
+ 'SwiftContainerWebsite')['physical_resource_id']
+
+ headers, _ = self.container_client.list_container_metadata(swcont)
+ for h in acl_headers:
+ self.assertNotIn(h, headers)
+ headers, _ = self.container_client.list_container_metadata(
+ swcont_website)
+ for h in acl_headers:
+ self.assertIn(h, headers)
+
+ def test_metadata(self):
+ metadatas = {
+ "web-index": "index.html",
+ "web-error": "error.html"
+ }
+ swcont_website = self.test_resources.get(
+ 'SwiftContainerWebsite')['physical_resource_id']
+ headers, _ = self.container_client.list_container_metadata(
+ swcont_website)
+
+ for meta in metadatas:
+ header_meta = "x-container-meta-%s" % meta
+ self.assertIn(header_meta, headers)
+ self.assertEqual(headers[header_meta], metadatas[meta])
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/telemetry/base.py b/tempest/api/telemetry/base.py
index 1f661a6..c4614c6 100644
--- a/tempest/api/telemetry/base.py
+++ b/tempest/api/telemetry/base.py
@@ -10,7 +10,9 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest.common.utils import data_utils
from tempest import config
+from tempest import exceptions
import tempest.test
CONF = config.CONF
@@ -22,6 +24,28 @@
@classmethod
def setUpClass(cls):
- super(BaseTelemetryTest, cls).setUpClass()
if not CONF.service_available.ceilometer:
raise cls.skipException("Ceilometer support is required")
+ super(BaseTelemetryTest, cls).setUpClass()
+ os = cls.get_client_manager()
+ cls.telemetry_client = os.telemetry_client
+ cls.alarm_ids = []
+
+ @classmethod
+ def create_alarm(cls, **kwargs):
+ resp, body = cls.telemetry_client.create_alarm(
+ name=data_utils.rand_name('telemetry_alarm'),
+ type='threshold', **kwargs)
+ if resp['status'] == '201':
+ cls.alarm_ids.append(body['alarm_id'])
+ return resp, body
+
+ @classmethod
+ def tearDownClass(cls):
+ for alarm_id in cls.alarm_ids:
+ try:
+ cls.telemetry_client.delete_alarm(alarm_id)
+ except exceptions.NotFound:
+ pass
+ cls.clear_isolated_creds()
+ super(BaseTelemetryTest, cls).tearDownClass()
diff --git a/tempest/api/telemetry/test_telemetry_alarming_api.py b/tempest/api/telemetry/test_telemetry_alarming_api.py
new file mode 100644
index 0000000..907d3d0
--- /dev/null
+++ b/tempest/api/telemetry/test_telemetry_alarming_api.py
@@ -0,0 +1,43 @@
+# 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.telemetry import base
+from tempest import exceptions
+from tempest.test import attr
+
+
+class TelemetryAlarmingAPITestJSON(base.BaseTelemetryTest):
+ _interface = 'json'
+
+ @attr(type="gate")
+ def test_alarm_list(self):
+ resp, _ = self.telemetry_client.list_alarms()
+ self.assertEqual(int(resp['status']), 200)
+
+ @attr(type="gate")
+ def test_create_alarm(self):
+ rules = {'meter_name': 'cpu_util',
+ 'comparison_operator': 'gt',
+ 'threshold': 80.0,
+ 'period': 70}
+ resp, body = self.create_alarm(threshold_rule=rules)
+ self.alarm_id = body['alarm_id']
+ self.assertEqual(int(resp['status']), 201)
+ self.assertDictContainsSubset(rules, body['threshold_rule'])
+ resp, body = self.telemetry_client.get_alarm(self.alarm_id)
+ self.assertEqual(int(resp['status']), 200)
+ self.assertDictContainsSubset(rules, body['threshold_rule'])
+ resp, _ = self.telemetry_client.delete_alarm(self.alarm_id)
+ self.assertEqual(int(resp['status']), 204)
+ self.assertRaises(exceptions.NotFound,
+ self.telemetry_client.get_alarm,
+ self.alarm_id)
diff --git a/tempest/api/utils.py b/tempest/api/utils.py
index c62dc8d..00c93b7 100644
--- a/tempest/api/utils.py
+++ b/tempest/api/utils.py
@@ -15,7 +15,7 @@
"""Common utilities used in testing."""
-from tempest.test import BaseTestCase
+from tempest import test
class skip_unless_attr(object):
@@ -30,7 +30,7 @@
"""Wrapped skipper function."""
testobj = args[0]
if not getattr(testobj, self.attr, False):
- raise BaseTestCase.skipException(self.message)
+ raise test.BaseTestCase.skipException(self.message)
func(*args, **kw)
_skipper.__name__ = func.__name__
_skipper.__doc__ = func.__doc__
diff --git a/tempest/api/volume/admin/test_multi_backend.py b/tempest/api/volume/admin/test_multi_backend.py
index cb1a6cb..6178a1c 100644
--- a/tempest/api/volume/admin/test_multi_backend.py
+++ b/tempest/api/volume/admin/test_multi_backend.py
@@ -14,9 +14,7 @@
from tempest.common.utils import data_utils
from tempest import config
from tempest.openstack.common import log as logging
-from tempest.services.volume.json.admin import volume_types_client
-from tempest.services.volume.json import volumes_client
-from tempest.test import attr
+from tempest import test
CONF = config.CONF
@@ -36,20 +34,7 @@
cls.backend1_name = CONF.volume.backend1_name
cls.backend2_name = CONF.volume.backend2_name
- adm_user = CONF.identity.admin_username
- adm_pass = CONF.identity.admin_password
- adm_tenant = CONF.identity.admin_tenant_name
- auth_url = CONF.identity.uri
-
- cls.volume_client = volumes_client.VolumesClientJSON(adm_user,
- adm_pass,
- auth_url,
- adm_tenant)
- cls.type_client = volume_types_client.VolumeTypesClientJSON(adm_user,
- adm_pass,
- auth_url,
- adm_tenant)
-
+ cls.volume_client = cls.os_adm.volumes_client
cls.volume_type_id_list = []
cls.volume_id_list = []
try:
@@ -57,7 +42,7 @@
type1_name = data_utils.rand_name('Type-')
vol1_name = data_utils.rand_name('Volume-')
extra_specs1 = {"volume_backend_name": cls.backend1_name}
- resp, cls.type1 = cls.type_client.create_volume_type(
+ resp, cls.type1 = cls.client.create_volume_type(
type1_name, extra_specs=extra_specs1)
cls.volume_type_id_list.append(cls.type1['id'])
@@ -72,7 +57,7 @@
type2_name = data_utils.rand_name('Type-')
vol2_name = data_utils.rand_name('Volume-')
extra_specs2 = {"volume_backend_name": cls.backend2_name}
- resp, cls.type2 = cls.type_client.create_volume_type(
+ resp, cls.type2 = cls.client.create_volume_type(
type2_name, extra_specs=extra_specs2)
cls.volume_type_id_list.append(cls.type2['id'])
@@ -97,11 +82,11 @@
# volume types deletion
volume_type_id_list = getattr(cls, 'volume_type_id_list', [])
for volume_type_id in volume_type_id_list:
- cls.type_client.delete_volume_type(volume_type_id)
+ cls.client.delete_volume_type(volume_type_id)
super(VolumeMultiBackendTest, cls).tearDownClass()
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_backend_name_reporting(self):
# this test checks if os-vol-attr:host is populated correctly after
# the multi backend feature has been enabled
@@ -115,7 +100,7 @@
self.volume1['id'])
self.assertTrue(len(volume1_host.split("@")) > 1, msg)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_backend_name_distinction(self):
# this test checks that the two volumes created at setUp don't
# belong to the same backend (if they are, than the
diff --git a/tempest/api/volume/admin/test_snapshots_actions.py b/tempest/api/volume/admin/test_snapshots_actions.py
index 12fda92..594c703 100644
--- a/tempest/api/volume/admin/test_snapshots_actions.py
+++ b/tempest/api/volume/admin/test_snapshots_actions.py
@@ -15,13 +15,14 @@
from tempest.api.volume import base
from tempest.common.utils import data_utils
-from tempest.test import attr
+from tempest import test
class SnapshotsActionsTest(base.BaseVolumeV1AdminTest):
_interface = "json"
@classmethod
+ @test.safe_setup
def setUpClass(cls):
super(SnapshotsActionsTest, cls).setUpClass()
cls.client = cls.snapshots_client
@@ -80,7 +81,7 @@
def _get_progress_alias(self):
return 'os-extended-snapshot-attributes:progress'
- @attr(type='gate')
+ @test.attr(type='gate')
def test_reset_snapshot_status(self):
# Reset snapshot status to creating
status = 'creating'
@@ -92,7 +93,7 @@
self.assertEqual(200, resp_get.status)
self.assertEqual(status, snapshot_get['status'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_update_snapshot_status(self):
# Reset snapshot status to creating
status = 'creating'
@@ -112,22 +113,22 @@
self.assertEqual(status, snapshot_get['status'])
self.assertEqual(progress, snapshot_get[progress_alias])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_snapshot_force_delete_when_snapshot_is_creating(self):
# test force delete when status of snapshot is creating
self._create_reset_and_force_delete_temp_snapshot('creating')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_snapshot_force_delete_when_snapshot_is_deleting(self):
# test force delete when status of snapshot is deleting
self._create_reset_and_force_delete_temp_snapshot('deleting')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_snapshot_force_delete_when_snapshot_is_error(self):
# test force delete when status of snapshot is error
self._create_reset_and_force_delete_temp_snapshot('error')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_snapshot_force_delete_when_snapshot_is_error_deleting(self):
# test force delete when status of snapshot is error_deleting
self._create_reset_and_force_delete_temp_snapshot('error_deleting')
diff --git a/tempest/api/volume/admin/test_volume_hosts.py b/tempest/api/volume/admin/test_volume_hosts.py
index 5c311e1..01ba915 100644
--- a/tempest/api/volume/admin/test_volume_hosts.py
+++ b/tempest/api/volume/admin/test_volume_hosts.py
@@ -14,13 +14,13 @@
# under the License.
from tempest.api.volume import base
-from tempest.test import attr
+from tempest import test
class VolumeHostsAdminTestsJSON(base.BaseVolumeV1AdminTest):
_interface = "json"
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_hosts(self):
resp, hosts = self.hosts_client.list_hosts()
self.assertEqual(200, resp.status)
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..2949d56
--- /dev/null
+++ b/tempest/api/volume/admin/test_volume_quotas.py
@@ -0,0 +1,105 @@
+# 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"
+ force_tenant_isolation = True
+
+ @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)
+
+ cleanup_quota_set = dict(
+ (k, v) for k, v in default_quota_set.iteritems()
+ if k in QUOTA_KEYS)
+ self.addCleanup(self.quotas_client.update_quota_set,
+ self.demo_tenant_id, **cleanup_quota_set)
+ self.assertEqual(200, resp.status)
+ # test that the specific values we set are actually in
+ # the final result. There is nothing here that ensures there
+ # would be no other values in there.
+ self.assertDictContainsSubset(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_volume_types.py b/tempest/api/volume/admin/test_volume_types.py
index d481251..ee1d09a 100644
--- a/tempest/api/volume/admin/test_volume_types.py
+++ b/tempest/api/volume/admin/test_volume_types.py
@@ -16,7 +16,7 @@
from tempest.api.volume 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
@@ -33,14 +33,14 @@
resp, _ = self.client.delete_volume_type(volume_type_id)
self.assertEqual(202, resp.status)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_volume_type_list(self):
# List Volume types.
resp, body = self.client.list_volume_types()
self.assertEqual(200, resp.status)
self.assertIsInstance(body, list)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_create_get_delete_volume_with_volume_type_and_extra_specs(self):
# Create/get/delete volume with volume_type and extra spec.
volume = {}
@@ -84,7 +84,7 @@
'The fetched Volume is different '
'from the created Volume')
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_volume_type_create_get_delete(self):
# Create/get volume type.
body = {}
@@ -116,3 +116,35 @@
self.assertEqual(extra_specs, fetched_volume_type['extra_specs'],
'The fetched Volume_type is different '
'from the created Volume_type')
+
+ @test.attr(type='smoke')
+ def test_volume_type_encryption_create_get(self):
+ # Create/get encryption type.
+ provider = "LuksEncryptor"
+ control_location = "front-end"
+ name = data_utils.rand_name("volume-type-")
+ resp, body = self.client.create_volume_type(name)
+ self.assertEqual(200, resp.status)
+ self.addCleanup(self._delete_volume_type, body['id'])
+ resp, encryption_type = self.client.create_encryption_type(
+ body['id'], provider=provider,
+ control_location=control_location)
+ self.assertEqual(200, resp.status)
+ self.assertIn('volume_type_id', encryption_type)
+ self.assertEqual(provider, encryption_type['provider'],
+ "The created encryption_type provider is not equal "
+ "to the requested provider")
+ self.assertEqual(control_location, encryption_type['control_location'],
+ "The created encryption_type control_location is not "
+ "equal to the requested control_location")
+ resp, fetched_encryption_type = self.client.get_encryption_type(
+ encryption_type['volume_type_id'])
+ self.assertEqual(200, resp.status)
+ self.assertEqual(provider,
+ fetched_encryption_type['provider'],
+ 'The fetched encryption_type provider is different '
+ 'from the created encryption_type')
+ self.assertEqual(control_location,
+ fetched_encryption_type['control_location'],
+ 'The fetched encryption_type control_location is '
+ 'different from the created encryption_type')
diff --git a/tempest/api/volume/admin/test_volume_types_extra_specs.py b/tempest/api/volume/admin/test_volume_types_extra_specs.py
index 99a0826..06a0b34 100644
--- a/tempest/api/volume/admin/test_volume_types_extra_specs.py
+++ b/tempest/api/volume/admin/test_volume_types_extra_specs.py
@@ -15,7 +15,7 @@
from tempest.api.volume import base
from tempest.common.utils import data_utils
-from tempest.test import attr
+from tempest import test
class VolumeTypesExtraSpecsTest(base.BaseVolumeV1AdminTest):
@@ -32,7 +32,7 @@
cls.client.delete_volume_type(cls.volume_type['id'])
super(VolumeTypesExtraSpecsTest, cls).tearDownClass()
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_volume_type_extra_specs_list(self):
# List Volume types extra specs.
extra_specs = {"spec1": "val1"}
@@ -47,7 +47,7 @@
self.assertIsInstance(body, dict)
self.assertIn('spec1', body)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_volume_type_extra_specs_update(self):
# Update volume type extra specs
extra_specs = {"spec2": "val1"}
@@ -67,7 +67,7 @@
self.assertEqual(extra_spec['spec2'], body['spec2'],
"Volume type extra spec incorrectly updated")
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_volume_type_extra_spec_create_get_delete(self):
# Create/Get/Delete volume type extra spec.
extra_specs = {"spec3": "val1"}
diff --git a/tempest/api/volume/admin/test_volume_types_extra_specs_negative.py b/tempest/api/volume/admin/test_volume_types_extra_specs_negative.py
index 5a1a2cd..d3a052e 100644
--- a/tempest/api/volume/admin/test_volume_types_extra_specs_negative.py
+++ b/tempest/api/volume/admin/test_volume_types_extra_specs_negative.py
@@ -18,7 +18,7 @@
from tempest.api.volume import base
from tempest.common.utils import data_utils
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class ExtraSpecsNegativeTest(base.BaseVolumeV1AdminTest):
@@ -38,7 +38,7 @@
cls.client.delete_volume_type(cls.volume_type['id'])
super(ExtraSpecsNegativeTest, cls).tearDownClass()
- @attr(type='gate')
+ @test.attr(type='gate')
def test_update_no_body(self):
# Should not update volume type extra specs with no body
extra_spec = {"spec1": "val2"}
@@ -46,7 +46,7 @@
self.client.update_volume_type_extra_specs,
self.volume_type['id'], extra_spec.keys()[0], None)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_update_nonexistent_extra_spec_id(self):
# Should not update volume type extra specs with nonexistent id.
extra_spec = {"spec1": "val2"}
@@ -55,7 +55,7 @@
self.volume_type['id'], str(uuid.uuid4()),
extra_spec)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_update_none_extra_spec_id(self):
# Should not update volume type extra specs with none id.
extra_spec = {"spec1": "val2"}
@@ -63,7 +63,7 @@
self.client.update_volume_type_extra_specs,
self.volume_type['id'], None, extra_spec)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_update_multiple_extra_spec(self):
# Should not update volume type extra specs with multiple specs as
# body.
@@ -73,7 +73,7 @@
self.volume_type['id'], extra_spec.keys()[0],
extra_spec)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_create_nonexistent_type_id(self):
# Should not create volume type extra spec for nonexistent volume
# type id.
@@ -82,21 +82,21 @@
self.client.create_volume_type_extra_specs,
str(uuid.uuid4()), extra_specs)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_create_none_body(self):
# Should not create volume type extra spec for none POST body.
self.assertRaises(exceptions.BadRequest,
self.client.create_volume_type_extra_specs,
self.volume_type['id'], None)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_create_invalid_body(self):
# Should not create volume type extra spec for invalid POST body.
self.assertRaises(exceptions.BadRequest,
self.client.create_volume_type_extra_specs,
self.volume_type['id'], ['invalid'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_delete_nonexistent_volume_type_id(self):
# Should not delete volume type extra spec for nonexistent
# type id.
@@ -105,14 +105,14 @@
self.client.delete_volume_type_extra_specs,
str(uuid.uuid4()), extra_specs.keys()[0])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_nonexistent_volume_type_id(self):
# Should not list volume type extra spec for nonexistent type id.
self.assertRaises(exceptions.NotFound,
self.client.list_volume_types_extra_specs,
str(uuid.uuid4()))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_nonexistent_volume_type_id(self):
# Should not get volume type extra spec for nonexistent type id.
extra_specs = {"spec1": "val1"}
@@ -120,7 +120,7 @@
self.client.get_volume_type_extra_specs,
str(uuid.uuid4()), extra_specs.keys()[0])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_nonexistent_extra_spec_id(self):
# Should not get volume type extra spec for nonexistent extra spec
# id.
diff --git a/tempest/api/volume/admin/test_volume_types_negative.py b/tempest/api/volume/admin/test_volume_types_negative.py
index 56ad227..c18e15d 100644
--- a/tempest/api/volume/admin/test_volume_types_negative.py
+++ b/tempest/api/volume/admin/test_volume_types_negative.py
@@ -17,13 +17,13 @@
from tempest.api.volume import base
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class VolumeTypesNegativeTest(base.BaseVolumeV1AdminTest):
_interface = 'json'
- @attr(type='gate')
+ @test.attr(type='gate')
def test_create_with_nonexistent_volume_type(self):
# Should not be able to create volume with nonexistent volume_type.
self.assertRaises(exceptions.NotFound,
@@ -31,19 +31,19 @@
display_name=str(uuid.uuid4()),
volume_type=str(uuid.uuid4()))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_create_with_empty_name(self):
# Should not be able to create volume type with an empty name.
self.assertRaises(exceptions.BadRequest,
self.client.create_volume_type, '')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_nonexistent_type_id(self):
# Should not be able to get volume type with nonexistent type id.
self.assertRaises(exceptions.NotFound, self.client.get_volume_type,
str(uuid.uuid4()))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_delete_nonexistent_type_id(self):
# Should not be able to delete volume type with nonexistent type id.
self.assertRaises(exceptions.NotFound, self.client.delete_volume_type,
diff --git a/tempest/api/volume/admin/test_volumes_actions.py b/tempest/api/volume/admin/test_volumes_actions.py
index 9274fce..4496f18 100644
--- a/tempest/api/volume/admin/test_volumes_actions.py
+++ b/tempest/api/volume/admin/test_volumes_actions.py
@@ -15,13 +15,14 @@
from tempest.api.volume import base
from tempest.common.utils import data_utils as utils
-from tempest.test import attr
+from tempest import test
class VolumesActionsTest(base.BaseVolumeV1AdminTest):
_interface = "json"
@classmethod
+ @test.safe_setup
def setUpClass(cls):
super(VolumesActionsTest, cls).setUpClass()
cls.client = cls.volumes_client
@@ -75,7 +76,7 @@
self.assertEqual(202, resp_delete.status)
self.client.wait_for_resource_deletion(temp_volume['id'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_volume_reset_status(self):
# test volume reset status : available->error->available
resp, body = self._reset_volume_status(self.volume['id'], 'error')
@@ -84,7 +85,7 @@
self.volume['id'])
self.assertEqual('error', volume_get['status'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_volume_begin_detaching(self):
# test volume begin detaching : available -> detaching -> available
resp, body = self.client.volume_begin_detaching(self.volume['id'])
@@ -92,7 +93,7 @@
resp_get, volume_get = self.client.get_volume(self.volume['id'])
self.assertEqual('detaching', volume_get['status'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_volume_roll_detaching(self):
# test volume roll detaching : detaching -> in-use -> available
resp, body = self.client.volume_begin_detaching(self.volume['id'])
@@ -110,7 +111,7 @@
# test force delete when status of volume is attaching
self._create_reset_and_force_delete_temp_volume('attaching')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_volume_force_delete_when_volume_is_error(self):
# test force delete when status of volume is error
self._create_reset_and_force_delete_temp_volume('error')
diff --git a/tempest/api/volume/admin/test_volumes_backup.py b/tempest/api/volume/admin/test_volumes_backup.py
new file mode 100644
index 0000000..cd6d7a8
--- /dev/null
+++ b/tempest/api/volume/admin/test_volumes_backup.py
@@ -0,0 +1,78 @@
+# Copyright 2014 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.
+
+from tempest.api.volume import base
+from tempest.common.utils import data_utils
+from tempest import config
+from tempest.openstack.common import log as logging
+from tempest import test
+
+CONF = config.CONF
+LOG = logging.getLogger(__name__)
+
+
+class VolumesBackupsTest(base.BaseVolumeV1AdminTest):
+ _interface = "json"
+
+ @classmethod
+ def setUpClass(cls):
+ super(VolumesBackupsTest, cls).setUpClass()
+
+ if not CONF.volume_feature_enabled.backup:
+ raise cls.skipException("Cinder backup feature disabled")
+
+ cls.volumes_adm_client = cls.os_adm.volumes_client
+ cls.backups_adm_client = cls.os_adm.backups_client
+ cls.volume = cls.create_volume()
+
+ @test.attr(type='smoke')
+ 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'],
+ name=backup_name)
+ self.assertEqual(202, resp.status)
+ self.addCleanup(self.backups_adm_client.delete_backup,
+ backup['id'])
+ 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'])
+
+ # 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(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'],
+ 'available')
diff --git a/tempest/api/volume/base.py b/tempest/api/volume/base.py
index de2b240..2c6050c 100644
--- a/tempest/api/volume/base.py
+++ b/tempest/api/volume/base.py
@@ -69,18 +69,6 @@
# only in a single location in the source, and could be more general.
@classmethod
- def create_volume(cls, size=1, **kwargs):
- """Wrapper utility that returns a test volume."""
- vol_name = data_utils.rand_name('Volume')
- resp, volume = cls.volumes_client.create_volume(size,
- display_name=vol_name,
- **kwargs)
- assert 200 == resp.status
- cls.volumes.append(volume)
- cls.volumes_client.wait_for_volume_status(volume['id'], 'available')
- return volume
-
- @classmethod
def clear_volumes(cls):
for volume in cls.volumes:
try:
@@ -118,8 +106,21 @@
super(BaseVolumeV1Test, cls).setUpClass()
cls.snapshots_client = cls.os.snapshots_client
cls.volumes_client = cls.os.volumes_client
+ cls.backups_client = cls.os.backups_client
cls.volumes_extension_client = cls.os.volumes_extension_client
+ @classmethod
+ def create_volume(cls, size=1, **kwargs):
+ """Wrapper utility that returns a test volume."""
+ vol_name = data_utils.rand_name('Volume')
+ resp, volume = cls.volumes_client.create_volume(size,
+ display_name=vol_name,
+ **kwargs)
+ assert 200 == resp.status
+ cls.volumes.append(volume)
+ cls.volumes_client.wait_for_volume_status(volume['id'], 'available')
+ return volume
+
class BaseVolumeV1AdminTest(BaseVolumeV1Test):
"""Base test case class for all Volume Admin API tests."""
@@ -144,3 +145,26 @@
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):
+ @classmethod
+ def setUpClass(cls):
+ if not CONF.volume_feature_enabled.api_v2:
+ msg = "Volume API v2 not supported"
+ raise cls.skipException(msg)
+ super(BaseVolumeV2Test, cls).setUpClass()
+ cls.volumes_client = cls.os.volumes_v2_client
+
+ @classmethod
+ def create_volume(cls, size=1, **kwargs):
+ """Wrapper utility that returns a test volume."""
+ vol_name = data_utils.rand_name('Volume')
+ resp, volume = cls.volumes_client.create_volume(size,
+ name=vol_name,
+ **kwargs)
+ assert 202 == resp.status
+ cls.volumes.append(volume)
+ cls.volumes_client.wait_for_volume_status(volume['id'], 'available')
+ return volume
diff --git a/tempest/api/volume/test_extensions.py b/tempest/api/volume/test_extensions.py
index cceffd6..ce019a2 100644
--- a/tempest/api/volume/test_extensions.py
+++ b/tempest/api/volume/test_extensions.py
@@ -17,7 +17,7 @@
from tempest.api.volume import base
from tempest import config
from tempest.openstack.common import log as logging
-from tempest.test import attr
+from tempest import test
CONF = config.CONF
@@ -28,7 +28,7 @@
class ExtensionsTestJSON(base.BaseVolumeV1Test):
_interface = 'json'
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_extensions(self):
# List of all extensions
resp, extensions = self.volumes_extension_client.list_extensions()
diff --git a/tempest/api/volume/test_snapshot_metadata.py b/tempest/api/volume/test_snapshot_metadata.py
index 1493b37..d2c4ab7 100644
--- a/tempest/api/volume/test_snapshot_metadata.py
+++ b/tempest/api/volume/test_snapshot_metadata.py
@@ -21,6 +21,7 @@
_interface = "json"
@classmethod
+ @test.safe_setup
def setUpClass(cls):
super(SnapshotMetadataTest, cls).setUpClass()
cls.client = cls.snapshots_client
diff --git a/tempest/api/volume/test_volume_metadata.py b/tempest/api/volume/test_volume_metadata.py
index ec732d1..e94c700 100644
--- a/tempest/api/volume/test_volume_metadata.py
+++ b/tempest/api/volume/test_volume_metadata.py
@@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
-from testtools.matchers import ContainsAll
+from testtools import matchers
from tempest.api.volume import base
from tempest import test
@@ -43,7 +43,8 @@
# Create metadata for the volume
metadata = {"key1": "value1",
"key2": "value2",
- "key3": "value3"}
+ "key3": "value3",
+ "key4": "<value&special_chars>"}
rsp, body = self.volumes_client.create_volume_metadata(self.volume_id,
metadata)
@@ -51,7 +52,7 @@
# Get the metadata of the volume
resp, body = self.volumes_client.get_volume_metadata(self.volume_id)
self.assertEqual(200, resp.status)
- self.assertThat(body.items(), ContainsAll(metadata.items()))
+ self.assertThat(body.items(), matchers.ContainsAll(metadata.items()))
# Delete one item metadata of the volume
rsp, body = self.volumes_client.delete_volume_metadata_item(
self.volume_id,
@@ -59,6 +60,8 @@
self.assertEqual(200, rsp.status)
resp, body = self.volumes_client.get_volume_metadata(self.volume_id)
self.assertNotIn("key1", body)
+ del metadata["key1"]
+ self.assertThat(body.items(), matchers.ContainsAll(metadata.items()))
@test.attr(type='gate')
def test_update_volume_metadata(self):
@@ -78,7 +81,7 @@
# Get the metadata of the volume
resp, body = self.volumes_client.get_volume_metadata(self.volume_id)
self.assertEqual(200, resp.status)
- self.assertThat(body.items(), ContainsAll(metadata.items()))
+ self.assertThat(body.items(), matchers.ContainsAll(metadata.items()))
# Update metadata
resp, body = self.volumes_client.update_volume_metadata(
self.volume_id,
@@ -87,7 +90,7 @@
# Get the metadata of the volume
resp, body = self.volumes_client.get_volume_metadata(self.volume_id)
self.assertEqual(200, resp.status)
- self.assertThat(body.items(), ContainsAll(update.items()))
+ self.assertThat(body.items(), matchers.ContainsAll(update.items()))
@test.attr(type='gate')
def test_update_volume_metadata_item(self):
@@ -104,7 +107,7 @@
self.volume_id,
metadata)
self.assertEqual(200, resp.status)
- self.assertThat(body.items(), ContainsAll(metadata.items()))
+ self.assertThat(body.items(), matchers.ContainsAll(metadata.items()))
# Update metadata item
resp, body = self.volumes_client.update_volume_metadata_item(
self.volume_id,
@@ -114,7 +117,7 @@
# Get the metadata of the volume
resp, body = self.volumes_client.get_volume_metadata(self.volume_id)
self.assertEqual(200, resp.status)
- self.assertThat(body.items(), ContainsAll(expect.items()))
+ self.assertThat(body.items(), matchers.ContainsAll(expect.items()))
class VolumeMetadataTestXML(VolumeMetadataTest):
diff --git a/tempest/api/volume/test_volume_transfers.py b/tempest/api/volume/test_volume_transfers.py
index fc4f07d..55a72c1 100644
--- a/tempest/api/volume/test_volume_transfers.py
+++ b/tempest/api/volume/test_volume_transfers.py
@@ -13,10 +13,12 @@
# License for the specific language governing permissions and limitations
# under the License.
+from testtools import matchers
+
from tempest.api.volume import base
from tempest import clients
from tempest import config
-from tempest.test import attr
+from tempest import test
CONF = config.CONF
@@ -47,7 +49,7 @@
interface=cls._interface)
else:
cls.os_alt = clients.AltManager()
- alt_tenant_name = cls.os_alt.tenant_name
+ alt_tenant_name = cls.os_alt.credentials['tenant_name']
identity_client = cls._get_identity_admin_client()
_, tenants = identity_client.list_tenants()
cls.alt_tenant_id = [tnt['id'] for tnt in tenants
@@ -64,7 +66,7 @@
self.assertEqual(202, resp.status)
self.adm_client.wait_for_resource_deletion(volume_id)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_create_get_list_accept_volume_transfer(self):
# Create a volume first
volume = self.create_volume()
@@ -87,7 +89,7 @@
# or equal to 1
resp, body = self.client.list_volume_transfers()
self.assertEqual(200, resp.status)
- self.assertGreaterEqual(len(body), 1)
+ self.assertThat(len(body), matchers.GreaterThan(0))
# Accept a volume transfer by alt_tenant
resp, body = self.alt_client.accept_volume_transfer(transfer_id,
@@ -107,10 +109,14 @@
self.client.wait_for_volume_status(volume['id'],
'awaiting-transfer')
- # List all volume transfers, there's only one in this test
+ # List all volume transfers (looking for the one we created)
resp, body = self.client.list_volume_transfers()
self.assertEqual(200, resp.status)
- self.assertEqual(volume['id'], body[0]['volume_id'])
+ for transfer in body:
+ if volume['id'] == transfer['volume_id']:
+ break
+ else:
+ self.fail('Transfer not found for volume %s' % volume['id'])
# Delete a volume transfer
resp, body = self.client.delete_volume_transfer(transfer_id)
diff --git a/tempest/api/volume/test_volumes_actions.py b/tempest/api/volume/test_volumes_actions.py
index 5924c7e..cfab0bd 100644
--- a/tempest/api/volume/test_volumes_actions.py
+++ b/tempest/api/volume/test_volumes_actions.py
@@ -16,9 +16,7 @@
from tempest.api.volume import base
from tempest.common.utils import data_utils
from tempest import config
-from tempest.test import attr
-from tempest.test import services
-from tempest.test import stresstest
+from tempest import test
CONF = config.CONF
@@ -27,6 +25,7 @@
_interface = "json"
@classmethod
+ @test.safe_setup
def setUpClass(cls):
super(VolumesActionsTest, cls).setUpClass()
cls.client = cls.volumes_client
@@ -46,13 +45,13 @@
def tearDownClass(cls):
# Delete the test instance
cls.servers_client.delete_server(cls.server['id'])
- cls.client.wait_for_resource_deletion(cls.server['id'])
+ cls.servers_client.wait_for_server_termination(cls.server['id'])
super(VolumesActionsTest, cls).tearDownClass()
- @stresstest(class_setup_per='process')
- @attr(type='smoke')
- @services('compute')
+ @test.stresstest(class_setup_per='process')
+ @test.attr(type='smoke')
+ @test.services('compute')
def test_attach_detach_volume_to_instance(self):
# Volume is attached and detached successfully from an instance
mountpoint = '/dev/vdc'
@@ -65,9 +64,9 @@
self.assertEqual(202, resp.status)
self.client.wait_for_volume_status(self.volume['id'], 'available')
- @stresstest(class_setup_per='process')
- @attr(type='gate')
- @services('compute')
+ @test.stresstest(class_setup_per='process')
+ @test.attr(type='gate')
+ @test.services('compute')
def test_get_volume_attachment(self):
# Verify that a volume's attachment information is retrieved
mountpoint = '/dev/vdc'
@@ -91,8 +90,8 @@
self.assertEqual(self.volume['id'], attachment['id'])
self.assertEqual(self.volume['id'], attachment['volume_id'])
- @attr(type='gate')
- @services('image')
+ @test.attr(type='gate')
+ @test.services('image')
def test_volume_upload(self):
# NOTE(gfidente): the volume uploaded in Glance comes from setUpClass,
# it is shared with the other tests. After it is uploaded in Glance,
@@ -108,7 +107,7 @@
self.image_client.wait_for_image_status(image_id, 'active')
self.client.wait_for_volume_status(self.volume['id'], 'available')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_volume_extend(self):
# Extend Volume Test.
extend_size = int(self.volume['size']) + 1
@@ -119,7 +118,7 @@
self.assertEqual(200, resp.status)
self.assertEqual(int(volume['size']), extend_size)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_reserve_unreserve_volume(self):
# Mark volume as reserved.
resp, body = self.client.reserve_volume(self.volume['id'])
@@ -139,7 +138,7 @@
def _is_true(self, val):
return val in ['true', 'True', True]
- @attr(type='gate')
+ @test.attr(type='gate')
def test_volume_readonly_update(self):
# Update volume readonly true
readonly = True
diff --git a/tempest/api/volume/test_volumes_get.py b/tempest/api/volume/test_volumes_get.py
index 6d89e5b..be5d76b 100644
--- a/tempest/api/volume/test_volumes_get.py
+++ b/tempest/api/volume/test_volumes_get.py
@@ -13,13 +13,12 @@
# License for the specific language governing permissions and limitations
# under the License.
-from testtools.matchers import ContainsAll
+from testtools import matchers
from tempest.api.volume import base
from tempest.common.utils import data_utils
from tempest import config
-from tempest.test import attr
-from tempest.test import services
+from tempest import test
CONF = config.CONF
@@ -78,7 +77,7 @@
'The fetched Volume id is different '
'from the created Volume')
self.assertThat(fetched_volume['metadata'].items(),
- ContainsAll(metadata.items()),
+ matchers.ContainsAll(metadata.items()),
'The fetched Volume metadata misses data '
'from the created Volume')
@@ -91,6 +90,12 @@
self.assertEqual(boot_flag, False)
# Update Volume
+ # Test volume update when display_name is same with original value
+ resp, update_volume = \
+ self.client.update_volume(volume['id'],
+ display_name=v_name)
+ self.assertEqual(200, resp.status)
+ # Test volume update when display_name is new
new_v_name = data_utils.rand_name('new-Volume')
new_desc = 'This is the new description of volume'
resp, update_volume = \
@@ -108,9 +113,29 @@
self.assertEqual(new_v_name, updated_volume['display_name'])
self.assertEqual(new_desc, updated_volume['display_description'])
self.assertThat(updated_volume['metadata'].items(),
- ContainsAll(metadata.items()),
+ matchers.ContainsAll(metadata.items()),
'The fetched Volume metadata misses data '
'from the created Volume')
+ # Test volume create when display_name is none and display_description
+ # contains specific characters,
+ # then test volume update if display_name is duplicated
+ new_volume = {}
+ new_v_desc = data_utils.rand_name('@#$%^* description')
+ resp, new_volume = \
+ self.client.create_volume(size=1,
+ display_description=new_v_desc,
+ availability_zone=
+ volume['availability_zone'])
+ self.assertEqual(200, resp.status)
+ self.assertIn('id', new_volume)
+ self.addCleanup(self._delete_volume, new_volume['id'])
+ self.client.wait_for_volume_status(new_volume['id'], 'available')
+ resp, update_volume = \
+ self.client.update_volume(new_volume['id'],
+ display_name=volume['display_name'],
+ display_description=
+ volume['display_description'])
+ self.assertEqual(200, resp.status)
# NOTE(jdg): Revert back to strict true/false checking
# after fix for bug #1227837 merges
@@ -120,16 +145,16 @@
if 'imageRef' not in kwargs:
self.assertEqual(boot_flag, False)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_volume_create_get_update_delete(self):
self._volume_create_get_update_delete()
- @attr(type='smoke')
- @services('image')
+ @test.attr(type='smoke')
+ @test.services('image')
def test_volume_create_get_update_delete_from_image(self):
self._volume_create_get_update_delete(imageRef=CONF.compute.image_ref)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_volume_create_get_update_delete_as_clone(self):
origin = self.create_volume()
self._volume_create_get_update_delete(source_volid=origin['id'])
diff --git a/tempest/api/volume/test_volumes_list.py b/tempest/api/volume/test_volumes_list.py
index 049544d..c356342 100644
--- a/tempest/api/volume/test_volumes_list.py
+++ b/tempest/api/volume/test_volumes_list.py
@@ -18,8 +18,8 @@
from tempest.api.volume import base
from tempest.common.utils import data_utils
from tempest.openstack.common import log as logging
-from tempest.test import attr
-from testtools.matchers import ContainsAll
+from tempest import test
+from testtools import matchers
LOG = logging.getLogger(__name__)
@@ -111,12 +111,12 @@
('details' if with_detail else '', key)
if key == 'metadata':
self.assertThat(volume[key].items(),
- ContainsAll(params[key].items()),
+ matchers.ContainsAll(params[key].items()),
msg)
else:
self.assertEqual(params[key], volume[key], msg)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_volume_list(self):
# Get a list of Volumes
# Fetch all volumes
@@ -125,7 +125,7 @@
self.assertVolumesIn(fetched_list, self.volume_list,
fields=VOLUME_FIELDS)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_volume_list_with_details(self):
# Get a list of Volumes with details
# Fetch all Volumes
@@ -133,7 +133,7 @@
self.assertEqual(200, resp.status)
self.assertVolumesIn(fetched_list, self.volume_list)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_volume_list_by_name(self):
volume = self.volume_list[data_utils.rand_int_id(0, 2)]
params = {'display_name': volume['display_name']}
@@ -143,7 +143,7 @@
self.assertEqual(fetched_vol[0]['display_name'],
volume['display_name'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_volume_list_details_by_name(self):
volume = self.volume_list[data_utils.rand_int_id(0, 2)]
params = {'display_name': volume['display_name']}
@@ -153,7 +153,7 @@
self.assertEqual(fetched_vol[0]['display_name'],
volume['display_name'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_volumes_list_by_status(self):
params = {'status': 'available'}
resp, fetched_list = self.client.list_volumes(params)
@@ -163,7 +163,7 @@
self.assertVolumesIn(fetched_list, self.volume_list,
fields=VOLUME_FIELDS)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_volumes_list_details_by_status(self):
params = {'status': 'available'}
resp, fetched_list = self.client.list_volumes_with_detail(params)
@@ -172,7 +172,7 @@
self.assertEqual('available', volume['status'])
self.assertVolumesIn(fetched_list, self.volume_list)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_volumes_list_by_availability_zone(self):
volume = self.volume_list[data_utils.rand_int_id(0, 2)]
zone = volume['availability_zone']
@@ -184,7 +184,7 @@
self.assertVolumesIn(fetched_list, self.volume_list,
fields=VOLUME_FIELDS)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_volumes_list_details_by_availability_zone(self):
volume = self.volume_list[data_utils.rand_int_id(0, 2)]
zone = volume['availability_zone']
@@ -195,19 +195,19 @@
self.assertEqual(zone, volume['availability_zone'])
self.assertVolumesIn(fetched_list, self.volume_list)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_volume_list_with_param_metadata(self):
# Test to list volumes when metadata param is given
params = {'metadata': self.metadata}
self._list_by_param_value_and_assert(params)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_volume_list_with_detail_param_metadata(self):
# Test to list volumes details when metadata param is given
params = {'metadata': self.metadata}
self._list_by_param_value_and_assert(params, with_detail=True)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_volume_list_param_display_name_and_status(self):
# Test to list volume when display name and status param is given
volume = self.volume_list[data_utils.rand_int_id(0, 2)]
@@ -215,7 +215,7 @@
'status': 'available'}
self._list_by_param_value_and_assert(params)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_volume_list_with_detail_param_display_name_and_status(self):
# Test to list volume when name and status param is given
volume = self.volume_list[data_utils.rand_int_id(0, 2)]
diff --git a/tempest/api/volume/test_volumes_negative.py b/tempest/api/volume/test_volumes_negative.py
index 284c321..82924a5 100644
--- a/tempest/api/volume/test_volumes_negative.py
+++ b/tempest/api/volume/test_volumes_negative.py
@@ -18,7 +18,7 @@
from tempest.api.volume import base
from tempest.common.utils import data_utils
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class VolumesNegativeTest(base.BaseVolumeV1Test):
@@ -33,19 +33,19 @@
cls.volume = cls.create_volume()
cls.mountpoint = "/dev/vdc"
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_volume_get_nonexistent_volume_id(self):
# Should not be able to get a non-existent volume
self.assertRaises(exceptions.NotFound, self.client.get_volume,
str(uuid.uuid4()))
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_volume_delete_nonexistent_volume_id(self):
# Should not be able to delete a non-existent Volume
self.assertRaises(exceptions.NotFound, self.client.delete_volume,
str(uuid.uuid4()))
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_volume_with_invalid_size(self):
# Should not be able to create volume with invalid size
# in request
@@ -54,7 +54,7 @@
self.assertRaises(exceptions.BadRequest, self.client.create_volume,
size='#$%', display_name=v_name, metadata=metadata)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_volume_with_out_passing_size(self):
# Should not be able to create volume without passing size
# in request
@@ -63,7 +63,7 @@
self.assertRaises(exceptions.BadRequest, self.client.create_volume,
size='', display_name=v_name, metadata=metadata)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_volume_with_size_zero(self):
# Should not be able to create volume with size zero
v_name = data_utils.rand_name('Volume-')
@@ -71,7 +71,7 @@
self.assertRaises(exceptions.BadRequest, self.client.create_volume,
size='0', display_name=v_name, metadata=metadata)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_volume_with_size_negative(self):
# Should not be able to create volume with size negative
v_name = data_utils.rand_name('Volume-')
@@ -79,7 +79,7 @@
self.assertRaises(exceptions.BadRequest, self.client.create_volume,
size='-1', display_name=v_name, metadata=metadata)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_volume_with_nonexistent_volume_type(self):
# Should not be able to create volume with non-existent volume type
v_name = data_utils.rand_name('Volume-')
@@ -88,7 +88,7 @@
size='1', volume_type=str(uuid.uuid4()),
display_name=v_name, metadata=metadata)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_volume_with_nonexistent_snapshot_id(self):
# Should not be able to create volume with non-existent snapshot
v_name = data_utils.rand_name('Volume-')
@@ -97,7 +97,7 @@
size='1', snapshot_id=str(uuid.uuid4()),
display_name=v_name, metadata=metadata)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_volume_with_nonexistent_source_volid(self):
# Should not be able to create volume with non-existent source volume
v_name = data_utils.rand_name('Volume-')
@@ -106,7 +106,7 @@
size='1', source_volid=str(uuid.uuid4()),
display_name=v_name, metadata=metadata)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_update_volume_with_nonexistent_volume_id(self):
v_name = data_utils.rand_name('Volume-')
metadata = {'Type': 'work'}
@@ -114,7 +114,7 @@
volume_id=str(uuid.uuid4()), display_name=v_name,
metadata=metadata)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_update_volume_with_invalid_volume_id(self):
v_name = data_utils.rand_name('Volume-')
metadata = {'Type': 'work'}
@@ -122,7 +122,7 @@
volume_id='#$%%&^&^', display_name=v_name,
metadata=metadata)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_update_volume_with_empty_volume_id(self):
v_name = data_utils.rand_name('Volume-')
metadata = {'Type': 'work'}
@@ -130,29 +130,29 @@
volume_id='', display_name=v_name,
metadata=metadata)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_get_invalid_volume_id(self):
# Should not be able to get volume with invalid id
self.assertRaises(exceptions.NotFound, self.client.get_volume,
'#$%%&^&^')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_get_volume_without_passing_volume_id(self):
# Should not be able to get volume when empty ID is passed
self.assertRaises(exceptions.NotFound, self.client.get_volume, '')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_invalid_volume_id(self):
# Should not be able to delete volume when invalid ID is passed
self.assertRaises(exceptions.NotFound, self.client.delete_volume,
'!@#$%^&*()')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_volume_without_passing_volume_id(self):
# Should not be able to delete volume when empty ID is passed
self.assertRaises(exceptions.NotFound, self.client.delete_volume, '')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_attach_volumes_with_nonexistent_volume_id(self):
srv_name = data_utils.rand_name('Instance-')
resp, server = self.servers_client.create_server(srv_name,
@@ -166,60 +166,60 @@
server['id'],
self.mountpoint)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_detach_volumes_with_invalid_volume_id(self):
self.assertRaises(exceptions.NotFound,
self.client.detach_volume,
'xxx')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_volume_extend_with_size_smaller_than_original_size(self):
# Extend volume with smaller size than original size.
extend_size = 0
self.assertRaises(exceptions.BadRequest, self.client.extend_volume,
self.volume['id'], extend_size)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_volume_extend_with_non_number_size(self):
# Extend volume when size is non number.
extend_size = 'abc'
self.assertRaises(exceptions.BadRequest, self.client.extend_volume,
self.volume['id'], extend_size)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_volume_extend_with_None_size(self):
# Extend volume with None size.
extend_size = None
self.assertRaises(exceptions.BadRequest, self.client.extend_volume,
self.volume['id'], extend_size)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_volume_extend_with_nonexistent_volume_id(self):
# Extend volume size when volume is nonexistent.
extend_size = int(self.volume['size']) + 1
self.assertRaises(exceptions.NotFound, self.client.extend_volume,
str(uuid.uuid4()), extend_size)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_volume_extend_without_passing_volume_id(self):
# Extend volume size when passing volume id is None.
extend_size = int(self.volume['size']) + 1
self.assertRaises(exceptions.NotFound, self.client.extend_volume,
None, extend_size)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_reserve_volume_with_nonexistent_volume_id(self):
self.assertRaises(exceptions.NotFound,
self.client.reserve_volume,
str(uuid.uuid4()))
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_unreserve_volume_with_nonexistent_volume_id(self):
self.assertRaises(exceptions.NotFound,
self.client.unreserve_volume,
str(uuid.uuid4()))
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_reserve_volume_with_negative_volume_status(self):
# Mark volume as reserved.
resp, body = self.client.reserve_volume(self.volume['id'])
@@ -232,7 +232,7 @@
resp, body = self.client.unreserve_volume(self.volume['id'])
self.assertEqual(202, resp.status)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_list_volumes_with_nonexistent_name(self):
v_name = data_utils.rand_name('Volume-')
params = {'display_name': v_name}
@@ -240,7 +240,7 @@
self.assertEqual(200, resp.status)
self.assertEqual(0, len(fetched_volume))
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_list_volumes_detail_with_nonexistent_name(self):
v_name = data_utils.rand_name('Volume-')
params = {'display_name': v_name}
@@ -248,14 +248,14 @@
self.assertEqual(200, resp.status)
self.assertEqual(0, len(fetched_volume))
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_list_volumes_with_invalid_status(self):
params = {'status': 'null'}
resp, fetched_volume = self.client.list_volumes(params)
self.assertEqual(200, resp.status)
self.assertEqual(0, len(fetched_volume))
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_list_volumes_detail_with_invalid_status(self):
params = {'status': 'null'}
resp, fetched_volume = self.client.list_volumes_with_detail(params)
diff --git a/tempest/api/volume/test_volumes_snapshots.py b/tempest/api/volume/test_volumes_snapshots.py
index 487ada6..84c9501 100644
--- a/tempest/api/volume/test_volumes_snapshots.py
+++ b/tempest/api/volume/test_volumes_snapshots.py
@@ -12,10 +12,12 @@
from tempest.api.volume import base
from tempest.common.utils import data_utils
+from tempest import config
from tempest.openstack.common import log as logging
-from tempest.test import attr
+from tempest import test
LOG = logging.getLogger(__name__)
+CONF = config.CONF
class VolumesSnapshotTest(base.BaseVolumeV1Test):
@@ -35,6 +37,11 @@
def tearDownClass(cls):
super(VolumesSnapshotTest, cls).tearDownClass()
+ def _detach(self, volume_id):
+ """Detach volume."""
+ self.volumes_client.detach_volume(volume_id)
+ self.volumes_client.wait_for_volume_status(volume_id, 'available')
+
def _list_by_param_values_and_assert(self, params, with_detail=False):
"""
Perform list or list_details action with given params
@@ -56,7 +63,33 @@
('details' if with_detail else '', key)
self.assertEqual(params[key], snap[key], msg)
- @attr(type='gate')
+ @test.attr(type='gate')
+ def test_snapshot_create_with_volume_in_use(self):
+ # Create a snapshot when volume status is in-use
+ # Create a test instance
+ server_name = data_utils.rand_name('instance-')
+ resp, server = self.servers_client.create_server(server_name,
+ self.image_ref,
+ self.flavor_ref)
+ self.addCleanup(self.servers_client.delete_server, server['id'])
+ self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
+ mountpoint = '/dev/%s' % CONF.compute.volume_device_name
+ resp, body = self.volumes_client.attach_volume(
+ self.volume_origin['id'], server['id'], mountpoint)
+ self.assertEqual(202, resp.status)
+ self.volumes_client.wait_for_volume_status(self.volume_origin['id'],
+ 'in-use')
+ self.addCleanup(self._detach, self.volume_origin['id'])
+ # Snapshot a volume even if it's attached to an instance
+ snapshot = self.create_snapshot(self.volume_origin['id'],
+ force=True)
+ # Delete the snapshot
+ self.snapshots_client.delete_snapshot(snapshot['id'])
+ self.assertEqual(202, resp.status)
+ self.snapshots_client.wait_for_resource_deletion(snapshot['id'])
+ self.snapshots.remove(snapshot)
+
+ @test.attr(type='gate')
def test_snapshot_create_get_list_update_delete(self):
# Create a snapshot
s_name = data_utils.rand_name('snap')
@@ -101,7 +134,7 @@
self.snapshots_client.wait_for_resource_deletion(snapshot['id'])
self.snapshots.remove(snapshot)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_snapshots_list_with_params(self):
"""list snapshots with params."""
# Create a snapshot
@@ -122,7 +155,7 @@
'display_name': snapshot['display_name']}
self._list_by_param_values_and_assert(params)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_snapshots_list_details_with_params(self):
"""list snapshot details with params."""
# Create a snapshot
@@ -141,7 +174,7 @@
'display_name': snapshot['display_name']}
self._list_by_param_values_and_assert(params, with_detail=True)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_volume_from_snapshot(self):
# Create a temporary snap using wrapper method from base, then
# create a snap based volume, check resp code and deletes it
diff --git a/tempest/api/volume/test_volumes_snapshots_negative.py b/tempest/api/volume/test_volumes_snapshots_negative.py
index b24b597..9e47c03 100644
--- a/tempest/api/volume/test_volumes_snapshots_negative.py
+++ b/tempest/api/volume/test_volumes_snapshots_negative.py
@@ -15,13 +15,13 @@
from tempest.api.volume import base
from tempest.common.utils import data_utils
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class VolumesSnapshotNegativeTest(base.BaseVolumeV1Test):
_interface = "json"
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_snapshot_with_nonexistent_volume_id(self):
# Create a snapshot with nonexistent volume id
s_name = data_utils.rand_name('snap')
@@ -29,7 +29,7 @@
self.snapshots_client.create_snapshot,
str(uuid.uuid4()), display_name=s_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_snapshot_without_passing_volume_id(self):
# Create a snapshot without passing volume id
s_name = data_utils.rand_name('snap')
diff --git a/tempest/api/volume/v2/__init__.py b/tempest/api/volume/v2/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/api/volume/v2/__init__.py
diff --git a/tempest/api/volume/v2/test_volumes_list.py b/tempest/api/volume/v2/test_volumes_list.py
new file mode 100644
index 0000000..fff40ed
--- /dev/null
+++ b/tempest/api/volume/v2/test_volumes_list.py
@@ -0,0 +1,214 @@
+# Copyright 2012 OpenStack Foundation
+# Copyright 2013 IBM Corp.
+# 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 operator
+
+from tempest.api.volume import base
+from tempest.common.utils import data_utils
+from tempest.openstack.common import log as logging
+from tempest import test
+from testtools import matchers
+
+LOG = logging.getLogger(__name__)
+
+VOLUME_FIELDS = ('id', 'name')
+
+
+class VolumesV2ListTestJSON(base.BaseVolumeV2Test):
+
+ """
+ This test creates a number of 1G volumes. To run successfully,
+ ensure that the backing file for the volume group that Nova uses
+ has space for at least 3 1G volumes!
+ If you are running a Devstack environment, ensure that the
+ VOLUME_BACKING_FILE_SIZE is at least 4G in your localrc
+ """
+
+ _interface = 'json'
+
+ def assertVolumesIn(self, fetched_list, expected_list, fields=None):
+ if fields:
+ expected_list = map(operator.itemgetter(*fields), expected_list)
+ fetched_list = map(operator.itemgetter(*fields), fetched_list)
+
+ missing_vols = [v for v in expected_list if v not in fetched_list]
+ if len(missing_vols) == 0:
+ return
+
+ def str_vol(vol):
+ return "%s:%s" % (vol['id'], vol['name'])
+
+ raw_msg = "Could not find volumes %s in expected list %s; fetched %s"
+ self.fail(raw_msg % ([str_vol(v) for v in missing_vols],
+ [str_vol(v) for v in expected_list],
+ [str_vol(v) for v in fetched_list]))
+
+ @classmethod
+ def setUpClass(cls):
+ super(VolumesV2ListTestJSON, cls).setUpClass()
+ cls.client = cls.volumes_client
+
+ # Create 3 test volumes
+ cls.volume_list = []
+ cls.volume_id_list = []
+ cls.metadata = {'Type': 'work'}
+ for i in range(3):
+ try:
+ volume = cls.create_volume(metadata=cls.metadata)
+ resp, volume = cls.client.get_volume(volume['id'])
+ cls.volume_list.append(volume)
+ cls.volume_id_list.append(volume['id'])
+ except Exception:
+ LOG.exception('Failed to create volume. %d volumes were '
+ 'created' % len(cls.volume_id_list))
+ if cls.volume_list:
+ # We could not create all the volumes, though we were able
+ # to create *some* of the volumes. This is typically
+ # because the backing file size of the volume group is
+ # too small.
+ for volid in cls.volume_id_list:
+ cls.client.delete_volume(volid)
+ cls.client.wait_for_resource_deletion(volid)
+ raise
+
+ @classmethod
+ def tearDownClass(cls):
+ # Delete the created volumes
+ for volid in cls.volume_id_list:
+ resp, _ = cls.client.delete_volume(volid)
+ cls.client.wait_for_resource_deletion(volid)
+ super(VolumesV2ListTestJSON, cls).tearDownClass()
+
+ def _list_by_param_value_and_assert(self, params, expected_list=None,
+ with_detail=False):
+ """
+ Perform list or list_details action with given params
+ and validates result.
+ """
+ if with_detail:
+ resp, fetched_vol_list = \
+ self.client.list_volumes_with_detail(params=params)
+ else:
+ resp, fetched_vol_list = self.client.list_volumes(params=params)
+
+ self.assertEqual(200, resp.status)
+ if expected_list is None:
+ expected_list = self.volume_list
+ self.assertVolumesIn(fetched_vol_list, expected_list,
+ fields=VOLUME_FIELDS)
+ # Validating params of fetched volumes
+ if with_detail:
+ for volume in fetched_vol_list:
+ for key in params:
+ msg = "Failed to list volumes %s by %s" % \
+ ('details' if with_detail else '', key)
+ if key == 'metadata':
+ self.assertThat(volume[key].items(),
+ matchers.ContainsAll(
+ params[key].items()), msg)
+ else:
+ self.assertEqual(params[key], volume[key], msg)
+
+ @test.attr(type='smoke')
+ def test_volume_list(self):
+ # Get a list of Volumes
+ # Fetch all volumes
+ resp, fetched_list = self.client.list_volumes()
+ self.assertEqual(200, resp.status)
+ self.assertVolumesIn(fetched_list, self.volume_list,
+ fields=VOLUME_FIELDS)
+
+ @test.attr(type='gate')
+ def test_volume_list_with_details(self):
+ # Get a list of Volumes with details
+ # Fetch all Volumes
+ resp, fetched_list = self.client.list_volumes_with_detail()
+ self.assertEqual(200, resp.status)
+ self.assertVolumesIn(fetched_list, self.volume_list)
+
+ @test.attr(type='gate')
+ def test_volume_list_by_name(self):
+ volume = self.volume_list[data_utils.rand_int_id(0, 2)]
+ params = {'name': volume['name']}
+ resp, fetched_vol = self.client.list_volumes(params)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(1, len(fetched_vol), str(fetched_vol))
+ self.assertEqual(fetched_vol[0]['name'], volume['name'])
+
+ @test.attr(type='gate')
+ def test_volume_list_details_by_name(self):
+ volume = self.volume_list[data_utils.rand_int_id(0, 2)]
+ params = {'name': volume['name']}
+ resp, fetched_vol = self.client.list_volumes_with_detail(params)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(1, len(fetched_vol), str(fetched_vol))
+ self.assertEqual(fetched_vol[0]['name'], volume['name'])
+
+ @test.attr(type='gate')
+ def test_volumes_list_by_status(self):
+ params = {'status': 'available'}
+ self._list_by_param_value_and_assert(params)
+
+ @test.attr(type='gate')
+ def test_volumes_list_details_by_status(self):
+ params = {'status': 'available'}
+ self._list_by_param_value_and_assert(params, with_detail=True)
+
+ @test.attr(type='gate')
+ def test_volumes_list_by_availability_zone(self):
+ volume = self.volume_list[data_utils.rand_int_id(0, 2)]
+ zone = volume['availability_zone']
+ params = {'availability_zone': zone}
+ self._list_by_param_value_and_assert(params)
+
+ @test.attr(type='gate')
+ def test_volumes_list_details_by_availability_zone(self):
+ volume = self.volume_list[data_utils.rand_int_id(0, 2)]
+ zone = volume['availability_zone']
+ params = {'availability_zone': zone}
+ self._list_by_param_value_and_assert(params, with_detail=True)
+
+ @test.attr(type='gate')
+ def test_volume_list_with_param_metadata(self):
+ # Test to list volumes when metadata param is given
+ params = {'metadata': self.metadata}
+ self._list_by_param_value_and_assert(params)
+
+ @test.attr(type='gate')
+ def test_volume_list_with_detail_param_metadata(self):
+ # Test to list volumes details when metadata param is given
+ params = {'metadata': self.metadata}
+ self._list_by_param_value_and_assert(params, with_detail=True)
+
+ @test.attr(type='gate')
+ def test_volume_list_param_display_name_and_status(self):
+ # Test to list volume when display name and status param is given
+ volume = self.volume_list[data_utils.rand_int_id(0, 2)]
+ params = {'name': volume['name'],
+ 'status': 'available'}
+ self._list_by_param_value_and_assert(params, expected_list=[volume])
+
+ @test.attr(type='gate')
+ def test_volume_list_with_detail_param_display_name_and_status(self):
+ # Test to list volume when name and status param is given
+ volume = self.volume_list[data_utils.rand_int_id(0, 2)]
+ params = {'name': volume['name'],
+ 'status': 'available'}
+ self._list_by_param_value_and_assert(params, expected_list=[volume],
+ with_detail=True)
+
+
+class VolumesV2ListTestXML(VolumesV2ListTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api_schema/__init__.py b/tempest/api_schema/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/api_schema/__init__.py
diff --git a/tempest/api_schema/compute/__init__.py b/tempest/api_schema/compute/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/api_schema/compute/__init__.py
diff --git a/tempest/api_schema/compute/hosts.py b/tempest/api_schema/compute/hosts.py
new file mode 100644
index 0000000..b9a3db9
--- /dev/null
+++ b/tempest/api_schema/compute/hosts.py
@@ -0,0 +1,35 @@
+# 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_hosts = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'hosts': {
+ 'type': 'array',
+ 'items': {
+ 'type': 'object',
+ 'properties': {
+ 'host_name': {'type': 'string'},
+ 'service': {'type': 'string'},
+ 'zone': {'type': 'string'}
+ },
+ 'required': ['host_name', 'service', 'zone']
+ }
+ }
+ },
+ 'required': ['hosts']
+ }
+}
diff --git a/tempest/api_schema/compute/services.py b/tempest/api_schema/compute/services.py
new file mode 100644
index 0000000..4793f5a
--- /dev/null
+++ b/tempest/api_schema/compute/services.py
@@ -0,0 +1,44 @@
+# 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': 'object',
+ 'properties': {
+ 'services': {
+ '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']
+ }
+ }
+ },
+ 'required': ['services']
+ }
+}
diff --git a/tempest/api_schema/compute/v2/__init__.py b/tempest/api_schema/compute/v2/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/api_schema/compute/v2/__init__.py
diff --git a/tempest/api_schema/compute/v2/fixed_ips.py b/tempest/api_schema/compute/v2/fixed_ips.py
new file mode 100644
index 0000000..a6add04
--- /dev/null
+++ b/tempest/api_schema/compute/v2/fixed_ips.py
@@ -0,0 +1,36 @@
+# 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.
+
+fixed_ips = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'fixed_ip': {
+ 'type': 'object',
+ 'properties': {
+ 'address': {
+ 'type': 'string',
+ 'format': 'ip-address'
+ },
+ 'cidr': {'type': 'string'},
+ 'host': {'type': 'string'},
+ 'hostname': {'type': 'string'}
+ },
+ 'required': ['address', 'cidr', 'host', 'hostname']
+ }
+ },
+ 'required': ['fixed_ip']
+ }
+}
diff --git a/tempest/api_schema/compute/v2/floating_ips.py b/tempest/api_schema/compute/v2/floating_ips.py
new file mode 100644
index 0000000..61582ec
--- /dev/null
+++ b/tempest/api_schema/compute/v2/floating_ips.py
@@ -0,0 +1,46 @@
+# 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_floating_ips = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'floating_ips': {
+ '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']},
+ 'pool': {'type': ['string', 'null']},
+ 'instance_id': {'type': ['integer', 'string', 'null']},
+ 'ip': {
+ 'type': 'string',
+ 'format': 'ip-address'
+ },
+ 'fixed_ip': {
+ 'type': ['string', 'null'],
+ 'format': 'ip-address'
+ }
+ },
+ 'required': ['id', 'pool', 'instance_id', 'ip', 'fixed_ip']
+ }
+ }
+ },
+ 'required': ['floating_ips']
+ }
+}
diff --git a/tempest/api_schema/compute/v2/limits.py b/tempest/api_schema/compute/v2/limits.py
new file mode 100644
index 0000000..b9857f1
--- /dev/null
+++ b/tempest/api_schema/compute/v2/limits.py
@@ -0,0 +1,94 @@
+# 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.
+
+get_limit = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'limits': {
+ 'type': 'object',
+ 'properties': {
+ 'absolute': {
+ 'type': 'object',
+ 'properties': {
+ 'maxTotalRAMSize': {'type': 'integer'},
+ 'totalCoresUsed': {'type': 'integer'},
+ 'maxTotalInstances': {'type': 'integer'},
+ 'maxTotalFloatingIps': {'type': 'integer'},
+ 'totalSecurityGroupsUsed': {'type': 'integer'},
+ 'maxTotalCores': {'type': 'integer'},
+ 'totalFloatingIpsUsed': {'type': 'integer'},
+ 'maxSecurityGroups': {'type': 'integer'},
+ 'maxServerMeta': {'type': 'integer'},
+ 'maxPersonality': {'type': 'integer'},
+ 'maxImageMeta': {'type': 'integer'},
+ 'maxPersonalitySize': {'type': 'integer'},
+ 'maxSecurityGroupRules': {'type': 'integer'},
+ 'maxTotalKeypairs': {'type': 'integer'},
+ 'totalRAMUsed': {'type': 'integer'},
+ 'totalInstancesUsed': {'type': 'integer'}
+ },
+ 'required': ['maxImageMeta',
+ 'maxPersonality',
+ 'maxPersonalitySize',
+ 'maxSecurityGroupRules',
+ 'maxSecurityGroups',
+ 'maxServerMeta',
+ 'maxTotalCores',
+ 'maxTotalFloatingIps',
+ 'maxTotalInstances',
+ 'maxTotalKeypairs',
+ 'maxTotalRAMSize',
+ 'totalCoresUsed',
+ 'totalFloatingIpsUsed',
+ 'totalInstancesUsed',
+ 'totalRAMUsed',
+ 'totalSecurityGroupsUsed']
+ },
+ 'rate': {
+ 'type': 'array',
+ 'items': {
+ 'type': 'object',
+ 'properties': {
+ 'limit': {
+ 'type': 'array',
+ 'items': {
+ 'type': 'object',
+ 'properties': {
+ 'next-available':
+ {'type': 'string'},
+ 'remaining':
+ {'type': 'integer'},
+ 'unit':
+ {'type': 'string'},
+ 'value':
+ {'type': 'integer'},
+ 'verb':
+ {'type': 'string'}
+ }
+ }
+ },
+ 'regex': {'type': 'string'},
+ 'uri': {'type': 'string'}
+ }
+ }
+ }
+ },
+ 'required': ['absolute', 'rate']
+ }
+ },
+ 'required': ['limits']
+ }
+}
diff --git a/tempest/api_schema/compute/v2/servers.py b/tempest/api_schema/compute/v2/servers.py
new file mode 100644
index 0000000..7f06ca6
--- /dev/null
+++ b/tempest/api_schema/compute/v2/servers.py
@@ -0,0 +1,53 @@
+# 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.
+
+create_server = {
+ 'status_code': [202],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'server': {
+ 'type': 'object',
+ 'properties': {
+ # NOTE: Now the type of 'id' is uuid, but here allows
+ # 'integer' also because old OpenStack uses 'integer'
+ # as a server id.
+ 'id': {'type': ['integer', 'string']},
+ 'security_groups': {'type': 'array'},
+ 'links': {
+ 'type': 'array',
+ 'items': {
+ 'type': 'object',
+ 'properties': {
+ 'href': {
+ 'type': 'string',
+ 'format': 'uri'
+ },
+ 'rel': {'type': 'string'}
+ },
+ 'required': ['href', 'rel']
+ }
+ },
+ 'adminPass': {'type': 'string'},
+ 'OS-DCF:diskConfig': {'type': 'string'}
+ },
+ # NOTE: OS-DCF:diskConfig is API extension, and some
+ # environments return a response without the attribute.
+ # So it is not 'required'.
+ 'required': ['id', 'security_groups', 'links', 'adminPass']
+ }
+ },
+ 'required': ['server']
+ }
+}
diff --git a/tempest/api_schema/compute/v2/volumes.py b/tempest/api_schema/compute/v2/volumes.py
new file mode 100644
index 0000000..16ed7c2
--- /dev/null
+++ b/tempest/api_schema/compute/v2/volumes.py
@@ -0,0 +1,56 @@
+# 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.
+
+get_volume = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'volume': {
+ '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']},
+ 'status': {'type': 'string'},
+ 'displayName': {'type': ['string', 'null']},
+ 'availabilityZone': {'type': 'string'},
+ 'createdAt': {'type': 'string'},
+ 'displayDescription': {'type': ['string', 'null']},
+ 'volumeType': {'type': 'string'},
+ 'snapshotId': {'type': ['string', 'null']},
+ 'metadata': {'type': 'object'},
+ 'size': {'type': 'integer'},
+ 'attachments': {
+ 'type': 'array',
+ 'items': {
+ 'type': 'object',
+ 'properties': {
+ 'id': {'type': ['integer', 'string']},
+ 'device': {'type': 'string'},
+ 'volumeId': {'type': ['integer', 'string']},
+ 'serverId': {'type': ['integer', 'string']}
+ }
+ }
+ }
+ },
+ 'required': ['id', 'status', 'displayName', 'availabilityZone',
+ 'createdAt', 'displayDescription', 'volumeType',
+ 'snapshotId', 'metadata', 'size', 'attachments']
+ }
+ },
+ 'required': ['volume']
+ }
+}
diff --git a/tempest/api_schema/compute/v3/__init__.py b/tempest/api_schema/compute/v3/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/api_schema/compute/v3/__init__.py
diff --git a/tempest/api_schema/compute/v3/servers.py b/tempest/api_schema/compute/v3/servers.py
new file mode 100644
index 0000000..e69b25f
--- /dev/null
+++ b/tempest/api_schema/compute/v3/servers.py
@@ -0,0 +1,55 @@
+# 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.
+
+create_server = {
+ 'status_code': [202],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'server': {
+ 'type': 'object',
+ 'properties': {
+ # NOTE: Now the type of 'id' is uuid, but here allows
+ # 'integer' also because old OpenStack uses 'integer'
+ # as a server id.
+ 'id': {'type': ['integer', 'string']},
+ 'os-security-groups:security_groups': {'type': 'array'},
+ 'links': {
+ 'type': 'array',
+ 'items': {
+ 'type': 'object',
+ 'properties': {
+ 'href': {
+ 'type': 'string',
+ 'format': 'uri'
+ },
+ 'rel': {'type': 'string'}
+ },
+ 'required': ['href', 'rel']
+ }
+ },
+ 'admin_password': {'type': 'string'},
+ 'os-access-ips:access_ip_v4': {'type': 'string'},
+ 'os-access-ips:access_ip_v6': {'type': 'string'}
+ },
+ # NOTE: os-access-ips:access_ip_v4/v6 are API extension,
+ # and some environments return a response without these
+ # attributes. So they are not 'required'.
+ 'required': ['id', 'os-security-groups:security_groups',
+ 'links', 'admin_password']
+ }
+ },
+ 'required': ['server']
+ }
+}
diff --git a/tempest/auth.py b/tempest/auth.py
index 8d826cf..0e45161 100644
--- a/tempest/auth.py
+++ b/tempest/auth.py
@@ -14,11 +14,11 @@
# under the License.
import copy
+import datetime
import exceptions
import re
import urlparse
-from datetime import datetime
from tempest import config
from tempest.services.identity.json import identity_client as json_id
from tempest.services.identity.v3.json import identity_client as json_v3id
@@ -68,10 +68,10 @@
"""
Decorate request with authentication data
"""
- raise NotImplemented
+ raise NotImplementedError
def _get_auth(self):
- raise NotImplemented
+ raise NotImplementedError
@classmethod
def check_credentials(cls, credentials):
@@ -98,7 +98,7 @@
self.cache = None
def is_expired(self, auth_data):
- raise NotImplemented
+ raise NotImplementedError
def auth_request(self, method, url, headers=None, body=None, filters=None):
"""
@@ -110,9 +110,6 @@
:param filters: select a base URL out of the catalog
:returns a Tuple (url, headers, body)
"""
- LOG.debug("Auth request m:{m}, u:{u}, h:{h}, b:{b}, f:{f}".format(
- m=method, u=url, h=headers, b=body, f=filters
- ))
orig_req = dict(url=url, headers=headers, body=body)
auth_url, auth_headers, auth_body = self._decorate_request(
@@ -127,7 +124,6 @@
auth_data=self.alt_auth_data)
alt_auth_req = dict(url=alt_url, headers=alt_headers,
body=alt_body)
- self._log_auth_request(alt_auth_req, 'ALTERNATE')
auth_req[self.alt_part] = alt_auth_req[self.alt_part]
else:
@@ -137,21 +133,8 @@
# Next auth request will be normal, unless otherwise requested
self.reset_alt_auth_data()
- self._log_auth_request(auth_req, 'Authorized Request:')
-
return auth_req['url'], auth_req['headers'], auth_req['body']
- def _log_auth_request(self, auth_req, tag):
- url = auth_req.get('url', None)
- headers = copy.deepcopy(auth_req.get('headers', None))
- body = auth_req.get('body', None)
- if headers is not None:
- if 'X-Auth-Token' in headers.keys():
- headers['X-Auth-Token'] = '<Token Omitted>'
- LOG.debug("[{tag}]: u: {url}, h: {headers}, b: {body}".format(
- tag=tag, url=url, headers=headers, body=body
- ))
-
def reset_alt_auth_data(self):
"""
Configure auth provider to provide valid authentication data
@@ -176,7 +159,7 @@
"""
Extracts the base_url based on provided filters
"""
- raise NotImplemented
+ raise NotImplementedError
class KeystoneAuthProvider(AuthProvider):
@@ -194,7 +177,7 @@
base_url = self.base_url(filters=filters, auth_data=auth_data)
# build authenticated request
# returns new request, it does not touch the original values
- _headers = copy.deepcopy(headers)
+ _headers = copy.deepcopy(headers) if headers is not None else {}
_headers['X-Auth-Token'] = token
if url is None or url == "":
_url = base_url
@@ -208,10 +191,10 @@
return _url, _headers, body
def _auth_client(self):
- raise NotImplemented
+ raise NotImplementedError
def _auth_params(self):
- raise NotImplemented
+ raise NotImplementedError
def _get_auth(self):
# Bypasses the cache
@@ -223,7 +206,7 @@
token, auth_data = auth_func(**auth_params)
return token, auth_data
else:
- raise NotImplemented
+ raise NotImplementedError
def get_token(self):
return self.auth_data[0]
@@ -250,7 +233,7 @@
else:
return xml_id.TokenClientXML()
else:
- raise NotImplemented
+ raise NotImplementedError
def _auth_params(self):
if self.client_type == 'tempest':
@@ -260,7 +243,7 @@
tenant=self.credentials.get('tenant_name', None),
auth_data=True)
else:
- raise NotImplemented
+ raise NotImplementedError
def base_url(self, filters, auth_data=None):
"""
@@ -299,7 +282,7 @@
path = "/" + filters['api_version']
noversion_path = "/".join(parts.path.split("/")[2:])
if noversion_path != "":
- path += noversion_path
+ path += "/" + noversion_path
_base_url = _base_url.replace(parts.path, path)
if filters.get('skip_path', None) is not None:
_base_url = _base_url.replace(parts.path, "/")
@@ -308,9 +291,9 @@
def is_expired(self, auth_data):
_, access = auth_data
- expiry = datetime.strptime(access['token']['expires'],
- self.EXPIRY_DATE_FORMAT)
- return expiry <= datetime.now()
+ expiry = datetime.datetime.strptime(access['token']['expires'],
+ self.EXPIRY_DATE_FORMAT)
+ return expiry <= datetime.datetime.now()
class KeystoneV3AuthProvider(KeystoneAuthProvider):
@@ -334,7 +317,7 @@
else:
return xml_v3id.V3TokenClientXML()
else:
- raise NotImplemented
+ raise NotImplementedError
def _auth_params(self):
if self.client_type == 'tempest':
@@ -345,7 +328,7 @@
domain=self.credentials['domain_name'],
auth_data=True)
else:
- raise NotImplemented
+ raise NotImplementedError
def base_url(self, filters, auth_data=None):
"""
@@ -388,7 +371,7 @@
ep['region'] == region]
if len(filtered_catalog) == 0:
# No matching region, take the first endpoint
- filtered_catalog = [filtered_catalog[0]]
+ filtered_catalog = [service_catalog[0]]
# There should be only one match. If not take the first.
_base_url = filtered_catalog[0].get('url', None)
if _base_url is None:
@@ -399,7 +382,7 @@
path = "/" + filters['api_version']
noversion_path = "/".join(parts.path.split("/")[2:])
if noversion_path != "":
- path += noversion_path
+ path += "/" + noversion_path
_base_url = _base_url.replace(parts.path, path)
if filters.get('skip_path', None) is not None:
_base_url = _base_url.replace(parts.path, "/")
@@ -408,6 +391,6 @@
def is_expired(self, auth_data):
_, access = auth_data
- expiry = datetime.strptime(access['expires_at'],
- self.EXPIRY_DATE_FORMAT)
- return expiry <= datetime.now()
+ expiry = datetime.datetime.strptime(access['expires_at'],
+ self.EXPIRY_DATE_FORMAT)
+ return expiry <= datetime.datetime.now()
diff --git a/tempest/cli/__init__.py b/tempest/cli/__init__.py
index a5e0447..932b151 100644
--- a/tempest/cli/__init__.py
+++ b/tempest/cli/__init__.py
@@ -42,6 +42,7 @@
def nova(self, action, flags='', params='', admin=True, fail_ok=False):
"""Executes nova command for the given action."""
+ flags += ' --endpoint-type %s' % CONF.compute.endpoint_type
return self.cmd_with_auth(
'nova', action, flags, params, admin, fail_ok)
@@ -58,37 +59,49 @@
def glance(self, action, flags='', params='', admin=True, fail_ok=False):
"""Executes glance command for the given action."""
+ flags += ' --os-endpoint-type %s' % CONF.image.endpoint_type
return self.cmd_with_auth(
'glance', action, flags, params, admin, fail_ok)
def ceilometer(self, action, flags='', params='', admin=True,
fail_ok=False):
"""Executes ceilometer command for the given action."""
+ flags += ' --os-endpoint-type %s' % CONF.telemetry.endpoint_type
return self.cmd_with_auth(
'ceilometer', action, flags, params, admin, fail_ok)
def heat(self, action, flags='', params='', admin=True,
fail_ok=False):
"""Executes heat command for the given action."""
+ flags += ' --os-endpoint-type %s' % CONF.orchestration.endpoint_type
return self.cmd_with_auth(
'heat', action, flags, params, admin, fail_ok)
def cinder(self, action, flags='', params='', admin=True, fail_ok=False):
"""Executes cinder command for the given action."""
+ flags += ' --endpoint-type %s' % CONF.volume.endpoint_type
return self.cmd_with_auth(
'cinder', action, flags, params, admin, fail_ok)
def neutron(self, action, flags='', params='', admin=True, fail_ok=False):
"""Executes neutron command for the given action."""
+ flags += ' --endpoint-type %s' % CONF.network.endpoint_type
return self.cmd_with_auth(
'neutron', action, flags, params, admin, fail_ok)
+ def sahara(self, action, flags='', params='', admin=True, fail_ok=False):
+ """Executes sahara command for the given action."""
+ flags += ' --endpoint-type %s' % CONF.data_processing.endpoint_type
+ return self.cmd_with_auth(
+ # TODO (slukjanov): replace with sahara when new client released
+ 'savanna', action, flags, params, admin, fail_ok)
+
def cmd_with_auth(self, cmd, action, flags='', params='',
admin=True, fail_ok=False):
"""Executes given command with auth attributes appended."""
# TODO(jogo) make admin=False work
creds = ('--os-username %s --os-tenant-name %s --os-password %s '
- '--os-auth-url %s ' %
+ '--os-auth-url %s' %
(CONF.identity.admin_username,
CONF.identity.admin_tenant_name,
CONF.identity.admin_password,
diff --git a/tempest/cli/simple_read_only/test_ceilometer.py b/tempest/cli/simple_read_only/test_ceilometer.py
index 0b6ae22..1d2822d 100644
--- a/tempest/cli/simple_read_only/test_ceilometer.py
+++ b/tempest/cli/simple_read_only/test_ceilometer.py
@@ -16,6 +16,7 @@
from tempest import cli
from tempest import config
from tempest.openstack.common import log as logging
+from tempest import test
CONF = config.CONF
@@ -41,6 +42,7 @@
def test_ceilometer_meter_list(self):
self.ceilometer('meter-list')
+ @test.attr(type='slow')
def test_ceilometer_resource_list(self):
self.ceilometer('resource-list')
diff --git a/tempest/cli/simple_read_only/test_neutron.py b/tempest/cli/simple_read_only/test_neutron.py
index ebf0dc4..c1d58b5 100644
--- a/tempest/cli/simple_read_only/test_neutron.py
+++ b/tempest/cli/simple_read_only/test_neutron.py
@@ -57,32 +57,34 @@
self.assertTableStruct(ext, ['alias', 'name'])
@test.attr(type='smoke')
+ @test.requires_ext(extension='dhcp_agent_scheduler', service='network')
def test_neutron_dhcp_agent_list_hosting_net(self):
self.neutron('dhcp-agent-list-hosting-net',
params=CONF.compute.fixed_network_name)
@test.attr(type='smoke')
+ @test.requires_ext(extension='agent', service='network')
def test_neutron_agent_list(self):
agents = self.parser.listing(self.neutron('agent-list'))
field_names = ['id', 'agent_type', 'host', 'alive', 'admin_state_up']
self.assertTableStruct(agents, field_names)
@test.attr(type='smoke')
+ @test.requires_ext(extension='router', service='network')
def test_neutron_floatingip_list(self):
self.neutron('floatingip-list')
- @test.skip_because(bug="1240694")
@test.attr(type='smoke')
@test.requires_ext(extension='metering', service='network')
def test_neutron_meter_label_list(self):
self.neutron('meter-label-list')
- @test.skip_because(bug="1240694")
@test.attr(type='smoke')
@test.requires_ext(extension='metering', service='network')
def test_neutron_meter_label_rule_list(self):
self.neutron('meter-label-rule-list')
+ @test.requires_ext(extension='lbaas_agent_scheduler', service='network')
def _test_neutron_lbaas_command(self, command):
try:
self.neutron(command)
@@ -107,6 +109,7 @@
self._test_neutron_lbaas_command('lb-vip-list')
@test.attr(type='smoke')
+ @test.requires_ext(extension='external-net', service='network')
def test_neutron_net_external_list(self):
self.neutron('net-external-list')
@@ -115,19 +118,23 @@
self.neutron('port-list')
@test.attr(type='smoke')
+ @test.requires_ext(extension='quotas', service='network')
def test_neutron_quota_list(self):
self.neutron('quota-list')
@test.attr(type='smoke')
+ @test.requires_ext(extension='router', service='network')
def test_neutron_router_list(self):
self.neutron('router-list')
@test.attr(type='smoke')
+ @test.requires_ext(extension='security-group', service='network')
def test_neutron_security_group_list(self):
security_grp = self.parser.listing(self.neutron('security-group-list'))
self.assertTableStruct(security_grp, ['id', 'name', 'description'])
@test.attr(type='smoke')
+ @test.requires_ext(extension='security-group', service='network')
def test_neutron_security_group_rule_list(self):
self.neutron('security-group-rule-list')
diff --git a/tempest/cli/simple_read_only/test_nova.py b/tempest/cli/simple_read_only/test_nova.py
index 62b4831..a3787ab 100644
--- a/tempest/cli/simple_read_only/test_nova.py
+++ b/tempest/cli/simple_read_only/test_nova.py
@@ -154,12 +154,18 @@
def test_admin_usage_list(self):
self.nova('usage-list')
+ @testtools.skipIf(not CONF.service_available.cinder,
+ "Skipped as Cinder is not available")
def test_admin_volume_list(self):
self.nova('volume-list')
+ @testtools.skipIf(not CONF.service_available.cinder,
+ "Skipped as Cinder is not available")
def test_admin_volume_snapshot_list(self):
self.nova('volume-snapshot-list')
+ @testtools.skipIf(not CONF.service_available.cinder,
+ "Skipped as Cinder is not available")
def test_admin_volume_type_list(self):
self.nova('volume-type-list')
diff --git a/tempest/cli/simple_read_only/test_nova_manage.py b/tempest/cli/simple_read_only/test_nova_manage.py
index 13a1589..f1fee2e 100644
--- a/tempest/cli/simple_read_only/test_nova_manage.py
+++ b/tempest/cli/simple_read_only/test_nova_manage.py
@@ -41,6 +41,10 @@
if not CONF.service_available.nova:
msg = ("%s skipped as Nova is not available" % cls.__name__)
raise cls.skipException(msg)
+ if not CONF.cli.has_manage:
+ msg = ("%s skipped as *-manage commands not available"
+ % cls.__name__)
+ raise cls.skipException(msg)
super(SimpleReadOnlyNovaManageTest, cls).setUpClass()
def test_admin_fake_action(self):
diff --git a/tempest/cli/simple_read_only/test_sahara.py b/tempest/cli/simple_read_only/test_sahara.py
new file mode 100644
index 0000000..cd819a4
--- /dev/null
+++ b/tempest/cli/simple_read_only/test_sahara.py
@@ -0,0 +1,70 @@
+# Copyright (c) 2013 Mirantis 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
+import subprocess
+
+from tempest import cli
+from tempest import config
+from tempest import test
+
+CONF = config.CONF
+
+LOG = logging.getLogger(__name__)
+
+
+class SimpleReadOnlySaharaClientTest(cli.ClientTestBase):
+ """Basic, read-only tests for Sahara CLI client.
+
+ Checks return values and output of read-only commands.
+ These tests do not presume any content, nor do they create
+ their own. They only verify the structure of output if present.
+ """
+
+ @classmethod
+ def setUpClass(cls):
+ if not CONF.service_available.sahara:
+ msg = "Skipping all Sahara cli tests because it is not available"
+ raise cls.skipException(msg)
+ super(SimpleReadOnlySaharaClientTest, cls).setUpClass()
+
+ @test.attr(type='negative')
+ def test_sahara_fake_action(self):
+ self.assertRaises(subprocess.CalledProcessError,
+ self.sahara,
+ 'this-does-not-exist')
+
+ def test_sahara_plugins_list(self):
+ plugins = self.parser.listing(self.sahara('plugin-list'))
+ self.assertTableStruct(plugins, ['name', 'versions', 'title'])
+
+ def test_sahara_plugins_show(self):
+ plugin = self.parser.listing(self.sahara('plugin-show',
+ params='--name vanilla'))
+ self.assertTableStruct(plugin, ['Property', 'Value'])
+
+ def test_sahara_node_group_template_list(self):
+ plugins = self.parser.listing(self.sahara('node-group-template-list'))
+ self.assertTableStruct(plugins, ['name', 'id', 'plugin_name',
+ 'node_processes', 'description'])
+
+ def test_sahara_cluster_template_list(self):
+ plugins = self.parser.listing(self.sahara('cluster-template-list'))
+ self.assertTableStruct(plugins, ['name', 'id', 'plugin_name',
+ 'node_groups', 'description'])
+
+ def test_sahara_cluster_list(self):
+ plugins = self.parser.listing(self.sahara('cluster-list'))
+ self.assertTableStruct(plugins, ['name', 'id', 'status', 'node_count'])
diff --git a/tempest/clients.py b/tempest/clients.py
index fd46656..7ebd983 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -13,10 +13,20 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest import auth
+# Default client libs
+import cinderclient.client
+import glanceclient
+import heatclient.client
+import keystoneclient.exceptions
+import keystoneclient.v2_0.client
+import neutronclient.v2_0.client
+import novaclient.client
+import swiftclient
+
from tempest.common.rest_client import NegativeRestClient
from tempest import config
from tempest import exceptions
+from tempest import manager
from tempest.openstack.common import log as logging
from tempest.services.baremetal.v1.client_json import BaremetalClientJSON
from tempest.services import botoclients
@@ -51,6 +61,7 @@
TenantUsagesClientJSON
from tempest.services.compute.json.volumes_extensions_client import \
VolumesExtensionsClientJSON
+from tempest.services.compute.v3.json.agents_client import AgentsV3ClientJSON
from tempest.services.compute.v3.json.aggregates_client import \
AggregatesV3ClientJSON
from tempest.services.compute.v3.json.availability_zone_client import \
@@ -63,8 +74,6 @@
from tempest.services.compute.v3.json.hosts_client import HostsV3ClientJSON
from tempest.services.compute.v3.json.hypervisor_client import \
HypervisorV3ClientJSON
-from tempest.services.compute.v3.json.instance_usage_audit_log_client import \
- InstanceUsagesAuditLogV3ClientJSON
from tempest.services.compute.v3.json.interfaces_client import \
InterfacesV3ClientJSON
from tempest.services.compute.v3.json.keypairs_client import \
@@ -75,8 +84,6 @@
ServersV3ClientJSON
from tempest.services.compute.v3.json.services_client import \
ServicesV3ClientJSON
-from tempest.services.compute.v3.json.tenant_usages_client import \
- TenantUsagesV3ClientJSON
from tempest.services.compute.v3.json.version_client import \
VersionV3ClientJSON
from tempest.services.compute.xml.aggregates_client import AggregatesClientXML
@@ -108,6 +115,8 @@
from tempest.services.compute.xml.volumes_extensions_client import \
VolumesExtensionsClientXML
from tempest.services.data_processing.v1_1.client import DataProcessingClient
+from tempest.services.database.json.flavors_client import \
+ DatabaseFlavorsClientJSON
from tempest.services.identity.json.identity_client import IdentityClientJSON
from tempest.services.identity.json.identity_client import TokenClientJSON
from tempest.services.identity.v3.json.credentials_client import \
@@ -144,22 +153,31 @@
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
from tempest.services.volume.json.extensions_client import \
ExtensionsClientJSON as VolumeExtensionClientJSON
from tempest.services.volume.json.snapshots_client import SnapshotsClientJSON
from tempest.services.volume.json.volumes_client import VolumesClientJSON
+from tempest.services.volume.v2.json.volumes_client import VolumesV2ClientJSON
+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
from tempest.services.volume.xml.extensions_client import \
ExtensionsClientXML as VolumeExtensionClientXML
from tempest.services.volume.xml.snapshots_client import SnapshotsClientXML
@@ -169,10 +187,10 @@
LOG = logging.getLogger(__name__)
-class Manager(object):
+class Manager(manager.Manager):
"""
- Top level manager for OpenStack Compute clients
+ Top level manager for OpenStack tempest clients
"""
def __init__(self, username=None, password=None, tenant_name=None,
@@ -187,153 +205,153 @@
:param tenant_name: Override of the tenant name
"""
self.interface = interface
- self.auth_version = CONF.identity.auth_version
- # FIXME(andreaf) Change Manager __init__ to accept a credentials dict
- if username is None or password is None:
- # Tenant None is a valid use case
- self.credentials = self.get_default_credentials()
- else:
- self.credentials = dict(username=username, password=password,
- tenant_name=tenant_name)
- if self.auth_version == 'v3':
- self.credentials['domain_name'] = 'Default'
- # Setup an auth provider
- auth_provider = self.get_auth_provider(self.credentials)
+ self.client_type = 'tempest'
+ # super cares for credentials validation
+ super(Manager, self).__init__(
+ username=username, password=password, tenant_name=tenant_name)
if self.interface == 'xml':
self.certificates_client = CertificatesClientXML(
- auth_provider)
- self.servers_client = ServersClientXML(auth_provider)
- self.limits_client = LimitsClientXML(auth_provider)
- self.images_client = ImagesClientXML(auth_provider)
- self.keypairs_client = KeyPairsClientXML(auth_provider)
- self.quotas_client = QuotasClientXML(auth_provider)
- self.flavors_client = FlavorsClientXML(auth_provider)
- self.extensions_client = ExtensionsClientXML(auth_provider)
+ self.auth_provider)
+ self.servers_client = ServersClientXML(self.auth_provider)
+ self.limits_client = LimitsClientXML(self.auth_provider)
+ self.images_client = ImagesClientXML(self.auth_provider)
+ self.keypairs_client = KeyPairsClientXML(self.auth_provider)
+ self.quotas_client = QuotasClientXML(self.auth_provider)
+ self.flavors_client = FlavorsClientXML(self.auth_provider)
+ self.extensions_client = ExtensionsClientXML(self.auth_provider)
self.volumes_extensions_client = VolumesExtensionsClientXML(
- auth_provider)
+ self.auth_provider)
self.floating_ips_client = FloatingIPsClientXML(
- auth_provider)
- self.snapshots_client = SnapshotsClientXML(auth_provider)
- self.volumes_client = VolumesClientXML(auth_provider)
+ self.auth_provider)
+ self.backups_client = BackupsClientXML(self.auth_provider)
+ self.snapshots_client = SnapshotsClientXML(self.auth_provider)
+ self.volumes_client = VolumesClientXML(self.auth_provider)
+ self.volumes_v2_client = VolumesV2ClientXML(self.auth_provider)
self.volume_types_client = VolumeTypesClientXML(
- auth_provider)
- self.identity_client = IdentityClientXML(auth_provider)
+ self.auth_provider)
+ self.identity_client = IdentityClientXML(self.auth_provider)
self.identity_v3_client = IdentityV3ClientXML(
- auth_provider)
+ self.auth_provider)
self.security_groups_client = SecurityGroupsClientXML(
- auth_provider)
- self.interfaces_client = InterfacesClientXML(auth_provider)
- self.endpoints_client = EndPointClientXML(auth_provider)
- self.fixed_ips_client = FixedIPsClientXML(auth_provider)
+ self.auth_provider)
+ self.interfaces_client = InterfacesClientXML(self.auth_provider)
+ self.endpoints_client = EndPointClientXML(self.auth_provider)
+ self.fixed_ips_client = FixedIPsClientXML(self.auth_provider)
self.availability_zone_client = AvailabilityZoneClientXML(
- auth_provider)
- self.service_client = ServiceClientXML(auth_provider)
- self.aggregates_client = AggregatesClientXML(auth_provider)
- self.services_client = ServicesClientXML(auth_provider)
+ self.auth_provider)
+ self.service_client = ServiceClientXML(self.auth_provider)
+ self.aggregates_client = AggregatesClientXML(self.auth_provider)
+ self.services_client = ServicesClientXML(self.auth_provider)
self.tenant_usages_client = TenantUsagesClientXML(
- auth_provider)
- self.policy_client = PolicyClientXML(auth_provider)
- self.hosts_client = HostsClientXML(auth_provider)
- self.hypervisor_client = HypervisorClientXML(auth_provider)
- self.network_client = NetworkClientXML(auth_provider)
+ self.auth_provider)
+ self.policy_client = PolicyClientXML(self.auth_provider)
+ self.hosts_client = HostsClientXML(self.auth_provider)
+ self.hypervisor_client = HypervisorClientXML(self.auth_provider)
+ self.network_client = NetworkClientXML(self.auth_provider)
self.credentials_client = CredentialsClientXML(
- auth_provider)
+ self.auth_provider)
self.instance_usages_audit_log_client = \
- InstanceUsagesAuditLogClientXML(auth_provider)
+ InstanceUsagesAuditLogClientXML(self.auth_provider)
self.volume_hosts_client = VolumeHostsClientXML(
- auth_provider)
+ self.auth_provider)
+ self.volume_quotas_client = VolumeQuotasClientXML(
+ self.auth_provider)
self.volumes_extension_client = VolumeExtensionClientXML(
- auth_provider)
+ self.auth_provider)
if CONF.service_available.ceilometer:
self.telemetry_client = TelemetryClientXML(
- auth_provider)
+ self.auth_provider)
self.token_client = TokenClientXML()
self.token_v3_client = V3TokenClientXML()
elif self.interface == 'json':
self.certificates_client = CertificatesClientJSON(
- auth_provider)
+ self.auth_provider)
self.certificates_v3_client = CertificatesV3ClientJSON(
- auth_provider)
- self.baremetal_client = BaremetalClientJSON(auth_provider)
- self.servers_client = ServersClientJSON(auth_provider)
- self.servers_v3_client = ServersV3ClientJSON(auth_provider)
- self.limits_client = LimitsClientJSON(auth_provider)
- self.images_client = ImagesClientJSON(auth_provider)
+ self.auth_provider)
+ self.baremetal_client = BaremetalClientJSON(self.auth_provider)
+ self.servers_client = ServersClientJSON(self.auth_provider)
+ self.servers_v3_client = ServersV3ClientJSON(self.auth_provider)
+ self.limits_client = LimitsClientJSON(self.auth_provider)
+ self.images_client = ImagesClientJSON(self.auth_provider)
self.keypairs_v3_client = KeyPairsV3ClientJSON(
- auth_provider)
- self.keypairs_client = KeyPairsClientJSON(auth_provider)
+ self.auth_provider)
+ self.keypairs_client = KeyPairsClientJSON(self.auth_provider)
self.keypairs_v3_client = KeyPairsV3ClientJSON(
- auth_provider)
- self.quotas_client = QuotasClientJSON(auth_provider)
- self.quotas_v3_client = QuotasV3ClientJSON(auth_provider)
- self.flavors_client = FlavorsClientJSON(auth_provider)
- self.flavors_v3_client = FlavorsV3ClientJSON(auth_provider)
+ self.auth_provider)
+ self.quotas_client = QuotasClientJSON(self.auth_provider)
+ self.quotas_v3_client = QuotasV3ClientJSON(self.auth_provider)
+ self.flavors_client = FlavorsClientJSON(self.auth_provider)
+ self.flavors_v3_client = FlavorsV3ClientJSON(self.auth_provider)
self.extensions_v3_client = ExtensionsV3ClientJSON(
- auth_provider)
+ self.auth_provider)
self.extensions_client = ExtensionsClientJSON(
- auth_provider)
+ self.auth_provider)
self.volumes_extensions_client = VolumesExtensionsClientJSON(
- auth_provider)
+ self.auth_provider)
self.floating_ips_client = FloatingIPsClientJSON(
- auth_provider)
- self.snapshots_client = SnapshotsClientJSON(auth_provider)
- self.volumes_client = VolumesClientJSON(auth_provider)
+ self.auth_provider)
+ self.backups_client = BackupsClientJSON(self.auth_provider)
+ self.snapshots_client = SnapshotsClientJSON(self.auth_provider)
+ self.volumes_client = VolumesClientJSON(self.auth_provider)
+ self.volumes_v2_client = VolumesV2ClientJSON(self.auth_provider)
self.volume_types_client = VolumeTypesClientJSON(
- auth_provider)
- self.identity_client = IdentityClientJSON(auth_provider)
+ self.auth_provider)
+ self.identity_client = IdentityClientJSON(self.auth_provider)
self.identity_v3_client = IdentityV3ClientJSON(
- auth_provider)
+ self.auth_provider)
self.security_groups_client = SecurityGroupsClientJSON(
- auth_provider)
+ self.auth_provider)
self.interfaces_v3_client = InterfacesV3ClientJSON(
- auth_provider)
+ self.auth_provider)
self.interfaces_client = InterfacesClientJSON(
- auth_provider)
- self.endpoints_client = EndPointClientJSON(auth_provider)
- self.fixed_ips_client = FixedIPsClientJSON(auth_provider)
+ self.auth_provider)
+ self.endpoints_client = EndPointClientJSON(self.auth_provider)
+ self.fixed_ips_client = FixedIPsClientJSON(self.auth_provider)
self.availability_zone_v3_client = AvailabilityZoneV3ClientJSON(
- auth_provider)
+ self.auth_provider)
self.availability_zone_client = AvailabilityZoneClientJSON(
- auth_provider)
+ self.auth_provider)
self.services_v3_client = ServicesV3ClientJSON(
- auth_provider)
- self.service_client = ServiceClientJSON(auth_provider)
+ self.auth_provider)
+ self.service_client = ServiceClientJSON(self.auth_provider)
+ self.agents_v3_client = AgentsV3ClientJSON(self.auth_provider)
self.aggregates_v3_client = AggregatesV3ClientJSON(
- auth_provider)
+ self.auth_provider)
self.aggregates_client = AggregatesClientJSON(
- auth_provider)
- self.services_client = ServicesClientJSON(auth_provider)
- self.tenant_usages_v3_client = TenantUsagesV3ClientJSON(
- auth_provider)
+ self.auth_provider)
+ self.services_client = ServicesClientJSON(self.auth_provider)
self.tenant_usages_client = TenantUsagesClientJSON(
- auth_provider)
- self.version_v3_client = VersionV3ClientJSON(auth_provider)
- self.policy_client = PolicyClientJSON(auth_provider)
- self.hosts_client = HostsClientJSON(auth_provider)
+ self.auth_provider)
+ self.version_v3_client = VersionV3ClientJSON(self.auth_provider)
+ self.policy_client = PolicyClientJSON(self.auth_provider)
+ self.hosts_client = HostsClientJSON(self.auth_provider)
self.hypervisor_v3_client = HypervisorV3ClientJSON(
- auth_provider)
+ self.auth_provider)
self.hypervisor_client = HypervisorClientJSON(
- auth_provider)
- self.network_client = NetworkClientJSON(auth_provider)
+ self.auth_provider)
+ self.network_client = NetworkClientJSON(self.auth_provider)
self.credentials_client = CredentialsClientJSON(
- auth_provider)
+ self.auth_provider)
self.instance_usages_audit_log_client = \
- InstanceUsagesAuditLogClientJSON(auth_provider)
- self.instance_usages_audit_log_v3_client = \
- InstanceUsagesAuditLogV3ClientJSON(auth_provider)
+ InstanceUsagesAuditLogClientJSON(self.auth_provider)
self.volume_hosts_client = VolumeHostsClientJSON(
- auth_provider)
+ self.auth_provider)
+ self.volume_quotas_client = VolumeQuotasClientJSON(
+ self.auth_provider)
self.volumes_extension_client = VolumeExtensionClientJSON(
- auth_provider)
- self.hosts_v3_client = HostsV3ClientJSON(auth_provider)
+ 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(
- auth_provider)
+ self.auth_provider)
self.token_client = TokenClientJSON()
self.token_v3_client = V3TokenClientJSON()
- self.negative_client = NegativeRestClient(auth_provider)
+ self.negative_client = NegativeRestClient(self.auth_provider)
self.negative_client.service = service
else:
@@ -347,47 +365,22 @@
self.credentials.get('tenant_name'))
# common clients
- self.account_client = AccountClient(auth_provider)
+ self.account_client = AccountClient(self.auth_provider)
if CONF.service_available.glance:
- self.image_client = ImageClientJSON(auth_provider)
- self.image_client_v2 = ImageClientV2JSON(auth_provider)
- self.container_client = ContainerClient(auth_provider)
- self.object_client = ObjectClient(auth_provider)
+ self.image_client = ImageClientJSON(self.auth_provider)
+ self.image_client_v2 = ImageClientV2JSON(self.auth_provider)
+ self.container_client = ContainerClient(self.auth_provider)
+ self.object_client = ObjectClient(self.auth_provider)
self.orchestration_client = OrchestrationClient(
- auth_provider)
+ self.auth_provider)
self.ec2api_client = botoclients.APIClientEC2(*ec2_client_args)
self.s3_client = botoclients.ObjectClientS3(*ec2_client_args)
self.custom_object_client = ObjectClientCustomizedHeader(
- auth_provider)
+ self.auth_provider)
self.custom_account_client = \
- AccountClientCustomizedHeader(auth_provider)
+ AccountClientCustomizedHeader(self.auth_provider)
self.data_processing_client = DataProcessingClient(
- auth_provider)
-
- @classmethod
- def get_auth_provider_class(cls, auth_version):
- if auth_version == 'v2':
- return auth.KeystoneV2AuthProvider
- else:
- return auth.KeystoneV3AuthProvider
-
- def get_default_credentials(self):
- return dict(
- username=CONF.identity.username,
- password=CONF.identity.password,
- tenant_name=CONF.identity.tenant_name
- )
-
- def get_auth_provider(self, credentials=None):
- auth_params = dict(client_type='tempest',
- interface=self.interface)
- auth_provider_class = self.get_auth_provider_class(self.auth_version)
- # If invalid / incomplete credentials are provided, use default ones
- if credentials is None or \
- not auth_provider_class.check_credentials(credentials):
- credentials = self.credentials
- auth_params['credentials'] = credentials
- return auth_provider_class(**auth_params)
+ self.auth_provider)
class AltManager(Manager):
@@ -443,8 +436,196 @@
"""
def __init__(self, interface='json', service=None):
base = super(OrchestrationManager, self)
+ # heat currently needs an admin user so that stacks can create users
+ # however the tests need the demo tenant so that the neutron
+ # private network is the default. DO NOT change this auth combination
+ # until heat can run with the demo user.
base.__init__(CONF.identity.admin_username,
CONF.identity.admin_password,
CONF.identity.tenant_name,
interface=interface,
service=service)
+
+
+class OfficialClientManager(manager.Manager):
+ """
+ Manager that provides access to the official python clients for
+ calling various OpenStack APIs.
+ """
+
+ NOVACLIENT_VERSION = '2'
+ CINDERCLIENT_VERSION = '1'
+ HEATCLIENT_VERSION = '1'
+
+ def __init__(self, username, password, tenant_name):
+ # FIXME(andreaf) Auth provider for client_type 'official' is
+ # not implemented yet, setting to 'tempest' for now.
+ self.client_type = 'tempest'
+ self.interface = None
+ # super cares for credentials validation
+ super(OfficialClientManager, self).__init__(
+ username=username, password=password, tenant_name=tenant_name)
+ self.compute_client = self._get_compute_client(username,
+ password,
+ tenant_name)
+ self.identity_client = self._get_identity_client(username,
+ password,
+ tenant_name)
+ self.image_client = self._get_image_client()
+ self.network_client = self._get_network_client()
+ self.volume_client = self._get_volume_client(username,
+ password,
+ tenant_name)
+ self.object_storage_client = self._get_object_storage_client(
+ username,
+ password,
+ tenant_name)
+ self.orchestration_client = self._get_orchestration_client(
+ username,
+ password,
+ tenant_name)
+
+ def _get_compute_client(self, username, password, tenant_name):
+ # Novaclient will not execute operations for anyone but the
+ # identified user, so a new client needs to be created for
+ # each user that operations need to be performed for.
+ self._validate_credentials(username, password, tenant_name)
+
+ auth_url = CONF.identity.uri
+ dscv = CONF.identity.disable_ssl_certificate_validation
+ region = CONF.identity.region
+
+ client_args = (username, password, tenant_name, auth_url)
+
+ # Create our default Nova client to use in testing
+ service_type = CONF.compute.catalog_type
+ endpoint_type = CONF.compute.endpoint_type
+ return novaclient.client.Client(self.NOVACLIENT_VERSION,
+ *client_args,
+ service_type=service_type,
+ endpoint_type=endpoint_type,
+ region_name=region,
+ no_cache=True,
+ insecure=dscv,
+ http_log_debug=True)
+
+ def _get_image_client(self):
+ token = self.identity_client.auth_token
+ region = CONF.identity.region
+ endpoint_type = CONF.image.endpoint_type
+ endpoint = self.identity_client.service_catalog.url_for(
+ attr='region', filter_value=region,
+ service_type=CONF.image.catalog_type, endpoint_type=endpoint_type)
+ dscv = CONF.identity.disable_ssl_certificate_validation
+ return glanceclient.Client('1', endpoint=endpoint, token=token,
+ insecure=dscv)
+
+ def _get_volume_client(self, username, password, tenant_name):
+ auth_url = CONF.identity.uri
+ region = CONF.identity.region
+ endpoint_type = CONF.volume.endpoint_type
+ return cinderclient.client.Client(self.CINDERCLIENT_VERSION,
+ username,
+ password,
+ tenant_name,
+ auth_url,
+ region_name=region,
+ endpoint_type=endpoint_type,
+ http_log_debug=True)
+
+ def _get_object_storage_client(self, username, password, tenant_name):
+ auth_url = CONF.identity.uri
+ # add current tenant to swift operator role group.
+ keystone_admin = self._get_identity_client(
+ CONF.identity.admin_username,
+ CONF.identity.admin_password,
+ CONF.identity.admin_tenant_name)
+
+ # enable test user to operate swift by adding operator role to him.
+ roles = keystone_admin.roles.list()
+ operator_role = CONF.object_storage.operator_role
+ member_role = [role for role in roles if role.name == operator_role][0]
+ # NOTE(maurosr): This is surrounded in the try-except block cause
+ # neutron tests doesn't have tenant isolation.
+ try:
+ keystone_admin.roles.add_user_role(self.identity_client.user_id,
+ member_role.id,
+ self.identity_client.tenant_id)
+ except keystoneclient.exceptions.Conflict:
+ pass
+
+ endpoint_type = CONF.object_storage.endpoint_type
+ os_options = {'endpoint_type': endpoint_type}
+ return swiftclient.Connection(auth_url, username, password,
+ tenant_name=tenant_name,
+ auth_version='2',
+ os_options=os_options)
+
+ def _get_orchestration_client(self, username=None, password=None,
+ tenant_name=None):
+ if not username:
+ username = CONF.identity.admin_username
+ if not password:
+ password = CONF.identity.admin_password
+ if not tenant_name:
+ tenant_name = CONF.identity.tenant_name
+
+ self._validate_credentials(username, password, tenant_name)
+
+ keystone = self._get_identity_client(username, password, tenant_name)
+ region = CONF.identity.region
+ endpoint_type = CONF.orchestration.endpoint_type
+ token = keystone.auth_token
+ service_type = CONF.orchestration.catalog_type
+ try:
+ endpoint = keystone.service_catalog.url_for(
+ attr='region',
+ filter_value=region,
+ service_type=service_type,
+ endpoint_type=endpoint_type)
+ except keystoneclient.exceptions.EndpointNotFound:
+ return None
+ else:
+ return heatclient.client.Client(self.HEATCLIENT_VERSION,
+ endpoint,
+ token=token,
+ username=username,
+ password=password)
+
+ def _get_identity_client(self, username, password, tenant_name):
+ # This identity client is not intended to check the security
+ # of the identity service, so use admin credentials by default.
+ self._validate_credentials(username, password, tenant_name)
+
+ auth_url = CONF.identity.uri
+ dscv = CONF.identity.disable_ssl_certificate_validation
+
+ return keystoneclient.v2_0.client.Client(username=username,
+ password=password,
+ tenant_name=tenant_name,
+ auth_url=auth_url,
+ insecure=dscv)
+
+ def _get_network_client(self):
+ # The intended configuration is for the network client to have
+ # admin privileges and indicate for whom resources are being
+ # created via a 'tenant_id' parameter. This will often be
+ # preferable to authenticating as a specific user because
+ # working with certain resources (public routers and networks)
+ # often requires admin privileges anyway.
+ username = CONF.identity.admin_username
+ password = CONF.identity.admin_password
+ tenant_name = CONF.identity.admin_tenant_name
+
+ self._validate_credentials(username, password, tenant_name)
+
+ auth_url = CONF.identity.uri
+ dscv = CONF.identity.disable_ssl_certificate_validation
+ endpoint_type = CONF.network.endpoint_type
+
+ return neutronclient.v2_0.client.Client(username=username,
+ password=password,
+ tenant_name=tenant_name,
+ endpoint_type=endpoint_type,
+ auth_url=auth_url,
+ insecure=dscv)
diff --git a/tempest/common/commands.py b/tempest/common/commands.py
index 6405eaa..c31a038 100644
--- a/tempest/common/commands.py
+++ b/tempest/common/commands.py
@@ -73,3 +73,7 @@
def iptables_ns(ns, table):
return ip_ns_exec(ns, "iptables -v -S -t " + table)
+
+
+def ovs_db_dump():
+ return sudo_cmd_call("ovsdb-client dump")
diff --git a/tempest/common/debug.py b/tempest/common/debug.py
index 8325d4d..6a496c2 100644
--- a/tempest/common/debug.py
+++ b/tempest/common/debug.py
@@ -38,3 +38,15 @@
for table in ['filter', 'nat', 'mangle']:
LOG.info('ns(%s) table(%s):\n%s', ns, table,
commands.iptables_ns(ns, table))
+
+
+def log_ovs_db():
+ if not CONF.debug.enable or not CONF.service_available.neutron:
+ return
+ db_dump = commands.ovs_db_dump()
+ LOG.info("OVS DB:\n" + db_dump)
+
+
+def log_net_debug():
+ log_ip_ns()
+ log_ovs_db()
diff --git a/tempest/common/generate_json.py b/tempest/common/generate_json.py
deleted file mode 100644
index 0a0afe4..0000000
--- a/tempest/common/generate_json.py
+++ /dev/null
@@ -1,239 +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": {"type": "string"}},
- "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/generate_sample_tempest.py b/tempest/common/generate_sample_tempest.py
index e1213db..ceb3394 100644
--- a/tempest/common/generate_sample_tempest.py
+++ b/tempest/common/generate_sample_tempest.py
@@ -31,5 +31,5 @@
if __name__ == "__main__":
- CONF = tempest.config.TempestConfigPrivate(False)
+ tempest.config.register_opts()
generator.generate(sys.argv[1:])
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/glance_http.py b/tempest/common/glance_http.py
index 4503f13..b4ba933 100644
--- a/tempest/common/glance_http.py
+++ b/tempest/common/glance_http.py
@@ -21,6 +21,7 @@
import json
import posixpath
import re
+from six import moves
import socket
import StringIO
import struct
@@ -264,7 +265,7 @@
# Also try Subject Alternative Names for a match
san_list = None
- for i in xrange(x509.get_extension_count()):
+ for i in moves.xrange(x509.get_extension_count()):
ext = x509.get_extension(i)
if ext.get_short_name() == 'subjectAltName':
san_list = str(ext)
diff --git a/tempest/common/isolated_creds.py b/tempest/common/isolated_creds.py
index ac8b14f..c54a8e8 100644
--- a/tempest/common/isolated_creds.py
+++ b/tempest/common/isolated_creds.py
@@ -456,7 +456,8 @@
port
for port in self.ports
if (port['network_id'] == network_id and
- port['device_owner'] != 'network:router_interface')
+ port['device_owner'] != 'network:router_interface' and
+ port['device_owner'] != 'network:dhcp')
]
for port in ports_to_delete:
try:
diff --git a/tempest/common/rest_client.py b/tempest/common/rest_client.py
index 8a85602..88dbe58 100644
--- a/tempest/common/rest_client.py
+++ b/tempest/common/rest_client.py
@@ -21,11 +21,13 @@
import re
import time
+import jsonschema
+
from tempest.common import http
from tempest import config
from tempest import exceptions
from tempest.openstack.common import log as logging
-from tempest.services.compute.xml.common import xml_to_json
+from tempest.services.compute.xml import common
CONF = config.CONF
@@ -38,19 +40,31 @@
class RestClient(object):
+
TYPE = "json"
+
+ # This is used by _parse_resp method
+ # Redefine it for purposes of your xml service client
+ # List should contain top-xml_tag-names of data, which is like list/array
+ # For example, in keystone it is users, roles, tenants and services
+ # All of it has children with same tag-names
+ list_tags = []
+
+ # This is used by _parse_resp method too
+ # Used for selection of dict-like xmls,
+ # like metadata for Vms in nova, and volumes in cinder
+ dict_tags = ["metadata", ]
+
LOG = logging.getLogger(__name__)
def __init__(self, auth_provider):
self.auth_provider = auth_provider
- self.endpoint_url = 'publicURL'
+ self.endpoint_url = None
self.service = None
# The version of the API this client implements
self.api_version = None
self._skip_path = False
- self.headers = {'Content-Type': 'application/%s' % self.TYPE,
- 'Accept': 'application/%s' % self.TYPE}
self.build_interval = CONF.compute.build_interval
self.build_timeout = CONF.compute.build_timeout
self.general_header_lc = set(('cache-control', 'connection',
@@ -65,6 +79,17 @@
self.http_obj = http.ClosingHttp(
disable_ssl_certificate_validation=dscv)
+ def _get_type(self):
+ return self.TYPE
+
+ def get_headers(self, accept_type=None, send_type=None):
+ if accept_type is None:
+ accept_type = self._get_type()
+ if send_type is None:
+ send_type = self._get_type()
+ return {'Content-Type': 'application/%s' % send_type,
+ 'Accept': 'application/%s' % accept_type}
+
def __str__(self):
STRING_LIMIT = 80
str_format = ("config:%s, service:%s, base_url:%s, "
@@ -74,7 +99,7 @@
self.filters, self.build_interval,
self.build_timeout,
str(self.token)[0:STRING_LIMIT],
- str(self.headers)[0:STRING_LIMIT])
+ str(self.get_headers())[0:STRING_LIMIT])
def _get_region(self, service):
"""
@@ -91,6 +116,28 @@
service_region = CONF.identity.region
return service_region
+ def _get_endpoint_type(self, service):
+ """
+ Returns the endpoint type for a specific service
+ """
+ # If the client requests a specific endpoint type, then be it
+ if self.endpoint_url:
+ return self.endpoint_url
+ endpoint_type = None
+ for cfgname in dir(CONF._config):
+ # Find all config.FOO.catalog_type and assume FOO is a service.
+ cfg = getattr(CONF, cfgname)
+ catalog_type = getattr(cfg, 'catalog_type', None)
+ if catalog_type == service:
+ endpoint_type = getattr(cfg, 'endpoint_type', 'publicURL')
+ break
+ # Special case for compute v3 service which hasn't its own
+ # configuration group
+ else:
+ if service == CONF.compute.catalog_v3_type:
+ endpoint_type = CONF.compute.endpoint_type
+ return endpoint_type
+
@property
def user(self):
return self.auth_provider.credentials.get('username', None)
@@ -108,10 +155,14 @@
return self.auth_provider.base_url(filters=self.filters)
@property
+ def token(self):
+ return self.auth_provider.get_token()
+
+ @property
def filters(self):
_filters = dict(
service=self.service,
- endpoint_type=self.endpoint_url,
+ endpoint_type=self._get_endpoint_type(self.service),
region=self._get_region(self.service)
)
if self.api_version is not None:
@@ -146,7 +197,7 @@
details = pattern.format(read_code, expected_code)
raise exceptions.InvalidHttpSuccessCode(details)
- def post(self, url, body, headers):
+ def post(self, url, body, headers=None):
return self.request('POST', url, headers, body)
def get(self, url, headers=None):
@@ -155,10 +206,10 @@
def delete(self, url, headers=None, body=None):
return self.request('DELETE', url, headers, body)
- def patch(self, url, body, headers):
+ def patch(self, url, body, headers=None):
return self.request('PATCH', url, headers, body)
- def put(self, url, body, headers):
+ def put(self, url, body, headers=None):
return self.request('PUT', url, headers, body)
def head(self, url, headers=None):
@@ -170,7 +221,6 @@
def get_versions(self):
resp, body = self.get('')
body = self._parse_resp(body)
- body = body['versions']
versions = map(lambda x: x['id'], body)
return resp, versions
@@ -198,10 +248,10 @@
headers = resp.copy()
del headers['status']
if headers.get('x-compute-request-id'):
- self.LOG.info("Nova request id: %s" %
+ self.LOG.info("Nova/Cinder request id: %s" %
headers.pop('x-compute-request-id'))
elif headers.get('x-openstack-request-id'):
- self.LOG.info("Glance request id %s" %
+ self.LOG.info("OpenStack request id %s" %
headers.pop('x-openstack-request-id'))
if len(headers):
self.LOG.debug('Response Headers: ' + str(headers))
@@ -214,7 +264,48 @@
hashlib.md5(str_body).hexdigest())
def _parse_resp(self, body):
- return json.loads(body)
+ if self._get_type() is "json":
+ body = json.loads(body)
+
+ # We assume, that if the first value of the deserialized body's
+ # item set is a dict or a list, that we just return the first value
+ # of deserialized body.
+ # Essentially "cutting out" the first placeholder element in a body
+ # that looks like this:
+ #
+ # {
+ # "users": [
+ # ...
+ # ]
+ # }
+ try:
+ # Ensure there are not more than one top-level keys
+ if len(body.keys()) > 1:
+ return body
+ # Just return the "wrapped" element
+ first_key, first_item = body.items()[0]
+ if isinstance(first_item, (dict, list)):
+ return first_item
+ except (ValueError, IndexError):
+ pass
+ return body
+ elif self._get_type() is "xml":
+ element = etree.fromstring(body)
+ if any(s in element.tag for s in self.dict_tags):
+ # Parse dictionary-like xmls (metadata, etc)
+ dictionary = {}
+ for el in element.getchildren():
+ dictionary[u"%s" % el.get("key")] = u"%s" % el.text
+ return dictionary
+ if any(s in element.tag for s in self.list_tags):
+ # Parse list-like xmls (users, roles, etc)
+ array = []
+ for child in element.getchildren():
+ array.append(common.xml_to_json(child))
+ return array
+
+ # Parse one-item-like xmls (user, role, etc)
+ return common.xml_to_json(element)
def response_checker(self, method, url, headers, body, resp, resp_body):
if (resp.status in set((204, 205, 304)) or resp.status < 200 or
@@ -244,8 +335,7 @@
if not resp_body and resp.status >= 400:
self.LOG.warning("status >= 400 response with empty body")
- def _request(self, method, url,
- headers=None, body=None):
+ def _request(self, method, url, headers=None, body=None):
"""A simple HTTP request interface."""
# Authenticate the request with the auth provider
req_url, req_headers, req_body = self.auth_provider.auth_request(
@@ -261,12 +351,13 @@
return resp, resp_body
- def request(self, method, url,
- headers=None, body=None):
+ def request(self, method, url, headers=None, body=None):
retry = 0
if headers is None:
- headers = {}
+ # NOTE(vponomaryov): if some client do not need headers,
+ # it should explicitly pass empty dict
+ headers = self.get_headers()
resp, resp_body = self._request(method, url,
headers=headers, body=body)
@@ -320,7 +411,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()
@@ -362,34 +453,38 @@
# 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
'retry-after' not in resp):
return True
- over_limit = resp_body.get('overLimit', None)
- if not over_limit:
- return True
- return 'exceed' in over_limit.get('message', 'blabla')
+ if self._get_type() is "json":
+ over_limit = resp_body.get('overLimit', None)
+ if not over_limit:
+ return True
+ return 'exceed' in over_limit.get('message', 'blabla')
+ elif self._get_type() is "xml":
+ return 'exceed' in resp_body.get('message', 'blabla')
def wait_for_resource_deletion(self, id):
"""Waits for a resource to be deleted."""
@@ -409,18 +504,30 @@
% self.__class__.__name__)
raise NotImplementedError(message)
-
-class RestClientXML(RestClient):
- TYPE = "xml"
-
- def _parse_resp(self, body):
- return xml_to_json(etree.fromstring(body))
-
- def is_absolute_limit(self, resp, resp_body):
- if (not isinstance(resp_body, collections.Mapping) or
- 'retry-after' not in resp):
- return True
- return 'exceed' in resp_body.get('message', 'blabla')
+ @classmethod
+ def validate_response(cls, schema, resp, body):
+ # Only check the response if the status code is a success code
+ # TODO(cyeoh): Eventually we should be able to verify that a failure
+ # code if it exists is something that we expect. This is explicitly
+ # declared in the V3 API and so we should be able to export this in
+ # the response schema. For now we'll ignore it.
+ if str(resp.status).startswith('2'):
+ 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)
class NegativeRestClient(RestClient):
@@ -436,11 +543,11 @@
if method == "GET":
resp, body = self.get(url)
elif method == "POST":
- resp, body = self.post(url, body, self.headers)
+ resp, body = self.post(url, body)
elif method == "PUT":
- resp, body = self.put(url, body, self.headers)
+ resp, body = self.put(url, body)
elif method == "PATCH":
- resp, body = self.patch(url, body, self.headers)
+ resp, body = self.patch(url, body)
elif method == "HEAD":
resp, body = self.head(url)
elif method == "DELETE":
diff --git a/tempest/common/ssh.py b/tempest/common/ssh.py
index c772ce9..531887c 100644
--- a/tempest/common/ssh.py
+++ b/tempest/common/ssh.py
@@ -16,6 +16,7 @@
import cStringIO
import select
+import six
import socket
import time
import warnings
@@ -39,7 +40,7 @@
self.host = host
self.username = username
self.password = password
- if isinstance(pkey, basestring):
+ if isinstance(pkey, six.string_types):
pkey = paramiko.RSAKey.from_private_key(
cStringIO.StringIO(str(pkey)))
self.pkey = pkey
@@ -72,7 +73,7 @@
look_for_keys=self.look_for_keys,
key_filename=self.key_filename,
timeout=self.channel_timeout, pkey=self.pkey)
- LOG.info("ssh connection to %s@%s sucessfuly created",
+ LOG.info("ssh connection to %s@%s successfuly created",
self.username, self.host)
return ssh
except (socket.error,
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/common/utils/linux/remote_client.py b/tempest/common/utils/linux/remote_client.py
index bb2fcfb..00e5e0d 100644
--- a/tempest/common/utils/linux/remote_client.py
+++ b/tempest/common/utils/linux/remote_client.py
@@ -11,11 +11,12 @@
# under the License.
import re
+import six
import time
-from tempest.common.ssh import Client
+from tempest.common import ssh
from tempest import config
-from tempest.exceptions import ServerUnreachable
+from tempest import exceptions
CONF = config.CONF
@@ -28,7 +29,7 @@
network = CONF.compute.network_for_ssh
ip_version = CONF.compute.ip_version_for_ssh
ssh_channel_timeout = CONF.compute.ssh_channel_timeout
- if isinstance(server, basestring):
+ if isinstance(server, six.string_types):
ip_address = server
else:
addresses = server['addresses'][network]
@@ -37,10 +38,13 @@
ip_address = address['addr']
break
else:
- raise ServerUnreachable()
- self.ssh_client = Client(ip_address, username, password, ssh_timeout,
- pkey=pkey,
- channel_timeout=ssh_channel_timeout)
+ raise exceptions.ServerUnreachable()
+ self.ssh_client = ssh.Client(ip_address, username, password,
+ ssh_timeout, pkey=pkey,
+ channel_timeout=ssh_channel_timeout)
+
+ def exec_command(self, cmd):
+ return self.ssh_client.exec_command(cmd)
def validate_authentication(self):
"""Validate ssh connection and authentication
@@ -50,33 +54,33 @@
def hostname_equals_servername(self, expected_hostname):
# Get host name using command "hostname"
- actual_hostname = self.ssh_client.exec_command("hostname").rstrip()
+ actual_hostname = self.exec_command("hostname").rstrip()
return expected_hostname == actual_hostname
def get_files(self, path):
# Return a list of comma separated files
command = "ls -m " + path
- return self.ssh_client.exec_command(command).rstrip('\n').split(', ')
+ return self.exec_command(command).rstrip('\n').split(', ')
def get_ram_size_in_mb(self):
- output = self.ssh_client.exec_command('free -m | grep Mem')
+ output = self.exec_command('free -m | grep Mem')
if output:
return output.split()[1]
def get_number_of_vcpus(self):
command = 'cat /proc/cpuinfo | grep processor | wc -l'
- output = self.ssh_client.exec_command(command)
+ output = self.exec_command(command)
return int(output)
def get_partitions(self):
# Return the contents of /proc/partitions
command = 'cat /proc/partitions'
- output = self.ssh_client.exec_command(command)
+ output = self.exec_command(command)
return output
def get_boot_time(self):
cmd = 'cut -f1 -d. /proc/uptime'
- boot_secs = self.ssh_client.exec_command(cmd)
+ boot_secs = self.exec_command(cmd)
boot_time = time.time() - int(boot_secs)
return time.localtime(boot_time)
@@ -84,12 +88,27 @@
message = re.sub("([$\\`])", "\\\\\\\\\\1", message)
# usually to /dev/ttyS0
cmd = 'sudo sh -c "echo \\"%s\\" >/dev/console"' % message
- return self.ssh_client.exec_command(cmd)
+ return self.exec_command(cmd)
def ping_host(self, host):
cmd = 'ping -c1 -w1 %s' % host
- return self.ssh_client.exec_command(cmd)
+ return self.exec_command(cmd)
def get_mac_address(self):
cmd = "/sbin/ifconfig | awk '/HWaddr/ {print $5}'"
- return self.ssh_client.exec_command(cmd)
+ return self.exec_command(cmd)
+
+ def get_ip_list(self):
+ cmd = "/bin/ip address"
+ return self.exec_command(cmd)
+
+ def assign_static_ip(self, nic, addr):
+ cmd = "sudo /bin/ip addr add {ip}/{mask} dev {nic}".format(
+ ip=addr, mask=CONF.network.tenant_network_mask_bits,
+ nic=nic
+ )
+ return self.exec_command(cmd)
+
+ def turn_nic_on(self, nic):
+ cmd = "sudo /bin/ip link set {nic} up".format(nic=nic)
+ return self.exec_command(cmd)
diff --git a/tempest/common/utils/test_utils.py b/tempest/common/utils/test_utils.py
index eca716e..cc0d831 100644
--- a/tempest/common/utils/test_utils.py
+++ b/tempest/common/utils/test_utils.py
@@ -12,9 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest import clients
from tempest.common.utils import misc
from tempest import config
-from tempest.scenario import manager
import json
import re
@@ -35,7 +35,7 @@
self.non_ssh_image_pattern = \
CONF.input_scenario.non_ssh_image_regex
# Setup clients
- ocm = manager.OfficialClientManager(CONF.identity.username,
+ ocm = clients.OfficialClientManager(CONF.identity.username,
CONF.identity.password,
CONF.identity.tenant_name)
self.client = ocm.compute_client
@@ -95,7 +95,7 @@
digit=string.digits)
def __init__(self):
- ocm = manager.OfficialClientManager(CONF.identity.username,
+ ocm = clients.OfficialClientManager(CONF.identity.username,
CONF.identity.password,
CONF.identity.tenant_name)
self.client = ocm.compute_client
@@ -112,6 +112,8 @@
"""
:return: a scenario with name and uuid of images
"""
+ if not CONF.service_available.glance:
+ return []
if not hasattr(self, '_scenario_images'):
images = self.client.images.list(detailed=False)
self._scenario_images = [
diff --git a/tempest/common/waiters.py b/tempest/common/waiters.py
index dbeba8f..8e6b9fb 100644
--- a/tempest/common/waiters.py
+++ b/tempest/common/waiters.py
@@ -42,7 +42,7 @@
timeout = client.build_timeout + extra_timeout
while True:
# NOTE(afazekas): Now the BUILD status only reached
- # between the UNKOWN->ACTIVE transition.
+ # between the UNKNOWN->ACTIVE transition.
# TODO(afazekas): enumerate and validate the stable status set
if status == 'BUILD' and server_status != 'UNKNOWN':
return
diff --git a/tempest/config.py b/tempest/config.py
index 068193b..471a0de 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -15,6 +15,7 @@
from __future__ import print_function
+import logging as std_logging
import os
from oslo.config import cfg
@@ -46,25 +47,29 @@
cfg.StrOpt('auth_version',
default='v2',
help="Identity API version to be used for authentication "
- "for API tests. Planned to extend to tenant isolation, "
- "scenario tests and CLI tests."),
+ "for API tests."),
cfg.StrOpt('region',
default='RegionOne',
help="The identity region name to use. Also used as the other "
"services' region name unless they are set explicitly. "
"If no such region is found in the service catalog, the "
"first found one is used."),
+ cfg.StrOpt('endpoint_type',
+ default='publicURL',
+ choices=['public', 'admin', 'internal',
+ 'publicURL', 'adminURL', 'internalURL'],
+ help="The endpoint type to use for the identity service."),
cfg.StrOpt('username',
- default='demo',
+ default=None,
help="Username to use for Nova API requests."),
cfg.StrOpt('tenant_name',
- default='demo',
+ default=None,
help="Tenant name to use for Nova API requests."),
cfg.StrOpt('admin_role',
default='admin',
help="Role required to administrate keystone."),
cfg.StrOpt('password',
- default='pass',
+ default=None,
help="API key to use when authenticating.",
secret=True),
cfg.StrOpt('alt_username',
@@ -80,15 +85,15 @@
help="API key to use when authenticating as alternate user.",
secret=True),
cfg.StrOpt('admin_username',
- default='admin',
+ default=None,
help="Administrative Username to use for "
"Keystone API requests."),
cfg.StrOpt('admin_tenant_name',
- default='admin',
+ default=None,
help="Administrative Tenant name to use for Keystone API "
"requests."),
cfg.StrOpt('admin_password',
- default='pass',
+ default=None,
help="API key to use when authenticating as admin.",
secret=True),
]
@@ -100,7 +105,13 @@
cfg.BoolOpt('trust',
default=True,
help='Does the identity service have delegation and '
- 'impersonation enabled')
+ 'impersonation enabled'),
+ cfg.BoolOpt('api_v2',
+ default=True,
+ help='Is the v2 identity API enabled'),
+ cfg.BoolOpt('api_v3',
+ default=True,
+ help='Is the v3 identity API enabled'),
]
compute_group = cfg.OptGroup(name='compute',
@@ -188,6 +199,11 @@
"of identity.region is used instead. If no such region "
"is found in the service catalog, the first found one is "
"used."),
+ cfg.StrOpt('endpoint_type',
+ default='publicURL',
+ choices=['public', 'admin', 'internal',
+ 'publicURL', 'adminURL', 'internalURL'],
+ help="The endpoint type to use for the compute service."),
cfg.StrOpt('catalog_v3_type',
default='computev3',
help="Catalog type of the Compute v3 service."),
@@ -220,8 +236,8 @@
help="If false, skip disk config tests"),
cfg.ListOpt('api_extensions',
default=['all'],
- help='A list of enabled extensions with a special entry all '
- 'which indicates every extension is enabled'),
+ help='A list of enabled compute extensions with a special '
+ 'entry all which indicates every extension is enabled'),
cfg.ListOpt('api_v3_extensions',
default=['all'],
help='A list of enabled v3 extensions with a special entry all'
@@ -230,9 +246,6 @@
default=False,
help="Does the test environment support changing the admin "
"password?"),
- cfg.BoolOpt('create_image',
- default=False,
- help="Does the test environment support snapshots?"),
cfg.BoolOpt('resize',
default=False,
help="Does the test environment support resizing?"),
@@ -247,7 +260,11 @@
cfg.BoolOpt('block_migrate_cinder_iscsi',
default=False,
help="Does the test environment block migration support "
- "cinder iSCSI volumes")
+ "cinder iSCSI volumes"),
+ cfg.BoolOpt('vnc_console',
+ default=False,
+ help='Enable VNC console. This configuration value should '
+ 'be same as [nova.vnc]->vnc_enabled in nova.conf')
]
@@ -256,14 +273,14 @@
ComputeAdminGroup = [
cfg.StrOpt('username',
- default='admin',
+ default=None,
help="Administrative Username to use for Nova API requests."),
cfg.StrOpt('tenant_name',
- default='admin',
+ default=None,
help="Administrative Tenant name to use for Nova API "
"requests."),
cfg.StrOpt('password',
- default='pass',
+ default=None,
help="API key to use when authenticating as admin.",
secret=True),
]
@@ -281,6 +298,11 @@
"of identity.region is used instead. If no such region "
"is found in the service catalog, the first found one is "
"used."),
+ cfg.StrOpt('endpoint_type',
+ default='publicURL',
+ choices=['public', 'admin', 'internal',
+ 'publicURL', 'adminURL', 'internalURL'],
+ help="The endpoint type to use for the image service."),
cfg.StrOpt('http_image',
default='http://download.cirros-cloud.net/0.3.1/'
'cirros-0.3.1-x86_64-uec.tar.gz',
@@ -312,12 +334,23 @@
"of identity.region is used instead. If no such region "
"is found in the service catalog, the first found one is "
"used."),
+ cfg.StrOpt('endpoint_type',
+ default='publicURL',
+ choices=['public', 'admin', 'internal',
+ 'publicURL', 'adminURL', 'internalURL'],
+ help="The endpoint type to use for the network service."),
cfg.StrOpt('tenant_network_cidr',
default="10.100.0.0/16",
- help="The cidr block to allocate tenant networks from"),
+ help="The cidr block to allocate tenant ipv4 subnets from"),
cfg.IntOpt('tenant_network_mask_bits',
default=28,
- help="The mask bits for tenant networks"),
+ help="The mask bits for tenant ipv4 subnets"),
+ cfg.StrOpt('tenant_network_v6_cidr',
+ default="2003::/64",
+ help="The cidr block to allocate tenant ipv6 subnets from"),
+ cfg.IntOpt('tenant_network_v6_mask_bits',
+ default=96,
+ help="The mask bits for tenant ipv6 subnets"),
cfg.BoolOpt('tenant_networks_reachable',
default=False,
help="Whether tenant network connectivity should be "
@@ -330,16 +363,36 @@
default="",
help="Id of the public router that provides external "
"connectivity"),
+ cfg.IntOpt('build_timeout',
+ default=300,
+ help="Timeout in seconds to wait for network operation to "
+ "complete."),
+ cfg.IntOpt('build_interval',
+ default=10,
+ help="Time in seconds between network operation status "
+ "checks."),
]
network_feature_group = cfg.OptGroup(name='network-feature-enabled',
title='Enabled network service features')
NetworkFeaturesGroup = [
+ cfg.BoolOpt('ipv6',
+ default=True,
+ help="Allow the execution of IPv6 tests"),
cfg.ListOpt('api_extensions',
default=['all'],
- help='A list of enabled extensions with a special entry all '
- 'which indicates every extension is enabled'),
+ help='A list of enabled network extensions with a special '
+ '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',
@@ -362,6 +415,11 @@
"of identity.region is used instead. If no such region "
"is found in the service catalog, the first found one is "
"used."),
+ cfg.StrOpt('endpoint_type',
+ default='publicURL',
+ choices=['public', 'admin', 'internal',
+ 'publicURL', 'adminURL', 'internalURL'],
+ help="The endpoint type to use for the volume service."),
cfg.StrOpt('backend1_name',
default='BACKEND_1',
help="Name of the backend1 (must be declared in cinder.conf)"),
@@ -386,13 +444,19 @@
cfg.BoolOpt('multi_backend',
default=False,
help="Runs Cinder multi-backend test (requires 2 backends)"),
+ cfg.BoolOpt('backup',
+ default=True,
+ help='Runs Cinder volumes backup test'),
cfg.ListOpt('api_extensions',
default=['all'],
- help='A list of enabled extensions with a special entry all '
- 'which indicates every extension is enabled'),
+ help='A list of enabled volume extensions with a special '
+ 'entry all which indicates every extension is enabled'),
cfg.BoolOpt('api_v1',
default=True,
help="Is the v1 volume API enabled"),
+ cfg.BoolOpt('api_v2',
+ default=True,
+ help="Is the v2 volume API enabled"),
]
@@ -409,6 +473,11 @@
"value of identity.region is used instead. If no such "
"region is found in the service catalog, the first found "
"one is used."),
+ cfg.StrOpt('endpoint_type',
+ default='publicURL',
+ choices=['public', 'admin', 'internal',
+ 'publicURL', 'adminURL', 'internalURL'],
+ help="The endpoint type to use for the object-store service."),
cfg.IntOpt('container_sync_timeout',
default=120,
help="Number of seconds to time on waiting for a container "
@@ -421,6 +490,9 @@
default='Member',
help="Role to add to users created for swift tests to "
"enable creating containers"),
+ cfg.StrOpt('reseller_admin_role',
+ default='ResellerAdmin',
+ help="User role that has reseller admin"),
]
object_storage_feature_group = cfg.OptGroup(
@@ -435,6 +507,17 @@
"features are expected to be enabled"),
]
+database_group = cfg.OptGroup(name='database',
+ title='Database Service Options')
+
+DatabaseGroup = [
+ cfg.StrOpt('catalog_type',
+ default='database',
+ help="Catalog type of the Database service."),
+ cfg.StrOpt('db_flavor_ref',
+ default="1",
+ help="Valid primary flavor to use in database tests."),
+]
orchestration_group = cfg.OptGroup(name='orchestration',
title='Orchestration Service Options')
@@ -449,6 +532,11 @@
"value of identity.region is used instead. If no such "
"region is found in the service catalog, the first found "
"one is used."),
+ cfg.StrOpt('endpoint_type',
+ default='publicURL',
+ choices=['public', 'admin', 'internal',
+ 'publicURL', 'adminURL', 'internalURL'],
+ help="The endpoint type to use for the orchestration service."),
cfg.BoolOpt('allow_tenant_isolation',
default=False,
help="Allows test cases to create/destroy tenants and "
@@ -459,7 +547,7 @@
default=1,
help="Time in seconds between build status checks."),
cfg.IntOpt('build_timeout',
- default=300,
+ default=600,
help="Timeout in seconds to wait for a stack to build."),
cfg.StrOpt('instance_type',
default='m1.micro',
@@ -485,6 +573,11 @@
cfg.StrOpt('catalog_type',
default='metering',
help="Catalog type of the Telemetry service."),
+ cfg.StrOpt('endpoint_type',
+ default='publicURL',
+ choices=['public', 'admin', 'internal',
+ 'publicURL', 'adminURL', 'internalURL'],
+ help="The endpoint type to use for the telemetry service."),
]
@@ -507,7 +600,13 @@
DataProcessingGroup = [
cfg.StrOpt('catalog_type',
default='data_processing',
- help="Catalog type of the data processing service.")
+ help="Catalog type of the data processing service."),
+ cfg.StrOpt('endpoint_type',
+ default='publicURL',
+ choices=['public', 'admin', 'internal',
+ 'publicURL', 'adminURL', 'internalURL'],
+ help="The endpoint type to use for the data processing "
+ "service."),
]
@@ -527,6 +626,9 @@
cfg.StrOpt('aws_access',
default=None,
help="AWS Access Key"),
+ cfg.StrOpt('aws_zone',
+ default="nova",
+ help="AWS Zone for EC2 tests"),
cfg.StrOpt('s3_materials_path',
default="/opt/stack/devstack/files/images/"
"s3-materials/cirros-0.3.0",
@@ -592,7 +694,12 @@
default=False,
help='Prevent the cleaning (tearDownClass()) between'
' each stress test run if an exception occurs'
- ' during this run.')
+ ' during this run.'),
+ cfg.BoolOpt('full_clean_stack',
+ default=False,
+ help='Allows a full cleaning process after a stress test.'
+ ' Caution : this cleanup will remove every objects of'
+ ' every tenant.')
]
@@ -603,6 +710,9 @@
default='/opt/stack/new/devstack/files/images/'
'cirros-0.3.1-x86_64-uec',
help='Directory containing image files'),
+ cfg.StrOpt('qcow2_img_file',
+ default='cirros-0.3.1-x86_64-disk.img',
+ help='QCOW2 image file name'),
cfg.StrOpt('ami_img_file',
default='cirros-0.3.1-x86_64-blank.img',
help='AMI image file name'),
@@ -651,12 +761,18 @@
cfg.BoolOpt('horizon',
default=True,
help="Whether or not Horizon is expected to be available"),
- cfg.BoolOpt('savanna',
+ cfg.BoolOpt('sahara',
default=False,
- help="Whether or not Savanna is expected to be available"),
+ help="Whether or not Sahara is expected to be available"),
cfg.BoolOpt('ironic',
default=False,
help="Whether or not Ironic is expected to be available"),
+ 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",
@@ -697,6 +813,12 @@
cfg.StrOpt('catalog_type',
default='baremetal',
help="Catalog type of the baremetal provisioning service."),
+ cfg.StrOpt('endpoint_type',
+ default='publicURL',
+ choices=['public', 'admin', 'internal',
+ 'publicURL', 'adminURL', 'internalURL'],
+ help="The endpoint type to use for the baremetal provisioning "
+ "service."),
]
cli_group = cfg.OptGroup(name='cli', title="cli Configuration Options")
@@ -708,11 +830,63 @@
cfg.StrOpt('cli_dir',
default='/usr/local/bin',
help="directory where python client binaries are located"),
+ cfg.BoolOpt('has_manage',
+ default=True,
+ help=("Whether the tempest run location has access to the "
+ "*-manage commands. In a pure blackbox environment "
+ "it will not.")),
cfg.IntOpt('timeout',
default=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)
+ register_opt_group(cfg.CONF, compute_features_group,
+ ComputeFeaturesGroup)
+ register_opt_group(cfg.CONF, identity_group, IdentityGroup)
+ register_opt_group(cfg.CONF, identity_feature_group,
+ IdentityFeatureGroup)
+ register_opt_group(cfg.CONF, image_group, ImageGroup)
+ register_opt_group(cfg.CONF, image_feature_group, ImageFeaturesGroup)
+ 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)
+ register_opt_group(cfg.CONF, object_storage_group, ObjectStoreGroup)
+ register_opt_group(cfg.CONF, object_storage_feature_group,
+ ObjectStoreFeaturesGroup)
+ register_opt_group(cfg.CONF, database_group, DatabaseGroup)
+ register_opt_group(cfg.CONF, orchestration_group, OrchestrationGroup)
+ register_opt_group(cfg.CONF, telemetry_group, TelemetryGroup)
+ register_opt_group(cfg.CONF, dashboard_group, DashboardGroup)
+ register_opt_group(cfg.CONF, data_processing_group,
+ DataProcessingGroup)
+ register_opt_group(cfg.CONF, boto_group, BotoGroup)
+ register_opt_group(cfg.CONF, compute_admin_group, ComputeAdminGroup)
+ register_opt_group(cfg.CONF, stress_group, StressGroup)
+ register_opt_group(cfg.CONF, scenario_group, ScenarioGroup)
+ register_opt_group(cfg.CONF, service_available_group,
+ ServiceAvailableGroup)
+ register_opt_group(cfg.CONF, debug_group, DebugGroup)
+ 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
class TempestConfigPrivate(object):
@@ -724,6 +898,41 @@
DEFAULT_CONFIG_FILE = "tempest.conf"
+ def _set_attrs(self):
+ self.compute = cfg.CONF.compute
+ self.compute_feature_enabled = cfg.CONF['compute-feature-enabled']
+ self.identity = cfg.CONF.identity
+ self.identity_feature_enabled = cfg.CONF['identity-feature-enabled']
+ self.image = cfg.CONF.image
+ self.image_feature_enabled = cfg.CONF['image-feature-enabled']
+ self.network = cfg.CONF.network
+ self.network_feature_enabled = cfg.CONF['network-feature-enabled']
+ self.volume = cfg.CONF.volume
+ self.volume_feature_enabled = cfg.CONF['volume-feature-enabled']
+ self.object_storage = cfg.CONF['object-storage']
+ self.object_storage_feature_enabled = cfg.CONF[
+ '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
+ self.boto = cfg.CONF.boto
+ self.compute_admin = cfg.CONF['compute-admin']
+ self.stress = cfg.CONF.stress
+ self.scenario = cfg.CONF.scenario
+ self.service_available = cfg.CONF.service_available
+ self.debug = cfg.CONF.debug
+ 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
+ self.compute_admin.tenant_name = self.identity.admin_tenant_name
+
def __init__(self, parse_conf=True):
"""Initialize a configuration from a conf directory and conf file."""
super(TempestConfigPrivate, self).__init__()
@@ -749,69 +958,10 @@
logging.setup('tempest')
LOG = logging.getLogger('tempest')
LOG.info("Using tempest config file %s" % path)
-
- register_opt_group(cfg.CONF, compute_group, ComputeGroup)
- register_opt_group(cfg.CONF, compute_features_group,
- ComputeFeaturesGroup)
- register_opt_group(cfg.CONF, identity_group, IdentityGroup)
- register_opt_group(cfg.CONF, identity_feature_group,
- IdentityFeatureGroup)
- register_opt_group(cfg.CONF, image_group, ImageGroup)
- register_opt_group(cfg.CONF, image_feature_group, ImageFeaturesGroup)
- register_opt_group(cfg.CONF, network_group, NetworkGroup)
- register_opt_group(cfg.CONF, network_feature_group,
- NetworkFeaturesGroup)
- register_opt_group(cfg.CONF, volume_group, VolumeGroup)
- register_opt_group(cfg.CONF, volume_feature_group,
- VolumeFeaturesGroup)
- register_opt_group(cfg.CONF, object_storage_group, ObjectStoreGroup)
- register_opt_group(cfg.CONF, object_storage_feature_group,
- ObjectStoreFeaturesGroup)
- register_opt_group(cfg.CONF, orchestration_group, OrchestrationGroup)
- register_opt_group(cfg.CONF, telemetry_group, TelemetryGroup)
- register_opt_group(cfg.CONF, dashboard_group, DashboardGroup)
- register_opt_group(cfg.CONF, data_processing_group,
- DataProcessingGroup)
- register_opt_group(cfg.CONF, boto_group, BotoGroup)
- register_opt_group(cfg.CONF, compute_admin_group, ComputeAdminGroup)
- register_opt_group(cfg.CONF, stress_group, StressGroup)
- register_opt_group(cfg.CONF, scenario_group, ScenarioGroup)
- register_opt_group(cfg.CONF, service_available_group,
- ServiceAvailableGroup)
- register_opt_group(cfg.CONF, debug_group, DebugGroup)
- 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)
- self.compute = cfg.CONF.compute
- self.compute_feature_enabled = cfg.CONF['compute-feature-enabled']
- self.identity = cfg.CONF.identity
- self.identity_feature_enabled = cfg.CONF['identity-feature-enabled']
- self.images = cfg.CONF.image
- self.image_feature_enabled = cfg.CONF['image-feature-enabled']
- self.network = cfg.CONF.network
- self.network_feature_enabled = cfg.CONF['network-feature-enabled']
- self.volume = cfg.CONF.volume
- self.volume_feature_enabled = cfg.CONF['volume-feature-enabled']
- self.object_storage = cfg.CONF['object-storage']
- self.object_storage_feature_enabled = cfg.CONF[
- 'object-storage-feature-enabled']
- self.orchestration = cfg.CONF.orchestration
- self.telemetry = cfg.CONF.telemetry
- self.dashboard = cfg.CONF.dashboard
- self.data_processing = cfg.CONF.data_processing
- self.boto = cfg.CONF.boto
- self.compute_admin = cfg.CONF['compute-admin']
- self.stress = cfg.CONF.stress
- self.scenario = cfg.CONF.scenario
- self.service_available = cfg.CONF.service_available
- self.debug = cfg.CONF.debug
- self.baremetal = cfg.CONF.baremetal
- self.input_scenario = cfg.CONF['input-scenario']
- self.cli = cfg.CONF.cli
- if not self.compute_admin.username:
- self.compute_admin.username = self.identity.admin_username
- self.compute_admin.password = self.identity.admin_password
- self.compute_admin.tenant_name = self.identity.admin_tenant_name
+ register_opts()
+ self._set_attrs()
+ if parse_conf:
+ cfg.CONF.log_opt_values(LOG, std_logging.DEBUG)
class TempestConfigProxy(object):
diff --git a/tempest/exceptions.py b/tempest/exceptions.py
deleted file mode 100644
index 3b3f3eb..0000000
--- a/tempest/exceptions.py
+++ /dev/null
@@ -1,183 +0,0 @@
-# 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 testtools
-
-
-class TempestException(Exception):
- """
- Base Tempest Exception
-
- To correctly use this class, inherit from it and define
- a 'message' property. That message will get printf'd
- with the keyword arguments provided to the constructor.
- """
- message = "An unknown exception occurred"
-
- def __init__(self, *args, **kwargs):
- super(TempestException, self).__init__()
- try:
- self._error_string = self.message % kwargs
- except Exception:
- # at least get the core message out if something happened
- self._error_string = self.message
- if len(args) > 0:
- # If there is a non-kwarg parameter, assume it's the error
- # message or reason description and tack it on to the end
- # of the exception message
- # Convert all arguments into their string representations...
- args = ["%s" % arg for arg in args]
- self._error_string = (self._error_string +
- "\nDetails: %s" % '\n'.join(args))
-
- def __str__(self):
- return self._error_string
-
-
-class InvalidConfiguration(TempestException):
- message = "Invalid Configuration"
-
-
-class RestClientException(TempestException,
- testtools.TestCase.failureException):
- pass
-
-
-class InvalidHttpSuccessCode(RestClientException):
- message = "The success code is different than the expected one"
-
-
-class NotFound(RestClientException):
- message = "Object not found"
-
-
-class Unauthorized(RestClientException):
- message = 'Unauthorized'
-
-
-class InvalidServiceTag(RestClientException):
- message = "Invalid service tag"
-
-
-class TimeoutException(TempestException):
- message = "Request timed out"
-
-
-class BuildErrorException(TempestException):
- message = "Server %(server_id)s failed to build and is in ERROR status"
-
-
-class ImageKilledException(TempestException):
- message = "Image %(image_id)s 'killed' while waiting for '%(status)s'"
-
-
-class AddImageException(TempestException):
- message = "Image %(image_id)s failed to become ACTIVE in the allotted time"
-
-
-class EC2RegisterImageException(TempestException):
- message = ("Image %(image_id)s failed to become 'available' "
- "in the allotted time")
-
-
-class VolumeBuildErrorException(TempestException):
- message = "Volume %(volume_id)s failed to build and is in ERROR status"
-
-
-class SnapshotBuildErrorException(TempestException):
- message = "Snapshot %(snapshot_id)s failed to build and is in ERROR status"
-
-
-class StackBuildErrorException(TempestException):
- message = ("Stack %(stack_identifier)s is in %(stack_status)s status "
- "due to '%(stack_status_reason)s'")
-
-
-class BadRequest(RestClientException):
- message = "Bad request"
-
-
-class UnprocessableEntity(RestClientException):
- message = "Unprocessable entity"
-
-
-class AuthenticationFailure(RestClientException):
- message = ("Authentication with user %(user)s and password "
- "%(password)s failed auth using tenant %(tenant)s.")
-
-
-class EndpointNotFound(TempestException):
- message = "Endpoint not found"
-
-
-class RateLimitExceeded(TempestException):
- message = "Rate limit exceeded"
-
-
-class OverLimit(TempestException):
- message = "Quota exceeded"
-
-
-class ServerFault(TempestException):
- message = "Got server fault"
-
-
-class ImageFault(TempestException):
- message = "Got image fault"
-
-
-class IdentityError(TempestException):
- message = "Got identity error"
-
-
-class Conflict(RestClientException):
- message = "An object with that identifier already exists"
-
-
-class SSHTimeout(TempestException):
- message = ("Connection to the %(host)s via SSH timed out.\n"
- "User: %(user)s, Password: %(password)s")
-
-
-class SSHExecCommandFailed(TempestException):
- """Raised when remotely executed command returns nonzero status."""
- message = ("Command '%(command)s', exit status: %(exit_status)d, "
- "Error:\n%(strerror)s")
-
-
-class ServerUnreachable(TempestException):
- message = "The server is not reachable via the configured network"
-
-
-class TearDownException(TempestException):
- message = "%(num)d cleanUp operation failed"
-
-
-class RFCViolation(RestClientException):
- message = "RFC Violation"
-
-
-class ResponseWithNonEmptyBody(RFCViolation):
- message = ("RFC Violation! Response with %(status)d HTTP Status Code "
- "MUST NOT have a body")
-
-
-class ResponseWithEntity(RFCViolation):
- message = ("RFC Violation! Response with 205 HTTP Status Code "
- "MUST NOT have an entity")
-
-
-class InvalidHTTPResponseBody(RestClientException):
- message = "HTTP response body is invalid json or xml"
diff --git a/tempest/exceptions/README.rst b/tempest/exceptions/README.rst
new file mode 100644
index 0000000..dbe42b2
--- /dev/null
+++ b/tempest/exceptions/README.rst
@@ -0,0 +1,27 @@
+Tempest Field Guide to Exceptions
+=================================
+
+
+What are these exceptions?
+--------------------------
+
+These exceptions are used by Tempest for covering OpenStack specific exceptional
+cases.
+
+How to add new exceptions?
+--------------------------
+
+Each exception-template for inheritance purposes should be added into 'base'
+submodule.
+All other exceptions can be added in two ways:
+- in main module
+- in submodule
+But only in one of the ways. Need to make sure, that new exception is not
+present already.
+
+How to use exceptions?
+----------------------
+
+Any exceptions from this module or its submodules should be used in appropriate
+places to handle exceptional cases.
+Classes from 'base' module should be used only for inheritance.
diff --git a/tempest/exceptions/__init__.py b/tempest/exceptions/__init__.py
new file mode 100644
index 0000000..485f532
--- /dev/null
+++ b/tempest/exceptions/__init__.py
@@ -0,0 +1,160 @@
+# 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.
+
+from tempest.exceptions import base
+
+
+class InvalidConfiguration(base.TempestException):
+ message = "Invalid Configuration"
+
+
+class InvalidCredentials(base.TempestException):
+ message = "Invalid Credentials"
+
+
+class InvalidHttpSuccessCode(base.RestClientException):
+ message = "The success code is different than the expected one"
+
+
+class NotFound(base.RestClientException):
+ message = "Object not found"
+
+
+class Unauthorized(base.RestClientException):
+ message = 'Unauthorized'
+
+
+class InvalidServiceTag(base.RestClientException):
+ message = "Invalid service tag"
+
+
+class TimeoutException(base.TempestException):
+ message = "Request timed out"
+
+
+class BuildErrorException(base.TempestException):
+ message = "Server %(server_id)s failed to build and is in ERROR status"
+
+
+class ImageKilledException(base.TempestException):
+ message = "Image %(image_id)s 'killed' while waiting for '%(status)s'"
+
+
+class AddImageException(base.TempestException):
+ message = "Image %(image_id)s failed to become ACTIVE in the allotted time"
+
+
+class EC2RegisterImageException(base.TempestException):
+ message = ("Image %(image_id)s failed to become 'available' "
+ "in the allotted time")
+
+
+class VolumeBuildErrorException(base.TempestException):
+ message = "Volume %(volume_id)s failed to build and is in ERROR status"
+
+
+class SnapshotBuildErrorException(base.TempestException):
+ message = "Snapshot %(snapshot_id)s failed to build and is in ERROR status"
+
+
+class VolumeBackupException(base.TempestException):
+ message = "Volume backup %(backup_id)s failed and is in ERROR status"
+
+
+class StackBuildErrorException(base.TempestException):
+ message = ("Stack %(stack_identifier)s is in %(stack_status)s status "
+ "due to '%(stack_status_reason)s'")
+
+
+class BadRequest(base.RestClientException):
+ message = "Bad request"
+
+
+class UnprocessableEntity(base.RestClientException):
+ message = "Unprocessable entity"
+
+
+class AuthenticationFailure(base.RestClientException):
+ message = ("Authentication with user %(user)s and password "
+ "%(password)s failed auth using tenant %(tenant)s.")
+
+
+class EndpointNotFound(base.TempestException):
+ message = "Endpoint not found"
+
+
+class RateLimitExceeded(base.TempestException):
+ message = "Rate limit exceeded"
+
+
+class OverLimit(base.TempestException):
+ message = "Quota exceeded"
+
+
+class ServerFault(base.TempestException):
+ message = "Got server fault"
+
+
+class ImageFault(base.TempestException):
+ message = "Got image fault"
+
+
+class IdentityError(base.TempestException):
+ message = "Got identity error"
+
+
+class Conflict(base.RestClientException):
+ message = "An object with that identifier already exists"
+
+
+class SSHTimeout(base.TempestException):
+ message = ("Connection to the %(host)s via SSH timed out.\n"
+ "User: %(user)s, Password: %(password)s")
+
+
+class SSHExecCommandFailed(base.TempestException):
+ """Raised when remotely executed command returns nonzero status."""
+ message = ("Command '%(command)s', exit status: %(exit_status)d, "
+ "Error:\n%(strerror)s")
+
+
+class ServerUnreachable(base.TempestException):
+ message = "The server is not reachable via the configured network"
+
+
+class TearDownException(base.TempestException):
+ message = "%(num)d cleanUp operation failed"
+
+
+class ResponseWithNonEmptyBody(base.RFCViolation):
+ message = ("RFC Violation! Response with %(status)d HTTP Status Code "
+ "MUST NOT have a body")
+
+
+class ResponseWithEntity(base.RFCViolation):
+ message = ("RFC Violation! Response with 205 HTTP Status Code "
+ "MUST NOT have an entity")
+
+
+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/exceptions/base.py b/tempest/exceptions/base.py
new file mode 100644
index 0000000..b8e470e
--- /dev/null
+++ b/tempest/exceptions/base.py
@@ -0,0 +1,55 @@
+# 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 testtools
+
+
+class TempestException(Exception):
+ """
+ Base Tempest Exception
+
+ To correctly use this class, inherit from it and define
+ a 'message' property. That message will get printf'd
+ with the keyword arguments provided to the constructor.
+ """
+ message = "An unknown exception occurred"
+
+ def __init__(self, *args, **kwargs):
+ super(TempestException, self).__init__()
+ try:
+ self._error_string = self.message % kwargs
+ except Exception:
+ # at least get the core message out if something happened
+ self._error_string = self.message
+ if len(args) > 0:
+ # If there is a non-kwarg parameter, assume it's the error
+ # message or reason description and tack it on to the end
+ # of the exception message
+ # Convert all arguments into their string representations...
+ args = ["%s" % arg for arg in args]
+ self._error_string = (self._error_string +
+ "\nDetails: %s" % '\n'.join(args))
+
+ def __str__(self):
+ return self._error_string
+
+
+class RestClientException(TempestException,
+ testtools.TestCase.failureException):
+ pass
+
+
+class RFCViolation(RestClientException):
+ message = "RFC Violation"
diff --git a/tempest/hacking/checks.py b/tempest/hacking/checks.py
index 2e499a2..7f39905 100644
--- a/tempest/hacking/checks.py
+++ b/tempest/hacking/checks.py
@@ -15,12 +15,15 @@
import re
-PYTHON_CLIENTS = ['cinder', 'glance', 'keystone', 'nova', 'swift', 'neutron']
+PYTHON_CLIENTS = ['cinder', 'glance', 'keystone', 'nova', 'swift', 'neutron',
+ 'trove', 'ironic', 'savanna', 'heat', 'ceilometer',
+ 'marconi']
PYTHON_CLIENT_RE = re.compile('import (%s)client' % '|'.join(PYTHON_CLIENTS))
TEST_DEFINITION = re.compile(r'^\s*def test.*')
SETUPCLASS_DEFINITION = re.compile(r'^\s*def setUpClass')
SCENARIO_DECORATOR = re.compile(r'\s*@.*services\(')
+VI_HEADER_RE = re.compile(r"^#\s+vim?:.+")
def import_no_clients_in_api(physical_line, filename):
@@ -58,7 +61,22 @@
"T105: setUpClass can not be used with unit tests")
+def no_vi_headers(physical_line, line_number, lines):
+ """Check for vi editor configuration in source files.
+
+ By default vi modelines can only appear in the first or
+ last 5 lines of a source file.
+
+ T106
+ """
+ # NOTE(gilliard): line_number is 1-indexed
+ if line_number <= 5 or line_number > len(lines) - 5:
+ if VI_HEADER_RE.match(physical_line):
+ return 0, "T106: Don't put vi configuration in source files"
+
+
def factory(register):
register(import_no_clients_in_api)
register(scenario_tests_need_service_tags)
register(no_setupclass_for_unit_tests)
+ register(no_vi_headers)
diff --git a/tempest/manager.py b/tempest/manager.py
index 93ff10f..63235db 100644
--- a/tempest/manager.py
+++ b/tempest/manager.py
@@ -13,8 +13,12 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest import auth
+from tempest import config
from tempest import exceptions
+CONF = config.CONF
+
class Manager(object):
@@ -25,7 +29,27 @@
and a client object for a test case to use in performing actions.
"""
- def __init__(self):
+ def __init__(self, username=None, password=None, tenant_name=None):
+ """
+ We allow overriding of the credentials used within the various
+ client classes managed by the Manager object. Left as None, the
+ standard username/password/tenant_name[/domain_name] is used.
+
+ :param credentials: Override of the credentials
+ """
+ self.auth_version = CONF.identity.auth_version
+ # FIXME(andreaf) Change Manager __init__ to accept a credentials dict
+ if username is None or password is None:
+ # Tenant None is a valid use case
+ self.credentials = self.get_default_credentials()
+ else:
+ self.credentials = dict(username=username, password=password,
+ tenant_name=tenant_name)
+ if self.auth_version == 'v3':
+ self.credentials['domain_name'] = 'Default'
+ # Creates an auth provider for the credentials
+ self.auth_provider = self.get_auth_provider(self.credentials)
+ # FIXME(andreaf) unused
self.client_attr_names = []
# we do this everywhere, have it be part of the super class
@@ -36,3 +60,27 @@
"tenant_name: %(t)s" %
{'u': username, 'p': password, 't': tenant_name})
raise exceptions.InvalidConfiguration(msg)
+
+ @classmethod
+ def get_auth_provider_class(cls, auth_version):
+ if auth_version == 'v2':
+ return auth.KeystoneV2AuthProvider
+ else:
+ return auth.KeystoneV3AuthProvider
+
+ def get_default_credentials(self):
+ return dict(
+ username=CONF.identity.username,
+ password=CONF.identity.password,
+ tenant_name=CONF.identity.tenant_name
+ )
+
+ def get_auth_provider(self, credentials):
+ if credentials is None:
+ raise exceptions.InvalidCredentials(
+ 'Credentials must be specified')
+ auth_provider_class = self.get_auth_provider_class(self.auth_version)
+ return auth_provider_class(
+ client_type=getattr(self, 'client_type', None),
+ interface=getattr(self, 'interface', None),
+ credentials=credentials)
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 0c9d503..f06a850 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -16,28 +16,20 @@
import logging
import os
+import six
import subprocess
-# Default client libs
-import cinderclient.client
-import glanceclient
-import heatclient.client
-import keystoneclient.apiclient.exceptions
-import keystoneclient.v2_0.client
import netaddr
from neutronclient.common import exceptions as exc
-import neutronclient.v2_0.client
-import novaclient.client
from novaclient import exceptions as nova_exceptions
-import swiftclient
from tempest.api.network import common as net_common
+from tempest import clients
from tempest.common import isolated_creds
from tempest.common.utils import data_utils
-from tempest.common.utils.linux.remote_client import RemoteClient
+from tempest.common.utils.linux import remote_client
from tempest import config
from tempest import exceptions
-import tempest.manager
from tempest.openstack.common import log
import tempest.test
@@ -53,172 +45,6 @@
LOG_cinder_client.addHandler(log.NullHandler())
-class OfficialClientManager(tempest.manager.Manager):
- """
- Manager that provides access to the official python clients for
- calling various OpenStack APIs.
- """
-
- NOVACLIENT_VERSION = '2'
- CINDERCLIENT_VERSION = '1'
- HEATCLIENT_VERSION = '1'
-
- def __init__(self, username, password, tenant_name):
- super(OfficialClientManager, self).__init__()
- self.compute_client = self._get_compute_client(username,
- password,
- tenant_name)
- self.identity_client = self._get_identity_client(username,
- password,
- tenant_name)
- self.image_client = self._get_image_client()
- self.network_client = self._get_network_client()
- self.volume_client = self._get_volume_client(username,
- password,
- tenant_name)
- self.object_storage_client = self._get_object_storage_client(
- username,
- password,
- tenant_name)
- self.orchestration_client = self._get_orchestration_client(
- username,
- password,
- tenant_name)
-
- def _get_compute_client(self, username, password, tenant_name):
- # Novaclient will not execute operations for anyone but the
- # identified user, so a new client needs to be created for
- # each user that operations need to be performed for.
- self._validate_credentials(username, password, tenant_name)
-
- auth_url = CONF.identity.uri
- dscv = CONF.identity.disable_ssl_certificate_validation
- region = CONF.identity.region
-
- client_args = (username, password, tenant_name, auth_url)
-
- # Create our default Nova client to use in testing
- service_type = CONF.compute.catalog_type
- return novaclient.client.Client(self.NOVACLIENT_VERSION,
- *client_args,
- service_type=service_type,
- region_name=region,
- no_cache=True,
- insecure=dscv,
- http_log_debug=True)
-
- def _get_image_client(self):
- token = self.identity_client.auth_token
- region = CONF.identity.region
- endpoint = self.identity_client.service_catalog.url_for(
- attr='region', filter_value=region,
- service_type='image', endpoint_type='publicURL')
- dscv = CONF.identity.disable_ssl_certificate_validation
- return glanceclient.Client('1', endpoint=endpoint, token=token,
- insecure=dscv)
-
- def _get_volume_client(self, username, password, tenant_name):
- auth_url = CONF.identity.uri
- region = CONF.identity.region
- return cinderclient.client.Client(self.CINDERCLIENT_VERSION,
- username,
- password,
- tenant_name,
- auth_url,
- region_name=region,
- http_log_debug=True)
-
- def _get_object_storage_client(self, username, password, tenant_name):
- auth_url = CONF.identity.uri
- # add current tenant to swift operator role group.
- keystone_admin = self._get_identity_client(
- CONF.identity.admin_username,
- CONF.identity.admin_password,
- CONF.identity.admin_tenant_name)
-
- # enable test user to operate swift by adding operator role to him.
- roles = keystone_admin.roles.list()
- operator_role = CONF.object_storage.operator_role
- member_role = [role for role in roles if role.name == operator_role][0]
- # NOTE(maurosr): This is surrounded in the try-except block cause
- # neutron tests doesn't have tenant isolation.
- try:
- keystone_admin.roles.add_user_role(self.identity_client.user_id,
- member_role.id,
- self.identity_client.tenant_id)
- except keystoneclient.apiclient.exceptions.Conflict:
- pass
-
- return swiftclient.Connection(auth_url, username, password,
- tenant_name=tenant_name,
- auth_version='2')
-
- def _get_orchestration_client(self, username=None, password=None,
- tenant_name=None):
- if not username:
- username = CONF.identity.admin_username
- if not password:
- password = CONF.identity.admin_password
- if not tenant_name:
- tenant_name = CONF.identity.tenant_name
-
- self._validate_credentials(username, password, tenant_name)
-
- keystone = self._get_identity_client(username, password, tenant_name)
- region = CONF.identity.region
- token = keystone.auth_token
- try:
- endpoint = keystone.service_catalog.url_for(
- attr='region',
- filter_value=region,
- service_type='orchestration',
- endpoint_type='publicURL')
- except keystoneclient.exceptions.EndpointNotFound:
- return None
- else:
- return heatclient.client.Client(self.HEATCLIENT_VERSION,
- endpoint,
- token=token,
- username=username,
- password=password)
-
- def _get_identity_client(self, username, password, tenant_name):
- # This identity client is not intended to check the security
- # of the identity service, so use admin credentials by default.
- self._validate_credentials(username, password, tenant_name)
-
- auth_url = CONF.identity.uri
- dscv = CONF.identity.disable_ssl_certificate_validation
-
- return keystoneclient.v2_0.client.Client(username=username,
- password=password,
- tenant_name=tenant_name,
- auth_url=auth_url,
- insecure=dscv)
-
- def _get_network_client(self):
- # The intended configuration is for the network client to have
- # admin privileges and indicate for whom resources are being
- # created via a 'tenant_id' parameter. This will often be
- # preferable to authenticating as a specific user because
- # working with certain resources (public routers and networks)
- # often requires admin privileges anyway.
- username = CONF.identity.admin_username
- password = CONF.identity.admin_password
- tenant_name = CONF.identity.admin_tenant_name
-
- self._validate_credentials(username, password, tenant_name)
-
- auth_url = CONF.identity.uri
- dscv = CONF.identity.disable_ssl_certificate_validation
-
- return neutronclient.v2_0.client.Client(username=username,
- password=password,
- tenant_name=tenant_name,
- auth_url=auth_url,
- insecure=dscv)
-
-
class OfficialClientTest(tempest.test.BaseTestCase):
"""
Official Client test base class for scenario testing.
@@ -241,7 +67,8 @@
username, password, tenant_name = cls.credentials()
- cls.manager = OfficialClientManager(username, password, tenant_name)
+ cls.manager = clients.OfficialClientManager(
+ username, password, tenant_name)
cls.compute_client = cls.manager.compute_client
cls.image_client = cls.manager.image_client
cls.identity_client = cls.manager.identity_client
@@ -275,6 +102,41 @@
return cls._get_credentials(cls.isolated_creds.get_admin_creds,
'admin_')
+ @staticmethod
+ def cleanup_resource(resource, test_name):
+
+ LOG.debug("Deleting %r from shared resources of %s" %
+ (resource, test_name))
+ try:
+ # OpenStack resources are assumed to have a delete()
+ # method which destroys the resource...
+ resource.delete()
+ except Exception as e:
+ # If the resource is already missing, mission accomplished.
+ # add status code as workaround for bug 1247568
+ if (e.__class__.__name__ == 'NotFound' or
+ (hasattr(e, 'status_code') and e.status_code == 404)):
+ return
+ raise
+
+ def is_deletion_complete():
+ # Deletion testing is only required for objects whose
+ # existence cannot be checked via retrieval.
+ if isinstance(resource, dict):
+ return True
+ try:
+ resource.get()
+ except Exception as e:
+ # Clients are expected to return an exception
+ # called 'NotFound' if retrieval fails.
+ if e.__class__.__name__ == 'NotFound':
+ return True
+ raise
+ return False
+
+ # Block until resource deletion has completed or timed-out
+ tempest.test.call_until_true(is_deletion_complete, 10, 1)
+
@classmethod
def tearDownClass(cls):
# NOTE(jaypipes): Because scenario tests are typically run in a
@@ -284,38 +146,7 @@
# the scenario test class object
while cls.os_resources:
thing = cls.os_resources.pop()
- LOG.debug("Deleting %r from shared resources of %s" %
- (thing, cls.__name__))
-
- try:
- # OpenStack resources are assumed to have a delete()
- # method which destroys the resource...
- thing.delete()
- except Exception as e:
- # If the resource is already missing, mission accomplished.
- # add status code as workaround for bug 1247568
- if (e.__class__.__name__ == 'NotFound' or
- hasattr(e, 'status_code') and e.status_code == 404):
- continue
- raise
-
- def is_deletion_complete():
- # Deletion testing is only required for objects whose
- # existence cannot be checked via retrieval.
- if isinstance(thing, dict):
- return True
- try:
- thing.get()
- except Exception as e:
- # Clients are expected to return an exception
- # called 'NotFound' if retrieval fails.
- if e.__class__.__name__ == 'NotFound':
- return True
- raise
- return False
-
- # Block until resource deletion has completed or timed-out
- tempest.test.call_until_true(is_deletion_complete, 10, 1)
+ cls.cleanup_resource(thing, cls.__name__)
cls.isolated_creds.clear_isolated_creds()
super(OfficialClientTest, cls).tearDownClass()
@@ -395,8 +226,9 @@
# so case sensitive comparisons can really mess things
# up.
if new_status.lower() == error_status.lower():
- message = ("%s failed to get to expected status. "
- "In %s state.") % (thing, new_status)
+ message = ("%s failed to get to expected status (%s). "
+ "In %s state.") % (thing, expected_status,
+ new_status)
raise exceptions.BuildErrorException(message,
server_id=thing_id)
elif new_status == expected_status and expected_status is not None:
@@ -460,6 +292,27 @@
image = CONF.compute.image_ref
if flavor is None:
flavor = CONF.compute.flavor_ref
+
+ fixed_network_name = CONF.compute.fixed_network_name
+ if 'nics' not in create_kwargs and fixed_network_name:
+ networks = client.networks.list()
+ # If several networks found, set the NetID on which to connect the
+ # server to avoid the following error "Multiple possible networks
+ # found, use a Network ID to be more specific."
+ # See Tempest #1250866
+ if len(networks) > 1:
+ for network in networks:
+ if network.label == fixed_network_name:
+ create_kwargs['nics'] = [{'net-id': network.id}]
+ break
+ # If we didn't find the network we were looking for :
+ else:
+ msg = ("The network on which the NIC of the server must "
+ "be connected can not be found : "
+ "fixed_network_name=%s. Starting instance without "
+ "specifying a network.") % fixed_network_name
+ LOG.info(msg)
+
LOG.debug("Creating a server (name: %s, image: %s, flavor: %s)",
name, image, flavor)
server = client.servers.create(name, image, flavor, **create_kwargs)
@@ -519,7 +372,7 @@
return keypair
def get_remote_client(self, server_or_ip, username=None, private_key=None):
- if isinstance(server_or_ip, basestring):
+ if isinstance(server_or_ip, six.string_types):
ip = server_or_ip
else:
network_name_for_ssh = CONF.compute.network_for_ssh
@@ -528,7 +381,7 @@
username = CONF.scenario.ssh_user
if private_key is None:
private_key = self.keypair.private_key
- return RemoteClient(ip, username, pkey=private_key)
+ return remote_client.RemoteClient(ip, username, pkey=private_key)
def _log_console_output(self, servers=None):
if not servers:
@@ -537,6 +390,54 @@
LOG.debug('Console output for %s', server.id)
LOG.debug(server.get_console_output())
+ def wait_for_volume_status(self, status):
+ volume_id = self.volume.id
+ self.status_timeout(
+ self.volume_client.volumes, volume_id, status)
+
+ def _image_create(self, name, fmt, path, properties={}):
+ name = data_utils.rand_name('%s-' % name)
+ image_file = open(path, 'rb')
+ self.addCleanup(image_file.close)
+ params = {
+ 'name': name,
+ 'container_format': fmt,
+ 'disk_format': fmt,
+ 'is_public': 'True',
+ }
+ params.update(properties)
+ image = self.image_client.images.create(**params)
+ self.addCleanup(self.image_client.images.delete, image)
+ self.assertEqual("queued", image.status)
+ image.update(data=image_file)
+ return image.id
+
+ def glance_image_create(self):
+ qcow2_img_path = (CONF.scenario.img_dir + "/" +
+ CONF.scenario.qcow2_img_file)
+ aki_img_path = CONF.scenario.img_dir + "/" + CONF.scenario.aki_img_file
+ ari_img_path = CONF.scenario.img_dir + "/" + CONF.scenario.ari_img_file
+ ami_img_path = CONF.scenario.img_dir + "/" + CONF.scenario.ami_img_file
+ LOG.debug("paths: img: %s, ami: %s, ari: %s, aki: %s"
+ % (qcow2_img_path, ami_img_path, ari_img_path, aki_img_path))
+ try:
+ self.image = self._image_create('scenario-img',
+ 'bare',
+ qcow2_img_path,
+ properties={'disk_format':
+ 'qcow2'})
+ except IOError:
+ LOG.debug("A qcow2 image was not found. Try to get a uec image.")
+ kernel = self._image_create('scenario-aki', 'aki', aki_img_path)
+ ramdisk = self._image_create('scenario-ari', 'ari', ari_img_path)
+ properties = {
+ 'properties': {'kernel_id': kernel, 'ramdisk_id': ramdisk}
+ }
+ self.image = self._image_create('scenario-ami', 'ami',
+ path=ami_img_path,
+ properties=properties)
+ LOG.debug("image:%s" % self.image)
+
class NetworkScenarioTest(OfficialClientTest):
"""
@@ -584,58 +485,68 @@
self.set_resource(name, network)
return network
- def _list_networks(self):
- nets = self.network_client.list_networks()
+ def _list_networks(self, **kwargs):
+ nets = self.network_client.list_networks(**kwargs)
return nets['networks']
- def _list_subnets(self):
- subnets = self.network_client.list_subnets()
+ def _list_subnets(self, **kwargs):
+ subnets = self.network_client.list_subnets(**kwargs)
return subnets['subnets']
- def _list_routers(self):
- routers = self.network_client.list_routers()
+ def _list_routers(self, **kwargs):
+ routers = self.network_client.list_routers(**kwargs)
return routers['routers']
- def _list_ports(self):
- ports = self.network_client.list_ports()
+ def _list_ports(self, **kwargs):
+ ports = self.network_client.list_ports(**kwargs)
return ports['ports']
def _get_tenant_own_network_num(self, tenant_id):
- nets = self._list_networks()
- ownnets = [value for value in nets if tenant_id == value['tenant_id']]
- return len(ownnets)
+ nets = self._list_networks(tenant_id=tenant_id)
+ return len(nets)
def _get_tenant_own_subnet_num(self, tenant_id):
- subnets = self._list_subnets()
- ownsubnets = ([value for value in subnets
- if tenant_id == value['tenant_id']])
- return len(ownsubnets)
+ subnets = self._list_subnets(tenant_id=tenant_id)
+ return len(subnets)
def _get_tenant_own_port_num(self, tenant_id):
- ports = self._list_ports()
- ownports = ([value for value in ports
- if tenant_id == value['tenant_id']])
- return len(ownports)
+ ports = self._list_ports(tenant_id=tenant_id)
+ return len(ports)
- def _create_subnet(self, network, namestart='subnet-smoke-'):
+ def _create_subnet(self, network, namestart='subnet-smoke-', **kwargs):
"""
Create a subnet for the given network within the cidr block
configured for tenant networks.
"""
+
+ def cidr_in_use(cidr, tenant_id):
+ """
+ :return True if subnet with cidr already exist in tenant
+ False else
+ """
+ cidr_in_use = self._list_subnets(tenant_id=tenant_id, cidr=cidr)
+ return len(cidr_in_use) != 0
+
tenant_cidr = netaddr.IPNetwork(CONF.network.tenant_network_cidr)
result = None
# Repeatedly attempt subnet creation with sequential cidr
# blocks until an unallocated block is found.
for subnet_cidr in tenant_cidr.subnet(
CONF.network.tenant_network_mask_bits):
+ str_cidr = str(subnet_cidr)
+ if cidr_in_use(str_cidr, tenant_id=network.tenant_id):
+ continue
+
body = dict(
subnet=dict(
+ name=data_utils.rand_name(namestart),
ip_version=4,
network_id=network.id,
tenant_id=network.tenant_id,
- cidr=str(subnet_cidr),
+ cidr=str_cidr,
),
)
+ body['subnet'].update(kwargs)
try:
result = self.network_client.create_subnet(body=body)
break
@@ -646,7 +557,7 @@
self.assertIsNotNone(result, 'Unable to allocate tenant network')
subnet = net_common.DeletableSubnet(client=self.network_client,
**result['subnet'])
- self.assertEqual(subnet.cidr, str(subnet_cidr))
+ self.assertEqual(subnet.cidr, str_cidr)
self.set_resource(data_utils.rand_name(namestart), subnet)
return subnet
@@ -663,19 +574,15 @@
self.set_resource(name, port)
return port
- def _get_server_port_id(self, server):
- result = self.network_client.list_ports(device_id=server.id)
- ports = result.get('ports', [])
+ def _get_server_port_id(self, server, ip_addr=None):
+ ports = self._list_ports(device_id=server.id, fixed_ip=ip_addr)
self.assertEqual(len(ports), 1,
"Unable to determine which port to target.")
return ports[0]['id']
- def _create_floating_ip(self, thing, external_network_id,
- port_filters=None):
- if port_filters is None:
+ def _create_floating_ip(self, thing, external_network_id, port_id=None):
+ if not port_id:
port_id = self._get_server_port_id(thing)
- else:
- port_id = port_filters
body = dict(
floatingip=dict(
floating_network_id=external_network_id,
@@ -701,7 +608,7 @@
:param floating_ip: type DeletableFloatingIp
"""
floating_ip.update(port_id=None)
- self.assertEqual(None, floating_ip.port_id)
+ self.assertIsNone(floating_ip.port_id)
return floating_ip
def _ping_ip_address(self, ip_address, should_succeed=True):
@@ -797,6 +704,28 @@
private_key)
linux_client.validate_authentication()
+ def _check_remote_connectivity(self, source, dest, should_succeed=True):
+ """
+ check ping server via source ssh connection
+
+ :param source: RemoteClient: an ssh connection from which to ping
+ :param dest: and IP to ping against
+ :param should_succeed: boolean should ping succeed or not
+ :returns: boolean -- should_succeed == ping
+ :returns: ping is false if ping failed
+ """
+ def ping_remote():
+ try:
+ source.ping_host(dest)
+ except exceptions.SSHExecCommandFailed:
+ LOG.exception('Failed to ping host via ssh connection')
+ return not should_succeed
+ return should_succeed
+
+ return tempest.test.call_until_true(ping_remote,
+ CONF.compute.ping_timeout,
+ 1)
+
def _create_security_group_nova(self, client=None,
namestart='secgroup-smoke-',
tenant_id=None):
@@ -1029,9 +958,6 @@
router = self._get_router(tenant_id)
subnet = self._create_subnet(network)
subnet.add_to_router(router.id)
- self.networks.append(network)
- self.subnets.append(subnet)
- self.routers.append(router)
return network, subnet, router
diff --git a/tempest/scenario/orchestration/test_autoscaling.py b/tempest/scenario/orchestration/test_autoscaling.py
index cd7a2b2..82ba3c5 100644
--- a/tempest/scenario/orchestration/test_autoscaling.py
+++ b/tempest/scenario/orchestration/test_autoscaling.py
@@ -15,10 +15,7 @@
from tempest import config
from tempest.scenario import manager
-from tempest.test import attr
-from tempest.test import call_until_true
-from tempest.test import services
-from tempest.test import skip_because
+from tempest import test
CONF = config.CONF
@@ -64,9 +61,9 @@
if not CONF.orchestration.keypair_name:
self.set_resource('stack', self.stack)
- @skip_because(bug="1257575")
- @attr(type='slow')
- @services('orchestration', 'compute')
+ @test.skip_because(bug="1257575")
+ @test.attr(type='slow')
+ @test.services('orchestration', 'compute')
def test_scale_up_then_down(self):
self.assign_keypair()
@@ -98,8 +95,8 @@
return self.server_count
def assertScale(from_servers, to_servers):
- call_until_true(lambda: server_count() == to_servers,
- timeout, interval)
+ test.call_until_true(lambda: server_count() == to_servers,
+ timeout, interval)
self.assertEqual(to_servers, self.server_count,
'Failed scaling from %d to %d servers. '
'Current server count: %s' % (
diff --git a/tempest/scenario/test_aggregates_basic_ops.py b/tempest/scenario/test_aggregates_basic_ops.py
index f2b681e..8e34c16 100644
--- a/tempest/scenario/test_aggregates_basic_ops.py
+++ b/tempest/scenario/test_aggregates_basic_ops.py
@@ -14,7 +14,7 @@
# under the License.
from tempest.common import tempest_fixtures as fixtures
-from tempest.common.utils.data_utils import rand_name
+from tempest.common.utils import data_utils
from tempest.openstack.common import log as logging
from tempest.scenario import manager
from tempest import test
@@ -107,7 +107,7 @@
def test_aggregate_basic_ops(self):
self.useFixture(fixtures.LockFixture('availability_zone'))
az = 'foo_zone'
- aggregate_name = rand_name('aggregate-scenario')
+ aggregate_name = data_utils.rand_name('aggregate-scenario')
aggregate = self._create_aggregate(name=aggregate_name,
availability_zone=az)
@@ -119,7 +119,7 @@
self._check_aggregate_details(aggregate, aggregate_name, az, [host],
metadata)
- aggregate_name = rand_name('renamed-aggregate-scenario')
+ aggregate_name = data_utils.rand_name('renamed-aggregate-scenario')
aggregate = self._update_aggregate(aggregate, aggregate_name, None)
additional_metadata = {'foo': 'bar'}
diff --git a/tempest/scenario/test_dashboard_basic_ops.py b/tempest/scenario/test_dashboard_basic_ops.py
index 19996e5..6418a73 100644
--- a/tempest/scenario/test_dashboard_basic_ops.py
+++ b/tempest/scenario/test_dashboard_basic_ops.py
@@ -19,7 +19,7 @@
from tempest import config
from tempest.scenario import manager
-from tempest.test import services
+from tempest import test
CONF = config.CONF
@@ -69,7 +69,7 @@
response = self.opener.open(CONF.dashboard.dashboard_url)
self.assertIn('Overview', response.read())
- @services('dashboard')
+ @test.services('dashboard')
def test_basic_scenario(self):
self.check_login_page()
self.user_login()
diff --git a/tempest/scenario/test_large_ops.py b/tempest/scenario/test_large_ops.py
index e8030c9..b7a30f8 100644
--- a/tempest/scenario/test_large_ops.py
+++ b/tempest/scenario/test_large_ops.py
@@ -17,7 +17,7 @@
from tempest import config
from tempest.openstack.common import log as logging
from tempest.scenario import manager
-from tempest.test import services
+from tempest import test
CONF = config.CONF
@@ -47,43 +47,6 @@
self.status_timeout(
self.compute_client.servers, server.id, status)
- def _wait_for_volume_status(self, status):
- volume_id = self.volume.id
- self.status_timeout(
- self.volume_client.volumes, volume_id, status)
-
- def _image_create(self, name, fmt, path, properties={}):
- name = data_utils.rand_name('%s-' % name)
- image_file = open(path, 'rb')
- self.addCleanup(image_file.close)
- params = {
- 'name': name,
- 'container_format': fmt,
- 'disk_format': fmt,
- 'is_public': 'True',
- }
- params.update(properties)
- image = self.image_client.images.create(**params)
- self.addCleanup(self.image_client.images.delete, image)
- self.assertEqual("queued", image.status)
- image.update(data=image_file)
- return image.id
-
- def glance_image_create(self):
- aki_img_path = CONF.scenario.img_dir + "/" + CONF.scenario.aki_img_file
- ari_img_path = CONF.scenario.img_dir + "/" + CONF.scenario.ari_img_file
- ami_img_path = CONF.scenario.img_dir + "/" + CONF.scenario.ami_img_file
- LOG.debug("paths: ami: %s, ari: %s, aki: %s"
- % (ami_img_path, ari_img_path, aki_img_path))
- kernel_id = self._image_create('scenario-aki', 'aki', aki_img_path)
- ramdisk_id = self._image_create('scenario-ari', 'ari', ari_img_path)
- properties = {
- 'properties': {'kernel_id': kernel_id, 'ramdisk_id': ramdisk_id}
- }
- self.image = self._image_create('scenario-ami', 'ami',
- path=ami_img_path,
- properties=properties)
-
def nova_boot(self):
name = data_utils.rand_name('scenario-server-')
client = self.compute_client
@@ -100,7 +63,7 @@
self.set_resource(server.name, server)
self._wait_for_server_status('ACTIVE')
- @services('compute', 'image')
+ @test.services('compute', 'image')
def test_large_ops_scenario(self):
if CONF.scenario.large_ops_number < 1:
return
diff --git a/tempest/scenario/test_load_balancer_basic.py b/tempest/scenario/test_load_balancer_basic.py
index f4ca958..ce2c66f 100644
--- a/tempest/scenario/test_load_balancer_basic.py
+++ b/tempest/scenario/test_load_balancer_basic.py
@@ -17,7 +17,6 @@
import urllib
from tempest.api.network import common as net_common
-from tempest.common import ssh
from tempest.common.utils import data_utils
from tempest import config
from tempest import exceptions
@@ -61,13 +60,11 @@
super(TestLoadBalancerBasic, cls).setUpClass()
cls.check_preconditions()
cls.security_groups = {}
- cls.networks = []
- cls.subnets = []
cls.servers_keypairs = {}
- cls.pools = []
cls.members = []
- cls.vips = []
cls.floating_ips = {}
+ cls.server_ip = None
+ cls.vip_ip = None
cls.port1 = 80
cls.port2 = 88
@@ -80,45 +77,47 @@
name = data_utils.rand_name("smoke_server-")
keypair = self.create_keypair(name='keypair-%s' % name)
security_groups = [self.security_groups[tenant_id].name]
- nets = self.network_client.list_networks()
- for net in nets['networks']:
- if net['tenant_id'] == self.tenant_id:
- self.networks.append(net)
- create_kwargs = {
- 'nics': [
- {'net-id': net['id']},
- ],
- 'key_name': keypair.name,
- 'security_groups': security_groups,
- }
- server = self.create_server(name=name,
- create_kwargs=create_kwargs)
- self.servers_keypairs[server] = keypair
- break
+ net = self._list_networks(tenant_id=self.tenant_id)[0]
+ create_kwargs = {
+ 'nics': [
+ {'net-id': net['id']},
+ ],
+ 'key_name': keypair.name,
+ 'security_groups': security_groups,
+ }
+ server = self.create_server(name=name,
+ create_kwargs=create_kwargs)
+ self.servers_keypairs[server] = keypair
+ if (config.network.public_network_id and not
+ config.network.tenant_networks_reachable):
+ public_network_id = config.network.public_network_id
+ floating_ip = self._create_floating_ip(
+ server, public_network_id)
+ self.floating_ips[floating_ip] = server
+ self.server_ip = floating_ip.floating_ip_address
+ else:
+ self.server_ip = server.networks[net['name']][0]
self.assertTrue(self.servers_keypairs)
+ return server
- def _start_servers(self):
+ def _start_servers(self, server):
"""
1. SSH to the instance
- 2. Start two servers listening on ports 80 and 88 respectively
+ 2. Start two http backends listening on ports 80 and 88 respectively
"""
- for server in self.servers_keypairs.keys():
- ssh_login = config.compute.image_ssh_user
- private_key = self.servers_keypairs[server].private_key
- network_name = self.networks[0]['name']
- ip_address = server.networks[network_name][0]
- ssh_client = ssh.Client(ip_address, ssh_login,
- pkey=private_key,
- timeout=100)
- start_server = "while true; do echo -e 'HTTP/1.0 200 OK\r\n\r\n" \
- "%(server)s' | sudo nc -l -p %(port)s ; done &"
- cmd = start_server % {'server': 'server1',
- 'port': self.port1}
- ssh_client.exec_command(cmd)
- cmd = start_server % {'server': 'server2',
- 'port': self.port2}
- ssh_client.exec_command(cmd)
+ private_key = self.servers_keypairs[server].private_key
+ ssh_client = self.get_remote_client(
+ server_or_ip=self.server_ip,
+ private_key=private_key).ssh_client
+ start_server = "while true; do echo -e 'HTTP/1.0 200 OK\r\n\r\n" \
+ "%(server)s' | sudo nc -l -p %(port)s ; done &"
+ cmd = start_server % {'server': 'server1',
+ 'port': self.port1}
+ ssh_client.exec_command(cmd)
+ cmd = start_server % {'server': 'server2',
+ 'port': self.port2}
+ ssh_client.exec_command(cmd)
def _check_connection(self, check_ip):
def try_connect(ip):
@@ -138,19 +137,17 @@
def _create_pool(self):
"""Create a pool with ROUND_ROBIN algorithm."""
- subnets = self.network_client.list_subnets()
- for subnet in subnets['subnets']:
- if subnet['tenant_id'] == self.tenant_id:
- self.subnets.append(subnet)
- pool = super(TestLoadBalancerBasic, self)._create_pool(
- 'ROUND_ROBIN',
- 'HTTP',
- subnet['id'])
- self.pools.append(pool)
- break
- self.assertTrue(self.pools)
+ # get tenant subnet and verify there's only one
+ subnet = self._list_subnets(tenant_id=self.tenant_id)[0]
+ self.subnet = net_common.DeletableSubnet(client=self.network_client,
+ **subnet)
+ self.pool = super(TestLoadBalancerBasic, self)._create_pool(
+ 'ROUND_ROBIN',
+ 'HTTP',
+ self.subnet.id)
+ self.assertTrue(self.pool)
- def _create_members(self, network_name, server_ids):
+ def _create_members(self, server_ids):
"""
Create two members.
@@ -160,8 +157,8 @@
servers = self.compute_client.servers.list()
for server in servers:
if server.id in server_ids:
- ip = server.networks[network_name][0]
- pool_id = self.pools[0]['id']
+ ip = self.server_ip
+ pool_id = self.pool.id
if len(set(server_ids)) == 1 or len(servers) == 1:
member1 = self._create_member(ip, self.port1, pool_id)
member2 = self._create_member(ip, self.port2, pool_id)
@@ -173,29 +170,32 @@
def _assign_floating_ip_to_vip(self, vip):
public_network_id = config.network.public_network_id
- port_id = vip['port_id']
- floating_ip = self._create_floating_ip(vip,
- public_network_id,
- port_filters=port_id)
- self.floating_ips.setdefault(vip['id'], [])
- self.floating_ips[vip['id']].append(floating_ip)
+ port_id = vip.port_id
+ floating_ip = self._create_floating_ip(vip, public_network_id,
+ port_id=port_id)
+ self.floating_ips.setdefault(vip.id, [])
+ self.floating_ips[vip.id].append(floating_ip)
def _create_load_balancer(self):
self._create_pool()
- self._create_members(self.networks[0]['name'],
- [self.servers_keypairs.keys()[0].id])
- subnet_id = self.subnets[0]['id']
- pool_id = self.pools[0]['id']
- vip = super(TestLoadBalancerBasic, self)._create_vip('HTTP', 80,
- subnet_id,
- pool_id)
- self.vips.append(vip)
+ self._create_members([self.servers_keypairs.keys()[0].id])
+ subnet_id = self.subnet.id
+ pool_id = self.pool.id
+ self.vip = super(TestLoadBalancerBasic, self)._create_vip('HTTP', 80,
+ subnet_id,
+ pool_id)
self._status_timeout(NeutronRetriever(self.network_client,
self.network_client.vip_path,
net_common.DeletableVip),
- self.vips[0]['id'],
+ self.vip.id,
expected_status='ACTIVE')
- self._assign_floating_ip_to_vip(self.vips[0])
+ if (config.network.public_network_id and not
+ config.network.tenant_networks_reachable):
+ self._assign_floating_ip_to_vip(self.vip)
+ self.vip_ip = self.floating_ips[
+ self.vip.id][0]['floating_ip_address']
+ else:
+ self.vip_ip = self.vip.address
def _check_load_balancing(self):
"""
@@ -205,16 +205,13 @@
of the requests
"""
- vip = self.vips[0]
- floating_ip_vip = self.floating_ips[
- vip['id']][0]['floating_ip_address']
- self._check_connection(floating_ip_vip)
+ self._check_connection(self.vip_ip)
resp = []
for count in range(10):
resp.append(
urllib.urlopen(
- "http://{0}/".format(floating_ip_vip)).read())
- self.assertEqual({"server1\n", "server2\n"}, set(resp))
+ "http://{0}/".format(self.vip_ip)).read())
+ self.assertEqual(set(["server1\n", "server2\n"]), set(resp))
self.assertEqual(5, resp.count("server1\n"))
self.assertEqual(5, resp.count("server2\n"))
@@ -222,8 +219,8 @@
@test.services('compute', 'network')
def test_load_balancer_basic(self):
self._create_security_groups()
- self._create_server()
- self._start_servers()
+ server = self._create_server()
+ self._start_servers(server)
self._create_load_balancer()
self._check_load_balancing()
diff --git a/tempest/scenario/test_minimum_basic.py b/tempest/scenario/test_minimum_basic.py
index 846e0cc..24d2677 100644
--- a/tempest/scenario/test_minimum_basic.py
+++ b/tempest/scenario/test_minimum_basic.py
@@ -13,11 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest.common.utils import data_utils
+from tempest.common import debug
from tempest import config
from tempest.openstack.common import log as logging
from tempest.scenario import manager
-from tempest.test import services
+from tempest import test
CONF = config.CONF
@@ -42,43 +42,6 @@
self.status_timeout(
self.compute_client.servers, server_id, status)
- def _wait_for_volume_status(self, status):
- volume_id = self.volume.id
- self.status_timeout(
- self.volume_client.volumes, volume_id, status)
-
- def _image_create(self, name, fmt, path, properties={}):
- name = data_utils.rand_name('%s-' % name)
- image_file = open(path, 'rb')
- self.addCleanup(image_file.close)
- params = {
- 'name': name,
- 'container_format': fmt,
- 'disk_format': fmt,
- 'is_public': 'True',
- }
- params.update(properties)
- image = self.image_client.images.create(**params)
- self.addCleanup(self.image_client.images.delete, image)
- self.assertEqual("queued", image.status)
- image.update(data=image_file)
- return image.id
-
- def glance_image_create(self):
- aki_img_path = CONF.scenario.img_dir + "/" + CONF.scenario.aki_img_file
- ari_img_path = CONF.scenario.img_dir + "/" + CONF.scenario.ari_img_file
- ami_img_path = CONF.scenario.img_dir + "/" + CONF.scenario.ami_img_file
- LOG.debug("paths: ami: %s, ari: %s, aki: %s"
- % (ami_img_path, ari_img_path, aki_img_path))
- kernel_id = self._image_create('scenario-aki', 'aki', aki_img_path)
- ramdisk_id = self._image_create('scenario-ari', 'ari', ari_img_path)
- properties = {
- 'properties': {'kernel_id': kernel_id, 'ramdisk_id': ramdisk_id}
- }
- self.image = self._image_create('scenario-ami', 'ami',
- path=ami_img_path,
- properties=properties)
-
def nova_keypair_add(self):
self.keypair = self.create_keypair()
@@ -114,7 +77,7 @@
self.volume.id,
'/dev/vdb')
self.assertEqual(self.volume.id, volume.id)
- self._wait_for_volume_status('in-use')
+ self.wait_for_volume_status('in-use')
def nova_reboot(self):
self.server.reboot()
@@ -130,9 +93,11 @@
def ssh_to_server(self):
try:
self.linux_client = self.get_remote_client(self.floating_ip.ip)
+ self.linux_client.validate_authentication()
except Exception:
LOG.exception('ssh to server failed')
self._log_console_output()
+ debug.log_net_debug()
raise
def check_partitions(self):
@@ -142,12 +107,12 @@
def nova_volume_detach(self):
detach_volume_client = self.compute_client.volumes.delete_server_volume
detach_volume_client(self.server.id, self.volume.id)
- self._wait_for_volume_status('available')
+ self.wait_for_volume_status('available')
volume = self.volume_client.volumes.get(self.volume.id)
self.assertEqual('available', volume.status)
- @services('compute', 'volume', 'image', 'network')
+ @test.services('compute', 'volume', 'image', 'network')
def test_minimum_basic_scenario(self):
self.glance_image_create()
self.nova_keypair_add()
@@ -160,10 +125,11 @@
self.nova_volume_attach()
self.addCleanup(self.nova_volume_detach)
self.cinder_show()
- self.nova_reboot()
self.nova_floating_ip_create()
self.nova_floating_ip_add()
self._create_loginable_secgroup_rule_nova()
self.ssh_to_server()
+ self.nova_reboot()
+ self.ssh_to_server()
self.check_partitions()
diff --git a/tempest/scenario/test_network_basic_ops.py b/tempest/scenario/test_network_basic_ops.py
index 020a256..d5ab3d3 100644
--- a/tempest/scenario/test_network_basic_ops.py
+++ b/tempest/scenario/test_network_basic_ops.py
@@ -13,19 +13,24 @@
# 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 collections
+import re
+
+from tempest.api.network import common as net_common
from tempest.common import debug
from tempest.common.utils import data_utils
from tempest import config
from tempest.openstack.common import log as logging
from tempest.scenario import manager
-
-from tempest.test import attr
-from tempest.test import services
+from tempest import test
CONF = config.CONF
LOG = logging.getLogger(__name__)
+Floating_IP_tuple = collections.namedtuple('Floating_IP_tuple',
+ ['floating_ip', 'server'])
+
class TestNetworkBasicOps(manager.NetworkScenarioTest):
@@ -34,36 +39,6 @@
boot VM's with Neutron-managed networking, and attempts to
verify network connectivity as follows:
- * For a freshly-booted VM with an IP address ("port") on a given network:
-
- - the Tempest host can ping the IP address. This implies, but
- does not guarantee (see the ssh check that follows), that the
- VM has been assigned the correct IP address and has
- connectivity to the Tempest host.
-
- - the Tempest host can perform key-based authentication to an
- 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:
-
- - ping an external IP address, implying external connectivity.
-
- - ping an external hostname, implying that dns is correctly
- configured.
-
- - ping an internal IP address, implying connectivity to another
- VM on the same network.
-
There are presumed to be two types of networks: tenant and
public. A tenant network may or may not be reachable from the
Tempest host. A public network is assumed to be reachable from
@@ -113,47 +88,62 @@
@classmethod
def setUpClass(cls):
super(TestNetworkBasicOps, cls).setUpClass()
+ for ext in ['router', 'security-group']:
+ if not test.is_extension_enabled(ext, 'network'):
+ msg = "%s extension not enabled." % ext
+ raise cls.skipException(msg)
cls.check_preconditions()
- # TODO(mnewby) Consider looking up entities as needed instead
- # of storing them as collections on the class.
- cls.security_groups = {}
- cls.networks = []
- cls.subnets = []
- cls.routers = []
- cls.servers = {}
- cls.floating_ips = {}
- def _create_security_groups(self):
- self.security_groups[self.tenant_id] =\
+ def cleanup_wrapper(self, resource):
+ self.cleanup_resource(resource, self.__class__.__name__)
+
+ def setUp(self):
+ super(TestNetworkBasicOps, self).setUp()
+ self.security_group = \
self._create_security_group_neutron(tenant_id=self.tenant_id)
+ self.addCleanup(self.cleanup_wrapper, self.security_group)
+ self.network, self.subnet, self.router = self._create_networks()
+ for r in [self.network, self.router, self.subnet]:
+ self.addCleanup(self.cleanup_wrapper, r)
+ self.check_networks()
+ self.servers = {}
+ name = data_utils.rand_name('server-smoke')
+ serv_dict = self._create_server(name, self.network)
+ self.servers[serv_dict['server']] = serv_dict['keypair']
+ self._check_tenant_network_connectivity()
- def _check_networks(self):
- # Checks that we see the newly created network/subnet/router via
- # checking the result of list_[networks,routers,subnets]
+ self._create_and_associate_floating_ips()
+
+ def check_networks(self):
+ """
+ Checks that we see the newly created network/subnet/router via
+ checking the result of list_[networks,routers,subnets]
+ """
+
seen_nets = self._list_networks()
seen_names = [n['name'] for n in seen_nets]
seen_ids = [n['id'] for n in seen_nets]
- for mynet in self.networks:
- self.assertIn(mynet.name, seen_names)
- self.assertIn(mynet.id, seen_ids)
+ self.assertIn(self.network.name, seen_names)
+ self.assertIn(self.network.id, seen_ids)
+
seen_subnets = self._list_subnets()
seen_net_ids = [n['network_id'] for n in seen_subnets]
seen_subnet_ids = [n['id'] for n in seen_subnets]
- for mynet in self.networks:
- self.assertIn(mynet.id, seen_net_ids)
- for mysubnet in self.subnets:
- self.assertIn(mysubnet.id, seen_subnet_ids)
+ self.assertIn(self.network.id, seen_net_ids)
+ self.assertIn(self.subnet.id, seen_subnet_ids)
+
seen_routers = self._list_routers()
seen_router_ids = [n['id'] for n in seen_routers]
seen_router_names = [n['name'] for n in seen_routers]
- for myrouter in self.routers:
- self.assertIn(myrouter.name, seen_router_names)
- self.assertIn(myrouter.id, seen_router_ids)
+ self.assertIn(self.router.name,
+ seen_router_names)
+ self.assertIn(self.router.id,
+ seen_router_ids)
def _create_server(self, name, network):
- tenant_id = network.tenant_id
keypair = self.create_keypair(name='keypair-%s' % name)
- security_groups = [self.security_groups[tenant_id].name]
+ self.addCleanup(self.cleanup_wrapper, keypair)
+ security_groups = [self.security_group.name]
create_kwargs = {
'nics': [
{'net-id': network.id},
@@ -162,13 +152,8 @@
'security_groups': security_groups,
}
server = self.create_server(name=name, create_kwargs=create_kwargs)
- self.servers[server] = keypair
- return server
-
- def _create_servers(self):
- for i, network in enumerate(self.networks):
- name = data_utils.rand_name('server-smoke-%d-' % i)
- self._create_server(name, network)
+ self.addCleanup(self.cleanup_wrapper, server)
+ return dict(server=server, keypair=keypair)
def _check_tenant_network_connectivity(self):
if not CONF.network.tenant_networks_reachable:
@@ -179,7 +164,7 @@
# key-based authentication by cloud-init.
ssh_login = CONF.compute.image_ssh_user
try:
- for server, key in self.servers.items():
+ for server, key in self.servers.iteritems():
for net_name, ip_addresses in server.networks.iteritems():
for ip_address in ip_addresses:
self._check_vm_connectivity(ip_address, ssh_login,
@@ -187,14 +172,15 @@
except Exception:
LOG.exception('Tenant connectivity check failed')
self._log_console_output(servers=self.servers.keys())
- debug.log_ip_ns()
+ debug.log_net_debug()
raise
def _create_and_associate_floating_ips(self):
public_network_id = CONF.network.public_network_id
for server in self.servers.keys():
floating_ip = self._create_floating_ip(server, public_network_id)
- self.floating_ips[floating_ip] = server
+ self.floating_ip_tuple = Floating_IP_tuple(floating_ip, server)
+ self.addCleanup(self.cleanup_wrapper, floating_ip)
def _check_public_network_connectivity(self, should_connect=True,
msg=None):
@@ -202,49 +188,185 @@
# key-based authentication by cloud-init.
ssh_login = CONF.compute.image_ssh_user
LOG.debug('checking network connections')
+ floating_ip, server = self.floating_ip_tuple
+ ip_address = floating_ip.floating_ip_address
+ private_key = None
+ if should_connect:
+ private_key = self.servers[server].private_key
try:
- for floating_ip, server in self.floating_ips.iteritems():
- ip_address = floating_ip.floating_ip_address
- private_key = None
- if should_connect:
- private_key = self.servers[server].private_key
- self._check_vm_connectivity(ip_address,
- ssh_login,
- private_key,
- should_connect=should_connect)
+ self._check_vm_connectivity(ip_address,
+ ssh_login,
+ private_key,
+ should_connect=should_connect)
except Exception:
ex_msg = 'Public network connectivity check failed'
if msg:
ex_msg += ": " + msg
LOG.exception(ex_msg)
self._log_console_output(servers=self.servers.keys())
- debug.log_ip_ns()
+ debug.log_net_debug()
raise
def _disassociate_floating_ips(self):
- for floating_ip, server in self.floating_ips.iteritems():
- self._disassociate_floating_ip(floating_ip)
- self.floating_ips[floating_ip] = None
+ floating_ip, server = self.floating_ip_tuple
+ self._disassociate_floating_ip(floating_ip)
+ self.floating_ip_tuple = Floating_IP_tuple(
+ floating_ip, None)
def _reassociate_floating_ips(self):
- network = self.networks[0]
- for floating_ip in self.floating_ips.keys():
- name = data_utils.rand_name('new_server-smoke-')
- # create a new server for the floating ip
- server = self._create_server(name, network)
- self._associate_floating_ip(floating_ip, server)
- self.floating_ips[floating_ip] = server
+ floating_ip, server = self.floating_ip_tuple
+ name = data_utils.rand_name('new_server-smoke-')
+ # create a new server for the floating ip
+ serv_dict = self._create_server(name, self.network)
+ self.servers[serv_dict['server']] = serv_dict['keypair']
+ self._associate_floating_ip(floating_ip, serv_dict['server'])
+ self.floating_ip_tuple = Floating_IP_tuple(
+ floating_ip, serv_dict['server'])
- @attr(type='smoke')
- @services('compute', 'network')
+ def _create_new_network(self):
+ self.new_net = self._create_network(self.tenant_id)
+ self.addCleanup(self.cleanup_wrapper, self.new_net)
+ self.new_subnet = self._create_subnet(
+ network=self.new_net,
+ gateway_ip=None)
+ self.addCleanup(self.cleanup_wrapper, self.new_subnet)
+
+ def _hotplug_server(self):
+ old_floating_ip, server = self.floating_ip_tuple
+ ip_address = old_floating_ip.floating_ip_address
+ private_key = self.servers[server].private_key
+ ssh_client = self.get_remote_client(ip_address,
+ private_key=private_key)
+ old_nic_list = self._get_server_nics(ssh_client)
+ # get a port from a list of one item
+ port_list = self._list_ports(device_id=server.id)
+ self.assertEqual(1, len(port_list))
+ old_port = port_list[0]
+ self.compute_client.servers.interface_attach(server=server,
+ net_id=self.new_net.id,
+ port_id=None,
+ fixed_ip=None)
+ # move server to the head of the cleanup list
+ self.addCleanup(self.cleanup_wrapper, server)
+
+ def check_ports():
+ port_list = [port for port in
+ self._list_ports(device_id=server.id)
+ if port != old_port]
+ return len(port_list) == 1
+
+ test.call_until_true(check_ports, 60, 1)
+ new_port_list = [p for p in
+ self._list_ports(device_id=server.id)
+ if p != old_port]
+ self.assertEqual(1, len(new_port_list))
+ new_port = new_port_list[0]
+ new_port = net_common.DeletablePort(client=self.network_client,
+ **new_port)
+ new_nic_list = self._get_server_nics(ssh_client)
+ diff_list = [n for n in new_nic_list if n not in old_nic_list]
+ self.assertEqual(1, len(diff_list))
+ num, new_nic = diff_list[0]
+ ssh_client.assign_static_ip(nic=new_nic,
+ addr=new_port.fixed_ips[0]['ip_address'])
+ ssh_client.turn_nic_on(nic=new_nic)
+
+ def _get_server_nics(self, ssh_client):
+ reg = re.compile(r'(?P<num>\d+): (?P<nic_name>\w+):')
+ ipatxt = ssh_client.get_ip_list()
+ return reg.findall(ipatxt)
+
+ def _check_network_internal_connectivity(self, network):
+ """
+ via ssh check VM internal connectivity:
+ - 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=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[self.floating_ip_tuple.server].private_key
+ ssh_source = self._ssh_to_server(ip_address, private_key)
+
+ for remote_ip in address_list:
+ try:
+ self.assertTrue(self._check_remote_connectivity(ssh_source,
+ remote_ip),
+ "Timed out waiting for %s to become "
+ "reachable" % remote_ip)
+ except Exception:
+ LOG.exception("Unable to access {dest} via ssh to "
+ "floating-ip {src}".format(dest=remote_ip,
+ src=floating_ip))
+ debug.log_ip_ns()
+ raise
+
+ @test.attr(type='smoke')
+ @test.services('compute', 'network')
def test_network_basic_ops(self):
- self._create_security_groups()
- self._create_networks()
- self._check_networks()
- self._create_servers()
- self._create_and_associate_floating_ips()
- self._check_tenant_network_connectivity()
+ """
+ For a freshly-booted VM with an IP address ("port") on a given
+ network:
+
+ - the Tempest host can ping the IP address. This implies, but
+ does not guarantee (see the ssh check that follows), that the
+ VM has been assigned the correct IP address and has
+ connectivity to the Tempest host.
+
+ - the Tempest host can perform key-based authentication to an
+ ssh server hosted at the IP address. This check guarantees
+ that the IP address is associated with the target VM.
+
+ - the Tempest host can ssh into the VM via the IP address and
+ successfully execute the following:
+
+ - ping an external IP address, implying external connectivity.
+
+ - ping an external hostname, implying that dns is correctly
+ configured.
+
+ - 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 "
@@ -253,3 +375,20 @@
self._check_public_network_connectivity(should_connect=True,
msg="after re-associate "
"floating ip")
+
+ @test.attr(type='smoke')
+ @test.services('compute', 'network')
+ def test_hotplug_nic(self):
+ """
+ 1. create a new network, with no gateway (to prevent overwriting VM's
+ gateway)
+ 2. connect VM to new network
+ 3. set static ip and bring new nic up
+ 4. check VM can ping new network dhcp port
+
+ """
+
+ self._check_public_network_connectivity(should_connect=True)
+ self._create_new_network()
+ self._hotplug_server()
+ self._check_network_internal_connectivity(network=self.new_net)
diff --git a/tempest/scenario/test_cross_tenant_connectivity.py b/tempest/scenario/test_security_groups_basic_ops.py
similarity index 73%
rename from tempest/scenario/test_cross_tenant_connectivity.py
rename to tempest/scenario/test_security_groups_basic_ops.py
index edcf091..b9ee040 100644
--- a/tempest/scenario/test_cross_tenant_connectivity.py
+++ b/tempest/scenario/test_security_groups_basic_ops.py
@@ -13,23 +13,20 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest import clients
from tempest.common import debug
from tempest.common.utils import data_utils
from tempest import config
-from tempest import exceptions
from tempest.openstack.common import log as logging
from tempest.scenario import manager
-from tempest.scenario.manager import OfficialClientManager
-from tempest.test import attr
-from tempest.test import call_until_true
-from tempest.test import services
+from tempest import test
CONF = config.CONF
LOG = logging.getLogger(__name__)
-class TestNetworkCrossTenant(manager.NetworkScenarioTest):
+class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
"""
This test suite assumes that Nova has been configured to
@@ -50,7 +47,7 @@
failure - ping_timeout reached
setup:
- for each tenant (demo and alt):
+ for primary tenant:
1. create a network&subnet
2. create a router (if public router isn't configured)
3. connect tenant network to public network via router
@@ -59,8 +56,6 @@
b. a VM with a floating ip
5. create a general empty security group (same as "default", but
without rules allowing in-tenant traffic)
- 6. for demo tenant - create another server to test in-tenant
- connections
tests:
1. _verify_network_details
@@ -80,7 +75,7 @@
been created on source tenant
assumptions:
- 1. alt_tenant/user existed and is different from demo_tenant/user
+ 1. alt_tenant/user existed and is different from primary_tenant/user
2. Public network is defined and reachable from the Tempest host
3. Public router can either be:
* defined, in which case all tenants networks can connect directly
@@ -92,7 +87,7 @@
"""
class TenantProperties():
- '''
+ """
helper class to save tenant details
id
credentials
@@ -101,14 +96,15 @@
security groups
servers
access point
- '''
+ """
def __init__(self, tenant_id, tenant_user, tenant_pass, tenant_name):
- self.manager = OfficialClientManager(
+ self.manager = clients.OfficialClientManager(
tenant_user,
tenant_pass,
tenant_name
)
+ self.keypair = None
self.tenant_id = tenant_id
self.tenant_name = tenant_name
self.tenant_user = tenant_user
@@ -119,7 +115,7 @@
self.security_groups = {}
self.servers = list()
- def _set_network(self, network, subnet, router):
+ def set_network(self, network, subnet, router):
self.network = network
self.subnet = subnet
self.router = router
@@ -129,7 +125,7 @@
@classmethod
def check_preconditions(cls):
- super(TestNetworkCrossTenant, cls).check_preconditions()
+ super(TestSecurityGroupsBasicOps, cls).check_preconditions()
if (cls.alt_tenant_id is None) or (cls.tenant_id is cls.alt_tenant_id):
msg = 'No alt_tenant defined'
cls.enabled = False
@@ -143,7 +139,7 @@
@classmethod
def setUpClass(cls):
- super(TestNetworkCrossTenant, cls).setUpClass()
+ super(TestSecurityGroupsBasicOps, cls).setUpClass()
alt_creds = cls.alt_credentials()
cls.alt_tenant_id = cls.manager._get_identity_client(
*alt_creds
@@ -151,48 +147,44 @@
cls.check_preconditions()
# TODO(mnewby) Consider looking up entities as needed instead
# of storing them as collections on the class.
- cls.keypairs = {}
- cls.security_groups = {}
- cls.networks = []
- cls.subnets = []
- cls.routers = []
- cls.servers = []
cls.floating_ips = {}
cls.tenants = {}
- cls.demo_tenant = cls.TenantProperties(
- cls.tenant_id,
- *cls.credentials()
- )
- cls.alt_tenant = cls.TenantProperties(
- cls.alt_tenant_id,
- *alt_creds
- )
- for tenant in [cls.demo_tenant, cls.alt_tenant]:
+ cls.primary_tenant = cls.TenantProperties(cls.tenant_id,
+ *cls.credentials())
+ cls.alt_tenant = cls.TenantProperties(cls.alt_tenant_id,
+ *alt_creds)
+ for tenant in [cls.primary_tenant, cls.alt_tenant]:
cls.tenants[tenant.tenant_id] = tenant
- if not CONF.network.public_router_id:
- cls.floating_ip_access = True
- else:
- cls.floating_ip_access = False
+ cls.floating_ip_access = not CONF.network.public_router_id
- @classmethod
- def tearDownClass(cls):
- super(TestNetworkCrossTenant, cls).tearDownClass()
+ def cleanup_wrapper(self, resource):
+ self.cleanup_resource(resource, self.__class__.__name__)
+
+ def setUp(self):
+ super(TestSecurityGroupsBasicOps, self).setUp()
+ self._deploy_tenant(self.primary_tenant)
+ self._verify_network_details(self.primary_tenant)
+ self._verify_mac_addr(self.primary_tenant)
def _create_tenant_keypairs(self, tenant_id):
- self.keypairs[tenant_id] = self.create_keypair(
+ keypair = self.create_keypair(
name=data_utils.rand_name('keypair-smoke-'))
+ self.addCleanup(self.cleanup_wrapper, keypair)
+ self.tenants[tenant_id].keypair = keypair
def _create_tenant_security_groups(self, tenant):
- self.security_groups.setdefault(self.tenant_id, [])
access_sg = self._create_empty_security_group(
namestart='secgroup_access-',
tenant_id=tenant.tenant_id
)
+ self.addCleanup(self.cleanup_wrapper, access_sg)
+
# don't use default secgroup since it allows in-tenant traffic
def_sg = self._create_empty_security_group(
namestart='secgroup_general-',
tenant_id=tenant.tenant_id
)
+ self.addCleanup(self.cleanup_wrapper, def_sg)
tenant.security_groups.update(access=access_sg, default=def_sg)
ssh_rule = dict(
protocol='tcp',
@@ -200,9 +192,9 @@
port_range_max=22,
direction='ingress',
)
- self._create_security_group_rule(secgroup=access_sg,
- **ssh_rule
- )
+ rule = self._create_security_group_rule(secgroup=access_sg,
+ **ssh_rule)
+ self.addCleanup(self.cleanup_wrapper, rule)
def _verify_network_details(self, tenant):
# Checks that we see the newly created network/subnet/router via
@@ -245,11 +237,12 @@
'nics': [
{'net-id': tenant.network.id},
],
- 'key_name': self.keypairs[tenant.tenant_id].name,
+ 'key_name': tenant.keypair.name,
'security_groups': security_groups,
'tenant_id': tenant.tenant_id
}
server = self.create_server(name=name, create_kwargs=create_kwargs)
+ self.addCleanup(self.cleanup_wrapper, server)
return server
def _create_tenant_servers(self, tenant, num=1):
@@ -260,7 +253,6 @@
)
name = data_utils.rand_name(name)
server = self._create_server(name, tenant)
- self.servers.append(server)
tenant.servers.append(server)
def _set_access_point(self, tenant):
@@ -275,17 +267,20 @@
name = data_utils.rand_name(name)
server = self._create_server(name, tenant,
security_groups=secgroups)
- self.servers.append(server)
tenant.access_point = server
self._assign_floating_ips(server)
def _assign_floating_ips(self, server):
public_network_id = CONF.network.public_network_id
floating_ip = self._create_floating_ip(server, public_network_id)
+ self.addCleanup(self.cleanup_wrapper, floating_ip)
self.floating_ips.setdefault(server, floating_ip)
def _create_tenant_network(self, tenant):
- tenant._set_network(*self._create_networks(tenant.tenant_id))
+ network, subnet, router = self._create_networks(tenant.tenant_id)
+ for r in [network, router, subnet]:
+ self.addCleanup(self.cleanup_wrapper, r)
+ tenant.set_network(network, subnet, router)
def _set_compute_context(self, tenant):
self.compute_client = tenant.manager.compute_client
@@ -299,8 +294,6 @@
router (if public not defined)
access security group
access-point server
- for demo_tenant:
- creates general server to test against
"""
if not isinstance(tenant_or_id, self.TenantProperties):
tenant = self.tenants[tenant_or_id]
@@ -312,19 +305,20 @@
self._create_tenant_keypairs(tenant_id)
self._create_tenant_network(tenant)
self._create_tenant_security_groups(tenant)
- if tenant is self.demo_tenant:
- self._create_tenant_servers(tenant, num=1)
self._set_access_point(tenant)
def _get_server_ip(self, server, floating=False):
- '''
+ """
returns the ip (floating/internal) of a server
- '''
+ """
if floating:
- return self.floating_ips[server].floating_ip_address
+ server_ip = self.floating_ips[server].floating_ip_address
else:
+ server_ip = None
network_name = self.tenants[server.tenant_id].network.name
- return server.networks[network_name][0]
+ if network_name in server.networks:
+ server_ip = server.networks[network_name][0]
+ return server_ip
def _connect_to_access_point(self, tenant):
"""
@@ -332,33 +326,11 @@
"""
access_point_ssh = \
self.floating_ips[tenant.access_point].floating_ip_address
- private_key = self.keypairs[tenant.tenant_id].private_key
+ private_key = tenant.keypair.private_key
access_point_ssh = self._ssh_to_server(access_point_ssh,
private_key=private_key)
return access_point_ssh
- def _test_remote_connectivity(self, source, dest, should_succeed=True):
- """
- check ping server via source ssh connection
-
- :param source: RemoteClient: an ssh connection from which to ping
- :param dest: and IP to ping against
- :param should_succeed: boolean should ping succeed or not
- :returns: boolean -- should_succeed == ping
- :returns: ping is false if ping failed
- """
- def ping_remote():
- try:
- source.ping_host(dest)
- except exceptions.SSHExecCommandFailed as ex:
- LOG.debug(ex)
- return not should_succeed
- return should_succeed
-
- return call_until_true(ping_remote,
- CONF.compute.ping_timeout,
- 1)
-
def _check_connectivity(self, access_point, ip, should_succeed=True):
if should_succeed:
msg = "Timed out waiting for %s to become reachable" % ip
@@ -367,11 +339,11 @@
return True
msg = "%s is reachable" % ip
try:
- self.assertTrue(self._test_remote_connectivity(access_point, ip,
- should_succeed),
+ self.assertTrue(self._check_remote_connectivity(access_point, ip,
+ should_succeed),
msg)
except Exception:
- debug.log_ip_ns()
+ debug.log_net_debug()
raise
def _test_in_tenant_block(self, tenant):
@@ -391,17 +363,17 @@
secgroup=tenant.security_groups['default'],
**ruleset
)
+ self.addCleanup(self.cleanup_wrapper, rule)
access_point_ssh = self._connect_to_access_point(tenant)
for server in tenant.servers:
self._check_connectivity(access_point=access_point_ssh,
ip=self._get_server_ip(server))
- rule.delete()
def _test_cross_tenant_block(self, source_tenant, dest_tenant):
- '''
+ """
if public router isn't defined, then dest_tenant access is via
floating-ip
- '''
+ """
access_point_ssh = self._connect_to_access_point(source_tenant)
ip = self._get_server_ip(dest_tenant.access_point,
floating=self.floating_ip_access)
@@ -409,10 +381,10 @@
should_succeed=False)
def _test_cross_tenant_allow(self, source_tenant, dest_tenant):
- '''
+ """
check for each direction:
creating rule for tenant incoming traffic enables only 1way traffic
- '''
+ """
ruleset = dict(
protocol='icmp',
direction='ingress'
@@ -421,37 +393,26 @@
secgroup=dest_tenant.security_groups['default'],
**ruleset
)
- try:
- access_point_ssh = self._connect_to_access_point(source_tenant)
- ip = self._get_server_ip(dest_tenant.access_point,
- floating=self.floating_ip_access)
- self._check_connectivity(access_point_ssh, ip)
+ self.addCleanup(self.cleanup_wrapper, rule_s2d)
+ access_point_ssh = self._connect_to_access_point(source_tenant)
+ ip = self._get_server_ip(dest_tenant.access_point,
+ floating=self.floating_ip_access)
+ self._check_connectivity(access_point_ssh, ip)
- # test that reverse traffic is still blocked
- self._test_cross_tenant_block(dest_tenant, source_tenant)
+ # test that reverse traffic is still blocked
+ self._test_cross_tenant_block(dest_tenant, source_tenant)
- # allow reverse traffic and check
- rule_d2s = self._create_security_group_rule(
- secgroup=source_tenant.security_groups['default'],
- **ruleset
- )
- try:
- access_point_ssh_2 = self._connect_to_access_point(dest_tenant)
- ip = self._get_server_ip(source_tenant.access_point,
- floating=self.floating_ip_access)
- self._check_connectivity(access_point_ssh_2, ip)
+ # allow reverse traffic and check
+ rule_d2s = self._create_security_group_rule(
+ secgroup=source_tenant.security_groups['default'],
+ **ruleset
+ )
+ self.addCleanup(self.cleanup_wrapper, rule_d2s)
- # clean_rules
- rule_s2d.delete()
- rule_d2s.delete()
-
- except Exception as e:
- rule_d2s.delete()
- raise e
-
- except Exception as e:
- rule_s2d.delete()
- raise e
+ access_point_ssh_2 = self._connect_to_access_point(dest_tenant)
+ ip = self._get_server_ip(source_tenant.access_point,
+ floating=self.floating_ip_access)
+ self._check_connectivity(access_point_ssh_2, ip)
def _verify_mac_addr(self, tenant):
"""
@@ -471,24 +432,36 @@
subnet_id = tenant.subnet.id
self.assertIn((subnet_id, server_ip, mac_addr), port_detail_list)
- @attr(type='smoke')
- @services('compute', 'network')
+ @test.attr(type='smoke')
+ @test.services('compute', 'network')
def test_cross_tenant_traffic(self):
try:
- for tenant_id in self.tenants.keys():
- self._deploy_tenant(tenant_id)
- self._verify_network_details(self.tenants[tenant_id])
- self._verify_mac_addr(self.tenants[tenant_id])
-
- # in-tenant check
- self._test_in_tenant_block(self.demo_tenant)
- self._test_in_tenant_allow(self.demo_tenant)
+ # deploy new tenant
+ self._deploy_tenant(self.alt_tenant)
+ self._verify_network_details(self.alt_tenant)
+ self._verify_mac_addr(self.alt_tenant)
# cross tenant check
- source_tenant = self.demo_tenant
+ source_tenant = self.primary_tenant
dest_tenant = self.alt_tenant
self._test_cross_tenant_block(source_tenant, dest_tenant)
self._test_cross_tenant_allow(source_tenant, dest_tenant)
except Exception:
- self._log_console_output(servers=self.servers)
+ for tenant in self.tenants.values():
+ self._log_console_output(servers=tenant.servers)
+ raise
+
+ @test.attr(type='smoke')
+ @test.services('compute', 'network')
+ def test_in_tenant_traffic(self):
+ try:
+ self._create_tenant_servers(self.primary_tenant, num=1)
+
+ # in-tenant check
+ self._test_in_tenant_block(self.primary_tenant)
+ self._test_in_tenant_allow(self.primary_tenant)
+
+ except Exception:
+ for tenant in self.tenants.values():
+ self._log_console_output(servers=tenant.servers)
raise
diff --git a/tempest/scenario/test_server_advanced_ops.py b/tempest/scenario/test_server_advanced_ops.py
index 9626157..c0eb6e7 100644
--- a/tempest/scenario/test_server_advanced_ops.py
+++ b/tempest/scenario/test_server_advanced_ops.py
@@ -16,7 +16,7 @@
from tempest import config
from tempest.openstack.common import log as logging
from tempest.scenario import manager
-from tempest.test import services
+from tempest import test
CONF = config.CONF
@@ -47,7 +47,7 @@
msg = "Skipping test - flavor_ref and flavor_ref_alt are identical"
raise cls.skipException(msg)
- @services('compute')
+ @test.services('compute')
def test_resize_server_confirm(self):
# We create an instance for use in this test
instance = self.create_server()
@@ -65,7 +65,7 @@
self.status_timeout(
self.compute_client.servers, instance_id, 'ACTIVE')
- @services('compute')
+ @test.services('compute')
def test_server_sequence_suspend_resume(self):
# We create an instance for use in this test
instance = self.create_server()
diff --git a/tempest/scenario/test_server_basic_ops.py b/tempest/scenario/test_server_basic_ops.py
index 73ff6b4..d369f12 100644
--- a/tempest/scenario/test_server_basic_ops.py
+++ b/tempest/scenario/test_server_basic_ops.py
@@ -18,7 +18,7 @@
from tempest import config
from tempest.openstack.common import log as logging
from tempest.scenario import manager
-from tempest.test import services
+from tempest import test
import testscenarios
@@ -26,10 +26,6 @@
LOG = logging.getLogger(__name__)
-# NOTE(andreaf) - nose does not honour the load_tests protocol
-# however it's test discovery regex will match anything
-# which includes _tests. So nose would require some further
-# investigation to be supported with this
load_tests = testscenarios.load_tests_apply_scenarios
@@ -162,7 +158,7 @@
self._log_console_output()
raise
- @services('compute', 'network')
+ @test.services('compute', 'network')
def test_server_basicops(self):
self.add_keypair()
self.create_security_group()
diff --git a/tempest/scenario/test_snapshot_pattern.py b/tempest/scenario/test_snapshot_pattern.py
index 2bb3d84..562020a 100644
--- a/tempest/scenario/test_snapshot_pattern.py
+++ b/tempest/scenario/test_snapshot_pattern.py
@@ -16,7 +16,7 @@
from tempest import config
from tempest.openstack.common import log
from tempest.scenario import manager
-from tempest.test import services
+from tempest import test
CONF = config.CONF
@@ -45,11 +45,10 @@
def _ssh_to_server(self, server_or_ip):
try:
- linux_client = self.get_remote_client(server_or_ip)
+ return self.get_remote_client(server_or_ip)
except Exception:
LOG.exception()
self._log_console_output()
- return linux_client.ssh_client
def _write_timestamp(self, server_or_ip):
ssh_client = self._ssh_to_server(server_or_ip)
@@ -69,7 +68,7 @@
def _set_floating_ip_to_server(self, server, floating_ip):
server.add_floating_ip(floating_ip)
- @services('compute', 'network', 'image')
+ @test.services('compute', 'network', 'image')
def test_snapshot_pattern(self):
# prepare for booting a instance
self._add_keypair()
diff --git a/tempest/scenario/test_stamp_pattern.py b/tempest/scenario/test_stamp_pattern.py
index 8d043ae..128ec17 100644
--- a/tempest/scenario/test_stamp_pattern.py
+++ b/tempest/scenario/test_stamp_pattern.py
@@ -72,8 +72,7 @@
server.add_floating_ip(floating_ip)
def _ssh_to_server(self, server_or_ip):
- linux_client = self.get_remote_client(server_or_ip)
- return linux_client.ssh_client
+ return self.get_remote_client(server_or_ip)
def _create_volume_snapshot(self, volume):
snapshot_name = data_utils.rand_name('scenario-snapshot-')
@@ -114,7 +113,7 @@
detach_volume_client(server.id, volume.id)
self._wait_for_volume_status(volume, 'available')
- def _wait_for_volume_availible_on_the_system(self, server_or_ip):
+ def _wait_for_volume_available_on_the_system(self, server_or_ip):
ssh = self.get_remote_client(server_or_ip)
def _func():
@@ -161,7 +160,7 @@
ip_for_server = server
self._attach_volume(server, volume)
- self._wait_for_volume_availible_on_the_system(ip_for_server)
+ self._wait_for_volume_available_on_the_system(ip_for_server)
self._create_timestamp(ip_for_server)
self._detach_volume(server, volume)
@@ -189,7 +188,7 @@
# attach volume2 to instance2
self._attach_volume(server_from_snapshot, volume_from_snapshot)
- self._wait_for_volume_availible_on_the_system(ip_for_snapshot)
+ self._wait_for_volume_available_on_the_system(ip_for_snapshot)
# check the existence of the timestamp file in the volume2
self._check_timestamp(ip_for_snapshot)
diff --git a/tempest/scenario/test_swift_basic_ops.py b/tempest/scenario/test_swift_basic_ops.py
index 60df606..86e0867 100644
--- a/tempest/scenario/test_swift_basic_ops.py
+++ b/tempest/scenario/test_swift_basic_ops.py
@@ -14,11 +14,11 @@
# under the License.
-from tempest.common.utils.data_utils import rand_name
+from tempest.common.utils import data_utils
from tempest import config
from tempest.openstack.common import log as logging
from tempest.scenario import manager
-from tempest.test import services
+from tempest import test
CONF = config.CONF
@@ -53,7 +53,8 @@
LOG.debug('Swift status information obtained successfully')
def _create_container(self, container_name=None):
- name = container_name or rand_name('swift-scenario-container')
+ name = container_name or data_utils.rand_name(
+ 'swift-scenario-container')
self.object_storage_client.put_container(name)
# look for the container to assure it is created
self._list_and_check_container_objects(name)
@@ -65,9 +66,9 @@
LOG.debug('Container %s deleted' % (container_name))
def _upload_object_to_container(self, container_name, obj_name=None):
- obj_name = obj_name or rand_name('swift-scenario-object')
+ obj_name = obj_name or data_utils.rand_name('swift-scenario-object')
self.object_storage_client.put_object(container_name, obj_name,
- rand_name('obj_data'),
+ data_utils.rand_name('obj_data'),
content_type='text/plain')
return obj_name
@@ -93,7 +94,7 @@
for obj in not_present_obj:
self.assertNotIn(obj, object_list)
- @services('object_storage')
+ @test.services('object_storage')
def test_swift_basic_ops(self):
self._get_swift_stat()
container_name = self._create_container()
diff --git a/tempest/scenario/test_volume_boot_pattern.py b/tempest/scenario/test_volume_boot_pattern.py
index 7b002eb..e89ea70 100644
--- a/tempest/scenario/test_volume_boot_pattern.py
+++ b/tempest/scenario/test_volume_boot_pattern.py
@@ -14,7 +14,7 @@
from tempest import config
from tempest.openstack.common import log
from tempest.scenario import manager
-from tempest.test import services
+from tempest import test
CONF = config.CONF
@@ -53,7 +53,7 @@
'block_device_mapping': bd_map,
'key_name': keypair.name
}
- return self.create_server(create_kwargs=create_kwargs)
+ return self.create_server(image='', create_kwargs=create_kwargs)
def _create_snapshot_from_volume(self, vol_id):
volume_snapshots = self.volume_client.volume_snapshots
@@ -101,14 +101,13 @@
ip = server.networks[network_name_for_ssh][0]
try:
- client = self.get_remote_client(
+ return self.get_remote_client(
ip,
private_key=keypair.private_key)
except Exception:
LOG.exception('ssh to server failed')
self._log_console_output()
raise
- return client.ssh_client
def _get_content(self, ssh_client):
return ssh_client.exec_command('cat /tmp/text')
@@ -127,7 +126,7 @@
actual = self._get_content(ssh_client)
self.assertEqual(expected, actual)
- @services('compute', 'volume', 'image')
+ @test.services('compute', 'volume', 'image')
def test_volume_boot_pattern(self):
keypair = self.create_keypair()
self._create_loginable_secgroup_rule_nova()
@@ -170,3 +169,15 @@
# deletion operations to succeed
self._stop_instances([instance_2nd, instance_from_snapshot])
self._detach_volumes([volume_origin, volume])
+
+
+class TestVolumeBootPatternV2(TestVolumeBootPattern):
+ def _boot_instance_from_volume(self, vol_id, keypair):
+ bdms = [{'uuid': vol_id, 'source_type': 'volume',
+ 'destination_type': 'volume', 'boot_index': 0,
+ 'delete_on_termination': False}]
+ create_kwargs = {
+ 'block_device_mapping_v2': bdms,
+ 'key_name': keypair.name
+ }
+ return self.create_server(image='', create_kwargs=create_kwargs)
diff --git a/tempest/services/baremetal/base.py b/tempest/services/baremetal/base.py
index 6e86466..5f6b513 100644
--- a/tempest/services/baremetal/base.py
+++ b/tempest/services/baremetal/base.py
@@ -114,7 +114,7 @@
"""
uri = self._get_uri(resource, permanent=permanent)
- resp, body = self.get(uri, self.headers)
+ resp, body = self.get(uri)
return resp, self.deserialize(body)
@@ -127,7 +127,7 @@
"""
uri = self._get_uri(resource, uuid=uuid, permanent=permanent)
- resp, body = self.get(uri, self.headers)
+ resp, body = self.get(uri)
return resp, self.deserialize(body)
@@ -145,7 +145,7 @@
body = self.serialize(object_type, object_dict)
uri = self._get_uri(resource)
- resp, body = self.post(uri, headers=self.headers, body=body)
+ resp, body = self.post(uri, body=body)
return resp, self.deserialize(body)
@@ -160,7 +160,7 @@
"""
uri = self._get_uri(resource, uuid)
- resp, body = self.delete(uri, self.headers)
+ resp, body = self.delete(uri)
return resp, body
def _patch_request(self, resource, uuid, patch_object):
@@ -176,7 +176,7 @@
uri = self._get_uri(resource, uuid)
patch_body = json.dumps(patch_object)
- resp, body = self.patch(uri, headers=self.headers, body=patch_body)
+ resp, body = self.patch(uri, body=patch_body)
return resp, self.deserialize(body)
@handle_errors
diff --git a/tempest/services/botoclients.py b/tempest/services/botoclients.py
index 03e87b1..7616a99 100644
--- a/tempest/services/botoclients.py
+++ b/tempest/services/botoclients.py
@@ -35,6 +35,7 @@
def __init__(self, username=None, password=None,
auth_url=None, tenant_name=None,
*args, **kwargs):
+ # FIXME(andreaf) replace credentials and auth_url with auth_provider
self.connection_timeout = str(CONF.boto.http_socket_timeout)
self.num_retries = str(CONF.boto.num_retries)
@@ -45,6 +46,7 @@
"tenant_name": tenant_name}
def _keystone_aws_get(self):
+ # FIXME(andreaf) Move EC2 credentials to AuthProvider
import keystoneclient.v2_0.client
keystone = keystoneclient.v2_0.client.Client(**self.ks_cred)
@@ -177,19 +179,6 @@
'revoke_security_group',
'revoke_security_group_egress'))
- def get_good_zone(self):
- """
- :rtype: BaseString
- :return: Returns with the first available zone name
- """
- for zone in self.get_all_zones():
- # NOTE(afazekas): zone.region_name was None
- if (zone.state == "available" and
- zone.region.name == self.connection_data["region"].name):
- return zone.name
- else:
- raise IndexError("Don't have a good zone")
-
class ObjectClientS3(BotoClientBase):
diff --git a/tempest/services/compute/json/aggregates_client.py b/tempest/services/compute/json/aggregates_client.py
index aa52081..700a29b 100644
--- a/tempest/services/compute/json/aggregates_client.py
+++ b/tempest/services/compute/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 AggregatesClientJSON(RestClient):
+class AggregatesClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(AggregatesClientJSON, self).__init__(auth_provider)
@@ -43,7 +43,7 @@
def create_aggregate(self, **kwargs):
"""Creates a new aggregate."""
post_body = json.dumps({'aggregate': kwargs})
- resp, body = self.post('os-aggregates', post_body, self.headers)
+ resp, body = self.post('os-aggregates', post_body)
body = json.loads(body)
return resp, body['aggregate']
@@ -55,8 +55,7 @@
'availability_zone': availability_zone
}
put_body = json.dumps({'aggregate': put_body})
- resp, body = self.put('os-aggregates/%s' % str(aggregate_id),
- put_body, self.headers)
+ resp, body = self.put('os-aggregates/%s' % str(aggregate_id), put_body)
body = json.loads(body)
return resp, body['aggregate']
@@ -79,7 +78,7 @@
}
post_body = json.dumps({'add_host': post_body})
resp, body = self.post('os-aggregates/%s/action' % aggregate_id,
- post_body, self.headers)
+ post_body)
body = json.loads(body)
return resp, body['aggregate']
@@ -90,7 +89,7 @@
}
post_body = json.dumps({'remove_host': post_body})
resp, body = self.post('os-aggregates/%s/action' % aggregate_id,
- post_body, self.headers)
+ post_body)
body = json.loads(body)
return resp, body['aggregate']
@@ -101,6 +100,6 @@
}
post_body = json.dumps({'set_metadata': post_body})
resp, body = self.post('os-aggregates/%s/action' % aggregate_id,
- post_body, self.headers)
+ post_body)
body = json.loads(body)
return resp, body['aggregate']
diff --git a/tempest/services/compute/json/availability_zone_client.py b/tempest/services/compute/json/availability_zone_client.py
index ea4e95e..9278d5b 100644
--- a/tempest/services/compute/json/availability_zone_client.py
+++ b/tempest/services/compute/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 AvailabilityZoneClientJSON(RestClient):
+class AvailabilityZoneClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(AvailabilityZoneClientJSON, self).__init__(
diff --git a/tempest/services/compute/json/certificates_client.py b/tempest/services/compute/json/certificates_client.py
index b7135f6..c05e352 100644
--- a/tempest/services/compute/json/certificates_client.py
+++ b/tempest/services/compute/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 CertificatesClientJSON(RestClient):
+class CertificatesClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(CertificatesClientJSON, self).__init__(auth_provider)
@@ -36,6 +36,6 @@
def create_certificate(self):
"""create certificates."""
url = "os-certificates"
- resp, body = self.post(url, None, self.headers)
+ resp, body = self.post(url, None)
body = json.loads(body)
return resp, body['certificate']
diff --git a/tempest/services/compute/json/extensions_client.py b/tempest/services/compute/json/extensions_client.py
index f7e2737..5ad8b98 100644
--- a/tempest/services/compute/json/extensions_client.py
+++ b/tempest/services/compute/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/compute/json/fixed_ips_client.py b/tempest/services/compute/json/fixed_ips_client.py
index 144b7dc..5fdd564 100644
--- a/tempest/services/compute/json/fixed_ips_client.py
+++ b/tempest/services/compute/json/fixed_ips_client.py
@@ -15,13 +15,14 @@
import json
-from tempest.common.rest_client import RestClient
+from tempest.api_schema.compute.v2 import fixed_ips as schema
+from tempest.common import rest_client
from tempest import config
CONF = config.CONF
-class FixedIPsClientJSON(RestClient):
+class FixedIPsClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(FixedIPsClientJSON, self).__init__(auth_provider)
@@ -31,10 +32,11 @@
url = "os-fixed-ips/%s" % (fixed_ip)
resp, body = self.get(url)
body = json.loads(body)
+ self.validate_response(schema.fixed_ips, resp, body)
return resp, body['fixed_ip']
def reserve_fixed_ip(self, ip, body):
"""This reserves and unreserves fixed ips."""
url = "os-fixed-ips/%s/action" % (ip)
- resp, body = self.post(url, json.dumps(body), self.headers)
+ resp, body = self.post(url, json.dumps(body))
return resp, body
diff --git a/tempest/services/compute/json/flavors_client.py b/tempest/services/compute/json/flavors_client.py
index 96ab6d7..a8111af 100644
--- a/tempest/services/compute/json/flavors_client.py
+++ b/tempest/services/compute/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 FlavorsClientJSON(RestClient):
+class FlavorsClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(FlavorsClientJSON, self).__init__(auth_provider)
@@ -69,7 +69,7 @@
if kwargs.get('is_public'):
post_body['os-flavor-access:is_public'] = kwargs.get('is_public')
post_body = json.dumps({'flavor': post_body})
- resp, body = self.post('flavors', post_body, self.headers)
+ resp, body = self.post('flavors', post_body)
body = json.loads(body)
return resp, body['flavor']
@@ -92,7 +92,7 @@
"""Sets extra Specs to the mentioned flavor."""
post_body = json.dumps({'extra_specs': specs})
resp, body = self.post('flavors/%s/os-extra_specs' % flavor_id,
- post_body, self.headers)
+ post_body)
body = json.loads(body)
return resp, body['extra_specs']
@@ -112,8 +112,7 @@
def update_flavor_extra_spec(self, flavor_id, key, **kwargs):
"""Update specified extra Specs of the mentioned flavor and key."""
resp, body = self.put('flavors/%s/os-extra_specs/%s' %
- (flavor_id, key),
- json.dumps(kwargs), self.headers)
+ (flavor_id, key), json.dumps(kwargs))
body = json.loads(body)
return resp, body
@@ -124,8 +123,7 @@
def list_flavor_access(self, flavor_id):
"""Gets flavor access information given the flavor id."""
- resp, body = self.get('flavors/%s/os-flavor-access' % flavor_id,
- self.headers)
+ resp, body = self.get('flavors/%s/os-flavor-access' % flavor_id)
body = json.loads(body)
return resp, body['flavor_access']
@@ -137,8 +135,7 @@
}
}
post_body = json.dumps(post_body)
- resp, body = self.post('flavors/%s/action' % flavor_id,
- post_body, self.headers)
+ resp, body = self.post('flavors/%s/action' % flavor_id, post_body)
body = json.loads(body)
return resp, body['flavor_access']
@@ -150,7 +147,6 @@
}
}
post_body = json.dumps(post_body)
- resp, body = self.post('flavors/%s/action' % flavor_id,
- post_body, self.headers)
+ resp, body = self.post('flavors/%s/action' % flavor_id, post_body)
body = json.loads(body)
return resp, body['flavor_access']
diff --git a/tempest/services/compute/json/floating_ips_client.py b/tempest/services/compute/json/floating_ips_client.py
index 2bf5241..2a7e25a 100644
--- a/tempest/services/compute/json/floating_ips_client.py
+++ b/tempest/services/compute/json/floating_ips_client.py
@@ -16,14 +16,15 @@
import json
import urllib
-from tempest.common.rest_client import RestClient
+from tempest.api_schema.compute.v2 import floating_ips as schema
+from tempest.common import rest_client
from tempest import config
from tempest import exceptions
CONF = config.CONF
-class FloatingIPsClientJSON(RestClient):
+class FloatingIPsClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(FloatingIPsClientJSON, self).__init__(auth_provider)
self.service = CONF.compute.catalog_type
@@ -36,6 +37,7 @@
resp, body = self.get(url)
body = json.loads(body)
+ self.validate_response(schema.list_floating_ips, resp, body)
return resp, body['floating_ips']
def get_floating_ip_details(self, floating_ip_id):
@@ -52,7 +54,7 @@
url = 'os-floating-ips'
post_body = {'pool': pool_name}
post_body = json.dumps(post_body)
- resp, body = self.post(url, post_body, self.headers)
+ resp, body = self.post(url, post_body)
body = json.loads(body)
return resp, body['floating_ip']
@@ -72,7 +74,7 @@
}
post_body = json.dumps(post_body)
- resp, body = self.post(url, post_body, self.headers)
+ resp, body = self.post(url, post_body)
return resp, body
def disassociate_floating_ip_from_server(self, floating_ip, server_id):
@@ -85,7 +87,7 @@
}
post_body = json.dumps(post_body)
- resp, body = self.post(url, post_body, self.headers)
+ resp, body = self.post(url, post_body)
return resp, body
def is_resource_deleted(self, id):
diff --git a/tempest/services/compute/json/hosts_client.py b/tempest/services/compute/json/hosts_client.py
index aa63927..0130f27 100644
--- a/tempest/services/compute/json/hosts_client.py
+++ b/tempest/services/compute/json/hosts_client.py
@@ -15,13 +15,14 @@
import json
import urllib
-from tempest.common.rest_client import RestClient
+from tempest.api_schema.compute import hosts as schema
+from tempest.common import rest_client
from tempest import config
CONF = config.CONF
-class HostsClientJSON(RestClient):
+class HostsClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(HostsClientJSON, self).__init__(auth_provider)
@@ -36,6 +37,7 @@
resp, body = self.get(url)
body = json.loads(body)
+ self.validate_response(schema.list_hosts, resp, body)
return resp, body['hosts']
def show_host_detail(self, hostname):
@@ -55,8 +57,7 @@
request_body.update(**kwargs)
request_body = json.dumps(request_body)
- resp, body = self.put("os-hosts/%s" % str(hostname), request_body,
- self.headers)
+ resp, body = self.put("os-hosts/%s" % str(hostname), request_body)
body = json.loads(body)
return resp, body
diff --git a/tempest/services/compute/json/hypervisor_client.py b/tempest/services/compute/json/hypervisor_client.py
index 74844dc..c6b13b0 100644
--- a/tempest/services/compute/json/hypervisor_client.py
+++ b/tempest/services/compute/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 HypervisorClientJSON(RestClient):
+class HypervisorClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(HypervisorClientJSON, self).__init__(auth_provider)
diff --git a/tempest/services/compute/json/images_client.py b/tempest/services/compute/json/images_client.py
index 7324d84..5a79a29 100644
--- a/tempest/services/compute/json/images_client.py
+++ b/tempest/services/compute/json/images_client.py
@@ -16,7 +16,7 @@
import json
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
@@ -24,7 +24,7 @@
CONF = config.CONF
-class ImagesClientJSON(RestClient):
+class ImagesClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(ImagesClientJSON, self).__init__(auth_provider)
@@ -46,7 +46,7 @@
post_body = json.dumps(post_body)
resp, body = self.post('servers/%s/action' % str(server_id),
- post_body, self.headers)
+ post_body)
return resp, body
def list_images(self, params=None):
@@ -93,16 +93,14 @@
def set_image_metadata(self, image_id, meta):
"""Sets the metadata for an image."""
post_body = json.dumps({'metadata': meta})
- resp, body = self.put('images/%s/metadata' % str(image_id),
- post_body, self.headers)
+ resp, body = self.put('images/%s/metadata' % str(image_id), post_body)
body = json.loads(body)
return resp, body['metadata']
def update_image_metadata(self, image_id, meta):
"""Updates the metadata for an image."""
post_body = json.dumps({'metadata': meta})
- resp, body = self.post('images/%s/metadata' % str(image_id),
- post_body, self.headers)
+ resp, body = self.post('images/%s/metadata' % str(image_id), post_body)
body = json.loads(body)
return resp, body['metadata']
@@ -116,7 +114,7 @@
"""Sets the value for a specific image metadata key."""
post_body = json.dumps({'meta': meta})
resp, body = self.put('images/%s/metadata/%s' % (str(image_id), key),
- post_body, self.headers)
+ post_body)
body = json.loads(body)
return resp, body['meta']
diff --git a/tempest/services/compute/json/instance_usage_audit_log_client.py b/tempest/services/compute/json/instance_usage_audit_log_client.py
index 27930f2..1f6e988 100644
--- a/tempest/services/compute/json/instance_usage_audit_log_client.py
+++ b/tempest/services/compute/json/instance_usage_audit_log_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 InstanceUsagesAuditLogClientJSON(RestClient):
+class InstanceUsagesAuditLogClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(InstanceUsagesAuditLogClientJSON, self).__init__(
diff --git a/tempest/services/compute/json/interfaces_client.py b/tempest/services/compute/json/interfaces_client.py
index d9a2030..9928b94 100644
--- a/tempest/services/compute/json/interfaces_client.py
+++ b/tempest/services/compute/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 InterfacesClientJSON(RestClient):
+class InterfacesClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(InterfacesClientJSON, self).__init__(auth_provider)
@@ -46,7 +46,6 @@
post_body['interfaceAttachment']['fixed_ips'] = [fip]
post_body = json.dumps(post_body)
resp, body = self.post('servers/%s/os-interface' % server,
- headers=self.headers,
body=post_body)
body = json.loads(body)
return resp, body['interfaceAttachment']
@@ -81,3 +80,25 @@
raise exceptions.TimeoutException(message)
return resp, body
+
+ def add_fixed_ip(self, server_id, network_id):
+ """Add a fixed IP to input server instance."""
+ post_body = json.dumps({
+ 'addFixedIp': {
+ 'networkId': network_id
+ }
+ })
+ resp, body = self.post('servers/%s/action' % str(server_id),
+ post_body)
+ return resp, body
+
+ def remove_fixed_ip(self, server_id, ip_address):
+ """Remove input fixed IP from input server instance."""
+ post_body = json.dumps({
+ 'removeFixedIp': {
+ 'address': ip_address
+ }
+ })
+ resp, body = self.post('servers/%s/action' % str(server_id),
+ post_body)
+ return resp, body
diff --git a/tempest/services/compute/json/keypairs_client.py b/tempest/services/compute/json/keypairs_client.py
index 3e2d4a7..28f3c31 100644
--- a/tempest/services/compute/json/keypairs_client.py
+++ b/tempest/services/compute/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 KeyPairsClientJSON(RestClient):
+class KeyPairsClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(KeyPairsClientJSON, self).__init__(auth_provider)
@@ -47,8 +47,7 @@
if pub_key:
post_body['keypair']['public_key'] = pub_key
post_body = json.dumps(post_body)
- resp, body = self.post("os-keypairs",
- headers=self.headers, body=post_body)
+ resp, body = self.post("os-keypairs", body=post_body)
body = json.loads(body)
return resp, body['keypair']
diff --git a/tempest/services/compute/json/limits_client.py b/tempest/services/compute/json/limits_client.py
index 765ba79..e503bef 100644
--- a/tempest/services/compute/json/limits_client.py
+++ b/tempest/services/compute/json/limits_client.py
@@ -15,13 +15,14 @@
import json
-from tempest.common.rest_client import RestClient
+from tempest.api_schema.compute.v2 import limits as schema
+from tempest.common import rest_client
from tempest import config
CONF = config.CONF
-class LimitsClientJSON(RestClient):
+class LimitsClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(LimitsClientJSON, self).__init__(auth_provider)
@@ -30,11 +31,13 @@
def get_absolute_limits(self):
resp, body = self.get("limits")
body = json.loads(body)
+ self.validate_response(schema.get_limit, resp, body)
return resp, body['limits']['absolute']
def get_specific_absolute_limit(self, absolute_limit):
resp, body = self.get("limits")
body = json.loads(body)
+ self.validate_response(schema.get_limit, resp, body)
if absolute_limit not in body['limits']['absolute']:
return None
else:
diff --git a/tempest/services/compute/json/quotas_client.py b/tempest/services/compute/json/quotas_client.py
index 2007d4e..2fae927 100644
--- a/tempest/services/compute/json/quotas_client.py
+++ b/tempest/services/compute/json/quotas_client.py
@@ -15,22 +15,24 @@
import json
-from tempest.common.rest_client import RestClient
+from tempest.common import rest_client
from tempest import config
CONF = config.CONF
-class QuotasClientJSON(RestClient):
+class QuotasClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(QuotasClientJSON, self).__init__(auth_provider)
self.service = CONF.compute.catalog_type
- def get_quota_set(self, tenant_id):
+ def get_quota_set(self, tenant_id, user_id=None):
"""List the quota set for a tenant."""
url = 'os-quota-sets/%s' % str(tenant_id)
+ if user_id:
+ url += '?user_id=%s' % str(user_id)
resp, body = self.get(url)
body = json.loads(body)
return resp, body['quota_set']
@@ -96,8 +98,11 @@
post_body['security_groups'] = security_groups
post_body = json.dumps({'quota_set': post_body})
- resp, body = self.put('os-quota-sets/%s' % str(tenant_id), post_body,
- self.headers)
+ resp, body = self.put('os-quota-sets/%s' % str(tenant_id), post_body)
body = json.loads(body)
return resp, body['quota_set']
+
+ def delete_quota_set(self, tenant_id):
+ """Delete the tenant's quota set."""
+ return self.delete('os-quota-sets/%s' % str(tenant_id))
diff --git a/tempest/services/compute/json/security_groups_client.py b/tempest/services/compute/json/security_groups_client.py
index edaf4a3..899d4ef 100644
--- a/tempest/services/compute/json/security_groups_client.py
+++ b/tempest/services/compute/json/security_groups_client.py
@@ -16,14 +16,14 @@
import json
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 SecurityGroupsClientJSON(RestClient):
+class SecurityGroupsClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(SecurityGroupsClientJSON, self).__init__(auth_provider)
@@ -58,7 +58,7 @@
'description': description,
}
post_body = json.dumps({'security_group': post_body})
- resp, body = self.post('os-security-groups', post_body, self.headers)
+ resp, body = self.post('os-security-groups', post_body)
body = json.loads(body)
return resp, body['security_group']
@@ -77,7 +77,7 @@
post_body['description'] = description
post_body = json.dumps({'security_group': post_body})
resp, body = self.put('os-security-groups/%s' % str(security_group_id),
- post_body, self.headers)
+ post_body)
body = json.loads(body)
return resp, body['security_group']
@@ -107,7 +107,7 @@
}
post_body = json.dumps({'security_group_rule': post_body})
url = 'os-security-group-rules'
- resp, body = self.post(url, post_body, self.headers)
+ resp, body = self.post(url, post_body)
body = json.loads(body)
return resp, body['security_group_rule']
@@ -123,3 +123,10 @@
if sg['id'] == security_group_id:
return resp, sg['rules']
raise exceptions.NotFound('No such Security Group')
+
+ def is_resource_deleted(self, id):
+ try:
+ self.get_security_group(id)
+ except exceptions.NotFound:
+ return True
+ return False
diff --git a/tempest/services/compute/json/servers_client.py b/tempest/services/compute/json/servers_client.py
index 371a59c..4eba2b4 100644
--- a/tempest/services/compute/json/servers_client.py
+++ b/tempest/services/compute/json/servers_client.py
@@ -18,7 +18,8 @@
import time
import urllib
-from tempest.common.rest_client import RestClient
+from tempest.api_schema.compute.v2 import servers as schema
+from tempest.common import rest_client
from tempest.common import waiters
from tempest import config
from tempest import exceptions
@@ -26,7 +27,7 @@
CONF = config.CONF
-class ServersClientJSON(RestClient):
+class ServersClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(ServersClientJSON, self).__init__(auth_provider)
@@ -78,13 +79,14 @@
if value is not None:
post_body[post_param] = value
post_body = json.dumps({'server': post_body})
- resp, body = self.post('servers', post_body, self.headers)
+ resp, body = self.post('servers', post_body)
body = json.loads(body)
# NOTE(maurosr): this deals with the case of multiple server create
# with return reservation id set True
if 'reservation_id' in body:
return resp, body
+ self.validate_response(schema.create_server, resp, body)
return resp, body['server']
def update_server(self, server_id, name=None, meta=None, accessIPv4=None,
@@ -116,8 +118,7 @@
post_body['OS-DCF:diskConfig'] = disk_config
post_body = json.dumps({'server': post_body})
- resp, body = self.put("servers/%s" % str(server_id),
- post_body, self.headers)
+ resp, body = self.put("servers/%s" % str(server_id), post_body)
body = json.loads(body)
return resp, body['server']
@@ -194,7 +195,7 @@
def action(self, server_id, action_name, response_key, **kwargs):
post_body = json.dumps({action_name: kwargs})
resp, body = self.post('servers/%s/action' % str(server_id),
- post_body, self.headers)
+ post_body)
if response_key is not None:
body = json.loads(body)[response_key]
return resp, body
@@ -269,14 +270,14 @@
else:
post_body = json.dumps({'metadata': meta})
resp, body = self.put('servers/%s/metadata' % str(server_id),
- post_body, self.headers)
+ post_body)
body = json.loads(body)
return resp, body['metadata']
def update_server_metadata(self, server_id, meta):
post_body = json.dumps({'metadata': meta})
resp, body = self.post('servers/%s/metadata' % str(server_id),
- post_body, self.headers)
+ post_body)
body = json.loads(body)
return resp, body['metadata']
@@ -288,7 +289,7 @@
def set_server_metadata_item(self, server_id, key, meta):
post_body = json.dumps({'meta': meta})
resp, body = self.put('servers/%s/metadata/%s' % (str(server_id), key),
- post_body, self.headers)
+ post_body)
body = json.loads(body)
return resp, body['meta']
@@ -312,7 +313,7 @@
}
})
resp, body = self.post('servers/%s/os-volume_attachments' % server_id,
- post_body, self.headers)
+ post_body)
return resp, body
def detach_volume(self, server_id, volume_id):
@@ -340,8 +341,7 @@
req_body = json.dumps({'os-migrateLive': migrate_params})
- resp, body = self.post("servers/%s/action" % str(server_id),
- req_body, self.headers)
+ resp, body = self.post("servers/%s/action" % str(server_id), req_body)
return resp, body
def migrate_server(self, server_id, **kwargs):
@@ -384,6 +384,10 @@
"""Un-shelves the provided server."""
return self.action(server_id, 'unshelve', None, **kwargs)
+ def shelve_offload_server(self, server_id, **kwargs):
+ """Shelve-offload the provided server."""
+ return self.action(server_id, 'shelveOffload', None, **kwargs)
+
def get_console_output(self, server_id, length):
return self.action(server_id, 'os-getConsoleOutput', 'output',
length=length)
@@ -430,3 +434,16 @@
def restore_soft_deleted_server(self, server_id, **kwargs):
"""Restore a soft-deleted server."""
return self.action(server_id, 'restore', None, **kwargs)
+
+ def reset_network(self, server_id, **kwargs):
+ """Resets the Network of a server"""
+ return self.action(server_id, 'resetNetwork', None, **kwargs)
+
+ def inject_network_info(self, server_id, **kwargs):
+ """Inject the Network Info into server"""
+ return self.action(server_id, 'injectNetworkInfo', None, **kwargs)
+
+ def get_vnc_console(self, server_id, console_type):
+ """Get URL of VNC console."""
+ return self.action(server_id, "os-getVNCConsole",
+ "console", type=console_type)
diff --git a/tempest/services/compute/json/services_client.py b/tempest/services/compute/json/services_client.py
index 4abee47..0f7d4cb 100644
--- a/tempest/services/compute/json/services_client.py
+++ b/tempest/services/compute/json/services_client.py
@@ -17,13 +17,14 @@
import json
import urllib
-from tempest.common.rest_client import RestClient
+from tempest.api_schema.compute import services as schema
+from tempest.common import rest_client
from tempest import config
CONF = config.CONF
-class ServicesClientJSON(RestClient):
+class ServicesClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(ServicesClientJSON, self).__init__(auth_provider)
@@ -36,6 +37,7 @@
resp, body = self.get(url)
body = json.loads(body)
+ self.validate_response(schema.list_services, resp, body)
return resp, body['services']
def enable_service(self, host_name, binary):
@@ -45,7 +47,7 @@
binary: Service binary
"""
post_body = json.dumps({'binary': binary, 'host': host_name})
- resp, body = self.put('os-services/enable', post_body, self.headers)
+ resp, body = self.put('os-services/enable', post_body)
body = json.loads(body)
return resp, body['service']
@@ -56,6 +58,6 @@
binary: Service binary
"""
post_body = json.dumps({'binary': binary, 'host': host_name})
- resp, body = self.put('os-services/disable', post_body, self.headers)
+ resp, body = self.put('os-services/disable', post_body)
body = json.loads(body)
return resp, body['service']
diff --git a/tempest/services/compute/json/tenant_usages_client.py b/tempest/services/compute/json/tenant_usages_client.py
index b14fa9b..f3a67dd 100644
--- a/tempest/services/compute/json/tenant_usages_client.py
+++ b/tempest/services/compute/json/tenant_usages_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 TenantUsagesClientJSON(RestClient):
+class TenantUsagesClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(TenantUsagesClientJSON, self).__init__(auth_provider)
diff --git a/tempest/services/compute/json/volumes_extensions_client.py b/tempest/services/compute/json/volumes_extensions_client.py
index ba7b5df..451dbac 100644
--- a/tempest/services/compute/json/volumes_extensions_client.py
+++ b/tempest/services/compute/json/volumes_extensions_client.py
@@ -17,14 +17,15 @@
import time
import urllib
-from tempest.common.rest_client import RestClient
+from tempest.api_schema.compute.v2 import volumes as schema
+from tempest.common import rest_client
from tempest import config
from tempest import exceptions
CONF = config.CONF
-class VolumesExtensionsClientJSON(RestClient):
+class VolumesExtensionsClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(VolumesExtensionsClientJSON, self).__init__(
@@ -58,6 +59,7 @@
url = "os-volumes/%s" % str(volume_id)
resp, body = self.get(url)
body = json.loads(body)
+ self.validate_response(schema.get_volume, resp, body)
return resp, body['volume']
def create_volume(self, size, **kwargs):
@@ -75,7 +77,7 @@
}
post_body = json.dumps({'volume': post_body})
- resp, body = self.post('os-volumes', post_body, self.headers)
+ resp, body = self.post('os-volumes', post_body)
body = json.loads(body)
return resp, body['volume']
diff --git a/tempest/services/compute/v3/json/agents_client.py b/tempest/services/compute/v3/json/agents_client.py
new file mode 100644
index 0000000..6893af2
--- /dev/null
+++ b/tempest/services/compute/v3/json/agents_client.py
@@ -0,0 +1,52 @@
+# 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.
+
+import json
+import urllib
+
+from tempest.common import rest_client
+from tempest import config
+
+CONF = config.CONF
+
+
+class AgentsV3ClientJSON(rest_client.RestClient):
+
+ def __init__(self, auth_provider):
+ super(AgentsV3ClientJSON, self).__init__(auth_provider)
+ self.service = CONF.compute.catalog_v3_type
+
+ def list_agents(self, params=None):
+ """List all agent builds."""
+ url = 'os-agents'
+ if params:
+ url += '?%s' % urllib.urlencode(params)
+ resp, body = self.get(url)
+ return resp, self._parse_resp(body)
+
+ def create_agent(self, **kwargs):
+ """Create an agent build."""
+ post_body = json.dumps({'agent': kwargs})
+ resp, body = self.post('os-agents', post_body)
+ return resp, self._parse_resp(body)
+
+ def delete_agent(self, agent_id):
+ """Delete an existing agent build."""
+ return self.delete('os-agents/%s' % str(agent_id))
+
+ def update_agent(self, agent_id, **kwargs):
+ """Update an agent build."""
+ put_body = json.dumps({'agent': kwargs})
+ resp, body = self.put('os-agents/%s' % str(agent_id), put_body)
+ return resp, self._parse_resp(body)
diff --git a/tempest/services/compute/v3/json/aggregates_client.py b/tempest/services/compute/v3/json/aggregates_client.py
index 6bc758c..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)
@@ -43,7 +43,7 @@
def create_aggregate(self, **kwargs):
"""Creates a new aggregate."""
post_body = json.dumps({'aggregate': kwargs})
- resp, body = self.post('os-aggregates', post_body, self.headers)
+ resp, body = self.post('os-aggregates', post_body)
body = json.loads(body)
return resp, body['aggregate']
@@ -55,8 +55,7 @@
'availability_zone': availability_zone
}
put_body = json.dumps({'aggregate': put_body})
- resp, body = self.put('os-aggregates/%s' % str(aggregate_id),
- put_body, self.headers)
+ resp, body = self.put('os-aggregates/%s' % str(aggregate_id), put_body)
body = json.loads(body)
return resp, body['aggregate']
@@ -79,7 +78,7 @@
}
post_body = json.dumps({'add_host': post_body})
resp, body = self.post('os-aggregates/%s/action' % aggregate_id,
- post_body, self.headers)
+ post_body)
body = json.loads(body)
return resp, body['aggregate']
@@ -90,7 +89,7 @@
}
post_body = json.dumps({'remove_host': post_body})
resp, body = self.post('os-aggregates/%s/action' % aggregate_id,
- post_body, self.headers)
+ post_body)
body = json.loads(body)
return resp, body['aggregate']
@@ -101,6 +100,6 @@
}
post_body = json.dumps({'set_metadata': post_body})
resp, body = self.post('os-aggregates/%s/action' % aggregate_id,
- post_body, self.headers)
+ post_body)
body = json.loads(body)
return resp, body['aggregate']
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 0c9f9ac..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)
@@ -36,6 +36,6 @@
def create_certificate(self):
"""create certificates."""
url = "os-certificates"
- resp, body = self.post(url, None, self.headers)
+ resp, body = self.post(url, None)
body = json.loads(body)
return resp, body['certificate']
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 df3d0c1..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)
@@ -69,7 +69,7 @@
if kwargs.get('is_public'):
post_body['flavor-access:is_public'] = kwargs.get('is_public')
post_body = json.dumps({'flavor': post_body})
- resp, body = self.post('flavors', post_body, self.headers)
+ resp, body = self.post('flavors', post_body)
body = json.loads(body)
return resp, body['flavor']
@@ -92,7 +92,7 @@
"""Sets extra Specs to the mentioned flavor."""
post_body = json.dumps({'extra_specs': specs})
resp, body = self.post('flavors/%s/flavor-extra-specs' % flavor_id,
- post_body, self.headers)
+ post_body)
body = json.loads(body)
return resp, body['extra_specs']
@@ -112,8 +112,7 @@
def update_flavor_extra_spec(self, flavor_id, key, **kwargs):
"""Update specified extra Specs of the mentioned flavor and key."""
resp, body = self.put('flavors/%s/flavor-extra-specs/%s' %
- (flavor_id, key),
- json.dumps(kwargs), self.headers)
+ (flavor_id, key), json.dumps(kwargs))
body = json.loads(body)
return resp, body
@@ -124,8 +123,7 @@
def list_flavor_access(self, flavor_id):
"""Gets flavor access information given the flavor id."""
- resp, body = self.get('flavors/%s/flavor-access' % flavor_id,
- self.headers)
+ resp, body = self.get('flavors/%s/flavor-access' % flavor_id)
body = json.loads(body)
return resp, body['flavor_access']
@@ -137,8 +135,7 @@
}
}
post_body = json.dumps(post_body)
- resp, body = self.post('flavors/%s/action' % flavor_id,
- post_body, self.headers)
+ resp, body = self.post('flavors/%s/action' % flavor_id, post_body)
body = json.loads(body)
return resp, body['flavor_access']
@@ -150,7 +147,6 @@
}
}
post_body = json.dumps(post_body)
- resp, body = self.post('flavors/%s/action' % flavor_id,
- post_body, self.headers)
+ resp, body = self.post('flavors/%s/action' % flavor_id, post_body)
body = json.loads(body)
return resp, body['flavor_access']
diff --git a/tempest/services/compute/v3/json/hosts_client.py b/tempest/services/compute/v3/json/hosts_client.py
index e33dd5f..bcb9d36 100644
--- a/tempest/services/compute/v3/json/hosts_client.py
+++ b/tempest/services/compute/v3/json/hosts_client.py
@@ -15,13 +15,14 @@
import json
import urllib
-from tempest.common.rest_client import RestClient
+from tempest.api_schema.compute import hosts as schema
+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)
@@ -36,6 +37,7 @@
resp, body = self.get(url)
body = json.loads(body)
+ self.validate_response(schema.list_hosts, resp, body)
return resp, body['hosts']
def show_host_detail(self, hostname):
@@ -55,8 +57,7 @@
request_body.update(**kwargs)
request_body = json.dumps({'host': request_body})
- resp, body = self.put("os-hosts/%s" % str(hostname), request_body,
- self.headers)
+ resp, body = self.put("os-hosts/%s" % str(hostname), request_body)
body = json.loads(body)
return resp, body
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/instance_usage_audit_log_client.py b/tempest/services/compute/v3/json/instance_usage_audit_log_client.py
deleted file mode 100644
index 3a6ac5f..0000000
--- a/tempest/services/compute/v3/json/instance_usage_audit_log_client.py
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright 2013 IBM Corporation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import json
-
-from tempest.common.rest_client import RestClient
-from tempest import config
-
-CONF = config.CONF
-
-
-class InstanceUsagesAuditLogV3ClientJSON(RestClient):
-
- def __init__(self, auth_provider):
- super(InstanceUsagesAuditLogV3ClientJSON, self).__init__(
- auth_provider)
- self.service = CONF.compute.catalog_v3_type
-
- def list_instance_usage_audit_logs(self, time_before=None):
- if time_before:
- url = 'os-instance-usage-audit-log?before=%s' % time_before
- else:
- url = 'os-instance-usage-audit-log'
- resp, body = self.get(url)
- body = json.loads(body)
- return resp, body["instance_usage_audit_log"]
diff --git a/tempest/services/compute/v3/json/interfaces_client.py b/tempest/services/compute/v3/json/interfaces_client.py
index 053b9af..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)
@@ -45,7 +45,6 @@
post_body['fixed_ips'] = [dict(ip_address=fixed_ip)]
post_body = json.dumps({'interface_attachment': post_body})
resp, body = self.post('servers/%s/os-attach-interfaces' % server,
- headers=self.headers,
body=post_body)
body = json.loads(body)
return resp, body['interface_attachment']
@@ -82,3 +81,25 @@
raise exceptions.TimeoutException(message)
return resp, body
+
+ def add_fixed_ip(self, server_id, network_id):
+ """Add a fixed IP to input server instance."""
+ post_body = json.dumps({
+ 'add_fixed_ip': {
+ 'network_id': network_id
+ }
+ })
+ resp, body = self.post('servers/%s/action' % str(server_id),
+ post_body)
+ return resp, body
+
+ def remove_fixed_ip(self, server_id, ip_address):
+ """Remove input fixed IP from input server instance."""
+ post_body = json.dumps({
+ 'remove_fixed_ip': {
+ 'address': ip_address
+ }
+ })
+ resp, body = self.post('servers/%s/action' % str(server_id),
+ post_body)
+ return resp, body
diff --git a/tempest/services/compute/v3/json/keypairs_client.py b/tempest/services/compute/v3/json/keypairs_client.py
index 05dbe25..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)
@@ -47,8 +47,7 @@
if pub_key:
post_body['keypair']['public_key'] = pub_key
post_body = json.dumps(post_body)
- resp, body = self.post("keypairs",
- headers=self.headers, body=post_body)
+ resp, body = self.post("keypairs", body=post_body)
body = json.loads(body)
return resp, body['keypair']
diff --git a/tempest/services/compute/v3/json/quotas_client.py b/tempest/services/compute/v3/json/quotas_client.py
index 1ec8651..ed92aae 100644
--- a/tempest/services/compute/v3/json/quotas_client.py
+++ b/tempest/services/compute/v3/json/quotas_client.py
@@ -15,22 +15,32 @@
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)
self.service = CONF.compute.catalog_v3_type
- def get_quota_set(self, tenant_id):
+ def get_quota_set(self, tenant_id, user_id=None):
"""List the quota set for a tenant."""
url = 'os-quota-sets/%s' % str(tenant_id)
+ if user_id:
+ url += '?user_id=%s' % str(user_id)
+ resp, body = self.get(url)
+ body = json.loads(body)
+ return resp, body['quota_set']
+
+ def get_quota_set_detail(self, tenant_id):
+ """Get the quota set detail for a tenant."""
+
+ url = 'os-quota-sets/%s/detail' % str(tenant_id)
resp, body = self.get(url)
body = json.loads(body)
return resp, body['quota_set']
@@ -84,8 +94,11 @@
post_body['security_groups'] = security_groups
post_body = json.dumps({'quota_set': post_body})
- resp, body = self.put('os-quota-sets/%s' % str(tenant_id), post_body,
- self.headers)
+ resp, body = self.put('os-quota-sets/%s' % str(tenant_id), post_body)
body = json.loads(body)
return resp, body['quota_set']
+
+ def delete_quota_set(self, tenant_id):
+ """Delete the tenant's quota set."""
+ return self.delete('os-quota-sets/%s' % str(tenant_id))
diff --git a/tempest/services/compute/v3/json/servers_client.py b/tempest/services/compute/v3/json/servers_client.py
index 11538f5..6f492d0 100644
--- a/tempest/services/compute/v3/json/servers_client.py
+++ b/tempest/services/compute/v3/json/servers_client.py
@@ -19,7 +19,8 @@
import time
import urllib
-from tempest.common.rest_client import RestClient
+from tempest.api_schema.compute.v3 import servers as schema
+from tempest.common import rest_client
from tempest.common import waiters
from tempest import config
from tempest import exceptions
@@ -27,7 +28,7 @@
CONF = config.CONF
-class ServersV3ClientJSON(RestClient):
+class ServersV3ClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(ServersV3ClientJSON, self).__init__(auth_provider)
@@ -84,13 +85,14 @@
if value is not None:
post_body[post_param] = value
post_body = json.dumps({'server': post_body})
- resp, body = self.post('servers', post_body, self.headers)
+ resp, body = self.post('servers', post_body)
body = json.loads(body)
# NOTE(maurosr): this deals with the case of multiple server create
# with return reservation id set True
if 'servers_reservation' in body:
return resp, body['servers_reservation']
+ self.validate_response(schema.create_server, resp, body)
return resp, body['server']
def update_server(self, server_id, name=None, meta=None, access_ip_v4=None,
@@ -121,8 +123,7 @@
post_body['os-disk-config:disk_config'] = disk_config
post_body = json.dumps({'server': post_body})
- resp, body = self.put("servers/%s" % str(server_id),
- post_body, self.headers)
+ resp, body = self.put("servers/%s" % str(server_id), post_body)
body = json.loads(body)
return resp, body['server']
@@ -199,7 +200,7 @@
def action(self, server_id, action_name, response_key, **kwargs):
post_body = json.dumps({action_name: kwargs})
resp, body = self.post('servers/%s/action' % str(server_id),
- post_body, self.headers)
+ post_body)
if response_key is not None:
body = json.loads(body)[response_key]
return resp, body
@@ -216,6 +217,21 @@
return self.action(server_id, 'change_password', None,
admin_password=admin_password)
+ def get_password(self, server_id):
+ resp, body = self.get("servers/%s/os-server-password" %
+ str(server_id))
+ body = json.loads(body)
+ return resp, body
+
+ def delete_password(self, server_id):
+ """
+ Removes the encrypted server password from the metadata server
+ Note that this does not actually change the instance server
+ password.
+ """
+ return self.delete("servers/%s/os-server-password" %
+ str(server_id))
+
def reboot(self, server_id, reboot_type):
"""Reboots a server."""
return self.action(server_id, 'reboot', None, type=reboot_type)
@@ -258,7 +274,7 @@
post_body = json.dumps(post_body)
resp, body = self.post('servers/%s/action' % str(server_id),
- post_body, self.headers)
+ post_body)
return resp, body
def list_server_metadata(self, server_id):
@@ -272,14 +288,14 @@
else:
post_body = json.dumps({'metadata': meta})
resp, body = self.put('servers/%s/metadata' % str(server_id),
- post_body, self.headers)
+ post_body)
body = json.loads(body)
return resp, body['metadata']
def update_server_metadata(self, server_id, meta):
post_body = json.dumps({'metadata': meta})
resp, body = self.post('servers/%s/metadata' % str(server_id),
- post_body, self.headers)
+ post_body)
body = json.loads(body)
return resp, body['metadata']
@@ -291,7 +307,7 @@
def set_server_metadata_item(self, server_id, key, meta):
post_body = json.dumps({'metadata': meta})
resp, body = self.put('servers/%s/metadata/%s' % (str(server_id), key),
- post_body, self.headers)
+ post_body)
body = json.loads(body)
return resp, body['metadata']
@@ -327,7 +343,7 @@
req_body = json.dumps({'migrate_live': migrate_params})
resp, body = self.post("servers/%s/action" % str(server_id),
- req_body, self.headers)
+ req_body)
return resp, body
def migrate_server(self, server_id, **kwargs):
@@ -370,6 +386,10 @@
"""Un-shelves the provided server."""
return self.action(server_id, 'unshelve', None, **kwargs)
+ def shelve_offload_server(self, server_id, **kwargs):
+ """Shelve-offload the provided server."""
+ return self.action(server_id, 'shelve_offload', None, **kwargs)
+
def get_console_output(self, server_id, length):
return self.action(server_id, 'get_console_output', 'output',
length=length)
@@ -409,3 +429,23 @@
def restore_soft_deleted_server(self, server_id, **kwargs):
"""Restore a soft-deleted server."""
return self.action(server_id, 'restore', None, **kwargs)
+
+ def get_vnc_console(self, server_id, type):
+ """Get URL of VNC console."""
+ post_body = json.dumps({
+ "get_vnc_console": {
+ "type": type
+ }
+ })
+ resp, body = self.post('servers/%s/action' % str(server_id),
+ post_body)
+ body = json.loads(body)
+ return resp, body['console']
+
+ def reset_network(self, server_id, **kwargs):
+ """Resets the Network of a server"""
+ return self.action(server_id, 'reset_network', None, **kwargs)
+
+ def inject_network_info(self, server_id, **kwargs):
+ """Inject the Network Info into server"""
+ return self.action(server_id, 'inject_network_info', None, **kwargs)
diff --git a/tempest/services/compute/v3/json/services_client.py b/tempest/services/compute/v3/json/services_client.py
index 1082ea9..88c4d16 100644
--- a/tempest/services/compute/v3/json/services_client.py
+++ b/tempest/services/compute/v3/json/services_client.py
@@ -17,13 +17,14 @@
import json
import urllib
-from tempest.common.rest_client import RestClient
+from tempest.api_schema.compute import services as schema
+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)
@@ -36,6 +37,7 @@
resp, body = self.get(url)
body = json.loads(body)
+ self.validate_response(schema.list_services, resp, body)
return resp, body['services']
def enable_service(self, host_name, binary):
@@ -50,7 +52,7 @@
'host': host_name
}
})
- resp, body = self.put('os-services/enable', post_body, self.headers)
+ resp, body = self.put('os-services/enable', post_body)
body = json.loads(body)
return resp, body['service']
@@ -66,6 +68,6 @@
'host': host_name
}
})
- resp, body = self.put('os-services/disable', post_body, self.headers)
+ resp, body = self.put('os-services/disable', post_body)
body = json.loads(body)
return resp, body['service']
diff --git a/tempest/services/compute/v3/json/tenant_usages_client.py b/tempest/services/compute/v3/json/tenant_usages_client.py
deleted file mode 100644
index 6d59e20..0000000
--- a/tempest/services/compute/v3/json/tenant_usages_client.py
+++ /dev/null
@@ -1,47 +0,0 @@
-# Copyright 2013 NEC Corporation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import json
-import urllib
-
-from tempest.common.rest_client import RestClient
-from tempest import config
-
-CONF = config.CONF
-
-
-class TenantUsagesV3ClientJSON(RestClient):
-
- def __init__(self, auth_provider):
- super(TenantUsagesV3ClientJSON, self).__init__(auth_provider)
- self.service = CONF.compute.catalog_v3_type
-
- def list_tenant_usages(self, params=None):
- url = 'os-simple-tenant-usage'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- body = json.loads(body)
- return resp, body['tenant_usages'][0]
-
- def get_tenant_usage(self, tenant_id, params=None):
- url = 'os-simple-tenant-usage/%s' % tenant_id
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- body = json.loads(body)
- return resp, body['tenant_usage']
diff --git a/tempest/services/compute/xml/aggregates_client.py b/tempest/services/compute/xml/aggregates_client.py
index ba08f58..5b250ee 100644
--- a/tempest/services/compute/xml/aggregates_client.py
+++ b/tempest/services/compute/xml/aggregates_client.py
@@ -15,7 +15,7 @@
from lxml import etree
-from tempest.common.rest_client import RestClientXML
+from tempest.common import rest_client
from tempest import config
from tempest import exceptions
from tempest.services.compute.xml.common import Document
@@ -26,7 +26,8 @@
CONF = config.CONF
-class AggregatesClientXML(RestClientXML):
+class AggregatesClientXML(rest_client.RestClient):
+ TYPE = "xml"
def __init__(self, auth_provider):
super(AggregatesClientXML, self).__init__(auth_provider)
@@ -51,14 +52,13 @@
def list_aggregates(self):
"""Get aggregate list."""
- resp, body = self.get("os-aggregates", self.headers)
+ resp, body = self.get("os-aggregates")
aggregates = self._parse_array(etree.fromstring(body))
return resp, aggregates
def get_aggregate(self, aggregate_id):
"""Get details of the given aggregate."""
- resp, body = self.get("os-aggregates/%s" % str(aggregate_id),
- self.headers)
+ resp, body = self.get("os-aggregates/%s" % str(aggregate_id))
aggregate = self._format_aggregate(etree.fromstring(body))
return resp, aggregate
@@ -68,8 +68,7 @@
name=name,
availability_zone=availability_zone)
resp, body = self.post('os-aggregates',
- str(Document(post_body)),
- self.headers)
+ str(Document(post_body)))
aggregate = self._format_aggregate(etree.fromstring(body))
return resp, aggregate
@@ -79,15 +78,13 @@
name=name,
availability_zone=availability_zone)
resp, body = self.put('os-aggregates/%s' % str(aggregate_id),
- str(Document(put_body)),
- self.headers)
+ str(Document(put_body)))
aggregate = self._format_aggregate(etree.fromstring(body))
return resp, aggregate
def delete_aggregate(self, aggregate_id):
"""Deletes the given aggregate."""
- return self.delete("os-aggregates/%s" % str(aggregate_id),
- self.headers)
+ return self.delete("os-aggregates/%s" % str(aggregate_id))
def is_resource_deleted(self, id):
try:
@@ -100,8 +97,7 @@
"""Adds a host to the given aggregate."""
post_body = Element("add_host", host=host)
resp, body = self.post('os-aggregates/%s/action' % aggregate_id,
- str(Document(post_body)),
- self.headers)
+ str(Document(post_body)))
aggregate = self._format_aggregate(etree.fromstring(body))
return resp, aggregate
@@ -109,8 +105,7 @@
"""Removes a host from the given aggregate."""
post_body = Element("remove_host", host=host)
resp, body = self.post('os-aggregates/%s/action' % aggregate_id,
- str(Document(post_body)),
- self.headers)
+ str(Document(post_body)))
aggregate = self._format_aggregate(etree.fromstring(body))
return resp, aggregate
@@ -124,7 +119,6 @@
meta.append(Text(v))
metadata.append(meta)
resp, body = self.post('os-aggregates/%s/action' % aggregate_id,
- str(Document(post_body)),
- self.headers)
+ str(Document(post_body)))
aggregate = self._format_aggregate(etree.fromstring(body))
return resp, aggregate
diff --git a/tempest/services/compute/xml/availability_zone_client.py b/tempest/services/compute/xml/availability_zone_client.py
index 38280b5..4d71186 100644
--- a/tempest/services/compute/xml/availability_zone_client.py
+++ b/tempest/services/compute/xml/availability_zone_client.py
@@ -15,14 +15,15 @@
from lxml import etree
-from tempest.common.rest_client import RestClientXML
+from tempest.common import rest_client
from tempest import config
from tempest.services.compute.xml.common import xml_to_json
CONF = config.CONF
-class AvailabilityZoneClientXML(RestClientXML):
+class AvailabilityZoneClientXML(rest_client.RestClient):
+ TYPE = "xml"
def __init__(self, auth_provider):
super(AvailabilityZoneClientXML, self).__init__(
@@ -33,11 +34,11 @@
return [xml_to_json(x) for x in node]
def get_availability_zone_list(self):
- resp, body = self.get('os-availability-zone', self.headers)
+ resp, body = self.get('os-availability-zone')
availability_zone = self._parse_array(etree.fromstring(body))
return resp, availability_zone
def get_availability_zone_list_detail(self):
- resp, body = self.get('os-availability-zone/detail', self.headers)
+ resp, body = self.get('os-availability-zone/detail')
availability_zone = self._parse_array(etree.fromstring(body))
return resp, availability_zone
diff --git a/tempest/services/compute/xml/certificates_client.py b/tempest/services/compute/xml/certificates_client.py
index aad20a4..24ffca8 100644
--- a/tempest/services/compute/xml/certificates_client.py
+++ b/tempest/services/compute/xml/certificates_client.py
@@ -14,13 +14,14 @@
# under the License.
-from tempest.common.rest_client import RestClientXML
+from tempest.common import rest_client
from tempest import config
CONF = config.CONF
-class CertificatesClientXML(RestClientXML):
+class CertificatesClientXML(rest_client.RestClient):
+ TYPE = "xml"
def __init__(self, auth_provider):
super(CertificatesClientXML, self).__init__(auth_provider)
@@ -28,13 +29,13 @@
def get_certificate(self, id):
url = "os-certificates/%s" % (id)
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
body = self._parse_resp(body)
return resp, body
def create_certificate(self):
"""create certificates."""
url = "os-certificates"
- resp, body = self.post(url, None, self.headers)
+ resp, body = self.post(url, None)
body = self._parse_resp(body)
return resp, body
diff --git a/tempest/services/compute/xml/common.py b/tempest/services/compute/xml/common.py
index 4def19f..b1bf789 100644
--- a/tempest/services/compute/xml/common.py
+++ b/tempest/services/compute/xml/common.py
@@ -18,6 +18,12 @@
XMLNS_11 = "http://docs.openstack.org/compute/api/v1.1"
XMLNS_V3 = "http://docs.openstack.org/compute/api/v1.1"
+NEUTRON_NAMESPACES = {
+ 'binding': "http://docs.openstack.org/ext/binding/api/v1.0",
+ 'router': "http://docs.openstack.org/ext/neutron/router/api/v1.0",
+ 'provider': 'http://docs.openstack.org/ext/provider/api/v1.0',
+}
+
# NOTE(danms): This is just a silly implementation to help make generating
# XML faster for prototyping. Could be replaced with proper etree gorp
@@ -137,6 +143,9 @@
tag = child.tag
if tag.startswith("{"):
ns, tag = tag.split("}", 1)
+ for key, uri in NEUTRON_NAMESPACES.iteritems():
+ if uri == ns[1:]:
+ tag = key + ":" + tag
if plurals is not None and tag in plurals:
json[tag] = parse_array(child, plurals)
else:
diff --git a/tempest/services/compute/xml/extensions_client.py b/tempest/services/compute/xml/extensions_client.py
index 9753ca8..3e8254c 100644
--- a/tempest/services/compute/xml/extensions_client.py
+++ b/tempest/services/compute/xml/extensions_client.py
@@ -15,14 +15,15 @@
from lxml import etree
-from tempest.common.rest_client import RestClientXML
+from tempest.common import rest_client
from tempest import config
from tempest.services.compute.xml.common import xml_to_json
CONF = config.CONF
-class ExtensionsClientXML(RestClientXML):
+class ExtensionsClientXML(rest_client.RestClient):
+ TYPE = "xml"
def __init__(self, auth_provider):
super(ExtensionsClientXML, self).__init__(auth_provider)
@@ -36,7 +37,7 @@
def list_extensions(self):
url = 'extensions'
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
body = self._parse_array(etree.fromstring(body))
return resp, body
@@ -46,6 +47,6 @@
return any([e for e in exts if e['name'] == extension])
def get_extension(self, extension_alias):
- resp, body = self.get('extensions/%s' % extension_alias, self.headers)
+ resp, body = self.get('extensions/%s' % extension_alias)
body = xml_to_json(etree.fromstring(body))
return resp, body
diff --git a/tempest/services/compute/xml/fixed_ips_client.py b/tempest/services/compute/xml/fixed_ips_client.py
index 599e168..0475530 100644
--- a/tempest/services/compute/xml/fixed_ips_client.py
+++ b/tempest/services/compute/xml/fixed_ips_client.py
@@ -14,7 +14,7 @@
# under the License.
-from tempest.common.rest_client import RestClientXML
+from tempest.common import rest_client
from tempest import config
from tempest.services.compute.xml.common import Document
from tempest.services.compute.xml.common import Element
@@ -23,7 +23,8 @@
CONF = config.CONF
-class FixedIPsClientXML(RestClientXML):
+class FixedIPsClientXML(rest_client.RestClient):
+ TYPE = "xml"
def __init__(self, auth_provider):
super(FixedIPsClientXML, self).__init__(auth_provider)
@@ -31,7 +32,7 @@
def get_fixed_ip_details(self, fixed_ip):
url = "os-fixed-ips/%s" % (fixed_ip)
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
body = self._parse_resp(body)
return resp, body
@@ -44,5 +45,5 @@
key, value = body.popitem()
xml_body = Element(key)
xml_body.append(Text(value))
- resp, body = self.post(url, str(Document(xml_body)), self.headers)
+ resp, body = self.post(url, str(Document(xml_body)))
return resp, body
diff --git a/tempest/services/compute/xml/flavors_client.py b/tempest/services/compute/xml/flavors_client.py
index fb16d20..68a27c9 100644
--- a/tempest/services/compute/xml/flavors_client.py
+++ b/tempest/services/compute/xml/flavors_client.py
@@ -17,7 +17,7 @@
from lxml import etree
-from tempest.common.rest_client import RestClientXML
+from tempest.common import rest_client
from tempest import config
from tempest.services.compute.xml.common import Document
from tempest.services.compute.xml.common import Element
@@ -33,7 +33,8 @@
"http://docs.openstack.org/compute/ext/flavor_access/api/v2"
-class FlavorsClientXML(RestClientXML):
+class FlavorsClientXML(rest_client.RestClient):
+ TYPE = "xml"
def __init__(self, auth_provider):
super(FlavorsClientXML, self).__init__(auth_provider)
@@ -81,7 +82,7 @@
if params:
url += "?%s" % urllib.urlencode(params)
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
flavors = self._parse_array(etree.fromstring(body))
return resp, flavors
@@ -94,7 +95,7 @@
return self._list_flavors(url, params)
def get_flavor_details(self, flavor_id):
- resp, body = self.get("flavors/%s" % str(flavor_id), self.headers)
+ resp, body = self.get("flavors/%s" % str(flavor_id))
body = xml_to_json(etree.fromstring(body))
flavor = self._format_flavor(body)
return resp, flavor
@@ -120,14 +121,14 @@
kwargs.get('is_public'))
flavor.add_attr('xmlns:OS-FLV-EXT-DATA', XMLNS_OS_FLV_EXT_DATA)
flavor.add_attr('xmlns:os-flavor-access', XMLNS_OS_FLV_ACCESS)
- resp, body = self.post('flavors', str(Document(flavor)), self.headers)
+ resp, body = self.post('flavors', str(Document(flavor)))
body = xml_to_json(etree.fromstring(body))
flavor = self._format_flavor(body)
return resp, flavor
def delete_flavor(self, flavor_id):
"""Deletes the given flavor."""
- return self.delete("flavors/%s" % str(flavor_id), self.headers)
+ return self.delete("flavors/%s" % str(flavor_id))
def is_resource_deleted(self, id):
# Did not use get_flavor_details(id) for verification as it gives
@@ -145,21 +146,20 @@
for key in specs.keys():
extra_specs.add_attr(key, specs[key])
resp, body = self.post('flavors/%s/os-extra_specs' % flavor_id,
- str(Document(extra_specs)), self.headers)
+ str(Document(extra_specs)))
body = xml_to_json(etree.fromstring(body))
return resp, body
def get_flavor_extra_spec(self, flavor_id):
"""Gets extra Specs of the mentioned flavor."""
- resp, body = self.get('flavors/%s/os-extra_specs' % flavor_id,
- self.headers)
+ resp, body = self.get('flavors/%s/os-extra_specs' % flavor_id)
body = xml_to_json(etree.fromstring(body))
return resp, body
def get_flavor_extra_spec_with_key(self, flavor_id, key):
"""Gets extra Specs key-value of the mentioned flavor and key."""
resp, xml_body = self.get('flavors/%s/os-extra_specs/%s' %
- (str(flavor_id), key), self.headers)
+ (str(flavor_id), key))
body = {}
element = etree.fromstring(xml_body)
key = element.get('key')
@@ -176,8 +176,7 @@
element.append(value)
resp, body = self.put('flavors/%s/os-extra_specs/%s' %
- (flavor_id, key),
- str(doc), self.headers)
+ (flavor_id, key), str(doc))
body = xml_to_json(etree.fromstring(body))
return resp, {key: body}
@@ -191,8 +190,7 @@
def list_flavor_access(self, flavor_id):
"""Gets flavor access information given the flavor id."""
- resp, body = self.get('flavors/%s/os-flavor-access' % str(flavor_id),
- self.headers)
+ resp, body = self.get('flavors/%s/os-flavor-access' % str(flavor_id))
body = self._parse_array(etree.fromstring(body))
return resp, body
@@ -202,8 +200,7 @@
server = Element("addTenantAccess")
doc.append(server)
server.add_attr("tenant", tenant_id)
- resp, body = self.post('flavors/%s/action' % str(flavor_id),
- str(doc), self.headers)
+ resp, body = self.post('flavors/%s/action' % str(flavor_id), str(doc))
body = self._parse_array_access(etree.fromstring(body))
return resp, body
@@ -213,7 +210,6 @@
server = Element("removeTenantAccess")
doc.append(server)
server.add_attr("tenant", tenant_id)
- resp, body = self.post('flavors/%s/action' % str(flavor_id),
- str(doc), self.headers)
+ resp, body = self.post('flavors/%s/action' % str(flavor_id), str(doc))
body = self._parse_array_access(etree.fromstring(body))
return resp, body
diff --git a/tempest/services/compute/xml/floating_ips_client.py b/tempest/services/compute/xml/floating_ips_client.py
index 0119d8a..be54753 100644
--- a/tempest/services/compute/xml/floating_ips_client.py
+++ b/tempest/services/compute/xml/floating_ips_client.py
@@ -16,7 +16,7 @@
from lxml import etree
import urllib
-from tempest.common.rest_client import RestClientXML
+from tempest.common import rest_client
from tempest import config
from tempest import exceptions
from tempest.services.compute.xml.common import Document
@@ -27,7 +27,9 @@
CONF = config.CONF
-class FloatingIPsClientXML(RestClientXML):
+class FloatingIPsClientXML(rest_client.RestClient):
+ TYPE = "xml"
+
def __init__(self, auth_provider):
super(FloatingIPsClientXML, self).__init__(auth_provider)
self.service = CONF.compute.catalog_type
@@ -48,14 +50,14 @@
if params:
url += '?%s' % urllib.urlencode(params)
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
body = self._parse_array(etree.fromstring(body))
return resp, body
def get_floating_ip_details(self, floating_ip_id):
"""Get the details of a floating IP."""
url = "os-floating-ips/%s" % str(floating_ip_id)
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
body = self._parse_floating_ip(etree.fromstring(body))
if resp.status == 404:
raise exceptions.NotFound(body)
@@ -69,16 +71,16 @@
pool = Element("pool")
pool.append(Text(pool_name))
doc.append(pool)
- resp, body = self.post(url, str(doc), self.headers)
+ resp, body = self.post(url, str(doc))
else:
- resp, body = self.post(url, None, self.headers)
+ resp, body = self.post(url, None)
body = self._parse_floating_ip(etree.fromstring(body))
return resp, body
def delete_floating_ip(self, floating_ip_id):
"""Deletes the provided floating IP from the project."""
url = "os-floating-ips/%s" % str(floating_ip_id)
- resp, body = self.delete(url, self.headers)
+ resp, body = self.delete(url)
return resp, body
def associate_floating_ip_to_server(self, floating_ip, server_id):
@@ -88,7 +90,7 @@
server = Element("addFloatingIp")
doc.append(server)
server.add_attr("address", floating_ip)
- resp, body = self.post(url, str(doc), self.headers)
+ resp, body = self.post(url, str(doc))
return resp, body
def disassociate_floating_ip_from_server(self, floating_ip, server_id):
@@ -98,7 +100,7 @@
server = Element("removeFloatingIp")
doc.append(server)
server.add_attr("address", floating_ip)
- resp, body = self.post(url, str(doc), self.headers)
+ resp, body = self.post(url, str(doc))
return resp, body
def is_resource_deleted(self, id):
@@ -114,6 +116,6 @@
if params:
url += '?%s' % urllib.urlencode(params)
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
body = self._parse_array(etree.fromstring(body))
return resp, body
diff --git a/tempest/services/compute/xml/hosts_client.py b/tempest/services/compute/xml/hosts_client.py
index daa83c9..b74cd04 100644
--- a/tempest/services/compute/xml/hosts_client.py
+++ b/tempest/services/compute/xml/hosts_client.py
@@ -15,7 +15,7 @@
import urllib
from lxml import etree
-from tempest.common.rest_client import RestClientXML
+from tempest.common import rest_client
from tempest import config
from tempest.services.compute.xml.common import Document
from tempest.services.compute.xml.common import Element
@@ -24,7 +24,8 @@
CONF = config.CONF
-class HostsClientXML(RestClientXML):
+class HostsClientXML(rest_client.RestClient):
+ TYPE = "xml"
def __init__(self, auth_provider):
super(HostsClientXML, self).__init__(auth_provider)
@@ -37,7 +38,7 @@
if params:
url += '?%s' % urllib.urlencode(params)
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
node = etree.fromstring(body)
body = [xml_to_json(x) for x in node.getchildren()]
return resp, body
@@ -45,7 +46,7 @@
def show_host_detail(self, hostname):
"""Show detail information for the host."""
- resp, body = self.get("os-hosts/%s" % str(hostname), self.headers)
+ resp, body = self.get("os-hosts/%s" % str(hostname))
node = etree.fromstring(body)
body = [xml_to_json(node)]
return resp, body
@@ -58,8 +59,7 @@
for k, v in kwargs.iteritems():
request_body.append(Element(k, v))
resp, body = self.put("os-hosts/%s" % str(hostname),
- str(Document(request_body)),
- self.headers)
+ str(Document(request_body)))
node = etree.fromstring(body)
body = [xml_to_json(x) for x in node.getchildren()]
return resp, body
@@ -67,8 +67,7 @@
def startup_host(self, hostname):
"""Startup a host."""
- resp, body = self.get("os-hosts/%s/startup" % str(hostname),
- self.headers)
+ resp, body = self.get("os-hosts/%s/startup" % str(hostname))
node = etree.fromstring(body)
body = [xml_to_json(x) for x in node.getchildren()]
return resp, body
@@ -76,8 +75,7 @@
def shutdown_host(self, hostname):
"""Shutdown a host."""
- resp, body = self.get("os-hosts/%s/shutdown" % str(hostname),
- self.headers)
+ resp, body = self.get("os-hosts/%s/shutdown" % str(hostname))
node = etree.fromstring(body)
body = [xml_to_json(x) for x in node.getchildren()]
return resp, body
@@ -85,8 +83,7 @@
def reboot_host(self, hostname):
"""Reboot a host."""
- resp, body = self.get("os-hosts/%s/reboot" % str(hostname),
- self.headers)
+ resp, body = self.get("os-hosts/%s/reboot" % str(hostname))
node = etree.fromstring(body)
body = [xml_to_json(x) for x in node.getchildren()]
return resp, body
diff --git a/tempest/services/compute/xml/hypervisor_client.py b/tempest/services/compute/xml/hypervisor_client.py
index 5abaad8..ecd7541 100644
--- a/tempest/services/compute/xml/hypervisor_client.py
+++ b/tempest/services/compute/xml/hypervisor_client.py
@@ -15,14 +15,15 @@
from lxml import etree
-from tempest.common.rest_client import RestClientXML
+from tempest.common import rest_client
from tempest import config
from tempest.services.compute.xml.common import xml_to_json
CONF = config.CONF
-class HypervisorClientXML(RestClientXML):
+class HypervisorClientXML(rest_client.RestClient):
+ TYPE = "xml"
def __init__(self, auth_provider):
super(HypervisorClientXML, self).__init__(auth_provider)
@@ -33,46 +34,42 @@
def get_hypervisor_list(self):
"""List hypervisors information."""
- resp, body = self.get('os-hypervisors', self.headers)
+ resp, body = self.get('os-hypervisors')
hypervisors = self._parse_array(etree.fromstring(body))
return resp, hypervisors
def get_hypervisor_list_details(self):
"""Show detailed hypervisors information."""
- resp, body = self.get('os-hypervisors/detail', self.headers)
+ resp, body = self.get('os-hypervisors/detail')
hypervisors = self._parse_array(etree.fromstring(body))
return resp, hypervisors
def get_hypervisor_show_details(self, hyper_id):
"""Display the details of the specified hypervisor."""
- resp, body = self.get('os-hypervisors/%s' % hyper_id,
- self.headers)
+ resp, body = self.get('os-hypervisors/%s' % hyper_id)
hypervisor = xml_to_json(etree.fromstring(body))
return resp, hypervisor
def get_hypervisor_servers(self, hyper_name):
"""List instances belonging to the specified hypervisor."""
- resp, body = self.get('os-hypervisors/%s/servers' % hyper_name,
- self.headers)
+ resp, body = self.get('os-hypervisors/%s/servers' % hyper_name)
hypervisors = self._parse_array(etree.fromstring(body))
return resp, hypervisors
def get_hypervisor_stats(self):
"""Get hypervisor statistics over all compute nodes."""
- resp, body = self.get('os-hypervisors/statistics', self.headers)
+ resp, body = self.get('os-hypervisors/statistics')
stats = xml_to_json(etree.fromstring(body))
return resp, stats
def get_hypervisor_uptime(self, hyper_id):
"""Display the uptime of the specified hypervisor."""
- resp, body = self.get('os-hypervisors/%s/uptime' % hyper_id,
- self.headers)
+ resp, body = self.get('os-hypervisors/%s/uptime' % hyper_id)
uptime = xml_to_json(etree.fromstring(body))
return resp, uptime
def search_hypervisor(self, hyper_name):
"""Search specified hypervisor."""
- resp, body = self.get('os-hypervisors/%s/search' % hyper_name,
- self.headers)
+ resp, body = self.get('os-hypervisors/%s/search' % hyper_name)
hypervisors = self._parse_array(etree.fromstring(body))
return resp, hypervisors
diff --git a/tempest/services/compute/xml/images_client.py b/tempest/services/compute/xml/images_client.py
index d90a7d8..9d529be 100644
--- a/tempest/services/compute/xml/images_client.py
+++ b/tempest/services/compute/xml/images_client.py
@@ -17,7 +17,7 @@
from lxml import etree
-from tempest.common.rest_client import RestClientXML
+from tempest.common import rest_client
from tempest.common import waiters
from tempest import config
from tempest import exceptions
@@ -30,7 +30,8 @@
CONF = config.CONF
-class ImagesClientXML(RestClientXML):
+class ImagesClientXML(rest_client.RestClient):
+ TYPE = "xml"
def __init__(self, auth_provider):
super(ImagesClientXML, self).__init__(auth_provider)
@@ -102,7 +103,7 @@
data.append(Text(v))
metadata.append(data)
resp, body = self.post('servers/%s/action' % str(server_id),
- str(Document(post_body)), self.headers)
+ str(Document(post_body)))
return resp, body
def list_images(self, params=None):
@@ -111,7 +112,7 @@
if params:
url += '?%s' % urllib.urlencode(params)
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
body = self._parse_images(etree.fromstring(body))
return resp, body['images']
@@ -123,20 +124,20 @@
url = "images/detail?" + param_list
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
body = self._parse_images(etree.fromstring(body))
return resp, body['images']
def get_image(self, image_id):
"""Returns the details of a single image."""
- resp, body = self.get("images/%s" % str(image_id), self.headers)
+ resp, body = self.get("images/%s" % str(image_id))
self.expected_success(200, resp)
body = self._parse_image(etree.fromstring(body))
return resp, body
def delete_image(self, image_id):
"""Deletes the provided image."""
- return self.delete("images/%s" % str(image_id), self.headers)
+ return self.delete("images/%s" % str(image_id))
def wait_for_image_status(self, image_id, status):
"""Waits for an image to reach a given status."""
@@ -152,8 +153,7 @@
def list_image_metadata(self, image_id):
"""Lists all metadata items for an image."""
- resp, body = self.get("images/%s/metadata" % str(image_id),
- self.headers)
+ resp, body = self.get("images/%s/metadata" % str(image_id))
body = self._parse_key_value(etree.fromstring(body))
return resp, body
@@ -161,7 +161,7 @@
"""Sets the metadata for an image."""
post_body = self._metadata_body(meta)
resp, body = self.put('images/%s/metadata' % image_id,
- str(Document(post_body)), self.headers)
+ str(Document(post_body)))
body = self._parse_key_value(etree.fromstring(body))
return resp, body
@@ -169,14 +169,14 @@
"""Updates the metadata for an image."""
post_body = self._metadata_body(meta)
resp, body = self.post('images/%s/metadata' % str(image_id),
- str(Document(post_body)), self.headers)
+ str(Document(post_body)))
body = self._parse_key_value(etree.fromstring(body))
return resp, body
def get_image_metadata_item(self, image_id, key):
"""Returns the value for a specific image metadata key."""
resp, body = self.get("images/%s/metadata/%s.xml" %
- (str(image_id), key), self.headers)
+ (str(image_id), key))
body = self._parse_metadata(etree.fromstring(body))
return resp, body
@@ -186,7 +186,7 @@
post_body = Element('meta', key=key)
post_body.append(Text(v))
resp, body = self.put('images/%s/metadata/%s' % (str(image_id), key),
- str(Document(post_body)), self.headers)
+ str(Document(post_body)))
body = xml_to_json(etree.fromstring(body))
return resp, body
@@ -194,14 +194,13 @@
"""Sets the value for a specific image metadata key."""
post_body = Document('meta', Text(meta), key=key)
resp, body = self.put('images/%s/metadata/%s' % (str(image_id), key),
- post_body, self.headers)
+ post_body)
body = xml_to_json(etree.fromstring(body))
return resp, body['meta']
def delete_image_metadata_item(self, image_id, key):
"""Deletes a single image metadata key/value pair."""
- return self.delete("images/%s/metadata/%s" % (str(image_id), key),
- self.headers)
+ return self.delete("images/%s/metadata/%s" % (str(image_id), key))
def is_resource_deleted(self, id):
try:
diff --git a/tempest/services/compute/xml/instance_usage_audit_log_client.py b/tempest/services/compute/xml/instance_usage_audit_log_client.py
index 562774b..1cd8c07 100644
--- a/tempest/services/compute/xml/instance_usage_audit_log_client.py
+++ b/tempest/services/compute/xml/instance_usage_audit_log_client.py
@@ -15,14 +15,15 @@
from lxml import etree
-from tempest.common.rest_client import RestClientXML
+from tempest.common import rest_client
from tempest import config
from tempest.services.compute.xml.common import xml_to_json
CONF = config.CONF
-class InstanceUsagesAuditLogClientXML(RestClientXML):
+class InstanceUsagesAuditLogClientXML(rest_client.RestClient):
+ TYPE = "xml"
def __init__(self, auth_provider):
super(InstanceUsagesAuditLogClientXML, self).__init__(
@@ -31,12 +32,12 @@
def list_instance_usage_audit_logs(self):
url = 'os-instance_usage_audit_log'
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
instance_usage_audit_logs = xml_to_json(etree.fromstring(body))
return resp, instance_usage_audit_logs
def get_instance_usage_audit_log(self, time_before):
url = 'os-instance_usage_audit_log/%s' % time_before
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
instance_usage_audit_log = xml_to_json(etree.fromstring(body))
return resp, instance_usage_audit_log
diff --git a/tempest/services/compute/xml/interfaces_client.py b/tempest/services/compute/xml/interfaces_client.py
index 4194d7d..8d4bfcc 100644
--- a/tempest/services/compute/xml/interfaces_client.py
+++ b/tempest/services/compute/xml/interfaces_client.py
@@ -17,18 +17,20 @@
from lxml import etree
-from tempest.common.rest_client import RestClientXML
+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
CONF = config.CONF
-class InterfacesClientXML(RestClientXML):
+class InterfacesClientXML(rest_client.RestClient):
+ TYPE = "xml"
def __init__(self, auth_provider):
super(InterfacesClientXML, self).__init__(auth_provider)
@@ -42,7 +44,7 @@
return iface
def list_interfaces(self, server):
- resp, body = self.get('servers/%s/os-interface' % server, self.headers)
+ resp, body = self.get('servers/%s/os-interface' % server)
node = etree.fromstring(body)
interfaces = [self._process_xml_interface(x)
for x in node.getchildren()]
@@ -70,14 +72,12 @@
iface.append(_fixed_ips)
doc.append(iface)
resp, body = self.post('servers/%s/os-interface' % server,
- headers=self.headers,
body=str(doc))
body = self._process_xml_interface(etree.fromstring(body))
return resp, body
def show_interface(self, server, port_id):
- resp, body = self.get('servers/%s/os-interface/%s' % (server, port_id),
- self.headers)
+ resp, body = self.get('servers/%s/os-interface/%s' % (server, port_id))
body = self._process_xml_interface(etree.fromstring(body))
return resp, body
@@ -105,3 +105,21 @@
(port_id, status, self.build_timeout))
raise exceptions.TimeoutException(message)
return resp, body
+
+ def add_fixed_ip(self, server_id, network_id):
+ """Add a fixed IP to input server instance."""
+ post_body = Element("addFixedIp",
+ xmlns=XMLNS_11,
+ networkId=network_id)
+ resp, body = self.post('servers/%s/action' % str(server_id),
+ str(Document(post_body)))
+ return resp, body
+
+ def remove_fixed_ip(self, server_id, ip_address):
+ """Remove input fixed IP from input server instance."""
+ post_body = Element("removeFixedIp",
+ xmlns=XMLNS_11,
+ address=ip_address)
+ resp, body = self.post('servers/%s/action' % str(server_id),
+ str(Document(post_body)))
+ return resp, body
diff --git a/tempest/services/compute/xml/keypairs_client.py b/tempest/services/compute/xml/keypairs_client.py
index 92fade4..fb498c0 100644
--- a/tempest/services/compute/xml/keypairs_client.py
+++ b/tempest/services/compute/xml/keypairs_client.py
@@ -16,7 +16,7 @@
from lxml import etree
-from tempest.common.rest_client import RestClientXML
+from tempest.common import rest_client
from tempest import config
from tempest.services.compute.xml.common import Document
from tempest.services.compute.xml.common import Element
@@ -26,20 +26,21 @@
CONF = config.CONF
-class KeyPairsClientXML(RestClientXML):
+class KeyPairsClientXML(rest_client.RestClient):
+ TYPE = "xml"
def __init__(self, auth_provider):
super(KeyPairsClientXML, self).__init__(auth_provider)
self.service = CONF.compute.catalog_type
def list_keypairs(self):
- resp, body = self.get("os-keypairs", self.headers)
+ resp, body = self.get("os-keypairs")
node = etree.fromstring(body)
body = [{'keypair': xml_to_json(x)} for x in node.getchildren()]
return resp, body
def get_keypair(self, key_name):
- resp, body = self.get("os-keypairs/%s" % str(key_name), self.headers)
+ resp, body = self.get("os-keypairs/%s" % str(key_name))
body = xml_to_json(etree.fromstring(body))
return resp, body
@@ -61,8 +62,7 @@
doc.append(keypair_element)
- resp, body = self.post("os-keypairs",
- headers=self.headers, body=str(doc))
+ resp, body = self.post("os-keypairs", body=str(doc))
body = xml_to_json(etree.fromstring(body))
return resp, body
diff --git a/tempest/services/compute/xml/limits_client.py b/tempest/services/compute/xml/limits_client.py
index 2a8fbec..2327626 100644
--- a/tempest/services/compute/xml/limits_client.py
+++ b/tempest/services/compute/xml/limits_client.py
@@ -15,7 +15,7 @@
from lxml import objectify
-from tempest.common.rest_client import RestClientXML
+from tempest.common import rest_client
from tempest import config
CONF = config.CONF
@@ -23,14 +23,15 @@
NS = "{http://docs.openstack.org/common/api/v1.0}"
-class LimitsClientXML(RestClientXML):
+class LimitsClientXML(rest_client.RestClient):
+ TYPE = "xml"
def __init__(self, auth_provider):
super(LimitsClientXML, self).__init__(auth_provider)
self.service = CONF.compute.catalog_type
def get_absolute_limits(self):
- resp, body = self.get("limits", self.headers)
+ resp, body = self.get("limits")
body = objectify.fromstring(body)
lim = NS + 'absolute'
ret = {}
@@ -41,7 +42,7 @@
return resp, ret
def get_specific_absolute_limit(self, absolute_limit):
- resp, body = self.get("limits", self.headers)
+ resp, body = self.get("limits")
body = objectify.fromstring(body)
lim = NS + 'absolute'
ret = {}
diff --git a/tempest/services/compute/xml/quotas_client.py b/tempest/services/compute/xml/quotas_client.py
index f1041f0..911c476 100644
--- a/tempest/services/compute/xml/quotas_client.py
+++ b/tempest/services/compute/xml/quotas_client.py
@@ -15,7 +15,7 @@
from lxml import etree
-from tempest.common.rest_client import RestClientXML
+from tempest.common import rest_client
from tempest import config
from tempest.services.compute.xml.common import Document
from tempest.services.compute.xml.common import Element
@@ -25,7 +25,8 @@
CONF = config.CONF
-class QuotasClientXML(RestClientXML):
+class QuotasClientXML(rest_client.RestClient):
+ TYPE = "xml"
def __init__(self, auth_provider):
super(QuotasClientXML, self).__init__(auth_provider)
@@ -43,14 +44,13 @@
return quota
- def _parse_array(self, node):
- return [self._format_quota(xml_to_json(x)) for x in node]
-
- def get_quota_set(self, tenant_id):
+ def get_quota_set(self, tenant_id, user_id=None):
"""List the quota set for a tenant."""
url = 'os-quota-sets/%s' % str(tenant_id)
- resp, body = self.get(url, self.headers)
+ if user_id:
+ url += '?user_id=%s' % str(user_id)
+ resp, body = self.get(url)
body = xml_to_json(etree.fromstring(body))
body = self._format_quota(body)
return resp, body
@@ -59,7 +59,7 @@
"""List the default quota set for a tenant."""
url = 'os-quota-sets/%s/defaults' % str(tenant_id)
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
body = xml_to_json(etree.fromstring(body))
body = self._format_quota(body)
return resp, body
@@ -119,8 +119,11 @@
post_body.add_attr('security_groups', security_groups)
resp, body = self.put('os-quota-sets/%s' % str(tenant_id),
- str(Document(post_body)),
- self.headers)
+ str(Document(post_body)))
body = xml_to_json(etree.fromstring(body))
body = self._format_quota(body)
return resp, body
+
+ def delete_quota_set(self, tenant_id):
+ """Delete the tenant's quota set."""
+ return self.delete('os-quota-sets/%s' % str(tenant_id))
diff --git a/tempest/services/compute/xml/security_groups_client.py b/tempest/services/compute/xml/security_groups_client.py
index 83072be..d53e8da 100644
--- a/tempest/services/compute/xml/security_groups_client.py
+++ b/tempest/services/compute/xml/security_groups_client.py
@@ -16,7 +16,7 @@
from lxml import etree
import urllib
-from tempest.common.rest_client import RestClientXML
+from tempest.common import rest_client
from tempest import config
from tempest import exceptions
from tempest.services.compute.xml.common import Document
@@ -28,7 +28,8 @@
CONF = config.CONF
-class SecurityGroupsClientXML(RestClientXML):
+class SecurityGroupsClientXML(rest_client.RestClient):
+ TYPE = "xml"
def __init__(self, auth_provider):
super(SecurityGroupsClientXML, self).__init__(auth_provider)
@@ -51,14 +52,14 @@
if params:
url += '?%s' % urllib.urlencode(params)
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
body = self._parse_array(etree.fromstring(body))
return resp, body
def get_security_group(self, security_group_id):
"""Get the details of a Security Group."""
url = "os-security-groups/%s" % str(security_group_id)
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
body = self._parse_body(etree.fromstring(body))
return resp, body
@@ -73,8 +74,7 @@
des.append(Text(content=description))
security_group.append(des)
resp, body = self.post('os-security-groups',
- str(Document(security_group)),
- self.headers)
+ str(Document(security_group)))
body = self._parse_body(etree.fromstring(body))
return resp, body
@@ -97,15 +97,13 @@
security_group.append(des)
resp, body = self.put('os-security-groups/%s' %
str(security_group_id),
- str(Document(security_group)),
- self.headers)
+ str(Document(security_group)))
body = self._parse_body(etree.fromstring(body))
return resp, body
def delete_security_group(self, security_group_id):
"""Deletes the provided Security Group."""
- return self.delete('os-security-groups/%s' %
- str(security_group_id), self.headers)
+ return self.delete('os-security-groups/%s' % str(security_group_id))
def create_security_group_rule(self, parent_group_id, ip_proto, from_port,
to_port, **kwargs):
@@ -136,19 +134,19 @@
group_rule.append(element)
url = 'os-security-group-rules'
- resp, body = self.post(url, str(Document(group_rule)), self.headers)
+ resp, body = self.post(url, str(Document(group_rule)))
body = self._parse_body(etree.fromstring(body))
return resp, body
def delete_security_group_rule(self, group_rule_id):
"""Deletes the provided Security Group rule."""
return self.delete('os-security-group-rules/%s' %
- str(group_rule_id), self.headers)
+ str(group_rule_id))
def list_security_group_rules(self, security_group_id):
"""List all rules for a security group."""
url = "os-security-groups"
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
body = etree.fromstring(body)
secgroups = body.getchildren()
for secgroup in secgroups:
@@ -157,3 +155,10 @@
rules = [xml_to_json(x) for x in node.getchildren()]
return resp, rules
raise exceptions.NotFound('No such Security Group')
+
+ def is_resource_deleted(self, id):
+ try:
+ self.get_security_group(id)
+ except exceptions.NotFound:
+ return True
+ return False
diff --git a/tempest/services/compute/xml/servers_client.py b/tempest/services/compute/xml/servers_client.py
index 37980c9..1215b80 100644
--- a/tempest/services/compute/xml/servers_client.py
+++ b/tempest/services/compute/xml/servers_client.py
@@ -19,7 +19,7 @@
from lxml import etree
-from tempest.common.rest_client import RestClientXML
+from tempest.common import rest_client
from tempest.common import waiters
from tempest import config
from tempest import exceptions
@@ -139,7 +139,8 @@
return json
-class ServersClientXML(RestClientXML):
+class ServersClientXML(rest_client.RestClient):
+ TYPE = "xml"
def __init__(self, auth_provider):
super(ServersClientXML, self).__init__(auth_provider)
@@ -186,7 +187,7 @@
def get_server(self, server_id):
"""Returns the details of an existing server."""
- resp, body = self.get("servers/%s" % str(server_id), self.headers)
+ resp, body = self.get("servers/%s" % str(server_id))
server = self._parse_server(etree.fromstring(body))
return resp, server
@@ -226,6 +227,10 @@
"""Un-shelves the provided server."""
return self.action(server_id, 'unshelve', None, **kwargs)
+ def shelve_offload_server(self, server_id, **kwargs):
+ """Shelve-offload the provided server."""
+ return self.action(server_id, 'shelveOffload', None, **kwargs)
+
def reset_state(self, server_id, state='error'):
"""Resets the state of a server to active/error."""
return self.action(server_id, 'os-resetState', None, state=state)
@@ -245,7 +250,7 @@
if params:
url += '?%s' % urllib.urlencode(params)
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
servers = self._parse_array(etree.fromstring(body))
return resp, {"servers": servers}
@@ -254,7 +259,7 @@
if params:
url += '?%s' % urllib.urlencode(params)
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
servers = self._parse_array(etree.fromstring(body))
return resp, {"servers": servers}
@@ -282,8 +287,7 @@
meta.append(Text(v))
metadata.append(meta)
- resp, body = self.put('servers/%s' % str(server_id),
- str(doc), self.headers)
+ resp, body = self.put('servers/%s' % str(server_id), str(doc))
return resp, xml_to_json(etree.fromstring(body))
def create_server(self, name, image_ref, flavor_ref, **kwargs):
@@ -356,7 +360,7 @@
temp.append(Text(k['contents']))
personality.append(temp)
- resp, body = self.post('servers', str(Document(server)), self.headers)
+ resp, body = self.post('servers', str(Document(server)))
server = self._parse_server(etree.fromstring(body))
return resp, server
@@ -394,7 +398,7 @@
def list_addresses(self, server_id):
"""Lists all addresses for a server."""
- resp, body = self.get("servers/%s/ips" % str(server_id), self.headers)
+ resp, body = self.get("servers/%s/ips" % str(server_id))
networks = {}
xml_list = etree.fromstring(body)
@@ -407,8 +411,7 @@
def list_addresses_by_network(self, server_id, network_id):
"""Lists all addresses of a specific network type for a server."""
resp, body = self.get("servers/%s/ips/%s" % (str(server_id),
- network_id),
- self.headers)
+ network_id))
network = self._parse_network(etree.fromstring(body))
return resp, network
@@ -417,8 +420,7 @@
if 'xmlns' not in kwargs:
kwargs['xmlns'] = XMLNS_11
doc = Document((Element(action_name, **kwargs)))
- resp, body = self.post("servers/%s/action" % server_id,
- str(doc), self.headers)
+ resp, body = self.post("servers/%s/action" % server_id, str(doc))
if response_key is not None:
body = xml_to_json(etree.fromstring(body))
return resp, body
@@ -435,8 +437,7 @@
adminPass=password)
def get_password(self, server_id):
- resp, body = self.get("servers/%s/os-server-password" %
- str(server_id), self.headers)
+ resp, body = self.get("servers/%s/os-server-password" % str(server_id))
body = xml_to_json(etree.fromstring(body))
return resp, body
@@ -446,8 +447,7 @@
Note that this does not actually change the instance server
password.
"""
- return self.delete("servers/%s/os-server-password" %
- str(server_id))
+ return self.delete("servers/%s/os-server-password" % str(server_id))
def reboot(self, server_id, reboot_type):
return self.action(server_id, "reboot", None, type=reboot_type)
@@ -478,7 +478,7 @@
metadata.append(meta)
resp, body = self.post('servers/%s/action' % server_id,
- str(Document(rebuild)), self.headers)
+ str(Document(rebuild)))
server = self._parse_server(etree.fromstring(body))
return resp, server
@@ -523,12 +523,11 @@
host=dest_host)
resp, body = self.post("servers/%s/action" % str(server_id),
- str(Document(req_body)), self.headers)
+ str(Document(req_body)))
return resp, body
def list_server_metadata(self, server_id):
- resp, body = self.get("servers/%s/metadata" % str(server_id),
- self.headers)
+ resp, body = self.get("servers/%s/metadata" % str(server_id))
body = self._parse_key_value(etree.fromstring(body))
return resp, body
@@ -541,8 +540,7 @@
meta_element = Element("meta", key=k)
meta_element.append(Text(v))
metadata.append(meta_element)
- resp, body = self.put('servers/%s/metadata' % str(server_id),
- str(doc), self.headers)
+ resp, body = self.put('servers/%s/metadata' % str(server_id), str(doc))
return resp, xml_to_json(etree.fromstring(body))
def update_server_metadata(self, server_id, meta):
@@ -554,13 +552,12 @@
meta_element.append(Text(v))
metadata.append(meta_element)
resp, body = self.post("/servers/%s/metadata" % str(server_id),
- str(doc), headers=self.headers)
+ str(doc))
body = xml_to_json(etree.fromstring(body))
return resp, body
def get_server_metadata_item(self, server_id, key):
- resp, body = self.get("servers/%s/metadata/%s" % (str(server_id), key),
- headers=self.headers)
+ resp, body = self.get("servers/%s/metadata/%s" % (str(server_id), key))
return resp, dict([(etree.fromstring(body).attrib['key'],
xml_to_json(etree.fromstring(body)))])
@@ -571,7 +568,7 @@
meta_element.append(Text(v))
doc.append(meta_element)
resp, body = self.put('servers/%s/metadata/%s' % (str(server_id), key),
- str(doc), self.headers)
+ str(doc))
return resp, xml_to_json(etree.fromstring(body))
def delete_server_metadata_item(self, server_id, key):
@@ -588,7 +585,7 @@
List the virtual interfaces used in an instance.
"""
resp, body = self.get('/'.join(['servers', server_id,
- 'os-virtual-interfaces']), self.headers)
+ 'os-virtual-interfaces']))
virt_int = self._parse_xml_virtual_interfaces(etree.fromstring(body))
return resp, virt_int
@@ -604,7 +601,7 @@
post_body = Element("volumeAttachment", volumeId=volume_id,
device=device)
resp, body = self.post('servers/%s/os-volume_attachments' % server_id,
- str(Document(post_body)), self.headers)
+ str(Document(post_body)))
return resp, body
def detach_volume(self, server_id, volume_id):
@@ -616,22 +613,20 @@
def get_server_diagnostics(self, server_id):
"""Get the usage data for a server."""
- resp, body = self.get("servers/%s/diagnostics" % server_id,
- self.headers)
+ resp, body = self.get("servers/%s/diagnostics" % server_id)
body = xml_to_json(etree.fromstring(body))
return resp, body
def list_instance_actions(self, server_id):
"""List the provided server action."""
- resp, body = self.get("servers/%s/os-instance-actions" % server_id,
- self.headers)
+ resp, body = self.get("servers/%s/os-instance-actions" % server_id)
body = self._parse_array(etree.fromstring(body))
return resp, body
def get_instance_action(self, server_id, request_id):
"""Returns the action details of the provided server."""
resp, body = self.get("servers/%s/os-instance-actions/%s" %
- (server_id, request_id), self.headers)
+ (server_id, request_id))
body = xml_to_json(etree.fromstring(body))
return resp, body
@@ -642,3 +637,16 @@
def restore_soft_deleted_server(self, server_id, **kwargs):
"""Restore a soft-deleted server."""
return self.action(server_id, 'restore', None, **kwargs)
+
+ def reset_network(self, server_id, **kwargs):
+ """Resets the Network of a server"""
+ return self.action(server_id, 'resetNetwork', None, **kwargs)
+
+ def inject_network_info(self, server_id, **kwargs):
+ """Inject the Network Info into server"""
+ return self.action(server_id, 'injectNetworkInfo', None, **kwargs)
+
+ def get_vnc_console(self, server_id, console_type):
+ """Get URL of VNC console."""
+ return self.action(server_id, "os-getVNCConsole",
+ "console", type=console_type)
diff --git a/tempest/services/compute/xml/services_client.py b/tempest/services/compute/xml/services_client.py
index c28dc12..d7b8a60 100644
--- a/tempest/services/compute/xml/services_client.py
+++ b/tempest/services/compute/xml/services_client.py
@@ -18,7 +18,7 @@
from lxml import etree
-from tempest.common.rest_client import RestClientXML
+from tempest.common import rest_client
from tempest import config
from tempest.services.compute.xml.common import Document
from tempest.services.compute.xml.common import Element
@@ -27,7 +27,8 @@
CONF = config.CONF
-class ServicesClientXML(RestClientXML):
+class ServicesClientXML(rest_client.RestClient):
+ TYPE = "xml"
def __init__(self, auth_provider):
super(ServicesClientXML, self).__init__(auth_provider)
@@ -38,7 +39,7 @@
if params:
url += '?%s' % urllib.urlencode(params)
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
node = etree.fromstring(body)
body = [xml_to_json(x) for x in node.getchildren()]
return resp, body
@@ -53,8 +54,7 @@
post_body.add_attr('binary', binary)
post_body.add_attr('host', host_name)
- resp, body = self.put('os-services/enable', str(Document(post_body)),
- self.headers)
+ resp, body = self.put('os-services/enable', str(Document(post_body)))
body = xml_to_json(etree.fromstring(body))
return resp, body
@@ -68,7 +68,6 @@
post_body.add_attr('binary', binary)
post_body.add_attr('host', host_name)
- resp, body = self.put('os-services/disable', str(Document(post_body)),
- self.headers)
+ resp, body = self.put('os-services/disable', str(Document(post_body)))
body = xml_to_json(etree.fromstring(body))
return resp, body
diff --git a/tempest/services/compute/xml/tenant_usages_client.py b/tempest/services/compute/xml/tenant_usages_client.py
index 93eeb00..79f0ac9 100644
--- a/tempest/services/compute/xml/tenant_usages_client.py
+++ b/tempest/services/compute/xml/tenant_usages_client.py
@@ -17,14 +17,15 @@
from lxml import etree
-from tempest.common.rest_client import RestClientXML
+from tempest.common import rest_client
from tempest import config
from tempest.services.compute.xml.common import xml_to_json
CONF = config.CONF
-class TenantUsagesClientXML(RestClientXML):
+class TenantUsagesClientXML(rest_client.RestClient):
+ TYPE = "xml"
def __init__(self, auth_provider):
super(TenantUsagesClientXML, self).__init__(auth_provider)
@@ -39,7 +40,7 @@
if params:
url += '?%s' % urllib.urlencode(params)
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
tenant_usage = self._parse_array(etree.fromstring(body))
return resp, tenant_usage['tenant_usage']
@@ -48,6 +49,6 @@
if params:
url += '?%s' % urllib.urlencode(params)
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
tenant_usage = self._parse_array(etree.fromstring(body))
return resp, tenant_usage
diff --git a/tempest/services/compute/xml/volumes_extensions_client.py b/tempest/services/compute/xml/volumes_extensions_client.py
index 941cd69..570b715 100644
--- a/tempest/services/compute/xml/volumes_extensions_client.py
+++ b/tempest/services/compute/xml/volumes_extensions_client.py
@@ -18,7 +18,7 @@
from lxml import etree
-from tempest.common.rest_client import RestClientXML
+from tempest.common import rest_client
from tempest import config
from tempest import exceptions
from tempest.services.compute.xml.common import Document
@@ -30,7 +30,8 @@
CONF = config.CONF
-class VolumesExtensionsClientXML(RestClientXML):
+class VolumesExtensionsClientXML(rest_client.RestClient):
+ TYPE = "xml"
def __init__(self, auth_provider):
super(VolumesExtensionsClientXML, self).__init__(
@@ -60,7 +61,7 @@
if params:
url += '?%s' % urllib.urlencode(params)
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
body = etree.fromstring(body)
volumes = []
if body is not None:
@@ -74,7 +75,7 @@
if params:
url += '?%s' % urllib.urlencode(params)
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
body = etree.fromstring(body)
volumes = []
if body is not None:
@@ -84,7 +85,7 @@
def get_volume(self, volume_id):
"""Returns the details of a single volume."""
url = "os-volumes/%s" % str(volume_id)
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
body = etree.fromstring(body)
return resp, self._parse_volume(body)
@@ -110,8 +111,7 @@
meta.append(Text(value))
_metadata.append(meta)
- resp, body = self.post('os-volumes', str(Document(volume)),
- self.headers)
+ resp, body = self.post('os-volumes', str(Document(volume)))
body = xml_to_json(etree.fromstring(body))
return resp, body
diff --git a/tempest/services/data_processing/v1_1/client.py b/tempest/services/data_processing/v1_1/client.py
index db21201..e96b44b 100644
--- a/tempest/services/data_processing/v1_1/client.py
+++ b/tempest/services/data_processing/v1_1/client.py
@@ -77,3 +77,17 @@
uri = "node-group-templates/%s" % tmpl_id
return self.delete(uri)
+
+ def list_plugins(self):
+ """List all enabled plugins."""
+
+ uri = 'plugins'
+ return self._request_and_parse(self.get, uri, 'plugins')
+
+ def get_plugin(self, plugin_name, plugin_version=None):
+ """Returns the details of a single plugin."""
+
+ uri = "plugins/%s" % plugin_name
+ if plugin_version:
+ uri += '/%s' % plugin_version
+ return self._request_and_parse(self.get, uri, 'plugin')
diff --git a/tempest/services/database/__init__.py b/tempest/services/database/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/services/database/__init__.py
diff --git a/tempest/services/database/json/__init__.py b/tempest/services/database/json/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/services/database/json/__init__.py
diff --git a/tempest/services/database/json/flavors_client.py b/tempest/services/database/json/flavors_client.py
new file mode 100644
index 0000000..2ec0405
--- /dev/null
+++ b/tempest/services/database/json/flavors_client.py
@@ -0,0 +1,40 @@
+# Copyright 2014 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 urllib
+
+from tempest.common import rest_client
+from tempest import config
+
+CONF = config.CONF
+
+
+class DatabaseFlavorsClientJSON(rest_client.RestClient):
+
+ def __init__(self, auth_provider):
+ super(DatabaseFlavorsClientJSON, self).__init__(auth_provider)
+ self.service = CONF.database.catalog_type
+
+ def list_db_flavors(self, params=None):
+ url = 'flavors'
+ if params:
+ url += '?%s' % urllib.urlencode(params)
+
+ resp, body = self.get(url)
+ return resp, self._parse_resp(body)
+
+ def get_db_flavor_details(self, db_flavor_id):
+ resp, body = self.get("flavors/%s" % str(db_flavor_id))
+ return resp, self._parse_resp(body)
diff --git a/tempest/services/identity/json/identity_client.py b/tempest/services/identity/json/identity_client.py
index c018215..99b4036 100644
--- a/tempest/services/identity/json/identity_client.py
+++ b/tempest/services/identity/json/identity_client.py
@@ -12,20 +12,23 @@
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 IdentityClientJSON(RestClient):
+class IdentityClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(IdentityClientJSON, self).__init__(auth_provider)
self.service = CONF.identity.catalog_type
self.endpoint_url = 'adminURL'
+ # Needed for xml service client
+ self.list_tags = ["roles", "tenants", "users", "services"]
+
def has_admin_extensions(self):
"""
Returns True if the KSADM Admin Extensions are supported
@@ -43,9 +46,8 @@
'name': name,
}
post_body = json.dumps({'role': post_body})
- resp, body = self.post('OS-KSADM/roles', post_body, self.headers)
- body = json.loads(body)
- return resp, body['role']
+ resp, body = self.post('OS-KSADM/roles', post_body)
+ return resp, self._parse_resp(body)
def create_tenant(self, name, **kwargs):
"""
@@ -60,30 +62,24 @@
'enabled': kwargs.get('enabled', True),
}
post_body = json.dumps({'tenant': post_body})
- resp, body = self.post('tenants', post_body, self.headers)
- body = json.loads(body)
- return resp, body['tenant']
+ resp, body = self.post('tenants', post_body)
+ return resp, self._parse_resp(body)
def delete_role(self, role_id):
"""Delete a role."""
- resp, body = self.delete('OS-KSADM/roles/%s' % str(role_id))
- return resp, body
+ return self.delete('OS-KSADM/roles/%s' % str(role_id))
def list_user_roles(self, tenant_id, user_id):
"""Returns a list of roles assigned to a user for a tenant."""
url = '/tenants/%s/users/%s/roles' % (tenant_id, user_id)
resp, body = self.get(url)
- body = json.loads(body)
- return resp, body['roles']
+ return resp, self._parse_resp(body)
def assign_user_role(self, tenant_id, user_id, role_id):
"""Add roles to a user on a tenant."""
- post_body = json.dumps({})
resp, body = self.put('/tenants/%s/users/%s/roles/OS-KSADM/%s' %
- (tenant_id, user_id, role_id), post_body,
- self.headers)
- body = json.loads(body)
- return resp, body['role']
+ (tenant_id, user_id, role_id), "")
+ return resp, self._parse_resp(body)
def remove_user_role(self, tenant_id, user_id, role_id):
"""Removes a role assignment for a user on a tenant."""
@@ -92,20 +88,17 @@
def delete_tenant(self, tenant_id):
"""Delete a tenant."""
- resp, body = self.delete('tenants/%s' % str(tenant_id))
- return resp, body
+ return self.delete('tenants/%s' % str(tenant_id))
def get_tenant(self, tenant_id):
"""Get tenant details."""
resp, body = self.get('tenants/%s' % str(tenant_id))
- body = json.loads(body)
- return resp, body['tenant']
+ return resp, self._parse_resp(body)
def list_roles(self):
"""Returns roles."""
resp, body = self.get('OS-KSADM/roles')
- body = json.loads(body)
- return resp, body['roles']
+ return resp, self._parse_resp(body)
def list_tenants(self):
"""Returns tenants."""
@@ -133,50 +126,43 @@
'enabled': en,
}
post_body = json.dumps({'tenant': post_body})
- resp, body = self.post('tenants/%s' % tenant_id, post_body,
- self.headers)
- body = json.loads(body)
- return resp, body['tenant']
+ resp, body = self.post('tenants/%s' % tenant_id, post_body)
+ return resp, self._parse_resp(body)
def create_user(self, name, password, tenant_id, email, **kwargs):
"""Create a user."""
post_body = {
'name': name,
'password': password,
- 'tenantId': tenant_id,
'email': email
}
+ if tenant_id is not None:
+ post_body['tenantId'] = tenant_id
if kwargs.get('enabled') is not None:
post_body['enabled'] = kwargs.get('enabled')
post_body = json.dumps({'user': post_body})
- resp, body = self.post('users', post_body, self.headers)
- body = json.loads(body)
- return resp, body['user']
+ resp, body = self.post('users', post_body)
+ return resp, self._parse_resp(body)
def update_user(self, user_id, **kwargs):
"""Updates a user."""
put_body = json.dumps({'user': kwargs})
- resp, body = self.put('users/%s' % user_id, put_body,
- self.headers)
- body = json.loads(body)
- return resp, body['user']
+ resp, body = self.put('users/%s' % user_id, put_body)
+ return resp, self._parse_resp(body)
def get_user(self, user_id):
"""GET a user."""
resp, body = self.get("users/%s" % user_id)
- body = json.loads(body)
- return resp, body['user']
+ return resp, self._parse_resp(body)
def delete_user(self, user_id):
"""Delete a user."""
- resp, body = self.delete("users/%s" % user_id)
- return resp, body
+ return self.delete("users/%s" % user_id)
def get_users(self):
"""Get the list of users."""
resp, body = self.get("users")
- body = json.loads(body)
- return resp, body['users']
+ return resp, self._parse_resp(body)
def enable_disable_user(self, user_id, enabled):
"""Enables or disables a user."""
@@ -184,21 +170,22 @@
'enabled': enabled
}
put_body = json.dumps({'user': put_body})
- resp, body = self.put('users/%s/enabled' % user_id,
- put_body, self.headers)
- body = json.loads(body)
- return resp, body
+ resp, body = self.put('users/%s/enabled' % user_id, put_body)
+ return resp, self._parse_resp(body)
+
+ def get_token(self, token_id):
+ """Get token details."""
+ resp, body = self.get("tokens/%s" % token_id)
+ return resp, self._parse_resp(body)
def delete_token(self, token_id):
"""Delete a token."""
- resp, body = self.delete("tokens/%s" % token_id)
- return resp, body
+ return self.delete("tokens/%s" % token_id)
def list_users_for_tenant(self, tenant_id):
"""List users for a Tenant."""
resp, body = self.get('/tenants/%s/users' % tenant_id)
- body = json.loads(body)
- return resp, body['users']
+ return resp, self._parse_resp(body)
def get_user_by_username(self, tenant_id, username):
resp, users = self.list_users_for_tenant(tenant_id)
@@ -215,22 +202,19 @@
'description': kwargs.get('description')
}
post_body = json.dumps({'OS-KSADM:service': post_body})
- resp, body = self.post('/OS-KSADM/services', post_body, self.headers)
- body = json.loads(body)
- return resp, body['OS-KSADM:service']
+ resp, body = self.post('/OS-KSADM/services', post_body)
+ return resp, self._parse_resp(body)
def get_service(self, service_id):
"""Get Service."""
url = '/OS-KSADM/services/%s' % service_id
resp, body = self.get(url)
- body = json.loads(body)
- return resp, body['OS-KSADM:service']
+ return resp, self._parse_resp(body)
def list_services(self):
"""List Service - Returns Services."""
resp, body = self.get('/OS-KSADM/services/')
- body = json.loads(body)
- return resp, body['OS-KSADM:services']
+ return resp, self._parse_resp(body)
def delete_service(self, service_id):
"""Delete Service."""
@@ -238,7 +222,7 @@
return self.delete(url)
-class TokenClientJSON(RestClient):
+class TokenClientJSON(IdentityClientJSON):
def __init__(self):
super(TokenClientJSON, self).__init__(None)
@@ -250,26 +234,48 @@
self.auth_url = auth_url
- def auth(self, user, password, tenant):
+ def auth(self, user, password, tenant=None):
creds = {
'auth': {
'passwordCredentials': {
'username': user,
'password': password,
},
- 'tenantName': tenant,
}
}
+
+ if tenant:
+ creds['auth']['tenantName'] = tenant
+
body = json.dumps(creds)
- resp, body = self.post(self.auth_url, headers=self.headers, body=body)
+ resp, body = self.post(self.auth_url, body=body)
+
+ return resp, body['access']
+
+ def auth_token(self, token_id, tenant=None):
+ creds = {
+ 'auth': {
+ 'token': {
+ 'id': token_id,
+ },
+ }
+ }
+
+ if tenant:
+ creds['auth']['tenantName'] = tenant
+
+ body = json.dumps(creds)
+ resp, body = self.post(self.auth_url, body=body)
return resp, body['access']
def request(self, method, url, headers=None, body=None):
"""A simple HTTP request interface."""
if headers is None:
- headers = {}
-
+ # Always accept 'json', for TokenClientXML too.
+ # Because XML response is not easily
+ # converted to the corresponding JSON one
+ headers = self.get_headers(accept_type="json")
self._log_request(method, url, headers, body)
resp, resp_body = self.http_obj.request(url, method,
headers=headers, body=body)
@@ -282,7 +288,9 @@
raise exceptions.IdentityError(
'Unexpected status code {0}'.format(resp.status))
- return resp, json.loads(resp_body)
+ if isinstance(resp_body, str):
+ resp_body = json.loads(resp_body)
+ return resp, resp_body
def get_token(self, user, password, tenant, auth_data=False):
"""
diff --git a/tempest/services/identity/v3/json/credentials_client.py b/tempest/services/identity/v3/json/credentials_client.py
index a0fbb76..f795c7b 100644
--- a/tempest/services/identity/v3/json/credentials_client.py
+++ b/tempest/services/identity/v3/json/credentials_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 CredentialsClientJSON(RestClient):
+class CredentialsClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(CredentialsClientJSON, self).__init__(auth_provider)
@@ -40,8 +40,7 @@
"user_id": user_id
}
post_body = json.dumps({'credential': post_body})
- resp, body = self.post('credentials', post_body,
- self.headers)
+ resp, body = self.post('credentials', post_body)
body = json.loads(body)
body['credential']['blob'] = json.loads(body['credential']['blob'])
return resp, body['credential']
@@ -63,8 +62,7 @@
"user_id": user_id
}
post_body = json.dumps({'credential': post_body})
- resp, body = self.patch('credentials/%s' % credential_id, post_body,
- self.headers)
+ resp, body = self.patch('credentials/%s' % credential_id, post_body)
body = json.loads(body)
body['credential']['blob'] = json.loads(body['credential']['blob'])
return resp, body['credential']
diff --git a/tempest/services/identity/v3/json/endpoints_client.py b/tempest/services/identity/v3/json/endpoints_client.py
index 1b78115..f7a894b 100644
--- a/tempest/services/identity/v3/json/endpoints_client.py
+++ b/tempest/services/identity/v3/json/endpoints_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 EndPointClientJSON(RestClient):
+class EndPointClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(EndPointClientJSON, self).__init__(auth_provider)
@@ -36,9 +36,17 @@
return resp, body['endpoints']
def create_endpoint(self, service_id, interface, url, **kwargs):
- """Create endpoint."""
+ """Create endpoint.
+
+ Normally this function wouldn't allow setting values that are not
+ allowed for 'enabled'. Use `force_enabled` to set a non-boolean.
+
+ """
region = kwargs.get('region', None)
- enabled = kwargs.get('enabled', None)
+ if 'force_enabled' in kwargs:
+ enabled = kwargs.get('force_enabled', None)
+ else:
+ enabled = kwargs.get('enabled', None)
post_body = {
'service_id': service_id,
'interface': interface,
@@ -47,13 +55,18 @@
'enabled': enabled
}
post_body = json.dumps({'endpoint': post_body})
- resp, body = self.post('endpoints', post_body, self.headers)
+ resp, body = self.post('endpoints', post_body)
body = json.loads(body)
return resp, body['endpoint']
def update_endpoint(self, endpoint_id, service_id=None, interface=None,
- url=None, region=None, enabled=None):
- """Updates an endpoint with given parameters."""
+ url=None, region=None, enabled=None, **kwargs):
+ """Updates an endpoint with given parameters.
+
+ Normally this function wouldn't allow setting values that are not
+ allowed for 'enabled'. Use `force_enabled` to set a non-boolean.
+
+ """
post_body = {}
if service_id is not None:
post_body['service_id'] = service_id
@@ -63,11 +76,12 @@
post_body['url'] = url
if region is not None:
post_body['region'] = region
- if enabled is not None:
+ if 'force_enabled' in kwargs:
+ post_body['enabled'] = kwargs['force_enabled']
+ elif enabled is not None:
post_body['enabled'] = enabled
post_body = json.dumps({'endpoint': post_body})
- resp, body = self.patch('endpoints/%s' % endpoint_id, post_body,
- self.headers)
+ resp, body = self.patch('endpoints/%s' % endpoint_id, post_body)
body = json.loads(body)
return resp, body['endpoint']
diff --git a/tempest/services/identity/v3/json/identity_client.py b/tempest/services/identity/v3/json/identity_client.py
index ab1dc94..65f3355 100644
--- a/tempest/services/identity/v3/json/identity_client.py
+++ b/tempest/services/identity/v3/json/identity_client.py
@@ -14,16 +14,15 @@
# under the License.
import json
-import urlparse
-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 IdentityV3ClientJSON(RestClient):
+class IdentityV3ClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(IdentityV3ClientJSON, self).__init__(auth_provider)
@@ -49,8 +48,7 @@
'password': password
}
post_body = json.dumps({'user': post_body})
- resp, body = self.post('users', post_body,
- self.headers)
+ resp, body = self.post('users', post_body)
body = json.loads(body)
return resp, body['user']
@@ -72,14 +70,13 @@
'description': description
}
post_body = json.dumps({'user': post_body})
- resp, body = self.patch('users/%s' % user_id, post_body,
- self.headers)
+ resp, body = self.patch('users/%s' % user_id, post_body)
body = json.loads(body)
return resp, body['user']
def list_user_projects(self, user_id):
"""Lists the projects on which a user has roles assigned."""
- resp, body = self.get('users/%s/projects' % user_id, self.headers)
+ resp, body = self.get('users/%s/projects' % user_id)
body = json.loads(body)
return resp, body['projects']
@@ -112,7 +109,7 @@
'name': name
}
post_body = json.dumps({'project': post_body})
- resp, body = self.post('projects', post_body, self.headers)
+ resp, body = self.post('projects', post_body)
body = json.loads(body)
return resp, body['project']
@@ -135,8 +132,7 @@
'domain_id': domain_id,
}
post_body = json.dumps({'project': post_body})
- resp, body = self.patch('projects/%s' % project_id, post_body,
- self.headers)
+ resp, body = self.patch('projects/%s' % project_id, post_body)
body = json.loads(body)
return resp, body['project']
@@ -157,7 +153,7 @@
'name': name
}
post_body = json.dumps({'role': post_body})
- resp, body = self.post('roles', post_body, self.headers)
+ resp, body = self.post('roles', post_body)
body = json.loads(body)
return resp, body['role']
@@ -173,8 +169,7 @@
'name': name
}
post_body = json.dumps({'role': post_body})
- resp, body = self.patch('roles/%s' % str(role_id), post_body,
- self.headers)
+ resp, body = self.patch('roles/%s' % str(role_id), post_body)
body = json.loads(body)
return resp, body['role']
@@ -186,8 +181,7 @@
def assign_user_role(self, project_id, user_id, role_id):
"""Add roles to a user on a project."""
resp, body = self.put('projects/%s/users/%s/roles/%s' %
- (project_id, user_id, role_id), None,
- self.headers)
+ (project_id, user_id, role_id), None)
return resp, body
def create_domain(self, name, **kwargs):
@@ -200,7 +194,7 @@
'name': name
}
post_body = json.dumps({'domain': post_body})
- resp, body = self.post('domains', post_body, self.headers)
+ resp, body = self.post('domains', post_body)
body = json.loads(body)
return resp, body['domain']
@@ -227,8 +221,7 @@
'name': name
}
post_body = json.dumps({'domain': post_body})
- resp, body = self.patch('domains/%s' % domain_id, post_body,
- self.headers)
+ resp, body = self.patch('domains/%s' % domain_id, post_body)
body = json.loads(body)
return resp, body['domain']
@@ -263,13 +256,13 @@
'name': name
}
post_body = json.dumps({'group': post_body})
- resp, body = self.post('groups', post_body, self.headers)
+ resp, body = self.post('groups', post_body)
body = json.loads(body)
return resp, body['group']
def get_group(self, group_id):
"""Get group details."""
- resp, body = self.get('groups/%s' % group_id, self.headers)
+ resp, body = self.get('groups/%s' % group_id)
body = json.loads(body)
return resp, body['group']
@@ -283,8 +276,7 @@
'description': description
}
post_body = json.dumps({'group': post_body})
- resp, body = self.patch('groups/%s' % group_id, post_body,
- self.headers)
+ resp, body = self.patch('groups/%s' % group_id, post_body)
body = json.loads(body)
return resp, body['group']
@@ -296,33 +288,30 @@
def add_group_user(self, group_id, user_id):
"""Add user into group."""
resp, body = self.put('groups/%s/users/%s' % (group_id, user_id),
- None, self.headers)
+ None)
return resp, body
def list_group_users(self, group_id):
"""List users in group."""
- resp, body = self.get('groups/%s/users' % group_id, self.headers)
+ resp, body = self.get('groups/%s/users' % group_id)
body = json.loads(body)
return resp, body['users']
def delete_group_user(self, group_id, user_id):
"""Delete user in group."""
- resp, body = self.delete('groups/%s/users/%s' % (group_id, user_id),
- self.headers)
+ resp, body = self.delete('groups/%s/users/%s' % (group_id, user_id))
return resp, body
def assign_user_role_on_project(self, project_id, user_id, role_id):
"""Add roles to a user on a project."""
resp, body = self.put('projects/%s/users/%s/roles/%s' %
- (project_id, user_id, role_id), None,
- self.headers)
+ (project_id, user_id, role_id), None)
return resp, body
def assign_user_role_on_domain(self, domain_id, user_id, role_id):
"""Add roles to a user on a domain."""
resp, body = self.put('domains/%s/users/%s/roles/%s' %
- (domain_id, user_id, role_id), None,
- self.headers)
+ (domain_id, user_id, role_id), None)
return resp, body
def list_user_roles_on_project(self, project_id, user_id):
@@ -354,15 +343,13 @@
def assign_group_role_on_project(self, project_id, group_id, role_id):
"""Add roles to a user on a project."""
resp, body = self.put('projects/%s/groups/%s/roles/%s' %
- (project_id, group_id, role_id), None,
- self.headers)
+ (project_id, group_id, role_id), None)
return resp, body
def assign_group_role_on_domain(self, domain_id, group_id, role_id):
"""Add roles to a user on a domain."""
resp, body = self.put('domains/%s/groups/%s/roles/%s' %
- (domain_id, group_id, role_id), None,
- self.headers)
+ (domain_id, group_id, role_id), None)
return resp, body
def list_group_roles_on_project(self, project_id, group_id):
@@ -404,7 +391,7 @@
'expires_at': expires_at
}
post_body = json.dumps({'trust': post_body})
- resp, body = self.post('OS-TRUST/trusts', post_body, self.headers)
+ resp, body = self.post('OS-TRUST/trusts', post_body)
body = json.loads(body)
return resp, body['trust']
@@ -452,16 +439,15 @@
return resp, body
-class V3TokenClientJSON(RestClient):
+class V3TokenClientJSON(rest_client.RestClient):
def __init__(self):
super(V3TokenClientJSON, self).__init__(None)
auth_url = CONF.identity.uri_v3
- # If the v3 url is not set, get it from the v2 one
- if auth_url is None:
- auth_url = CONF.identity.uri.replace(urlparse.urlparse(
- CONF.identity.uri).path, "/v3")
-
+ if not auth_url and CONF.identity_feature_enabled.api_v3:
+ raise exceptions.InvalidConfiguration('you must specify a v3 uri '
+ 'if using the v3 identity '
+ 'api')
if 'auth/tokens' not in auth_url:
auth_url = auth_url.rstrip('/') + '/auth/tokens'
@@ -507,11 +493,16 @@
creds['auth']['scope'] = scope
body = json.dumps(creds)
- resp, body = self.post(self.auth_url, headers=self.headers, body=body)
+ resp, body = self.post(self.auth_url, body=body)
return resp, body
def request(self, method, url, headers=None, body=None):
"""A simple HTTP request interface."""
+ if headers is None:
+ # Always accept 'json', for xml token client too.
+ # Because XML response is not easily
+ # converted to the corresponding JSON one
+ headers = self.get_headers(accept_type="json")
self._log_request(method, url, headers, body)
resp, resp_body = self.http_obj.request(url, method,
headers=headers, body=body)
diff --git a/tempest/services/identity/v3/json/policy_client.py b/tempest/services/identity/v3/json/policy_client.py
index c376979..3c90fa1 100644
--- a/tempest/services/identity/v3/json/policy_client.py
+++ b/tempest/services/identity/v3/json/policy_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 PolicyClientJSON(RestClient):
+class PolicyClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(PolicyClientJSON, self).__init__(auth_provider)
@@ -36,7 +36,7 @@
"type": type
}
post_body = json.dumps({'policy': post_body})
- resp, body = self.post('policies', post_body, self.headers)
+ resp, body = self.post('policies', post_body)
body = json.loads(body)
return resp, body['policy']
@@ -62,8 +62,7 @@
}
post_body = json.dumps({'policy': post_body})
url = 'policies/%s' % policy_id
- resp, body = self.patch(url, post_body,
- self.headers)
+ resp, body = self.patch(url, post_body)
body = json.loads(body)
return resp, body['policy']
diff --git a/tempest/services/identity/v3/json/service_client.py b/tempest/services/identity/v3/json/service_client.py
index 92f7629..b66fb4a 100644
--- a/tempest/services/identity/v3/json/service_client.py
+++ b/tempest/services/identity/v3/json/service_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 ServiceClientJSON(RestClient):
+class ServiceClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(ServiceClientJSON, self).__init__(auth_provider)
@@ -41,8 +41,7 @@
'name': name
}
patch_body = json.dumps({'service': patch_body})
- resp, body = self.patch('services/%s' % service_id,
- patch_body, self.headers)
+ resp, body = self.patch('services/%s' % service_id, patch_body)
body = json.loads(body)
return resp, body['service']
@@ -52,3 +51,21 @@
resp, body = self.get(url)
body = json.loads(body)
return resp, body['service']
+
+ def create_service(self, serv_type, name=None, description=None,
+ enabled=True):
+ body_dict = {
+ "name": name,
+ 'type': serv_type,
+ 'enabled': enabled,
+ "description": description,
+ }
+ body = json.dumps({'service': body_dict})
+ resp, body = self.post("services", body)
+ body = json.loads(body)
+ return resp, body["service"]
+
+ def delete_service(self, serv_id):
+ url = "services/" + serv_id
+ resp, body = self.delete(url)
+ return resp, body
diff --git a/tempest/services/identity/v3/xml/credentials_client.py b/tempest/services/identity/v3/xml/credentials_client.py
index eca86ab..70f85a1 100644
--- a/tempest/services/identity/v3/xml/credentials_client.py
+++ b/tempest/services/identity/v3/xml/credentials_client.py
@@ -17,19 +17,17 @@
from lxml import etree
-from tempest.common.rest_client import RestClientXML
+from tempest.common import rest_client
from tempest import config
-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 import common
CONF = config.CONF
XMLNS = "http://docs.openstack.org/identity/api/v3"
-class CredentialsClientXML(RestClientXML):
+class CredentialsClientXML(rest_client.RestClient):
+ TYPE = "xml"
def __init__(self, auth_provider):
super(CredentialsClientXML, self).__init__(auth_provider)
@@ -38,7 +36,7 @@
self.api_version = "v3"
def _parse_body(self, body):
- data = xml_to_json(body)
+ data = common.xml_to_json(body)
return data
def _parse_creds(self, node):
@@ -46,7 +44,7 @@
for child in node.getchildren():
tag_list = child.tag.split('}', 1)
if tag_list[1] == "credential":
- array.append(xml_to_json(child))
+ array.append(common.xml_to_json(child))
return array
def create_credential(self, access_key, secret_key, user_id, project_id):
@@ -54,15 +52,14 @@
cred_type = 'ec2'
access = ""access": "%s"" % access_key
secret = ""secret": "%s"" % secret_key
- blob = Element('blob',
- xmlns=XMLNS)
- blob.append(Text("{%s , %s}"
- % (access, secret)))
- credential = Element('credential', project_id=project_id,
- type=cred_type, user_id=user_id)
+ blob = common.Element('blob',
+ xmlns=XMLNS)
+ blob.append(common.Text("{%s , %s}"
+ % (access, secret)))
+ credential = common.Element('credential', project_id=project_id,
+ type=cred_type, user_id=user_id)
credential.append(blob)
- resp, body = self.post('credentials', str(Document(credential)),
- self.headers)
+ resp, body = self.post('credentials', str(common.Document(credential)))
body = self._parse_body(etree.fromstring(body))
body['blob'] = json.loads(body['blob'])
return resp, body
@@ -77,35 +74,33 @@
user_id = kwargs.get('user_id', body['user_id'])
access = ""access": "%s"" % access_key
secret = ""secret": "%s"" % secret_key
- blob = Element('blob',
- xmlns=XMLNS)
- blob.append(Text("{%s , %s}"
- % (access, secret)))
- credential = Element('credential', project_id=project_id,
- type=cred_type, user_id=user_id)
+ blob = common.Element('blob',
+ xmlns=XMLNS)
+ blob.append(common.Text("{%s , %s}"
+ % (access, secret)))
+ credential = common.Element('credential', project_id=project_id,
+ type=cred_type, user_id=user_id)
credential.append(blob)
resp, body = self.patch('credentials/%s' % credential_id,
- str(Document(credential)),
- self.headers)
+ str(common.Document(credential)))
body = self._parse_body(etree.fromstring(body))
body['blob'] = json.loads(body['blob'])
return resp, body
def get_credential(self, credential_id):
"""To GET Details of a credential."""
- resp, body = self.get('credentials/%s' % credential_id, self.headers)
+ resp, body = self.get('credentials/%s' % credential_id)
body = self._parse_body(etree.fromstring(body))
body['blob'] = json.loads(body['blob'])
return resp, body
def list_credentials(self):
"""Lists out all the available credentials."""
- resp, body = self.get('credentials', self.headers)
+ resp, body = self.get('credentials')
body = self._parse_creds(etree.fromstring(body))
return resp, body
def delete_credential(self, credential_id):
"""Deletes a credential."""
- resp, body = self.delete('credentials/%s' % credential_id,
- self.headers)
+ resp, body = self.delete('credentials/%s' % credential_id)
return resp, body
diff --git a/tempest/services/identity/v3/xml/endpoints_client.py b/tempest/services/identity/v3/xml/endpoints_client.py
index a20a9f5..a1f9811 100644
--- a/tempest/services/identity/v3/xml/endpoints_client.py
+++ b/tempest/services/identity/v3/xml/endpoints_client.py
@@ -16,18 +16,17 @@
from lxml import etree
from tempest.common import http
-from tempest.common.rest_client import RestClientXML
+from tempest.common import rest_client
from tempest import config
-from tempest.services.compute.xml.common import Document
-from tempest.services.compute.xml.common import Element
-from tempest.services.compute.xml.common import xml_to_json
+from tempest.services.compute.xml import common
CONF = config.CONF
XMLNS = "http://docs.openstack.org/identity/api/v3"
-class EndPointClientXML(RestClientXML):
+class EndPointClientXML(rest_client.RestClient):
+ TYPE = "xml"
def __init__(self, auth_provider):
super(EndPointClientXML, self).__init__(auth_provider)
@@ -40,11 +39,11 @@
for child in node.getchildren():
tag_list = child.tag.split('}', 1)
if tag_list[1] == "endpoint":
- array.append(xml_to_json(child))
+ array.append(common.xml_to_json(child))
return array
def _parse_body(self, body):
- json = xml_to_json(body)
+ json = common.xml_to_json(body)
return json
def request(self, method, url, headers=None, body=None, wait=None):
@@ -58,30 +57,45 @@
def list_endpoints(self):
"""Get the list of endpoints."""
- resp, body = self.get("endpoints", self.headers)
+ resp, body = self.get("endpoints")
body = self._parse_array(etree.fromstring(body))
return resp, body
def create_endpoint(self, service_id, interface, url, **kwargs):
- """Create endpoint."""
+ """Create endpoint.
+
+ Normally this function wouldn't allow setting values that are not
+ allowed for 'enabled'. Use `force_enabled` to set a non-boolean.
+
+ """
region = kwargs.get('region', None)
- enabled = kwargs.get('enabled', None)
- create_endpoint = Element("endpoint",
- xmlns=XMLNS,
- service_id=service_id,
- interface=interface,
- url=url, region=region,
- enabled=enabled)
- resp, body = self.post('endpoints', str(Document(create_endpoint)),
- self.headers)
+ if 'force_enabled' in kwargs:
+ enabled = kwargs['force_enabled']
+ else:
+ enabled = kwargs.get('enabled', None)
+ if enabled is not None:
+ enabled = str(enabled).lower()
+ create_endpoint = common.Element("endpoint",
+ xmlns=XMLNS,
+ service_id=service_id,
+ interface=interface,
+ url=url, region=region,
+ enabled=enabled)
+ resp, body = self.post('endpoints',
+ str(common.Document(create_endpoint)))
body = self._parse_body(etree.fromstring(body))
return resp, body
def update_endpoint(self, endpoint_id, service_id=None, interface=None,
- url=None, region=None, enabled=None):
- """Updates an endpoint with given parameters."""
- doc = Document()
- endpoint = Element("endpoint")
+ url=None, region=None, enabled=None, **kwargs):
+ """Updates an endpoint with given parameters.
+
+ Normally this function wouldn't allow setting values that are not
+ allowed for 'enabled'. Use `force_enabled` to set a non-boolean.
+
+ """
+ doc = common.Document()
+ endpoint = common.Element("endpoint")
doc.append(endpoint)
if service_id:
@@ -92,10 +106,13 @@
endpoint.add_attr("url", url)
if region:
endpoint.add_attr("region", region)
- if enabled is not None:
- endpoint.add_attr("enabled", enabled)
- resp, body = self.patch('endpoints/%s' % str(endpoint_id),
- str(doc), self.headers)
+
+ if 'force_enabled' in kwargs:
+ endpoint.add_attr("enabled", kwargs['force_enabled'])
+ elif enabled is not None:
+ endpoint.add_attr("enabled", str(enabled).lower())
+
+ resp, body = self.patch('endpoints/%s' % str(endpoint_id), str(doc))
body = self._parse_body(etree.fromstring(body))
return resp, body
diff --git a/tempest/services/identity/v3/xml/identity_client.py b/tempest/services/identity/v3/xml/identity_client.py
index e7b85c1..6ff6d56 100644
--- a/tempest/services/identity/v3/xml/identity_client.py
+++ b/tempest/services/identity/v3/xml/identity_client.py
@@ -14,24 +14,21 @@
# under the License.
import json
-import urlparse
from lxml import etree
-from tempest.common.rest_client import RestClientXML
+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 import common
CONF = config.CONF
XMLNS = "http://docs.openstack.org/identity/api/v3"
-class IdentityV3ClientXML(RestClientXML):
+class IdentityV3ClientXML(rest_client.RestClient):
+ TYPE = "xml"
def __init__(self, auth_provider):
super(IdentityV3ClientXML, self).__init__(auth_provider)
@@ -44,7 +41,7 @@
for child in node.getchildren():
tag_list = child.tag.split('}', 1)
if tag_list[1] == "project":
- array.append(xml_to_json(child))
+ array.append(common.xml_to_json(child))
return array
def _parse_domains(self, node):
@@ -52,7 +49,7 @@
for child in node.getchildren():
tag_list = child.tag.split('}', 1)
if tag_list[1] == "domain":
- array.append(xml_to_json(child))
+ array.append(common.xml_to_json(child))
return array
def _parse_group_users(self, node):
@@ -60,7 +57,7 @@
for child in node.getchildren():
tag_list = child.tag.split('}', 1)
if tag_list[1] == "user":
- array.append(xml_to_json(child))
+ array.append(common.xml_to_json(child))
return array
def _parse_roles(self, node):
@@ -68,17 +65,17 @@
for child in node.getchildren():
tag_list = child.tag.split('}', 1)
if tag_list[1] == "role":
- array.append(xml_to_json(child))
+ array.append(common.xml_to_json(child))
return array
def _parse_array(self, node):
array = []
for child in node.getchildren():
- array.append(xml_to_json(child))
+ array.append(common.xml_to_json(child))
return array
def _parse_body(self, body):
- _json = xml_to_json(body)
+ _json = common.xml_to_json(body)
return _json
def create_user(self, user_name, **kwargs):
@@ -89,17 +86,16 @@
project_id = kwargs.get('project_id', None)
description = kwargs.get('description', None)
domain_id = kwargs.get('domain_id', 'default')
- post_body = Element("user",
- xmlns=XMLNS,
- name=user_name,
- password=password,
- description=description,
- email=email,
- enabled=str(en).lower(),
- project_id=project_id,
- domain_id=domain_id)
- resp, body = self.post('users', str(Document(post_body)),
- self.headers)
+ post_body = common.Element("user",
+ xmlns=XMLNS,
+ name=user_name,
+ password=password,
+ description=description,
+ email=email,
+ enabled=str(en).lower(),
+ project_id=project_id,
+ domain_id=domain_id)
+ resp, body = self.post('users', str(common.Document(post_body)))
body = self._parse_body(etree.fromstring(body))
return resp, body
@@ -111,41 +107,40 @@
project_id = kwargs.get('project_id', body['project_id'])
description = kwargs.get('description', body['description'])
domain_id = kwargs.get('domain_id', body['domain_id'])
- update_user = Element("user",
- xmlns=XMLNS,
- name=name,
- email=email,
- project_id=project_id,
- domain_id=domain_id,
- description=description,
- enabled=str(en).lower())
+ update_user = common.Element("user",
+ xmlns=XMLNS,
+ name=name,
+ email=email,
+ project_id=project_id,
+ domain_id=domain_id,
+ description=description,
+ enabled=str(en).lower())
resp, body = self.patch('users/%s' % user_id,
- str(Document(update_user)),
- self.headers)
+ str(common.Document(update_user)))
body = self._parse_body(etree.fromstring(body))
return resp, body
def list_user_projects(self, user_id):
"""Lists the projects on which a user has roles assigned."""
- resp, body = self.get('users/%s/projects' % user_id, self.headers)
+ resp, body = self.get('users/%s/projects' % user_id)
body = self._parse_projects(etree.fromstring(body))
return resp, body
def get_users(self):
"""Get the list of users."""
- resp, body = self.get("users", self.headers)
+ resp, body = self.get("users")
body = self._parse_array(etree.fromstring(body))
return resp, body
def get_user(self, user_id):
"""GET a user."""
- resp, body = self.get("users/%s" % user_id, self.headers)
+ resp, body = self.get("users/%s" % user_id)
body = self._parse_body(etree.fromstring(body))
return resp, body
def delete_user(self, user_id):
"""Deletes a User."""
- resp, body = self.delete("users/%s" % user_id, self.headers)
+ resp, body = self.delete("users/%s" % user_id)
return resp, body
def create_project(self, name, **kwargs):
@@ -153,21 +148,20 @@
description = kwargs.get('description', None)
en = kwargs.get('enabled', 'true')
domain_id = kwargs.get('domain_id', 'default')
- post_body = Element("project",
- xmlns=XMLNS,
- description=description,
- domain_id=domain_id,
- enabled=str(en).lower(),
- name=name)
+ post_body = common.Element("project",
+ xmlns=XMLNS,
+ description=description,
+ domain_id=domain_id,
+ enabled=str(en).lower(),
+ name=name)
resp, body = self.post('projects',
- str(Document(post_body)),
- self.headers)
+ str(common.Document(post_body)))
body = self._parse_body(etree.fromstring(body))
return resp, body
def list_projects(self):
"""Get the list of projects."""
- resp, body = self.get("projects", self.headers)
+ resp, body = self.get("projects")
body = self._parse_projects(etree.fromstring(body))
return resp, body
@@ -178,21 +172,20 @@
desc = kwargs.get('description', body['description'])
en = kwargs.get('enabled', body['enabled'])
domain_id = kwargs.get('domain_id', body['domain_id'])
- post_body = Element("project",
- xmlns=XMLNS,
- name=name,
- description=desc,
- enabled=str(en).lower(),
- domain_id=domain_id)
+ post_body = common.Element("project",
+ xmlns=XMLNS,
+ name=name,
+ description=desc,
+ enabled=str(en).lower(),
+ domain_id=domain_id)
resp, body = self.patch('projects/%s' % project_id,
- str(Document(post_body)),
- self.headers)
+ str(common.Document(post_body)))
body = self._parse_body(etree.fromstring(body))
return resp, body
def get_project(self, project_id):
"""GET a Project."""
- resp, body = self.get("projects/%s" % project_id, self.headers)
+ resp, body = self.get("projects/%s" % project_id)
body = self._parse_body(etree.fromstring(body))
return resp, body
@@ -203,67 +196,62 @@
def create_role(self, name):
"""Create a Role."""
- post_body = Element("role",
- xmlns=XMLNS,
- name=name)
- resp, body = self.post('roles',
- str(Document(post_body)),
- self.headers)
+ post_body = common.Element("role",
+ xmlns=XMLNS,
+ name=name)
+ resp, body = self.post('roles', str(common.Document(post_body)))
body = self._parse_body(etree.fromstring(body))
return resp, body
def get_role(self, role_id):
"""GET a Role."""
- resp, body = self.get('roles/%s' % str(role_id), self.headers)
+ resp, body = self.get('roles/%s' % str(role_id))
body = self._parse_body(etree.fromstring(body))
return resp, body
def update_role(self, name, role_id):
"""Updates a Role."""
- post_body = Element("role",
- xmlns=XMLNS,
- name=name)
+ post_body = common.Element("role",
+ xmlns=XMLNS,
+ name=name)
resp, body = self.patch('roles/%s' % str(role_id),
- str(Document(post_body)),
- self.headers)
+ str(common.Document(post_body)))
body = self._parse_body(etree.fromstring(body))
return resp, body
def delete_role(self, role_id):
"""Delete a role."""
- resp, body = self.delete('roles/%s' % str(role_id),
- self.headers)
+ resp, body = self.delete('roles/%s' % str(role_id))
return resp, body
def assign_user_role(self, project_id, user_id, role_id):
"""Add roles to a user on a tenant."""
resp, body = self.put('projects/%s/users/%s/roles/%s' %
- (project_id, user_id, role_id), '', self.headers)
+ (project_id, user_id, role_id), '')
return resp, body
def create_domain(self, name, **kwargs):
"""Creates a domain."""
description = kwargs.get('description', None)
en = kwargs.get('enabled', True)
- post_body = Element("domain",
- xmlns=XMLNS,
- name=name,
- description=description,
- enabled=str(en).lower())
- resp, body = self.post('domains', str(Document(post_body)),
- self.headers)
+ post_body = common.Element("domain",
+ xmlns=XMLNS,
+ name=name,
+ description=description,
+ enabled=str(en).lower())
+ resp, body = self.post('domains', str(common.Document(post_body)))
body = self._parse_body(etree.fromstring(body))
return resp, body
def list_domains(self):
"""Get the list of domains."""
- resp, body = self.get("domains", self.headers)
+ resp, body = self.get("domains")
body = self._parse_domains(etree.fromstring(body))
return resp, body
def delete_domain(self, domain_id):
"""Delete a domain."""
- resp, body = self.delete('domains/%s' % domain_id, self.headers)
+ resp, body = self.delete('domains/%s' % domain_id)
return resp, body
def update_domain(self, domain_id, **kwargs):
@@ -272,20 +260,19 @@
description = kwargs.get('description', body['description'])
en = kwargs.get('enabled', body['enabled'])
name = kwargs.get('name', body['name'])
- post_body = Element("domain",
- xmlns=XMLNS,
- name=name,
- description=description,
- enabled=str(en).lower())
+ post_body = common.Element("domain",
+ xmlns=XMLNS,
+ name=name,
+ description=description,
+ enabled=str(en).lower())
resp, body = self.patch('domains/%s' % domain_id,
- str(Document(post_body)),
- self.headers)
+ str(common.Document(post_body)))
body = self._parse_body(etree.fromstring(body))
return resp, body
def get_domain(self, domain_id):
"""Get Domain details."""
- resp, body = self.get('domains/%s' % domain_id, self.headers)
+ resp, body = self.get('domains/%s' % domain_id)
body = self._parse_body(etree.fromstring(body))
return resp, body
@@ -309,20 +296,19 @@
description = kwargs.get('description', None)
domain_id = kwargs.get('domain_id', 'default')
project_id = kwargs.get('project_id', None)
- post_body = Element("group",
- xmlns=XMLNS,
- name=name,
- description=description,
- domain_id=domain_id,
- project_id=project_id)
- resp, body = self.post('groups', str(Document(post_body)),
- self.headers)
+ post_body = common.Element("group",
+ xmlns=XMLNS,
+ name=name,
+ description=description,
+ domain_id=domain_id,
+ project_id=project_id)
+ resp, body = self.post('groups', str(common.Document(post_body)))
body = self._parse_body(etree.fromstring(body))
return resp, body
def get_group(self, group_id):
"""Get group details."""
- resp, body = self.get('groups/%s' % group_id, self.headers)
+ resp, body = self.get('groups/%s' % group_id)
body = self._parse_body(etree.fromstring(body))
return resp, body
@@ -331,129 +317,123 @@
resp, body = self.get_group(group_id)
name = kwargs.get('name', body['name'])
description = kwargs.get('description', body['description'])
- post_body = Element("group",
- xmlns=XMLNS,
- name=name,
- description=description)
+ post_body = common.Element("group",
+ xmlns=XMLNS,
+ name=name,
+ description=description)
resp, body = self.patch('groups/%s' % group_id,
- str(Document(post_body)),
- self.headers)
+ str(common.Document(post_body)))
body = self._parse_body(etree.fromstring(body))
return resp, body
def delete_group(self, group_id):
"""Delete a group."""
- resp, body = self.delete('groups/%s' % group_id, self.headers)
+ resp, body = self.delete('groups/%s' % group_id)
return resp, body
def add_group_user(self, group_id, user_id):
"""Add user into group."""
- resp, body = self.put('groups/%s/users/%s' % (group_id, user_id),
- '', self.headers)
+ resp, body = self.put('groups/%s/users/%s' % (group_id, user_id), '')
return resp, body
def list_group_users(self, group_id):
"""List users in group."""
- resp, body = self.get('groups/%s/users' % group_id, self.headers)
+ resp, body = self.get('groups/%s/users' % group_id)
body = self._parse_group_users(etree.fromstring(body))
return resp, body
def delete_group_user(self, group_id, user_id):
"""Delete user in group."""
- resp, body = self.delete('groups/%s/users/%s' % (group_id, user_id),
- self.headers)
+ resp, body = self.delete('groups/%s/users/%s' % (group_id, user_id))
return resp, body
def assign_user_role_on_project(self, project_id, user_id, role_id):
"""Add roles to a user on a project."""
resp, body = self.put('projects/%s/users/%s/roles/%s' %
- (project_id, user_id, role_id), '',
- self.headers)
+ (project_id, user_id, role_id), '')
return resp, body
def assign_user_role_on_domain(self, domain_id, user_id, role_id):
"""Add roles to a user on a domain."""
resp, body = self.put('domains/%s/users/%s/roles/%s' %
- (domain_id, user_id, role_id), '',
- self.headers)
+ (domain_id, user_id, role_id), '')
return resp, body
def list_user_roles_on_project(self, project_id, user_id):
"""list roles of a user on a project."""
resp, body = self.get('projects/%s/users/%s/roles' %
- (project_id, user_id), self.headers)
+ (project_id, user_id))
body = self._parse_roles(etree.fromstring(body))
return resp, body
def list_user_roles_on_domain(self, domain_id, user_id):
"""list roles of a user on a domain."""
resp, body = self.get('domains/%s/users/%s/roles' %
- (domain_id, user_id), self.headers)
+ (domain_id, user_id))
body = self._parse_roles(etree.fromstring(body))
return resp, body
def revoke_role_from_user_on_project(self, project_id, user_id, role_id):
"""Delete role of a user on a project."""
resp, body = self.delete('projects/%s/users/%s/roles/%s' %
- (project_id, user_id, role_id), self.headers)
+ (project_id, user_id, role_id))
return resp, body
def revoke_role_from_user_on_domain(self, domain_id, user_id, role_id):
"""Delete role of a user on a domain."""
resp, body = self.delete('domains/%s/users/%s/roles/%s' %
- (domain_id, user_id, role_id), self.headers)
+ (domain_id, user_id, role_id))
return resp, body
def assign_group_role_on_project(self, project_id, group_id, role_id):
"""Add roles to a user on a project."""
resp, body = self.put('projects/%s/groups/%s/roles/%s' %
- (project_id, group_id, role_id), '',
- self.headers)
+ (project_id, group_id, role_id), '')
return resp, body
def assign_group_role_on_domain(self, domain_id, group_id, role_id):
"""Add roles to a user on a domain."""
resp, body = self.put('domains/%s/groups/%s/roles/%s' %
- (domain_id, group_id, role_id), '',
- self.headers)
+ (domain_id, group_id, role_id), '')
return resp, body
def list_group_roles_on_project(self, project_id, group_id):
"""list roles of a user on a project."""
resp, body = self.get('projects/%s/groups/%s/roles' %
- (project_id, group_id), self.headers)
+ (project_id, group_id))
body = self._parse_roles(etree.fromstring(body))
return resp, body
def list_group_roles_on_domain(self, domain_id, group_id):
"""list roles of a user on a domain."""
resp, body = self.get('domains/%s/groups/%s/roles' %
- (domain_id, group_id), self.headers)
+ (domain_id, group_id))
body = self._parse_roles(etree.fromstring(body))
return resp, body
def revoke_role_from_group_on_project(self, project_id, group_id, role_id):
"""Delete role of a user on a project."""
resp, body = self.delete('projects/%s/groups/%s/roles/%s' %
- (project_id, group_id, role_id), self.headers)
+ (project_id, group_id, role_id))
return resp, body
def revoke_role_from_group_on_domain(self, domain_id, group_id, role_id):
"""Delete role of a user on a domain."""
resp, body = self.delete('domains/%s/groups/%s/roles/%s' %
- (domain_id, group_id, role_id), self.headers)
+ (domain_id, group_id, role_id))
return resp, body
-class V3TokenClientXML(RestClientXML):
+class V3TokenClientXML(rest_client.RestClient):
+ TYPE = "xml"
def __init__(self):
super(V3TokenClientXML, self).__init__(None)
auth_url = CONF.identity.uri_v3
- # If the v3 url is not set, get it from the v2 one
- if auth_url is None:
- auth_url = CONF.identity.uri.replace(urlparse.urlparse(
- CONF.identity.uri).path, "/v3")
+ if not auth_url and CONF.identity_feature_enabled.api_v3:
+ raise exceptions.InvalidConfiguration('you must specify a v3 uri '
+ 'if using the v3 identity '
+ 'api')
if 'auth/tokens' not in auth_url:
auth_url = auth_url.rstrip('/') + '/auth/tokens'
@@ -473,43 +453,44 @@
Validation is left to the server side.
"""
if user_type == 'id':
- _user = Element('user', id=user, password=password)
+ _user = common.Element('user', id=user, password=password)
else:
- _user = Element('user', name=user, password=password)
+ _user = common.Element('user', name=user, password=password)
if domain is not None:
- _domain = Element('domain', name=domain)
+ _domain = common.Element('domain', name=domain)
_user.append(_domain)
- password = Element('password')
+ password = common.Element('password')
password.append(_user)
- method = Element('method')
- method.append(Text('password'))
- methods = Element('methods')
+ method = common.Element('method')
+ method.append(common.Text('password'))
+ methods = common.Element('methods')
methods.append(method)
- identity = Element('identity')
+ identity = common.Element('identity')
identity.append(methods)
identity.append(password)
- auth = Element('auth')
+ auth = common.Element('auth')
auth.append(identity)
if tenant is not None:
- project = Element('project', name=tenant)
+ project = common.Element('project', name=tenant)
project.append(_domain)
- scope = Element('scope')
+ scope = common.Element('scope')
scope.append(project)
auth.append(scope)
- resp, body = self.post(self.auth_url, headers=self.headers,
- body=str(Document(auth)))
+ resp, body = self.post(self.auth_url, body=str(common.Document(auth)))
return resp, body
def request(self, method, url, headers=None, body=None):
"""A simple HTTP request interface."""
- # Send XML, accept JSON. XML response is not easily
- # converted to the corresponding JSON one
- headers['Accept'] = 'application/json'
+ if headers is None:
+ # Always accept 'json', for xml token client too.
+ # Because XML response is not easily
+ # converted to the corresponding JSON one
+ headers = self.get_headers(accept_type="json")
self._log_request(method, url, headers, body)
resp, resp_body = self.http_obj.request(url, method,
headers=headers, body=body)
diff --git a/tempest/services/identity/v3/xml/policy_client.py b/tempest/services/identity/v3/xml/policy_client.py
index 429c6a4..bf4cce7 100644
--- a/tempest/services/identity/v3/xml/policy_client.py
+++ b/tempest/services/identity/v3/xml/policy_client.py
@@ -16,18 +16,17 @@
from lxml import etree
from tempest.common import http
-from tempest.common.rest_client import RestClientXML
+from tempest.common import rest_client
from tempest import config
-from tempest.services.compute.xml.common import Document
-from tempest.services.compute.xml.common import Element
-from tempest.services.compute.xml.common import xml_to_json
+from tempest.services.compute.xml import common
CONF = config.CONF
XMLNS = "http://docs.openstack.org/identity/api/v3"
-class PolicyClientXML(RestClientXML):
+class PolicyClientXML(rest_client.RestClient):
+ TYPE = "xml"
def __init__(self, auth_provider):
super(PolicyClientXML, self).__init__(auth_provider)
@@ -40,11 +39,11 @@
for child in node.getchildren():
tag_list = child.tag.split('}', 1)
if tag_list[1] == "policy":
- array.append(xml_to_json(child))
+ array.append(common.xml_to_json(child))
return array
def _parse_body(self, body):
- json = xml_to_json(body)
+ json = common.xml_to_json(body)
return json
def request(self, method, url, headers=None, body=None, wait=None):
@@ -58,22 +57,22 @@
def create_policy(self, blob, type):
"""Creates a Policy."""
- create_policy = Element("policy", xmlns=XMLNS, blob=blob, type=type)
- resp, body = self.post('policies', str(Document(create_policy)),
- self.headers)
+ create_policy = common.Element("policy", xmlns=XMLNS,
+ blob=blob, type=type)
+ resp, body = self.post('policies', str(common.Document(create_policy)))
body = self._parse_body(etree.fromstring(body))
return resp, body
def list_policies(self):
"""Lists the policies."""
- resp, body = self.get('policies', self.headers)
+ resp, body = self.get('policies')
body = self._parse_array(etree.fromstring(body))
return resp, body
def get_policy(self, policy_id):
"""Lists out the given policy."""
url = 'policies/%s' % policy_id
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
body = self._parse_body(etree.fromstring(body))
return resp, body
@@ -81,10 +80,9 @@
"""Updates a policy."""
resp, body = self.get_policy(policy_id)
type = kwargs.get('type')
- update_policy = Element("policy", xmlns=XMLNS, type=type)
+ update_policy = common.Element("policy", xmlns=XMLNS, type=type)
url = 'policies/%s' % policy_id
- resp, body = self.patch(url, str(Document(update_policy)),
- self.headers)
+ resp, body = self.patch(url, str(common.Document(update_policy)))
body = self._parse_body(etree.fromstring(body))
return resp, body
diff --git a/tempest/services/identity/v3/xml/service_client.py b/tempest/services/identity/v3/xml/service_client.py
index df9b234..966d7f7 100644
--- a/tempest/services/identity/v3/xml/service_client.py
+++ b/tempest/services/identity/v3/xml/service_client.py
@@ -15,18 +15,17 @@
from lxml import etree
-from tempest.common.rest_client import RestClientXML
+from tempest.common import rest_client
from tempest import config
-from tempest.services.compute.xml.common import Document
-from tempest.services.compute.xml.common import Element
-from tempest.services.compute.xml.common import xml_to_json
+from tempest.services.compute.xml import common
CONF = config.CONF
XMLNS = "http://docs.openstack.org/identity/api/v3"
-class ServiceClientXML(RestClientXML):
+class ServiceClientXML(rest_client.RestClient):
+ TYPE = "xml"
def __init__(self, auth_provider):
super(ServiceClientXML, self).__init__(auth_provider)
@@ -34,14 +33,8 @@
self.endpoint_url = 'adminURL'
self.api_version = "v3"
- def _parse_array(self, node):
- array = []
- for child in node.getchildren():
- array.append(xml_to_json(child))
- return array
-
def _parse_body(self, body):
- data = xml_to_json(body)
+ data = common.xml_to_json(body)
return data
def update_service(self, service_id, **kwargs):
@@ -50,21 +43,35 @@
name = kwargs.get('name', body['name'])
description = kwargs.get('description', body['description'])
type = kwargs.get('type', body['type'])
- update_service = Element("service",
- xmlns=XMLNS,
- id=service_id,
- name=name,
- description=description,
- type=type)
+ update_service = common.Element("service",
+ xmlns=XMLNS,
+ id=service_id,
+ name=name,
+ description=description,
+ type=type)
resp, body = self.patch('services/%s' % service_id,
- str(Document(update_service)),
- self.headers)
+ str(common.Document(update_service)))
body = self._parse_body(etree.fromstring(body))
return resp, body
def get_service(self, service_id):
"""Get Service."""
url = 'services/%s' % service_id
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
body = self._parse_body(etree.fromstring(body))
return resp, body
+
+ def create_service(self, serv_type, name=None, description=None):
+ post_body = common.Element("service",
+ xmlns=XMLNS,
+ name=name,
+ description=description,
+ type=serv_type)
+ resp, body = self.post("services", str(common.Document(post_body)))
+ body = self._parse_body(etree.fromstring(body))
+ return resp, body
+
+ def delete_service(self, serv_id):
+ url = "services/" + serv_id
+ resp, body = self.delete(url)
+ return resp, body
diff --git a/tempest/services/identity/xml/identity_client.py b/tempest/services/identity/xml/identity_client.py
index 7c36680..c5bf310 100644
--- a/tempest/services/identity/xml/identity_client.py
+++ b/tempest/services/identity/xml/identity_client.py
@@ -12,58 +12,24 @@
# 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 lxml import etree
-
-from tempest.common.rest_client import RestClientXML
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 xml_to_json
+from tempest.services.compute.xml import common as xml
+from tempest.services.identity.json import identity_client
CONF = config.CONF
XMLNS = "http://docs.openstack.org/identity/api/v2.0"
-class IdentityClientXML(RestClientXML):
-
- def __init__(self, auth_provider):
- super(IdentityClientXML, self).__init__(auth_provider)
- self.service = CONF.identity.catalog_type
- self.endpoint_url = 'adminURL'
-
- def _parse_array(self, node):
- array = []
- for child in node.getchildren():
- array.append(xml_to_json(child))
- return array
-
- def _parse_body(self, body):
- data = xml_to_json(body)
- return data
-
- def has_admin_extensions(self):
- """
- Returns True if the KSADM Admin Extensions are supported
- False otherwise
- """
- if hasattr(self, '_has_admin_extensions'):
- return self._has_admin_extensions
- resp, body = self.list_roles()
- self._has_admin_extensions = ('status' in resp and resp.status != 503)
- return self._has_admin_extensions
+class IdentityClientXML(identity_client.IdentityClientJSON):
+ TYPE = "xml"
def create_role(self, name):
"""Create a role."""
- create_role = Element("role", xmlns=XMLNS, name=name)
- resp, body = self.post('OS-KSADM/roles', str(Document(create_role)),
- self.headers)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
+ create_role = xml.Element("role", xmlns=XMLNS, name=name)
+ resp, body = self.post('OS-KSADM/roles',
+ str(xml.Document(create_role)))
+ return resp, self._parse_resp(body)
def create_tenant(self, name, **kwargs):
"""
@@ -73,70 +39,18 @@
enabled <true|false>: Initial tenant status (default is true)
"""
en = kwargs.get('enabled', 'true')
- create_tenant = Element("tenant",
- xmlns=XMLNS,
- name=name,
- description=kwargs.get('description', ''),
- enabled=str(en).lower())
- resp, body = self.post('tenants', str(Document(create_tenant)),
- self.headers)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def delete_role(self, role_id):
- """Delete a role."""
- resp, body = self.delete('OS-KSADM/roles/%s' % str(role_id),
- self.headers)
- return resp, body
-
- def list_user_roles(self, tenant_id, user_id):
- """Returns a list of roles assigned to a user for a tenant."""
- url = '/tenants/%s/users/%s/roles' % (tenant_id, user_id)
- resp, body = self.get(url, self.headers)
- body = self._parse_array(etree.fromstring(body))
- return resp, body
-
- def assign_user_role(self, tenant_id, user_id, role_id):
- """Add roles to a user on a tenant."""
- resp, body = self.put('/tenants/%s/users/%s/roles/OS-KSADM/%s' %
- (tenant_id, user_id, role_id), '', self.headers)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def remove_user_role(self, tenant_id, user_id, role_id):
- """Removes a role assignment for a user on a tenant."""
- return self.delete('/tenants/%s/users/%s/roles/OS-KSADM/%s' %
- (tenant_id, user_id, role_id), self.headers)
-
- def delete_tenant(self, tenant_id):
- """Delete a tenant."""
- resp, body = self.delete('tenants/%s' % str(tenant_id), self.headers)
- return resp, body
-
- def get_tenant(self, tenant_id):
- """Get tenant details."""
- resp, body = self.get('tenants/%s' % str(tenant_id), self.headers)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def list_roles(self):
- """Returns roles."""
- resp, body = self.get('OS-KSADM/roles', self.headers)
- body = self._parse_array(etree.fromstring(body))
- return resp, body
+ create_tenant = xml.Element("tenant",
+ xmlns=XMLNS,
+ name=name,
+ description=kwargs.get('description', ''),
+ enabled=str(en).lower())
+ resp, body = self.post('tenants', str(xml.Document(create_tenant)))
+ return resp, self._parse_resp(body)
def list_tenants(self):
"""Returns tenants."""
- resp, body = self.get('tenants', self.headers)
- body = self._parse_array(etree.fromstring(body))
- return resp, body
-
- def get_tenant_by_name(self, tenant_name):
- resp, tenants = self.list_tenants()
- for tenant in tenants:
- if tenant['name'] == tenant_name:
- return tenant
- raise exceptions.NotFound('No such tenant')
+ resp, body = self.get('tenants')
+ return resp, self._parse_resp(body)
def update_tenant(self, tenant_id, **kwargs):
"""Updates a tenant."""
@@ -144,173 +58,83 @@
name = kwargs.get('name', body['name'])
desc = kwargs.get('description', body['description'])
en = kwargs.get('enabled', body['enabled'])
- update_tenant = Element("tenant",
- xmlns=XMLNS,
- id=tenant_id,
- name=name,
- description=desc,
- enabled=str(en).lower())
+ update_tenant = xml.Element("tenant",
+ xmlns=XMLNS,
+ id=tenant_id,
+ name=name,
+ description=desc,
+ enabled=str(en).lower())
resp, body = self.post('tenants/%s' % tenant_id,
- str(Document(update_tenant)),
- self.headers)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
+ str(xml.Document(update_tenant)))
+ return resp, self._parse_resp(body)
def create_user(self, name, password, tenant_id, email, **kwargs):
"""Create a user."""
- create_user = Element("user",
- xmlns=XMLNS,
- name=name,
- password=password,
- tenantId=tenant_id,
- email=email)
+ create_user = xml.Element("user",
+ xmlns=XMLNS,
+ name=name,
+ password=password,
+ email=email)
+ if tenant_id:
+ create_user.add_attr('tenantId', tenant_id)
if 'enabled' in kwargs:
create_user.add_attr('enabled', str(kwargs['enabled']).lower())
- resp, body = self.post('users', str(Document(create_user)),
- self.headers)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
+ resp, body = self.post('users', str(xml.Document(create_user)))
+ return resp, self._parse_resp(body)
def update_user(self, user_id, **kwargs):
"""Updates a user."""
if 'enabled' in kwargs:
kwargs['enabled'] = str(kwargs['enabled']).lower()
- update_user = Element("user", xmlns=XMLNS, **kwargs)
+ update_user = xml.Element("user", xmlns=XMLNS, **kwargs)
resp, body = self.put('users/%s' % user_id,
- str(Document(update_user)),
- self.headers)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def get_user(self, user_id):
- """GET a user."""
- resp, body = self.get("users/%s" % user_id, self.headers)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def delete_user(self, user_id):
- """Delete a user."""
- resp, body = self.delete("users/%s" % user_id, self.headers)
- return resp, body
-
- def get_users(self):
- """Get the list of users."""
- resp, body = self.get("users", self.headers)
- body = self._parse_array(etree.fromstring(body))
- return resp, body
+ str(xml.Document(update_user)))
+ return resp, self._parse_resp(body)
def enable_disable_user(self, user_id, enabled):
"""Enables or disables a user."""
- enable_user = Element("user", enabled=str(enabled).lower())
+ enable_user = xml.Element("user", enabled=str(enabled).lower())
resp, body = self.put('users/%s/enabled' % user_id,
- str(Document(enable_user)), self.headers)
- body = self._parse_array(etree.fromstring(body))
- return resp, body
+ str(xml.Document(enable_user)))
+ return resp, self._parse_resp(body)
- def delete_token(self, token_id):
- """Delete a token."""
- resp, body = self.delete("tokens/%s" % token_id, self.headers)
- return resp, body
-
- def list_users_for_tenant(self, tenant_id):
- """List users for a Tenant."""
- resp, body = self.get('/tenants/%s/users' % tenant_id, self.headers)
- body = self._parse_array(etree.fromstring(body))
- return resp, body
-
- def get_user_by_username(self, tenant_id, username):
- resp, users = self.list_users_for_tenant(tenant_id)
- for user in users:
- if user['name'] == username:
- return user
- raise exceptions.NotFound('No such user')
-
- def create_service(self, name, type, **kwargs):
+ def create_service(self, name, service_type, **kwargs):
"""Create a service."""
OS_KSADM = "http://docs.openstack.org/identity/api/ext/OS-KSADM/v1.0"
- create_service = Element("service",
- xmlns=OS_KSADM,
- name=name,
- type=type,
- description=kwargs.get('description'))
+ create_service = xml.Element("service",
+ xmlns=OS_KSADM,
+ name=name,
+ type=service_type,
+ description=kwargs.get('description'))
resp, body = self.post('OS-KSADM/services',
- str(Document(create_service)),
- self.headers)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def list_services(self):
- """Returns services."""
- resp, body = self.get('OS-KSADM/services', self.headers)
- body = self._parse_array(etree.fromstring(body))
- return resp, body
-
- def get_service(self, service_id):
- """Get Service."""
- url = '/OS-KSADM/services/%s' % service_id
- resp, body = self.get(url, self.headers)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def delete_service(self, service_id):
- """Delete Service."""
- url = '/OS-KSADM/services/%s' % service_id
- return self.delete(url, self.headers)
+ str(xml.Document(create_service)))
+ return resp, self._parse_resp(body)
-class TokenClientXML(RestClientXML):
+class TokenClientXML(identity_client.TokenClientJSON):
+ TYPE = "xml"
- def __init__(self):
- super(TokenClientXML, self).__init__(None)
- auth_url = CONF.identity.uri
-
- # Normalize URI to ensure /tokens is in it.
- if 'tokens' not in auth_url:
- auth_url = auth_url.rstrip('/') + '/tokens'
-
- self.auth_url = auth_url
-
- def auth(self, user, password, tenant):
- passwordCreds = Element("passwordCredentials",
- username=user,
- password=password)
- auth = Element("auth", tenantName=tenant)
+ def auth(self, user, password, tenant=None):
+ passwordCreds = xml.Element('passwordCredentials',
+ username=user,
+ password=password)
+ auth_kwargs = {}
+ if tenant:
+ auth_kwargs['tenantName'] = tenant
+ auth = xml.Element('auth', **auth_kwargs)
auth.append(passwordCreds)
- resp, body = self.post(self.auth_url, headers=self.headers,
- body=str(Document(auth)))
+ resp, body = self.post(self.auth_url, body=str(xml.Document(auth)))
return resp, body['access']
- def request(self, method, url, headers=None, body=None):
- """A simple HTTP request interface."""
- if headers is None:
- headers = {}
- # Send XML, accept JSON. XML response is not easily
- # converted to the corresponding JSON one
- headers['Accept'] = 'application/json'
- self._log_request(method, url, headers, body)
- resp, resp_body = self.http_obj.request(url, method,
- headers=headers, body=body)
- self._log_response(resp, resp_body)
-
- if resp.status in [401, 403]:
- resp_body = json.loads(resp_body)
- raise exceptions.Unauthorized(resp_body['error']['message'])
- elif resp.status not in [200, 201]:
- raise exceptions.IdentityError(
- 'Unexpected status code {0}'.format(resp.status))
-
- return resp, json.loads(resp_body)
-
- def get_token(self, user, password, tenant, auth_data=False):
- """
- Returns (token id, token data) for supplied credentials
- """
- resp, body = self.auth(user, password, tenant)
-
- if auth_data:
- return body['token']['id'], body
- else:
- return body['token']['id']
+ def auth_token(self, token_id, tenant=None):
+ tokenCreds = xml.Element('token', id=token_id)
+ auth_kwargs = {}
+ if tenant:
+ auth_kwargs['tenantName'] = tenant
+ auth = xml.Element('auth', **auth_kwargs)
+ auth.append(tokenCreds)
+ resp, body = self.post(self.auth_url, body=str(xml.Document(auth)))
+ return resp, body['access']
diff --git a/tempest/services/image/v1/json/image_client.py b/tempest/services/image/v1/json/image_client.py
index 17271cc..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,11 +31,11 @@
LOG = logging.getLogger(__name__)
-class ImageClientJSON(RestClient):
+class ImageClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
super(ImageClientJSON, self).__init__(auth_provider)
- self.service = CONF.images.catalog_type
+ self.service = CONF.image.catalog_type
self._http = None
def _image_meta_from_headers(self, headers):
@@ -157,7 +157,7 @@
return resp, body['image']
def update_image(self, image_id, name=None, container_format=None,
- data=None):
+ data=None, properties=None):
params = {}
headers = {}
if name is not None:
@@ -166,6 +166,9 @@
if container_format is not None:
params['container_format'] = container_format
+ if properties is not None:
+ params['properties'] = properties
+
headers.update(self._image_meta_to_headers(params))
if data is not None:
@@ -190,7 +193,8 @@
body = json.loads(body)
return resp, body['images']
- def image_list_detail(self, properties=dict(), **kwargs):
+ def image_list_detail(self, properties=dict(), changes_since=None,
+ **kwargs):
url = 'v1/images/detail'
params = {}
@@ -199,6 +203,9 @@
kwargs.update(params)
+ if changes_since is not None:
+ kwargs['changes-since'] = changes_since
+
if len(kwargs) > 0:
url += '?%s' % urllib.urlencode(kwargs)
@@ -241,7 +248,7 @@
body = None
if can_share:
body = json.dumps({'member': {'can_share': True}})
- resp, __ = self.put(url, body, self.headers)
+ resp, __ = self.put(url, body)
return resp
def delete_member(self, member_id, image_id):
@@ -252,7 +259,7 @@
def replace_membership_list(self, image_id, member_list):
url = 'v1/images/%s/members' % image_id
body = json.dumps({'membership': member_list})
- resp, data = self.put(url, body, self.headers)
+ resp, data = self.put(url, body)
data = json.loads(data)
return resp, data
diff --git a/tempest/services/image/v2/json/image_client.py b/tempest/services/image/v2/json/image_client.py
index 38aef2d..b3014fc 100644
--- a/tempest/services/image/v2/json/image_client.py
+++ b/tempest/services/image/v2/json/image_client.py
@@ -30,7 +30,7 @@
def __init__(self, auth_provider):
super(ImageClientV2JSON, self).__init__(auth_provider)
- self.service = CONF.images.catalog_type
+ self.service = CONF.image.catalog_type
self._http = None
def _get_http(self):
@@ -39,23 +39,9 @@
filters=self.filters,
insecure=dscv)
- def get_images_schema(self):
- url = 'v2/schemas/images'
- resp, body = self.get(url)
- body = json.loads(body)
- return resp, body
-
- def get_image_schema(self):
- url = 'v2/schemas/image'
- resp, body = self.get(url)
- body = json.loads(body)
- return resp, body
-
def _validate_schema(self, body, type='image'):
- if type == 'image':
- resp, schema = self.get_image_schema()
- elif type == 'images':
- resp, schema = self.get_images_schema()
+ if type in ['image', 'images']:
+ resp, schema = self.get_schema(type)
else:
raise ValueError("%s is not a valid schema type" % type)
@@ -68,6 +54,15 @@
self._http = self._get_http()
return self._http
+ def update_image(self, image_id, patch):
+ data = json.dumps(patch)
+ self._validate_schema(data)
+
+ headers = {"Content-Type": "application/openstack-images-v2.0"
+ "-json-patch"}
+ resp, body = self.patch('v2/images/%s' % image_id, data, headers)
+ return resp, self._parse_resp(body)
+
def create_image(self, name, container_format, disk_format, **kwargs):
params = {
"name": name,
@@ -86,7 +81,7 @@
data = json.dumps(params)
self._validate_schema(data)
- resp, body = self.post('v2/images', data, self.headers)
+ resp, body = self.post('v2/images', data)
body = json.loads(body)
return resp, body
@@ -132,7 +127,7 @@
def add_image_tag(self, image_id, tag):
url = 'v2/images/%s/tags/%s' % (image_id, tag)
- resp, body = self.put(url, body=None, headers=self.headers)
+ resp, body = self.put(url, body=None)
return resp, body
def delete_image_tag(self, image_id, tag):
@@ -150,7 +145,7 @@
def add_member(self, image_id, member_id):
url = 'v2/images/%s/members' % image_id
data = json.dumps({'member': member_id})
- resp, body = self.post(url, data, self.headers)
+ resp, body = self.post(url, data)
body = json.loads(body)
self.expected_success(200, resp)
return resp, body
@@ -159,7 +154,25 @@
"""Valid status are: ``pending``, ``accepted``, ``rejected``."""
url = 'v2/images/%s/members/%s' % (image_id, member_id)
data = json.dumps({'status': status})
- resp, body = self.put(url, data, self.headers)
+ resp, body = self.put(url, data)
body = json.loads(body)
self.expected_success(200, resp)
return resp, body
+
+ def get_member(self, image_id, member_id):
+ url = 'v2/images/%s/members/%s' % (image_id, member_id)
+ resp, body = self.get(url)
+ self.expected_success(200, resp)
+ return resp, json.loads(body)
+
+ def remove_member(self, image_id, member_id):
+ url = 'v2/images/%s/members/%s' % (image_id, member_id)
+ resp, _ = self.delete(url)
+ self.expected_success(204, resp)
+ return resp
+
+ def get_schema(self, schema):
+ url = 'v2/schemas/%s' % schema
+ resp, body = self.get(url)
+ body = json.loads(body)
+ return resp, body
diff --git a/tempest/services/network/json/network_client.py b/tempest/services/network/json/network_client.py
index 1458c7b..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)
@@ -154,20 +154,6 @@
body = json.loads(body)
return resp, body
- def create_security_group(self, name, **kwargs):
- post_body = {
- 'security_group': {
- 'name': name,
- }
- }
- for key, value in kwargs.iteritems():
- post_body['security_group'][str(key)] = value
- body = json.dumps(post_body)
- uri = '%s/security-groups' % (self.uri_prefix)
- resp, body = self.post(uri, body)
- body = json.loads(body)
- return resp, body
-
def update_floating_ip(self, floating_ip_id, **kwargs):
post_body = {
'floatingip': kwargs}
@@ -177,103 +163,6 @@
body = json.loads(body)
return resp, body
- def create_security_group_rule(self, secgroup_id,
- direction='ingress', **kwargs):
- post_body = {
- 'security_group_rule': {
- 'direction': direction,
- 'security_group_id': secgroup_id
- }
- }
- for key, value in kwargs.iteritems():
- post_body['security_group_rule'][str(key)] = value
- body = json.dumps(post_body)
- uri = '%s/security-group-rules' % (self.uri_prefix)
- resp, body = self.post(uri, body)
- body = json.loads(body)
- return resp, body
-
- def create_vip(self, name, protocol, protocol_port, subnet_id, pool_id):
- post_body = {
- "vip": {
- "protocol": protocol,
- "name": name,
- "subnet_id": subnet_id,
- "pool_id": pool_id,
- "protocol_port": protocol_port
- }
- }
- body = json.dumps(post_body)
- uri = '%s/lb/vips' % (self.uri_prefix)
- resp, body = self.post(uri, body)
- body = json.loads(body)
- return resp, body
-
- def update_vip(self, vip_id, new_name):
- put_body = {
- "vip": {
- "name": new_name,
- }
- }
- body = json.dumps(put_body)
- uri = '%s/lb/vips/%s' % (self.uri_prefix, vip_id)
- resp, body = self.put(uri, body)
- 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 create_health_monitor(self, delay, max_retries, Type, timeout):
- post_body = {
- "health_monitor": {
- "delay": delay,
- "max_retries": max_retries,
- "type": Type,
- "timeout": timeout
- }
- }
- body = json.dumps(post_body)
- uri = '%s/lb/health_monitors' % (self.uri_prefix)
- resp, body = self.post(uri, body)
- body = json.loads(body)
- return resp, body
-
- def update_health_monitor(self, admin_state_up, uuid):
- put_body = {
- "health_monitor": {
- "admin_state_up": admin_state_up
- }
- }
- body = json.dumps(put_body)
- uri = '%s/lb/health_monitors/%s' % (self.uri_prefix, uuid)
- 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 = {
@@ -340,6 +229,19 @@
body = json.loads(body)
return resp, body
+ def list_pools_hosted_by_one_lbaas_agent(self, agent_id):
+ uri = '%s/agents/%s/loadbalancer-pools' % (self.uri_prefix, agent_id)
+ resp, body = self.get(uri)
+ body = json.loads(body)
+ return resp, body
+
+ def show_lbaas_agent_hosting_pool(self, pool_id):
+ uri = ('%s/lb/pools/%s/loadbalancer-agent' %
+ (self.uri_prefix, pool_id))
+ resp, body = self.get(uri)
+ body = json.loads(body)
+ return resp, body
+
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)
@@ -352,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)
@@ -417,3 +333,9 @@
resp, body = self.put(uri, body)
body = json.loads(body)
return resp, body
+
+ def list_lb_pool_stats(self, pool_id):
+ uri = '%s/lb/pools/%s/stats' % (self.uri_prefix, pool_id)
+ resp, body = self.get(uri)
+ body = json.loads(body)
+ return resp, body
diff --git a/tempest/services/network/network_client_base.py b/tempest/services/network/network_client_base.py
index 96b9b1d..41a7aa4 100644
--- a/tempest/services/network/network_client_base.py
+++ b/tempest/services/network/network_client_base.py
@@ -10,9 +10,11 @@
# License for the specific language governing permissions and limitations
# under the License.
+import time
import urllib
from tempest import config
+from tempest import exceptions
CONF = config.CONF
@@ -27,7 +29,9 @@
'health_monitors': 'lb',
'members': 'lb',
'vpnservices': 'vpn',
- 'ikepolicies': 'vpn'
+ 'ikepolicies': 'vpn',
+ 'metering_labels': 'metering',
+ 'metering_label_rules': 'metering'
}
# The following list represents resource names that do not require
@@ -52,24 +56,22 @@
self.rest_client.service = CONF.network.catalog_type
self.version = '2.0'
self.uri_prefix = "v%s" % (self.version)
+ self.build_timeout = CONF.network.build_timeout
+ self.build_interval = CONF.network.build_interval
def get_rest_client(self, auth_provider):
raise NotImplementedError
def post(self, uri, body, headers=None):
- headers = headers or self.rest_client.headers
return self.rest_client.post(uri, body, headers)
def put(self, uri, body, headers=None):
- headers = headers or self.rest_client.headers
return self.rest_client.put(uri, body, headers)
def get(self, uri, headers=None):
- headers = headers or self.rest_client.headers
return self.rest_client.get(uri, headers)
def delete(self, uri, headers=None):
- headers = headers or self.rest_client.headers
return self.rest_client.delete(uri, headers)
def deserialize_list(self, body):
@@ -115,9 +117,14 @@
return _delete
def _shower(self, resource_name):
- def _show(resource_id):
+ def _show(resource_id, field_list=[]):
+ # field_list is a sequence of two-element tuples, with the
+ # first element being 'fields'. An example:
+ # [('fields', 'id'), ('fields', 'name')]
plural = self.pluralize(resource_name)
uri = '%s/%s' % (self.get_uri(plural), resource_id)
+ if field_list:
+ uri += '?' + urllib.urlencode(field_list)
resp, body = self.get(uri)
body = self.deserialize_single(body)
return resp, body
@@ -186,3 +193,23 @@
resp, body = self.post(uri, body)
body = {'ports': self.deserialize_list(body)}
return resp, body
+
+ def wait_for_resource_deletion(self, resource_type, id):
+ """Waits for a resource to be deleted."""
+ start_time = int(time.time())
+ while True:
+ if self.is_resource_deleted(resource_type, id):
+ return
+ if int(time.time()) - start_time >= self.build_timeout:
+ raise exceptions.TimeoutException
+ time.sleep(self.build_interval)
+
+ def is_resource_deleted(self, resource_type, id):
+ method = 'show_' + resource_type
+ try:
+ getattr(self, method)(id)
+ except AttributeError:
+ raise Exception("Unknown resource type %s " % resource_type)
+ except exceptions.NotFound:
+ return True
+ return False
diff --git a/tempest/services/network/xml/network_client.py b/tempest/services/network/xml/network_client.py
index 720c842..2a5083c 100644
--- a/tempest/services/network/xml/network_client.py
+++ b/tempest/services/network/xml/network_client.py
@@ -13,32 +13,26 @@
from lxml import etree
import xml.etree.ElementTree as ET
-from tempest.common.rest_client import RestClientXML
-from tempest.services.compute.xml.common import deep_dict_to_xml
-from tempest.services.compute.xml.common import Document
-from tempest.services.compute.xml.common import Element
-from tempest.services.compute.xml.common import parse_array
-from tempest.services.compute.xml.common import xml_to_json
+from tempest.common import rest_client
+from tempest.services.compute.xml import common
from tempest.services.network import network_client_base as client_base
class NetworkClientXML(client_base.NetworkClientBase):
+ TYPE = "xml"
# list of plurals used for xml serialization
PLURALS = ['dns_nameservers', 'host_routes', 'allocation_pools',
- 'fixed_ips', 'extensions']
+ 'fixed_ips', 'extensions', 'extra_dhcp_opts', 'pools',
+ 'health_monitors', 'vips']
def get_rest_client(self, auth_provider):
- return RestClientXML(auth_provider)
-
- def _parse_array(self, node):
- array = []
- for child in node.getchildren():
- array.append(xml_to_json(child))
- return array
+ rc = rest_client.RestClient(auth_provider)
+ rc.TYPE = self.TYPE
+ return rc
def deserialize_list(self, body):
- return parse_array(etree.fromstring(body), self.PLURALS)
+ return common.parse_array(etree.fromstring(body), self.PLURALS)
def deserialize_single(self, body):
return _root_tag_fetcher_and_xml_to_json_parse(body)
@@ -47,140 +41,66 @@
#TODO(enikanorov): implement better json to xml conversion
# expecting the dict with single key
root = body.keys()[0]
- post_body = Element(root)
+ post_body = common.Element(root)
post_body.add_attr('xmlns:xsi',
'http://www.w3.org/2001/XMLSchema-instance')
+ elements = set()
for name, attr in body[root].items():
elt = self._get_element(name, attr)
post_body.append(elt)
- return str(Document(post_body))
+ if ":" in name:
+ elements.add(name.split(":")[0])
+ if elements:
+ self._add_namespaces(post_body, elements)
+ return str(common.Document(post_body))
def serialize_list(self, body, root_name=None, item_name=None):
# expecting dict in form
# body = {'resources': [res_dict1, res_dict2, ...]
- post_body = Element(root_name)
+ post_body = common.Element(root_name)
post_body.add_attr('xmlns:xsi',
'http://www.w3.org/2001/XMLSchema-instance')
for item in body[body.keys()[0]]:
- elt = Element(item_name)
+ elt = common.Element(item_name)
for name, attr in item.items():
elt_content = self._get_element(name, attr)
elt.append(elt_content)
post_body.append(elt)
- return str(Document(post_body))
+ return str(common.Document(post_body))
def _get_element(self, name, value):
if value is None:
- xml_elem = Element(name)
+ xml_elem = common.Element(name)
xml_elem.add_attr("xsi:nil", "true")
return xml_elem
+ elif isinstance(value, dict):
+ dict_element = common.Element(name)
+ for key, value in value.iteritems():
+ elem = self._get_element(key, value)
+ dict_element.append(elem)
+ return dict_element
+ elif isinstance(value, list):
+ list_element = common.Element(name)
+ for element in value:
+ elem = self._get_element(name[:-1], element)
+ list_element.append(elem)
+ return list_element
else:
- return Element(name, value)
+ return common.Element(name, value)
- def create_security_group(self, name):
- uri = '%s/security-groups' % (self.uri_prefix)
- post_body = Element("security_group")
- p2 = Element("name", name)
- post_body.append(p2)
- resp, body = self.post(uri, str(Document(post_body)))
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def create_security_group_rule(self, secgroup_id,
- direction='ingress', **kwargs):
- uri = '%s/security-group-rules' % (self.uri_prefix)
- rule = Element("security_group_rule")
- p1 = Element('security_group_id', secgroup_id)
- p2 = Element('direction', direction)
- rule.append(p1)
- rule.append(p2)
- for key, val in kwargs.items():
- key = Element(key, val)
- rule.append(key)
- resp, body = self.post(uri, str(Document(rule)))
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def create_vip(self, name, protocol, protocol_port, subnet_id, pool_id):
- uri = '%s/lb/vips' % (self.uri_prefix)
- post_body = Element("vip")
- p1 = Element("name", name)
- p2 = Element("protocol", protocol)
- p3 = Element("protocol_port", protocol_port)
- p4 = Element("subnet_id", subnet_id)
- p5 = Element("pool_id", pool_id)
- post_body.append(p1)
- post_body.append(p2)
- post_body.append(p3)
- post_body.append(p4)
- post_body.append(p5)
- resp, body = self.post(uri, str(Document(post_body)))
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def update_vip(self, vip_id, new_name):
- uri = '%s/lb/vips/%s' % (self.uri_prefix, str(vip_id))
- put_body = Element("vip")
- p2 = Element("name", new_name)
- put_body.append(p2)
- resp, body = self.put(uri, str(Document(put_body)))
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def create_member(self, address, protocol_port, pool_id):
- uri = '%s/lb/members' % (self.uri_prefix)
- post_body = Element("member")
- p1 = Element("address", address)
- p2 = Element("protocol_port", protocol_port)
- p3 = Element("pool_id", pool_id)
- post_body.append(p1)
- post_body.append(p2)
- post_body.append(p3)
- resp, body = self.post(uri, str(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 = Element("member")
- p2 = Element("admin_state_up", admin_state_up)
- put_body.append(p2)
- resp, body = self.put(uri, str(Document(put_body)))
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def create_health_monitor(self, delay, max_retries, Type, timeout):
- uri = '%s/lb/health_monitors' % (self.uri_prefix)
- post_body = Element("health_monitor")
- p1 = Element("delay", delay)
- p2 = Element("max_retries", max_retries)
- p3 = Element("type", Type)
- p4 = Element("timeout", timeout)
- post_body.append(p1)
- post_body.append(p2)
- post_body.append(p3)
- post_body.append(p4)
- resp, body = self.post(uri, str(Document(post_body)))
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def update_health_monitor(self, admin_state_up, uuid):
- uri = '%s/lb/health_monitors/%s' % (self.uri_prefix, str(uuid))
- put_body = Element("health_monitor")
- p2 = Element("admin_state_up", admin_state_up)
- put_body.append(p2)
- resp, body = self.put(uri, str(Document(put_body)))
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
+ def _add_namespaces(self, root, elements):
+ for element in elements:
+ root.add_attr('xmlns:%s' % element,
+ common.NEUTRON_NAMESPACES[element])
def associate_health_monitor_with_pool(self, health_monitor_id,
pool_id):
uri = '%s/lb/pools/%s/health_monitors' % (self.uri_prefix,
pool_id)
- post_body = Element("health_monitor")
- p1 = Element("id", health_monitor_id,)
+ post_body = common.Element("health_monitor")
+ p1 = common.Element("id", health_monitor_id,)
post_body.append(p1)
- resp, body = self.post(uri, str(Document(post_body)))
+ resp, body = self.post(uri, str(common.Document(post_body)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
@@ -198,120 +118,150 @@
def create_router(self, name, **kwargs):
uri = '%s/routers' % (self.uri_prefix)
- router = Element("router")
- router.append(Element("name", name))
- deep_dict_to_xml(router, kwargs)
- resp, body = self.post(uri, str(Document(router)))
+ router = common.Element("router")
+ router.append(common.Element("name", name))
+ common.deep_dict_to_xml(router, kwargs)
+ resp, body = self.post(uri, str(common.Document(router)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
def update_router(self, router_id, **kwargs):
uri = '%s/routers/%s' % (self.uri_prefix, router_id)
- router = Element("router")
+ router = common.Element("router")
for element, content in kwargs.iteritems():
- router.append(Element(element, content))
- resp, body = self.put(uri, str(Document(router)))
+ router.append(common.Element(element, content))
+ resp, body = self.put(uri, str(common.Document(router)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
def add_router_interface_with_subnet_id(self, router_id, subnet_id):
uri = '%s/routers/%s/add_router_interface' % (self.uri_prefix,
router_id)
- subnet = Element("subnet_id", subnet_id)
- resp, body = self.put(uri, str(Document(subnet)))
+ subnet = common.Element("subnet_id", subnet_id)
+ resp, body = self.put(uri, str(common.Document(subnet)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
def add_router_interface_with_port_id(self, router_id, port_id):
uri = '%s/routers/%s/add_router_interface' % (self.uri_prefix,
router_id)
- port = Element("port_id", port_id)
- resp, body = self.put(uri, str(Document(port)))
+ port = common.Element("port_id", port_id)
+ resp, body = self.put(uri, str(common.Document(port)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
def remove_router_interface_with_subnet_id(self, router_id, subnet_id):
uri = '%s/routers/%s/remove_router_interface' % (self.uri_prefix,
router_id)
- subnet = Element("subnet_id", subnet_id)
- resp, body = self.put(uri, str(Document(subnet)))
+ subnet = common.Element("subnet_id", subnet_id)
+ resp, body = self.put(uri, str(common.Document(subnet)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
def remove_router_interface_with_port_id(self, router_id, port_id):
uri = '%s/routers/%s/remove_router_interface' % (self.uri_prefix,
router_id)
- port = Element("port_id", port_id)
- resp, body = self.put(uri, str(Document(port)))
+ port = common.Element("port_id", port_id)
+ resp, body = self.put(uri, str(common.Document(port)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
def create_floating_ip(self, ext_network_id, **kwargs):
uri = '%s/floatingips' % (self.uri_prefix)
- floatingip = Element('floatingip')
- floatingip.append(Element("floating_network_id", ext_network_id))
+ floatingip = common.Element('floatingip')
+ floatingip.append(common.Element("floating_network_id",
+ ext_network_id))
for element, content in kwargs.iteritems():
- floatingip.append(Element(element, content))
- resp, body = self.post(uri, str(Document(floatingip)))
+ floatingip.append(common.Element(element, content))
+ resp, body = self.post(uri, str(common.Document(floatingip)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
def update_floating_ip(self, floating_ip_id, **kwargs):
uri = '%s/floatingips/%s' % (self.uri_prefix, floating_ip_id)
- floatingip = Element('floatingip')
+ floatingip = common.Element('floatingip')
floatingip.add_attr('xmlns:xsi',
'http://www.w3.org/2001/XMLSchema-instance')
for element, content in kwargs.iteritems():
if content is None:
- xml_elem = Element(element)
+ xml_elem = common.Element(element)
xml_elem.add_attr("xsi:nil", "true")
floatingip.append(xml_elem)
else:
- floatingip.append(Element(element, content))
- resp, body = self.put(uri, str(Document(floatingip)))
+ floatingip.append(common.Element(element, content))
+ resp, body = self.put(uri, str(common.Document(floatingip)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
def list_router_interfaces(self, uuid):
uri = '%s/ports?device_id=%s' % (self.uri_prefix, uuid)
resp, body = self.get(uri)
- ports = parse_array(etree.fromstring(body), self.PLURALS)
+ ports = common.parse_array(etree.fromstring(body), self.PLURALS)
ports = {"ports": ports}
return resp, ports
def update_agent(self, agent_id, agent_info):
uri = '%s/agents/%s' % (self.uri_prefix, agent_id)
- agent = Element('agent')
+ agent = common.Element('agent')
for (key, value) in agent_info.items():
- p = Element(key, value)
+ p = common.Element(key, value)
agent.append(p)
- resp, body = self.put(uri, str(Document(agent)))
+ resp, body = self.put(uri, str(common.Document(agent)))
+ body = _root_tag_fetcher_and_xml_to_json_parse(body)
+ return resp, body
+
+ def list_pools_hosted_by_one_lbaas_agent(self, agent_id):
+ uri = '%s/agents/%s/loadbalancer-pools' % (self.uri_prefix, agent_id)
+ resp, body = self.get(uri)
+ pools = common.parse_array(etree.fromstring(body))
+ body = {'pools': pools}
+ return resp, body
+
+ def show_lbaas_agent_hosting_pool(self, pool_id):
+ uri = ('%s/lb/pools/%s/loadbalancer-agent' %
+ (self.uri_prefix, pool_id))
+ resp, body = self.get(uri)
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
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)
- agents = parse_array(etree.fromstring(body))
+ agents = common.parse_array(etree.fromstring(body))
body = {'agents': agents}
return resp, body
def list_networks_hosted_by_one_dhcp_agent(self, agent_id):
uri = '%s/agents/%s/dhcp-networks' % (self.uri_prefix, agent_id)
resp, body = self.get(uri)
- networks = parse_array(etree.fromstring(body))
+ networks = common.parse_array(etree.fromstring(body))
body = {'networks': networks}
return resp, body
@@ -321,14 +271,20 @@
resp, body = self.delete(uri)
return resp, body
+ def list_lb_pool_stats(self, pool_id):
+ uri = '%s/lb/pools/%s/stats' % (self.uri_prefix, pool_id)
+ resp, body = self.get(uri)
+ body = _root_tag_fetcher_and_xml_to_json_parse(body)
+ return resp, body
+
def _root_tag_fetcher_and_xml_to_json_parse(xml_returned_body):
body = ET.fromstring(xml_returned_body)
root_tag = body.tag
if root_tag.startswith("{"):
ns, root_tag = root_tag.split("}", 1)
- body = xml_to_json(etree.fromstring(xml_returned_body),
- NetworkClientXML.PLURALS)
+ body = common.xml_to_json(etree.fromstring(xml_returned_body),
+ NetworkClientXML.PLURALS)
nil = '{http://www.w3.org/2001/XMLSchema-instance}nil'
for key, val in body.iteritems():
if isinstance(val, dict):
diff --git a/tempest/services/object_storage/account_client.py b/tempest/services/object_storage/account_client.py
index 924d9a8..7c3fa85 100644
--- a/tempest/services/object_storage/account_client.py
+++ b/tempest/services/object_storage/account_client.py
@@ -17,22 +17,18 @@
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
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
- self.format = 'json'
-
- @property
- def token(self):
- return self.auth_provider.auth_data[0]
def create_account(self, data=None,
params=None,
@@ -62,7 +58,7 @@
url += 'bulk-delete&'
url = '?%s%s' % (url, urllib.urlencode(params))
- resp, body = self.delete(url, headers=None, body=data)
+ resp, body = self.delete(url, headers={}, body=data)
return resp, body
def list_account_metadata(self):
@@ -91,7 +87,25 @@
headers = {}
for item in metadata:
- headers[metadata_prefix + item] = 'x'
+ headers[metadata_prefix + item] = metadata[item]
+ resp, body = self.post('', headers=headers, body=None)
+ return resp, body
+
+ def create_and_delete_account_metadata(
+ self,
+ create_metadata=None,
+ delete_metadata=None,
+ create_metadata_prefix='X-Account-Meta-',
+ delete_metadata_prefix='X-Remove-Account-Meta-'):
+ """
+ Creates and deletes an account metadata entry.
+ """
+ headers = {}
+ for key in create_metadata:
+ headers[create_metadata_prefix + key] = create_metadata[key]
+ for key in delete_metadata:
+ headers[delete_metadata_prefix + key] = delete_metadata[key]
+
resp, body = self.post('', headers=headers, body=None)
return resp, body
@@ -116,36 +130,35 @@
response.
DEFAULT: Python-List returned in response body
"""
+ url = '?%s' % urllib.urlencode(params) if params else ''
- if params:
- if 'format' not in params:
- params['format'] = self.format
- else:
- params = {'format': self.format}
-
- url = '?' + urllib.urlencode(params)
- resp, body = self.get(url)
-
+ resp, body = self.get(url, headers={})
if params and params.get('format') == 'json':
body = json.loads(body)
+ elif params and params.get('format') == 'xml':
+ body = etree.fromstring(body)
+ else:
+ body = body.strip().splitlines()
return resp, body
def list_extensions(self):
self.skip_path()
- resp, body = self.get('info')
- self.reset_path()
+ try:
+ resp, body = self.get('info')
+ finally:
+ self.reset_path()
body = json.loads(body)
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 63a6460..546b557 100644
--- a/tempest/services/object_storage/container_client.py
+++ b/tempest/services/object_storage/container_client.py
@@ -16,26 +16,22 @@
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'
- @property
- def token(self):
- return self.auth_provider.auth_data[0]
-
def create_container(
self, container_name,
metadata=None,
@@ -185,7 +181,7 @@
url += '?'
url += '&%s' % urllib.urlencode(params)
- resp, body = self.get(url)
+ resp, body = self.get(url, headers={})
if params and params.get('format') == 'json':
body = json.loads(body)
elif params and params.get('format') == 'xml':
diff --git a/tempest/services/object_storage/object_client.py b/tempest/services/object_storage/object_client.py
index ca4f1c1..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)
@@ -32,7 +32,7 @@
def create_object(self, container, object_name, data, params=None):
"""Create storage object."""
- headers = dict(self.headers)
+ headers = self.get_headers()
if not data:
headers['content-length'] = '0'
url = "%s/%s" % (str(container), str(object_name))
@@ -51,7 +51,7 @@
url = "%s/%s" % (str(container), str(object_name))
if params:
url += '?%s' % urllib.urlencode(params)
- resp, body = self.delete(url)
+ resp, body = self.delete(url, headers={})
return resp, body
def update_object_metadata(self, container, object_name, metadata,
@@ -131,18 +131,18 @@
def create_object_segments(self, container, object_name, segment, data):
"""Creates object segments."""
url = "{0}/{1}/{2}".format(container, object_name, segment)
- resp, body = self.put(url, data, self.headers)
+ resp, body = self.put(url, data)
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/orchestration/json/orchestration_client.py b/tempest/services/orchestration/json/orchestration_client.py
index 0a16b9f..113003c 100644
--- a/tempest/services/orchestration/json/orchestration_client.py
+++ b/tempest/services/orchestration/json/orchestration_client.py
@@ -90,7 +90,7 @@
# Password must be provided on stack create so that heat
# can perform future operations on behalf of the user
- headers = dict(self.headers)
+ headers = self.get_headers()
headers['X-Auth-Key'] = self.password
headers['X-Auth-User'] = self.user
return headers, body
@@ -106,14 +106,14 @@
"""Suspend a stack."""
url = 'stacks/%s/actions' % stack_identifier
body = {'suspend': None}
- resp, body = self.post(url, json.dumps(body), self.headers)
+ resp, body = self.post(url, json.dumps(body))
return resp, body
def resume_stack(self, stack_identifier):
"""Resume a stack."""
url = 'stacks/%s/actions' % stack_identifier
body = {'resume': None}
- resp, body = self.post(url, json.dumps(body), self.headers)
+ resp, body = self.post(url, json.dumps(body))
return resp, body
def list_resources(self, stack_identifier):
@@ -177,7 +177,7 @@
stack_name = body['stack_name']
stack_status = body['stack_status']
if stack_status == status:
- return
+ return body
if fail_regexp.search(stack_status):
raise exceptions.StackBuildErrorException(
stack_identifier=stack_identifier,
@@ -232,7 +232,7 @@
def _validate_template(self, post_body):
"""Returns the validation request result."""
post_body = json.dumps(post_body)
- resp, body = self.post('validate', post_body, self.headers)
+ resp, body = self.post('validate', post_body)
body = json.loads(body)
return resp, body
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 747d7c1..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", ""))
@@ -29,10 +29,6 @@
def serialize(self, body):
return json.dumps(body)
- def create_alarm(self, **kwargs):
- uri = "%s/alarms" % self.uri_prefix
- return self.post(uri, kwargs)
-
def add_sample(self, sample_list, meter_name, meter_unit, volume,
sample_type, resource_id, **kwargs):
sample = {"counter_name": meter_name, "counter_unit": meter_unit,
diff --git a/tempest/services/telemetry/telemetry_client_base.py b/tempest/services/telemetry/telemetry_client_base.py
index 200c94a..610f07b 100644
--- a/tempest/services/telemetry/telemetry_client_base.py
+++ b/tempest/services/telemetry/telemetry_client_base.py
@@ -38,7 +38,6 @@
def __init__(self, auth_provider):
self.rest_client = self.get_rest_client(auth_provider)
self.rest_client.service = CONF.telemetry.catalog_type
- self.headers = self.rest_client.headers
self.version = '2'
self.uri_prefix = "v%s" % self.version
@@ -69,12 +68,12 @@
def post(self, uri, body):
body = self.serialize(body)
- resp, body = self.rest_client.post(uri, body, self.headers)
+ resp, body = self.rest_client.post(uri, body)
body = self.deserialize(body)
return resp, body
def put(self, uri, body):
- return self.rest_client.put(uri, body, self.headers)
+ return self.rest_client.put(uri, body)
def get(self, uri):
resp, body = self.rest_client.get(uri)
@@ -124,9 +123,13 @@
return self.get(uri)
def get_alarm(self, alarm_id):
- uri = '%s/meter/%s' % (self.uri_prefix, alarm_id)
+ uri = '%s/alarms/%s' % (self.uri_prefix, alarm_id)
return self.get(uri)
def delete_alarm(self, alarm_id):
uri = "%s/alarms/%s" % (self.uri_prefix, alarm_id)
return self.delete(uri)
+
+ def create_alarm(self, **kwargs):
+ uri = "%s/alarms" % self.uri_prefix
+ return self.post(uri, kwargs)
diff --git a/tempest/services/telemetry/xml/telemetry_client.py b/tempest/services/telemetry/xml/telemetry_client.py
index f29fe22..673f98e 100644
--- a/tempest/services/telemetry/xml/telemetry_client.py
+++ b/tempest/services/telemetry/xml/telemetry_client.py
@@ -15,25 +15,27 @@
from lxml import etree
-from tempest.common.rest_client import RestClientXML
-from tempest.services.compute.xml.common import Document
-from tempest.services.compute.xml.common import xml_to_json
+from tempest.common import rest_client
+from tempest.services.compute.xml import common
import tempest.services.telemetry.telemetry_client_base as client
class TelemetryClientXML(client.TelemetryClientBase):
+ TYPE = "xml"
def get_rest_client(self, auth_provider):
- return RestClientXML(auth_provider)
+ rc = rest_client.RestClient(auth_provider)
+ rc.TYPE = self.TYPE
+ return rc
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 653532e..c9c0582 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
"""
@@ -64,7 +64,7 @@
}
post_body = json.dumps({'volume_type': post_body})
- resp, body = self.post('types', post_body, self.headers)
+ resp, body = self.post('types', post_body)
body = json.loads(body)
return resp, body['volume_type']
@@ -98,7 +98,7 @@
"""
url = "types/%s/extra_specs" % str(vol_type_id)
post_body = json.dumps({'extra_specs': extra_spec})
- resp, body = self.post(url, post_body, self.headers)
+ resp, body = self.post(url, post_body)
body = json.loads(body)
return resp, body['extra_specs']
@@ -119,6 +119,34 @@
url = "types/%s/extra_specs/%s" % (str(vol_type_id),
str(extra_spec_name))
put_body = json.dumps(extra_spec)
- resp, body = self.put(url, put_body, self.headers)
+ resp, body = self.put(url, put_body)
body = json.loads(body)
return resp, body
+
+ def get_encryption_type(self, vol_type_id):
+ """
+ Get the volume encryption type for the specified volume type.
+ vol_type_id: Id of volume_type.
+ """
+ url = "/types/%s/encryption" % str(vol_type_id)
+ resp, body = self.get(url)
+ body = json.loads(body)
+ return resp, body
+
+ def create_encryption_type(self, vol_type_id, **kwargs):
+ """
+ Create a new encryption type for the specified volume type.
+
+ vol_type_id: Id of volume_type.
+ provider: Class providing encryption support.
+ cipher: Encryption algorithm/mode to use.
+ key_size: Size of the encryption key, in bits.
+ control_location: Notional service where encryption is performed.
+ """
+ url = "/types/%s/encryption" % str(vol_type_id)
+ post_body = {}
+ post_body.update(kwargs)
+ post_body = json.dumps({'encryption': post_body})
+ resp, body = self.post(url, post_body)
+ body = json.loads(body)
+ return resp, body['encryption']
diff --git a/tempest/services/volume/json/backups_client.py b/tempest/services/volume/json/backups_client.py
new file mode 100644
index 0000000..183d06b
--- /dev/null
+++ b/tempest/services/volume/json/backups_client.py
@@ -0,0 +1,96 @@
+# Copyright 2014 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 json
+import time
+
+from tempest.common import rest_client
+from tempest import config
+from tempest import exceptions
+
+CONF = config.CONF
+
+
+class BackupsClientJSON(rest_client.RestClient):
+ """
+ Client class to send CRUD Volume backup API requests to a Cinder endpoint
+ """
+
+ def __init__(self, auth_provider):
+ super(BackupsClientJSON, 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 create_backup(self, volume_id, container=None, name=None,
+ description=None):
+ """Creates a backup of volume."""
+ post_body = {'volume_id': volume_id}
+ if container:
+ post_body['container'] = container
+ if name:
+ post_body['name'] = name
+ if description:
+ post_body['description'] = description
+ post_body = json.dumps({'backup': post_body})
+ resp, body = self.post('backups', post_body)
+ body = json.loads(body)
+ return resp, body['backup']
+
+ def restore_backup(self, backup_id, volume_id=None):
+ """Restore volume from backup."""
+ post_body = {'volume_id': volume_id}
+ post_body = json.dumps({'restore': post_body})
+ resp, body = self.post('backups/%s/restore' % (backup_id), post_body)
+ body = json.loads(body)
+ return resp, body['restore']
+
+ def delete_backup(self, backup_id):
+ """Delete a backup of volume."""
+ resp, body = self.delete('backups/%s' % (str(backup_id)))
+ return resp, body
+
+ def get_backup(self, backup_id):
+ """Returns the details of a single backup."""
+ url = "backups/%s" % str(backup_id)
+ resp, body = self.get(url)
+ 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)
+ backup_status = body['status']
+ start = int(time.time())
+
+ while backup_status != status:
+ time.sleep(self.build_interval)
+ resp, body = self.get_backup(backup_id)
+ backup_status = body['status']
+ if backup_status == 'error':
+ raise exceptions.VolumeBackupException(backup_id=backup_id)
+
+ if int(time.time()) - start >= self.build_timeout:
+ message = ('Volume backup %s failed to reach %s status within '
+ 'the required time (%s s).' %
+ (backup_id, status, self.build_timeout))
+ raise exceptions.TimeoutException(message)
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 0a79469..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):
@@ -72,15 +72,14 @@
post_body = {'volume_id': volume_id}
post_body.update(kwargs)
post_body = json.dumps({'snapshot': post_body})
- resp, body = self.post('snapshots', post_body, self.headers)
+ resp, body = self.post('snapshots', post_body)
body = json.loads(body)
return resp, body['snapshot']
def update_snapshot(self, snapshot_id, **kwargs):
"""Updates a snapshot."""
put_body = json.dumps({'snapshot': kwargs})
- resp, body = self.put('snapshots/%s' % snapshot_id, put_body,
- self.headers)
+ resp, body = self.put('snapshots/%s' % snapshot_id, put_body)
body = json.loads(body)
return resp, body['snapshot']
@@ -135,8 +134,7 @@
def reset_snapshot_status(self, snapshot_id, status):
"""Reset the specified snapshot's status."""
post_body = json.dumps({'os-reset_status': {"status": status}})
- resp, body = self.post('snapshots/%s/action' % snapshot_id, post_body,
- self.headers)
+ resp, body = self.post('snapshots/%s/action' % snapshot_id, post_body)
return resp, body
def update_snapshot_status(self, snapshot_id, status, progress):
@@ -147,21 +145,21 @@
}
post_body = json.dumps({'os-update_snapshot_status': post_body})
url = 'snapshots/%s/action' % str(snapshot_id)
- resp, body = self.post(url, post_body, self.headers)
+ resp, body = self.post(url, post_body)
return resp, body
def create_snapshot_metadata(self, snapshot_id, metadata):
"""Create metadata for the snapshot."""
put_body = json.dumps({'metadata': metadata})
url = "snapshots/%s/metadata" % str(snapshot_id)
- resp, body = self.post(url, put_body, self.headers)
+ resp, body = self.post(url, put_body)
body = json.loads(body)
return resp, body['metadata']
def get_snapshot_metadata(self, snapshot_id):
"""Get metadata of the snapshot."""
url = "snapshots/%s/metadata" % str(snapshot_id)
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
body = json.loads(body)
return resp, body['metadata']
@@ -169,7 +167,7 @@
"""Update metadata for the snapshot."""
put_body = json.dumps({'metadata': metadata})
url = "snapshots/%s/metadata" % str(snapshot_id)
- resp, body = self.put(url, put_body, self.headers)
+ resp, body = self.put(url, put_body)
body = json.loads(body)
return resp, body['metadata']
@@ -177,19 +175,18 @@
"""Update metadata item for the snapshot."""
put_body = json.dumps({'meta': meta_item})
url = "snapshots/%s/metadata/%s" % (str(snapshot_id), str(id))
- resp, body = self.put(url, put_body, self.headers)
+ resp, body = self.put(url, put_body)
body = json.loads(body)
return resp, body['meta']
def delete_snapshot_metadata_item(self, snapshot_id, id):
"""Delete metadata item for the snapshot."""
url = "snapshots/%s/metadata/%s" % (str(snapshot_id), str(id))
- resp, body = self.delete(url, self.headers)
+ resp, body = self.delete(url)
return resp, body
def force_delete_snapshot(self, snapshot_id):
"""Force Delete Snapshot."""
post_body = json.dumps({'os-force_delete': {}})
- resp, body = self.post('snapshots/%s/action' % snapshot_id, post_body,
- self.headers)
+ resp, body = self.post('snapshots/%s/action' % snapshot_id, post_body)
return resp, body
diff --git a/tempest/services/volume/json/volumes_client.py b/tempest/services/volume/json/volumes_client.py
index 0524212..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
"""
@@ -81,15 +81,14 @@
post_body = {'size': size}
post_body.update(kwargs)
post_body = json.dumps({'volume': post_body})
- resp, body = self.post('volumes', post_body, self.headers)
+ resp, body = self.post('volumes', post_body)
body = json.loads(body)
return resp, body['volume']
def update_volume(self, volume_id, **kwargs):
"""Updates the Specified Volume."""
put_body = json.dumps({'volume': kwargs})
- resp, body = self.put('volumes/%s' % volume_id, put_body,
- self.headers)
+ resp, body = self.put('volumes/%s' % volume_id, put_body)
body = json.loads(body)
return resp, body['volume']
@@ -105,7 +104,7 @@
}
post_body = json.dumps({'os-volume_upload_image': post_body})
url = 'volumes/%s/action' % (volume_id)
- resp, body = self.post(url, post_body, self.headers)
+ resp, body = self.post(url, post_body)
body = json.loads(body)
return resp, body['os-volume_upload_image']
@@ -117,7 +116,7 @@
}
post_body = json.dumps({'os-attach': post_body})
url = 'volumes/%s/action' % (volume_id)
- resp, body = self.post(url, post_body, self.headers)
+ resp, body = self.post(url, post_body)
return resp, body
def detach_volume(self, volume_id):
@@ -125,7 +124,7 @@
post_body = {}
post_body = json.dumps({'os-detach': post_body})
url = 'volumes/%s/action' % (volume_id)
- resp, body = self.post(url, post_body, self.headers)
+ resp, body = self.post(url, post_body)
return resp, body
def reserve_volume(self, volume_id):
@@ -133,7 +132,7 @@
post_body = {}
post_body = json.dumps({'os-reserve': post_body})
url = 'volumes/%s/action' % (volume_id)
- resp, body = self.post(url, post_body, self.headers)
+ resp, body = self.post(url, post_body)
return resp, body
def unreserve_volume(self, volume_id):
@@ -141,7 +140,7 @@
post_body = {}
post_body = json.dumps({'os-unreserve': post_body})
url = 'volumes/%s/action' % (volume_id)
- resp, body = self.post(url, post_body, self.headers)
+ resp, body = self.post(url, post_body)
return resp, body
def wait_for_volume_status(self, volume_id, status):
@@ -178,28 +177,25 @@
}
post_body = json.dumps({'os-extend': post_body})
url = 'volumes/%s/action' % (volume_id)
- resp, body = self.post(url, post_body, self.headers)
+ resp, body = self.post(url, post_body)
return resp, body
def reset_volume_status(self, volume_id, status):
"""Reset the Specified Volume's Status."""
post_body = json.dumps({'os-reset_status': {"status": status}})
- resp, body = self.post('volumes/%s/action' % volume_id, post_body,
- self.headers)
+ resp, body = self.post('volumes/%s/action' % volume_id, post_body)
return resp, body
def volume_begin_detaching(self, volume_id):
"""Volume Begin Detaching."""
post_body = json.dumps({'os-begin_detaching': {}})
- resp, body = self.post('volumes/%s/action' % volume_id, post_body,
- self.headers)
+ resp, body = self.post('volumes/%s/action' % volume_id, post_body)
return resp, body
def volume_roll_detaching(self, volume_id):
"""Volume Roll Detaching."""
post_body = json.dumps({'os-roll_detaching': {}})
- resp, body = self.post('volumes/%s/action' % volume_id, post_body,
- self.headers)
+ resp, body = self.post('volumes/%s/action' % volume_id, post_body)
return resp, body
def create_volume_transfer(self, vol_id, display_name=None):
@@ -210,16 +206,14 @@
if display_name:
post_body['name'] = display_name
post_body = json.dumps({'transfer': post_body})
- resp, body = self.post('os-volume-transfer',
- post_body,
- self.headers)
+ resp, body = self.post('os-volume-transfer', post_body)
body = json.loads(body)
return resp, body['transfer']
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, self.headers)
+ resp, body = self.get(url)
body = json.loads(body)
return resp, body['transfer']
@@ -243,7 +237,7 @@
}
url = 'os-volume-transfer/%s/accept' % transfer_id
post_body = json.dumps({'accept': post_body})
- resp, body = self.post(url, post_body, self.headers)
+ resp, body = self.post(url, post_body)
body = json.loads(body)
return resp, body['transfer']
@@ -254,28 +248,27 @@
}
post_body = json.dumps({'os-update_readonly_flag': post_body})
url = 'volumes/%s/action' % (volume_id)
- resp, body = self.post(url, post_body, self.headers)
+ resp, body = self.post(url, post_body)
return resp, body
def force_delete_volume(self, volume_id):
"""Force Delete Volume."""
post_body = json.dumps({'os-force_delete': {}})
- resp, body = self.post('volumes/%s/action' % volume_id, post_body,
- self.headers)
+ resp, body = self.post('volumes/%s/action' % volume_id, post_body)
return resp, body
def create_volume_metadata(self, volume_id, metadata):
"""Create metadata for the volume."""
put_body = json.dumps({'metadata': metadata})
url = "volumes/%s/metadata" % str(volume_id)
- resp, body = self.post(url, put_body, self.headers)
+ resp, body = self.post(url, put_body)
body = json.loads(body)
return resp, body['metadata']
def get_volume_metadata(self, volume_id):
"""Get metadata of the volume."""
url = "volumes/%s/metadata" % str(volume_id)
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
body = json.loads(body)
return resp, body['metadata']
@@ -283,7 +276,7 @@
"""Update metadata for the volume."""
put_body = json.dumps({'metadata': metadata})
url = "volumes/%s/metadata" % str(volume_id)
- resp, body = self.put(url, put_body, self.headers)
+ resp, body = self.put(url, put_body)
body = json.loads(body)
return resp, body['metadata']
@@ -291,12 +284,12 @@
"""Update metadata item for the volume."""
put_body = json.dumps({'meta': meta_item})
url = "volumes/%s/metadata/%s" % (str(volume_id), str(id))
- resp, body = self.put(url, put_body, self.headers)
+ resp, body = self.put(url, put_body)
body = json.loads(body)
return resp, body['meta']
def delete_volume_metadata_item(self, volume_id, id):
"""Delete metadata item for the volume."""
url = "volumes/%s/metadata/%s" % (str(volume_id), str(id))
- resp, body = self.delete(url, self.headers)
+ resp, body = self.delete(url)
return resp, body
diff --git a/tempest/services/volume/v2/__init__.py b/tempest/services/volume/v2/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/services/volume/v2/__init__.py
diff --git a/tempest/services/volume/v2/json/__init__.py b/tempest/services/volume/v2/json/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/services/volume/v2/json/__init__.py
diff --git a/tempest/services/volume/v2/json/volumes_client.py b/tempest/services/volume/v2/json/volumes_client.py
new file mode 100644
index 0000000..5bfa75f
--- /dev/null
+++ b/tempest/services/volume/v2/json/volumes_client.py
@@ -0,0 +1,296 @@
+# 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 json
+import time
+import urllib
+
+from tempest.common import rest_client
+from tempest import config
+from tempest import exceptions
+
+CONF = config.CONF
+
+
+class VolumesV2ClientJSON(rest_client.RestClient):
+ """
+ Client class to send CRUD Volume V2 API requests to a Cinder endpoint
+ """
+
+ def __init__(self, auth_provider):
+ super(VolumesV2ClientJSON, self).__init__(auth_provider)
+
+ self.api_version = "v2"
+ self.service = CONF.volume.catalog_type
+ self.build_interval = CONF.volume.build_interval
+ self.build_timeout = CONF.volume.build_timeout
+
+ def get_attachment_from_volume(self, volume):
+ """Return the element 'attachment' from input volumes."""
+ return volume['attachments'][0]
+
+ def list_volumes(self, params=None):
+ """List all the volumes created."""
+ url = 'volumes'
+ if params:
+ url += '?%s' % urllib.urlencode(params)
+
+ resp, body = self.get(url)
+ body = json.loads(body)
+ return resp, body['volumes']
+
+ def list_volumes_with_detail(self, params=None):
+ """List the details of all volumes."""
+ url = 'volumes/detail'
+ if params:
+ url += '?%s' % urllib.urlencode(params)
+
+ resp, body = self.get(url)
+ body = json.loads(body)
+ return resp, body['volumes']
+
+ def get_volume(self, volume_id):
+ """Returns the details of a single volume."""
+ url = "volumes/%s" % str(volume_id)
+ resp, body = self.get(url)
+ body = json.loads(body)
+ return resp, body['volume']
+
+ def create_volume(self, size, **kwargs):
+ """
+ Creates a new Volume.
+ size(Required): Size of volume in GB.
+ Following optional keyword arguments are accepted:
+ name: Optional Volume Name.
+ metadata: A dictionary of values to be used as metadata.
+ volume_type: Optional Name of volume_type for the volume
+ snapshot_id: When specified the volume is created from this snapshot
+ imageRef: When specified the volume is created from this image
+ """
+ post_body = {'size': size}
+ post_body.update(kwargs)
+ post_body = json.dumps({'volume': post_body})
+ resp, body = self.post('volumes', post_body)
+ body = json.loads(body)
+ return resp, body['volume']
+
+ def update_volume(self, volume_id, **kwargs):
+ """Updates the Specified Volume."""
+ put_body = json.dumps({'volume': kwargs})
+ resp, body = self.put('volumes/%s' % volume_id, put_body)
+ body = json.loads(body)
+ return resp, body['volume']
+
+ def delete_volume(self, volume_id):
+ """Deletes the Specified Volume."""
+ return self.delete("volumes/%s" % str(volume_id))
+
+ def upload_volume(self, volume_id, image_name, disk_format):
+ """Uploads a volume in Glance."""
+ post_body = {
+ 'image_name': image_name,
+ 'disk_format': disk_format
+ }
+ post_body = json.dumps({'os-volume_upload_image': post_body})
+ url = 'volumes/%s/action' % (volume_id)
+ resp, body = self.post(url, post_body)
+ body = json.loads(body)
+ return resp, body['os-volume_upload_image']
+
+ def attach_volume(self, volume_id, instance_uuid, mountpoint):
+ """Attaches a volume to a given instance on a given mountpoint."""
+ post_body = {
+ 'instance_uuid': instance_uuid,
+ 'mountpoint': mountpoint,
+ }
+ post_body = json.dumps({'os-attach': post_body})
+ url = 'volumes/%s/action' % (volume_id)
+ resp, body = self.post(url, post_body)
+ return resp, body
+
+ def detach_volume(self, volume_id):
+ """Detaches a volume from an instance."""
+ post_body = {}
+ post_body = json.dumps({'os-detach': post_body})
+ url = 'volumes/%s/action' % (volume_id)
+ resp, body = self.post(url, post_body)
+ return resp, body
+
+ def reserve_volume(self, volume_id):
+ """Reserves a volume."""
+ post_body = {}
+ post_body = json.dumps({'os-reserve': post_body})
+ url = 'volumes/%s/action' % (volume_id)
+ resp, body = self.post(url, post_body)
+ return resp, body
+
+ def unreserve_volume(self, volume_id):
+ """Restore a reserved volume ."""
+ post_body = {}
+ post_body = json.dumps({'os-unreserve': post_body})
+ url = 'volumes/%s/action' % (volume_id)
+ resp, body = self.post(url, post_body)
+ return resp, body
+
+ def wait_for_volume_status(self, volume_id, status):
+ """Waits for a Volume to reach a given status."""
+ resp, body = self.get_volume(volume_id)
+ volume_name = body['name']
+ volume_status = body['status']
+ start = int(time.time())
+
+ while volume_status != status:
+ time.sleep(self.build_interval)
+ resp, body = self.get_volume(volume_id)
+ volume_status = body['status']
+ if volume_status == 'error':
+ raise exceptions.VolumeBuildErrorException(volume_id=volume_id)
+
+ if int(time.time()) - start >= self.build_timeout:
+ message = ('Volume %s failed to reach %s status within '
+ 'the required time (%s s).' %
+ (volume_name, status, self.build_timeout))
+ raise exceptions.TimeoutException(message)
+
+ def is_resource_deleted(self, id):
+ try:
+ self.get_volume(id)
+ except exceptions.NotFound:
+ return True
+ return False
+
+ def extend_volume(self, volume_id, extend_size):
+ """Extend a volume."""
+ post_body = {
+ 'new_size': extend_size
+ }
+ post_body = json.dumps({'os-extend': post_body})
+ url = 'volumes/%s/action' % (volume_id)
+ resp, body = self.post(url, post_body)
+ return resp, body
+
+ def reset_volume_status(self, volume_id, status):
+ """Reset the Specified Volume's Status."""
+ post_body = json.dumps({'os-reset_status': {"status": status}})
+ resp, body = self.post('volumes/%s/action' % volume_id, post_body)
+ return resp, body
+
+ def volume_begin_detaching(self, volume_id):
+ """Volume Begin Detaching."""
+ post_body = json.dumps({'os-begin_detaching': {}})
+ resp, body = self.post('volumes/%s/action' % volume_id, post_body)
+ return resp, body
+
+ def volume_roll_detaching(self, volume_id):
+ """Volume Roll Detaching."""
+ post_body = json.dumps({'os-roll_detaching': {}})
+ resp, body = self.post('volumes/%s/action' % volume_id, post_body)
+ return resp, body
+
+ def create_volume_transfer(self, vol_id, name=None):
+ """Create a volume transfer."""
+ post_body = {
+ 'volume_id': vol_id
+ }
+ if name:
+ post_body['name'] = name
+ post_body = json.dumps({'transfer': post_body})
+ resp, body = self.post('os-volume-transfer', post_body)
+ body = json.loads(body)
+ return resp, body['transfer']
+
+ 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)
+ body = json.loads(body)
+ return resp, body['transfer']
+
+ def list_volume_transfers(self, params=None):
+ """List all the volume transfers created."""
+ url = 'os-volume-transfer'
+ if params:
+ url += '?%s' % urllib.urlencode(params)
+ resp, body = self.get(url)
+ body = json.loads(body)
+ return resp, body['transfers']
+
+ def delete_volume_transfer(self, transfer_id):
+ """Delete a volume transfer."""
+ return self.delete("os-volume-transfer/%s" % str(transfer_id))
+
+ def accept_volume_transfer(self, transfer_id, transfer_auth_key):
+ """Accept a volume transfer."""
+ post_body = {
+ 'auth_key': transfer_auth_key,
+ }
+ url = 'os-volume-transfer/%s/accept' % transfer_id
+ post_body = json.dumps({'accept': post_body})
+ resp, body = self.post(url, post_body)
+ body = json.loads(body)
+ return resp, body['transfer']
+
+ def update_volume_readonly(self, volume_id, readonly):
+ """Update the Specified Volume readonly."""
+ post_body = {
+ 'readonly': readonly
+ }
+ post_body = json.dumps({'os-update_readonly_flag': post_body})
+ url = 'volumes/%s/action' % (volume_id)
+ resp, body = self.post(url, post_body)
+ return resp, body
+
+ def force_delete_volume(self, volume_id):
+ """Force Delete Volume."""
+ post_body = json.dumps({'os-force_delete': {}})
+ resp, body = self.post('volumes/%s/action' % volume_id, post_body)
+ return resp, body
+
+ def create_volume_metadata(self, volume_id, metadata):
+ """Create metadata for the volume."""
+ put_body = json.dumps({'metadata': metadata})
+ url = "volumes/%s/metadata" % str(volume_id)
+ resp, body = self.post(url, put_body)
+ body = json.loads(body)
+ return resp, body['metadata']
+
+ def get_volume_metadata(self, volume_id):
+ """Get metadata of the volume."""
+ url = "volumes/%s/metadata" % str(volume_id)
+ resp, body = self.get(url)
+ body = json.loads(body)
+ return resp, body['metadata']
+
+ def update_volume_metadata(self, volume_id, metadata):
+ """Update metadata for the volume."""
+ put_body = json.dumps({'metadata': metadata})
+ url = "volumes/%s/metadata" % str(volume_id)
+ resp, body = self.put(url, put_body)
+ body = json.loads(body)
+ return resp, body['metadata']
+
+ def update_volume_metadata_item(self, volume_id, id, meta_item):
+ """Update metadata item for the volume."""
+ put_body = json.dumps({'meta': meta_item})
+ url = "volumes/%s/metadata/%s" % (str(volume_id), str(id))
+ resp, body = self.put(url, put_body)
+ body = json.loads(body)
+ return resp, body['meta']
+
+ def delete_volume_metadata_item(self, volume_id, id):
+ """Delete metadata item for the volume."""
+ url = "volumes/%s/metadata/%s" % (str(volume_id), str(id))
+ resp, body = self.delete(url)
+ return resp, body
diff --git a/tempest/services/volume/v2/xml/__init__.py b/tempest/services/volume/v2/xml/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/services/volume/v2/xml/__init__.py
diff --git a/tempest/services/volume/v2/xml/volumes_client.py b/tempest/services/volume/v2/xml/volumes_client.py
new file mode 100644
index 0000000..0b8f47c
--- /dev/null
+++ b/tempest/services/volume/v2/xml/volumes_client.py
@@ -0,0 +1,404 @@
+# Copyright 2012 IBM Corp.
+# 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 time
+import urllib
+
+from lxml import etree
+
+from tempest.common import rest_client
+from tempest import config
+from tempest import exceptions
+from tempest.services.compute.xml import common
+
+CONF = config.CONF
+
+
+class VolumesV2ClientXML(rest_client.RestClient):
+ """
+ Client class to send CRUD Volume API requests to a Cinder endpoint
+ """
+ TYPE = "xml"
+
+ def __init__(self, auth_provider):
+ super(VolumesV2ClientXML, self).__init__(auth_provider)
+
+ self.api_version = "v2"
+ self.service = CONF.volume.catalog_type
+ self.build_interval = CONF.compute.build_interval
+ self.build_timeout = CONF.compute.build_timeout
+
+ def _parse_volume(self, body):
+ vol = dict((attr, body.get(attr)) for attr in body.keys())
+
+ for child in body.getchildren():
+ tag = child.tag
+ if tag.startswith("{"):
+ ns, tag = tag.split("}", 1)
+ if tag == 'metadata':
+ vol['metadata'] = dict((meta.get('key'),
+ meta.text) for meta in
+ child.getchildren())
+ else:
+ vol[tag] = common.xml_to_json(child)
+ return vol
+
+ def get_attachment_from_volume(self, volume):
+ """Return the element 'attachment' from input volumes."""
+ return volume['attachments']['attachment']
+
+ def _check_if_bootable(self, volume):
+ """
+ Check if the volume is bootable, also change the value
+ of 'bootable' from string to boolean.
+ """
+
+ # NOTE(jdg): Version 1 of Cinder API uses lc strings
+ # We should consider being explicit in this check to
+ # avoid introducing bugs like: LP #1227837
+
+ if volume['bootable'].lower() == 'true':
+ volume['bootable'] = True
+ elif volume['bootable'].lower() == 'false':
+ volume['bootable'] = False
+ else:
+ raise ValueError(
+ 'bootable flag is supposed to be either True or False,'
+ 'it is %s' % volume['bootable'])
+ return volume
+
+ def list_volumes(self, params=None):
+ """List all the volumes created."""
+ url = 'volumes'
+
+ if params:
+ url += '?%s' % urllib.urlencode(params)
+
+ resp, body = self.get(url)
+ body = etree.fromstring(body)
+ volumes = []
+ if body is not None:
+ volumes += [self._parse_volume(vol) for vol in list(body)]
+ return resp, volumes
+
+ def list_volumes_with_detail(self, params=None):
+ """List all the details of volumes."""
+ url = 'volumes/detail'
+
+ if params:
+ url += '?%s' % urllib.urlencode(params)
+
+ resp, body = self.get(url)
+ body = etree.fromstring(body)
+ volumes = []
+ if body is not None:
+ volumes += [self._parse_volume(vol) for vol in list(body)]
+ for v in volumes:
+ v = self._check_if_bootable(v)
+ return resp, volumes
+
+ def get_volume(self, volume_id):
+ """Returns the details of a single volume."""
+ url = "volumes/%s" % str(volume_id)
+ resp, body = self.get(url)
+ body = self._parse_volume(etree.fromstring(body))
+ body = self._check_if_bootable(body)
+ return resp, body
+
+ def create_volume(self, size, **kwargs):
+ """Creates a new Volume.
+
+ :param size: Size of volume in GB. (Required)
+ :param name: Optional Volume Name.
+ :param metadata: An optional dictionary of values for metadata.
+ :param volume_type: Optional Name of volume_type for the volume
+ :param snapshot_id: When specified the volume is created from
+ this snapshot
+ :param imageRef: When specified the volume is created from this
+ image
+ """
+ # NOTE(afazekas): it should use a volume namespace
+ volume = common.Element("volume", xmlns=common.XMLNS_11, size=size)
+
+ if 'metadata' in kwargs:
+ _metadata = common.Element('metadata')
+ volume.append(_metadata)
+ for key, value in kwargs['metadata'].items():
+ meta = common.Element('meta')
+ meta.add_attr('key', key)
+ meta.append(common.Text(value))
+ _metadata.append(meta)
+ attr_to_add = kwargs.copy()
+ del attr_to_add['metadata']
+ else:
+ attr_to_add = kwargs
+
+ for key, value in attr_to_add.items():
+ volume.add_attr(key, value)
+
+ 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 = common.Element("volume", xmlns=common.XMLNS_11, **kwargs)
+
+ resp, body = self.put('volumes/%s' % volume_id,
+ str(common.Document(put_body)))
+ body = common.xml_to_json(etree.fromstring(body))
+ return resp, body
+
+ def delete_volume(self, volume_id):
+ """Deletes the Specified Volume."""
+ return self.delete("volumes/%s" % str(volume_id))
+
+ def wait_for_volume_status(self, volume_id, status):
+ """Waits for a Volume to reach a given status."""
+ resp, body = self.get_volume(volume_id)
+ volume_status = body['status']
+ start = int(time.time())
+
+ while volume_status != status:
+ time.sleep(self.build_interval)
+ resp, body = self.get_volume(volume_id)
+ volume_status = body['status']
+ if volume_status == 'error':
+ raise exceptions.VolumeBuildErrorException(volume_id=volume_id)
+
+ if int(time.time()) - start >= self.build_timeout:
+ message = 'Volume %s failed to reach %s status within '\
+ 'the required time (%s s).' % (volume_id,
+ status,
+ self.build_timeout)
+ raise exceptions.TimeoutException(message)
+
+ def is_resource_deleted(self, id):
+ try:
+ self.get_volume(id)
+ except exceptions.NotFound:
+ return True
+ return False
+
+ def attach_volume(self, volume_id, instance_uuid, mountpoint):
+ """Attaches a volume to a given instance on a given 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(common.Document(post_body)))
+ if 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 = common.Element("os-detach")
+ url = 'volumes/%s/action' % str(volume_id)
+ resp, body = self.post(url, str(common.Document(post_body)))
+ if 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 = 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(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 = common.Element("os-extend",
+ new_size=extend_size)
+ url = 'volumes/%s/action' % str(volume_id)
+ resp, body = self.post(url, str(common.Document(post_body)))
+ if 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 = common.Element("os-reset_status",
+ status=status
+ )
+ url = 'volumes/%s/action' % str(volume_id)
+ resp, body = self.post(url, str(common.Document(post_body)))
+ if body:
+ body = common.xml_to_json(etree.fromstring(body))
+ return resp, body
+
+ def volume_begin_detaching(self, volume_id):
+ """Volume Begin Detaching."""
+ post_body = common.Element("os-begin_detaching")
+ url = 'volumes/%s/action' % str(volume_id)
+ resp, body = self.post(url, str(common.Document(post_body)))
+ if body:
+ body = common.xml_to_json(etree.fromstring(body))
+ return resp, body
+
+ def volume_roll_detaching(self, volume_id):
+ """Volume Roll Detaching."""
+ post_body = common.Element("os-roll_detaching")
+ url = 'volumes/%s/action' % str(volume_id)
+ resp, body = self.post(url, str(common.Document(post_body)))
+ if body:
+ body = common.xml_to_json(etree.fromstring(body))
+ return resp, body
+
+ def reserve_volume(self, volume_id):
+ """Reserves a volume."""
+ post_body = common.Element("os-reserve")
+ url = 'volumes/%s/action' % str(volume_id)
+ resp, body = self.post(url, str(common.Document(post_body)))
+ if body:
+ body = common.xml_to_json(etree.fromstring(body))
+ return resp, body
+
+ def unreserve_volume(self, volume_id):
+ """Restore a reserved volume ."""
+ post_body = common.Element("os-unreserve")
+ url = 'volumes/%s/action' % str(volume_id)
+ resp, body = self.post(url, str(common.Document(post_body)))
+ if 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 = common.Element("transfer", volume_id=vol_id)
+ if name:
+ post_body.add_attr('name', name)
+ resp, body = self.post('os-volume-transfer',
+ 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 = common.xml_to_json(etree.fromstring(body))
+ return resp, volume
+
+ def list_volume_transfers(self, params=None):
+ """List all the volume transfers created."""
+ url = 'os-volume-transfer'
+ if params:
+ url += '?%s' % urllib.urlencode(params)
+
+ resp, body = self.get(url)
+ body = etree.fromstring(body)
+ volumes = []
+ if body is not None:
+ volumes += [self._parse_volume_transfer(vol) for vol in list(body)]
+ return resp, volumes
+
+ def _parse_volume_transfer(self, body):
+ vol = dict((attr, body.get(attr)) for attr in body.keys())
+ for child in body.getchildren():
+ tag = child.tag
+ if tag.startswith("{"):
+ tag = tag.split("}", 1)
+ vol[tag] = common.xml_to_json(child)
+ return vol
+
+ def delete_volume_transfer(self, transfer_id):
+ """Delete a volume transfer."""
+ return self.delete("os-volume-transfer/%s" % str(transfer_id))
+
+ def accept_volume_transfer(self, transfer_id, transfer_auth_key):
+ """Accept a volume transfer."""
+ post_body = common.Element("accept", auth_key=transfer_auth_key)
+ url = 'os-volume-transfer/%s/accept' % transfer_id
+ 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 = common.Element("os-update_readonly_flag",
+ readonly=readonly)
+ url = 'volumes/%s/action' % str(volume_id)
+ resp, body = self.post(url, str(common.Document(post_body)))
+ if body:
+ body = common.xml_to_json(etree.fromstring(body))
+ return resp, body
+
+ def force_delete_volume(self, volume_id):
+ """Force Delete Volume."""
+ post_body = common.Element("os-force_delete")
+ url = 'volumes/%s/action' % str(volume_id)
+ resp, body = self.post(url, str(common.Document(post_body)))
+ if body:
+ body = common.xml_to_json(etree.fromstring(body))
+ return resp, body
+
+ def _metadata_body(self, meta):
+ post_body = common.Element('metadata')
+ for k, v in meta.items():
+ data = common.Element('meta', key=k)
+ data.append(common.Text(v))
+ post_body.append(data)
+ return post_body
+
+ def _parse_key_value(self, node):
+ """Parse <foo key='key'>value</foo> data into {'key': 'value'}."""
+ data = {}
+ for node in node.getchildren():
+ data[node.get('key')] = node.text
+ return data
+
+ def create_volume_metadata(self, volume_id, metadata):
+ """Create metadata for the volume."""
+ post_body = self._metadata_body(metadata)
+ resp, body = self.post('volumes/%s/metadata' % volume_id,
+ str(common.Document(post_body)))
+ body = self._parse_key_value(etree.fromstring(body))
+ return resp, body
+
+ def get_volume_metadata(self, volume_id):
+ """Get metadata of the volume."""
+ url = "volumes/%s/metadata" % str(volume_id)
+ resp, body = self.get(url)
+ body = self._parse_key_value(etree.fromstring(body))
+ return resp, body
+
+ def update_volume_metadata(self, volume_id, metadata):
+ """Update metadata for the volume."""
+ put_body = self._metadata_body(metadata)
+ url = "volumes/%s/metadata" % str(volume_id)
+ 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 = 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(common.Document(put_body)))
+ body = common.xml_to_json(etree.fromstring(body))
+ return resp, body
+
+ def delete_volume_metadata_item(self, volume_id, id):
+ """Delete metadata item for the volume."""
+ url = "volumes/%s/metadata/%s" % (str(volume_id), str(id))
+ return self.delete(url)
diff --git a/tempest/services/volume/xml/admin/volume_hosts_client.py b/tempest/services/volume/xml/admin/volume_hosts_client.py
index 7278fd9..e34b9f0 100644
--- a/tempest/services/volume/xml/admin/volume_hosts_client.py
+++ b/tempest/services/volume/xml/admin/volume_hosts_client.py
@@ -1,4 +1,4 @@
-# Copyright 2013 Openstack Foundation.
+# Copyright 2013 OpenStack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -17,17 +17,18 @@
from lxml import etree
-from tempest.common.rest_client import RestClientXML
+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
-class VolumeHostsClientXML(RestClientXML):
+class VolumeHostsClientXML(rest_client.RestClient):
"""
Client class to send CRUD Volume Hosts API requests to a Cinder endpoint
"""
+ TYPE = "xml"
def __init__(self, auth_provider):
super(VolumeHostsClientXML, self).__init__(auth_provider)
@@ -57,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):
@@ -67,6 +68,6 @@
if params:
url += '?%s' % urllib.urlencode(params)
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
body = self._parse_array(etree.fromstring(body))
return resp, body
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 29ba431..1fa3e73 100644
--- a/tempest/services/volume/xml/admin/volume_types_client.py
+++ b/tempest/services/volume/xml/admin/volume_types_client.py
@@ -17,22 +17,19 @@
from lxml import etree
-from tempest.common.rest_client import RestClientXML
+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
-class VolumeTypesClientXML(RestClientXML):
+class VolumeTypesClientXML(rest_client.RestClient):
"""
Client class to send CRUD Volume Types API requests to a Cinder endpoint
"""
+ TYPE = "xml"
def __init__(self, auth_provider):
super(VolumeTypesClientXML, self).__init__(auth_provider)
@@ -52,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):
@@ -63,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):
@@ -72,7 +69,7 @@
if params:
url += '?%s' % urllib.urlencode(params)
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
body = etree.fromstring(body)
volume_types = []
if body is not None:
@@ -83,7 +80,7 @@
def get_volume_type(self, type_id):
"""Returns the details of a single volume_type."""
url = "types/%s" % str(type_id)
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
body = etree.fromstring(body)
return resp, self._parse_volume_type(body)
@@ -94,23 +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)),
- self.headers)
- 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):
@@ -124,7 +120,7 @@
if params:
url += '?%s' % urllib.urlencode(params)
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
body = etree.fromstring(body)
extra_specs = []
if body is not None:
@@ -136,7 +132,7 @@
"""Returns the details of a single volume_type extra spec."""
url = "types/%s/extra_specs/%s" % (str(vol_type_id),
str(extra_spec_name))
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
body = etree.fromstring(body)
return resp, self._parse_volume_type_extra_specs(body)
@@ -147,22 +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)),
- self.headers)
- 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):
@@ -181,18 +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)),
- self.headers)
- 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/backups_client.py b/tempest/services/volume/xml/backups_client.py
new file mode 100644
index 0000000..81caaee
--- /dev/null
+++ b/tempest/services/volume/xml/backups_client.py
@@ -0,0 +1,26 @@
+# Copyright 2014 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.
+
+from tempest.services.volume.json import backups_client
+
+
+class BackupsClientXML(backups_client.BackupsClientJSON):
+ """
+ Client class to send CRUD Volume Backup API requests to a Cinder endpoint
+ """
+ TYPE = "xml"
+
+ #TODO(gfidente): XML client isn't yet implemented because of bug 1270589
+ pass
diff --git a/tempest/services/volume/xml/extensions_client.py b/tempest/services/volume/xml/extensions_client.py
index 21e1d04..4861733 100644
--- a/tempest/services/volume/xml/extensions_client.py
+++ b/tempest/services/volume/xml/extensions_client.py
@@ -15,14 +15,15 @@
from lxml import etree
-from tempest.common.rest_client import RestClientXML
+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
-class ExtensionsClientXML(RestClientXML):
+class ExtensionsClientXML(rest_client.RestClient):
+ TYPE = "xml"
def __init__(self, auth_provider):
super(ExtensionsClientXML, self).__init__(auth_provider)
@@ -31,11 +32,11 @@
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):
url = 'extensions'
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
body = self._parse_array(etree.fromstring(body))
return resp, body
diff --git a/tempest/services/volume/xml/snapshots_client.py b/tempest/services/volume/xml/snapshots_client.py
index 4f066a6..9ad86d2 100644
--- a/tempest/services/volume/xml/snapshots_client.py
+++ b/tempest/services/volume/xml/snapshots_client.py
@@ -15,23 +15,20 @@
from lxml import etree
-from tempest.common.rest_client import RestClientXML
+from tempest.common import rest_client
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
LOG = logging.getLogger(__name__)
-class SnapshotsClientXML(RestClientXML):
+class SnapshotsClientXML(rest_client.RestClient):
"""Client class to send CRUD Volume API requests."""
+ TYPE = "xml"
def __init__(self, auth_provider):
super(SnapshotsClientXML, self).__init__(auth_provider)
@@ -47,11 +44,11 @@
if params:
url += '?%s' % urllib.urlencode(params)
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
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):
@@ -61,19 +58,19 @@
if params:
url += '?%s' % urllib.urlencode(params)
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
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):
"""Returns the details of a single snapshot."""
url = "snapshots/%s" % str(snapshot_id)
- resp, body = self.get(url, self.headers)
+ 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.
@@ -83,22 +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)),
- self.headers)
- 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)),
- self.headers)
- 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
@@ -151,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)), self.headers)
+ 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)), self.headers)
+ 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
@@ -191,15 +186,14 @@
"""Create metadata for the snapshot."""
post_body = self._metadata_body(metadata)
resp, body = self.post('snapshots/%s/metadata' % snapshot_id,
- str(Document(post_body)),
- self.headers)
+ str(common.Document(post_body)))
body = self._parse_key_value(etree.fromstring(body))
return resp, body
def get_snapshot_metadata(self, snapshot_id):
"""Get metadata of the snapshot."""
url = "snapshots/%s/metadata" % str(snapshot_id)
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
body = self._parse_key_value(etree.fromstring(body))
return resp, body
@@ -207,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)), self.headers)
+ 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)), self.headers)
- 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):
@@ -228,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)), self.headers)
+ 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 deb56fd..8e886ce 100644
--- a/tempest/services/volume/xml/volumes_client.py
+++ b/tempest/services/volume/xml/volumes_client.py
@@ -17,23 +17,21 @@
import urllib
from lxml import etree
+from xml.sax import saxutils
-from tempest.common.rest_client import RestClientXML
+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
-class VolumesClientXML(RestClientXML):
+class VolumesClientXML(rest_client.RestClient):
"""
Client class to send CRUD Volume API requests to a Cinder endpoint
"""
+ TYPE = "xml"
def __init__(self, auth_provider):
super(VolumesClientXML, self).__init__(auth_provider)
@@ -53,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):
@@ -87,7 +85,7 @@
if params:
url += '?%s' % urllib.urlencode(params)
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
body = etree.fromstring(body)
volumes = []
if body is not None:
@@ -103,7 +101,7 @@
if params:
url += '?%s' % urllib.urlencode(params)
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
body = etree.fromstring(body)
volumes = []
if body is not None:
@@ -115,7 +113,7 @@
def get_volume(self, volume_id):
"""Returns the details of a single volume."""
url = "volumes/%s" % str(volume_id)
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
body = self._parse_volume(etree.fromstring(body))
body = self._check_if_bootable(body)
return resp, body
@@ -133,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']
@@ -151,19 +149,17 @@
for key, value in attr_to_add.items():
volume.add_attr(key, value)
- resp, body = self.post('volumes', str(Document(volume)),
- self.headers)
- 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)),
- self.headers)
- 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,109 +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)), self.headers)
+ 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)), self.headers)
+ 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)), self.headers)
- 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)), self.headers)
+ 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)), self.headers)
+ 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)), self.headers)
+ 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)), self.headers)
+ 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)), self.headers)
+ 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)), self.headers)
+ 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)),
- self.headers)
- 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, self.headers)
- volume = xml_to_json(etree.fromstring(body))
+ resp, body = self.get(url)
+ volume = common.xml_to_json(etree.fromstring(body))
return resp, volume
def list_volume_transfers(self, params=None):
@@ -310,7 +305,7 @@
if params:
url += '?%s' % urllib.urlencode(params)
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
body = etree.fromstring(body)
volumes = []
if body is not None:
@@ -323,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):
@@ -332,36 +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)), self.headers)
- 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)), self.headers)
+ 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)), self.headers)
+ 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)
+ # Escape value to allow for special XML chars
+ data.append(common.Text(saxutils.escape(v)))
post_body.append(data)
return post_body
@@ -376,15 +372,14 @@
"""Create metadata for the volume."""
post_body = self._metadata_body(metadata)
resp, body = self.post('volumes/%s/metadata' % volume_id,
- str(Document(post_body)),
- self.headers)
+ str(common.Document(post_body)))
body = self._parse_key_value(etree.fromstring(body))
return resp, body
def get_volume_metadata(self, volume_id):
"""Get metadata of the volume."""
url = "volumes/%s/metadata" % str(volume_id)
- resp, body = self.get(url, self.headers)
+ resp, body = self.get(url)
body = self._parse_key_value(etree.fromstring(body))
return resp, body
@@ -392,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)), self.headers)
+ 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)), self.headers)
- 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/stress/actions/ssh_floating.py b/tempest/stress/actions/ssh_floating.py
index a34a20d..c330165 100644
--- a/tempest/stress/actions/ssh_floating.py
+++ b/tempest/stress/actions/ssh_floating.py
@@ -69,7 +69,7 @@
servers_client = self.manager.servers_client
self.logger.info("creating %s" % name)
vm_args = self.vm_extra_args.copy()
- vm_args['security_groups'] = [{'name': self.sec_grp}]
+ vm_args['security_groups'] = [self.sec_grp]
resp, server = servers_client.create_server(name, self.image,
self.flavor,
**vm_args)
@@ -90,16 +90,15 @@
sec_grp_cli = self.manager.security_groups_client
s_name = data_utils.rand_name('sec_grp-')
s_description = data_utils.rand_name('desc-')
- _, _sec_grp = sec_grp_cli.create_security_group(s_name,
- s_description)
- self.sec_grp = _sec_grp['id']
+ _, self.sec_grp = sec_grp_cli.create_security_group(s_name,
+ s_description)
create_rule = sec_grp_cli.create_security_group_rule
- create_rule(self.sec_grp, 'tcp', 22, 22)
- create_rule(self.sec_grp, 'icmp', -1, -1)
+ create_rule(self.sec_grp['id'], 'tcp', 22, 22)
+ create_rule(self.sec_grp['id'], 'icmp', -1, -1)
def _destroy_sec_grp(self):
sec_grp_cli = self.manager.security_groups_client
- sec_grp_cli.delete_security_group(self.sec_grp)
+ sec_grp_cli.delete_security_group(self.sec_grp['id'])
def _create_floating_ip(self):
floating_cli = self.manager.floating_ips_client
diff --git a/tempest/stress/cleanup.py b/tempest/stress/cleanup.py
index b46de35..2587331 100644
--- a/tempest/stress/cleanup.py
+++ b/tempest/stress/cleanup.py
@@ -45,6 +45,16 @@
except Exception:
pass
+ secgrp_client = admin_manager.security_groups_client
+ _, secgrp = secgrp_client.list_security_groups({"all_tenants": True})
+ secgrp_del = [grp for grp in secgrp if grp['name'] != 'default']
+ LOG.info("Cleanup::remove %s Security Group" % len(secgrp_del))
+ for g in secgrp_del:
+ try:
+ secgrp_client.delete_security_group(g['id'])
+ except Exception:
+ pass
+
_, floating_ips = admin_manager.floating_ips_client.list_floating_ips()
LOG.info("Cleanup::remove %s floating ips" % len(floating_ips))
for f in floating_ips:
diff --git a/tempest/stress/driver.py b/tempest/stress/driver.py
index d4689c4..9660081 100644
--- a/tempest/stress/driver.py
+++ b/tempest/stress/driver.py
@@ -17,6 +17,8 @@
import signal
import time
+from six import moves
+
from tempest import clients
from tempest.common import ssh
from tempest.common.utils import data_utils
@@ -128,7 +130,7 @@
manager = admin_manager
else:
manager = clients.Manager()
- for p_number in xrange(test.get('threads', default_thread_num)):
+ for p_number in moves.xrange(test.get('threads', default_thread_num)):
if test.get('use_isolated_tenants', False):
username = data_utils.rand_name("stress_user")
tenant_name = data_utils.rand_name("stress_tenant")
@@ -220,7 +222,7 @@
LOG.info("Run %d actions (%d failed)" %
(sum_runs, sum_fails))
- if not had_errors:
+ if not had_errors and CONF.stress.full_clean_stack:
LOG.info("cleaning up")
cleanup.cleanup()
if had_errors:
diff --git a/tempest/stress/run_stress.py b/tempest/stress/run_stress.py
index 76320d0..c7c17c0 100755
--- a/tempest/stress/run_stress.py
+++ b/tempest/stress/run_stress.py
@@ -18,7 +18,7 @@
import inspect
import json
import sys
-from testtools.testsuite import iterate_tests
+from testtools import testsuite
try:
from unittest import loader
except ImportError:
@@ -38,7 +38,7 @@
tests = []
testloader = loader.TestLoader()
list = testloader.discover(path)
- for func in (iterate_tests(list)):
+ for func in (testsuite.iterate_tests(list)):
attrs = []
try:
method_name = getattr(func, '_testMethodName')
@@ -87,8 +87,13 @@
# NOTE(mkoderer): we just save the last result code
if (step_result != 0):
result = step_result
+ if ns.stop:
+ return result
else:
- driver.stress_openstack(tests, ns.duration, ns.number, ns.stop)
+ result = driver.stress_openstack(tests,
+ ns.duration,
+ ns.number,
+ ns.stop)
return result
diff --git a/tempest/test.py b/tempest/test.py
index 5464c03..75eb6be 100644
--- a/tempest/test.py
+++ b/tempest/test.py
@@ -17,20 +17,23 @@
import functools
import json
import os
+import sys
import time
import urllib
import uuid
import fixtures
-import nose.plugins.attrib
import testresources
import testtools
+from oslo.config import cfg
+
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__)
@@ -42,11 +45,10 @@
def attr(*args, **kwargs):
- """A decorator which applies the nose and testtools attr decorator
+ """A decorator which applies the testtools attr decorator
- This decorator applies the nose attr decorator as well as the
- the testtools.testcase.attr if it is in the list of attributes
- to testtools we want to apply.
+ This decorator applies the testtools.testcase.attr if it is in the list of
+ attributes to testtools we want to apply.
"""
def decorator(f):
@@ -59,7 +61,26 @@
f = testtools.testcase.attr(attr)(f)
if attr == 'smoke':
f = testtools.testcase.attr('gate')(f)
- return nose.plugins.attrib.attr(*args, **kwargs)(f)
+ return f
+
+ return decorator
+
+
+def safe_setup(f):
+ """A decorator used to wrap the setUpClass for cleaning up resources
+ when setUpClass failed.
+ """
+
+ def decorator(cls):
+ try:
+ f(cls)
+ except Exception as se:
+ LOG.exception("setUpClass failed: %s" % se)
+ try:
+ cls.tearDownClass()
+ except Exception as te:
+ LOG.exception("tearDownClass failed: %s" % te)
+ raise se
return decorator
@@ -70,16 +91,35 @@
This decorator applies a testtools attr for each service that gets
exercised by a test case.
"""
- valid_service_list = ['compute', 'image', 'volume', 'orchestration',
- 'network', 'identity', 'object_storage', 'dashboard']
+ service_list = {
+ 'compute': CONF.service_available.nova,
+ 'image': CONF.service_available.glance,
+ 'volume': CONF.service_available.cinder,
+ 'orchestration': CONF.service_available.heat,
+ # NOTE(mtreinish) nova-network will provide networking functionality
+ # if neutron isn't available, so always set to True.
+ 'network': True,
+ 'identity': True,
+ 'object_storage': CONF.service_available.swift,
+ 'dashboard': CONF.service_available.horizon,
+ }
def decorator(f):
for service in args:
- if service not in valid_service_list:
+ if service not in service_list:
raise exceptions.InvalidServiceTag('%s is not a valid service'
% service)
attr(type=list(args))(f)
- return f
+
+ @functools.wraps(f)
+ def wrapper(self, *func_args, **func_kwargs):
+ for service in args:
+ if not service_list[service]:
+ msg = 'Skipped because the %s service is not available' % (
+ service)
+ raise testtools.TestCase.skipException(msg)
+ return f(self, *func_args, **func_kwargs)
+ return wrapper
return decorator
@@ -129,6 +169,8 @@
else:
skip = True
if "bug" in kwargs and skip is True:
+ if not kwargs['bug'].isdigit():
+ raise ValueError('bug must be a valid bug number')
msg = "Skipped until Bug: %s is resolved." % kwargs["bug"]
raise testtools.TestCase.skipException(msg)
return f(self, *func_args, **func_kwargs)
@@ -172,60 +214,37 @@
return True
return False
-# there is a mis-match between nose and testtools for older pythons.
-# testtools will set skipException to be either
-# unittest.case.SkipTest, unittest2.case.SkipTest or an internal skip
-# exception, depending on what it can find. Python <2.7 doesn't have
-# unittest.case.SkipTest; so if unittest2 is not installed it falls
-# back to the internal class.
-#
-# The current nose skip plugin will decide to raise either
-# unittest.case.SkipTest or its own internal exception; it does not
-# look for unittest2 or the internal unittest exception. Thus we must
-# monkey-patch testtools.TestCase.skipException to be the exception
-# the nose skip plugin expects.
-#
-# However, with the switch to testr nose may not be available, so we
-# require you to opt-in to this fix with an environment variable.
-#
-# This is temporary until upstream nose starts looking for unittest2
-# as testtools does; we can then remove this and ensure unittest2 is
-# available for older pythons; then nose and testtools will agree
-# unittest2.case.SkipTest is the one-true skip test exception.
-#
-# https://review.openstack.org/#/c/33056
-# https://github.com/nose-devs/nose/pull/699
-if 'TEMPEST_PY26_NOSE_COMPAT' in os.environ:
- try:
- import unittest.case.SkipTest
- # convince pep8 we're using the import...
- if unittest.case.SkipTest:
- pass
- raise RuntimeError("You have unittest.case.SkipTest; "
- "no need to override")
- except ImportError:
- LOG.info("Overriding skipException to nose SkipTest")
- testtools.TestCase.skipException = nose.plugins.skip.SkipTest
at_exit_set = set()
def validate_tearDownClass():
if at_exit_set:
- raise RuntimeError("tearDownClass does not call the super's "
- "tearDownClass in these classes: "
- + str(at_exit_set) + "\n"
- "If you see the exception, with another "
- "exception please do not report this one! "
- "If you are changing tempest code, make sure you "
- "are calling the super class's tearDownClass!")
+ LOG.error(
+ "tearDownClass does not call the super's "
+ "tearDownClass in these classes: \n"
+ + str(at_exit_set))
+
atexit.register(validate_tearDownClass)
-
-class BaseTestCase(testtools.TestCase,
+if sys.version_info >= (2, 7):
+ class BaseDeps(testtools.TestCase,
testtools.testcase.WithAttributes,
testresources.ResourcedTestCase):
+ pass
+else:
+ # Define asserts for py26
+ import unittest2
+
+ class BaseDeps(testtools.TestCase,
+ testtools.testcase.WithAttributes,
+ testresources.ResourcedTestCase,
+ unittest2.TestCase):
+ pass
+
+
+class BaseTestCase(BaseDeps):
setUpClassCalled = False
_service = None
@@ -277,7 +296,7 @@
@classmethod
def get_client_manager(cls, interface=None):
"""
- Returns an Openstack client manager
+ Returns an OpenStack client manager
"""
cls.isolated_creds = isolated_creds.IsolatedCreds(
cls.__name__, network_resources=cls.network_resources)
@@ -353,6 +372,12 @@
'subnet': subnet,
'dhcp': dhcp}
+ def assertEmpty(self, list, msg=None):
+ self.assertTrue(len(list) == 0, msg)
+
+ def assertNotEmpty(self, list, msg=None):
+ self.assertTrue(len(list) > 0, msg)
+
class NegativeAutoTest(BaseTestCase):
@@ -363,6 +388,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):
@@ -401,21 +429,40 @@
"""
description = NegativeAutoTest.load_schema(description_file)
LOG.debug(description)
- generate_json.validate_negative_test_schema(description)
+
+ # NOTE(mkoderer): since this will be executed on import level the
+ # config doesn't have to be in place (e.g. for the pep8 job).
+ # In this case simply return.
+ try:
+ generator = importutils.import_class(
+ CONF.negative.test_generator)()
+ except cfg.ConfigFilesNotFoundError:
+ LOG.critical(
+ "Tempest config not found. Test scenarios aren't created")
+ return
+ generator.validate_schema(description)
schema = description.get("json-schema", None)
resources = description.get("resources", [])
scenario_list = []
+ expected_result = None
for resource in resources:
+ if isinstance(resource, dict):
+ expected_result = resource['expected_result']
+ resource = resource['name']
LOG.debug("Add resource to test %s" % resource)
scn_name = "inv_res_%s" % (resource)
scenario_list.append((scn_name, {"resource": (resource,
- str(uuid.uuid4()))
+ str(uuid.uuid4())),
+ "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
@@ -455,21 +502,22 @@
# 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)
- resp, resp_body = self.client.send_request(method, new_url,
- resources, body=body)
- self._check_negative_response(resp.status, resp_body)
- return
-
- if hasattr(self, "schema"):
+ 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)
- self._check_negative_response(resp.status, resp_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):
LOG.debug("dict: %s url: %s method: %s" % (json_dict, url, method))
@@ -510,6 +558,8 @@
:param name: The name of the kind of resource such as "flavor", "role",
etc.
"""
+ if isinstance(name, dict):
+ name = name['name']
if hasattr(self, "resource") and self.resource[0] == name:
LOG.debug("Return invalid resource (%s) value: %s" %
(self.resource[0], self.resource[1]))
diff --git a/tempest/tests/common/__init__.py b/tempest/tests/common/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/tests/common/__init__.py
diff --git a/tempest/tests/common/utils/__init__.py b/tempest/tests/common/utils/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/tests/common/utils/__init__.py
diff --git a/tempest/tests/common/utils/test_data_utils.py b/tempest/tests/common/utils/test_data_utils.py
new file mode 100644
index 0000000..7aafdb2
--- /dev/null
+++ b/tempest/tests/common/utils/test_data_utils.py
@@ -0,0 +1,77 @@
+# 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.
+
+
+from tempest.common.utils import data_utils
+from tempest.tests import base
+
+
+class TestDataUtils(base.TestCase):
+
+ def test_rand_uuid(self):
+ actual = data_utils.rand_uuid()
+ self.assertIsInstance(actual, str)
+ self.assertRegexpMatches(actual, "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]"
+ "{4}-[0-9a-f]{4}-[0-9a-f]{12}$")
+ actual2 = data_utils.rand_uuid()
+ self.assertNotEqual(actual, actual2)
+
+ def test_rand_uuid_hex(self):
+ actual = data_utils.rand_uuid_hex()
+ self.assertIsInstance(actual, str)
+ self.assertRegexpMatches(actual, "^[0-9a-f]{32}$")
+
+ actual2 = data_utils.rand_uuid_hex()
+ self.assertNotEqual(actual, actual2)
+
+ def test_rand_name(self):
+ actual = data_utils.rand_name()
+ self.assertIsInstance(actual, str)
+ actual2 = data_utils.rand_name()
+ self.assertNotEqual(actual, actual2)
+
+ actual = data_utils.rand_name('foo')
+ self.assertTrue(actual.startswith('foo'))
+ actual2 = data_utils.rand_name('foo')
+ self.assertTrue(actual.startswith('foo'))
+ self.assertNotEqual(actual, actual2)
+
+ def test_rand_int(self):
+ actual = data_utils.rand_int_id()
+ self.assertIsInstance(actual, int)
+
+ actual2 = data_utils.rand_int_id()
+ self.assertNotEqual(actual, actual2)
+
+ def test_rand_mac_address(self):
+ actual = data_utils.rand_mac_address()
+ self.assertIsInstance(actual, str)
+ self.assertRegexpMatches(actual, "^([0-9a-f][0-9a-f]:){5}"
+ "[0-9a-f][0-9a-f]$")
+
+ actual2 = data_utils.rand_mac_address()
+ self.assertNotEqual(actual, actual2)
+
+ def test_parse_image_id(self):
+ actual = data_utils.parse_image_id("/foo/bar/deadbeaf")
+ self.assertEqual("deadbeaf", actual)
+
+ def test_arbitrary_string(self):
+ actual = data_utils.arbitrary_string()
+ self.assertEqual(actual, "test")
+ actual = data_utils.arbitrary_string(size=30, base_text="abc")
+ self.assertEqual(actual, "abc" * (30 / len("abc")))
+ actual = data_utils.arbitrary_string(size=5, base_text="deadbeaf")
+ self.assertEqual(actual, "deadb")
diff --git a/tempest/tests/common/utils/test_misc.py b/tempest/tests/common/utils/test_misc.py
new file mode 100644
index 0000000..b8c6184
--- /dev/null
+++ b/tempest/tests/common/utils/test_misc.py
@@ -0,0 +1,52 @@
+# 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.
+
+
+from tempest.common.utils import misc
+from tempest.tests import base
+
+
+@misc.singleton
+class TestFoo(object):
+
+ count = 0
+
+ def increment(self):
+ self.count += 1
+ return self.count
+
+
+@misc.singleton
+class TestBar(object):
+
+ count = 0
+
+ def increment(self):
+ self.count += 1
+ return self.count
+
+
+class TestMisc(base.TestCase):
+
+ def test_singleton(self):
+ test = TestFoo()
+ self.assertEqual(0, test.count)
+ self.assertEqual(1, test.increment())
+ test2 = TestFoo()
+ self.assertEqual(1, test.count)
+ self.assertEqual(1, test2.count)
+ self.assertEqual(test, test2)
+ test3 = TestBar()
+ self.assertNotEqual(test, test3)
diff --git a/tempest/tests/fake_config.py b/tempest/tests/fake_config.py
index a50aaeb..8a8ebb0 100644
--- a/tempest/tests/fake_config.py
+++ b/tempest/tests/fake_config.py
@@ -12,15 +12,33 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo.config import cfg
-class FakeConfig(object):
+from tempest import config
+from tempest.openstack.common.fixture import config as conf_fixture
- class fake_compute(object):
- build_interval = 10
- build_timeout = 10
- class fake_identity(object):
- disable_ssl_certificate_validation = True
+class ConfigFixture(conf_fixture.Config):
- compute = fake_compute()
- identity = fake_identity()
+ def __init__(self):
+ config.register_opts()
+ super(ConfigFixture, self).__init__()
+
+ def setUp(self):
+ super(ConfigFixture, self).setUp()
+ self.conf.set_default('build_interval', 10, group='compute')
+ self.conf.set_default('build_timeout', 10, group='compute')
+ self.conf.set_default('disable_ssl_certificate_validation', True,
+ group='identity')
+ self.conf.set_default('uri', 'http://fake_uri.com/auth',
+ group='identity')
+ self.conf.set_default('uri_v3', 'http://fake_uri_v3.com/auth',
+ group='identity')
+ self.conf.set_default('neutron', True, group='service_available')
+ self.conf.set_default('heat', True, group='service_available')
+
+
+class FakePrivate(config.TempestConfigPrivate):
+ def __init__(self):
+ cfg.CONF([], default_config_files=[])
+ self._set_attrs()
diff --git a/tempest/tests/fake_http.py b/tempest/tests/fake_http.py
index ac5f765..a09d5ba 100644
--- a/tempest/tests/fake_http.py
+++ b/tempest/tests/fake_http.py
@@ -17,7 +17,7 @@
class fake_httplib2(object):
- def __init__(self, return_type=None):
+ def __init__(self, return_type=None, *args, **kwargs):
self.return_type = return_type
def request(self, uri, method="GET", body=None, headers=None,
diff --git a/tempest/tests/fake_identity.py b/tempest/tests/fake_identity.py
new file mode 100644
index 0000000..058c9c2
--- /dev/null
+++ b/tempest/tests/fake_identity.py
@@ -0,0 +1,163 @@
+# Copyright 2014 IBM Corp.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+
+import httplib2
+import json
+
+
+TOKEN = "fake_token"
+ALT_TOKEN = "alt_fake_token"
+
+# Fake Identity v2 constants
+COMPUTE_ENDPOINTS_V2 = {
+ "endpoints": [
+ {
+ "adminURL": "http://fake_url/v2/first_endpoint/admin",
+ "region": "NoMatchRegion",
+ "internalURL": "http://fake_url/v2/first_endpoint/internal",
+ "publicURL": "http://fake_url/v2/first_endpoint/public"
+ },
+ {
+ "adminURL": "http://fake_url/v2/second_endpoint/admin",
+ "region": "FakeRegion",
+ "internalURL": "http://fake_url/v2/second_endpoint/internal",
+ "publicURL": "http://fake_url/v2/second_endpoint/public"
+ },
+ ],
+ "type": "compute",
+ "name": "nova"
+}
+
+CATALOG_V2 = [COMPUTE_ENDPOINTS_V2, ]
+
+ALT_IDENTITY_V2_RESPONSE = {
+ "access": {
+ "token": {
+ "expires": "2020-01-01T00:00:10Z",
+ "id": ALT_TOKEN,
+ "tenant": {
+ "id": "fake_tenant_id"
+ },
+ },
+ "user": {
+ "id": "fake_user_id",
+ },
+ "serviceCatalog": CATALOG_V2,
+ },
+}
+
+IDENTITY_V2_RESPONSE = {
+ "access": {
+ "token": {
+ "expires": "2020-01-01T00:00:10Z",
+ "id": TOKEN,
+ "tenant": {
+ "id": "fake_tenant_id"
+ },
+ },
+ "user": {
+ "id": "fake_user_id",
+ },
+ "serviceCatalog": CATALOG_V2,
+ },
+}
+
+# Fake Identity V3 constants
+COMPUTE_ENDPOINTS_V3 = {
+ "endpoints": [
+ {
+ "id": "first_compute_fake_service",
+ "interface": "public",
+ "region": "NoMatchRegion",
+ "url": "http://fake_url/v3/first_endpoint/api"
+ },
+ {
+ "id": "second_fake_service",
+ "interface": "public",
+ "region": "FakeRegion",
+ "url": "http://fake_url/v3/second_endpoint/api"
+ },
+ {
+ "id": "third_fake_service",
+ "interface": "admin",
+ "region": "MiddleEarthRegion",
+ "url": "http://fake_url/v3/third_endpoint/api"
+ }
+
+ ],
+ "type": "compute",
+ "id": "fake_compute_endpoint"
+}
+
+CATALOG_V3 = [COMPUTE_ENDPOINTS_V3, ]
+
+IDENTITY_V3_RESPONSE = {
+ "token": {
+ "methods": [
+ "token",
+ "password"
+ ],
+ "expires_at": "2020-01-01T00:00:10.000123Z",
+ "project": {
+ "domain": {
+ "id": "fake_id",
+ "name": "fake"
+ },
+ "id": "project_id",
+ "name": "project_name"
+ },
+ "user": {
+ "domain": {
+ "id": "domain_id",
+ "name": "domain_name"
+ },
+ "id": "fake_user_id",
+ "name": "username"
+ },
+ "issued_at": "2013-05-29T16:55:21.468960Z",
+ "catalog": CATALOG_V3
+ }
+}
+
+ALT_IDENTITY_V3 = IDENTITY_V3_RESPONSE
+
+
+def _fake_v3_response(self, uri, method="GET", body=None, headers=None,
+ redirections=5, connection_type=None):
+ fake_headers = {
+ "status": "201",
+ "x-subject-token": TOKEN
+ }
+ return (httplib2.Response(fake_headers),
+ json.dumps(IDENTITY_V3_RESPONSE))
+
+
+def _fake_v2_response(self, uri, method="GET", body=None, headers=None,
+ redirections=5, connection_type=None):
+ return (httplib2.Response({"status": "200"}),
+ json.dumps(IDENTITY_V2_RESPONSE))
+
+
+def _fake_auth_failure_response():
+ # the response body isn't really used in this case, but lets send it anyway
+ # to have a safe check in some future change on the rest client.
+ body = {
+ "unauthorized": {
+ "message": "Unauthorized",
+ "code": "401"
+ }
+ }
+ return httplib2.Response({"status": "401"}), json.dumps(body)
diff --git a/tempest/tests/files/setup.cfg b/tempest/tests/files/setup.cfg
index 8639baa..f6f9f73 100644
--- a/tempest/tests/files/setup.cfg
+++ b/tempest/tests/files/setup.cfg
@@ -2,8 +2,8 @@
name = tempest_unit_tests
version = 1
summary = Fake Project for testing wrapper scripts
-author = OpenStack QA
-author-email = openstack-qa@lists.openstack.org
+author = OpenStack
+author-email = openstack-dev@lists.openstack.org
home-page = http://www.openstack.org/
classifier =
Intended Audience :: Information Technology
diff --git a/tempest/tests/negative/__init__.py b/tempest/tests/negative/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/tests/negative/__init__.py
diff --git a/tempest/tests/negative/test_generate_json.py b/tempest/tests/negative/test_generate_json.py
new file mode 100644
index 0000000..e09fcdf
--- /dev/null
+++ b/tempest/tests/negative/test_generate_json.py
@@ -0,0 +1,57 @@
+# 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.
+
+from tempest.common.generator import negative_generator
+import tempest.test
+
+
+class TestNegativeGenerator(tempest.test.BaseTestCase):
+
+ fake_input_str = {"type": "string",
+ "minLength": 2,
+ "maxLength": 8,
+ 'results': {'gen_number': 404}}
+
+ fake_input_int = {"type": "integer",
+ "maximum": 255,
+ "minimum": 1}
+
+ fake_input_obj = {"type": "object",
+ "properties": {"minRam": {"type": "integer"},
+ "diskName": {"type": "string"},
+ "maxRam": {"type": "integer", }
+ }
+ }
+
+ 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 = self.negative.generate(self.fake_input_str)
+ self._validate_result(result)
+
+ def test_generate_invalid_integer(self):
+ result = self.negative.generate(self.fake_input_int)
+ self._validate_result(result)
+
+ def test_generate_invalid_obj(self):
+ 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
new file mode 100644
index 0000000..7a1909a
--- /dev/null
+++ b/tempest/tests/negative/test_negative_auto_test.py
@@ -0,0 +1,72 @@
+# 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 mock
+
+from tempest import config
+import tempest.test as test
+from tempest.tests import base
+from tempest.tests import fake_config
+
+
+class TestNegativeAutoTest(base.TestCase):
+ # Fake entries
+ _interface = 'json'
+ _service = 'compute'
+
+ fake_input_desc = {"name": "list-flavors-with-detail",
+ "http-method": "GET",
+ "url": "flavors/detail",
+ "json-schema": {"type": "object",
+ "properties":
+ {"minRam": {"type": "integer"},
+ "minDisk": {"type": "integer"}}
+ },
+ "resources": ["flavor", "volume", "image"]
+ }
+
+ def setUp(self):
+ super(TestNegativeAutoTest, self).setUp()
+ self.useFixture(fake_config.ConfigFixture())
+ self.stubs.Set(config, 'TempestConfigPrivate', fake_config.FakePrivate)
+
+ def _check_prop_entries(self, result, entry):
+ entries = [a for a in result if entry in a[0]]
+ self.assertIsNotNone(entries)
+ self.assertIs(len(entries), 2)
+ for entry in entries:
+ self.assertIsNotNone(entry[1]['schema'])
+
+ def _check_resource_entries(self, result, entry):
+ entries = [a for a in result if entry in a[0]]
+ self.assertIsNotNone(entries)
+ self.assertIs(len(entries), 3)
+ for entry in entries:
+ self.assertIsNotNone(entry[1]['resource'])
+
+ @mock.patch('tempest.test.NegativeAutoTest.load_schema')
+ def test_generate_scenario(self, open_mock):
+ open_mock.return_value = self.fake_input_desc
+ scenarios = test.NegativeAutoTest.\
+ generate_scenario(None)
+
+ self.assertIsInstance(scenarios, list)
+ for scenario in scenarios:
+ self.assertIsInstance(scenario, tuple)
+ self.assertIsInstance(scenario[0], str)
+ self.assertIsInstance(scenario[1], dict)
+ self._check_prop_entries(scenarios, "prop_minRam")
+ self._check_prop_entries(scenarios, "prop_minDisk")
+ self._check_resource_entries(scenarios, "inv_res")
diff --git a/tempest/tests/test_auth.py b/tempest/tests/test_auth.py
new file mode 100644
index 0000000..b6e15bd
--- /dev/null
+++ b/tempest/tests/test_auth.py
@@ -0,0 +1,333 @@
+# Copyright 2014 IBM Corp.
+# 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
+
+from tempest import auth
+from tempest.common import http
+from tempest import config
+from tempest import exceptions
+from tempest.openstack.common.fixture import mockpatch
+from tempest.tests import base
+from tempest.tests import fake_config
+from tempest.tests import fake_http
+from tempest.tests import fake_identity
+
+
+class BaseAuthTestsSetUp(base.TestCase):
+ _auth_provider_class = None
+ credentials = {
+ 'username': 'fake_user',
+ 'password': 'fake_pwd',
+ 'tenant_name': 'fake_tenant'
+ }
+
+ def _auth(self, credentials, **params):
+ """
+ returns auth method according to keystone
+ """
+ return self._auth_provider_class(credentials, **params)
+
+ def setUp(self):
+ super(BaseAuthTestsSetUp, self).setUp()
+ self.useFixture(fake_config.ConfigFixture())
+ self.stubs.Set(config, 'TempestConfigPrivate', fake_config.FakePrivate)
+ self.fake_http = fake_http.fake_httplib2(return_type=200)
+ self.stubs.Set(http.ClosingHttp, 'request', self.fake_http.request)
+ self.auth_provider = self._auth(self.credentials)
+
+
+class TestBaseAuthProvider(BaseAuthTestsSetUp):
+ """
+ This tests auth.AuthProvider class which is base for the other so we
+ obviously don't test not implemented method or the ones which strongly
+ depends on them.
+ """
+ _auth_provider_class = auth.AuthProvider
+
+ def test_check_credentials_is_dict(self):
+ self.assertTrue(self.auth_provider.check_credentials({}))
+
+ def test_check_credentials_bad_type(self):
+ self.assertFalse(self.auth_provider.check_credentials([]))
+
+ def test_instantiate_with_bad_credentials_type(self):
+ """
+ Assure that credentials with bad type fail with TypeError
+ """
+ self.assertRaises(TypeError, self._auth, [])
+
+ def test_auth_data_property(self):
+ self.assertRaises(NotImplementedError, getattr, self.auth_provider,
+ 'auth_data')
+
+ def test_auth_data_property_when_cache_exists(self):
+ self.auth_provider.cache = 'foo'
+ self.useFixture(mockpatch.PatchObject(self.auth_provider,
+ 'is_expired',
+ return_value=False))
+ self.assertEqual('foo', getattr(self.auth_provider, 'auth_data'))
+
+ def test_delete_auth_data_property_through_deleter(self):
+ self.auth_provider.cache = 'foo'
+ del self.auth_provider.auth_data
+ self.assertIsNone(self.auth_provider.cache)
+
+ def test_delete_auth_data_property_through_clear_auth(self):
+ self.auth_provider.cache = 'foo'
+ self.auth_provider.clear_auth()
+ self.assertIsNone(self.auth_provider.cache)
+
+ def test_set_and_reset_alt_auth_data(self):
+ self.auth_provider.set_alt_auth_data('foo', 'bar')
+ self.assertEqual(self.auth_provider.alt_part, 'foo')
+ self.assertEqual(self.auth_provider.alt_auth_data, 'bar')
+
+ self.auth_provider.reset_alt_auth_data()
+ self.assertIsNone(self.auth_provider.alt_part)
+ self.assertIsNone(self.auth_provider.alt_auth_data)
+
+
+class TestKeystoneV2AuthProvider(BaseAuthTestsSetUp):
+ _endpoints = fake_identity.IDENTITY_V2_RESPONSE['access']['serviceCatalog']
+ _auth_provider_class = auth.KeystoneV2AuthProvider
+
+ def setUp(self):
+ super(TestKeystoneV2AuthProvider, self).setUp()
+ self.stubs.Set(http.ClosingHttp, 'request',
+ fake_identity._fake_v2_response)
+ self.target_url = 'test_api'
+
+ def _get_fake_alt_identity(self):
+ return fake_identity.ALT_IDENTITY_V2_RESPONSE['access']
+
+ def _get_result_url_from_endpoint(self, ep, endpoint_type='publicURL',
+ replacement=None):
+ if replacement:
+ return ep[endpoint_type].replace('v2', replacement)
+ return ep[endpoint_type]
+
+ def _get_token_from_fake_identity(self):
+ return fake_identity.TOKEN
+
+ def _test_request_helper(self, filters, expected):
+ url, headers, body = self.auth_provider.auth_request('GET',
+ self.target_url,
+ filters=filters)
+
+ self.assertEqual(expected['url'], url)
+ self.assertEqual(expected['token'], headers['X-Auth-Token'])
+ self.assertEqual(expected['body'], body)
+
+ def test_request(self):
+ filters = {
+ 'service': 'compute',
+ 'endpoint_type': 'publicURL',
+ 'region': 'FakeRegion'
+ }
+
+ url = self._get_result_url_from_endpoint(
+ self._endpoints[0]['endpoints'][1]) + '/' + self.target_url
+
+ expected = {
+ 'body': None,
+ 'url': url,
+ 'token': self._get_token_from_fake_identity(),
+ }
+ self._test_request_helper(filters, expected)
+
+ def test_request_with_alt_auth_cleans_alt(self):
+ self.auth_provider.set_alt_auth_data(
+ 'body',
+ (fake_identity.ALT_TOKEN, self._get_fake_alt_identity()))
+ self.test_request()
+ # Assert alt auth data is clear after it
+ self.assertIsNone(self.auth_provider.alt_part)
+ self.assertIsNone(self.auth_provider.alt_auth_data)
+
+ def test_request_with_alt_part_without_alt_data(self):
+ """
+ Assert that when alt_part is defined, the corresponding original
+ request element is kept the same.
+ """
+ filters = {
+ 'service': 'compute',
+ 'endpoint_type': 'publicURL',
+ 'region': 'fakeRegion'
+ }
+ self.auth_provider.set_alt_auth_data('url', None)
+
+ url, headers, body = self.auth_provider.auth_request('GET',
+ self.target_url,
+ filters=filters)
+
+ self.assertEqual(url, self.target_url)
+ self.assertEqual(self._get_token_from_fake_identity(),
+ headers['X-Auth-Token'])
+ self.assertEqual(body, None)
+
+ def test_request_with_bad_service(self):
+ filters = {
+ 'service': 'BAD_SERVICE',
+ 'endpoint_type': 'publicURL',
+ 'region': 'fakeRegion'
+ }
+ self.assertRaises(exceptions.EndpointNotFound,
+ self.auth_provider.auth_request, 'GET',
+ self.target_url, filters=filters)
+
+ def test_request_without_service(self):
+ filters = {
+ 'service': None,
+ 'endpoint_type': 'publicURL',
+ 'region': 'fakeRegion'
+ }
+ self.assertRaises(exceptions.EndpointNotFound,
+ self.auth_provider.auth_request, 'GET',
+ self.target_url, filters=filters)
+
+ def test_check_credentials_missing_attribute(self):
+ for attr in ['username', 'password']:
+ cred = copy.copy(self.credentials)
+ del cred[attr]
+ self.assertFalse(self.auth_provider.check_credentials(cred))
+
+ def test_check_credentials_not_scoped_missing_tenant_name(self):
+ cred = copy.copy(self.credentials)
+ del cred['tenant_name']
+ self.assertTrue(self.auth_provider.check_credentials(cred,
+ scoped=False))
+
+ def test_check_credentials_missing_tenant_name(self):
+ cred = copy.copy(self.credentials)
+ del cred['tenant_name']
+ self.assertFalse(self.auth_provider.check_credentials(cred))
+
+ def _test_base_url_helper(self, expected_url, filters,
+ auth_data=None):
+
+ url = self.auth_provider.base_url(filters, auth_data)
+ self.assertEqual(url, expected_url)
+
+ def test_base_url(self):
+ self.filters = {
+ 'service': 'compute',
+ 'endpoint_type': 'publicURL',
+ 'region': 'FakeRegion'
+ }
+ expected = self._get_result_url_from_endpoint(
+ self._endpoints[0]['endpoints'][1])
+ self._test_base_url_helper(expected, self.filters)
+
+ def test_base_url_to_get_admin_endpoint(self):
+ self.filters = {
+ 'service': 'compute',
+ 'endpoint_type': 'adminURL',
+ 'region': 'FakeRegion'
+ }
+ expected = self._get_result_url_from_endpoint(
+ self._endpoints[0]['endpoints'][1], endpoint_type='adminURL')
+ self._test_base_url_helper(expected, self.filters)
+
+ def test_base_url_unknown_region(self):
+ """
+ Assure that if the region is unknow the first endpoint is returned.
+ """
+ self.filters = {
+ 'service': 'compute',
+ 'endpoint_type': 'publicURL',
+ 'region': 'AintNoBodyKnowThisRegion'
+ }
+ expected = self._get_result_url_from_endpoint(
+ self._endpoints[0]['endpoints'][0])
+ self._test_base_url_helper(expected, self.filters)
+
+ def test_base_url_with_non_existent_service(self):
+ self.filters = {
+ 'service': 'BAD_SERVICE',
+ 'endpoint_type': 'publicURL',
+ 'region': 'FakeRegion'
+ }
+ self.assertRaises(exceptions.EndpointNotFound,
+ self._test_base_url_helper, None, self.filters)
+
+ def test_base_url_without_service(self):
+ self.filters = {
+ 'endpoint_type': 'publicURL',
+ 'region': 'FakeRegion'
+ }
+ self.assertRaises(exceptions.EndpointNotFound,
+ self._test_base_url_helper, None, self.filters)
+
+ def test_base_url_with_api_version_filter(self):
+ self.filters = {
+ 'service': 'compute',
+ 'endpoint_type': 'publicURL',
+ 'region': 'FakeRegion',
+ 'api_version': 'v12'
+ }
+ expected = self._get_result_url_from_endpoint(
+ self._endpoints[0]['endpoints'][1], replacement='v12')
+ self._test_base_url_helper(expected, self.filters)
+
+ def test_base_url_with_skip_path_filter(self):
+ self.filters = {
+ 'service': 'compute',
+ 'endpoint_type': 'publicURL',
+ 'region': 'FakeRegion',
+ 'skip_path': True
+ }
+ expected = 'http://fake_url/'
+ self._test_base_url_helper(expected, self.filters)
+
+
+class TestKeystoneV3AuthProvider(TestKeystoneV2AuthProvider):
+ _endpoints = fake_identity.IDENTITY_V3_RESPONSE['token']['catalog']
+ _auth_provider_class = auth.KeystoneV3AuthProvider
+ credentials = {
+ 'username': 'fake_user',
+ 'password': 'fake_pwd',
+ 'tenant_name': 'fake_tenant',
+ 'domain_name': 'fake_domain_name',
+ }
+
+ def setUp(self):
+ super(TestKeystoneV3AuthProvider, self).setUp()
+ self.stubs.Set(http.ClosingHttp, 'request',
+ fake_identity._fake_v3_response)
+
+ def _get_fake_alt_identity(self):
+ return fake_identity.ALT_IDENTITY_V3['token']
+
+ def _get_result_url_from_endpoint(self, ep, replacement=None):
+ if replacement:
+ return ep['url'].replace('v3', replacement)
+ return ep['url']
+
+ def test_check_credentials_missing_tenant_name(self):
+ cred = copy.copy(self.credentials)
+ del cred['domain_name']
+ self.assertFalse(self.auth_provider.check_credentials(cred))
+
+ # Overwrites v2 test
+ def test_base_url_to_get_admin_endpoint(self):
+ self.filters = {
+ 'service': 'compute',
+ 'endpoint_type': 'admin',
+ 'region': 'MiddleEarthRegion'
+ }
+ expected = self._get_result_url_from_endpoint(
+ self._endpoints[0]['endpoints'][2])
+ self._test_base_url_helper(expected, self.filters)
diff --git a/tempest/tests/test_decorators.py b/tempest/tests/test_decorators.py
new file mode 100644
index 0000000..ebf0ca0
--- /dev/null
+++ b/tempest/tests/test_decorators.py
@@ -0,0 +1,234 @@
+# Copyright 2013 IBM Corp.
+#
+# 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 testtools
+
+from oslo.config import cfg
+
+from tempest import config
+from tempest import exceptions
+from tempest.openstack.common.fixture import mockpatch
+from tempest import test
+from tempest.tests import base
+from tempest.tests import fake_config
+
+
+class BaseDecoratorsTest(base.TestCase):
+ def setUp(self):
+ super(BaseDecoratorsTest, self).setUp()
+ self.config_fixture = self.useFixture(fake_config.ConfigFixture())
+ self.stubs.Set(config, 'TempestConfigPrivate', fake_config.FakePrivate)
+
+
+class TestAttrDecorator(BaseDecoratorsTest):
+ def _test_attr_helper(self, expected_attrs, **decorator_args):
+ @test.attr(**decorator_args)
+ def foo():
+ pass
+
+ # By our test.attr decorator the attribute __testtools_attrs will be
+ # set only for 'type' argument, so we test it first.
+ if 'type' in decorator_args:
+ # this is what testtools sets
+ self.assertEqual(getattr(foo, '__testtools_attrs'),
+ set(expected_attrs))
+
+ def test_attr_without_type(self):
+ self._test_attr_helper(expected_attrs='baz', bar='baz')
+
+ def test_attr_decorator_with_smoke_type(self):
+ # smoke passed as type, so smoke and gate must have been set.
+ self._test_attr_helper(expected_attrs=['smoke', 'gate'], type='smoke')
+
+ def test_attr_decorator_with_list_type(self):
+ # if type is 'smoke' we'll get the original list of types plus 'gate'
+ self._test_attr_helper(expected_attrs=['smoke', 'foo', 'gate'],
+ type=['smoke', 'foo'])
+
+ def test_attr_decorator_with_unknown_type(self):
+ self._test_attr_helper(expected_attrs=['foo'], type='foo')
+
+ def test_attr_decorator_with_duplicated_type(self):
+ self._test_attr_helper(expected_attrs=['foo'], type=['foo', 'foo'])
+
+
+class TestServicesDecorator(BaseDecoratorsTest):
+ def _test_services_helper(self, *decorator_args):
+ class TestFoo(test.BaseTestCase):
+ @test.services(*decorator_args)
+ def test_bar(self):
+ return 0
+
+ t = TestFoo('test_bar')
+ self.assertEqual(set(decorator_args), getattr(t.test_bar,
+ '__testtools_attrs'))
+ self.assertEqual(t.test_bar(), 0)
+
+ def test_services_decorator_with_single_service(self):
+ self._test_services_helper('compute')
+
+ def test_services_decorator_with_multiple_services(self):
+ self._test_services_helper('compute', 'network')
+
+ def test_services_decorator_with_duplicated_service(self):
+ self._test_services_helper('compute', 'compute')
+
+ def test_services_decorator_with_invalid_service(self):
+ self.assertRaises(exceptions.InvalidServiceTag,
+ self._test_services_helper, 'compute',
+ 'bad_service')
+
+ def test_services_decorator_with_service_valid_and_unavailable(self):
+ self.useFixture(mockpatch.PatchObject(test.CONF.service_available,
+ 'cinder', False))
+ self.assertRaises(testtools.TestCase.skipException,
+ self._test_services_helper, 'compute',
+ 'volume')
+
+
+class TestStressDecorator(BaseDecoratorsTest):
+ def _test_stresstest_helper(self, expected_frequency='process',
+ expected_inheritance=False,
+ **decorator_args):
+ @test.stresstest(**decorator_args)
+ def foo():
+ pass
+ self.assertEqual(getattr(foo, 'st_class_setup_per'),
+ expected_frequency)
+ self.assertEqual(getattr(foo, 'st_allow_inheritance'),
+ expected_inheritance)
+ self.assertEqual(set(['stress']), getattr(foo, '__testtools_attrs'))
+
+ def test_stresstest_decorator_default(self):
+ self._test_stresstest_helper()
+
+ def test_stresstest_decorator_class_setup_frequency(self):
+ self._test_stresstest_helper('process', class_setup_per='process')
+
+ def test_stresstest_decorator_class_setup_frequency_non_default(self):
+ self._test_stresstest_helper(expected_frequency='application',
+ class_setup_per='application')
+
+ def test_stresstest_decorator_set_frequency_and_inheritance(self):
+ self._test_stresstest_helper(expected_frequency='application',
+ expected_inheritance=True,
+ class_setup_per='application',
+ allow_inheritance=True)
+
+
+class TestSkipBecauseDecorator(BaseDecoratorsTest):
+ def _test_skip_because_helper(self, expected_to_skip=True,
+ **decorator_args):
+ class TestFoo(test.BaseTestCase):
+ _interface = 'json'
+
+ @test.skip_because(**decorator_args)
+ def test_bar(self):
+ return 0
+
+ t = TestFoo('test_bar')
+ if expected_to_skip:
+ self.assertRaises(testtools.TestCase.skipException, t.test_bar)
+ else:
+ # assert that test_bar returned 0
+ self.assertEqual(TestFoo('test_bar').test_bar(), 0)
+
+ def test_skip_because_bug(self):
+ self._test_skip_because_helper(bug='12345')
+
+ def test_skip_because_bug_and_interface_match(self):
+ self._test_skip_because_helper(bug='12346', interface='json')
+
+ def test_skip_because_bug_interface_not_match(self):
+ self._test_skip_because_helper(expected_to_skip=False,
+ bug='12347', interface='xml')
+
+ def test_skip_because_bug_and_condition_true(self):
+ self._test_skip_because_helper(bug='12348', condition=True)
+
+ def test_skip_because_bug_and_condition_false(self):
+ self._test_skip_because_helper(expected_to_skip=False,
+ bug='12349', condition=False)
+
+ def test_skip_because_bug_condition_false_and_interface_match(self):
+ """
+ Assure that only condition will be evaluated if both parameters are
+ passed.
+ """
+ self._test_skip_because_helper(expected_to_skip=False,
+ bug='12350', condition=False,
+ interface='json')
+
+ def test_skip_because_bug_condition_true_and_interface_not_match(self):
+ """
+ Assure that only condition will be evaluated if both parameters are
+ passed.
+ """
+ self._test_skip_because_helper(bug='12351', condition=True,
+ interface='xml')
+
+ def test_skip_because_bug_without_bug_never_skips(self):
+ """Never skip without a bug parameter."""
+ self._test_skip_because_helper(expected_to_skip=False,
+ condition=True)
+ self._test_skip_because_helper(expected_to_skip=False,
+ interface='json')
+
+ def test_skip_because_invalid_bug_number(self):
+ """Raise ValueError if with an invalid bug number"""
+ self.assertRaises(ValueError, self._test_skip_because_helper,
+ bug='critical_bug')
+
+
+class TestRequiresExtDecorator(BaseDecoratorsTest):
+ def setUp(self):
+ super(TestRequiresExtDecorator, self).setUp()
+ cfg.CONF.set_default('api_extensions', ['enabled_ext', 'another_ext'],
+ 'compute-feature-enabled')
+
+ def _test_requires_ext_helper(self, expected_to_skip=True,
+ **decorator_args):
+ class TestFoo(test.BaseTestCase):
+ @test.requires_ext(**decorator_args)
+ def test_bar(self):
+ return 0
+
+ t = TestFoo('test_bar')
+ if expected_to_skip:
+ self.assertRaises(testtools.TestCase.skipException, t.test_bar)
+ else:
+ self.assertEqual(t.test_bar(), 0)
+
+ def test_requires_ext_decorator(self):
+ self._test_requires_ext_helper(expected_to_skip=False,
+ extension='enabled_ext',
+ service='compute')
+
+ def test_requires_ext_decorator_disabled_ext(self):
+ self._test_requires_ext_helper(extension='disabled_ext',
+ service='compute')
+
+ def test_requires_ext_decorator_with_all_ext_enabled(self):
+ # disable fixture so the default (all) is used.
+ self.config_fixture.cleanUp()
+ self._test_requires_ext_helper(expected_to_skip=False,
+ extension='random_ext',
+ service='compute')
+
+ def test_requires_ext_decorator_bad_service(self):
+ self.assertRaises(KeyError,
+ self._test_requires_ext_helper,
+ extension='enabled_ext',
+ service='bad_service')
diff --git a/tempest/tests/test_rest_client.py b/tempest/tests/test_rest_client.py
index ead112b..da9ab72 100644
--- a/tempest/tests/test_rest_client.py
+++ b/tempest/tests/test_rest_client.py
@@ -13,11 +13,13 @@
# under the License.
import httplib2
+import json
from tempest.common import rest_client
from tempest import config
from tempest import exceptions
from tempest.openstack.common.fixture import mockpatch
+from tempest.services.compute.xml import common as xml
from tempest.tests import base
from tempest.tests import fake_auth_provider
from tempest.tests import fake_config
@@ -26,12 +28,15 @@
class BaseRestClientTestClass(base.TestCase):
+ url = 'fake_endpoint'
+
def _get_region(self):
return 'fake region'
def setUp(self):
super(BaseRestClientTestClass, self).setUp()
- self.stubs.Set(config, 'TempestConfigPrivate', fake_config.FakeConfig)
+ self.useFixture(fake_config.ConfigFixture())
+ self.stubs.Set(config, 'TempestConfigPrivate', fake_config.FakePrivate)
self.rest_client = rest_client.RestClient(
fake_auth_provider.FakeAuthProvider())
self.stubs.Set(httplib2.Http, 'request', self.fake_http.request)
@@ -49,36 +54,33 @@
'_error_checker'))
def test_post(self):
- __, return_dict = self.rest_client.post('fake_endpoint', {},
- {})
+ __, return_dict = self.rest_client.post(self.url, {}, {})
self.assertEqual('POST', return_dict['method'])
def test_get(self):
- __, return_dict = self.rest_client.get('fake_endpoint')
+ __, return_dict = self.rest_client.get(self.url)
self.assertEqual('GET', return_dict['method'])
def test_delete(self):
- __, return_dict = self.rest_client.delete('fake_endpoint')
+ __, return_dict = self.rest_client.delete(self.url)
self.assertEqual('DELETE', return_dict['method'])
def test_patch(self):
- __, return_dict = self.rest_client.patch('fake_endpoint', {},
- {})
+ __, return_dict = self.rest_client.patch(self.url, {}, {})
self.assertEqual('PATCH', return_dict['method'])
def test_put(self):
- __, return_dict = self.rest_client.put('fake_endpoint', {},
- {})
+ __, return_dict = self.rest_client.put(self.url, {}, {})
self.assertEqual('PUT', return_dict['method'])
def test_head(self):
self.useFixture(mockpatch.PatchObject(self.rest_client,
'response_checker'))
- __, return_dict = self.rest_client.head('fake_endpoint')
+ __, return_dict = self.rest_client.head(self.url)
self.assertEqual('HEAD', return_dict['method'])
def test_copy(self):
- __, return_dict = self.rest_client.copy('fake_endpoint')
+ __, return_dict = self.rest_client.copy(self.url)
self.assertEqual('COPY', return_dict['method'])
@@ -89,4 +91,296 @@
def test_post(self):
self.assertRaises(exceptions.NotFound, self.rest_client.post,
- 'fake_endpoint', {}, {})
+ self.url, {}, {})
+
+
+class TestRestClientHeadersJSON(TestRestClientHTTPMethods):
+ TYPE = "json"
+
+ def _verify_headers(self, resp):
+ self.assertEqual(self.rest_client._get_type(), self.TYPE)
+ resp = dict((k.lower(), v) for k, v in resp.iteritems())
+ self.assertEqual(self.header_value, resp['accept'])
+ self.assertEqual(self.header_value, resp['content-type'])
+
+ def setUp(self):
+ super(TestRestClientHeadersJSON, self).setUp()
+ self.rest_client.TYPE = self.TYPE
+ self.header_value = 'application/%s' % self.rest_client._get_type()
+
+ def test_post(self):
+ resp, __ = self.rest_client.post(self.url, {})
+ self._verify_headers(resp)
+
+ def test_get(self):
+ resp, __ = self.rest_client.get(self.url)
+ self._verify_headers(resp)
+
+ def test_delete(self):
+ resp, __ = self.rest_client.delete(self.url)
+ self._verify_headers(resp)
+
+ def test_patch(self):
+ resp, __ = self.rest_client.patch(self.url, {})
+ self._verify_headers(resp)
+
+ def test_put(self):
+ resp, __ = self.rest_client.put(self.url, {})
+ self._verify_headers(resp)
+
+ def test_head(self):
+ self.useFixture(mockpatch.PatchObject(self.rest_client,
+ 'response_checker'))
+ resp, __ = self.rest_client.head(self.url)
+ self._verify_headers(resp)
+
+ def test_copy(self):
+ resp, __ = self.rest_client.copy(self.url)
+ self._verify_headers(resp)
+
+
+class TestRestClientHeadersXML(TestRestClientHeadersJSON):
+ TYPE = "xml"
+
+ # These two tests are needed in one exemplar
+ def test_send_json_accept_xml(self):
+ resp, __ = self.rest_client.get(self.url,
+ self.rest_client.get_headers("xml",
+ "json"))
+ resp = dict((k.lower(), v) for k, v in resp.iteritems())
+ self.assertEqual("application/json", resp["content-type"])
+ self.assertEqual("application/xml", resp["accept"])
+
+ def test_send_xml_accept_json(self):
+ resp, __ = self.rest_client.get(self.url,
+ self.rest_client.get_headers("json",
+ "xml"))
+ resp = dict((k.lower(), v) for k, v in resp.iteritems())
+ self.assertEqual("application/json", resp["accept"])
+ self.assertEqual("application/xml", resp["content-type"])
+
+
+class TestRestClientParseRespXML(BaseRestClientTestClass):
+ TYPE = "xml"
+
+ keys = ["fake_key1", "fake_key2"]
+ values = ["fake_value1", "fake_value2"]
+ item_expected = dict((key, value) for (key, value) in zip(keys, values))
+ list_expected = {"body_list": [
+ {keys[0]: values[0]},
+ {keys[1]: values[1]},
+ ]}
+ dict_expected = {"body_dict": {
+ keys[0]: values[0],
+ keys[1]: values[1],
+ }}
+
+ def setUp(self):
+ self.fake_http = fake_http.fake_httplib2()
+ super(TestRestClientParseRespXML, self).setUp()
+ self.rest_client.TYPE = self.TYPE
+
+ def test_parse_resp_body_item(self):
+ body_item = xml.Element("item", **self.item_expected)
+ body = self.rest_client._parse_resp(str(xml.Document(body_item)))
+ self.assertEqual(self.item_expected, body)
+
+ def test_parse_resp_body_list(self):
+ self.rest_client.list_tags = ["fake_list", ]
+ body_list = xml.Element(self.rest_client.list_tags[0])
+ for i in range(2):
+ body_list.append(xml.Element("fake_item",
+ **self.list_expected["body_list"][i]))
+ body = self.rest_client._parse_resp(str(xml.Document(body_list)))
+ self.assertEqual(self.list_expected["body_list"], body)
+
+ def test_parse_resp_body_dict(self):
+ self.rest_client.dict_tags = ["fake_dict", ]
+ body_dict = xml.Element(self.rest_client.dict_tags[0])
+
+ for i in range(2):
+ body_dict.append(xml.Element("fake_item", xml.Text(self.values[i]),
+ key=self.keys[i]))
+
+ body = self.rest_client._parse_resp(str(xml.Document(body_dict)))
+ self.assertEqual(self.dict_expected["body_dict"], body)
+
+
+class TestRestClientParseRespJSON(TestRestClientParseRespXML):
+ TYPE = "json"
+
+ def test_parse_resp_body_item(self):
+ body = self.rest_client._parse_resp(json.dumps(self.item_expected))
+ self.assertEqual(self.item_expected, body)
+
+ def test_parse_resp_body_list(self):
+ body = self.rest_client._parse_resp(json.dumps(self.list_expected))
+ self.assertEqual(self.list_expected["body_list"], body)
+
+ def test_parse_resp_body_dict(self):
+ body = self.rest_client._parse_resp(json.dumps(self.dict_expected))
+ self.assertEqual(self.dict_expected["body_dict"], body)
+
+ def test_parse_resp_two_top_keys(self):
+ dict_two_keys = self.dict_expected.copy()
+ dict_two_keys.update({"second_key": ""})
+ body = self.rest_client._parse_resp(json.dumps(dict_two_keys))
+ self.assertEqual(dict_two_keys, body)
+
+ def test_parse_resp_one_top_key_without_list_or_dict(self):
+ 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.useFixture(fake_config.ConfigFixture())
+ self.stubs.Set(config, 'TempestConfigPrivate', fake_config.FakePrivate)
+ 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"))
+
+
+class TestRestClientUtils(BaseRestClientTestClass):
+
+ def _is_resource_deleted(self, resource_id):
+ if not isinstance(self.retry_pass, int):
+ return False
+ if self.retry_count >= self.retry_pass:
+ return True
+ self.retry_count = self.retry_count + 1
+ return False
+
+ def setUp(self):
+ self.fake_http = fake_http.fake_httplib2()
+ super(TestRestClientUtils, self).setUp()
+ self.retry_count = 0
+ self.retry_pass = None
+ self.original_deleted_method = self.rest_client.is_resource_deleted
+ self.rest_client.is_resource_deleted = self._is_resource_deleted
+
+ def test_wait_for_resource_deletion(self):
+ self.retry_pass = 2
+ # Ensure timeout long enough for loop execution to hit retry count
+ self.rest_client.build_timeout = 500
+ sleep_mock = self.patch('time.sleep')
+ self.rest_client.wait_for_resource_deletion('1234')
+ self.assertEqual(len(sleep_mock.mock_calls), 2)
+
+ def test_wait_for_resource_deletion_not_deleted(self):
+ self.patch('time.sleep')
+ # Set timeout to be very quick to force exception faster
+ self.rest_client.build_timeout = 1
+ self.assertRaises(exceptions.TimeoutException,
+ self.rest_client.wait_for_resource_deletion,
+ '1234')
+
+ def test_wait_for_deletion_with_unimplemented_deleted_method(self):
+ self.rest_client.is_resource_deleted = self.original_deleted_method
+ self.assertRaises(NotImplementedError,
+ self.rest_client.wait_for_resource_deletion,
+ '1234')
diff --git a/tempest/tests/test_tenant_isolation.py b/tempest/tests/test_tenant_isolation.py
new file mode 100644
index 0000000..2e50cfd
--- /dev/null
+++ b/tempest/tests/test_tenant_isolation.py
@@ -0,0 +1,336 @@
+# Copyright 2014 IBM Corp.
+#
+# 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 keystoneclient.v2_0.client as keystoneclient
+from mock import patch
+import neutronclient.v2_0.client as neutronclient
+from oslo.config import cfg
+
+from tempest.common import isolated_creds
+from tempest import config
+from tempest.openstack.common.fixture import mockpatch
+from tempest.services.identity.json import identity_client as json_iden_client
+from tempest.services.identity.xml import identity_client as xml_iden_client
+from tempest.services.network.json import network_client as json_network_client
+from tempest.services.network.xml import network_client as xml_network_client
+from tempest.tests import base
+from tempest.tests import fake_config
+
+
+class TestTenantIsolation(base.TestCase):
+
+ def setUp(self):
+ super(TestTenantIsolation, self).setUp()
+ self.useFixture(fake_config.ConfigFixture())
+ self.stubs.Set(config, 'TempestConfigPrivate', fake_config.FakePrivate)
+
+ def test_tempest_client(self):
+ iso_creds = isolated_creds.IsolatedCreds('test class')
+ self.assertTrue(isinstance(iso_creds.identity_admin_client,
+ json_iden_client.IdentityClientJSON))
+ self.assertTrue(isinstance(iso_creds.network_admin_client,
+ json_network_client.NetworkClientJSON))
+
+ def test_official_client(self):
+ self.useFixture(mockpatch.PatchObject(keystoneclient.Client,
+ 'authenticate'))
+ iso_creds = isolated_creds.IsolatedCreds('test class',
+ tempest_client=False)
+ self.assertTrue(isinstance(iso_creds.identity_admin_client,
+ keystoneclient.Client))
+ self.assertTrue(isinstance(iso_creds.network_admin_client,
+ neutronclient.Client))
+
+ def test_tempest_client_xml(self):
+ iso_creds = isolated_creds.IsolatedCreds('test class', interface='xml')
+ self.assertEqual(iso_creds.interface, 'xml')
+ self.assertTrue(isinstance(iso_creds.identity_admin_client,
+ xml_iden_client.IdentityClientXML))
+ self.assertTrue(isinstance(iso_creds.network_admin_client,
+ xml_network_client.NetworkClientXML))
+
+ def _mock_user_create(self, id, name):
+ user_fix = self.useFixture(mockpatch.PatchObject(
+ json_iden_client.IdentityClientJSON,
+ 'create_user',
+ return_value=({'status': 200},
+ {'id': id, 'name': name})))
+ return user_fix
+
+ def _mock_tenant_create(self, id, name):
+ tenant_fix = self.useFixture(mockpatch.PatchObject(
+ json_iden_client.IdentityClientJSON,
+ 'create_tenant',
+ return_value=({'status': 200},
+ {'id': id, 'name': name})))
+ return tenant_fix
+
+ def _mock_network_create(self, iso_creds, id, name):
+ net_fix = self.useFixture(mockpatch.PatchObject(
+ iso_creds.network_admin_client,
+ 'create_network',
+ return_value=({'status': 200},
+ {'network': {'id': id, 'name': name}})))
+ return net_fix
+
+ def _mock_subnet_create(self, iso_creds, id, name):
+ subnet_fix = self.useFixture(mockpatch.PatchObject(
+ iso_creds.network_admin_client,
+ 'create_subnet',
+ return_value=({'status': 200},
+ {'subnet': {'id': id, 'name': name}})))
+ return subnet_fix
+
+ def _mock_router_create(self, id, name):
+ router_fix = self.useFixture(mockpatch.PatchObject(
+ json_network_client.NetworkClientJSON,
+ 'create_router',
+ return_value=({'status': 200},
+ {'router': {'id': id, 'name': name}})))
+ return router_fix
+
+ @patch('tempest.common.rest_client.RestClient')
+ def test_primary_creds(self, MockRestClient):
+ cfg.CONF.set_default('neutron', False, 'service_available')
+ iso_creds = isolated_creds.IsolatedCreds('test class',
+ password='fake_password')
+ self._mock_tenant_create('1234', 'fake_prim_tenant')
+ self._mock_user_create('1234', 'fake_prim_user')
+ username, tenant_name, password = iso_creds.get_primary_creds()
+ self.assertEqual(username, 'fake_prim_user')
+ self.assertEqual(tenant_name, 'fake_prim_tenant')
+ # Verify helper methods
+ tenant = iso_creds.get_primary_tenant()
+ user = iso_creds.get_primary_user()
+ self.assertEqual(tenant['id'], '1234')
+ self.assertEqual(user['id'], '1234')
+
+ @patch('tempest.common.rest_client.RestClient')
+ def test_admin_creds(self, MockRestClient):
+ cfg.CONF.set_default('neutron', False, 'service_available')
+ iso_creds = isolated_creds.IsolatedCreds('test class',
+ password='fake_password')
+ self._mock_user_create('1234', 'fake_admin_user')
+ self._mock_tenant_create('1234', 'fake_admin_tenant')
+ self.useFixture(mockpatch.PatchObject(
+ json_iden_client.IdentityClientJSON,
+ 'list_roles',
+ return_value=({'status': 200},
+ [{'id': '1234', 'name': 'admin'}])))
+
+ user_mock = patch.object(json_iden_client.IdentityClientJSON,
+ 'assign_user_role')
+ user_mock.start()
+ self.addCleanup(user_mock.stop)
+ with patch.object(json_iden_client.IdentityClientJSON,
+ 'assign_user_role') as user_mock:
+ username, tenant_name, password = iso_creds.get_admin_creds()
+ user_mock.assert_called_once_with('1234', '1234', '1234')
+ self.assertEqual(username, 'fake_admin_user')
+ self.assertEqual(tenant_name, 'fake_admin_tenant')
+ # Verify helper methods
+ tenant = iso_creds.get_admin_tenant()
+ user = iso_creds.get_admin_user()
+ self.assertEqual(tenant['id'], '1234')
+ self.assertEqual(user['id'], '1234')
+
+ @patch('tempest.common.rest_client.RestClient')
+ def test_all_cred_cleanup(self, MockRestClient):
+ cfg.CONF.set_default('neutron', False, 'service_available')
+ iso_creds = isolated_creds.IsolatedCreds('test class',
+ password='fake_password')
+ tenant_fix = self._mock_tenant_create('1234', 'fake_prim_tenant')
+ user_fix = self._mock_user_create('1234', 'fake_prim_user')
+ username, tenant_name, password = iso_creds.get_primary_creds()
+ tenant_fix.cleanUp()
+ user_fix.cleanUp()
+ tenant_fix = self._mock_tenant_create('12345', 'fake_alt_tenant')
+ user_fix = self._mock_user_create('12345', 'fake_alt_user')
+ alt_username, alt_tenant, alt_password = iso_creds.get_alt_creds()
+ tenant_fix.cleanUp()
+ user_fix.cleanUp()
+ tenant_fix = self._mock_tenant_create('123456', 'fake_admin_tenant')
+ user_fix = self._mock_user_create('123456', 'fake_admin_user')
+ self.useFixture(mockpatch.PatchObject(
+ json_iden_client.IdentityClientJSON,
+ 'list_roles',
+ return_value=({'status': 200},
+ [{'id': '123456', 'name': 'admin'}])))
+ with patch.object(json_iden_client.IdentityClientJSON,
+ 'assign_user_role'):
+ admin_username, admin_tenant, admin_pass = \
+ iso_creds.get_admin_creds()
+ user_mock = self.patch(
+ 'tempest.services.identity.json.identity_client.'
+ 'IdentityClientJSON.delete_user')
+ tenant_mock = self.patch(
+ 'tempest.services.identity.json.identity_client.'
+ 'IdentityClientJSON.delete_tenant')
+ iso_creds.clear_isolated_creds()
+ # Verify user delete calls
+ calls = user_mock.mock_calls
+ self.assertEqual(len(calls), 3)
+ args = map(lambda x: x[1][0], calls)
+ self.assertIn('1234', args)
+ self.assertIn('12345', args)
+ self.assertIn('123456', args)
+ # Verify tenant delete calls
+ calls = tenant_mock.mock_calls
+ self.assertEqual(len(calls), 3)
+ args = map(lambda x: x[1][0], calls)
+ self.assertIn('1234', args)
+ self.assertIn('12345', args)
+ self.assertIn('123456', args)
+
+ @patch('tempest.common.rest_client.RestClient')
+ def test_alt_creds(self, MockRestClient):
+ cfg.CONF.set_default('neutron', False, 'service_available')
+ iso_creds = isolated_creds.IsolatedCreds('test class',
+ password='fake_password')
+ self._mock_user_create('1234', 'fake_alt_user')
+ self._mock_tenant_create('1234', 'fake_alt_tenant')
+ username, tenant_name, password = iso_creds.get_alt_creds()
+ self.assertEqual(username, 'fake_alt_user')
+ self.assertEqual(tenant_name, 'fake_alt_tenant')
+ # Verify helper methods
+ tenant = iso_creds.get_alt_tenant()
+ user = iso_creds.get_alt_user()
+ self.assertEqual(tenant['id'], '1234')
+ self.assertEqual(user['id'], '1234')
+
+ @patch('tempest.common.rest_client.RestClient')
+ def test_network_creation(self, MockRestClient):
+ iso_creds = isolated_creds.IsolatedCreds('test class',
+ password='fake_password')
+ self._mock_user_create('1234', 'fake_prim_user')
+ self._mock_tenant_create('1234', 'fake_prim_tenant')
+ self._mock_network_create(iso_creds, '1234', 'fake_net')
+ self._mock_subnet_create(iso_creds, '1234', 'fake_subnet')
+ self._mock_router_create('1234', 'fake_router')
+ router_interface_mock = self.patch(
+ 'tempest.services.network.json.network_client.NetworkClientJSON.'
+ 'add_router_interface_with_subnet_id')
+ username, tenant_name, password = iso_creds.get_primary_creds()
+ router_interface_mock.called_once_with('1234', '1234')
+ network = iso_creds.get_primary_network()
+ subnet = iso_creds.get_primary_subnet()
+ router = iso_creds.get_primary_router()
+ self.assertEqual(network['id'], '1234')
+ self.assertEqual(network['name'], 'fake_net')
+ self.assertEqual(subnet['id'], '1234')
+ self.assertEqual(subnet['name'], 'fake_subnet')
+ self.assertEqual(router['id'], '1234')
+ self.assertEqual(router['name'], 'fake_router')
+
+ @patch('tempest.common.rest_client.RestClient')
+ def test_network_cleanup(self, MockRestClient):
+ iso_creds = isolated_creds.IsolatedCreds('test class',
+ password='fake_password')
+ # Create primary tenant and network
+ user_fix = self._mock_user_create('1234', 'fake_prim_user')
+ tenant_fix = self._mock_tenant_create('1234', 'fake_prim_tenant')
+ net_fix = self._mock_network_create(iso_creds, '1234', 'fake_net')
+ subnet_fix = self._mock_subnet_create(iso_creds, '1234', 'fake_subnet')
+ router_fix = self._mock_router_create('1234', 'fake_router')
+ router_interface_mock = self.patch(
+ 'tempest.services.network.json.network_client.NetworkClientJSON.'
+ 'add_router_interface_with_subnet_id')
+ username, tenant_name, password = iso_creds.get_primary_creds()
+ router_interface_mock.called_once_with('1234', '1234')
+ router_interface_mock.reset_mock()
+ tenant_fix.cleanUp()
+ user_fix.cleanUp()
+ net_fix.cleanUp()
+ subnet_fix.cleanUp()
+ router_fix.cleanUp()
+ # Create alternate tenant and network
+ user_fix = self._mock_user_create('12345', 'fake_alt_user')
+ tenant_fix = self._mock_tenant_create('12345', 'fake_alt_tenant')
+ net_fix = self._mock_network_create(iso_creds, '12345', 'fake_alt_net')
+ subnet_fix = self._mock_subnet_create(iso_creds, '12345',
+ 'fake_alt_subnet')
+ router_fix = self._mock_router_create('12345', 'fake_alt_router')
+ alt_username, alt_tenant_name, password = iso_creds.get_alt_creds()
+ router_interface_mock.called_once_with('12345', '12345')
+ router_interface_mock.reset_mock()
+ tenant_fix.cleanUp()
+ user_fix.cleanUp()
+ net_fix.cleanUp()
+ subnet_fix.cleanUp()
+ router_fix.cleanUp()
+ # Create admin tenant and networks
+ user_fix = self._mock_user_create('123456', 'fake_admin_user')
+ tenant_fix = self._mock_tenant_create('123456', 'fake_admin_tenant')
+ net_fix = self._mock_network_create(iso_creds, '123456',
+ 'fake_admin_net')
+ subnet_fix = self._mock_subnet_create(iso_creds, '123456',
+ 'fake_admin_subnet')
+ router_fix = self._mock_router_create('123456', 'fake_admin_router')
+ self.useFixture(mockpatch.PatchObject(
+ json_iden_client.IdentityClientJSON,
+ 'list_roles',
+ return_value=({'status': 200},
+ [{'id': '123456', 'name': 'admin'}])))
+ with patch.object(json_iden_client.IdentityClientJSON,
+ 'assign_user_role'):
+ admin_user, admin_tenant, password = iso_creds.get_admin_creds()
+ self.patch('tempest.services.identity.json.identity_client.'
+ 'IdentityClientJSON.delete_user')
+ self.patch('tempest.services.identity.json.identity_client.'
+ 'IdentityClientJSON.delete_tenant')
+ net = patch.object(iso_creds.network_admin_client,
+ 'delete_network')
+ net_mock = net.start()
+ subnet = patch.object(iso_creds.network_admin_client,
+ 'delete_subnet')
+ subnet_mock = subnet.start()
+ router = patch.object(iso_creds.network_admin_client,
+ 'delete_router')
+ router_mock = router.start()
+ remove_router_interface_mock = self.patch(
+ 'tempest.services.network.json.network_client.NetworkClientJSON.'
+ 'remove_router_interface_with_subnet_id')
+ port_list_mock = patch.object(iso_creds.network_admin_client,
+ 'list_ports', return_value=(
+ {'status': 200}, {'ports': []}))
+ port_list_mock.start()
+ iso_creds.clear_isolated_creds()
+ # Verify remove router interface calls
+ calls = remove_router_interface_mock.mock_calls
+ self.assertEqual(len(calls), 3)
+ args = map(lambda x: x[1], calls)
+ self.assertIn(('1234', '1234'), args)
+ self.assertIn(('12345', '12345'), args)
+ self.assertIn(('123456', '123456'), args)
+ # Verify network delete calls
+ calls = net_mock.mock_calls
+ self.assertEqual(len(calls), 3)
+ args = map(lambda x: x[1][0], calls)
+ self.assertIn('1234', args)
+ self.assertIn('12345', args)
+ self.assertIn('123456', args)
+ # Verify subnet delete calls
+ calls = subnet_mock.mock_calls
+ self.assertEqual(len(calls), 3)
+ args = map(lambda x: x[1][0], calls)
+ self.assertIn('1234', args)
+ self.assertIn('12345', args)
+ self.assertIn('123456', args)
+ # Verify router delete calls
+ calls = router_mock.mock_calls
+ self.assertEqual(len(calls), 3)
+ args = map(lambda x: x[1][0], calls)
+ self.assertIn('1234', args)
+ self.assertIn('12345', args)
+ self.assertIn('123456', args)
diff --git a/tempest/tests/test_waiters.py b/tempest/tests/test_waiters.py
new file mode 100644
index 0000000..1f9825e
--- /dev/null
+++ b/tempest/tests/test_waiters.py
@@ -0,0 +1,49 @@
+# Copyright 2014 IBM Corp.
+#
+# 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 time
+
+import mock
+
+from tempest.common import waiters
+from tempest import exceptions
+from tempest.tests import base
+
+
+class TestImageWaiters(base.TestCase):
+ def setUp(self):
+ super(TestImageWaiters, self).setUp()
+ self.client = mock.MagicMock()
+ self.client.build_timeout = 1
+ self.client.build_interval = 1
+
+ def test_wait_for_image_status(self):
+ self.client.get_image.return_value = (None, {'status': 'active'})
+ start_time = int(time.time())
+ waiters.wait_for_image_status(self.client, 'fake_image_id', 'active')
+ end_time = int(time.time())
+ # Ensure waiter returns before build_timeout
+ self.assertTrue((end_time - start_time) < 10)
+
+ def test_wait_for_image_status_timeout(self):
+ self.client.get_image.return_value = (None, {'status': 'saving'})
+ self.assertRaises(exceptions.TimeoutException,
+ waiters.wait_for_image_status,
+ self.client, 'fake_image_id', 'active')
+
+ def test_wait_for_image_status_error_on_image_create(self):
+ self.client.get_image.return_value = (None, {'status': 'ERROR'})
+ self.assertRaises(exceptions.AddImageException,
+ waiters.wait_for_image_status,
+ self.client, 'fake_image_id', 'active')
diff --git a/tempest/thirdparty/boto/test.py b/tempest/thirdparty/boto/test.py
index b36e8c7..4c39f78 100644
--- a/tempest/thirdparty/boto/test.py
+++ b/tempest/thirdparty/boto/test.py
@@ -17,6 +17,7 @@
import logging as orig_logging
import os
import re
+import six
import urlparse
import boto
@@ -26,14 +27,12 @@
import keystoneclient.exceptions
import tempest.clients
-from tempest.common.utils.file_utils import have_effective_read_access
+from tempest.common.utils import file_utils
from tempest import config
from tempest import exceptions
from tempest.openstack.common import log as logging
import tempest.test
-from tempest.thirdparty.boto.utils.wait import re_search_wait
-from tempest.thirdparty.boto.utils.wait import state_wait
-from tempest.thirdparty.boto.utils.wait import wait_exception
+from tempest.thirdparty.boto.utils import wait
CONF = config.CONF
LOG = logging.getLogger(__name__)
@@ -47,7 +46,7 @@
id_matcher = re.compile("[A-Za-z0-9]{20,}")
def all_read(*args):
- return all(map(have_effective_read_access, args))
+ return all(map(file_utils.have_effective_read_access, args))
materials_path = CONF.boto.s3_materials_path
ami_path = materials_path + os.sep + CONF.boto.ami_manifest
@@ -109,6 +108,9 @@
CODE_RE = '.*' # regexp makes sense in group match
def match(self, exc):
+ """:returns: Retruns with an error string if not matches,
+ returns with None when matches.
+ """
if not isinstance(exc, exception.BotoServerError):
return "%r not an BotoServerError instance" % exc
LOG.info("Status: %s , error_code: %s", exc.status, exc.error_code)
@@ -120,6 +122,7 @@
return ("Error code (%s) does not match" +
"the expected re pattern \"%s\"") %\
(exc.error_code, self.CODE_RE)
+ return None
class ClientError(BotoExceptionMatcher):
@@ -136,7 +139,7 @@
The not leaf elements does wildcard match
"""
# in error_code just literal and '.' characters expected
- if not isinstance(error_data, basestring):
+ if not isinstance(error_data, six.string_types):
(error_code, status_code) = map(str, error_data)
else:
status_code = None
@@ -146,7 +149,7 @@
num_parts = len(parts)
max_index = num_parts - 1
add_cls = error_cls
- for i_part in xrange(num_parts):
+ for i_part in six.moves.xrange(num_parts):
part = parts[i_part]
leaf = i_part == max_index
if not leaf:
@@ -314,7 +317,7 @@
except ValueError:
return "_GONE"
except exception.EC2ResponseError as exc:
- if colusure_matcher.match(exc):
+ if colusure_matcher.match(exc) is None:
return "_GONE"
else:
raise
@@ -327,7 +330,7 @@
final_set = set((final_set,))
final_set |= self.gone_set
lfunction = self.get_lfunction_gone(lfunction)
- state = state_wait(lfunction, final_set, valid_set)
+ state = wait.state_wait(lfunction, final_set, valid_set)
self.assertIn(state, valid_set | self.gone_set)
return state
@@ -377,8 +380,8 @@
return "ASSOCIATED"
return "DISASSOCIATED"
- state = state_wait(_disassociate, "DISASSOCIATED",
- set(("ASSOCIATED", "DISASSOCIATED")))
+ state = wait.state_wait(_disassociate, "DISASSOCIATED",
+ set(("ASSOCIATED", "DISASSOCIATED")))
self.assertEqual(state, "DISASSOCIATED")
def assertAddressReleasedWait(self, address):
@@ -391,7 +394,7 @@
return "DELETED"
return "NOTDELETED"
- state = state_wait(_address_delete, "DELETED")
+ state = wait.state_wait(_address_delete, "DELETED")
self.assertEqual(state, "DELETED")
def assertReSearch(self, regexp, string):
@@ -450,7 +453,7 @@
return "_GONE"
except exception.EC2ResponseError as exc:
if cls.ec2_error_code.\
- client.InvalidInstanceID.NotFound.match(exc):
+ client.InvalidInstanceID.NotFound.match(exc) is None:
return "_GONE"
# NOTE(afazekas): incorrect code,
# but the resource must be destoreyd
@@ -462,7 +465,7 @@
for instance in reservation.instances:
try:
instance.terminate()
- re_search_wait(_instance_state, "_GONE")
+ wait.re_search_wait(_instance_state, "_GONE")
except BaseException:
LOG.exception("Failed to terminate instance %s " % instance)
exc_num += 1
@@ -503,7 +506,8 @@
return volume.status
try:
- re_search_wait(_volume_state, "available") # not validates status
+ wait.re_search_wait(_volume_state, "available")
+ # not validates status
LOG.info(_volume_state())
volume.delete()
except BaseException:
@@ -520,7 +524,7 @@
def _update():
snapshot.update(validate=True)
- wait_exception(_update)
+ wait.wait_exception(_update)
# you can specify tuples if you want to specify the status pattern
diff --git a/tempest/thirdparty/boto/test_ec2_instance_run.py b/tempest/thirdparty/boto/test_ec2_instance_run.py
index a6932bc..e6a1638 100644
--- a/tempest/thirdparty/boto/test_ec2_instance_run.py
+++ b/tempest/thirdparty/boto/test_ec2_instance_run.py
@@ -16,23 +16,21 @@
from boto import exception
from tempest.common.utils import data_utils
-from tempest.common.utils.linux.remote_client import RemoteClient
+from tempest.common.utils.linux import remote_client
from tempest import config
from tempest import exceptions
from tempest.openstack.common import log as logging
-from tempest.test import attr
-from tempest.test import skip_because
-from tempest.thirdparty.boto.test import BotoTestCase
-from tempest.thirdparty.boto.utils.s3 import s3_upload_dir
-from tempest.thirdparty.boto.utils.wait import re_search_wait
-from tempest.thirdparty.boto.utils.wait import state_wait
+from tempest import test
+from tempest.thirdparty.boto import test as boto_test
+from tempest.thirdparty.boto.utils import s3
+from tempest.thirdparty.boto.utils import wait
CONF = config.CONF
LOG = logging.getLogger(__name__)
-class InstanceRunTest(BotoTestCase):
+class InstanceRunTest(boto_test.BotoTestCase):
@classmethod
def setUpClass(cls):
@@ -42,7 +40,7 @@
": requires ami/aki/ari manifest")))
cls.s3_client = cls.os.s3_client
cls.ec2_client = cls.os.ec2api_client
- cls.zone = cls.ec2_client.get_good_zone()
+ cls.zone = CONF.boto.aws_zone
cls.materials_path = CONF.boto.s3_materials_path
ami_manifest = CONF.boto.ami_manifest
aki_manifest = CONF.boto.aki_manifest
@@ -57,7 +55,7 @@
cls.addResourceCleanUp(cls.destroy_bucket,
cls.s3_client.connection_data,
cls.bucket_name)
- s3_upload_dir(bucket, cls.materials_path)
+ s3.s3_upload_dir(bucket, cls.materials_path)
cls.images = {"ami":
{"name": data_utils.rand_name("ami-name-"),
"location": cls.bucket_name + "/" + ami_manifest},
@@ -78,14 +76,14 @@
def _state():
retr = cls.ec2_client.get_image(image["image_id"])
return retr.state
- state = state_wait(_state, "available")
+ state = wait.state_wait(_state, "available")
if state != "available":
for _image in cls.images.itervalues():
cls.ec2_client.deregister_image(_image["image_id"])
raise exceptions.EC2RegisterImageException(image_id=
image["image_id"])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_run_idempotent_instances(self):
# EC2 run instances idempotently
@@ -123,16 +121,7 @@
_terminate_reservation(reservation_1, rcuk_1)
_terminate_reservation(reservation_2, rcuk_2)
- reservation_3, rcuk_3 = _run_instance('token_1')
- self.assertIsNotNone(reservation_3)
-
- # make sure we don't get the old reservation back
- self.assertNotEqual(reservation_1.id, reservation_3.id)
-
- # clean up
- _terminate_reservation(reservation_3, rcuk_3)
-
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_run_stop_terminate_instance(self):
# EC2 run, stop and terminate instance
image_ami = self.ec2_client.get_image(self.images["ami"]
@@ -157,7 +146,7 @@
instance.terminate()
self.cancelResourceCleanUp(rcuk)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_run_stop_terminate_instance_with_tags(self):
# EC2 run, stop and terminate instance with tags
image_ami = self.ec2_client.get_image(self.images["ami"]
@@ -204,8 +193,8 @@
instance.terminate()
self.cancelResourceCleanUp(rcuk)
- @skip_because(bug="1098891")
- @attr(type='smoke')
+ @test.skip_because(bug="1098891")
+ @test.attr(type='smoke')
def test_run_terminate_instance(self):
# EC2 run, terminate immediately
image_ami = self.ec2_client.get_image(self.images["ami"]
@@ -231,8 +220,8 @@
# NOTE(afazekas): doctored test case,
# with normal validation it would fail
- @skip_because(bug="1182679")
- @attr(type='smoke')
+ @test.skip_because(bug="1182679")
+ @test.attr(type='smoke')
def test_integration_1(self):
# EC2 1. integration test (not strict)
image_ami = self.ec2_client.get_image(self.images["ami"]["image_id"])
@@ -278,11 +267,11 @@
# TODO(afazekas): ping test. dependecy/permission ?
self.assertVolumeStatusWait(volume, "available")
- # NOTE(afazekas): it may be reports availble before it is available
+ # NOTE(afazekas): it may be reports available before it is available
- ssh = RemoteClient(address.public_ip,
- CONF.compute.ssh_user,
- pkey=self.keypair.material)
+ ssh = remote_client.RemoteClient(address.public_ip,
+ CONF.compute.ssh_user,
+ pkey=self.keypair.material)
text = data_utils.rand_name("Pattern text for console output -")
resp = ssh.write_to_console(text)
self.assertFalse(resp)
@@ -291,7 +280,7 @@
output = instance.get_console_output()
return output.output
- re_search_wait(_output, text)
+ wait.re_search_wait(_output, text)
part_lines = ssh.get_partitions().split('\n')
volume.attach(instance.id, "/dev/vdh")
@@ -300,7 +289,7 @@
return volume.status
self.assertVolumeStatusWait(_volume_state, "in-use")
- re_search_wait(_volume_state, "in-use")
+ wait.re_search_wait(_volume_state, "in-use")
# NOTE(afazekas): Different Hypervisor backends names
# differently the devices,
@@ -314,7 +303,7 @@
return 'DECREASE'
return 'EQUAL'
- state_wait(_part_state, 'INCREASE')
+ wait.state_wait(_part_state, 'INCREASE')
part_lines = ssh.get_partitions().split('\n')
# TODO(afazekas): Resource compare to the flavor settings
@@ -322,10 +311,10 @@
volume.detach()
self.assertVolumeStatusWait(_volume_state, "available")
- re_search_wait(_volume_state, "available")
+ wait.re_search_wait(_volume_state, "available")
LOG.info("Volume %s state: %s", volume.id, volume.status)
- state_wait(_part_state, 'DECREASE')
+ wait.state_wait(_part_state, 'DECREASE')
instance.stop()
address.disassociate()
diff --git a/tempest/thirdparty/boto/test_ec2_keys.py b/tempest/thirdparty/boto/test_ec2_keys.py
index 329ace3..dec0170 100644
--- a/tempest/thirdparty/boto/test_ec2_keys.py
+++ b/tempest/thirdparty/boto/test_ec2_keys.py
@@ -14,9 +14,8 @@
# under the License.
from tempest.common.utils import data_utils
-from tempest.test import attr
-from tempest.test import skip_because
-from tempest.thirdparty.boto.test import BotoTestCase
+from tempest import test
+from tempest.thirdparty.boto import test as boto_test
def compare_key_pairs(a, b):
@@ -24,7 +23,7 @@
a.fingerprint == b.fingerprint)
-class EC2KeysTest(BotoTestCase):
+class EC2KeysTest(boto_test.BotoTestCase):
@classmethod
def setUpClass(cls):
@@ -33,7 +32,7 @@
cls.ec = cls.ec2_error_code
# TODO(afazekas): merge create, delete, get test cases
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_create_ec2_keypair(self):
# EC2 create KeyPair
key_name = data_utils.rand_name("keypair-")
@@ -42,16 +41,16 @@
self.assertTrue(compare_key_pairs(keypair,
self.client.get_key_pair(key_name)))
- @skip_because(bug="1072318")
- @attr(type='smoke')
+ @test.skip_because(bug="1072318")
+ @test.attr(type='smoke')
def test_delete_ec2_keypair(self):
# EC2 delete KeyPair
key_name = data_utils.rand_name("keypair-")
self.client.create_key_pair(key_name)
self.client.delete_key_pair(key_name)
- self.assertEqual(None, self.client.get_key_pair(key_name))
+ self.assertIsNone(self.client.get_key_pair(key_name))
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_get_ec2_keypair(self):
# EC2 get KeyPair
key_name = data_utils.rand_name("keypair-")
@@ -60,7 +59,7 @@
self.assertTrue(compare_key_pairs(keypair,
self.client.get_key_pair(key_name)))
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_duplicate_ec2_keypair(self):
# EC2 duplicate KeyPair
key_name = data_utils.rand_name("keypair-")
diff --git a/tempest/thirdparty/boto/test_ec2_network.py b/tempest/thirdparty/boto/test_ec2_network.py
index 4b2f01f..d508c07 100644
--- a/tempest/thirdparty/boto/test_ec2_network.py
+++ b/tempest/thirdparty/boto/test_ec2_network.py
@@ -13,12 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest.test import attr
-from tempest.test import skip_because
-from tempest.thirdparty.boto.test import BotoTestCase
+from tempest import test
+from tempest.thirdparty.boto import test as boto_test
-class EC2NetworkTest(BotoTestCase):
+class EC2NetworkTest(boto_test.BotoTestCase):
@classmethod
def setUpClass(cls):
@@ -26,8 +25,8 @@
cls.client = cls.os.ec2api_client
# Note(afazekas): these tests for things duable without an instance
- @skip_because(bug="1080406")
- @attr(type='smoke')
+ @test.skip_because(bug="1080406")
+ @test.attr(type='smoke')
def test_disassociate_not_associated_floating_ip(self):
# EC2 disassociate not associated floating ip
ec2_codes = self.ec2_error_code
diff --git a/tempest/thirdparty/boto/test_ec2_security_groups.py b/tempest/thirdparty/boto/test_ec2_security_groups.py
index 9b58603..86140ec 100644
--- a/tempest/thirdparty/boto/test_ec2_security_groups.py
+++ b/tempest/thirdparty/boto/test_ec2_security_groups.py
@@ -14,18 +14,18 @@
# under the License.
from tempest.common.utils import data_utils
-from tempest.test import attr
-from tempest.thirdparty.boto.test import BotoTestCase
+from tempest import test
+from tempest.thirdparty.boto import test as boto_test
-class EC2SecurityGroupTest(BotoTestCase):
+class EC2SecurityGroupTest(boto_test.BotoTestCase):
@classmethod
def setUpClass(cls):
super(EC2SecurityGroupTest, cls).setUpClass()
cls.client = cls.os.ec2api_client
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_create_authorize_security_group(self):
# EC2 Create, authorize/revoke security group
group_name = data_utils.rand_name("securty_group-")
diff --git a/tempest/thirdparty/boto/test_ec2_volumes.py b/tempest/thirdparty/boto/test_ec2_volumes.py
index 04671c5..12dea18 100644
--- a/tempest/thirdparty/boto/test_ec2_volumes.py
+++ b/tempest/thirdparty/boto/test_ec2_volumes.py
@@ -13,10 +13,12 @@
# 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.test import attr
-from tempest.thirdparty.boto.test import BotoTestCase
+from tempest import test
+from tempest.thirdparty.boto import test as boto_test
+CONF = config.CONF
LOG = logging.getLogger(__name__)
@@ -25,15 +27,20 @@
a.size == b.size)
-class EC2VolumesTest(BotoTestCase):
+class EC2VolumesTest(boto_test.BotoTestCase):
@classmethod
def setUpClass(cls):
super(EC2VolumesTest, cls).setUpClass()
- cls.client = cls.os.ec2api_client
- cls.zone = cls.client.get_good_zone()
- @attr(type='smoke')
+ if not CONF.service_available.cinder:
+ skip_msg = ("%s skipped as Cinder is not available" % cls.__name__)
+ raise cls.skipException(skip_msg)
+
+ cls.client = cls.os.ec2api_client
+ cls.zone = CONF.boto.aws_zone
+
+ @test.attr(type='smoke')
def test_create_get_delete(self):
# EC2 Create, get, delete Volume
volume = self.client.create_volume(1, self.zone)
@@ -46,7 +53,7 @@
self.client.delete_volume(volume.id)
self.cancelResourceCleanUp(cuk)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_create_volume_from_snapshot(self):
# EC2 Create volume from snapshot
volume = self.client.create_volume(1, self.zone)
diff --git a/tempest/thirdparty/boto/test_s3_buckets.py b/tempest/thirdparty/boto/test_s3_buckets.py
index f34faac..af6aa8b 100644
--- a/tempest/thirdparty/boto/test_s3_buckets.py
+++ b/tempest/thirdparty/boto/test_s3_buckets.py
@@ -14,20 +14,19 @@
# under the License.
from tempest.common.utils import data_utils
-from tempest.test import attr
-from tempest.test import skip_because
-from tempest.thirdparty.boto.test import BotoTestCase
+from tempest import test
+from tempest.thirdparty.boto import test as boto_test
-class S3BucketsTest(BotoTestCase):
+class S3BucketsTest(boto_test.BotoTestCase):
@classmethod
def setUpClass(cls):
super(S3BucketsTest, cls).setUpClass()
cls.client = cls.os.s3_client
- @skip_because(bug="1076965")
- @attr(type='smoke')
+ @test.skip_because(bug="1076965")
+ @test.attr(type='smoke')
def test_create_and_get_delete_bucket(self):
# S3 Create, get and delete bucket
bucket_name = data_utils.rand_name("s3bucket-")
diff --git a/tempest/thirdparty/boto/test_s3_ec2_images.py b/tempest/thirdparty/boto/test_s3_ec2_images.py
index 9607a92..d2300ee 100644
--- a/tempest/thirdparty/boto/test_s3_ec2_images.py
+++ b/tempest/thirdparty/boto/test_s3_ec2_images.py
@@ -17,14 +17,14 @@
from tempest.common.utils import data_utils
from tempest import config
-from tempest.test import attr
-from tempest.thirdparty.boto.test import BotoTestCase
-from tempest.thirdparty.boto.utils.s3 import s3_upload_dir
+from tempest import test
+from tempest.thirdparty.boto import test as boto_test
+from tempest.thirdparty.boto.utils import s3
CONF = config.CONF
-class S3ImagesTest(BotoTestCase):
+class S3ImagesTest(boto_test.BotoTestCase):
@classmethod
def setUpClass(cls):
@@ -46,9 +46,9 @@
cls.addResourceCleanUp(cls.destroy_bucket,
cls.s3_client.connection_data,
cls.bucket_name)
- s3_upload_dir(bucket, cls.materials_path)
+ s3.s3_upload_dir(bucket, cls.materials_path)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_register_get_deregister_ami_image(self):
# Register and deregister ami image
image = {"name": data_utils.rand_name("ami-name-"),
diff --git a/tempest/thirdparty/boto/test_s3_objects.py b/tempest/thirdparty/boto/test_s3_objects.py
index a102a22..1ae46de 100644
--- a/tempest/thirdparty/boto/test_s3_objects.py
+++ b/tempest/thirdparty/boto/test_s3_objects.py
@@ -18,18 +18,18 @@
import boto.s3.key
from tempest.common.utils import data_utils
-from tempest.test import attr
-from tempest.thirdparty.boto.test import BotoTestCase
+from tempest import test
+from tempest.thirdparty.boto import test as boto_test
-class S3BucketsTest(BotoTestCase):
+class S3BucketsTest(boto_test.BotoTestCase):
@classmethod
def setUpClass(cls):
super(S3BucketsTest, cls).setUpClass()
cls.client = cls.os.s3_client
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_create_get_delete_object(self):
# S3 Create, get and delete object
bucket_name = data_utils.rand_name("s3bucket-")
diff --git a/tempest/thirdparty/boto/utils/wait.py b/tempest/thirdparty/boto/utils/wait.py
index eed0a92..752ed0f 100644
--- a/tempest/thirdparty/boto/utils/wait.py
+++ b/tempest/thirdparty/boto/utils/wait.py
@@ -17,7 +17,7 @@
import time
import boto.exception
-from testtools import TestCase
+import testtools
from tempest import config
from tempest.openstack.common import log as logging
@@ -44,10 +44,11 @@
return status
dtime = time.time() - start_time
if dtime > CONF.boto.build_timeout:
- raise TestCase.failureException("State change timeout exceeded!"
- '(%ds) While waiting'
- 'for %s at "%s"' %
- (dtime, final_set, status))
+ raise testtools.TestCase\
+ .failureException("State change timeout exceeded!"
+ '(%ds) While waiting'
+ 'for %s at "%s"' %
+ (dtime, final_set, status))
time.sleep(CONF.boto.build_interval)
old_status = status
status = lfunction()
@@ -67,10 +68,11 @@
return result
dtime = time.time() - start_time
if dtime > CONF.boto.build_timeout:
- raise TestCase.failureException('Pattern find timeout exceeded!'
- '(%ds) While waiting for'
- '"%s" pattern in "%s"' %
- (dtime, regexp, text))
+ raise testtools.TestCase\
+ .failureException('Pattern find timeout exceeded!'
+ '(%ds) While waiting for'
+ '"%s" pattern in "%s"' %
+ (dtime, regexp, text))
time.sleep(CONF.boto.build_interval)
@@ -98,8 +100,8 @@
# Let the other exceptions propagate
dtime = time.time() - start_time
if dtime > CONF.boto.build_timeout:
- raise TestCase.failureException("Wait timeout exceeded! (%ds)" %
- dtime)
+ raise testtools.TestCase\
+ .failureException("Wait timeout exceeded! (%ds)" % dtime)
time.sleep(CONF.boto.build_interval)
@@ -116,8 +118,8 @@
return exc
dtime = time.time() - start_time
if dtime > CONF.boto.build_timeout:
- raise TestCase.failureException("Wait timeout exceeded! (%ds)" %
- dtime)
+ raise testtools.TestCase\
+ .failureException("Wait timeout exceeded! (%ds)" % dtime)
time.sleep(CONF.boto.build_interval)
# TODO(afazekas): consider strategy design pattern..
diff --git a/test-requirements.txt b/test-requirements.txt
index 3fe2f27..8d64167 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -3,7 +3,7 @@
docutils==0.9.1
sphinx>=1.1.2,<1.2
python-subunit>=0.0.18
-oslo.sphinx
+oslosphinx
mox>=0.5.3
mock>=1.0
coverage>=3.6
diff --git a/tools/check_logs.py b/tools/check_logs.py
index f3204e3..e28c230 100755
--- a/tools/check_logs.py
+++ b/tools/check_logs.py
@@ -25,20 +25,45 @@
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 = is_neutron
+dump_all_errors = True
+
+# As logs are made clean, add to this set
+allowed_dirty = set([
+ 'c-api',
+ 'ceilometer-acentral',
+ 'ceilometer-acompute',
+ 'ceilometer-alarm-evaluator',
+ 'ceilometer-anotification',
+ 'ceilometer-api',
+ 'c-vol',
+ 'g-api',
+ 'h-api',
+ 'h-eng',
+ 'ir-cond',
+ 'n-api',
+ 'n-cpu',
+ 'n-net',
+ 'n-sch',
+ 'q-agt',
+ 'q-dhcp',
+ 'q-lbaas',
+ 'q-meta',
+ 'q-metering',
+ 'q-svc',
+ 'q-vpn',
+ 's-proxy'])
def process_files(file_specs, url_specs, whitelists):
- regexp = re.compile(r"^.* (ERROR|CRITICAL) .*\[.*\-.*\]")
- had_errors = False
+ regexp = re.compile(r"^.* (ERROR|CRITICAL|TRACE) .*\[.*\-.*\]")
+ 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 +72,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):
@@ -65,11 +90,12 @@
break
if not whitelisted or dump_all_errors:
if print_log_name:
- print("Log File: %s" % name)
+ print("Log File Has Errors: %s" % name)
print_log_name = False
if not whitelisted:
had_errors = True
- print(line)
+ print("*** Not Whitelisted ***"),
+ print(line.rstrip())
return had_errors
@@ -121,19 +147,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 not in allowed_dirty:
+ print("Log: %s not allowed to have ERRORS or TRACES" % 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.
diff --git a/tools/install_venv.py b/tools/install_venv.py
index e41ca43..96b8279 100644
--- a/tools/install_venv.py
+++ b/tools/install_venv.py
@@ -25,12 +25,12 @@
def print_help(venv, root):
help = """
- Openstack development environment setup is complete.
+ OpenStack development environment setup is complete.
- Openstack development uses virtualenv to track and manage Python
+ OpenStack development uses virtualenv to track and manage Python
dependencies while in development and testing.
- To activate the Openstack virtualenv for the extent of your current shell
+ To activate the OpenStack virtualenv for the extent of your current shell
session you can run:
$ source %s/bin/activate
diff --git a/tools/tempest_auto_config.py b/tools/tempest_auto_config.py
index 9aeb077..5b8d05b 100644
--- a/tools/tempest_auto_config.py
+++ b/tools/tempest_auto_config.py
@@ -13,14 +13,14 @@
# License for the specific language governing permissions and limitations
# under the License.
#
-# This script aims to configure an initial Openstack environment with all the
-# necessary configurations for tempest's run using nothing but Openstack's
+# This script aims to configure an initial OpenStack environment with all the
+# necessary configurations for tempest's run using nothing but OpenStack's
# native API.
# That includes, creating users, tenants, registering images (cirros),
# configuring neutron and so on.
#
# ASSUMPTION: this script is run by an admin user as it is meant to configure
-# the Openstack environment prior to actual use.
+# the OpenStack environment prior to actual use.
# Config
import ConfigParser
@@ -32,7 +32,7 @@
import glanceclient as glance_client
import keystoneclient.v2_0.client as keystone_client
-# Import Openstack exceptions
+# Import OpenStack exceptions
import glanceclient.exc as glance_exception
import keystoneclient.exceptions as keystone_exception
@@ -88,7 +88,7 @@
def get_image_client(self, version="1", *args, **kwargs):
"""
- This method returns Openstack glance python client
+ This method returns OpenStack glance python client
:param version: a string representing the version of the glance client
to use.
:param string endpoint: A user-supplied endpoint URL for the glance
@@ -333,7 +333,7 @@
"""
Creates images for tempest's use and registers the environment variables
IMAGE_ID and IMAGE_ID_ALT with registered images
- :param image_client: Openstack python image client
+ :param image_client: OpenStack python image client
:param config: a ConfigParser object representing the tempest config file
:param config_section: the section name where the IMAGE ids are set
:param download_url: the URL from which we should download the UEC tar
diff --git a/tools/verify_tempest_config.py b/tools/verify_tempest_config.py
index 29eed9d..79e1fe3 100755
--- a/tools/verify_tempest_config.py
+++ b/tools/verify_tempest_config.py
@@ -42,7 +42,12 @@
def verify_nova_api_versions(os):
# Check nova api versions - only get base URL without PATH
os.servers_client.skip_path = True
- __, body = RAW_HTTP.request(os.servers_client.base_url, 'GET')
+ # The nova base endpoint url includes the version but to get the versions
+ # list the unversioned endpoint is needed
+ v2_endpoint = os.servers_client.base_url
+ v2_endpoint_parts = v2_endpoint.split('/')
+ endpoint = v2_endpoint_parts[0] + '//' + v2_endpoint_parts[2]
+ __, body = RAW_HTTP.request(endpoint, 'GET')
body = json.loads(body)
# Restore full base_url
os.servers_client.skip_path = False
@@ -58,6 +63,7 @@
'nova_v3': os.extensions_v3_client,
'cinder': os.volumes_extension_client,
'neutron': os.network_client,
+ 'swift': os.account_client,
}
if service not in extensions_client:
print('No tempest extensions client for %s' % service)
@@ -71,6 +77,7 @@
'nova_v3': CONF.compute_feature_enabled.api_v3_extensions,
'cinder': CONF.volume_feature_enabled.api_extensions,
'neutron': CONF.network_feature_enabled.api_extensions,
+ 'swift': CONF.object_storage_feature_enabled.discoverable_apis,
}
if service not in extensions_options:
print('No supported extensions list option for %s' % service)
@@ -88,6 +95,10 @@
# instead of name.
if service == 'neutron':
extensions = map(lambda x: x['alias'], resp['extensions'])
+ elif service == 'swift':
+ # Remove Swift general information from extensions list
+ resp.pop('swift')
+ extensions = resp.keys()
else:
extensions = map(lambda x: x['name'], resp['extensions'])
@@ -137,7 +148,7 @@
print('Running config verification...')
os = clients.ComputeAdminManager(interface='json')
results = {}
- for service in ['nova', 'nova_v3', 'cinder', 'neutron']:
+ for service in ['nova', 'nova_v3', 'cinder', 'neutron', 'swift']:
# TODO(mtreinish) make this a keystone endpoint check for available
# services
if not check_service_availability(service):
diff --git a/tox.ini b/tox.ini
index 88f2537..4a625f8 100644
--- a/tox.ini
+++ b/tox.ini
@@ -4,14 +4,10 @@
skipsdist = True
[testenv]
-sitepackages = True
setenv = VIRTUAL_ENV={envdir}
- LANG=en_US.UTF-8
- LANGUAGE=en_US:en
- LC_ALL=C
OS_TEST_PATH=./tempest/test_discover
usedevelop = True
-install_command = pip install {opts} {packages}
+install_command = pip install -U {opts} {packages}
[testenv:py26]
setenv = OS_TEST_PATH=./tempest/tests
@@ -30,60 +26,48 @@
commands = python setup.py testr --coverage --testr-arg='tempest\.tests {posargs}'
[testenv:all]
+sitepackages = True
setenv = VIRTUAL_ENV={envdir}
commands =
- python setup.py testr --slowest --testr-args='{posargs}'
+ bash tools/pretty_tox.sh '{posargs}'
[testenv:full]
+sitepackages = True
# The regex below is used to select which tests to run and exclude the slow tag:
# See the testrepostiory bug: https://bugs.launchpad.net/testrepository/+bug/1208610
commands =
bash tools/pretty_tox.sh '(?!.*\[.*\bslow\b.*\])(^tempest\.(api|scenario|thirdparty|cli)) {posargs}'
+[testenv:full-serial]
+# The regex below is used to select which tests to run and exclude the slow tag:
+# See the testrepostiory bug: https://bugs.launchpad.net/testrepository/+bug/1208610
+commands =
+ bash tools/pretty_tox_serial.sh '(?!.*\[.*\bslow\b.*\])(^tempest\.(api|scenario|thirdparty|cli)) {posargs}'
+
[testenv:testr-full]
+sitepackages = True
commands =
bash tools/pretty_tox.sh '(?!.*\[.*\bslow\b.*\])(^tempest\.(api|scenario|thirdparty|cli)) {posargs}'
[testenv:heat-slow]
+sitepackages = True
setenv = OS_TEST_TIMEOUT=1200
# The regex below is used to select heat api/scenario tests tagged as slow.
commands =
bash tools/pretty_tox_serial.sh '(?=.*\[.*\bslow\b.*\])(^tempest\.(api|scenario)\.orchestration) {posargs}'
[testenv:large-ops]
+sitepackages = True
commands =
python setup.py testr --slowest --testr-args='tempest.scenario.test_large_ops {posargs}'
-
-[testenv:py26-full]
-setenv = VIRTUAL_ENV={envdir}
- NOSE_WITH_OPENSTACK=1
- NOSE_OPENSTACK_COLOR=1
- NOSE_OPENSTACK_RED=15
- NOSE_OPENSTACK_YELLOW=3
- NOSE_OPENSTACK_SHOW_ELAPSED=1
- NOSE_OPENSTACK_STDOUT=1
- TEMPEST_PY26_NOSE_COMPAT=1
-commands =
- nosetests --logging-format '%(asctime)-15s %(message)s' --with-xunit -sv --xunit-file=nosetests-full.xml tempest/api tempest/scenario tempest/thirdparty tempest/cli {posargs}
-
-[testenv:py26-smoke]
-setenv = VIRTUAL_ENV={envdir}
-NOSE_WITH_OPENSTACK=1
- NOSE_OPENSTACK_COLOR=1
- NOSE_OPENSTACK_RED=15
- NOSE_OPENSTACK_YELLOW=3
- NOSE_OPENSTACK_SHOW_ELAPSED=1
- NOSE_OPENSTACK_STDOUT=1
- TEMPEST_PY26_NOSE_COMPAT=1
-commands =
- nosetests --logging-format '%(asctime)-15s %(message)s' --with-xunit -sv --attr=type=smoke --xunit-file=nosetests-smoke.xml tempest {posargs}
-
[testenv:smoke]
+sitepackages = True
commands =
bash tools/pretty_tox.sh '(?!.*\[.*\bslow\b.*\])((smoke)|(^tempest\.scenario)) {posargs}'
[testenv:smoke-serial]
+sitepackages = True
# This is still serial because neutron doesn't work with parallel. See:
# https://bugs.launchpad.net/tempest/+bug/1216076 so the neutron smoke
# job would fail if we moved it to parallel.
@@ -91,6 +75,7 @@
bash tools/pretty_tox_serial.sh '(?!.*\[.*\bslow\b.*\])((smoke)|(^tempest\.scenario)) {posargs}'
[testenv:stress]
+sitepackages = True
commands =
python -m tempest/stress/run_stress -a -d 3600 -S