Enable in-process func tests to optionally use fast-post

Running functional tests in the in-process mode uses
the default value for proxy-server object_post_as_copy,
which is True. This patch adds support for an environment
variable to change this value to False so that the fast-post
mode is tested when running in-process functional tests.

The patch also adds a new tox environment func-in-process-fast-post
which forces in-process functional testing with
object_post_as_copy=False.

The motivation for this change, apart from enabling configurable
local testing, is to put support in place for an upstream CI job
that will actually functionally test the fast-post mode, which is
otherwise only covered by unit tests.

There are currently two gate jobs that run the functional tests:

- gate-swift-dsvm-functional runs the tests *twice* against a
  devstack swift service, once using tempauth and once using
  keystoneauth. The devstack swift service uses the default
  object_post_as_copy=True.

- gate-swift-tox-func runs the func tests in in-process mode
  which also uses tempauth and object_post_as_copy=True. This
  duplicates one of the config scenarios above.

With this change either the gate-swift-tox-func job or a new job
could run the functional tests using object_post_as_copy=False.

Change-Id: Ia37f6df1dc38e44ef7404fbf0a52f6fc22fae0c2
This commit is contained in:
Alistair Coles 2016-01-29 14:22:19 +00:00
parent 5ec586bd34
commit c7e5e12500
3 changed files with 38 additions and 4 deletions

@ -83,15 +83,35 @@ For example, this command would run the functional tests using policy
SWIFT_TEST_POLICY=silver tox -e func
In-process functional testing
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If the ``test.conf`` file is not found then the functional test framework will
instantiate a set of Swift servers in the same process that executes the
functional tests. This 'in-process test' mode may also be enabled (or disabled)
by setting the environment variable ``SWIFT_TEST_IN_PROCESS`` to a true (or
false) value prior to executing `tox -e func`.
When using the 'in-process test' mode, the optional in-memory
object server may be selected by setting the environment variable
``SWIFT_TEST_IN_MEMORY_OBJ`` to a true value.
When using the 'in-process test' mode some server configuration options may be
set using environment variables:
- the optional in-memory object server may be selected by setting the
environment variable ``SWIFT_TEST_IN_MEMORY_OBJ`` to a true value.
- the proxy-server ``object_post_as_copy`` option may be set using the
environment variable ``SWIFT_TEST_IN_PROCESS_OBJECT_POST_AS_COPY``.
For example, this command would run the in-process mode functional tests with
the proxy-server using object_post_as_copy=False (the 'fast-POST' mode)::
SWIFT_TEST_IN_PROCESS=1 SWIFT_TEST_IN_PROCESS_OBJECT_POST_AS_COPY=False \
tox -e func
This particular example may also be run using the ``func-in-process-fast-post``
tox environment::
tox -e func-in-process-fast-post
The 'in-process test' mode searches for ``proxy-server.conf`` and
``swift.conf`` config files from which it copies config options and overrides
@ -127,7 +147,7 @@ using config files found in ``$HOME/my_tests`` and policy 'silver'::
Coding Style
------------
Swift use flake8 with the OpenStack `hacking`_ module to enforce
Swift uses flake8 with the OpenStack `hacking`_ module to enforce
coding style.
Install flake8 and hacking with pip or by the packages of your

@ -388,6 +388,15 @@ def in_process_setup(the_object_server=object_server):
'SERVICE_require_group': 'service'
})
# If an env var explicitly specifies the proxy-server object_post_as_copy
# option then use its value, otherwise leave default config unchanged.
object_post_as_copy = os.environ.get(
'SWIFT_TEST_IN_PROCESS_OBJECT_POST_AS_COPY')
if object_post_as_copy is not None:
object_post_as_copy = config_true_value(object_post_as_copy)
config['object_post_as_copy'] = str(object_post_as_copy)
_debug('Setting object_post_as_copy to %r' % object_post_as_copy)
acc1lis = eventlet.listen(('localhost', 0))
acc2lis = eventlet.listen(('localhost', 0))
con1lis = eventlet.listen(('localhost', 0))

@ -44,6 +44,11 @@ commands =
[testenv:func]
commands = ./.functests {posargs}
[testenv:func-in-process-fast-post]
commands = ./.functests {posargs}
setenv = SWIFT_TEST_IN_PROCESS=1
SWIFT_TEST_IN_PROCESS_OBJECT_POST_AS_COPY=False
[testenv:venv]
commands = {posargs}