Commit Graph

12 Commits

Author SHA1 Message Date
Stephen Finucane 6652999494 scheduler: Merge driver into manager
There's only one driver now, which means there isn't really a driver at
all. Move the code into the manager altogether and avoid a useless layer
of abstraction.

Change-Id: I609df5b707e05ea70c8a738701423ca751682575
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2021-08-23 16:52:25 +01:00
Stephen Finucane e0534cc289 scheduler: Merge 'FilterScheduler' into base class
There are no longer any custom filters. We don't need the abstract base
class. Merge the code in and give it a more useful 'SchedulerDriver'
name.

Change-Id: Id08dafa72d617ca85e66d50b3c91045e0e8723d0
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2021-06-29 12:24:41 +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 60b097a5ef Move HostNameWeigher to a common fixture
Multiple functional tests used its own copy-pasted implementation of a
weigher to make the scheduling deterministic based on host names.

This patch moves the HostNameWeigher implementation to a common place
and adds a fixtures to set up the weigher in the conf.

Change-Id: I4c23a3c4f8963c42379e7a8d63c6c1e089350eb3
2019-09-25 09:57:38 +02: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 c22b53c248 Update RequestSpec.instance_uuid during scheduling
Before change I4b67ec9dd4ce846a704d0f75ad64c41e693de0fb
the ServerGroupAntiAffinityFilter did not rely on the
HostState.instances dict to determine **within the same
request** how many members of the same anti-affinity
group were on a given host. In fact, at that time, the
HostState.instances dict wasn't updated between filter
runs in the same multi-create request. That was fixed with
change Iacc636fa8a59a9e8670a8d683c10bdbb0dc8237b so that
as we select a host for each group member being created
within a single request, we also update the HostState.instances
dict so the ServerGroupAntiAffinityFilter would have
accurate tracking of which group members were on which
hosts.

However, that did not account for a wrinkle in the filter
added in change Ie016f59f5b98bb9c70b3e33556bd747f79fc77bd
which is needed to allow resizing a server to the same host
when that server is in an anti-affinity group. That wrinkle,
combined with the fact the RequestSpec the filter is acting
upon for a given instance in a multi-create request might
not actually have the same instance_uuid can cause the filter
to think it's in a resize situation and accept a host which
already has another member from the same anti-affinity group
on it, which breaks the anti-affinity policy.

For background, during a multi-create request, we create a
RequestSpec per instance being created, but conductor only
sends the first RequestSpec for the first instance to the
scheduler. This means RequestSpec.num_instances can be >1
and we can be processing the Nth instance in the list during
scheduling but working on a RequestSpec for the first instance.
That is what breaks the resize check in ServerGroupAntiAffinityFilter
with regard to multi-create.

To resolve this, we update the RequestSpec.instance_uuid when
filtering hosts for a given instance but we don't persist that
change to the RequestSpec.

This is a bit clunky, but it kind of comes with the territory of
how we hack scheduling requests together using a single RequestSpec
for multi-create requests. An alternative to this is found in change
I0dd1fa5a70ac169efd509a50b5d69ee5deb8deb7 where we rely on the
RequestSpec.num_instances field to determine if we're in a multi-create
situation, but that has its own flaws because num_instances is
persisted with the RequestSpec which might cause us to re-introduce
bug 1558532 if we're not careful. In that case we'd have to either
(1) stop persisting RequestSpec.num_instances or (2) temporarily
unset it like we do using RequestSpec.reset_forced_destinations()
during move operations.

Co-Authored-By: Sean Mooney <work@seanmooney.info>

Closes-Bug: #1781710

Change-Id: Icba22060cb379ebd5e906981ec283667350b8c5a
2018-07-19 14:50:09 -04:00
Matt Riedemann 5e262d673b Add regression test for bug 1781710
Co-Authored-By: Sean Mooney <work@seanmooney.info>

Related-Bug: #1781710
Change-Id: I411eb17524a44da4f765fd1463e404dc15075e2c
2018-07-19 14:37:30 -04:00