Simplify test checks and fixtures:

Remove default SSH key path.
Replace multiple fixtures for file generation with single function.
Rename references to keyword modules.
Update pytest test cases to be consistent with new keywords.
Remove gas balance checks from container operations.
Add logic to run initial gas transfer only if storage is not free.
Remove robot testsuites for s3 and http gateways.
S3 and http tests are covered and will be maintained in the future in pytest.

Signed-off-by: Vladimir Domnich <v.domnich@yadro.com>
This commit is contained in:
Vladimir Domnich 2022-07-05 14:17:36 +04:00 committed by Anastasia Prasolova
parent 8acf738147
commit 6e23e7d454
14 changed files with 122 additions and 335 deletions

View file

@ -11,13 +11,10 @@ from robot.api import deco
import rpc_client
import wallet
from cli_helpers import _cmd_run
from common import (ASSETS_DIR, COMPLEX_OBJ_SIZE, COMMON_PLACEMENT_RULE,
MAINNET_WALLET_PATH, NEO_MAINNET_ENDPOINT, SIMPLE_OBJ_SIZE, REMOTE_HOST, CONTROL_NODE_USER,
CONTROL_NODE_PWD)
from common import (ASSETS_DIR, COMMON_PLACEMENT_RULE, CONTROL_NODE_USER, CONTROL_NODE_PWD,
FREE_STORAGE, MAINNET_WALLET_PATH, NEO_MAINNET_ENDPOINT, REMOTE_HOST)
from payment_neogo import neofs_deposit, transfer_mainnet_gas
from python_keywords.container import create_container
from python_keywords.payment_neogo import get_balance
from python_keywords.utility_keywords import generate_file_and_file_hash
from ssh_helper import HostClient
from wellknown_acl import PUBLIC_ACL
@ -50,7 +47,7 @@ def init_wallet_with_address():
full_path = f'{os.getcwd()}/{ASSETS_DIR}'
os.mkdir(full_path)
yield wallet.init_wallet_w_addr(ASSETS_DIR)
yield wallet.init_wallet(ASSETS_DIR)
shutil.rmtree(full_path)
@ -58,7 +55,6 @@ def init_wallet_with_address():
@pytest.fixture(scope='session')
@allure.title('Prepare wallet and deposit')
def prepare_wallet_and_deposit(init_wallet_with_address):
deposit = 30
local_wallet_path = None
wallet, addr, _ = init_wallet_with_address
logger.info(f'Init wallet: {wallet},\naddr: {addr}')
@ -68,8 +64,10 @@ def prepare_wallet_and_deposit(init_wallet_with_address):
local_wallet_path = os.path.join(ASSETS_DIR, os.path.basename(MAINNET_WALLET_PATH))
ssh_client.copy_file_from_host(MAINNET_WALLET_PATH, local_wallet_path)
transfer_mainnet_gas(wallet, deposit + 1, wallet_path=local_wallet_path or MAINNET_WALLET_PATH)
neofs_deposit(wallet, deposit)
if not FREE_STORAGE:
deposit = 30
transfer_mainnet_gas(wallet, deposit + 1, wallet_path=local_wallet_path or MAINNET_WALLET_PATH)
neofs_deposit(wallet, deposit)
return wallet
@ -90,19 +88,12 @@ def prepare_public_container(prepare_wallet_and_deposit):
def prepare_container_impl(wallet: str, rule=COMMON_PLACEMENT_RULE, basic_acl: str = ''):
balance = get_balance(wallet)
assert balance > 0, f'Expected balance is greater than 0. Got {balance}'
cid = create_container(wallet, rule=rule, basic_acl=basic_acl)
new_balance = get_balance(wallet)
assert new_balance < balance, 'Expected some fee has charged'
return cid, wallet
@allure.step('Wait until transaction accepted in block')
def wait_unitl_transaction_accepted_in_block(tx_id: str):
def wait_until_transaction_accepted_in_block(tx_id: str):
"""
This function return True in case of accepted TX.
Parameters:
@ -126,29 +117,3 @@ def wait_unitl_transaction_accepted_in_block(tx_id: str):
raise e
sleep(sleep_interval)
raise TimeoutError(f'Timeout {sleep_interval * attempts} sec. reached on waiting for transaction accepted')
@pytest.fixture()
@allure.title('Generate files')
def generate_files():
file_name_simple, _ = generate_file_and_file_hash(SIMPLE_OBJ_SIZE)
large_file_name, _ = generate_file_and_file_hash(COMPLEX_OBJ_SIZE)
return file_name_simple, large_file_name
@pytest.fixture()
@allure.title('Generate file')
def generate_file():
file_name_simple, _ = generate_file_and_file_hash(SIMPLE_OBJ_SIZE)
return file_name_simple
@pytest.fixture()
@allure.title('Generate large file')
def generate_large_file():
obj_size = int(os.getenv('BIG_OBJ_SIZE', COMPLEX_OBJ_SIZE))
file_path, file_hash = generate_file_and_file_hash(obj_size)
return file_path, file_hash