787bb33606
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
60 lines
2.2 KiB
Python
60 lines
2.2 KiB
Python
# Copyright 2015 NEC Corporation. All rights reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
from __future__ import absolute_import
|
|
|
|
import os
|
|
|
|
import fixtures
|
|
|
|
import nova.conf
|
|
from nova.conf import paths
|
|
|
|
|
|
CONF = nova.conf.CONF
|
|
|
|
|
|
class ApiPasteV21Fixture(fixtures.Fixture):
|
|
|
|
def _replace_line(self, target_file, line):
|
|
# TODO(johnthetubaguy) should really point the tests at /v2.1
|
|
target_file.write(line.replace(
|
|
"/v2: openstack_compute_api_v21_legacy_v2_compatible",
|
|
"/v2: openstack_compute_api_v21"))
|
|
|
|
def setUp(self):
|
|
super(ApiPasteV21Fixture, self).setUp()
|
|
CONF.set_default('api_paste_config',
|
|
paths.state_path_def('etc/nova/api-paste.ini'),
|
|
group='wsgi')
|
|
tmp_api_paste_dir = self.useFixture(fixtures.TempDir())
|
|
tmp_api_paste_file_name = os.path.join(tmp_api_paste_dir.path,
|
|
'fake_api_paste.ini')
|
|
with open(CONF.wsgi.api_paste_config, 'r') as orig_api_paste:
|
|
with open(tmp_api_paste_file_name, 'w') as tmp_file:
|
|
for line in orig_api_paste:
|
|
self._replace_line(tmp_file, line)
|
|
CONF.set_override('api_paste_config', tmp_api_paste_file_name,
|
|
group='wsgi')
|
|
|
|
|
|
class ApiPasteNoProjectId(ApiPasteV21Fixture):
|
|
|
|
def _replace_line(self, target_file, line):
|
|
line = line.replace(
|
|
"paste.filter_factory = nova.api.openstack.auth:"
|
|
"NoAuthMiddleware.factory",
|
|
"paste.filter_factory = nova.api.openstack.auth:"
|
|
"NoAuthMiddlewareV2_18.factory")
|
|
target_file.write(line)
|