Commit Graph

12 Commits

Author SHA1 Message Date
Stephen Finucane 97d25371b3 scheduler: Remove 'USES_ALLOCATION_CANDIDATES'
There is only one scheduler driver now. This variable is no longer
necessary.

We remove a couple of test that validated behavior for scheduler drivers
that didn't support allocation candidates (there are none) and update
the test for the 'nova-manage placement heal_allocations' command to
drop allocations instead of relying on them not being created.

Change-Id: I64dc67e2bacd7a6c86153db5ae983dfb54bd40eb
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2021-06-29 11:40:04 +01:00
Stephen Finucane c269285568 tests: Move remaining non-libvirt fixtures
Move these to the central place. There's a large amount of test damage
but it's pretty trivial.

Change-Id: If581eb7aa463c9dde13714f34f0f1b41549a7130
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2021-05-12 16:32:43 +01:00
Stephen Finucane cc45581a18 functional: Add and use 'GlanceFixture'
This rather beefy (but also quite simple) patch replaces the
'stub_out_image_service' call and associated cleanup in all functional
tests with a new 'GlanceFixture', based on the old 'FakeImageService'.
The use of a fixture means we don't have to worry about teardown and
allows us to stub Glance in the same manners as Cinder, Neutron,
Placement etc.

Unit test cleanup is handled in a later patch.

Change-Id: I6daea47988181dfa6dde3d9c42004c0ecf6ae87a
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2020-09-16 11:31:23 +01:00
Stephen Finucane 458d37fceb functional: Add unified '_build_server' helper function
'_IntegratedTestBase' has subclassed 'InstanceHelperMixin' since change
I0d21cb94c932e6e556eca964c57868c705b2d120, which means both now provide
a '_build_minimal_create_server_request' function. However, only
'_IntegratedTestBase' provides a '_build_server' function. The
'_build_minimal_create_server_request' and '_build_server' functions do
pretty much the same thing but there are some differences. Combine these
under the '_build_server' alias.

Change-Id: I91fa2f73185fef48e9aae9b7f61389c374e06676
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2020-01-15 10:31:24 +00:00
Stephen Finucane 7ae1a10913 functional: Remove 'api' parameter
Pretty much every test case in 'nova.tests.functional' defines an 'api'
attribute, and many define an 'admin_api' attribute. We can pull these
from the class rather than explicitly passing them to helpers. Rework
things so this happens.

Note that the bulk of the changes here are in the
'nova/tests/functional/integrated_helpers.py' file. The rest of the
changes were auto-generated using the following script (my sed-fu is
non-existent):

  $ cd nova/tests/functional
  $ python3
  >>> import glob
  >>> import re
  >>> pattern = r'_state_change\((\n\s+)?self\.(admin_)?api,\s+'
  >>> replace = r'_state_change(\1'
  >>> for path in glob.glob('*.py') + glob.glob('*/*.py'):
  ...     with open(path) as fh:
  ...         data = fh.read()
  ...     new = re.sub(pattern, replace, data, flags=re.MULTILINE)
  ...     if new != data:
  ...         with open(path, 'w') as fh:
  ...             fh.write(new)
  ...
  >>> quit()

(ditto for the other substitutions)

Some manual fixups were required after, which pre-commit highlighted :)

Change-Id: I8c96b337f32148f8f5899c9b87af331b1fa41424
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2019-12-06 15:35:33 +00:00
Balazs Gibizer b5666fb492 Remove global state from the FakeDriver
The virt driver FakeDriver used in both the functional and in the unit
test used a global state to configure the host and node names the driver
reports. This was hard to use when more then one compute service is started.
Also global state is dangerous.

It turned out that only a set of unit tests are using multiple nodes per
compute the rest of the tests can simply use host=<hostname>,
nodes=[<hostname>] setup.

So this removes the global state.

Change-Id: I2cf2fcbaebc706f897ce5dfbff47d32117064f9c
2019-06-21 10:37:20 +02:00
Takashi NATSUME bda4ae3884 Remove duplicate cleanup in functional tests
It is not necessary to call the following statement multiple times in
some functional tests.

self.addCleanup(fake.restore_nodes)

So remove duplicate calls in the tests.

TrivalFix
Change-Id: Iaae6fc4a66145576f4a4fc1cea452ef6acbadb15
2019-03-07 23:58:58 +00:00
Chris Dent 787bb33606 Use external placement in functional tests
Adjust the fixtures used by the functional tests so they
use placement database and web fixtures defined by placement
code. To avoid making redundant changes, the solely placement-
related unit and functional tests are removed, but the placement
code itself is not (yet).

openstack-placement is required by the functional tests. It is not
added to test-requirements as we do not want unit tests to depend
on placement in any way, and we enforce this by not having placement
in the test env.

The concept of tox-siblings is used to ensure that the
placement requirement will be satisfied correctly if there is a
depends-on. To make this happen, the functional jobs defined in
.zuul.yaml are updated to require openstack/placement.

tox.ini has to be updated to use a envdir that is the same
name as job. Otherwise the tox siblings role in ansible cannot work.

The handling of the placement fixtures is moved out of nova/test.py
into the functional tests that actually use it because we do not
want unit tests (which get the base test class out of test.py) to
have anything to do with placement. This requires adjusting some
test files to use absolute import.

Similarly, a test of the comparison function for the api samples tests
is moved into functional, because it depends on placement functionality,

TestUpgradeCheckResourceProviders in unit.cmd.test_status is moved into
a new test file: nova/tests/functional/test_nova_status.py. This is done
because it requires the PlacementFixture, which is only available to
functional tests. A MonkeyPatch is required in the test to make sure that
the right context managers are used at the right time in the command
itself (otherwise some tables do no exist). In the test itself, to avoid
speaking directly to the placement database, which would require
manipulating the RequestContext objects, resource providers are now
created over the API.

Co-Authored-By: Balazs Gibizer <balazs.gibizer@ericsson.com>
Change-Id: Idaed39629095f86d24a54334c699a26c218c6593
2018-12-12 18:46:49 +00:00
Matt Riedemann 25dadb94db Remove the CachingScheduler
The CachingScheduler has been deprecated since Pike [1].
It does not use the placement service and as more of nova
relies on placement for managing resource allocations,
maintaining compabitility for the CachingScheduler is
exorbitant.

The release note in this change goes into much more detail
about why the FilterScheduler + Placement should be a
sufficient replacement for the original justification
for the CachingScheduler along with details on how to migrate
from the CachingScheduler to the FilterScheduler.

Since the [scheduler]/driver configuration option does allow
loading out-of-tree drivers and the scheduler driver interface
does have the USES_ALLOCATION_CANDIDATES variable, it is
possible that there are drivers being used which are also not
using the placement service. The release note also explains this
but warns against it. However, as a result some existing
functional tests, which were using the CachingScheduler, are
updated to still test scheduling without allocations being
created in the placement service.

Over time we will likely remove the USES_ALLOCATION_CANDIDATES
variable in the scheduler driver interface along with the
compatibility code associated with it, but that is left for
a later change.

[1] Ia7ff98ff28b7265058845e46b277317a2bfc96d2

Change-Id: I1832da2190be5ef2b04953938860a56a43e8cddf
2018-10-18 17:55:36 -04:00
Matt Riedemann 5fe80b6339 (Re)start caching scheduler after starting computes in tests
This moves the scheduler restart logic from the heal_allocations
tests into a more generic location (like restart_compute_service)
so that we can re-use it in other functional tests that rely on
the caching scheduler. There are a couple of other tests that don't
need to restart the scheduler if we just move the start of the
scheduler to after we start the computes.

Change-Id: I7720fe4a3a0e537b7b356947317766597d4b47cf
Related-Bug: #1781648
2018-08-29 13:16:09 -04:00
Matt Riedemann 68f7b95bdc Handle no allocations during migrate
The CachingScheduler does not create allocations in the
scheduler, so the assertion in the conductor migrate task
that the instance will have allocations on the source node
is incorrect. This removes the assertion and changes the
error to a debug message.

The related functional regression test is updated to show
resize working with the CachingScheduler again.

There are other places in the code, especially the compute
and resource tracker, where we log errors if we can't find
allocations and those likely need to be updated at some
point, but it can happen in a follow up.

Change-Id: I0bb2933c4ed7ed479206c9b06be7e30a2ec92f2a
Closes-Bug: #1741307
2018-01-04 14:18:50 -05:00
Matt Riedemann 5dad1ecc32 Add regression test for resizing failing when using CachingScheduler
The cold migrate task in conductor assumes that the scheduler (or compute)
created allocations against the source node for the instance when it
attempts to swap those allocations to the migration record. However, if
using the CachingScheduler, the scheduler doesn't create allocations in
Placement, and if the computes are >=Pike, they won't either, so conductor
fails to find the allocations for the instance on the source node and fails.

This adds a functional regression test to show the failure. A follow up
patch with the fix will modify the test to show it passing again.

Change-Id: I80a401f6adce1c4e77a595928d6b9f085ff769a8
Related-Bug: #1741307
2018-01-04 13:25:10 -05:00