Commit Graph

54942 Commits

Author SHA1 Message Date
Takashi NATSUME d4ed9ed93f Add a hacking rule for non-existent assertions
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
2019-08-21 05:23:02 +00:00
Takashi NATSUME 5ccdbc7189 Fix missing rule description in HACKING.rst
The description of N363 hacking rule is missing
in HACKING.rst.
Add the description.

Change-Id: I036a48612fcd256df4ccbd2ebba814bf3ed7a1c2
Closes-Bug: #1840862
2019-08-21 10:40:21 +09:00
Zuul 4e9d224479 Merge "Add functional recreate test for bug 1823370" 2019-08-20 18:06:07 +00:00
Zuul 45107fce8d Merge "Update api-ref for 2.75 to add config_drive in server update response" 2019-08-20 15:19:24 +00:00
Matt Riedemann a7bd9688d5 Add functional recreate test for bug 1823370
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
2019-08-20 11:18:24 -04:00
Ghanshyam Mann f7e672d302 Update api-ref for 2.75 to add config_drive in server update response
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
2019-08-20 12:58:36 +00:00
Zuul 7e98253729 Merge "Move router advertisement daemon restarts to privsep." 2019-08-20 04:56:59 +00:00
Zuul 900e94d305 Merge "Move dnsmasq restarts to privsep." 2019-08-20 00:46:15 +00:00
Zuul ee735b8499 Merge "Move iptables rule fetching and setting to privsep." 2019-08-20 00:46:06 +00:00
Zuul e195761958 Merge "api-ref: add config_drive to 2.75 rebuild response parameters" 2019-08-19 23:38:20 +00:00
Zuul 4bd6e650ce Merge "Fix use of mock.patch with new_callable=PropertyMock" 2019-08-19 23:38:06 +00:00
Zuul dcdec12480 Merge "doc: cleanup 2.75 REST API microversion history doc" 2019-08-19 23:37:57 +00:00
Matt Riedemann ad75beee11 api-ref: add config_drive to 2.75 rebuild response parameters
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
2019-08-19 15:01:35 -04:00
Matt Riedemann 9f269e5386 doc: cleanup 2.75 REST API microversion history doc
Fixes some formatting, typos and grammar. Also includes
the other os-hypervisors impacted routes.

Change-Id: I594dc84b071ac4e8e951bd948a89677149755722
2019-08-19 15:01:15 -04:00
Takashi NATSUME 1eec451b1b Tests: autospecs all the mock.patch usages
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
2019-08-19 09:43:10 -05:00
Takashi NATSUME 8ea5e37338 Fix wrong assertions in unit tests
Change-Id: I54dff4d5ed513690d0fae65de47a1a9c23aebbd4
Closes-Bug: #1840601
2019-08-19 21:20:51 +09:00
Takashi NATSUME ad482e53fb Fix 'has_calls' method calls in unit tests
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
2019-08-19 07:34:29 +00:00
Zuul ee6b69cadc Merge "Fix libvirt driver tests to use LibvirtConfigCapsGuest instances" 2019-08-16 19:12:17 +00:00
Zuul 45a680cdf5 Merge "Allow assertXmlEqual() to pass options to matchers.XMLMatches" 2019-08-16 19:12:10 +00:00
Zuul 0311656d65 Merge "libvirt: Mock libvirt'y things in setUp" 2019-08-16 18:07:37 +00:00
Balazs Gibizer 588c513f3d Avoid timeout from service update api unit tests
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
2019-08-16 14:23:33 +02:00
Michael Still f2d93d0980 Move router advertisement daemon restarts to privsep.
A relatively simple case.

Change-Id: I875483c869a253648fd90a9d3510f79cee509ce5
2019-08-16 11:24:25 +01:00
Michael Still 6e563d9703 Move dnsmasq restarts to privsep.
I don't really love this one, but I don't see a better way to
untangle this.

Change-Id: Icce18320a7c8fba3cf06bd032fbbe1846804e897
2019-08-16 11:24:22 +01:00
Michael Still 54bf4694b9 Move iptables rule fetching and setting to privsep.
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
2019-08-16 11:24:07 +01:00
Stephen Finucane 85ea4f703d libvirt: Mock libvirt'y things in setUp
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>
2019-08-16 11:13:25 +01:00
Zuul c7a32709b9 Merge "config: remove deprecated checksum options" 2019-08-16 07:25:48 +00:00
Zuul 839b3624ff Merge "Fix non-existent method of Mock" 2019-08-15 23:40:05 +00:00
Zuul 35485eacfb Merge "API microversion 2.76: Add 'power-update' external event" 2019-08-15 23:39:50 +00:00
Takashi NATSUME cf7d28eb6e Fix non-existent method of Mock
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
2019-08-15 21:20:08 +00:00
Adam Spiers d5b9b0052a Fix libvirt driver tests to use LibvirtConfigCapsGuest instances
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
2019-08-15 19:24:26 +01:00
Adam Spiers 1e05b9e61c Allow assertXmlEqual() to pass options to matchers.XMLMatches
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
2019-08-15 19:24:26 +01:00
Surya Seetharaman 62f6a0a1bc API microversion 2.76: Add 'power-update' external event
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
2019-08-15 13:19:44 -04:00
Adam Spiers 27f6579fa9 Fix use of mock.patch with new_callable=PropertyMock
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
2019-08-15 18:11:53 +01:00
Mohammed Naser e141bcdb25 config: remove deprecated checksum options
This patch removes the legacy code for image checksumming
as well as configuration values that are not longer being
used.

Change-Id: I9c552e33456bb862688beaabe69f2b72bb8ebcce
2019-08-15 11:47:51 -04:00
Zuul 872a823d9a Merge "Enhance SDK fixture for 0.34.0" 2019-08-15 09:23:08 +00:00
Eric Fried 5f412cadbd Enhance SDK fixture for 0.34.0
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
2019-08-14 17:15:15 -05:00
Zuul 79d1c884b2 Merge "Restore soft-deleted compute node with same uuid" 2019-08-14 20:14:47 +00:00
Zuul dbe267aba5 Merge "Add functional regression recreate test for bug 1839560" 2019-08-14 20:14:37 +00:00
Zuul 7bcf8c5a7e Merge "lxc: make use of filter python3 compatible" 2019-08-14 18:25:57 +00:00
Zuul 778a986a65 Merge "api-ref: Fix collapse of 'host_status' description" 2019-08-14 07:27:09 +00:00
Zuul 77916e6d7b Merge "Execute TargetDBSetupTask" 2019-08-14 04:05:29 +00:00
Takashi NATSUME abfb28291a api-ref: Fix collapse of 'host_status' description
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
2019-08-14 10:46:26 +09:00
Sean Mooney fc9fb383c1 lxc: make use of filter python3 compatible
_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
2019-08-13 22:29:57 +00:00
Zuul 0b290050b2 Merge "Add CrossCellMigrationTask" 2019-08-13 22:23:34 +00:00
Zuul 4467506437 Merge "rt: only map compute node if we created it" 2019-08-13 22:23:18 +00:00
Zuul 878d68ea8f Merge "Fix misuse of nova.objects.base.obj_equal_prims" 2019-08-13 22:08:39 +00:00
Zuul 8292cb9013 Merge "Prevent init_host test to interfere with other tests" 2019-08-13 18:48:32 +00:00
Zuul e0c8375e9f Merge "Add TargetDBSetupTask" 2019-08-13 18:48:24 +00:00
Matt Riedemann e7e6dfb7de Execute TargetDBSetupTask
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
2019-08-13 16:13:33 +00:00
Matt Riedemann b910af3b41 Add CrossCellMigrationTask
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
2019-08-13 16:11:46 +00:00