test - Run gsutil unit/integration tests (for developers)

Synopsis

gsutil test [-l] [-u] [-f] [command command...]

Description

The gsutil test command runs the gsutil unit tests and integration tests. The unit tests use an in-memory mock storage service implementation, while the integration tests send requests to the production service using the preferred API set in the boto configuration file.

To run both the unit tests and integration tests, run the command with no arguments:

gsutil test

To run the unit tests only (which run quickly):

gsutil test -u

Tests run in parallel regardless of whether the top-level -m flag is present. To limit the number of tests run in parallel to 10 at a time:

gsutil test -p 10

To force tests to run sequentially:

gsutil test -p 1

To have sequentially-run tests stop running immediately when an error occurs:

gsutil test -f

To run tests for one or more individual commands add those commands as arguments. For example, the following command will run the cp and mv command tests:

gsutil test cp mv

To list available tests, run the test command with the -l argument:

gsutil test -l

The tests are defined in the code under the gslib/tests module. Each test file is of the format test_[name].py where [name] is the test name you can pass to this command. For example, running "gsutil test ls" would run the tests in "gslib/tests/test_ls.py".

You can also run an individual test class or function name by passing the test module followed by the class name and optionally a test name. For example, to run the an entire test class by name:

gsutil test naming.GsutilNamingTests

or an individual test function:

gsutil test cp.TestCp.test_streaming

You can list the available tests under a module or class by passing arguments with the -l option. For example, to list all available test functions in the cp module:

gsutil test -l cp

To output test coverage:

gsutil test -c -p 500
coverage html

This will output an HTML report to a directory named 'htmlcov'.

Test coverage is compatible with v4.1 of the coverage module (https://pypi.python.org/pypi/coverage).

Options

-b

Run tests against multi-regional US buckets. By default, tests run against regional buckets in us-central1.

-c

Output coverage information.

-f

Exit on first sequential test failure.

-l

List available tests.

-p N

Run at most N tests in parallel. The default value is 5.

-s

Run tests against S3 instead of GS.

-u

Only run unit tests.