frostfs-testcases/Makefile

134 lines
5.8 KiB
Makefile

#!/usr/bin/make -f
.DEFAULT_GOAL := help
SHELL = bash
OUTPUT_DIR = artifacts/
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:7
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
endif
.PHONY: all
all: venvs
include venv_template.mk
run: venvs
@echo "⇒ Test Run"
@robot --timestampoutputs --outputdir $(OUTPUT_DIR) robot/testsuites/integration/
.PHONY: venvs
venvs:
$(foreach venv,$(VENVS),venv.$(venv))
$(foreach venv,$(VENVS),$(eval $(call VENV_template,$(venv))))
submodules:
@git submodule init
@git submodule update --recursive --remote
clean:
rm -rf venv.*
pytest-local:
@echo "⇒ Run Pytest"
export PYTHONPATH=$(ROOT_DIR)/neofs-keywords/lib:$(ROOT_DIR)/neofs-keywords/robot:$(ROOT_DIR)/robot/resources/lib:$(ROOT_DIR)/robot/resources/lib/python_keywords:$(ROOT_DIR)/robot/variables && \
python -m pytest pytest_tests/testsuites/
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: setup-for-sbercloud
setup-for-sbercloud:
mkdir -p $(SETUP_DIR)
# Copy files from configuration directory to setup directory
cp -r $(CONFIG_DIR)/alphabet-wallets $(SETUP_DIR)
cp $(CONFIG_DIR)/config.yaml $(SETUP_DIR)
cp -r $(CONFIG_DIR)/wallets $(SETUP_DIR)
# Generate .env file
# skipped IR_WALLET_PATH, NEOFS_IR_CONTRACTS_NEOFS, not sure whether NEO_MAINNET_ENDPOINT is correct
echo NEO_MAINNET_ENDPOINT=http://$(NODE1):40333 > $(CURDIR)/.env
echo MORPH_ENDPOINT=http://$(NODE1):40332 >> $(CURDIR)/.env
echo HTTP_GATE=http://$(NODE1):8888 >> $(CURDIR)/.env
echo S3_GATE=http://$(NODE1):8084 >> $(CURDIR)/.env
echo STORAGE_CONTROL_ENDPOINT_1=$(NODE1):40332 >> $(CURDIR)/.env
echo STORAGE_CONTROL_ENDPOINT_2=$(NODE2):40332 >> $(CURDIR)/.env
echo STORAGE_CONTROL_ENDPOINT_3=$(NODE3):40332 >> $(CURDIR)/.env
echo STORAGE_CONTROL_ENDPOINT_4=$(NODE4):40332 >> $(CURDIR)/.env
echo NEOFS_ENDPOINT=$(NODE1):8080 >> $(CURDIR)/.env
echo STORAGE_RPC_ENDPOINT_1=$(NODE1):8080 >> $(CURDIR)/.env
echo STORAGE_RPC_ENDPOINT_2=$(NODE2):8080 >> $(CURDIR)/.env
echo STORAGE_RPC_ENDPOINT_3=$(NODE3):8080 >> $(CURDIR)/.env
echo STORAGE_RPC_ENDPOINT_4=$(NODE4):8080 >> $(CURDIR)/.env
echo STORAGE_WALLET_PATH_1="/.setup/wallets/node1-storage.json" >> $(CURDIR)/.env
echo STORAGE_WALLET_PATH_2="/.setup/wallets/node2-storage.json" >> $(CURDIR)/.env
echo STORAGE_WALLET_PATH_3="/.setup/wallets/node3-storage.json" >> $(CURDIR)/.env
echo STORAGE_WALLET_PATH_4="/.setup/wallets/node4-storage.json" >> $(CURDIR)/.env
echo MAINNET_WALLET_PATH="/.setup/alphabet-wallets/az.json" >> $(CURDIR)/.env
# env: files inside storage node to make calls via SSH on that node
echo STORAGE_NODE_BIN_PATH="/usr/local/bin/" >> $(CURDIR)/.env
echo STORAGE_NODE_CONFIG_PATH="/tmp/conf.yaml" >> $(CURDIR)/.env
# env: s3 gateway public key
echo S3_GATE_PUB_KEY=$(shell $(NEO_BIN_DIR)/neo-go wallet dump-keys -w $(CONFIG_DIR)/wallets/node1-s3.json | head -2 | tail -1) >> $(CURDIR)/.env
echo FREE_STORAGE=true >> $(CURDIR)/.env
.PHONY: pytest-docker
pytest-docker:
-docker ps
-docker rm neofs_tests_py
-docker pull $(DEV_IMAGE_PY)
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 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(NEO_BIN_DIR):/neofs \
-v $(SETUP_DIR):/.setup \
--privileged \
$(DOCKER_NETWORK) \
--env-file $(CURDIR)/.env \
$(DEV_IMAGE_PY) \
-v \
-m "$(CI_MARKERS)" \
--color=no \
--junitxml=/tests/xunit_results.xml \
--alluredir=/tests/allure_results \
--setup-show \
/tests/pytest_tests/testsuites