Repository with all acceptance tests of the Onedata system.
Tests are run on a Onedata deployment set up using one-env on a Kubernetes cluster.
As the testing framework, pytest with pytest-bdd extension is used.
-
Currently, all selenium-based tests that use a web browser run on Google Chrome. Other browsers are only theoretically supported.
-
It is recommended to use Ubuntu 20.04+. Ubuntu 18.04+ is a slightly worse choice, but surely a working one. Setting up a deployment and running tests in macOS is possible, but problematic; see macOS deployment setup for tips.
- python 3.12+
- docker
- kubernetes cluster (e.g. minikube)
By default, the tests are run using a dockerized testing toolkit. All the required libraries are preinstalled in the docker image. However, it is possible to run some tests using a locally installed testing toolkit, as described in tests/gui/README.md.
In general, there are two ways of running acceptance tests:
-
Using
Makefile(recommended):make ENV_FILE=$ENV SUITE=$SUITE KEYWORDS=$KEYWORDS OPTS=$OPTS $test_type_identifier$SUITE- file name fromtests/*/scenarioswithout extension; determines the test suite to run.$KEYWORDS- optional pytest keyword expression used to select tests from the suite. It is passed to pytest as-k EXPRESSION, so you build it from test-name fragments and boolean operators. Examples:KEYWORDS="test_user_fails_to_view_group_after_leaving_it",KEYWORDS="fails_to_view_group and not admin",KEYWORDS="group and (leave or delete)". In other words, write a logical expression over words that appear in the test name or pytest keyword; pytest keeps only matching tests.$ENV_FILE- file name fromtests/*/environmentswithout extension; determines the env-file (description of Onedata deployment). If not specified, default 1oz_1op_deployed.yaml will be used.$OPTS- optional, any of./test_run.pyparameters (see Useful test_run parameters section).$test_type_identifier- determines the type of tests; one of:test_gui,
test_mixed,test_oneclient.
-
Using
./test_run.py(when advanced customization is required):Makefile essentially uses
./test_run.pywith default parameters. If needed, you can use the command directly with desired parameters.
The exact procedure of running tests is described in:
- tests/gui/README.md for GUI tests,
- tests/mixed/README.md for Mixed tests (these tests use GUI, REST and Oneclient at the same time)
- tests/oneclient/README.md for Oneclient tests,
- tests/demo_mode/README.md for Demo-mode tests, which run the commands published in the administrator guide directly.
For use in CI (Bamboo), see Bamboo Specs files placed in bamboo-specs
directory in root of this repository. These specs use the Makefile targets directly.
If there is a pre-existing deployment, it will be automatically detected and
used for the test. The deployment may be started manually (see the section that follows)
before running the test command. Note, however, that by default, the deployment
will be cleaned after the test. To prevent that, use the --no-clean option.
Running tests with --no-clean option is the optimal way to do consecutive
runs - the environment is set up once and then reused.
In typical scenarios, the deployment is started automatically as a part of the test procedure. If needed, it can be set up manually in order to run the tests on a preexisting deployment.
The manual start of Onedata deployment is described in the following document: one-env guide.
To start Onedata deployment, navigate to the one-env directory in
one-env repository
or to one-env submodule in the onedata-acceptance repository and run:
./onenv up -f test_env_config.yaml
Note: For above command to work, you need to build submodules using
make submodules command (invoke from repo root).
Example of a 2 provider deployment with specified onezone and oneprovider images:
./onenv up -f -pi docker.onedata.org/oneprovider-dev:develop -zi docker.onedata.org/onezone-dev:develop ../../tests/gui/environments/1oz_2op_deployed.yamlThe selectors below can be combined. Use -t to limit collection to a directory,
suite, or exact pytest node ID, and -k to filter the collected tests by name.
-t tests/gui- runs all tests under the specified directory.-t tests/gui/scenarios/test_onezone_groups_basic.py- runs one test suite.-t 'tests/gui/scenarios/test_onezone_groups_basic.py::test_user_fails_to_view_group_after_leaving_it'- runs one scenario using its exact pytest node ID. A parameterized node ID can also be supplied to select one particular test variant.
-k EXPRESSION- runs tests whose names match the case-insensitive pytest keyword expression. Build the expression from test-name fragments or keyword names using boolean operators:and,or,not, and parentheses. For example:-k 'fails_to_view_group'selects tests whose names contain that fragment.-k 'fails_to_view_group and not admin'keeps the failing case but excludes names containingadmin.-k 'group and (leave or delete)'selects tests that mentiongroupand eitherleaveordelete.
When using the Makefile, SUITE corresponds to the suite file passed with -t,
while KEYWORDS is passed as -k. The value you set should therefore be a
logical expression over parts of the test names you want to match. For example:
make ENV_FILE=1oz_1op_deployed SUITE=test_onezone_groups_basic \
KEYWORDS=test_user_fails_to_view_group_after_leaving_it COUNT=3 test_guiSee pytest's test selection documentation for the complete syntax.
--count N- repeats every test in the suiteNtimes on the same deployment. Tests marked withclean_environment(such as deployment tests) receive a fresh environment for every repetition.--reruns N- reruns failed tests up toNtimes. Unlike--count, successful tests are not repeated.--timeout SECONDS- sets the timeout used while waiting for the Onedata environment.--report-path PATH- specifies the output path for the JUnit XML report.--op-image IMAGE- selects the Oneprovider Docker image.--oz-image IMAGE- selects the Onezone Docker image.--rest-cli-image IMAGE- selects the REST CLI Docker image.--no-clean- prevents deleting Onedata deployment after tests - makes consecutive runs much faster (a preexisting deployment is detected and reused)--test-type gui- determines the test type.--driver=Chrome- set the browser to test in-i onedata/gui_builder:latest- use Docker image with dependencies for GUI tests (i.e. Python, Selenium, Xvfb, Chrome)--xvfb- starts Xvfb, a virtual display server, that makes tests headless (without opening local browser window)--xvfb-recording=<all|none|failed>- optional, record all or none or failed tests as movies and save them to<logdir>/movies--env-file=1oz_1op_not_deployed- specifiesenv_filethat will be used to start deployment if there is no active deployment--local- uses locally installed testing toolkit instead of dockerized one--no-pull- prevents from downloading docker images (by default all tests scenarios force pulling docker images even if they are already present on host machine.)--pdb- used to run the pdb debugger just after encountering a failure. For more information see: pytest documentation--oc-image=docker.onedata.org/oneclient-dev:develop- used to specify oneclient service docker image--sources- optional, if used, Onedata deployment starts using sources. Sources have to be located in appropriate directories.
Parameters: (for advanced usage)
--local-charts-path PATH- uses Helm charts from the specified local directory instead of the default charts.--kube-config-path PATH- specifies a non-default Kubernetes configuration directory mounted in the test-runner container.--minikube-config-path PATH- specifies a non-default Minikube configuration directory mounted in the test-runner container.--ignore-xfail- treats tests marked as expected failures as regular tests. Primarily useful for verification and upgrade testing.--preserve-users- preserves users left by previous tests; tests that would create users with conflicting names are skipped.--file-mode <regular|hardlink|symlink>- controls how files are created in Oneclient tests.--gui-pkg-verification- enables additional verification of installed GUI packages.--pull-only-missing-images- pulls only Docker images that are unavailable locally.--no-mosaic-filter- optional, if set, videos of tests using multiple browsers will be recorded as different video for each browser (mosaic video created by default)--update-etc-hosts- adds entries to/etc/hostsfor all pods in deployment. When using this option script has to be run with root privileges.--add-test-domain- when running tests on local machine, option for adding entries to/etc/hostsis turned off by default. This may cause that some test will fail. You can enable adding entries to/etc/hostsusing--add-test-domainoption, or add entries manually.
Note: using --add-test-domain, --update-etc-hosts flags can be problematic due to permissions of /etc/hosts file.
The experimental and not safe method is to do sudo chmod go+w /etc/hosts locally and
share /etc directory in docker.
Please contact our support if you have issues with updating /etc/hosts for testing.
Python debugger pdb is a very handy tool when it comes to test debugging.
The typical usage is to insert:
import pdb
pdb.set_trace()
at the location you want to break into the debugger, and then run test.
When the program stops, you can step through the code and then continue test
using c(continue) command.
Some useful debugger commands:
c(ont(inue))- continue execution, only stop when a breakpoint is encountered.q(uit)- quit from the debugger. The program being executed is aborted.n(ext)- continue execution until the next line in the current function is reached or it returns.
For more information about Python debugger see : pdb documentation
In test scenario you can add (Given-When-Then) trace
step, which works exactly the same, and stops test between steps.
- Some of the
test_run.pyflags are outdated and not used. They should be checked and eventually removed. - Known issues section in GUI README.
- Known issues section in Mixed README.
- Known issues section in Oneclient README.