From c7e5e125003de1a0f288f79783e9a41650e6f686 Mon Sep 17 00:00:00 2001 From: Alistair Coles Date: Fri, 29 Jan 2016 14:22:19 +0000 Subject: [PATCH] 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 --- doc/source/development_guidelines.rst | 28 +++++++++++++++++++++++---- test/functional/__init__.py | 9 +++++++++ tox.ini | 5 +++++ 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/doc/source/development_guidelines.rst b/doc/source/development_guidelines.rst index ec2c45c5ba..51300d3638 100644 --- a/doc/source/development_guidelines.rst +++ b/doc/source/development_guidelines.rst @@ -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 diff --git a/test/functional/__init__.py b/test/functional/__init__.py index b458b180ee..9e0ebe2b6c 100644 --- a/test/functional/__init__.py +++ b/test/functional/__init__.py @@ -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)) diff --git a/tox.ini b/tox.ini index 3af407543c..ce451579ff 100644 --- a/tox.ini +++ b/tox.ini @@ -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}