This repo contains functional integration tests for NeoFS.
Tests can be found under pytest_tests/tests
directory.
We use pytest.
- Fix OpenSSL ripemd160
Hashlib uses OpenSSL for ripemd160 and apparently OpenSSL disabled some older crypto algos around version 3.0 in November 2021. All the functions are still there but require manual enabling. See openssl/openssl#16994
But we use ripemd160 for tests.
For ripemd160 to be supported, make sure that the config file /usr/lib/ssl/openssl.cnf
contains following lines:
openssl_conf = openssl_init
[openssl_init]
providers = provider_sect
[provider_sect]
default = default_sect
legacy = legacy_sect
[default_sect]
activate = 1
[legacy_sect]
activate = 1
There is also a script that does this for you - sudo python ./tools/src/openssl_config_fix.py
- Create and activate venv with dependencies from requirements.txt. We've put some basics into the makefile target:
$ make venv.pytest
$ . venv.pytest/bin/activate
But you can use any other way you want to create venv. If you don't know what venv is, please, check - https://docs.python.org/3/library/venv.html
-
Just run the test -
pytest -s -k test_get_object_api pytest_tests/tests/object/test_object_api.py
-
Everything should work out of the box, if not - check the rest of this README. If nothing useful there - feel free to open a github issue.
For reporting we use allure report and if you want to get it, take the following steps:
- Run a test with
--alluredir
parameter to specify a dir where allure report json files will be saved.
pytest --alluredir my-allure-234 -s pytest_tests/tests/services/rest_gate/test_rest_bearer.py
- After the test you will see a bunch of json files inside a directory from
--alluredir
. Now we need to convert them into nice and pretty web page. To do this you need allure cli:
Installation for Linux: instruction Installation for macOS: instruction
- To generate the report:
$ allure serve my-allure-123
You will be redirected to your browser and a web page with allure report will be opened.
Tests deploy test environment out of a set of binaries and run them as a separate processes.
By default these binaries are downloaded automatically.
List of all required binaries with corresponding URLs can be found here - neofs-testlib/neofs_testlib/env/templates/neofs_env_config.yaml
.
To use a patched binary for tests just place it to the repo root directory.
Config files for binaries are located here - neofs-testlib/neofs_testlib/env/templates
.
If you are going to run tests several times in the same dev environment,
you can use the --persist-env
key to initiate keeping the test environment.
As a result, you'll find something like Persist env at: env_files/*
in the report.
For example:
[MainThread] 2024-04-27 18:31:55 [INFO] Persist env at: env_files/persisted_env_awxyrbxdwu
After that, you can run tests faster by adding the --load-env
flag along with
the received value. This way you won't waste time redeploy the environment.
For example:
pytest -s pytest_tests/tests/services/rest_gate/test_rest_bearer.py --load-env env_files/persisted_env_awxyrbxdwu
Custom pytest marks used in tests:
sanity
- a short subset of tests to ensure basic NeoFS functionality works.
Tests are located under pytest_tests/tests
.
Different libraries used by tests are located under pytest_tests/lib/
and neofs_testlib/
.
At this moment, there is no logic behind libraries location.
But it was assumed that common python libraries that can be useful in other projects should be placed under neofs_testlib/
.
Other projects (e.g. s3-tests) use git submodules to copy the whole repo.
We use ruff. All PRs are automatically checked.
So, please, install it in your IDE to properly format the code.
We also have some pre-commit hooks to run ruff on staged files before you run a git commit
command, install them with:
$ pre-commit install
Main action is located here - .github/workflows/system-tests.yml
.
Be careful with updating since it is used throughout https://github.com/nspcc-dev
. Be sure that all dependent workflows work.
Feel free to contribute to this project after reading the contributing guidelines.
Before starting to work on a certain topic, create a new issue first, describing the feature/topic you are going to implement.