Commit Graph

12 Commits

Author SHA1 Message Date
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
Matteo Sposato 032bbc3960 Refactoring of functional.regression.test_bug_1702454
Removed direct post api call
Added _evacuate_server helper

Change-Id: I78f9c6fa561dbc5bf002c396d7de34e21f7cbca2
2020-12-15 16:43:03 +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
Stephen Finucane 9142a97f24 nova-net: Remove final references to nova-net from functional tests
Most of this is just removal of unnecessary 'use_neutron=True' conf
overrides. The sole exception is the conversion of the metadata API
tests, which turned out to be far less effort to convert than I
expected.

Change-Id: I5114bf13e7df95ed02be70f29d453116387d4f9c
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2019-11-29 17:20:02 +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
Stephen Finucane 8f6de35636 tests: Stop starting consoleauth in functional tests
This hasn't been needed since we moved console authentication to the
database in Rocky.

Part of blueprint remove-consoleauth

Change-Id: Ie5e7d70f9d6af77edd22756128937f06d0b961a9
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2019-06-17 15:18:31 +01: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
Sylvain Bauza 6e332cb7f1 Functional regression test for evacuate with a target
In I6ddcaaca37fc5387c2d2e9f51c67ea9e85acb5c5 we forgot to update the
legacy filter properties dictionary so the requested target wasn't
passed to the scheduler when evacuating.
Adding a functional test for verifying the behaviour.

NOTE(sbauza): The issue has been incendentally fixed in Pike by
I434af8e4ad991ac114dd67d66797a562d16bafe2 so the regression test just
verifies that the expected behaviour works.
The Newton and Ocata backports will be slightly different from that one as we
need to verify that host3 will be preferred eventually over host2.

Related-Bug: #1702454

Change-Id: Id9adb10d2ef821c8b61d8f1d5dc9dd66ec7aaac8
2017-10-29 13:49:06 -04:00