This patch is to fix an exception name when deleted volume is busy
in delete_volume().
Although exception ``VolumeIsBusy`` should be issued in that case,
``VolumeDriverException`` is issued. It should be fixed.
Closes-Bug: #2024418
Change-Id: I5405790c7cd4ca513ceea70380be723a54c3fe3c
This patch adds a new unit test to validate the successful execution of
the _run_ssh method in the CiscoFCSanLookupService class. The test ensures
that the expected command output is returned and that the mock SSH execute
method is called with the correct parameter
Change-Id: Id8cae36f06f82dcf28a1fb7a2058f01f1a1bd1a2
Our current code does not properly clean up the fake RPC exchange between
tests.
This means that if a test invokes code in cinder that makes an RPC
request and it is not consumed by that test, then another test may get
some code invoked.
One test that makes such an RPC request that is not consumed is our test
cinder.tests.unit.policies.test_snapshots.SnapshotsPolicyTest.test_delete_policy_6_project_reader
This means that if the next tests starts the volume manager service and
asserts that cinder.volume.volume_utils.notify_about_snapshot_usage is
not being called, it will fail, as the notification would have been
called when processing the previous test deletion request.
This was found when working on Change-Id patch
I60527edb029265ed4b2a48d2c358265cea1a9b2c and analyzing a spurious
failure and finding out that running these 2 tests one after the other
was the problem:
cinder.tests.unit.policies.test_snapshots.SnapshotsPolicyTest.test_delete_policy_6_project_reader
cinder.tests.unit.test_volume_transfer.VolumeTransferTestCase.test_transfer_accept_with_snapshots_1_True
The second test is added in that Change-Id that follows this one in the
patch dependency chain.
This patch fixes this issue by forcefully clearing the class dictionary
in the fake exchange.
We do it forcefully because the oslo messaging library doesn't have any
other mechanism to do so for now, but once patch
https://review.opendev.org/c/openstack/oslo.messaging/+/901018 is merged
we can remove this code.
Change-Id: I52ee4b345b0a4b262e330a9a89552cd216eafdbe
This should have been done when we switched from SQLAlchemy-Migrate to
Alembic way back. Oops /o\ Do it now.
Change-Id: I5899a5020c81e62a67f37e95facfc87cd312561c
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
... because these cause the following warning.
FutureWarning: b"'mock_volume_type_id'" is an invalid UUID. Using
UUIDFields with invalid UUIDs is no longer supported, and will be
removed in a future release. Please update your code to input valid
UUIDs or accept ValueErrors for invalid UUIDs.
Change-Id: Ief8962b3120148bde64dca02713c1723548bab21
This necessitates using a raw connection [1] to enable foreign keys, due
SQLAlchemy 2.0 wrapping mostly everything in transactions which in-turn
limits our ability to do this easily on a non-global basis.
[1] https://docs.python.org/3/library/sqlite3.html#sqlite3.Connection.execute
Change-Id: Id6d4219ea2be797e4da6c43b3a950983f3fc951f
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This allows us to use 'alembic' (the CLI) again and is functionally
identical.
Change-Id: I7af445fce9b4e84ebbd24d546cab13461aa0b0e5
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
SQLAlchemy 2.0 require executable strings be wrapped in
'sqlalchemy.sql.expression.text()'. 'op.execute' does automatic coercion
[1], which keeps things a little simpler and arguably more idiomatic.
[1] https://alembic.sqlalchemy.org/en/latest/ops.html#alembic.operations.Operations.execute
Change-Id: Ic454f00ddc3f4e0e1d2b5222808dab22bc8391d7
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This reverts commit 5edc77a18c.
Reason for revert: Bug: #2019190
This revealed a bug in Cinder optimized migration code that can lead to data loss with RBD and potentially other drivers, by using the optimized migration path in more cases. Once the issues there are fixed, this should be re-introduced.
Change-Id: I893105cbd270300be9ec48b3127e66022f739314
Adding test cases for recently merged replication-enabled consistency groups feature.
Fixed variable name to correctly unpack it in the create consistency group function.
Related: I64bc4aa48d1d372b8687a22846aeece729e02598
Change-Id: I3964cac87a933a256064c332c68b312705ca7e0c
Unit tests fails when running on systems without nvmet support.
This is caused by the nvmet library trying to do some safe reads on
sysfs. Writtings won't happen though.
This patch ensures that we always use a mocked nvmet library instead of
trying to use the real library when available like we are doing now.
Example of failure:
cinder.tests.unit.targets.test_nvmet_driver.TestNVMETDriver.test__namespace_dict_shared
---------------------------------------------------------------------------------------
Captured traceback:
~~~~~~~~~~~~~~~~~~~
Traceback (most recent call last):
File "/home/zuul/src/code.engineering.redhat.com/cinder/cinder/tests/unit/targets/test_nvmet_driver.py", line 34, in setUp
self.target = nvmet.NVMET(root_helper=utils.get_root_helper(),
File "/home/zuul/src/code.engineering.redhat.com/cinder/cinder/volume/targets/nvmet.py", line 40, in __init__
self._nvmet_root = nvmet.Root()
File "/usr/lib/python3.9/site-packages/nvmet/nvme.py", line 241, in __init__
raise CFSError("%s does not exist. Giving up." %
nvmet.nvme.CFSError: /sys/kernel/config/nvmet does not exist. Giving up.
Change-Id: I1845ce07886d7cd6256be55c71e9da3fd9122fe4
We were previously calling 'connect()' on the 'connectable' object in
'run_migrations_online', regardless of whether it was an 'Engine' or
'Connection' object. This worked because, as noted in an inline comment,
"when connectable is already a Connection object, calling 'connect()'
gives us a *branched connection*." This is no longer the case. From the
SQLAlchemy docs [1]:
The Connection object does not support "branching", which was a
pattern by which a sub "connection" would be used that refers to this
connection as a parent.
Update our code to reflect this change, using the newly updated example
from the SQLAlchemy cookbook doc [2] as inspiration.
[1] https://docs.sqlalchemy.org/en/14/core/future.html#sqlalchemy.future.Connection
[2] https://alembic.sqlalchemy.org/en/latest/cookbook.html#connection-sharing
Change-Id: I658cdec1c6edc3e369e23b21e4b5f89cdc2805b0
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>