Merge "Handling invalid name of workspace register and rename."
diff --git a/.mailmap b/.mailmap
index 7898e69..fc74aa9 100644
--- a/.mailmap
+++ b/.mailmap
@@ -6,8 +6,9 @@
Andrea Frittoli <andrea.frittoli@gmail.com> <andrea.frittoli@hpe.com>
Daryl Walleck <daryl.walleck@rackspace.com> <daryl.walleck@rackspace.com>
David Kranz <dkranz@redhat.com> David Kranz <david.kranz@qrclab.com>
-Ghanshyam <ghanshyam.mann@nectechnologies.in> <ghanshyam.mann@nectechnologies.in>
-Ghanshyam <ghanshyam.mann@nectechnologies.in> <ghanshyam.mann@nectechnologies.in>
+Ghanshyam Mann <gmann@ghanshyammann.com> <ghanshyam.mann@nectechnologies.in>
+Ghanshyam Mann <gmann@ghanshyammann.com> <ghanshyam.mann@india.nec.com>
+Ghanshyam Mann <gmann@ghanshyammann.com> <ghanshyammann@gmail.com>
Jay Pipes <jaypipes@gmail.com> <jpipes@librebox.gateway.2wire.net>
Joe Gordon <joe.gordon0@gmail.com> <jogo@cloudscaling.com>
Ken'ichi Ohmichi <ken-oomichi@wx.jp.nec.com> <oomichi@mxs.nes.nec.co.jp>
diff --git a/.zuul.yaml b/.zuul.yaml
index 17ec1fc..1e052bd 100644
--- a/.zuul.yaml
+++ b/.zuul.yaml
@@ -21,19 +21,19 @@
$TEMPEST_CONFIG:
compute:
min_compute_nodes: "{{ groups['compute'] | default(['controller']) | length }}"
- test_results_stage_name: 'test_results'
+ test_results_stage_name: test_results
zuul_copy_output:
- '{{ devstack_base_dir }}/tempest/etc/tempest.conf': 'logs'
- '{{ devstack_base_dir }}/tempest/etc/accounts.yaml': 'logs'
- '{{ devstack_base_dir }}/tempest/tempest.log': 'logs'
- '{{ stage_dir }}/{{ test_results_stage_name }}.subunit': 'logs'
- '{{ stage_dir }}/{{ test_results_stage_name }}.html': 'logs'
- '{{ stage_dir }}/stackviz': 'logs'
+ '{{ devstack_base_dir }}/tempest/etc/tempest.conf': logs
+ '{{ devstack_base_dir }}/tempest/etc/accounts.yaml': logs
+ '{{ devstack_base_dir }}/tempest/tempest.log': logs
+ '{{ stage_dir }}/{{ test_results_stage_name }}.subunit': logs
+ '{{ stage_dir }}/{{ test_results_stage_name }}.html': logs
+ '{{ stage_dir }}/stackviz': logs
extensions_to_txt:
- conf: True
- log: True
- yaml: True
- yml: True
+ conf: true
+ log: true
+ yaml: true
+ yml: true
run: playbooks/devstack-tempest.yaml
post-run: playbooks/post-tempest.yaml
@@ -41,10 +41,9 @@
name: tempest-full
parent: devstack-tempest
# This currently works from stable/pike on.
- branches:
- - master
- - stable/queens
- - stable/pike
+ # Before stable/pike, legacy version of tempest-full
+ # 'legacy-tempest-dsvm-neutron-full' run.
+ branches: ^(?!stable/ocata).*$
description: |
Base integration test with Neutron networking and py27.
Former names for this job where:
@@ -71,9 +70,10 @@
- job:
name: tempest-full-py3
parent: devstack-tempest
- branches:
- - master
- - stable/queens
+ # This currently works from stable/pike on.
+ # Before stable/pike, legacy version of tempest-full
+ # 'legacy-tempest-dsvm-neutron-full' run.
+ branches: ^(?!stable/ocata).*$
description: |
Base integration test with Neutron networking and py3.
Former names for this job where:
@@ -82,8 +82,8 @@
vars:
tox_envlist: full
devstack_localrc:
- USE_PYTHON3: True
- FORCE_CONFIG_DRIVE: True
+ USE_PYTHON3: true
+ FORCE_CONFIG_DRIVE: true
devstack_services:
s-account: false
s-container: false
@@ -112,7 +112,7 @@
vars:
tox_envlist: full
devstack_localrc:
- FORCE_CONFIG_DRIVE: False
+ FORCE_CONFIG_DRIVE: false
NOVA_ALLOW_MOVE_TO_SAME_HOST: false
LIVE_MIGRATION_AVAILABLE: true
USE_BLOCK_MIGRATION_FOR_LIVE_MIGRATION: true
@@ -143,6 +143,25 @@
Base integration test with Neutron networking and py36.
voting: false
+- nodeset:
+ name: openstack-opensuse150-node
+ nodes:
+ - name: controller
+ label: opensuse-150
+ groups:
+ - name: tempest
+ nodes:
+ - controller
+
+- job:
+ name: tempest-full-py3-opensuse150
+ parent: tempest-full-py3
+ nodeset: openstack-opensuse150-node
+ description: |
+ Base integration test with Neutron networking and py36 running
+ on openSUSE Leap 15.0
+ voting: false
+
- job:
name: tempest-slow
parent: tempest-multinode-full
@@ -284,9 +303,44 @@
devstack_localrc:
TEMPEST_VOLUME_TYPE: volumev2
+- job:
+ name: tempest-full-test-account-py3
+ parent: tempest-full-py3
+ description: |
+ This job runs the full set of tempest tests using pre-provisioned
+ credentials instead of dynamic credentials and py3.
+ Former names for this job were:
+ - legacy-tempest-dsvm-full-test-accounts
+ - legacy-tempest-dsvm-neutron-full-test-accounts
+ - legacy-tempest-dsvm-identity-v3-test-accounts
+ vars:
+ devstack_localrc:
+ TEMPEST_USE_TEST_ACCOUNTS: True
+
+- job:
+ name: tempest-full-test-account-no-admin-py3
+ parent: tempest-full-test-account-py3
+ description: |
+ This job runs the full set of tempest tests using pre-provisioned
+ credentials and py3 without having an admin account.
+ Former name for this job was:
+ - legacy-tempest-dsvm-neutron-full-non-admin
+
+ vars:
+ devstack_localrc:
+ TEMPEST_HAS_ADMIN: False
+
- project:
templates:
+ - check-requirements
+ - integrated-gate
+ - integrated-gate-py35
+ - openstack-cover-jobs
+ - openstack-python-jobs
+ - openstack-python35-jobs
- openstack-python36-jobs
+ - publish-openstack-docs-pti
+ - release-notes-jobs-python3
check:
jobs:
- devstack-tempest:
@@ -295,7 +349,8 @@
- ^roles/
- ^.zuul.yaml$
- nova-multiattach:
- irrelevant-files:
+ # Define list of irrelevant files to use everywhere else
+ irrelevant-files: &tempest-irrelevant-files
- ^(test-|)requirements.txt$
- ^.*\.rst$
- ^doc/.*$
@@ -305,151 +360,97 @@
- ^tempest/hacking/.*$
- ^tempest/tests/.*$
- tempest-full-parallel:
- irrelevant-files:
- - ^(test-|)requirements.txt$
- - ^.*\.rst$
- - ^doc/.*$
- - ^etc/.*$
- - ^releasenotes/.*$
- - ^setup.cfg$
- - ^tempest/hacking/.*$
- - ^tempest/tests/.*$
+ irrelevant-files: *tempest-irrelevant-files
- tempest-full-py36:
- irrelevant-files:
- - ^(test-|)requirements.txt$
- - ^.*\.rst$
- - ^doc/.*$
- - ^etc/.*$
- - ^releasenotes/.*$
- - ^setup.cfg$
- - ^tempest/hacking/.*$
- - ^tempest/tests/.*$
+ irrelevant-files: *tempest-irrelevant-files
- tempest-full-rocky:
- irrelevant-files:
- - ^(test-|)requirements.txt$
- - ^.*\.rst$
- - ^doc/.*$
- - ^etc/.*$
- - ^releasenotes/.*$
- - ^setup.cfg$
- - ^tempest/hacking/.*$
- - ^tempest/tests/.*$
+ irrelevant-files: *tempest-irrelevant-files
- tempest-full-rocky-py3:
- irrelevant-files:
- - ^(test-|)requirements.txt$
- - ^.*\.rst$
- - ^doc/.*$
- - ^etc/.*$
- - ^releasenotes/.*$
- - ^setup.cfg$
- - ^tempest/hacking/.*$
- - ^tempest/tests/.*$
+ irrelevant-files: *tempest-irrelevant-files
- tempest-full-queens:
- irrelevant-files:
- - ^(test-|)requirements.txt$
- - ^.*\.rst$
- - ^doc/.*$
- - ^etc/.*$
- - ^releasenotes/.*$
- - ^setup.cfg$
- - ^tempest/hacking/.*$
- - ^tempest/tests/.*$
+ irrelevant-files: *tempest-irrelevant-files
- tempest-full-queens-py3:
- irrelevant-files:
- - ^(test-|)requirements.txt$
- - ^.*\.rst$
- - ^doc/.*$
- - ^etc/.*$
- - ^releasenotes/.*$
- - ^setup.cfg$
- - ^tempest/hacking/.*$
- - ^tempest/tests/.*$
+ irrelevant-files: *tempest-irrelevant-files
- tempest-full-pike:
- irrelevant-files:
- - ^(test-|)requirements.txt$
- - ^.*\.rst$
- - ^doc/.*$
- - ^etc/.*$
- - ^releasenotes/.*$
- - ^setup.cfg$
- - ^tempest/hacking/.*$
- - ^tempest/tests/.*$
+ irrelevant-files: *tempest-irrelevant-files
- tempest-multinode-full:
- irrelevant-files:
- - ^(test-|)requirements.txt$
- - ^.*\.rst$
- - ^doc/.*$
- - ^etc/.*$
- - ^releasenotes/.*$
- - ^setup.cfg$
- - ^tempest/hacking/.*$
- - ^tempest/tests/.*$
+ irrelevant-files: *tempest-irrelevant-files
- tempest-tox-plugin-sanity-check
- tempest-slow:
- irrelevant-files:
- - ^(test-|)requirements.txt$
- - ^.*\.rst$
- - ^doc/.*$
- - ^etc/.*$
- - ^releasenotes/.*$
- - ^setup.cfg$
- - ^tempest/hacking/.*$
- - ^tempest/tests/.*$
+ irrelevant-files: *tempest-irrelevant-files
- nova-cells-v1:
- irrelevant-files:
- - ^(test-|)requirements.txt$
- - ^.*\.rst$
- - ^doc/.*$
- - ^etc/.*$
- - ^releasenotes/.*$
- - ^setup.cfg$
- - ^tempest/hacking/.*$
- - ^tempest/tests/.*$
+ irrelevant-files: *tempest-irrelevant-files
- nova-live-migration:
voting: false
- irrelevant-files:
- - ^(test-|)requirements.txt$
- - ^.*\.rst$
- - ^doc/.*$
- - ^etc/.*$
- - ^releasenotes/.*$
- - ^setup.cfg$
- - ^tempest/hacking/.*$
- - ^tempest/tests/.*$
+ irrelevant-files: *tempest-irrelevant-files
+ - neutron-grenade-multinode:
+ irrelevant-files: *tempest-irrelevant-files
+ - neutron-grenade:
+ irrelevant-files: *tempest-irrelevant-files
+ - devstack-plugin-ceph-tempest:
+ voting: false
+ irrelevant-files: *tempest-irrelevant-files
+ - puppet-openstack-integration-4-scenario001-tempest-centos-7:
+ voting: false
+ irrelevant-files: *tempest-irrelevant-files
+ - puppet-openstack-integration-4-scenario002-tempest-centos-7:
+ voting: false
+ irrelevant-files: *tempest-irrelevant-files
+ - puppet-openstack-integration-4-scenario003-tempest-centos-7:
+ voting: false
+ irrelevant-files: *tempest-irrelevant-files
+ - puppet-openstack-integration-4-scenario004-tempest-centos-7:
+ voting: false
+ irrelevant-files: *tempest-irrelevant-files
+ - neutron-tempest-dvr:
+ irrelevant-files: *tempest-irrelevant-files
+ - legacy-tempest-dsvm-neutron-full-ocata:
+ irrelevant-files: *tempest-irrelevant-files
+ - tempest-full:
+ irrelevant-files: *tempest-irrelevant-files
+ - interop-tempest-consistency:
+ voting: false
+ irrelevant-files: *tempest-irrelevant-files
+ - tempest-full-test-account-py3:
+ voting: false
+ irrelevant-files: *tempest-irrelevant-files
+ - tempest-full-test-account-no-admin-py3:
+ voting: false
+ irrelevant-files: *tempest-irrelevant-files
gate:
jobs:
- nova-multiattach:
- irrelevant-files:
- - ^(test-|)requirements.txt$
- - ^.*\.rst$
- - ^doc/.*$
- - ^etc/.*$
- - ^releasenotes/.*$
- - ^setup.cfg$
- - ^tempest/hacking/.*$
- - ^tempest/tests/.*$
+ irrelevant-files: *tempest-irrelevant-files
- tempest-slow:
- irrelevant-files:
- - ^(test-|)requirements.txt$
- - ^.*\.rst$
- - ^doc/.*$
- - ^etc/.*$
- - ^releasenotes/.*$
- - ^setup.cfg$
- - ^tempest/hacking/.*$
- - ^tempest/tests/.*$
+ irrelevant-files: *tempest-irrelevant-files
+ - neutron-grenade-multinode:
+ irrelevant-files: *tempest-irrelevant-files
+ - legacy-tempest-dsvm-neutron-full:
+ irrelevant-files: *tempest-irrelevant-files
+ - neutron-grenade:
+ irrelevant-files: *tempest-irrelevant-files
experimental:
jobs:
- tempest-cinder-v2-api:
- irrelevant-files:
- - ^(test-|)requirements.txt$
- - ^.*\.rst$
- - ^doc/.*$
- - ^etc/.*$
- - ^releasenotes/.*$
- - ^setup.cfg$
- - ^tempest/hacking/.*$
- - ^tempest/tests/.*$
+ irrelevant-files: *tempest-irrelevant-files
+ - legacy-periodic-tempest-dsvm-all-master:
+ irrelevant-files: *tempest-irrelevant-files
+ - legacy-tempest-dsvm-multinode-full:
+ irrelevant-files: *tempest-irrelevant-files
+ - legacy-tempest-dsvm-neutron-dvr-multinode-full:
+ irrelevant-files: *tempest-irrelevant-files
+ - neutron-tempest-dvr-ha-multinode-full:
+ irrelevant-files: *tempest-irrelevant-files
+ - legacy-tempest-dsvm-nova-v20-api:
+ irrelevant-files: *tempest-irrelevant-files
+ - legacy-tempest-dsvm-lvm-multibackend:
+ irrelevant-files: *tempest-irrelevant-files
+ - devstack-plugin-ceph-tempest-py3:
+ irrelevant-files: *tempest-irrelevant-files
+ - legacy-tempest-dsvm-neutron-pg-full:
+ irrelevant-files: *tempest-irrelevant-files
+ - tempest-full-py3-opensuse150:
+ irrelevant-files: *tempest-irrelevant-files
periodic-stable:
jobs:
- tempest-full-rocky
@@ -457,3 +458,7 @@
- tempest-full-queens
- tempest-full-queens-py3
- tempest-full-pike
+ - legacy-periodic-tempest-dsvm-neutron-full-ocata
+ periodic:
+ jobs:
+ - legacy-periodic-tempest-dsvm-all-master
diff --git a/HACKING.rst b/HACKING.rst
index 5b9c0f1..e767b25 100644
--- a/HACKING.rst
+++ b/HACKING.rst
@@ -349,18 +349,19 @@
docstrings for the workflow in each test methods can be used instead. A good
example of this would be::
- class TestVolumeBootPattern(manager.ScenarioTest):
- """
- This test case attempts to reproduce the following steps:
+ class TestServerBasicOps(manager.ScenarioTest):
- * Create in Cinder some bootable volume importing a Glance image
- * Boot an instance from the bootable volume
- * Write content to the volume
- * Delete an instance and Boot a new instance from the volume
- * Check written content in the instance
- * Create a volume snapshot while the instance is running
- * Boot an additional instance from the new snapshot based volume
- * Check written content in the instance booted from snapshot
+ """The test suite for server basic operations
+
+ This smoke test case follows this basic set of operations:
+ * Create a keypair for use in launching an instance
+ * Create a security group to control network access in instance
+ * Add simple permissive rules to the security group
+ * Launch an instance
+ * Perform ssh to instance
+ * Verify metadata service
+ * Verify metadata on config_drive
+ * Terminate the instance
"""
Test Identification with Idempotent ID
diff --git a/README.rst b/README.rst
index 0a130dc..307ceb3 100644
--- a/README.rst
+++ b/README.rst
@@ -198,21 +198,21 @@
is ``test_path=./tempest/test_discover`` which will only run test discover on the
Tempest suite.
-Alternatively, there are the py27 and py35 tox jobs which will run the unit
+Alternatively, there are the py27 and py36 tox jobs which will run the unit
tests with the corresponding version of python.
One common activity is to just run a single test, you can do this with tox
-simply by specifying to just run py27 or py35 tests against a single test::
+simply by specifying to just run py27 or py36 tests against a single test::
- $ tox -e py27 -- -n tempest.tests.test_microversions.TestMicroversionsTestsClass.test_config_version_none_23
+ $ tox -e py36 -- -n tempest.tests.test_microversions.TestMicroversionsTestsClass.test_config_version_none_23
Or all tests in the test_microversions.py file::
- $ tox -e py27 -- -n tempest.tests.test_microversions
+ $ tox -e py36 -- -n tempest.tests.test_microversions
You may also use regular expressions to run any matching tests::
- $ tox -e py27 -- test_microversions
+ $ tox -e py36 -- test_microversions
Additionally, when running a single test, or test-file, the ``-n/--no-discover``
argument is no longer required, however it may perform faster if included.
diff --git a/REVIEWING.rst b/REVIEWING.rst
index 8a1e152..bf63ed2 100644
--- a/REVIEWING.rst
+++ b/REVIEWING.rst
@@ -36,8 +36,11 @@
For any change that adds new functionality to either common functionality or an
out-of-band tool unit tests are required. This is to ensure we don't introduce
future regressions and to test conditions which we may not hit in the gate runs.
-Tests, and service clients aren't required to have unit tests since they should
-be self verifying by running them in the gate.
+API and scenario tests aren't required to have unit tests since they should
+be self-verifying by running them in the gate. All service clients, on the
+other hand, `must have`_ unit tests, as they belong to ``tempest/lib``.
+
+.. _must have: https://docs.openstack.org/tempest/latest/library.html#testing
API Stability
diff --git a/releasenotes/notes/agents-client-delete-method-de1a7fb3f845999c.yaml b/releasenotes/notes/agents-client-delete-method-de1a7fb3f845999c.yaml
new file mode 100644
index 0000000..21068ec
--- /dev/null
+++ b/releasenotes/notes/agents-client-delete-method-de1a7fb3f845999c.yaml
@@ -0,0 +1,7 @@
+---
+features:
+ - |
+ Adds the new method to AgentsClient that implements agent deletion
+ according to the API [0].
+ [0] https://developer.openstack.org/api-ref/network/v2/index.html#delete-agent
+
diff --git a/releasenotes/notes/config-image-api-v1-default-to-false-39d5f2xafc534ab1.yaml b/releasenotes/notes/config-image-api-v1-default-to-false-39d5f2xafc534ab1.yaml
new file mode 100644
index 0000000..5efa4a9
--- /dev/null
+++ b/releasenotes/notes/config-image-api-v1-default-to-false-39d5f2xafc534ab1.yaml
@@ -0,0 +1,7 @@
+---
+upgrade:
+ - |
+ Changed the default value of 'api_v1' config option in the
+ 'image-feature-enabled' group to False from True, because
+ glance v1 APIs are deprecated. Please set True explicitly
+ on the option if still testing glance v1 APIs.
diff --git a/releasenotes/notes/network-show-version-18e1707a4df0a3d3.yaml b/releasenotes/notes/network-show-version-18e1707a4df0a3d3.yaml
new file mode 100644
index 0000000..36a9710
--- /dev/null
+++ b/releasenotes/notes/network-show-version-18e1707a4df0a3d3.yaml
@@ -0,0 +1,7 @@
+---
+features:
+- |
+ Add ``show_version`` function to the ``NetworkVersionsClient`` client. This
+ allows the possibility of getting details for Networking API.
+
+ .. API reference: https://developer.openstack.org/api-ref/network/v2/index.html#show-api-v2-details
diff --git a/releasenotes/notes/tempest-default-run_validations-9640c41b6a4a9121.yaml b/releasenotes/notes/tempest-default-run_validations-9640c41b6a4a9121.yaml
new file mode 100644
index 0000000..8ff0b5c
--- /dev/null
+++ b/releasenotes/notes/tempest-default-run_validations-9640c41b6a4a9121.yaml
@@ -0,0 +1,10 @@
+---
+upgrade:
+ - |
+ ``CONF.validation.run_validation`` default enabled.
+ This option required to be set ``true`` in order to run api tests
+ stability when the guest cooperation required. For example when
+ the guest needs react on Volume/Interface detach.
+ The ssh test makes sure the VM is alive and ready
+ when the detach needs to happen.
+ The option was enabled on the gate for a long time.
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 e4a2ffd..1b62249 100644
--- a/tempest/api/compute/admin/test_instance_usage_audit_log.py
+++ b/tempest/api/compute/admin/test_instance_usage_audit_log.py
@@ -31,27 +31,11 @@
@decorators.idempotent_id('25319919-33d9-424f-9f99-2c203ee48b9d')
def test_list_instance_usage_audit_logs(self):
# list instance usage audit logs
- body = (self.adm_client.list_instance_usage_audit_logs()
- ["instance_usage_audit_logs"])
- 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.adm_client.list_instance_usage_audit_logs()
@decorators.idempotent_id('6e40459d-7c5f-400b-9e83-449fbc8e7feb')
def test_get_instance_usage_audit_log(self):
# Get instance usage audit log before specified time
now = datetime.datetime.now()
- body = (self.adm_client.show_instance_usage_audit_log(
+ self.adm_client.show_instance_usage_audit_log(
urllib.quote(now.strftime("%Y-%m-%d %H:%M:%S")))
- ["instance_usage_audit_log"])
-
- 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)
diff --git a/tempest/api/compute/admin/test_volume_swap.py b/tempest/api/compute/admin/test_volume_swap.py
index ed8cf20..a853182 100644
--- a/tempest/api/compute/admin/test_volume_swap.py
+++ b/tempest/api/compute/admin/test_volume_swap.py
@@ -82,6 +82,11 @@
is attached to "instance1" and "volume2" is in available state.
"""
+ # NOTE(mriedem): This is an uncommon scenario to call the compute API
+ # to swap volumes directly; swap volume is primarily only for volume
+ # live migration and retype callbacks from the volume service, and is slow
+ # so it's marked as such.
+ @decorators.attr(type='slow')
@decorators.idempotent_id('1769f00d-a693-4d67-a631-6a3496773813')
@utils.services('volume')
def test_volume_swap(self):
@@ -136,6 +141,11 @@
if not CONF.compute_feature_enabled.volume_multiattach:
raise cls.skipException('Volume multi-attach is not available.')
+ # NOTE(mriedem): This is an uncommon scenario to call the compute API
+ # to swap volumes directly; swap volume is primarily only for volume
+ # live migration and retype callbacks from the volume service, and is slow
+ # so it's marked as such.
+ @decorators.attr(type='slow')
@decorators.idempotent_id('e8f8f9d1-d7b7-4cd2-8213-ab85ef697b6e')
@utils.services('volume')
def test_volume_swap_with_multiattach(self):
@@ -146,13 +156,19 @@
volume1 = self.create_volume(multiattach=True)
volume2 = self.create_volume(multiattach=True)
- # Boot server1
- server1 = self.create_test_server(wait_until='ACTIVE')
+ # Create two servers and wait for them to be ACTIVE.
+ reservation_id = self.create_test_server(
+ wait_until='ACTIVE', min_count=2,
+ return_reservation_id=True)['reservation_id']
+ # Get the servers using the reservation_id.
+ servers = self.servers_client.list_servers(
+ reservation_id=reservation_id)['servers']
+ self.assertEqual(2, len(servers))
# Attach volume1 to server1
+ server1 = servers[0]
self.attach_volume(server1, volume1)
- # Boot server2
- server2 = self.create_test_server(wait_until='ACTIVE')
# Attach volume1 to server2
+ server2 = servers[1]
self.attach_volume(server2, volume1)
# Swap volume1 to volume2 on server1, volume1 should remain attached
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index ff2f99c..4e2b59b 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -331,8 +331,7 @@
# The compute image proxy APIs were deprecated in 2.35 so
# use the images client directly if the API microversion being
# used is >=2.36.
- if api_version_utils.compare_version_header_to_response(
- "OpenStack-API-Version", "compute 2.36", image.response, "lt"):
+ if not cls.is_requested_microversion_compatible('2.35'):
client = cls.images_client
else:
client = cls.compute_images_client
@@ -341,6 +340,9 @@
if wait_until is not None:
try:
+ wait_until = wait_until.upper()
+ if not cls.is_requested_microversion_compatible('2.35'):
+ wait_until = wait_until.lower()
waiters.wait_for_image_status(client, image_id, wait_until)
except lib_exc.NotFound:
if wait_until.upper() == 'ACTIVE':
diff --git a/tempest/api/compute/images/test_images.py b/tempest/api/compute/images/test_images.py
index 29bd6da..c8221c2 100644
--- a/tempest/api/compute/images/test_images.py
+++ b/tempest/api/compute/images/test_images.py
@@ -38,7 +38,10 @@
@classmethod
def setup_clients(cls):
super(ImagesTestJSON, cls).setup_clients()
- cls.client = cls.compute_images_client
+ if cls.is_requested_microversion_compatible('2.35'):
+ cls.client = cls.compute_images_client
+ else:
+ cls.client = cls.images_client
@decorators.idempotent_id('aa06b52b-2db5-4807-b218-9441f75d74e3')
def test_delete_saving_image(self):
diff --git a/tempest/api/compute/images/test_images_negative.py b/tempest/api/compute/images/test_images_negative.py
index e292389..2400348 100644
--- a/tempest/api/compute/images/test_images_negative.py
+++ b/tempest/api/compute/images/test_images_negative.py
@@ -22,11 +22,11 @@
CONF = config.CONF
-class ImagesNegativeTestJSON(base.BaseV2ComputeTest):
+class ImagesNegativeTestBase(base.BaseV2ComputeTest):
@classmethod
def skip_checks(cls):
- super(ImagesNegativeTestJSON, cls).skip_checks()
+ super(ImagesNegativeTestBase, cls).skip_checks()
if not CONF.service_available.glance:
skip_msg = ("%s skipped as glance is not available" % cls.__name__)
raise cls.skipException(skip_msg)
@@ -37,9 +37,12 @@
@classmethod
def setup_clients(cls):
- super(ImagesNegativeTestJSON, cls).setup_clients()
+ super(ImagesNegativeTestBase, cls).setup_clients()
cls.client = cls.compute_images_client
+
+class ImagesNegativeTestJSON(ImagesNegativeTestBase):
+
@decorators.attr(type=['negative'])
@decorators.idempotent_id('6cd5a89d-5b47-46a7-93bc-3916f0d84973')
def test_create_image_from_deleted_server(self):
@@ -82,6 +85,10 @@
self.assertRaises(lib_exc.NotFound, self.client.create_image,
test_uuid, name=snapshot_name)
+
+class ImagesDeleteNegativeTestJSON(ImagesNegativeTestBase):
+ max_microversion = '2.35'
+
@decorators.attr(type=['negative'])
@decorators.idempotent_id('381acb65-785a-4942-94ce-d8f8c84f1f0f')
def test_delete_image_with_invalid_image_id(self):
diff --git a/tempest/api/compute/images/test_images_oneserver.py b/tempest/api/compute/images/test_images_oneserver.py
index 058e7e6..3c152c9 100644
--- a/tempest/api/compute/images/test_images_oneserver.py
+++ b/tempest/api/compute/images/test_images_oneserver.py
@@ -44,7 +44,10 @@
@classmethod
def setup_clients(cls):
super(ImagesOneServerTestJSON, cls).setup_clients()
- cls.client = cls.compute_images_client
+ if cls.is_requested_microversion_compatible('2.35'):
+ cls.client = cls.compute_images_client
+ else:
+ cls.client = cls.images_client
def _get_default_flavor_disk_size(self, flavor_id):
flavor = self.flavors_client.show_flavor(flavor_id)['flavor']
@@ -52,6 +55,13 @@
@decorators.idempotent_id('3731d080-d4c5-4872-b41a-64d0d0021314')
def test_create_delete_image(self):
+ if self.is_requested_microversion_compatible('2.35'):
+ MIN_DISK = 'minDisk'
+ MIN_RAM = 'minRam'
+ else:
+ MIN_DISK = 'min_disk'
+ MIN_RAM = 'min_ram'
+
# Create a new image
name = data_utils.rand_name('image')
meta = {'image_type': 'test'}
@@ -61,17 +71,22 @@
# Verify the image was created correctly
self.assertEqual(name, image['name'])
- self.assertEqual('test', image['metadata']['image_type'])
+ if self.is_requested_microversion_compatible('2.35'):
+ self.assertEqual('test', image['metadata']['image_type'])
+ else:
+ self.assertEqual('test', image['image_type'])
- original_image = self.client.show_image(self.image_ref)['image']
+ original_image = self.client.show_image(self.image_ref)
+ if self.is_requested_microversion_compatible('2.35'):
+ original_image = original_image['image']
# 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
self.client.delete_image(image['id'])
@@ -86,7 +101,8 @@
# will return 400(Bad Request) if we attempt to send a name which has
# 4 byte utf-8 character.
utf8_name = data_utils.rand_name(b'\xe2\x82\xa1'.decode('utf-8'))
- body = self.client.create_image(self.server_id, name=utf8_name)
+ body = self.compute_images_client.create_image(
+ self.server_id, name=utf8_name)
if api_version_utils.compare_version_header_to_response(
"OpenStack-API-Version", "compute 2.45", body.response, "lt"):
image_id = body['image_id']
diff --git a/tempest/api/compute/images/test_images_oneserver_negative.py b/tempest/api/compute/images/test_images_oneserver_negative.py
index bebc6ca..512c9d2 100644
--- a/tempest/api/compute/images/test_images_oneserver_negative.py
+++ b/tempest/api/compute/images/test_images_oneserver_negative.py
@@ -72,7 +72,10 @@
@classmethod
def setup_clients(cls):
super(ImagesOneServerNegativeTestJSON, cls).setup_clients()
- cls.client = cls.compute_images_client
+ if cls.is_requested_microversion_compatible('2.35'):
+ cls.client = cls.compute_images_client
+ else:
+ cls.client = cls.images_client
@classmethod
def resource_setup(cls):
@@ -122,7 +125,8 @@
# Return an error if snapshot name over 255 characters is passed
snapshot_name = ('a' * 256)
- self.assertRaises(lib_exc.BadRequest, self.client.create_image,
+ self.assertRaises(lib_exc.BadRequest,
+ self.compute_images_client.create_image,
self.server_id, name=snapshot_name)
@decorators.attr(type=['negative'])
diff --git a/tempest/api/compute/images/test_list_image_filters.py b/tempest/api/compute/images/test_list_image_filters.py
index d83d8df..2ac7de3 100644
--- a/tempest/api/compute/images/test_list_image_filters.py
+++ b/tempest/api/compute/images/test_list_image_filters.py
@@ -31,6 +31,7 @@
class ListImageFiltersTestJSON(base.BaseV2ComputeTest):
+ max_microversion = '2.35'
@classmethod
def skip_checks(cls):
diff --git a/tempest/api/compute/images/test_list_image_filters_negative.py b/tempest/api/compute/images/test_list_image_filters_negative.py
index d37f8fc..81c59f9 100644
--- a/tempest/api/compute/images/test_list_image_filters_negative.py
+++ b/tempest/api/compute/images/test_list_image_filters_negative.py
@@ -22,6 +22,7 @@
class ListImageFiltersNegativeTestJSON(base.BaseV2ComputeTest):
+ max_microversion = '2.35'
@classmethod
def skip_checks(cls):
diff --git a/tempest/api/compute/images/test_list_images.py b/tempest/api/compute/images/test_list_images.py
index e2dbd72..cbb65bb 100644
--- a/tempest/api/compute/images/test_list_images.py
+++ b/tempest/api/compute/images/test_list_images.py
@@ -21,6 +21,7 @@
class ListImagesTestJSON(base.BaseV2ComputeTest):
+ max_microversion = '2.35'
@classmethod
def skip_checks(cls):
diff --git a/tempest/api/compute/servers/test_attach_interfaces.py b/tempest/api/compute/servers/test_attach_interfaces.py
index 0636ee4..1e952a1 100644
--- a/tempest/api/compute/servers/test_attach_interfaces.py
+++ b/tempest/api/compute/servers/test_attach_interfaces.py
@@ -20,6 +20,7 @@
from tempest.api.compute import base
from tempest.common import compute
from tempest.common import utils
+from tempest.common.utils.linux import remote_client
from tempest.common.utils import net_utils
from tempest.common import waiters
from tempest import config
@@ -38,11 +39,16 @@
raise cls.skipException("Neutron is required")
if not CONF.compute_feature_enabled.interface_attach:
raise cls.skipException("Interface attachment is not available.")
+ if not CONF.validation.run_validation:
+ raise cls.skipException('Validation should be enabled to ensure '
+ 'guest OS is running and capable of '
+ 'processing ACPI events.')
@classmethod
def setup_credentials(cls):
# This test class requires network and subnet
- cls.set_network_resources(network=True, subnet=True)
+ cls.set_network_resources(network=True, subnet=True, router=True,
+ dhcp=True)
super(AttachInterfacesTestBase, cls).setup_credentials()
@classmethod
@@ -51,8 +57,27 @@
cls.subnets_client = cls.os_primary.subnets_client
cls.ports_client = cls.os_primary.ports_client
+ def _wait_for_validation(self, server, validation_resources):
+ linux_client = remote_client.RemoteClient(
+ self.get_server_ip(server, validation_resources),
+ self.image_ssh_user,
+ self.image_ssh_password,
+ validation_resources['keypair']['private_key'],
+ server=server,
+ servers_client=self.servers_client)
+ linux_client.validate_authentication()
+
def _create_server_get_interfaces(self):
- server = self.create_test_server(wait_until='ACTIVE')
+ validation_resources = self.get_test_validation_resources(
+ self.os_primary)
+ server = self.create_test_server(
+ validatable=True,
+ validation_resources=validation_resources,
+ wait_until='ACTIVE')
+ # NOTE(artom) self.create_test_server adds cleanups, but this is
+ # apparently not enough? Add cleanup here.
+ self.addCleanup(self.delete_server, server['id'])
+ self._wait_for_validation(server, validation_resources)
ifs = (self.interfaces_client.list_interfaces(server['id'])
['interfaceAttachments'])
body = waiters.wait_for_interface_status(
@@ -274,15 +299,26 @@
port_id = port['port']['id']
self.addCleanup(self.ports_client.delete_port, port_id)
- # create two servers
- _, servers = compute.create_test_server(
- self.os_primary, tenant_network=network,
- wait_until='ACTIVE', min_count=2)
+ # NOTE(artom) We create two servers one at a time because
+ # create_test_server doesn't support multiple validatable servers.
+ validation_resources = self.get_test_validation_resources(
+ self.os_primary)
+
+ def _create_validatable_server():
+ _, servers = compute.create_test_server(
+ self.os_primary, tenant_network=network,
+ wait_until='ACTIVE', validatable=True,
+ validation_resources=validation_resources)
+ return servers[0]
+
+ servers = [_create_validatable_server(), _create_validatable_server()]
+
# add our cleanups for the servers since we bypassed the base class
for server in servers:
self.addCleanup(self.delete_server, server['id'])
for server in servers:
+ self._wait_for_validation(server, validation_resources)
# attach the port to the server
iface = self.interfaces_client.create_interface(
server['id'], port_id=port_id)['interfaceAttachment']
diff --git a/tempest/api/compute/servers/test_device_tagging.py b/tempest/api/compute/servers/test_device_tagging.py
index 40681cb..d40f937 100644
--- a/tempest/api/compute/servers/test_device_tagging.py
+++ b/tempest/api/compute/servers/test_device_tagging.py
@@ -138,6 +138,9 @@
except Exception:
return False
+ # NOTE(mriedem): This is really more like a scenario test and is slow so
+ # it's marked as such.
+ @decorators.attr(type='slow')
@decorators.idempotent_id('a2e65a6c-66f1-4442-aaa8-498c31778d96')
@utils.services('network', 'volume', 'image')
def test_tagged_boot_devices(self):
diff --git a/tempest/api/compute/servers/test_server_actions.py b/tempest/api/compute/servers/test_server_actions.py
index f6494b5..f3d7476 100644
--- a/tempest/api/compute/servers/test_server_actions.py
+++ b/tempest/api/compute/servers/test_server_actions.py
@@ -265,6 +265,11 @@
self.client.start_server(self.server_id)
+ # NOTE(mriedem): Marked as slow because while rebuild and volume-backed is
+ # common, we don't actually change the image (you can't with volume-backed
+ # rebuild) so this isn't testing much outside normal rebuild
+ # (and it's slow).
+ @decorators.attr(type='slow')
@decorators.idempotent_id('b68bd8d6-855d-4212-b59b-2e704044dace')
@utils.services('volume')
def test_rebuild_server_with_volume_attached(self):
diff --git a/tempest/api/compute/servers/test_server_personality.py b/tempest/api/compute/servers/test_server_personality.py
index 6f32b46..4f484e2 100644
--- a/tempest/api/compute/servers/test_server_personality.py
+++ b/tempest/api/compute/servers/test_server_personality.py
@@ -45,6 +45,10 @@
super(ServerPersonalityTestJSON, cls).setup_clients()
cls.client = cls.servers_client
+ # NOTE(mriedem): Marked as slow because personality (file injection) is
+ # deprecated in nova so we don't care as much about running this all the
+ # time (and it's slow).
+ @decorators.attr(type='slow')
@decorators.idempotent_id('3cfe87fd-115b-4a02-b942-7dc36a337fdf')
def test_create_server_with_personality(self):
file_contents = 'This is a test file.'
@@ -75,6 +79,10 @@
linux_client.exec_command(
'sudo cat %s' % file_path))
+ # NOTE(mriedem): Marked as slow because personality (file injection) is
+ # deprecated in nova so we don't care as much about running this all the
+ # time (and it's slow).
+ @decorators.attr(type='slow')
@decorators.idempotent_id('128966d8-71fc-443c-8cab-08e24114ecc9')
def test_rebuild_server_with_personality(self):
validation_resources = self.get_test_validation_resources(
@@ -117,6 +125,10 @@
self.assertRaises((lib_exc.Forbidden, lib_exc.OverLimit),
self.create_test_server, personality=personality)
+ # NOTE(mriedem): Marked as slow because personality (file injection) is
+ # deprecated in nova so we don't care as much about running this all the
+ # time (and it's slow).
+ @decorators.attr(type='slow')
@decorators.idempotent_id('52f12ee8-5180-40cc-b417-31572ea3d555')
def test_can_create_server_with_max_number_personality_files(self):
# Server should be created successfully if maximum allowed number of
diff --git a/tempest/api/compute/servers/test_servers_negative.py b/tempest/api/compute/servers/test_servers_negative.py
index 0c1c05c..6cabf65 100644
--- a/tempest/api/compute/servers/test_servers_negative.py
+++ b/tempest/api/compute/servers/test_servers_negative.py
@@ -488,8 +488,11 @@
server = self.client.show_server(self.server_id)['server']
image_name = server['name'] + '-shelved'
- params = {'name': image_name}
- images = self.compute_images_client.list_images(**params)['images']
+ if CONF.image_feature_enabled.api_v1:
+ kwargs = {'name': image_name}
+ else:
+ kwargs = {'params': {'name': image_name}}
+ images = self.images_client.list_images(**kwargs)['images']
self.assertEqual(1, len(images))
self.assertEqual(image_name, images[0]['name'])
diff --git a/tempest/api/compute/volumes/test_attach_volume.py b/tempest/api/compute/volumes/test_attach_volume.py
index caa445d..811b521 100644
--- a/tempest/api/compute/volumes/test_attach_volume.py
+++ b/tempest/api/compute/volumes/test_attach_volume.py
@@ -160,6 +160,9 @@
This test checks the attaching and detaching volumes from
a shelved or shelved offload instance.
+
+ Note that these are uncommon scenarios until blueprint detach-boot-volume
+ is implemented in the compute service.
"""
min_microversion = '2.20'
@@ -220,6 +223,9 @@
server, validation_resources)
self.assertEqual(number_of_volumes, counted_volumes)
+ # NOTE(mriedem): Marked as slow since this is an uncommon scenario until
+ # attach/detach root volume is supported in nova, and it's slow.
+ @decorators.attr(type='slow')
@decorators.idempotent_id('13a940b6-3474-4c3c-b03f-29b89112bfee')
def test_attach_volume_shelved_or_offload_server(self):
# Create server, count number of volumes on it, shelve
@@ -245,6 +251,9 @@
# case of shelved_offloaded.
self.assertIsNotNone(volume_attachment['device'])
+ # NOTE(mriedem): Marked as slow since this is an uncommon scenario until
+ # attach/detach root volume is supported in nova, and it's slow.
+ @decorators.attr(type='slow')
@decorators.idempotent_id('b54e86dd-a070-49c4-9c07-59ae6dae15aa')
def test_detach_volume_shelved_or_offload_server(self):
# Count number of volumes on instance, shelve
diff --git a/tempest/api/identity/admin/v3/test_credentials.py b/tempest/api/identity/admin/v3/test_credentials.py
index ba19ff7..23fe788 100644
--- a/tempest/api/identity/admin/v3/test_credentials.py
+++ b/tempest/api/identity/admin/v3/test_credentials.py
@@ -20,6 +20,10 @@
class CredentialsTestJSON(base.BaseIdentityV3AdminTest):
+ # NOTE: force_tenant_isolation is true in the base class by default but
+ # overridden to false here to allow test execution for clouds using the
+ # pre-provisioned credentials provider.
+ force_tenant_isolation = False
@classmethod
def resource_setup(cls):
@@ -27,10 +31,6 @@
cls.projects = list()
cls.creds_list = [['project_id', 'user_id', 'id'],
['access', 'secret']]
- u_name = data_utils.rand_name('user')
- u_desc = '%s description' % u_name
- u_email = '%s@testmail.tm' % u_name
- u_password = data_utils.rand_password()
for _ in range(2):
project = cls.projects_client.create_project(
data_utils.rand_name('project'),
@@ -38,12 +38,8 @@
cls.addClassResourceCleanup(
cls.projects_client.delete_project, project['id'])
cls.projects.append(project['id'])
-
- cls.user_body = cls.users_client.create_user(
- name=u_name, description=u_desc, password=u_password,
- email=u_email, project_id=cls.projects[0])['user']
- cls.addClassResourceCleanup(
- cls.users_client.delete_user, cls.user_body['id'])
+ cls.user_body = cls.users_client.show_user(
+ cls.os_primary.credentials.user_id)['user']
def _delete_credential(self, cred_id):
self.creds_client.delete_credential(cred_id)
diff --git a/tempest/api/image/v2/test_images_member.py b/tempest/api/image/v2/test_images_member.py
index 0208780..e19d8c8 100644
--- a/tempest/api/image/v2/test_images_member.py
+++ b/tempest/api/image/v2/test_images_member.py
@@ -33,8 +33,8 @@
self.assertIn(image_id, self._list_image_ids_as_alt())
body = self.image_member_client.list_image_members(image_id)
members = body['members']
- member = members[0]
self.assertEqual(len(members), 1, str(members))
+ member = members[0]
self.assertEqual(member['member_id'], self.alt_tenant_id)
self.assertEqual(member['image_id'], image_id)
self.assertEqual(member['status'], 'accepted')
diff --git a/tempest/api/network/admin/test_agent_management.py b/tempest/api/network/admin/test_agent_management.py
index 5068fc4..30ed176 100644
--- a/tempest/api/network/admin/test_agent_management.py
+++ b/tempest/api/network/admin/test_agent_management.py
@@ -15,7 +15,9 @@
from tempest.api.network import base
from tempest.common import tempest_fixtures as fixtures
from tempest.common import utils
+from tempest.lib.common.utils import data_utils
from tempest.lib import decorators
+from tempest.lib import exceptions as lib_exc
class AgentManagementTestJSON(base.BaseAdminNetworkTest):
@@ -86,3 +88,11 @@
origin_agent = {'description': description}
self.admin_agents_client.update_agent(agent_id=self.agent['id'],
agent=origin_agent)
+
+ @decorators.idempotent_id('b33af888-b6ac-4e68-a0ca-0444c2696cf9')
+ @decorators.attr(type=['negative'])
+ def test_delete_agent_negative(self):
+ non_existent_id = data_utils.rand_uuid()
+ self.assertRaises(
+ lib_exc.NotFound,
+ self.agents_client.delete_agent, non_existent_id)
diff --git a/tempest/api/network/test_routers.py b/tempest/api/network/test_routers.py
index 8b03631..be3cf65 100644
--- a/tempest/api/network/test_routers.py
+++ b/tempest/api/network/test_routers.py
@@ -27,22 +27,6 @@
class RoutersTest(base.BaseNetworkTest):
- def _cleanup_router(self, router):
- self.delete_router(router)
-
- def _create_router(self, name=None, admin_state_up=False,
- external_network_id=None, enable_snat=None):
- # associate a cleanup with created routers to avoid quota limits
- router = self.create_router(name, admin_state_up,
- external_network_id, enable_snat)
- self.addCleanup(self._cleanup_router, router)
- return router
-
- def _create_subnet(self, network, gateway='', cidr=None):
- subnet = self.create_subnet(network, gateway, cidr)
- self.addCleanup(self.subnets_client.delete_subnet, subnet['id'])
- return subnet
-
def _add_router_interface_with_subnet_id(self, router_id, subnet_id):
interface = self.routers_client.add_router_interface(
router_id, subnet_id=subnet_id)
@@ -70,10 +54,11 @@
def test_create_show_list_update_delete_router(self):
# Create a router
router_name = data_utils.rand_name(self.__class__.__name__ + '-router')
- router = self._create_router(
- name=router_name,
+ router = self.create_router(
+ router_name,
admin_state_up=False,
external_network_id=CONF.network.public_network_id)
+ self.addCleanup(self.delete_router, router)
self.assertEqual(router['name'], router_name)
self.assertEqual(router['admin_state_up'], False)
self.assertEqual(
@@ -106,8 +91,10 @@
name=network_name)['network']
self.addCleanup(self.networks_client.delete_network,
network['id'])
- subnet = self._create_subnet(network)
- router = self._create_router()
+ subnet = self.create_subnet(network)
+ self.addCleanup(self.subnets_client.delete_subnet, subnet['id'])
+ router = self.create_router()
+ self.addCleanup(self.delete_router, router)
# Add router interface with subnet id
interface = self.routers_client.add_router_interface(
router['id'], subnet_id=subnet['id'])
@@ -129,8 +116,10 @@
name=network_name)['network']
self.addCleanup(self.networks_client.delete_network,
network['id'])
- self._create_subnet(network)
- router = self._create_router()
+ subnet = self.create_subnet(network)
+ self.addCleanup(self.subnets_client.delete_subnet, subnet['id'])
+ router = self.create_router()
+ self.addCleanup(self.delete_router, router)
port_body = self.ports_client.create_port(
network_id=network['id'])
# add router interface to port created above
@@ -188,7 +177,8 @@
test_routes = []
routes_num = 4
# Create a router
- router = self._create_router(admin_state_up=True)
+ router = self.create_router(admin_state_up=True)
+ self.addCleanup(self.delete_router, router)
self.addCleanup(
self._delete_extra_routes,
router['id'])
@@ -201,6 +191,7 @@
self.addCleanup(self.networks_client.delete_network,
network['id'])
subnet = self.create_subnet(network, cidr=next_cidr)
+ self.addCleanup(self.subnets_client.delete_subnet, subnet['id'])
next_cidr = next_cidr.next()
# Add router interface with subnet id
@@ -247,7 +238,8 @@
@decorators.idempotent_id('a8902683-c788-4246-95c7-ad9c6d63a4d9')
def test_update_router_admin_state(self):
- router = self._create_router()
+ router = self.create_router()
+ self.addCleanup(self.delete_router, router)
self.assertFalse(router['admin_state_up'])
# Update router admin state
update_body = self.routers_client.update_router(router['id'],
@@ -264,14 +256,18 @@
name=network_name)['network']
self.addCleanup(self.networks_client.delete_network,
network01['id'])
+ network_name = data_utils.rand_name(self.__class__.__name__)
network02 = self.networks_client.create_network(
- name=data_utils.rand_name(self.__class__.__name__))['network']
+ name=network_name)['network']
self.addCleanup(self.networks_client.delete_network,
network02['id'])
- subnet01 = self._create_subnet(network01)
+ subnet01 = self.create_subnet(network01)
+ self.addCleanup(self.subnets_client.delete_subnet, subnet01['id'])
sub02_cidr = self.cidr.next()
- subnet02 = self._create_subnet(network02, cidr=sub02_cidr)
- router = self._create_router()
+ subnet02 = self.create_subnet(network02, cidr=sub02_cidr)
+ self.addCleanup(self.subnets_client.delete_subnet, subnet02['id'])
+ router = self.create_router()
+ self.addCleanup(self.delete_router, router)
interface01 = self._add_router_interface_with_subnet_id(router['id'],
subnet01['id'])
self._verify_router_interface(router['id'], subnet01['id'],
@@ -288,8 +284,10 @@
name=network_name)['network']
self.addCleanup(self.networks_client.delete_network,
network['id'])
- subnet = self._create_subnet(network)
- router = self._create_router()
+ subnet = self.create_subnet(network)
+ self.addCleanup(self.subnets_client.delete_subnet, subnet['id'])
+ router = self.create_router()
+ self.addCleanup(self.delete_router, router)
fixed_ip = [{'subnet_id': subnet['id']}]
interface = self._add_router_interface_with_subnet_id(router['id'],
subnet['id'])
diff --git a/tempest/api/network/test_versions.py b/tempest/api/network/test_versions.py
index 2f01e50..020cb5c 100644
--- a/tempest/api/network/test_versions.py
+++ b/tempest/api/network/test_versions.py
@@ -29,7 +29,7 @@
"""
result = self.network_versions_client.list_versions()
- expected_versions = ('v2.0')
+ expected_versions = ('v2.0',)
expected_resources = ('id', 'links', 'status')
received_list = result.values()
@@ -38,3 +38,14 @@
for resource in expected_resources:
self.assertIn(resource, version)
self.assertIn(version['id'], expected_versions)
+
+ @decorators.attr(type='smoke')
+ @decorators.idempotent_id('e64b7216-3178-4263-967c-d389290988bf')
+ def test_show_api_v2_details(self):
+ """Test that GET /v2.0/ returns expected resources."""
+ current_version = 'v2.0'
+ expected_resources = ('subnet', 'network', 'port')
+ result = self.network_versions_client.show_version(current_version)
+ actual_resources = [r['name'] for r in result['resources']]
+ for resource in expected_resources:
+ self.assertIn(resource, actual_resources)
diff --git a/tempest/api/volume/admin/test_backends_capabilities.py b/tempest/api/volume/admin/test_backends_capabilities.py
index 607fc43..affed6b 100644
--- a/tempest/api/volume/admin/test_backends_capabilities.py
+++ b/tempest/api/volume/admin/test_backends_capabilities.py
@@ -72,8 +72,8 @@
]
# Returns a tuple of VOLUME_STATS values
- expected_list = list(map(operator.itemgetter(*VOLUME_STATS),
- cinder_pools))
- observed_list = list(map(operator.itemgetter(*VOLUME_STATS),
- capabilities))
+ expected_list = sorted(list(map(operator.itemgetter(*VOLUME_STATS),
+ cinder_pools)))
+ observed_list = sorted(list(map(operator.itemgetter(*VOLUME_STATS),
+ capabilities)))
self.assertEqual(expected_list, observed_list)
diff --git a/tempest/api/volume/admin/test_group_snapshots.py b/tempest/api/volume/admin/test_group_snapshots.py
index 731a055..f695f51 100644
--- a/tempest/api/volume/admin/test_group_snapshots.py
+++ b/tempest/api/volume/admin/test_group_snapshots.py
@@ -215,6 +215,7 @@
max_microversion = 'latest'
@decorators.idempotent_id('3b42c9b9-c984-4444-816e-ca2e1ed30b40')
+ @decorators.skip_because(bug='1770179')
def test_reset_group_snapshot_status(self):
# Create volume type
volume_type = self.create_volume_type()
diff --git a/tempest/api/volume/admin/test_volume_types.py b/tempest/api/volume/admin/test_volume_types.py
index 1077524..9e24176 100644
--- a/tempest/api/volume/admin/test_volume_types.py
+++ b/tempest/api/volume/admin/test_volume_types.py
@@ -193,8 +193,13 @@
'is_public': is_public}
updated_vol_type = self.admin_volume_types_client.update_volume_type(
volume_type['id'], **kwargs)['volume_type']
-
- # Verify volume type details were updated
self.assertEqual(name, updated_vol_type['name'])
self.assertEqual(description, updated_vol_type['description'])
self.assertEqual(is_public, updated_vol_type['is_public'])
+
+ # Verify volume type details were updated
+ fetched_volume_type = self.admin_volume_types_client.show_volume_type(
+ volume_type['id'])['volume_type']
+ self.assertEqual(name, fetched_volume_type['name'])
+ self.assertEqual(description, fetched_volume_type['description'])
+ self.assertEqual(is_public, fetched_volume_type['is_public'])
diff --git a/tempest/cmd/account_generator.py b/tempest/cmd/account_generator.py
index 9be8ee2..25e91aa 100755
--- a/tempest/cmd/account_generator.py
+++ b/tempest/cmd/account_generator.py
@@ -162,7 +162,6 @@
if CONF.service_available.swift:
spec.append([CONF.object_storage.operator_role])
spec.append([CONF.object_storage.reseller_admin_role])
- spec.append([CONF.object_storage.operator_role])
if admin:
spec.append('admin')
resources = []
@@ -195,7 +194,6 @@
if test_resource.network:
account['resources'] = {}
- if test_resource.network:
account['resources']['network'] = test_resource.network['name']
accounts.append(account)
if os.path.exists(account_file):
diff --git a/tempest/cmd/cleanup_service.py b/tempest/cmd/cleanup_service.py
index 83cf42c..1a08246 100644
--- a/tempest/cmd/cleanup_service.py
+++ b/tempest/cmd/cleanup_service.py
@@ -720,11 +720,11 @@
class ImageService(BaseService):
def __init__(self, manager, **kwargs):
super(ImageService, self).__init__(kwargs)
- self.client = manager.compute_images_client
+ self.client = manager.image_client_v2
def list(self):
client = self.client
- images = client.list_images({"all_tenants": True})['images']
+ images = client.list_images(params={"all_tenants": True})['images']
if not self.is_save_state:
images = [image for image in images if image['id']
not in self.saved_state_json['images'].keys()]
diff --git a/tempest/config.py b/tempest/config.py
index a8a3bc3..dbce504 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -306,7 +306,7 @@
help='Time in seconds before a shelved instance is eligible '
'for removing from a host. -1 never offload, 0 offload '
'when shelved. This configuration value should be same as '
- '[nova.DEFAULT]->shelved_offload_time in nova.conf, and '
+ 'nova.conf: DEFAULT.shelved_offload_time, and '
'some tests will run for as long as the time.'),
cfg.IntOpt('min_compute_nodes',
default=1,
@@ -408,7 +408,7 @@
cfg.BoolOpt('vnc_console',
default=False,
help='Enable VNC console. This configuration value should '
- 'be same as [nova.vnc]->vnc_enabled in nova.conf'),
+ 'be same as nova.conf: vnc.enabled'),
cfg.StrOpt('vnc_server_header',
default='WebSockify',
help='Expected VNC server name (WebSockify, nginx, etc) '
@@ -416,16 +416,16 @@
cfg.BoolOpt('spice_console',
default=False,
help='Enable Spice console. This configuration value should '
- 'be same as [nova.spice]->enabled in nova.conf'),
+ 'be same as nova.conf: spice.enabled'),
cfg.BoolOpt('rdp_console',
default=False,
help='Enable RDP console. This configuration value should '
- 'be same as [nova.rdp]->enabled in nova.conf'),
+ 'be same as nova.conf: rdp.enabled'),
cfg.BoolOpt('serial_console',
default=False,
help='Enable serial console. This configuration value '
- 'should be the same as [nova.serial_console]->enabled '
- 'in nova.conf'),
+ 'should be the same as '
+ 'nova.conf: serial_console.enabled'),
cfg.BoolOpt('rescue',
default=True,
help='Does the test environment support instance rescue '
@@ -547,7 +547,7 @@
'test v2 APIs only so this config option '
'will be removed.'),
cfg.BoolOpt('api_v1',
- default=True,
+ default=False,
help="Is the v1 image API enabled",
deprecated_for_removal=True,
deprecated_reason='Glance v1 APIs are deprecated and v2 APIs '
@@ -672,9 +672,11 @@
ValidationGroup = [
cfg.BoolOpt('run_validation',
- default=False,
+ default=True,
help='Enable ssh on created servers and creation of additional'
- ' validation resources to enable remote access'),
+ ' validation resources to enable remote access.'
+ ' In case the guest does not support ssh set it'
+ ' to false'),
cfg.BoolOpt('security_group',
default=True,
help='Enable/disable security groups.'),
@@ -1229,6 +1231,11 @@
def set_config_path(self, path):
self._path = path
+ # FIXME(masayukig): bug#1783751 To pass the config file path to child
+ # processes, we need to set the environment variables here as a
+ # workaround.
+ os.environ['TEMPEST_CONFIG_DIR'] = os.path.dirname(path)
+ os.environ['TEMPEST_CONFIG'] = os.path.basename(path)
CONF = TempestConfigProxy()
diff --git a/tempest/lib/api_schema/response/volume/qos.py b/tempest/lib/api_schema/response/volume/qos.py
new file mode 100644
index 0000000..d1b3910
--- /dev/null
+++ b/tempest/lib/api_schema/response/volume/qos.py
@@ -0,0 +1,123 @@
+# Copyright 2018 ZTE 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.
+
+show_qos = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'qos_specs': {
+ 'type': 'object',
+ 'properties': {
+ 'name': {'type': 'string'},
+ 'id': {'type': 'string', 'format': 'uuid'},
+ 'consumer': {'type': 'string'},
+ 'specs': {'type': ['object', 'null']},
+ },
+ 'additionalProperties': False,
+ 'required': ['name', 'id', 'specs']
+ },
+ 'links': {
+ 'type': 'array',
+ 'items': {
+ 'type': 'object',
+ 'properties': {
+ 'href': {'type': 'string',
+ 'format': 'uri'},
+ 'rel': {'type': 'string'},
+ },
+ 'additionalProperties': False,
+ 'required': ['href', 'rel']
+ }
+ }
+ },
+ 'additionalProperties': False,
+ 'required': ['qos_specs', 'links']
+ }
+}
+
+delete_qos = {'status_code': [202]}
+
+list_qos = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'qos_specs': {
+ 'type': 'array',
+ 'items': {
+ 'type': 'object',
+ 'properties': {
+ 'specs': {
+ 'type': 'object',
+ 'patternProperties': {'^.+$': {'type': 'string'}}
+ },
+ 'consumer': {'type': 'string'},
+ 'id': {'type': 'string', 'format': 'uuid'},
+ 'name': {'type': 'string'}
+ },
+ 'additionalProperties': False,
+ 'required': ['specs', 'id', 'name']
+ }
+ }
+ },
+ 'additionalProperties': False,
+ 'required': ['qos_specs']
+ }
+}
+
+set_qos_key = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'qos_specs': {
+ 'type': 'object',
+ 'patternProperties': {'^.+$': {'type': 'string'}}
+ },
+ },
+ 'additionalProperties': False,
+ 'required': ['qos_specs']
+ }
+}
+
+unset_qos_key = {'status_code': [202]}
+associate_qos = {'status_code': [202]}
+
+show_association_qos = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'qos_associations': {
+ 'type': 'array',
+ 'items': {
+ 'type': 'object',
+ 'properties': {
+ 'association_type': {'type': 'string'},
+ 'id': {'type': 'string', 'format': 'uuid'},
+ 'name': {'type': 'string'}
+ },
+ 'additionalProperties': False,
+ 'required': ['association_type', 'id', 'name']
+ }
+ },
+ },
+ 'additionalProperties': False,
+ 'required': ['qos_associations']
+ }
+}
+
+disassociate_qos = {'status_code': [202]}
+disassociate_all_qos = {'status_code': [202]}
diff --git a/tempest/lib/services/network/agents_client.py b/tempest/lib/services/network/agents_client.py
index 5068121..9fa4672 100644
--- a/tempest/lib/services/network/agents_client.py
+++ b/tempest/lib/services/network/agents_client.py
@@ -37,6 +37,16 @@
uri = '/agents/%s' % agent_id
return self.show_resource(uri, **fields)
+ def delete_agent(self, agent_id):
+ """Delete agent.
+
+ For a full list of available parameters, please refer to the official
+ API reference:
+ https://developer.openstack.org/api-ref/network/v2/index.html#delete-agent
+ """
+ uri = '/agents/%s' % agent_id
+ return self.delete_resource(uri)
+
def list_agents(self, **filters):
"""List all agents.
diff --git a/tempest/lib/services/network/versions_client.py b/tempest/lib/services/network/versions_client.py
index f87fe87..807f416 100644
--- a/tempest/lib/services/network/versions_client.py
+++ b/tempest/lib/services/network/versions_client.py
@@ -12,32 +12,36 @@
# License for the specific language governing permissions and limitations
# under the License.
-import time
-
from oslo_serialization import jsonutils as json
+from tempest.lib.common import rest_client
from tempest.lib.services.network import base
class NetworkVersionsClient(base.BaseNetworkClient):
def list_versions(self):
- """Do a GET / to fetch available API version information."""
+ """Do a GET / to fetch available API version information.
- version_url = self._get_base_version_url()
+ For more information, please refer to the official API reference:
+ https://developer.openstack.org/api-ref/network/v2/index.html#list-api-versions
+ """
- # Note: we do a raw_request here because we want to use
+ # Note: we do a self.get('/') here because we want to use
# an unversioned URL, not "v2/$project_id/".
- # Since raw_request doesn't log anything, we do that too.
- start = time.time()
- self._log_request_start('GET', version_url)
- response, body = self.raw_request(version_url, 'GET')
- self._error_checker(response, body)
- end = time.time()
- self._log_request('GET', version_url, response,
- secs=(end - start), resp_body=body)
-
- self.response_checker('GET', response, body)
- self.expected_success(200, response.status)
+ resp, body = self.get('/')
body = json.loads(body)
- return body
+ self.expected_success(200, resp.status)
+ return rest_client.ResponseBody(resp, body)
+
+ def show_version(self, version):
+ """Do a GET /<version> to fetch available resources.
+
+ For more information, please refer to the official API reference:
+ https://developer.openstack.org/api-ref/network/v2/index.html#show-api-v2-details
+ """
+
+ resp, body = self.get(version + '/')
+ body = json.loads(body)
+ self.expected_success(200, resp.status)
+ return rest_client.ResponseBody(resp, body)
diff --git a/tempest/lib/services/volume/v3/qos_client.py b/tempest/lib/services/volume/v3/qos_client.py
index 8f4d37f..5205590 100644
--- a/tempest/lib/services/volume/v3/qos_client.py
+++ b/tempest/lib/services/volume/v3/qos_client.py
@@ -14,6 +14,7 @@
from oslo_serialization import jsonutils as json
+from tempest.lib.api_schema.response.volume import qos as schema
from tempest.lib.common import rest_client
from tempest.lib import exceptions as lib_exc
@@ -45,15 +46,15 @@
"""
post_body = json.dumps({'qos_specs': kwargs})
resp, body = self.post('qos-specs', post_body)
- self.expected_success(200, resp.status)
body = json.loads(body)
+ self.validate_response(schema.show_qos, resp, body)
return rest_client.ResponseBody(resp, body)
def delete_qos(self, qos_id, force=False):
"""Delete the specified QoS specification."""
resp, body = self.delete(
"qos-specs/%s?force=%s" % (qos_id, force))
- self.expected_success(202, resp.status)
+ self.validate_response(schema.delete_qos, resp, body)
return rest_client.ResponseBody(resp, body)
def list_qos(self):
@@ -61,7 +62,7 @@
url = 'qos-specs'
resp, body = self.get(url)
body = json.loads(body)
- self.expected_success(200, resp.status)
+ self.validate_response(schema.list_qos, resp, body)
return rest_client.ResponseBody(resp, body)
def show_qos(self, qos_id):
@@ -69,7 +70,7 @@
url = "qos-specs/%s" % qos_id
resp, body = self.get(url)
body = json.loads(body)
- self.expected_success(200, resp.status)
+ self.validate_response(schema.show_qos, resp, body)
return rest_client.ResponseBody(resp, body)
def set_qos_key(self, qos_id, **kwargs):
@@ -82,7 +83,7 @@
put_body = json.dumps({"qos_specs": kwargs})
resp, body = self.put('qos-specs/%s' % qos_id, put_body)
body = json.loads(body)
- self.expected_success(200, resp.status)
+ self.validate_response(schema.set_qos_key, resp, body)
return rest_client.ResponseBody(resp, body)
def unset_qos_key(self, qos_id, keys):
@@ -96,7 +97,7 @@
"""
put_body = json.dumps({'keys': keys})
resp, body = self.put('qos-specs/%s/delete_keys' % qos_id, put_body)
- self.expected_success(202, resp.status)
+ self.validate_response(schema.unset_qos_key, resp, body)
return rest_client.ResponseBody(resp, body)
def associate_qos(self, qos_id, vol_type_id):
@@ -104,7 +105,7 @@
url = "qos-specs/%s/associate" % qos_id
url += "?vol_type_id=%s" % vol_type_id
resp, body = self.get(url)
- self.expected_success(202, resp.status)
+ self.validate_response(schema.associate_qos, resp, body)
return rest_client.ResponseBody(resp, body)
def show_association_qos(self, qos_id):
@@ -112,7 +113,7 @@
url = "qos-specs/%s/associations" % qos_id
resp, body = self.get(url)
body = json.loads(body)
- self.expected_success(200, resp.status)
+ self.validate_response(schema.show_association_qos, resp, body)
return rest_client.ResponseBody(resp, body)
def disassociate_qos(self, qos_id, vol_type_id):
@@ -120,12 +121,12 @@
url = "qos-specs/%s/disassociate" % qos_id
url += "?vol_type_id=%s" % vol_type_id
resp, body = self.get(url)
- self.expected_success(202, resp.status)
+ self.validate_response(schema.disassociate_qos, resp, body)
return rest_client.ResponseBody(resp, body)
def disassociate_all_qos(self, qos_id):
"""Disassociate the specified QoS with all associations."""
url = "qos-specs/%s/disassociate_all" % qos_id
resp, body = self.get(url)
- self.expected_success(202, resp.status)
+ self.validate_response(schema.disassociate_all_qos, resp, body)
return rest_client.ResponseBody(resp, body)
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index dff50a9..00d45cd 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -225,8 +225,12 @@
if size is None:
size = CONF.volume.volume_size
if imageRef:
- image = self.compute_images_client.show_image(imageRef)['image']
- min_disk = image.get('minDisk')
+ if CONF.image_feature_enabled.api_v1:
+ resp = self.image_client.check_image(imageRef)
+ image = common_image.get_image_meta_from_headers(resp)
+ else:
+ image = self.image_client.show_image(imageRef)
+ min_disk = image.get('min_disk')
size = max(size, min_disk)
if name is None:
name = data_utils.rand_name(self.__class__.__name__ + "-volume")
diff --git a/tempest/scenario/test_network_advanced_server_ops.py b/tempest/scenario/test_network_advanced_server_ops.py
index 8827610..e94ce3d 100644
--- a/tempest/scenario/test_network_advanced_server_ops.py
+++ b/tempest/scenario/test_network_advanced_server_ops.py
@@ -230,6 +230,7 @@
self.assertNotEqual(src_host, dst_host)
+ @decorators.skip_because(bug='1788403')
@decorators.idempotent_id('25b188d7-0183-4b1e-a11d-15840c8e2fd6')
@testtools.skipUnless(CONF.compute_feature_enabled.cold_migration,
'Cold migration is not available.')
diff --git a/tempest/tests/api/compute/test_base.py b/tempest/tests/api/compute/test_base.py
index 47f4ad6..1593464 100644
--- a/tempest/tests/api/compute/test_base.py
+++ b/tempest/tests/api/compute/test_base.py
@@ -131,8 +131,13 @@
self.assertIn(fault, six.text_type(ex))
else:
self.assertNotIn(fault, six.text_type(ex))
+ if compute_base.BaseV2ComputeTest.is_requested_microversion_compatible(
+ '2.35'):
+ status = 'ACTIVE'
+ else:
+ status = 'active'
wait_for_image_status.assert_called_once_with(
- compute_images_client, image_id, 'active')
+ compute_images_client, image_id, status)
servers_client.show_server.assert_called_once_with(
mock.sentinel.server_id)
diff --git a/tempest/tests/cmd/test_account_generator.py b/tempest/tests/cmd/test_account_generator.py
index fd9af08..a1d3a40 100644
--- a/tempest/tests/cmd/test_account_generator.py
+++ b/tempest/tests/cmd/test_account_generator.py
@@ -208,9 +208,9 @@
resources = account_generator.generate_resources(
self.cred_provider, admin=True)
resource_types = [k for k, _ in resources]
- # all options on, expect six credentials
- self.assertEqual(6, len(resources))
- # Ensure create_user was invoked 6 times (6 distinct users)
+ # all options on, expect five credentials
+ self.assertEqual(5, len(resources))
+ # Ensure create_user was invoked 5 times (5 distinct users)
self.assertEqual(5, self.user_create_fixture.mock.call_count)
self.assertIn('primary', resource_types)
self.assertIn('alt', resource_types)
@@ -267,14 +267,14 @@
# Ordered args in [0], keyword args in [1]
accounts, f = yaml_dump_mock.call_args[0]
self.assertEqual(handle, f)
- self.assertEqual(6, len(accounts))
+ self.assertEqual(5, len(accounts))
if self.domain_is_in:
self.assertIn('domain_name', accounts[0].keys())
else:
self.assertNotIn('domain_name', accounts[0].keys())
self.assertEqual(1, len([x for x in accounts if
x.get('types') == ['admin']]))
- self.assertEqual(3, len([x for x in accounts if 'roles' in x]))
+ self.assertEqual(2, len([x for x in accounts if 'roles' in x]))
for account in accounts:
self.assertIn('resources', account)
self.assertIn('network', account.get('resources'))
@@ -298,14 +298,14 @@
# Ordered args in [0], keyword args in [1]
accounts, f = yaml_dump_mock.call_args[0]
self.assertEqual(handle, f)
- self.assertEqual(6, len(accounts))
+ self.assertEqual(5, len(accounts))
if self.domain_is_in:
self.assertIn('domain_name', accounts[0].keys())
else:
self.assertNotIn('domain_name', accounts[0].keys())
self.assertEqual(1, len([x for x in accounts if
x.get('types') == ['admin']]))
- self.assertEqual(3, len([x for x in accounts if 'roles' in x]))
+ self.assertEqual(2, len([x for x in accounts if 'roles' in x]))
for account in accounts:
self.assertIn('resources', account)
self.assertIn('network', account.get('resources'))
diff --git a/tempest/tests/cmd/test_cleanup_services.py b/tempest/tests/cmd/test_cleanup_services.py
new file mode 100644
index 0000000..495d127
--- /dev/null
+++ b/tempest/tests/cmd/test_cleanup_services.py
@@ -0,0 +1,563 @@
+# Copyright 2018 AT&T 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 fixtures
+
+from oslo_serialization import jsonutils as json
+from tempest import clients
+from tempest.cmd import cleanup_service
+from tempest import config
+from tempest.tests import base
+from tempest.tests import fake_config
+from tempest.tests.lib import fake_credentials
+from tempest.tests.lib import fake_http
+
+
+class MockFunctionsBase(base.TestCase):
+
+ def _create_response(self, body, status, headers):
+ if status:
+ if body:
+ body = json.dumps(body)
+ resp = fake_http.fake_http_response(headers, status=status), body
+ return resp
+ else:
+ return body
+
+ def _create_fixtures(self, fixtures_to_make):
+ mocked_fixtures = []
+ for fixture in fixtures_to_make:
+ func, body, status = fixture
+ mocked_response = self._create_response(body, status, None)
+ if mocked_response == 'error':
+ mocked_func = self.useFixture(fixtures.MockPatch(
+ func, side_effect=Exception("error")))
+ else:
+ mocked_func = self.useFixture(fixtures.MockPatch(
+ func, return_value=mocked_response))
+ mocked_fixtures.append(mocked_func)
+ return mocked_fixtures
+
+ def run_function_with_mocks(self, function_to_run, functions_to_mock):
+ """Mock a service client function for testing.
+
+ :param function_to_run: The service client function to call.
+ :param functions_to_mock: a list of tuples containing the function
+ to mock, the response body, and the response status.
+ EX:
+ ('tempest.lib.common.rest_client.RestClient.get',
+ {'users': ['']},
+ 200)
+ """
+ mocked_fixtures = self._create_fixtures(functions_to_mock)
+ func_return = function_to_run()
+ return func_return, mocked_fixtures
+
+
+class BaseCmdServiceTests(MockFunctionsBase):
+
+ def setUp(self):
+ super(BaseCmdServiceTests, self).setUp()
+ self.useFixture(fake_config.ConfigFixture())
+ self.patchobject(config, 'TempestConfigPrivate',
+ fake_config.FakePrivate)
+ self.useFixture(fixtures.MockPatch(
+ 'tempest.cmd.cleanup_service._get_network_id',
+ return_value=''))
+ cleanup_service.init_conf()
+ self.conf_values = {"flavors": cleanup_service.CONF_FLAVORS[0],
+ "images": cleanup_service.CONF_IMAGES[0],
+ "projects": cleanup_service.CONF_PROJECTS[0],
+ "users": cleanup_service.CONF_USERS[0],
+ }
+
+ # Static list to ensure global service saved items are not deleted
+ saved_state = {"users": {u'32rwef64245tgr20121qw324bgg': u'Lightning'},
+ "flavors": {u'42': u'm1.tiny'},
+ "images": {u'34yhwr-4t3q': u'stratus-0.3.2-x86_64-disk'},
+ "roles": {u'3efrt74r45hn': u'president'},
+ "projects": {u'f38ohgp93jj032': u'manhattan'},
+ "domains": {u'default': u'Default'}
+ }
+ # Mocked methods
+ get_method = 'tempest.lib.common.rest_client.RestClient.get'
+ delete_method = 'tempest.lib.common.rest_client.RestClient.delete'
+ log_method = 'tempest.cmd.cleanup_service.LOG.exception'
+ # Override parameters
+ service_class = 'BaseService'
+ response = None
+ service_name = 'default'
+
+ def _create_cmd_service(self, service_type, is_save_state=False,
+ is_preserve=False, is_dry_run=False):
+ creds = fake_credentials.FakeKeystoneV3Credentials()
+ os = clients.Manager(creds)
+ return getattr(cleanup_service, service_type)(
+ os,
+ is_save_state=is_save_state,
+ is_preserve=is_preserve,
+ is_dry_run=is_dry_run,
+ data={},
+ saved_state_json=self.saved_state
+ )
+
+ def _test_delete(self, mocked_fixture_tuple_list, fail=False):
+ serv = self._create_cmd_service(self.service_class)
+ resp, fixtures = self.run_function_with_mocks(
+ serv.run,
+ mocked_fixture_tuple_list,
+ )
+ for fixture in fixtures:
+ if fail is False and fixture.mock.return_value == 'exception':
+ fixture.mock.assert_not_called()
+ elif self.service_name in self.saved_state.keys():
+ fixture.mock.assert_called_once()
+ for key in self.saved_state[self.service_name].keys():
+ self.assertNotIn(key, fixture.mock.call_args[0][0])
+ else:
+ fixture.mock.assert_called_once()
+ self.assertFalse(serv.data)
+
+ def _test_dry_run_true(self, mocked_fixture_tuple_list):
+ serv = self._create_cmd_service(self.service_class, is_dry_run=True)
+ _, fixtures = self.run_function_with_mocks(
+ serv.run,
+ mocked_fixture_tuple_list
+ )
+ for fixture in fixtures:
+ if fixture.mock.return_value == 'delete':
+ fixture.mock.assert_not_called()
+ elif self.service_name in self.saved_state.keys():
+ fixture.mock.assert_called_once()
+ for key in self.saved_state[self.service_name].keys():
+ self.assertNotIn(key, fixture.mock.call_args[0][0])
+ else:
+ fixture.mock.assert_called_once()
+
+ def _test_saved_state_true(self, mocked_fixture_tuple_list):
+ serv = self._create_cmd_service(self.service_class, is_save_state=True)
+ _, fixtures = self.run_function_with_mocks(
+ serv.run,
+ mocked_fixture_tuple_list
+ )
+ for item in self.response[self.service_name]:
+ self.assertIn(item['id'],
+ serv.data[self.service_name])
+ for fixture in fixtures:
+ fixture.mock.assert_called_once()
+
+ def _test_is_preserve_true(self, mocked_fixture_tuple_list):
+ serv = self._create_cmd_service(self.service_class, is_preserve=True)
+ resp, fixtures = self.run_function_with_mocks(
+ serv.list,
+ mocked_fixture_tuple_list
+ )
+ for fixture in fixtures:
+ fixture.mock.assert_called_once()
+ self.assertIn(resp[0], self.response[self.service_name])
+ for rsp in resp:
+ self.assertNotIn(rsp['id'], self.conf_values.values())
+ self.assertNotIn(rsp['name'], self.conf_values.values())
+
+
+class TestDomainService(BaseCmdServiceTests):
+
+ service_class = 'DomainService'
+ service_name = 'domains'
+ response = {
+ "domains": [
+ {
+ "description": "Destroy all humans",
+ "enabled": True,
+ "id": "5a75994a3",
+ "links": {
+ "self": "http://example.com/identity/v3/domains/5a75994a3"
+ },
+ "name": "Sky_net"
+ },
+ {
+ "description": "Owns users and tenants on Identity API",
+ "enabled": False,
+ "id": "default",
+ "links": {
+ "self": "http://example.com/identity/v3/domains/default"
+ },
+ "name": "Default"
+ }
+ ]
+ }
+
+ mock_update = ("tempest.lib.services.identity.v3."
+ "domains_client.DomainsClient.update_domain")
+
+ def test_delete_fail(self):
+ delete_mock = [(self.get_method, self.response, 200),
+ (self.delete_method, 'error', None),
+ (self.log_method, 'exception', None),
+ (self.mock_update, 'update', None)]
+ self._test_delete(delete_mock, fail=True)
+
+ def test_delete_pass(self):
+ delete_mock = [(self.get_method, self.response, 200),
+ (self.delete_method, None, 204),
+ (self.log_method, 'exception', None),
+ (self.mock_update, 'update', None)]
+ self._test_delete(delete_mock)
+
+ def test_dry_run(self):
+ dry_mock = [(self.get_method, self.response, 200),
+ (self.delete_method, "delete", None)]
+ self._test_dry_run_true(dry_mock)
+
+ def test_save_state(self):
+ self._test_saved_state_true([(self.get_method, self.response, 200)])
+
+
+class TestProjectsService(BaseCmdServiceTests):
+
+ service_class = 'ProjectService'
+ service_name = 'projects'
+ response = {
+ "projects": [
+ {
+ "is_domain": False,
+ "description": None,
+ "domain_id": "default",
+ "enabled": True,
+ "id": "f38ohgp93jj032",
+ "links": {
+ "self": "http://example.com/identity/v3/projects"
+ "/f38ohgp93jj032"
+ },
+ "name": "manhattan",
+ "parent_id": None
+ },
+ {
+ "is_domain": False,
+ "description": None,
+ "domain_id": "default",
+ "enabled": True,
+ "id": "098f89d3292ri4jf4",
+ "links": {
+ "self": "http://example.com/identity/v3/projects"
+ "/098f89d3292ri4jf4"
+ },
+ "name": "Apollo",
+ "parent_id": None
+ }
+ ]
+ }
+
+ def test_delete_fail(self):
+ delete_mock = [(self.get_method, self.response, 200),
+ (self.delete_method, 'error', None),
+ (self.log_method, 'exception', None)]
+ self._test_delete(delete_mock, fail=True)
+
+ def test_delete_pass(self):
+ delete_mock = [(self.get_method, self.response, 200),
+ (self.delete_method, None, 204),
+ (self.log_method, 'exception', None)]
+ self._test_delete(delete_mock)
+
+ def test_dry_run(self):
+ dry_mock = [(self.get_method, self.response, 200),
+ (self.delete_method, "delete", None)]
+ self._test_dry_run_true(dry_mock)
+
+ def test_save_state(self):
+ self._test_saved_state_true([(self.get_method, self.response, 200)])
+
+ def test_preserve_list(self):
+ self.response['projects'].append(
+ {
+ "is_domain": False,
+ "description": None,
+ "domain_id": "default",
+ "enabled": True,
+ "id": "r343q98h09f3092",
+ "links": {
+ "self": "http://example.com/identity/v3/projects"
+ "/r343q98h09f3092"
+ },
+ "name": cleanup_service.CONF_PROJECTS[0],
+ "parent_id": None
+ })
+ self._test_is_preserve_true([(self.get_method, self.response, 200)])
+
+
+class TestImagesService(BaseCmdServiceTests):
+
+ service_class = 'ImageService'
+ service_name = 'images'
+ response = {
+ "images": [
+ {
+ "status": "ACTIVE",
+ "name": "stratus-0.3.2-x86_64-disk",
+ "id": "34yhwr-4t3q",
+ "updated": "2014-11-03T16:40:10Z",
+ "links": [{
+ "href": "http://openstack.ex.com/v2/openstack/images/"
+ "34yhwr-4t3q",
+ "rel": "self"}],
+ "created": "2014-10-30T08:23:39Z",
+ "minDisk": 0,
+ "minRam": 0,
+ "progress": 0,
+ "metadata": {},
+ },
+ {
+ "status": "ACTIVE",
+ "name": "cirros-0.3.2-x86_64-disk",
+ "id": "1bea47ed-f6a9",
+ "updated": "2014-11-03T16:40:10Z",
+ "links": [{
+ "href": "http://openstack.ex.com/v2/openstack/images/"
+ "1bea47ed-f6a9",
+ "rel": "self"}],
+ "created": "2014-10-30T08:23:39Z",
+ "minDisk": 0,
+ "minRam": 0,
+ "progress": 0,
+ "metadata": {},
+ }
+ ]
+ }
+
+ def test_delete_fail(self):
+ delete_mock = [(self.get_method, self.response, 200),
+ (self.delete_method, 'error', None),
+ (self.log_method, 'exception', None)]
+ self._test_delete(delete_mock, fail=True)
+
+ def test_delete_pass(self):
+ delete_mock = [(self.get_method, self.response, 200),
+ (self.delete_method, None, 204),
+ (self.log_method, 'exception', None)]
+ self._test_delete(delete_mock)
+
+ def test_dry_run(self):
+ dry_mock = [(self.get_method, self.response, 200),
+ (self.delete_method, "delete", None)]
+ self._test_dry_run_true(dry_mock)
+
+ def test_save_state(self):
+ self._test_saved_state_true([(self.get_method, self.response, 200)])
+
+ def test_preserve_list(self):
+ self.response['images'].append(
+ {
+ "status": "ACTIVE",
+ "name": "cirros-0.3.2-x86_64-disk",
+ "id": cleanup_service.CONF_IMAGES[0],
+ "updated": "2014-11-03T16:40:10Z",
+ "links": [{
+ "href": "http://openstack.ex.com/v2/openstack/images/"
+ "None",
+ "rel": "self"}],
+ "created": "2014-10-30T08:23:39Z",
+ "minDisk": 0,
+ "minRam": 0,
+ "progress": 0,
+ "metadata": {},
+ })
+ self._test_is_preserve_true([(self.get_method, self.response, 200)])
+
+
+class TestFlavorService(BaseCmdServiceTests):
+
+ service_class = 'FlavorService'
+ service_name = 'flavors'
+ response = {
+ "flavors": [
+ {
+ "disk": 1,
+ "id": "42",
+ "links": [{
+ "href": "http://openstack.ex.com/v2/openstack/flavors/1",
+ "rel": "self"}, {
+ "href": "http://openstack.ex.com/openstack/flavors/1",
+ "rel": "bookmark"}],
+ "name": "m1.tiny",
+ "ram": 512,
+ "swap": 1,
+ "vcpus": 1
+ },
+ {
+ "disk": 2,
+ "id": "13",
+ "links": [{
+ "href": "http://openstack.ex.com/v2/openstack/flavors/2",
+ "rel": "self"}, {
+ "href": "http://openstack.ex.com/openstack/flavors/2",
+ "rel": "bookmark"}],
+ "name": "m1.tiny",
+ "ram": 512,
+ "swap": 1,
+ "vcpus": 1
+ }
+ ]
+ }
+
+ def test_delete_fail(self):
+ delete_mock = [(self.get_method, self.response, 200),
+ (self.delete_method, 'error', None),
+ (self.log_method, 'exception', None)]
+ self._test_delete(delete_mock, fail=True)
+
+ def test_delete_pass(self):
+ delete_mock = [(self.get_method, self.response, 200),
+ (self.delete_method, None, 202),
+ (self.log_method, 'exception', None)]
+ self._test_delete(delete_mock)
+
+ def test_dry_run(self):
+ dry_mock = [(self.get_method, self.response, 200),
+ (self.delete_method, "delete", None)]
+ self._test_dry_run_true(dry_mock)
+
+ def test_save_state(self):
+ self._test_saved_state_true([(self.get_method, self.response, 200)])
+
+ def test_preserve_list(self):
+ self.response['flavors'].append(
+ {
+ "disk": 3,
+ "id": cleanup_service.CONF_FLAVORS[0],
+ "links": [{
+ "href": "http://openstack.ex.com/v2/openstack/flavors/3",
+ "rel": "self"}, {
+ "href": "http://openstack.ex.com/openstack/flavors/3",
+ "rel": "bookmark"}],
+ "name": "m1.tiny",
+ "ram": 512,
+ "swap": 1,
+ "vcpus": 1
+ })
+ self._test_is_preserve_true([(self.get_method, self.response, 200)])
+
+
+class TestRoleService(BaseCmdServiceTests):
+
+ service_class = 'RoleService'
+ service_name = 'roles'
+ response = {
+ "roles": [
+ {
+ "domain_id": "FakeDomain",
+ "id": "3efrt74r45hn",
+ "name": "president",
+ "links": {
+ "self": "http://ex.com/identity/v3/roles/3efrt74r45hn"
+ }
+ },
+ {
+ "domain_id": 'FakeDomain',
+ "id": "39ruo5sdk040",
+ "name": "vice-p",
+ "links": {
+ "self": "http://ex.com/identity/v3/roles/39ruo5sdk040"
+ }
+ }
+ ]
+ }
+
+ def test_delete_fail(self):
+ delete_mock = [(self.get_method, self.response, 200),
+ (self.delete_method, 'error', None),
+ (self.log_method, 'exception', None)]
+ self._test_delete(delete_mock, fail=True)
+
+ def test_delete_pass(self):
+ delete_mock = [(self.get_method, self.response, 200),
+ (self.delete_method, None, 204),
+ (self.log_method, 'exception', None)]
+ self._test_delete(delete_mock)
+
+ def test_dry_run(self):
+ dry_mock = [(self.get_method, self.response, 200),
+ (self.delete_method, "delete", None)]
+ self._test_dry_run_true(dry_mock)
+
+ def test_save_state(self):
+ self._test_saved_state_true([(self.get_method, self.response, 200)])
+
+
+class TestUserService(BaseCmdServiceTests):
+
+ service_class = 'UserService'
+ service_name = 'users'
+ response = {
+ "users": [
+ {
+ "domain_id": "TempestDomain",
+ "enabled": True,
+ "id": "e812fb332456423fdv1b1320121qwe2",
+ "links": {
+ "self": "http://example.com/identity/v3/users/"
+ "e812fb332456423fdv1b1320121qwe2",
+ },
+ "name": "Thunder",
+ "password_expires_at": "3102-11-06T15:32:17.000000",
+ },
+ {
+ "domain_id": "TempestDomain",
+ "enabled": True,
+ "id": "32rwef64245tgr20121qw324bgg",
+ "links": {
+ "self": "http://example.com/identity/v3/users/"
+ "32rwef64245tgr20121qw324bgg",
+ },
+ "name": "Lightning",
+ "password_expires_at": "1893-11-06T15:32:17.000000",
+ }
+ ]
+ }
+
+ def test_delete_fail(self):
+ delete_mock = [(self.get_method, self.response, 200),
+ (self.delete_method, 'error', None),
+ (self.log_method, 'exception', None)]
+ self._test_delete(delete_mock, fail=True)
+
+ def test_delete_pass(self):
+ delete_mock = [(self.get_method, self.response, 200),
+ (self.delete_method, None, 204),
+ (self.log_method, 'exception', None)]
+ self._test_delete(delete_mock)
+
+ def test_dry_run(self):
+ dry_mock = [(self.get_method, self.response, 200),
+ (self.delete_method, "delete", None)]
+ self._test_dry_run_true(dry_mock)
+
+ def test_save_state(self):
+ self._test_saved_state_true([(self.get_method, self.response, 200)])
+
+ def test_preserve_list(self):
+ self.response['users'].append(
+ {
+ "domain_id": "TempestDomain",
+ "enabled": True,
+ "id": "23ads5tg3rtrhe30121qwhyth",
+ "links": {
+ "self": "http://example.com/identity/v3/users/"
+ "23ads5tg3rtrhe30121qwhyth",
+ },
+ "name": cleanup_service.CONF_USERS[0],
+ "password_expires_at": "1893-11-06T15:32:17.000000",
+ })
+ self._test_is_preserve_true([(self.get_method, self.response, 200)])
diff --git a/tempest/tests/cmd/test_run.py b/tempest/tests/cmd/test_run.py
index f55df30..9a6be4e 100644
--- a/tempest/tests/cmd/test_run.py
+++ b/tempest/tests/cmd/test_run.py
@@ -24,11 +24,14 @@
import six
from tempest.cmd import run
+from tempest import config
from tempest.tests import base
DEVNULL = open(os.devnull, 'wb')
atexit.register(DEVNULL.close)
+CONF = config.CONF
+
class TestTempestRun(base.TestCase):
@@ -140,6 +143,35 @@
'--regex', 'passing'], 0)
+class TestConfigPathCheck(base.TestCase):
+ def setUp(self):
+ super(TestConfigPathCheck, self).setUp()
+ self.run_cmd = run.TempestRun(None, None)
+
+ def test_tempest_run_set_config_path(self):
+ # Note: (mbindlish) This test is created for the bug id: 1783751
+ # Checking TEMPEST_CONFIG_DIR and TEMPEST_CONFIG is actually
+ # getting set in os environment when some data has passed to
+ # set the environment.
+
+ self.run_cmd._set_env("/fakedir/fakefile")
+ self.assertEqual("/fakedir/fakefile", CONF._path)
+ self.assertIn('TEMPEST_CONFIG_DIR', os.environ)
+ self.assertEqual("/fakedir/fakefile",
+ os.path.join(os.environ['TEMPEST_CONFIG_DIR'],
+ os.environ['TEMPEST_CONFIG']))
+
+ def test_tempest_run_set_config_no_path(self):
+ # Note: (mbindlish) This test is created for the bug id: 1783751
+ # Checking TEMPEST_CONFIG_DIR and TEMPEST_CONFIG should have no value
+ # in os environment when no data has passed to set the environment.
+
+ self.run_cmd._set_env("")
+ self.assertFalse(CONF._path)
+ self.assertNotIn('TEMPEST_CONFIG_DIR', os.environ)
+ self.assertNotIn('TEMPEST_CONFIG', os.environ)
+
+
class TestTakeAction(base.TestCase):
def test_workspace_not_registered(self):
class Exception_(Exception):
@@ -180,7 +212,6 @@
tempest_run = run.TempestRun(app=mock.Mock(), app_args=mock.Mock())
parsed_args = mock.Mock()
- parsed_args.config_file = []
parsed_args.workspace = None
parsed_args.state = None
diff --git a/tempest/tests/cmd/test_verify_tempest_config.py b/tempest/tests/cmd/test_verify_tempest_config.py
index c260343..8dbba38 100644
--- a/tempest/tests/cmd/test_verify_tempest_config.py
+++ b/tempest/tests/cmd/test_verify_tempest_config.py
@@ -12,11 +12,14 @@
# License for the specific language governing permissions and limitations
# under the License.
+import os
+
import fixtures
import mock
from oslo_serialization import jsonutils as json
from tempest import clients
+from tempest.cmd import init
from tempest.cmd import verify_tempest_config
from tempest.common import credentials_factory
from tempest import config
@@ -234,8 +237,8 @@
with mock.patch.object(verify_tempest_config,
'print_and_or_update') as print_mock:
verify_tempest_config.verify_glance_api_versions(fake_os, True)
- print_mock.assert_called_once_with('api_v2', 'image-feature-enabled',
- False, True)
+ print_mock.assert_called_with('api_v2', 'image-feature-enabled',
+ False, True)
def test_verify_glance_version_no_v2_with_v1_0(self):
# This test verifies that wrong config api_v2 = True is detected
@@ -250,8 +253,8 @@
with mock.patch.object(verify_tempest_config,
'print_and_or_update') as print_mock:
verify_tempest_config.verify_glance_api_versions(fake_os, True)
- print_mock.assert_called_once_with('api_v2', 'image-feature-enabled',
- False, True)
+ print_mock.assert_called_with('api_v2', 'image-feature-enabled',
+ False, True)
def test_verify_glance_version_no_v1(self):
# This test verifies that wrong config api_v1 = True is detected
@@ -271,8 +274,7 @@
with mock.patch.object(verify_tempest_config,
'print_and_or_update') as print_mock:
verify_tempest_config.verify_glance_api_versions(fake_os, True)
- print_mock.assert_called_once_with('api_v1', 'image-feature-enabled',
- False, True)
+ print_mock.assert_not_called()
def test_verify_glance_version_no_version(self):
# This test verifies that wrong config api_v1 = True is detected
@@ -566,3 +568,64 @@
extensions_client = verify_tempest_config.get_extension_client(
os, service)
self.assertIsInstance(extensions_client, rest_client.RestClient)
+
+ def test_get_extension_client_sysexit(self):
+ creds = credentials_factory.get_credentials(
+ fill_in=False, username='fake_user', project_name='fake_project',
+ password='fake_password')
+ os = clients.Manager(creds)
+ self.assertRaises(SystemExit,
+ verify_tempest_config.get_extension_client,
+ os, 'fakeservice')
+
+ def test_get_config_file(self):
+ conf_dir = os.path.join(os.getcwd(), 'etc/')
+ conf_file = "tempest.conf.sample"
+ local_sample_conf_file = os.path.join(conf_dir, conf_file)
+
+ def fake_environ_get(key, default=None):
+ if key == 'TEMPEST_CONFIG_DIR':
+ return conf_dir
+ elif key == 'TEMPEST_CONFIG':
+ return 'tempest.conf.sample'
+ return default
+
+ with mock.patch('os.environ.get', side_effect=fake_environ_get,
+ autospec=True):
+ init_cmd = init.TempestInit(None, None)
+ init_cmd.generate_sample_config(os.path.join(conf_dir, os.pardir))
+ self.assertTrue(os.path.isfile(local_sample_conf_file),
+ local_sample_conf_file)
+
+ file_pointer = verify_tempest_config._get_config_file()
+ self.assertEqual(local_sample_conf_file, file_pointer.name)
+
+ with open(local_sample_conf_file, 'r+') as f:
+ local_sample_conf_contents = f.read()
+ self.assertEqual(local_sample_conf_contents, file_pointer.read())
+
+ if file_pointer:
+ file_pointer.close()
+
+ def test_print_and_or_update_true(self):
+ with mock.patch.object(
+ verify_tempest_config, 'change_option') as test_mock:
+ verify_tempest_config.print_and_or_update(
+ 'fakeservice', 'fake-service-available', False, True)
+ test_mock.assert_called_once_with(
+ 'fakeservice', 'fake-service-available', False)
+
+ def test_print_and_or_update_false(self):
+ with mock.patch.object(
+ verify_tempest_config, 'change_option') as test_mock:
+ verify_tempest_config.print_and_or_update(
+ 'fakeservice', 'fake-service-available', False, False)
+ test_mock.assert_not_called()
+
+ def test_contains_version_positive_data(self):
+ self.assertTrue(
+ verify_tempest_config.contains_version('v1.', ['v1.0', 'v2.0']))
+
+ def test_contains_version_negative_data(self):
+ self.assertFalse(
+ verify_tempest_config.contains_version('v5.', ['v1.0', 'v2.0']))
diff --git a/tempest/tests/fake_config.py b/tempest/tests/fake_config.py
index be54130..25e99d5 100644
--- a/tempest/tests/fake_config.py
+++ b/tempest/tests/fake_config.py
@@ -32,6 +32,7 @@
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('image_ref', 'fake_image_id', group='compute')
self.conf.set_default('disable_ssl_certificate_validation', True,
group='identity')
self.conf.set_default('uri', 'http://fake_uri.com/auth',
diff --git a/tempest/tests/lib/services/network/test_agents_client.py b/tempest/tests/lib/services/network/test_agents_client.py
new file mode 100644
index 0000000..aabc6ce
--- /dev/null
+++ b/tempest/tests/lib/services/network/test_agents_client.py
@@ -0,0 +1,37 @@
+# Copyright 2018 AT&T 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.lib.services.network import agents_client
+from tempest.tests.lib import fake_auth_provider
+from tempest.tests.lib.services import base
+
+
+class TestAgentsClient(base.BaseServiceTest):
+
+ FAKE_AGENT_ID = "d32019d3-bc6e-4319-9c1d-6123f4135a88"
+
+ def setUp(self):
+ super(TestAgentsClient, self).setUp()
+ fake_auth = fake_auth_provider.FakeAuthProvider()
+ self.agents_client = agents_client.AgentsClient(
+ fake_auth, "network", "regionOne")
+
+ def test_delete_agent(self):
+ self.check_service_client_function(
+ self.agents_client.delete_agent,
+ "tempest.lib.common.rest_client.RestClient.delete",
+ {},
+ status=204,
+ agent_id=self.FAKE_AGENT_ID)
diff --git a/tempest/tests/lib/services/network/test_versions_client.py b/tempest/tests/lib/services/network/test_versions_client.py
index 026dc6d..188fc31 100644
--- a/tempest/tests/lib/services/network/test_versions_client.py
+++ b/tempest/tests/lib/services/network/test_versions_client.py
@@ -12,63 +12,92 @@
# License for the specific language governing permissions and limitations
# under the License.
-import copy
-
from tempest.lib.services.network import versions_client
from tempest.tests.lib import fake_auth_provider
from tempest.tests.lib.services import base
class TestNetworkVersionsClient(base.BaseServiceTest):
-
- FAKE_INIT_VERSION = {
- "version": {
- "id": "v2.0",
- "links": [
- {
- "href": "http://openstack.example.com/v2.0/",
- "rel": "self"
- },
- {
- "href": "http://docs.openstack.org/",
- "rel": "describedby",
- "type": "text/html"
- }
- ],
- "status": "CURRENT"
- }
- }
+ VERSION = "v2.0"
FAKE_VERSIONS_INFO = {
- "versions": [FAKE_INIT_VERSION["version"]]
- }
-
- FAKE_VERSION_INFO = copy.deepcopy(FAKE_INIT_VERSION)
-
- FAKE_VERSION_INFO["version"]["media-types"] = [
- {
- "base": "application/json",
- "type": "application/vnd.openstack.network+json;version=2.0"
- }
+ "versions": [
+ {
+ "id": "v2.0",
+ "links": [
+ {
+ "href": "http://openstack.example.com/%s/" % VERSION,
+ "rel": "self"
+ }
+ ],
+ "status": "CURRENT"
+ }
]
+ }
+
+ FAKE_VERSION_DETAILS = {
+ "resources": [
+ {
+ "collection": "subnets",
+ "links": [
+ {
+ "href": "http://openstack.example.com:9696/"
+ "%s/subnets" % VERSION,
+ "rel": "self"
+ }
+ ],
+ "name": "subnet"
+ },
+ {
+ "collection": "networks",
+ "links": [
+ {
+ "href": "http://openstack.example.com:9696/"
+ "%s/networks" % VERSION,
+ "rel": "self"
+ }
+ ],
+ "name": "network"
+ },
+ {
+ "collection": "ports",
+ "links": [
+ {
+ "href": "http://openstack.example.com:9696/"
+ "%s/ports" % VERSION,
+ "rel": "self"
+ }
+ ],
+ "name": "port"
+ }
+ ]
+ }
def setUp(self):
super(TestNetworkVersionsClient, self).setUp()
fake_auth = fake_auth_provider.FakeAuthProvider()
- self.versions_client = (
- versions_client.NetworkVersionsClient
- (fake_auth, 'compute', 'regionOne'))
+ self.versions_client = versions_client.NetworkVersionsClient(
+ fake_auth, 'compute', 'regionOne')
- def _test_versions_client(self, bytes_body=False):
+ def _test_versions_client(self, func, body, bytes_body=False, **kwargs):
self.check_service_client_function(
- self.versions_client.list_versions,
- 'tempest.lib.common.rest_client.RestClient.raw_request',
- self.FAKE_VERSIONS_INFO,
- bytes_body,
- 200)
+ func, 'tempest.lib.common.rest_client.RestClient.raw_request',
+ body, bytes_body, 200, **kwargs)
def test_list_versions_client_with_str_body(self):
- self._test_versions_client()
+ self._test_versions_client(self.versions_client.list_versions,
+ self.FAKE_VERSIONS_INFO)
def test_list_versions_client_with_bytes_body(self):
- self._test_versions_client(bytes_body=True)
+ self._test_versions_client(self.versions_client.list_versions,
+ self.FAKE_VERSIONS_INFO, bytes_body=True)
+
+ def test_show_version_client_with_str_body(self):
+ self._test_versions_client(self.versions_client.show_version,
+ self.FAKE_VERSION_DETAILS,
+ version=self.VERSION)
+
+ def test_show_version_client_with_bytes_body(self):
+ self._test_versions_client(self.versions_client.show_version,
+ self.FAKE_VERSION_DETAILS, bytes_body=True,
+ version=self.VERSION)
diff --git a/tempest/tests/lib/services/volume/v3/test_hosts_client.py b/tempest/tests/lib/services/volume/v3/test_hosts_client.py
index 67ae4fd..09bc0b1 100644
--- a/tempest/tests/lib/services/volume/v3/test_hosts_client.py
+++ b/tempest/tests/lib/services/volume/v3/test_hosts_client.py
@@ -18,7 +18,7 @@
from tempest.tests.lib.services import base
-class TestQuotasClient(base.BaseServiceTest):
+class TestHostsClient(base.BaseServiceTest):
FAKE_LIST_HOSTS = {
"hosts": [
{
@@ -66,7 +66,7 @@
}
def setUp(self):
- super(TestQuotasClient, self).setUp()
+ super(TestHostsClient, self).setUp()
fake_auth = fake_auth_provider.FakeAuthProvider()
self.client = hosts_client.HostsClient(fake_auth,
'volume',
diff --git a/tox.ini b/tox.ini
index 970f415..8208066 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
[tox]
-envlist = pep8,py35,py27,pip-check-reqs
+envlist = pep8,py36,py27,pip-check-reqs
minversion = 2.3.1
skipsdist = True
@@ -61,6 +61,26 @@
tempest run --regex {posargs}
[testenv:all-plugin]
+# DEPRECATED
+# NOTE(andreaf) The all-plugin tox env uses sitepackages
+# so that plugins installed outsite of Tempest virtual environment
+# can be discovered. After the implementation during the Queens
+# release cycle of the goal of moving Tempest plugins in dedicated
+# git repos, this environment should not be used anymore. "all"
+# should be used instead with the appropriate regex filtering.
+sitepackages = True
+# 'all' includes slow tests
+setenv =
+ {[tempestenv]setenv}
+ OS_TEST_TIMEOUT={env:OS_TEST_TIMEOUT:1200}
+deps = {[tempestenv]deps}
+commands =
+ echo "WARNING: The all-plugin env is deprecated and will be removed"
+ echo "WARNING Please use the 'all' environment for Tempest plugins."
+ find . -type f -name "*.pyc" -delete
+ tempest run --regex {posargs}
+
+[testenv:all-site-packages]
sitepackages = True
# 'all' includes slow tests
setenv =