(#111): python virtualenv for users
Signed-off-by: anastasia prasolova <anastasia@nspcc.ru>
This commit is contained in:
parent
7638c10a20
commit
b95f6bd7c8
7 changed files with 88 additions and 33 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -9,3 +9,4 @@
|
||||||
TemporaryDir/*
|
TemporaryDir/*
|
||||||
artifacts/*
|
artifacts/*
|
||||||
docs/*
|
docs/*
|
||||||
|
venv.*/*
|
||||||
|
|
28
Makefile
28
Makefile
|
@ -1,18 +1,30 @@
|
||||||
|
#!/usr/bin/make -f
|
||||||
|
|
||||||
.DEFAULT_GOAL := help
|
.DEFAULT_GOAL := help
|
||||||
|
|
||||||
OUTPUT_DIR = artifacts/
|
SHELL = bash
|
||||||
KEYWORDS_PATH = ../neofs-keywords
|
|
||||||
KEYWORDS_REPO = git@github.com:nspcc-dev/neofs-keywords.git
|
|
||||||
|
|
||||||
run: deps
|
OUTPUT_DIR = artifacts/
|
||||||
|
KEYWORDS_REPO = git@github.com:nspcc-dev/neofs-keywords.git
|
||||||
|
VENVS = $(shell ls -1d venv/*/ | sort -u | xargs basename -a)
|
||||||
|
|
||||||
|
.PHONY: all
|
||||||
|
all: venvs
|
||||||
|
|
||||||
|
include venv_template.mk
|
||||||
|
|
||||||
|
run: venvs
|
||||||
@echo "⇒ Test Run"
|
@echo "⇒ Test Run"
|
||||||
@robot --timestampoutputs --outputdir $(OUTPUT_DIR) robot/testsuites/integration/
|
@robot --timestampoutputs --outputdir $(OUTPUT_DIR) robot/testsuites/integration/
|
||||||
|
|
||||||
deps: $(KEYWORDS_PATH)
|
.PHONY: venvs
|
||||||
|
venvs:
|
||||||
|
$(foreach venv,$(VENVS),venv.$(venv))
|
||||||
|
|
||||||
$(KEYWORDS_PATH):
|
$(foreach venv,$(VENVS),$(eval $(call VENV_template,$(venv))))
|
||||||
@echo "Cloning keywords repo"
|
|
||||||
@git clone $(KEYWORDS_REPO) $(KEYWORDS_PATH)
|
clean:
|
||||||
|
rm -rf venv.*
|
||||||
|
|
||||||
help:
|
help:
|
||||||
@echo "⇒ run Run testcases ${R}"
|
@echo "⇒ run Run testcases ${R}"
|
||||||
|
|
31
README.md
31
README.md
|
@ -22,17 +22,7 @@
|
||||||
- `sudo cp bin/neo-go /usr/local/bin/neo-go`
|
- `sudo cp bin/neo-go /usr/local/bin/neo-go`
|
||||||
or download binary from releases: https://github.com/nspcc-dev/neo-go/releases
|
or download binary from releases: https://github.com/nspcc-dev/neo-go/releases
|
||||||
|
|
||||||
4. Install Testcases dependencies
|
4. Clone neofs-dev-env and prepare it
|
||||||
- `pip3.8 install -r requirements.txt`
|
|
||||||
- `make deps`
|
|
||||||
|
|
||||||
Test cases are designed to run on Python 3.8.
|
|
||||||
|
|
||||||
### Run
|
|
||||||
|
|
||||||
0. Add keywords repo to PYTHONPATH `export PYTHONPATH=${PYTHONPATH}:~/neofs-keywords/lib::~/neofs-keywords/robot`
|
|
||||||
|
|
||||||
1. Clone neofs-dev-env and prepare it
|
|
||||||
|
|
||||||
```
|
```
|
||||||
# clean up obsolete volumes
|
# clean up obsolete volumes
|
||||||
|
@ -43,25 +33,18 @@ make up
|
||||||
# decrease maximum object size to 1000 bytes
|
# decrease maximum object size to 1000 bytes
|
||||||
make update.max_object_size val=1000
|
make update.max_object_size val=1000
|
||||||
```
|
```
|
||||||
Also disable Storage Nodes Morph cache
|
|
||||||
|
|
||||||
|
5. Build virtual env
|
||||||
```
|
```
|
||||||
export NEOFS_MORPH_DISABLE_CACHE=true
|
make venv.localtest
|
||||||
|
. venv.localtest/bin/activate
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Export neofs-dev-env variables into the shell where you are going to run tests
|
Test cases are designed to run on Python 3.8.
|
||||||
|
|
||||||
```
|
### Run
|
||||||
cd neofs-dev-env
|
|
||||||
export `make env`
|
|
||||||
```
|
|
||||||
|
|
||||||
3. Execute the command `make run`
|
Execute the command `make run`. Logs will be available in the artifacts/ directory after tests with any of the statuses are completed.
|
||||||
|
|
||||||
4. Logs will be available in the artifacts/ directory after tests with any of the statuses are completed.
|
|
||||||
|
|
||||||
|
|
||||||
### Running an arbitrary test case
|
|
||||||
|
|
||||||
To run an arbitrary UserScenario or testcase, you need to run the command:
|
To run an arbitrary UserScenario or testcase, you need to run the command:
|
||||||
`robot --outputdir artifacts/ robot/testsuites/integration/<UserScenario>` or `robot --outputdir artifacts/ robot/testsuites/integration/<UserScenario>/<testcase>.robot`
|
`robot --outputdir artifacts/ robot/testsuites/integration/<UserScenario>` or `robot --outputdir artifacts/ robot/testsuites/integration/<UserScenario>/<testcase>.robot`
|
||||||
|
|
26
build_assets/activate.patch
Normal file
26
build_assets/activate.patch
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
diff -urN bin.orig/activate bin/activate
|
||||||
|
--- bin.orig/activate 2018-12-27 14:55:13.916461020 +0900
|
||||||
|
+++ bin/activate 2018-12-27 20:38:35.223248728 +0900
|
||||||
|
@@ -30,6 +30,10 @@
|
||||||
|
unset _OLD_VIRTUAL_PS1
|
||||||
|
fi
|
||||||
|
|
||||||
|
+ # Uset external env variables
|
||||||
|
+ declare -f env_deactivate > /dev/null && env_deactivate
|
||||||
|
+ declare -f venv_deactivate > /dev/null && venv_deactivate
|
||||||
|
+
|
||||||
|
unset VIRTUAL_ENV
|
||||||
|
if [ ! "${1-}" = "nondestructive" ] ; then
|
||||||
|
# Self destruct!
|
||||||
|
@@ -47,6 +51,11 @@
|
||||||
|
PATH="$VIRTUAL_ENV/bin:$PATH"
|
||||||
|
export PATH
|
||||||
|
|
||||||
|
+# Set external variables
|
||||||
|
+if [ -f ${VIRTUAL_ENV}/bin/environment.sh ] ; then
|
||||||
|
+ . ${VIRTUAL_ENV}/bin/environment.sh
|
||||||
|
+fi
|
||||||
|
+
|
||||||
|
# unset PYTHONHOME if set
|
||||||
|
if ! [ -z "${PYTHONHOME+_}" ] ; then
|
||||||
|
_OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME"
|
5
venv/localtest/environment.sh
Normal file
5
venv/localtest/environment.sh
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# DevEnv variables
|
||||||
|
export NEOFS_MORPH_DISABLE_CACHE=true
|
||||||
|
pushd ../neofs-dev-env
|
||||||
|
export `make env`
|
||||||
|
popd
|
8
venv/localtest/requirements.txt
Normal file
8
venv/localtest/requirements.txt
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
robotframework==3.2.1
|
||||||
|
requests==2.25.1
|
||||||
|
pexpect==4.8.0
|
||||||
|
boto3==1.16.33
|
||||||
|
docker==4.4.0
|
||||||
|
botocore==1.19.33
|
||||||
|
urllib3==1.26.3
|
||||||
|
base58==1.0.3
|
20
venv_template.mk
Normal file
20
venv_template.mk
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
define VENV_template
|
||||||
|
venv.$(1): venv.$(1)/bin/activate venv.$(1)/bin/environment.sh
|
||||||
|
|
||||||
|
venv.$(1)/bin/activate: venv/$(1)/requirements.txt
|
||||||
|
@echo "Creating $(1) venv in $$@ from $$<"
|
||||||
|
virtualenv --python=python3.8 --prompt="($(1))" venv.$(1)
|
||||||
|
source venv.$(1)/bin/activate && \
|
||||||
|
pip3.8 install -Ur venv/$(1)/requirements.txt
|
||||||
|
@echo "Cloning keywords repo"
|
||||||
|
git clone $(KEYWORDS_REPO) venv.$(1)/neofs-keywords
|
||||||
|
source venv.$(1)/bin/activate && \
|
||||||
|
pip3.8 install -Ur venv.$(1)/neofs-keywords/requirements.txt
|
||||||
|
@echo "Applying activate script patch"
|
||||||
|
patch -R --dry-run -p1 -s -f -d venv.$(1)/bin/ < build_assets/activate.patch || \
|
||||||
|
patch -p1 -d venv.$(1)/bin/ < build_assets/activate.patch
|
||||||
|
|
||||||
|
venv.$(1)/bin/environment.sh: | venv/$(1)/environment.sh
|
||||||
|
ln -s ../../venv/$(1)/environment.sh venv.$(1)/bin/environment.sh
|
||||||
|
|
||||||
|
endef
|
Loading…
Reference in a new issue