diff --git a/doc/source/development_guidelines.rst b/doc/source/development_guidelines.rst index 0a62e2c595..76b5126be7 100644 --- a/doc/source/development_guidelines.rst +++ b/doc/source/development_guidelines.rst @@ -51,6 +51,25 @@ To execute the unit tests: - `tox -e pep8,py26` +The functional tests may be executed against a :doc:`development_saio` or +other running Swift cluster using the command: + +- `tox -e func` + +The endpoint and authorization credentials to be used by functional tests +should be configured in the ``test.conf`` file as described in the section +:ref:`setup_scripts`. + +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. + ------------ Coding Style ------------ @@ -78,7 +97,7 @@ The documentation in docstrings should follow the PEP 257 conventions More specifically: - 1. Triple qutes should be used for all docstrings. + 1. Triple quotes should be used for all docstrings. 2. If the docstring is simple and fits on one line, then just use one line. 3. For docstrings that take multiple lines, there should be a newline @@ -117,3 +136,4 @@ another year added, and date ranges are not needed.:: # implied. # See the License for the specific language governing permissions and # limitations under the License. + diff --git a/doc/source/development_saio.rst b/doc/source/development_saio.rst index 9e635c0331..e33e60db2a 100644 --- a/doc/source/development_saio.rst +++ b/doc/source/development_saio.rst @@ -398,6 +398,8 @@ commands are as follows: .. literalinclude:: /../saio/swift/object-server/4.conf +.. _setup_scripts: + ------------------------------------ Setting up scripts for running Swift ------------------------------------ diff --git a/swift/obj/mem_diskfile.py b/swift/obj/mem_diskfile.py index d02cdbe43e..efb8c6c8c0 100644 --- a/swift/obj/mem_diskfile.py +++ b/swift/obj/mem_diskfile.py @@ -395,5 +395,5 @@ class DiskFile(object): :param timestamp: timestamp to compare with each file """ fp, md = self._filesystem.get_object(self._name) - if md['X-Timestamp'] < Timestamp(timestamp): + if md and md['X-Timestamp'] < Timestamp(timestamp): self._filesystem.del_object(self._name) diff --git a/test/functional/__init__.py b/test/functional/__init__.py index 4994e17a3b..65f521bd24 100644 --- a/test/functional/__init__.py +++ b/test/functional/__init__.py @@ -48,7 +48,7 @@ from swift.common.utils import config_true_value from swift.proxy import server as proxy_server from swift.account import server as account_server from swift.container import server as container_server -from swift.obj import server as object_server +from swift.obj import server as object_server, mem_server as mem_object_server import swift.proxy.controllers.obj # In order to get the proper blocking behavior of sockets without using @@ -133,6 +133,7 @@ max_file_size = %d def in_process_setup(the_object_server=object_server): print >>sys.stderr, 'IN-PROCESS SERVERS IN USE FOR FUNCTIONAL TESTS' + print >>sys.stderr, 'Using object_server: %s' % the_object_server.__name__ monkey_patch_mimetools() @@ -408,7 +409,10 @@ def setup_package(): config.update(get_config('func_test')) if in_process: - in_process_setup() + in_mem_obj_env = os.environ.get('SWIFT_TEST_IN_MEMORY_OBJ') + in_mem_obj = utils.config_true_value(in_mem_obj_env) + in_process_setup(the_object_server=( + mem_object_server if in_mem_obj else object_server)) global web_front_end web_front_end = config.get('web_front_end', 'integral')