k.sosnovskikh
Find a file
Vladimir Domnich 3df12e2869 [#3] Add tools required to build PyPI package
Signed-off-by: Vladimir Domnich <v.domnich@yadro.com>
2022-09-28 13:10:35 +04:00
src/neofs_testlib [#3] Add tools required to build PyPI package 2022-09-28 13:10:35 +04:00
tests [#3] Move source code of testlib to src directory 2022-09-28 13:10:35 +04:00
.gitignore [#3] Add tools required to build PyPI package 2022-09-28 13:10:35 +04:00
.pre-commit-config.yaml Implement basic version of ssh shell 2022-09-09 17:53:36 +03:00
LICENSE Initial commit 2022-08-24 16:36:00 +03:00
pyproject.toml [#3] Add tools required to build PyPI package 2022-09-28 13:10:35 +04:00
README.md [#3] Add tools required to build PyPI package 2022-09-28 13:10:35 +04:00
requirements.txt [#3] Add tools required to build PyPI package 2022-09-28 13:10:35 +04:00

neofs-testlib

This library provides building blocks and utilities to facilitate development of automated tests for NeoFS system.

Installation

Library can be installed via pip:

$ pip install neofs-testlib

Library structure

The library provides the following primary components:

  • cli - wrappers on top of neoFS command-line tools. These wrappers execute on a shell and provide type-safe interface for interacting with the tools.
  • reporter - abstraction on top of test reporting tool like Allure. Components of the library will report their steps and attach artifacts to the configured reporter instance.
  • shell - shells that can be used to execute commands. Currently library provides local shell (on machine that runs the code) or SSH shell that connects to a remote machine via SSH.

Contributing

Any contributions to the library should conform to the contribution guideline.

Development Environment

To setup development environment for neofs-testlib, please, take the following steps:

  1. Prepare virtualenv
$ virtualenv --python=python3.9 venv
$ source venv/bin/activate
  1. Install all dependencies:
$ pip install -r requirements.txt
  1. Setup pre-commit hooks to run code formatters on staged files before you run a git commit command:
$ pre-commit install

Optionally you might want to integrate code formatters with your code editor to apply formatters to code files as you go:

  • isort is supported by PyCharm, VS Code. Plugins exist for other IDEs/editors as well.
  • black can be integrated with multiple editors, please, instructions are available here.

Unit Tests

Before submitting any changes to the library, please, make sure that all unit tests are passing. To run the tests, please, use the following command:

$ python -m unittest discover --start-directory tests

To enable tests that interact with SSH server, please, setup SSH server and set the following environment variables before running the tests:

SSH_SHELL_HOST = <address of the server>
SSH_SHELL_LOGIN = <login that has permissions to run python3 on the server>
SSH_SHELL_PRIVATE_KEY_PATH = <path to SSH private key on your machine>
SSH_SHELL_PRIVATE_KEY_PASSPHRASE = <passphrase for the SSH private key>

Editable installation

If you would like to modify code of the library in the integration with your test suite, you can use editable installation. For that, in virtual environment of your test suite (not in the virtual environment of the testlib itself!) run the following command (path to neofs-testlib directory might be different on your machine):

$ pip install -e ../neofs-testlib

Building and publishing package

To build Python package of the library, please run the following command in the library root directory:

$ python -m build

This command will put wheel file and source archive under dist directory.

To check that package description will be correctly rendered at PyPI, please, use command:

$ twine check dist/*

To upload package to test PyPI, please, use command:

$ twine upload -r testpypi dist/*

It will prompt for your username and password. You would need to create test PyPI account in order to execute it.

To upload package to actual PyPI, please, use command:

$ twine upload dist/*

It will prompt for your username and password. You would need to create PyPI account in order to execute it.