[#163] Setup and Teardown restart dev-env

Signed-off-by: Elizaveta Chichindaeva <elizaveta@nspcc.ru>
This commit is contained in:
Elizaveta Chichindaeva 2022-01-10 14:02:57 +03:00 committed by Anastasia Prasolova
parent bd9507a19e
commit 0d86352cbe
7 changed files with 49 additions and 13 deletions

View file

@ -42,10 +42,8 @@ Test cases are designed to run on Python 3.8.
## Run ## Run
Execute `./run.sh` script. It will run all the tests available in this repo. To run an arbitrary UserScenario or testcase(s), you need to run the command: To run an arbitrary UserScenario or testcase, you need to run the command:
`./run.sh robot/testsuites/integration/<UserScenario>` or `./run.sh robot/testsuites/integration/<UserScenario>/<testcase>.robot` `robot --outputdir artifacts/ robot/testsuites/integration/<UserScenario>` or `robot --outputdir artifacts/ robot/testsuites/integration/<UserScenario>/<testcase>.robot`
Logs will be saved in the artifacts/ directory after tests with any of the statuses are completed.
The following UserScenarios and testcases are available for execution: The following UserScenarios and testcases are available for execution:

View file

@ -13,14 +13,14 @@ from robot.api import logger
ROBOT_AUTO_KEYWORDS = False ROBOT_AUTO_KEYWORDS = False
def _cmd_run(cmd): def _cmd_run(cmd, timeout=30):
""" """
Runs given shell command <cmd>, in case of success returns its stdout, Runs given shell command <cmd>, in case of success returns its stdout,
in case of failure returns error message. in case of failure returns error message.
""" """
try: try:
compl_proc = subprocess.run(cmd, check=True, universal_newlines=True, compl_proc = subprocess.run(cmd, check=True, universal_newlines=True,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, timeout=30, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, timeout=timeout,
shell=True) shell=True)
output = compl_proc.stdout output = compl_proc.stdout
logger.info(f"Output: {output}") logger.info(f"Output: {output}")

View file

@ -1,16 +1,17 @@
#!/usr/bin/python3.8 #!/usr/bin/python3.8
import docker
import os import os
import tarfile import tarfile
import uuid import uuid
import docker
from neo3 import wallet from neo3 import wallet
from robot.api.deco import keyword from robot.api.deco import keyword
from robot.api import logger from robot.api import logger
from robot.libraries.BuiltIn import BuiltIn from robot.libraries.BuiltIn import BuiltIn
from common import * from common import *
from cli_helpers import _cmd_run
ROBOT_AUTO_KEYWORDS = False ROBOT_AUTO_KEYWORDS = False
@ -48,6 +49,32 @@ def get_container_logs(testcase_name: str) -> None:
def wif_to_binary(wif: str) -> str: def wif_to_binary(wif: str) -> str:
priv_key = wallet.Account.private_key_from_wif(wif) priv_key = wallet.Account.private_key_from_wif(wif)
path = f"{os.getcwd()}/{ASSETS_DIR}/{str(uuid.uuid4())}" path = f"{os.getcwd()}/{ASSETS_DIR}/{str(uuid.uuid4())}"
with open(path, "wb") as f: with open(path, "wb") as out:
f.write(priv_key) out.write(priv_key)
return path return path
@keyword('Make Up')
def make_up(services=['']):
test_path = os.getcwd()
dev_path = os.getenv('DEVENV_PATH', '../neofs-dev-env')
os.chdir(dev_path)
if services != ['']:
for service in services:
cmd = f'make up/{service}'
_cmd_run(cmd, timeout=80)
else:
cmd = f'make up/basic; make update.max_object_size val={SIMPLE_OBJ_SIZE}'
_cmd_run(cmd, timeout=80)
os.chdir(test_path)
@keyword('Make Down')
def make_down():
test_path = os.getcwd()
dev_path = os.getenv('DEVENV_PATH', '../neofs-dev-env')
os.chdir(dev_path)
cmd = 'make down; make clean'
_cmd_run(cmd)
os.chdir(test_path)

View file

@ -7,9 +7,12 @@ Library utility_keywords.py
*** Keywords *** *** Keywords ***
Setup Setup
[Arguments]
Make Up
Create Directory ${ASSETS_DIR} Create Directory ${ASSETS_DIR}
Teardown Teardown
[Arguments] ${LOGFILE} [Arguments] ${LOGFILE}
Remove Directory ${ASSETS_DIR} True Remove Directory ${ASSETS_DIR} True
Get Docker Logs ${LOGFILE} Get Docker Logs ${LOGFILE}
Make Down

View file

@ -7,6 +7,7 @@ Library payment_neogo.py
Library gates.py Library gates.py
Library wallet_keywords.py Library wallet_keywords.py
Library rpc_call_keywords.py Library rpc_call_keywords.py
Library utility_keywords.py
Resource payment_operations.robot Resource payment_operations.robot
Resource setup_teardown.robot Resource setup_teardown.robot
@ -16,6 +17,7 @@ ${PLACEMENT_RULE} = REP 1 IN X CBF 1 SELECT 1 FROM * AS X
${TRANSFER_AMOUNT} = ${6} ${TRANSFER_AMOUNT} = ${6}
${DEPOSIT_AMOUNT} = ${5} ${DEPOSIT_AMOUNT} = ${5}
${CONTAINER_WAIT_INTERVAL} = 1 min ${CONTAINER_WAIT_INTERVAL} = 1 min
@{INCLUDE_SVC} = http_gate
*** Test cases *** *** Test cases ***
@ -24,6 +26,7 @@ NeoFS HTTP Gateway
[Timeout] 5 min [Timeout] 5 min
[Setup] Setup [Setup] Setup
Make Up ${INCLUDE_SVC}
${WALLET} ${ADDR} ${WIF} = Prepare Wallet And Deposit ${WALLET} ${ADDR} ${WIF} = Prepare Wallet And Deposit

View file

@ -16,6 +16,7 @@ Resource payment_operations.robot
${DEPOSIT} = ${30} ${DEPOSIT} = ${30}
${WIF} = ${MAINNET_WALLET_WIF} ${WIF} = ${MAINNET_WALLET_WIF}
${DEPOSIT_TIMEOUT}= 30s ${DEPOSIT_TIMEOUT}= 30s
@{INCLUDE_SVC} = s3_gate
*** Test cases *** *** Test cases ***
Buckets in NeoFS S3 Gateway Buckets in NeoFS S3 Gateway
@ -23,6 +24,7 @@ Buckets in NeoFS S3 Gateway
[Timeout] 10 min [Timeout] 10 min
[Setup] Setup [Setup] Setup
Make Up ${INCLUDE_SVC}
${WALLET} ${ADDR} ${WIF} = Prepare Wallet And Deposit ${WALLET} ${ADDR} ${WIF} = Prepare Wallet And Deposit
${FILE_S3} = Generate file of bytes ${COMPLEX_OBJ_SIZE} ${FILE_S3} = Generate file of bytes ${COMPLEX_OBJ_SIZE}

View file

@ -7,12 +7,14 @@ Library payment_neogo.py
Library gates.py Library gates.py
Library wallet_keywords.py Library wallet_keywords.py
Library contract_keywords.py Library contract_keywords.py
Library utility_keywords.py
Resource setup_teardown.robot Resource setup_teardown.robot
*** Variables *** *** Variables ***
${DEPOSIT_AMOUNT} = ${5} ${DEPOSIT_AMOUNT} = ${5}
${WIF} = ${MAINNET_WALLET_WIF} ${WIF} = ${MAINNET_WALLET_WIF}
@{INCLUDE_SVC} = s3_gate
*** Test cases *** *** Test cases ***
Objects in NeoFS S3 Gateway Objects in NeoFS S3 Gateway
@ -21,6 +23,7 @@ Objects in NeoFS S3 Gateway
[Timeout] 10 min [Timeout] 10 min
[Setup] Setup [Setup] Setup
Make Up ${INCLUDE_SVC}
${WALLET} ${ADDR} = Init Wallet from WIF ${ASSETS_DIR} ${WIF} ${WALLET} ${ADDR} = Init Wallet from WIF ${ASSETS_DIR} ${WIF}
${TX_DEPOSIT} = NeoFS Deposit ${WIF} ${DEPOSIT_AMOUNT} ${TX_DEPOSIT} = NeoFS Deposit ${WIF} ${DEPOSIT_AMOUNT}