summaryrefslogtreecommitdiff
path: root/nova/tests/unit/test_cinder.py
Commit message (Collapse)AuthorAgeFilesLines
* Use unittest.mock instead of third party mockStephen Finucane2022-08-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now that we no longer support py27, we can use the standard library unittest.mock module instead of the third party mock lib. Most of this is autogenerated, as described below, but there is one manual change necessary: nova/tests/functional/regressions/test_bug_1781286.py We need to avoid using 'fixtures.MockPatch' since fixtures is using 'mock' (the library) under the hood and a call to 'mock.patch.stop' found in that test will now "stop" mocks from the wrong library. We have discussed making this configurable but the option proposed isn't that pretty [1] so this is better. The remainder was auto-generated with the following (hacky) script, with one or two manual tweaks after the fact: import glob for path in glob.glob('nova/tests/**/*.py', recursive=True): with open(path) as fh: lines = fh.readlines() if 'import mock\n' not in lines: continue import_group_found = False create_first_party_group = False for num, line in enumerate(lines): line = line.strip() if line.startswith('import ') or line.startswith('from '): tokens = line.split() for lib in ( 'ddt', 'six', 'webob', 'fixtures', 'testtools' 'neutron', 'cinder', 'ironic', 'keystone', 'oslo', ): if lib in tokens[1]: create_first_party_group = True break if create_first_party_group: break import_group_found = True if not import_group_found: continue if line.startswith('import ') or line.startswith('from '): tokens = line.split() if tokens[1] > 'unittest': break elif tokens[1] == 'unittest' and ( len(tokens) == 2 or tokens[4] > 'mock' ): break elif not line: break if create_first_party_group: lines.insert(num, 'from unittest import mock\n\n') else: lines.insert(num, 'from unittest import mock\n') del lines[lines.index('import mock\n')] with open(path, 'w+') as fh: fh.writelines(lines) Note that we cannot remove mock from our requirements files yet due to importing pypowervm unit test code in nova unit tests. This library still uses the mock lib, and since we are importing test code and that lib (correctly) only declares mock in its test-requirements.txt, mock would not otherwise be installed and would cause errors while loading nova unit test code. [1] https://github.com/testing-cabal/fixtures/pull/49 Change-Id: Id5b04cf2f6ca24af8e366d23f15cf0e5cac8e1cc Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
* Make [cinder]/catalog_info no longer require a service_nameMatt Riedemann2018-11-281-0/+19
| | | | | | | | | | | | | | | | | The service_name part of the cinder catalog_info option is not necessary to lookup the endpoint from the service catalog when we have the endpoint type (volumev3) and the interface (publicURL). This changes the option default to not include the service name and no longer makes a service name required. If one is provided, then it will be sent along to KSA/cinderclient, otherwise it is omitted. As this is a change in behavior of the config option, a release note is added. Change-Id: I89395fafffd60981fba17a7b09f7015e1f827b62 Closes-Bug: #1803627
* Fix bug case by none token contextlixipeng2018-01-241-2/+2
| | | | | | | | | | | | | | | | | | | | | When set reclaim_instance_interval > 0, and then delete an instance which booted from volume with `delete_on_termination` set as true. After reclaim_instance_interval time pass, all volumes boot instance will with state: attached and in-use, but attached instances was deleted. This bug case as admin context from `nova.compute.manager._reclaim_queued_deletes` did not have any token info, then call cinder api would be failed. So add user/project CONF with admin role at cinder group, and when determine context is_admin and without token, do authenticaion with user/project info to call cinder api. Change-Id: I3c35bba43fee81baebe8261f546c1424ce3a3383 Closes-Bug: #1733736 Closes-Bug: #1734025 Partial-Bug: #1736773
* Drop support for the Cinder v2 APIMatt Riedemann2017-09-161-13/+32
| | | | | | | | | | | We deprecated support for the Cinder v2 API in Pike: Ice67d29f31aa5bd5c84fad4e828435d8552a9629 Enough time has passed that we can drop support for the v2 API and rely solely on the v3 API. Change-Id: Ibbc30b071f638114a4f0967a90c43b593bf47e1f
* Fix ksa mocking in test_cinderclient_unsupported_v1Matt Riedemann2017-01-051-7/+6
| | | | | | | | | | | | | This test was previously mocking the keystoneauth1 loading code globally which was getting randomly trampled by other tests that were mocking the same thing. This changes the scope on the mock so it should be isolated from other tests mocking out the same thing. Change-Id: Id6c35c583edf0938b5d0178ab2cfb54277f0225f Closes-Bug: #1654393
* Remove support for the Cinder v1 APIMatt Riedemann2016-12-121-59/+20
| | | | | | | | The Cinder v1 API is deprecated and Nova has been emitting a warning when using it since Juno, so it's time to drop the support as we start looking to support the new Cinder v3 API. Change-Id: I8eb9ca88be81cc04c4feb3bafda2d8aa79a12dc4
* config options: centralize cinder optionsJiajun Liu2016-03-151-3/+6
| | | | | | | | This change moves the cinder config options to a central location "nova/conf/cinder.py". Change-Id: I144abf6c92f499fa605307631121cf96e24fbd62 Partially-Implements: blueprint centralize-config-options-newton
* Pass attachment_id to Cinder when detach a volumeKrisztian Gacsal2016-01-201-4/+64
| | | | | | | | | | | | | | | | | | | Cinder needs the attachment_id to properly identify which attachment of a volume to detach. This patch adapts the Cinder driver to pass the required information. The attachment_id is necessary for volumes that enable multiple attachments in order to terminate the connection properly. The attachment_id is retrieved in the API layer where available and sent through RPC, the RPC version is bumped to 4.7. Also the translation functions are modified to retrieve all necessary information for the volume info coming from Cinder including the multiple attachments. The Nova API returns the volume info in the same format as earlier. Co-Authored-By: Ildiko Vancsa <ildiko.vancsa@ericsson.com> Partially-implements: blueprint multi-attach-volume Change-Id: I3cdc49924acbdd21d1e6678a3bb4cf7de7f1db1a
* Fix order of arguments in assertEqualPranaliDeore2015-09-031-2/+2
| | | | | | | | | | Some tests used incorrect order assertEqual(observed, expected). The correct order expected by testtools is assertEqual(expected, observed). Partial-Bug: #1259292 Change-Id: I30e7c4346844ec0eba50c50ca327ca1966600e7d
* Use session in cinderclientJamie Lennox2014-11-181-334/+122
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use the common session loading parameters and the session object for talking to cinder. There are some related changes in this patch. Firstly auth_token middleware now provides an authentication plugin that can be used along with the session object to make requests under the user's authentication. This will largely replace the information required on the context object. This authentication plugin is not serializable though and so it cannot be transferred over RPC so we introduce a simple authentication plugin that reconstructs the required information from the context. When talking to cinder we now create a global session object (think of this like keeping open a connection pool object) and use the authentication plugin to send requests to cinder. I also condense the cinder tests as they are largely copied and pasted between v1 and v2 and this solves fixing them in two places. DocImpact: Renames cinder's timeout, insecure and CA certificates parameters to the parameters used by the common session object. Adds options for using client certificates with connection. Change-Id: I7afe604503b8597c16be61d2a66a10b94269a219
* move all tests to nova/tests/unitSean Dague2014-11-121-0/+405
As part of the split of functional and unit tests we need to isolate the unit tests into a separate directory for having multiple test targets in a sane way. Part of bp:functional-tests-for-nova Change-Id: Id42ba373c1bda6a312b673ab2b489ca56da8c628