Commit Graph

8 Commits

Author SHA1 Message Date
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
Chris Dent f7c5aca3b2 Set policy_opt defaults in placement deploy unit test
Without this change, tests can intermittently fail with NoSuchOptError
when a single process does not have the ConfigFixture running before
this test. This change ensure the opts are registered and defaulted.

Change-Id: I6a4873726e3e7fe0d4db3d1dea61309702b8f24b
Closes-Bug: #1788176
2018-08-21 16:56:43 +01:00
yanpuqing 59d5eb125b Rename auth_uri to www_authenticate_uri
Keystone deprecated 'auth_uri' to bring 'www_authenticate_uri' in
https://review.openstack.org/#/c/508522/, so 'auth_uri'
should be removed from all openstack projects.
The auth_url is the parameter passed to the keystoneauth plugin
and the auth_uri is the parameter specific to keystonemiddleware,
so the auth_url would be appropriate in api/client since that's
going to be passed straight to keystoneauth, and it should be
the same in api/client and in the fixture. So we change the
parameter to auth_url in api/client instead of www_authenticate_uri.

Change-Id: I7f878974fe8bebb8fe5803ca4e2f8839cdc971d0
Related-Bug: 1755728
2018-07-23 02:19:35 +00:00
Chris Dent 1fc3e7d0fe Do not use nova.test in placement.test_deploy
The tests are very straightforward and do not require many of the setup
and fixtures that nova.test.NoDBTestCase supplies. Also, in the future
of placement extraction we don't want the dependecy.

One missing tool from NoDBTestCase is self.flags, which helps manage
configuration. That is a facade over CONF.set_override, so we just call
that instead.

Partially implements blueprint placement-extract

Change-Id: Ice6a42b3b8b94e155d7332256e9b568f80bc663d
2018-06-07 05:44:36 +08:00
Chris Dent 46d919c11b Flexibly test keystonmiddleware in placement stack
In change I524c93d30607ea6ab70de92ceea207ee77f34c25 keystonemiddleware
adjusted how the value of the Keystone uri is quoted when sending a
www-authenticate header. It went from using a single quote to double.
Double is more correct.

The existing version of the test changed in this commit relied on the
single quote to verify that a URL set in config would be used by the
middleware appropriately. Now, instead of one exact match test, two
in-string tests are used.

Change-Id: Ie9d1df419f2bdfa1d658f5f64ea9b7285de7b9b7
Closes-Bug: #1770718
2018-05-11 19:12:40 +01:00
Chris Dent fc71fb891e [placement] annotate loadapp as public interface
When Change-Id: I61d20c5d19797f7e66648c7864a632f3328be8ce was under
review there were questions about why the interface on deploy() was not
changed to remove the no-longer used project_name kwarg. I mistakenly
asserted that this was because it was a public interface for building
a Placement WSGI application. That's not the case. loadapp() is the
public interface.

This change annotates loadapp() as such, and removes the unused arg
deploy().

Change-Id: I9f3d03d964654ab1b9515ecd6fe35c518d5f496a
Related-Bug: #1734491
2018-02-12 11:41:50 +00:00
Hongbin Lu c4c1770475 placement: skip authentication on root URI
The placement API GET / is for version discovery. Skip authentication
on this URL.

The change to test_deploy is required to make it request a URL that
requires authentication. It had been using /.

Change-Id: I5ed1f7a607620c43671e90eaf8a1f6285f1d15e4
Closes-Bug: #1733630
2017-12-11 17:28:36 +00:00
Chris Dent b2e02f5147 [placement] re-use existing conf with auth token middleware
If 'oslo_config_project' is passed to the auth_token filter
factory, the mechanism in nova.api.openstack.placement.wsgi for
overriding the location of the configuration file is ignored
meaning that expected custom configuration is also ignored.

Instead pass the already existing conf with 'olso_config_config'
parameter.

The unit test in test_deploy.py shows that the configuration
settings get passed to the middleware and used by testing the
value of the 'WWW-Authenticate' header (which comes from a few
different configuration settings, of which is 'auth_uri') in
a response generated by the placement WSGI application.
The same test against the previous deploy.py code fails.

Change-Id: I61d20c5d19797f7e66648c7864a632f3328be8ce
Closes-Bug: #1734491
2017-12-01 19:27:03 +00:00