Add makefile target to setup tests to run against remote devenv.

This commit is contained in:
Vladimir Domnich 2022-07-12 12:23:48 +04:00
parent 26ccd9b194
commit 31eab0ffcc
4 changed files with 41 additions and 11 deletions

7
.gitignore vendored
View file

@ -6,8 +6,13 @@
allure_results/*
xunit_results.xml
# ignore pycache under any path
# ignore caches under any path
**/__pycache__
**/.pytest_cache
# ignore work directories and setup files
.setup
.env
TemporaryDir/*
artifacts/*
docs/*

View file

@ -9,11 +9,8 @@ KEYWORDS_REPO = git@github.com:nspcc-dev/neofs-keywords.git
VENVS = $(shell ls -1d venv/*/ | sort -u | xargs basename -a)
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
DEV_IMAGE_PY ?= registry.spb.yadro.com/tools/pytest-neofs-x86_64:6
ifdef DEVENV_SERVICES_PATH
RUN_OPTIONS += -v $(DEVENV_SERVICES_PATH)/chain/node-wallet.json:/wallets/mainnet.json -e MAINNET_WALLET_PATH_HOST="/wallets/mainnet.json"
RUN_OPTIONS += -v $(DEVENV_SERVICES_PATH)/ir/wallet01.json:/wallets/ir.json -e IR_WALLET_PATH="/wallets/ir.json"
endif
SETUP_DIR ?= $(CURDIR)/.setup
DEV_ENV_DEPLOY_DIR ?= /opt/dev-env
ifeq ($(shell uname -s),Darwin)
DOCKER_NETWORK = --network bridge -p 389:389 -p 636:636
@ -50,6 +47,33 @@ pytest-local:
help:
@echo "⇒ run Run testcases ${R}"
.PHONY: setup-for-remote-devenv
setup-for-remote-devenv:
mkdir -p $(SETUP_DIR)
# Download services directory from remote devenv into $(SETUP_DIR)/services
scp -r root@$(DEV_ENV_HOST_NAME):$(DEV_ENV_DEPLOY_DIR)/services $(SETUP_DIR)
# Generate .env file
echo NEO_MAINNET_ENDPOINT=http://$(DEV_ENV_HOST_NAME):30333 > $(CURDIR)/.env
echo MORPH_ENDPOINT=http://$(DEV_ENV_HOST_NAME):30334 >> $(CURDIR)/.env
echo HTTP_GATE=http://$(DEV_ENV_HOST_NAME):81 >> $(CURDIR)/.env
echo S3_GATE=https://$(DEV_ENV_HOST_NAME):8080 >> $(CURDIR)/.env
echo STORAGE_CONTROL_ENDPOINT_1=$(DEV_ENV_HOST_NAME):8181 >> $(CURDIR)/.env
echo STORAGE_CONTROL_ENDPOINT_2=$(DEV_ENV_HOST_NAME):8182 >> $(CURDIR)/.env
echo STORAGE_CONTROL_ENDPOINT_3=$(DEV_ENV_HOST_NAME):8183 >> $(CURDIR)/.env
echo STORAGE_CONTROL_ENDPOINT_4=$(DEV_ENV_HOST_NAME):8184 >> $(CURDIR)/.env
echo STORAGE_RPC_ENDPOINT_1=$(DEV_ENV_HOST_NAME):8081 >> $(CURDIR)/.env
echo STORAGE_RPC_ENDPOINT_2=$(DEV_ENV_HOST_NAME):8082 >> $(CURDIR)/.env
echo STORAGE_RPC_ENDPOINT_3=$(DEV_ENV_HOST_NAME):8083 >> $(CURDIR)/.env
echo STORAGE_RPC_ENDPOINT_4=$(DEV_ENV_HOST_NAME):8084 >> $(CURDIR)/.env
echo NEOFS_ENDPOINT=$(DEV_ENV_HOST_NAME):8081 >> $(CURDIR)/.env
echo STORAGE_WALLET_PATH_1="/.setup/services/storage/wallet01.json"
echo STORAGE_WALLET_PATH_2="/.setup/services/storage/wallet02.json"
echo STORAGE_WALLET_PATH_3="/.setup/services/storage/wallet03.json"
echo STORAGE_WALLET_PATH_4="/.setup/services/storage/wallet04.json"
echo MAINNET_WALLET_PATH="/.setup/services/chain/node-wallet.json" >> $(CURDIR)/.env
echo IR_WALLET_PATH="/.setup/services/ir/wallet01.json" >> $(CURDIR)/.env
ssh root@$(DEV_ENV_HOST_NAME) 'cd $(DEV_ENV_DEPLOY_DIR) && make env | grep NEOFS_IR_CONTRACTS_NEOFS' >> $(CURDIR)/.env
.PHONY: pytest-docker
pytest-docker:
-docker ps
@ -58,11 +82,11 @@ pytest-docker:
docker run -t --rm \
-w /tests \
--name neofs_tests_py \
-e PYTHONPATH="/tests/neofs-keywords/lib:/tests/neofs-keywords/robot:/tests/robot/resources/lib:/tests/robot/resources/lib/python_keywords:/tests/robot/variables:/tests/pytest_tests/helpers" \
-v $(CURDIR):/tests \
-e PYTHONPATH="/tests/neofs-keywords/lib:/tests/neofs-keywords/robot:/tests/robot/resources/lib:/tests/robot/resources/lib/python_keywords:/tests/robot/variables:/tests/pytest_tests/helpers" \
-v $(CURDIR):/tests \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(NEO_BIN_DIR):/neofs \
$(RUN_OPTIONS) \
-v $(SETUP_DIR):/.setup \
--privileged \
$(DOCKER_NETWORK) \
--env-file $(CURDIR)/.env \

View file

@ -46,6 +46,7 @@ def init_wallet_with_address():
yield wallet.init_wallet(ASSETS_DIR)
@pytest.fixture(scope='session')
@allure.title('Prepare tmp directory')
def prepare_tmp_dir():
full_path = f'{os.getcwd()}/{ASSETS_DIR}'

View file

@ -84,10 +84,10 @@ WALLET_CONFIG = f"{os.getcwd()}/neofs_cli_configs/empty_passwd.yml"
MAINNET_WALLET_PATH = os.getenv("MAINNET_WALLET_PATH", f"{DEVENV_PATH}/services/chain/node-wallet.json")
MAINNET_WALLET_CONFIG = f"{os.getcwd()}/neofs_cli_configs/one_wallet_password.yml"
MAINNET_SINGLE_ADDR = 'NfgHwwTi3wHAS8aFAN243C5vGbkYDpqLHP'
MAINNET_WALLET_PASS = 'one'
MAINNET_WALLET_PASS = os.getenv("MAINNET_WALLET_PASS", "one")
IR_WALLET_PATH = os.getenv("IR_WALLET_PATH", f"{DEVENV_PATH}/services/ir/wallet01.json")
IR_WALLET_CONFIG = f"{os.getcwd()}/neofs_cli_configs/one_wallet_password.yml"
IR_WALLET_PASS = 'one'
IR_WALLET_PASS = os.getenv("IR_WALLET_PASS", "one")
STORAGE_NODE_USER = os.getenv('STORAGE_NODE_USER', 'root')
STORAGE_NODE_PWD = os.getenv('STORAGE_NODE_PWD')