Add a hacking rule for non-existent mock assertion methods and
attributes.
[N364] Non existent mock assertion method or attribute (<name>) is used.
Check a typo or whether the assertion method should begin with
'assert_'.
Change-Id: Ic6860e373120086a1a2ae9953f09a7bbaa032a7b
The description of N363 hacking rule is missing
in HACKING.rst.
Add the description.
Change-Id: I036a48612fcd256df4ccbd2ebba814bf3ed7a1c2
Closes-Bug: #1840862
When evacuating a server in a multi-cell environment
we should be restricting the scheduling request during
evacuate to the cell in which the instance already exists
since we don't support cross-cell evacuate.
This adds a functional test to recreate the bug to show
that the scheduler is not restricted to the instance's
current cell when evacuating.
Change-Id: I56e20c84f25cc4961dc8d637c222b6f213c4d5f9
Related-Bug: #1823370
In 2.75, we missed to add the config_drive field in api-ref for
update server response
- I9d257a003d315b84b937dcef91f3cb41f3e24b53.
This commit updates the api-ref.
Change-Id: I46ab0b8650bf50a5384bb56027cdf0dc2a9bb2fe
Partial-Implements: blueprint api-consistency-cleanup
Change I9d257a003d315b84b937dcef91f3cb41f3e24b53 and the 2.75
microversion returns the config_drive parameter in the rebuild
response and it's in the 2.75 rebuild response sample but was
missing from the response parameters table.
Change-Id: I89eca8638bc0d64b7f320f4ec5c49375bfebdb56
By default, mock.patch's autospec argument is None, meaning that
there's no signature checking for the patched methods and functions.
oslotest.mock_fixture.patch_mock_module fixes a few issues within
mock.patch functions, as well as setting autospec=True by default,
unless otherwise specified or new_callable, create, spec arguments
are passed in.
Co-Authored-By: Claudiu Belu <cbelu@cloudbasesolutions.com>
Change-Id: I4484e63c97bd1cdde3d88855eabe7545784f365e
Closes-Bug: #1735588
The 'has_calls' method does not exist in assertion methods of mock.
Replace the 'has_calls' method with an 'assert_has_calls' method or
an 'assert_called_once_with' method.
Add an 'assertEqual' check before an 'assert_has_calls' method.
Change-Id: I4b606fce473d064b9bb00213696c075cea020aaf
Closes-Bug: #1840200
Since If32bca070185937ef83f689b7163d965a89ec10a some of the service
update api tests are slow because setting a compute enabled or
disabled makes an RPC call to the given compute service. These tests
does not have the proper RPC setup so that call times out. The compute
api only logs an error for the timeout so the tests wasn't failing.
This patch stubs the RPC call as that is not necessary for the
api testing and therefore speeds up the tests.
Change-Id: If0960de896a67fd6bfca230b8915a45cb7af99b7
Rules are fetched, edited, and set. Keep the edit logic in nova/network,
but move the bits requiring elevated permissions to privsep.
Change-Id: I1f8382c450b95d261f68ec8bae2a2077f9361fe0
While addressing a nit from change
I8e5a122cc547222249973cf595d90c2d8d5658d4, I realized pretty much every
test using the nova.tests.functional.libvirt.base.ServersTestBase' base
class was now mocking the same things. This results in a lot of noise
and distracts from what the tests are trying to do. Centralize the
common mocks in the base class and clean up said noise.
Change-Id: I5895865751e8e1fb08b3515bc9f8119cfcb9f35e
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
There is no method called_once_with() in Mock object.
Use assert_called_once_with() or assert_has_calls() instead.
Change-Id: I9f73fcbe7c3dfd64e75ac8224c13934b03443cd5
Closes-Bug: #1544522
test_driver.LibvirtConnTestCase.test_cpu_info() and
test_driver.LibvirtConnTestCase.test_get_instance_capabilities() were
incorrectly adding LibvirtConfigGuest fixture objects to the guests
attribute of LibvirtConfigCaps, rather than LibvirtConfigCapsGuest
objects which is what the parse_dom() method of LibvirtConfigCaps
does. LibvirtConfigCaps is intended to capture all useful information
returned by libvirt's getCapabilities API call, and
LibvirtConfigCapsGuest is intended to capture a small subset of that.
In contrast, LibvirtConfigGuest is intended for holding the entire
configuration of a libvirt guest domain.
So fix this to instead add LibvirtConfigCapsGuest fixtures.
Note that despite this bug, the tests previously passed through
duck-typing because LibvirtConfigCaps does not define __slots__ or any
other mechanism for limiting how attributes can be set on instances.
This is required by another commit in the SEV series in the near
future which will alter the fields within LibvirtConfigCapsGuest.
blueprint: amd-sev-libvirt-support
Change-Id: Ic4cbbaf81938fc88980e44c4a17fe388f9c2b92b
matchers.XMLMatches supports three options:
- allow_mixed_nodes
- skip_empty_text_nodes
- skip_values
However these are not accessible when using the matcher via
assertXmlEqual(). So extend the latter with an *options
dictionary to allow options to be passed through.
This will be used by another commit in the SEV series in the near
future which needs the allow_mixed_nodes option to be enabled to
compare XML fragments with elements in different orders.
blueprint: amd-sev-libvirt-support
Change-Id: I31c60771891c3a2eb06fbc780ba2d369465498ec
This patch adds a new external event called "power-update"
through which ironic will convey all (power_off and power_on)
power state changes (running -> shutdown or shutdown -> running
will be the only ones handled by nova and the rest will be ignored)
on a physical instance to nova. The database will be updated
accordingly to reflect the real vm_state and power_state of the
instance. This way nova will not be able to enforce
an incorrect power state on the physical instance during
the periodic "sync_power_states" task.
Implements blueprint nova-support-instance-power-update
Story: 2004969
Task: 29423
Change-Id: I2b292050cc3ce5ef625659f5a1fe56bb76072496
mock.patch's new_callable attribute is supposed to be set to a
callable object which when called will generate the new object for the
patched object to return:
https://docs.python.org/dev/library/unittest.mock.html#unittest.mock.patch
So when it is desired to return a PropertyMock object, new_callable
should be set to the class, not an instance of the class.
Alternatively if it is desired to set the return value within the
decorator, then the new attribute should be used instead of
new_callable.
So change existing tests to adhere to this principle. Previously they
passed more or less by accident, due to instances of PropertyMock
themselves being callable even though they are supposed to be used as
properties rather than methods.
Change-Id: I707169384c5732b9ad9f3941a9334f96478d4aab
This patch removes the legacy code for image checksumming
as well as configuration values that are not longer being
used.
Change-Id: I9c552e33456bb862688beaabe69f2b72bb8ebcce
As we work out the kinks in openstacksdk to smooth the road for nova's
usage thereof, and until openstacksdk can provide opaque fixtures that
it can keep up to date as its internals change, we've been needing to
stub things out incrementally.
This commit more aggressively mocks the piece of openstacksdk that
keeps changing under us. It effectively does what [1] does, but without
the get_endpoint() sanity check, which blows up in unit/functional test
because it tries to do real ksa auth.
[1] https://review.opendev.org/#/c/675135/
Change-Id: I1ef2ca51da2dc25026a2fbdcfb1ed5199aaa518b
Fix collapse of 'host_status' description in the follwoing APIs
in the compute API reference.
- PUT /servers/{server_id}
- POST /servers/{server_id}/action (rebuild)
Change-Id: I003f9a81ac6f7e0ec13a24db3fda1b7ff6612bc5
Closes-Bug: #1840094
_detect_nbd_devices uses the filter
builtin internally to filter valid devices.
In python 2, filter returns a list. In python 3,
filter returns an iterable or generator function.
This change eagerly converts the result of calling filter
to a list to preserve the python 2 behaviour under python 3.
Closes-Bug: #1840068
Change-Id: I25616c5761ea625a15d725777ae58175651558f8
This adds the code to CrossCellMigrationTask which
executes the TargetDBSetupTask sub-task and stores
some fields on the main task for use later when
dealing with the target cell.
Part of blueprint cross-cell-resize
Change-Id: I00683acee216c0c0ad87be3eb5ec832f20f054c7
This adds the main conductor task that will orchestrate
a cross-cell resize. This will get called from the
existing conductor MigrationTask when that task determines
the scheduler picked a target host in another cell for the
resize operation.
The only thing CrossCellMigrationTask does in this change
is perform checks on the neutron and cinder APIs to make
sure they are new enough for what we need before we go any
further with the resize.
Part of blueprint cross-cell-resize
Change-Id: I4d181b44494f3b0b04537d5798537831c8fdf400