Remove step for iptables installation
Installation of iptables was implemented in environment preparation pipeline and tests do not need to worry about it. Removed conditions that were checking pytest mode vs robot mode, because we got rid of robot tests in this branch of codebase. Signed-off-by: Vladimir Domnich <v.domnich@yadro.com>
This commit is contained in:
parent
0ca45d1ba8
commit
d935c2cafa
4 changed files with 29 additions and 54 deletions
|
@ -6,7 +6,7 @@ import allure
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from common import (STORAGE_NODE_SSH_PRIVATE_KEY_PATH, STORAGE_NODE_SSH_USER,
|
from common import (STORAGE_NODE_SSH_PRIVATE_KEY_PATH, STORAGE_NODE_SSH_USER,
|
||||||
STORAGE_NODE_SSH_PASSWORD, NEOFS_NETMAP_DICT)
|
STORAGE_NODE_SSH_PASSWORD)
|
||||||
from failover_utils import wait_all_storage_node_returned, wait_object_replication_on_nodes
|
from failover_utils import wait_all_storage_node_returned, wait_object_replication_on_nodes
|
||||||
from iptables_helper import IpTablesHelper
|
from iptables_helper import IpTablesHelper
|
||||||
from python_keywords.container import create_container
|
from python_keywords.container import create_container
|
||||||
|
@ -22,25 +22,6 @@ PORTS_TO_BLOCK = [STORAGE_NODE_COMMUNICATION_PORT, STORAGE_NODE_COMMUNICATION_PO
|
||||||
blocked_hosts = []
|
blocked_hosts = []
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
|
||||||
@allure.step('Install iptables if needed')
|
|
||||||
def install_iptables_if_needed():
|
|
||||||
check_command = 'sudo iptables --version'
|
|
||||||
install_command = 'sudo apt-get --yes install iptables'
|
|
||||||
for node_config in NEOFS_NETMAP_DICT.values():
|
|
||||||
host = node_config.get('rpc').split(':')[0]
|
|
||||||
client = HostClient(ip=host, login=STORAGE_NODE_SSH_USER,
|
|
||||||
password=STORAGE_NODE_SSH_PASSWORD,
|
|
||||||
private_key_path=STORAGE_NODE_SSH_PRIVATE_KEY_PATH)
|
|
||||||
with client.create_ssh_connection():
|
|
||||||
try:
|
|
||||||
client.exec(check_command)
|
|
||||||
except AssertionError as err:
|
|
||||||
logger.info(f'Command {check_command} fails with error {err}')
|
|
||||||
client.exec(install_command)
|
|
||||||
client.exec(check_command)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
@allure.step('Restore network')
|
@allure.step('Restore network')
|
||||||
def restore_network():
|
def restore_network():
|
||||||
|
|
|
@ -100,26 +100,24 @@ def _configure_aws_cli(cmd: str, key_id: str, access_key: str, out_format: str =
|
||||||
|
|
||||||
def _attach_allure_log(cmd: str, output: str, return_code: int, start_time: datetime,
|
def _attach_allure_log(cmd: str, output: str, return_code: int, start_time: datetime,
|
||||||
end_time: datetime) -> None:
|
end_time: datetime) -> None:
|
||||||
if 'robot' not in sys.modules:
|
command_attachment = (
|
||||||
command_attachment = (
|
f"COMMAND: '{cmd}'\n"
|
||||||
f"COMMAND: '{cmd}'\n"
|
f'OUTPUT:\n {output}\n'
|
||||||
f'OUTPUT:\n {output}\n'
|
f'RC: {return_code}\n'
|
||||||
f'RC: {return_code}\n'
|
f'Start / End / Elapsed\t {start_time.time()} / {end_time.time()} / {end_time - start_time}'
|
||||||
f'Start / End / Elapsed\t {start_time.time()} / {end_time.time()} / {end_time - start_time}'
|
)
|
||||||
)
|
with allure.step(f'COMMAND: {shorten(cmd, width=60, placeholder="...")}'):
|
||||||
with allure.step(f'COMMAND: {shorten(cmd, width=60, placeholder="...")}'):
|
allure.attach(command_attachment, 'Command execution', allure.attachment_type.TEXT)
|
||||||
allure.attach(command_attachment, 'Command execution', allure.attachment_type.TEXT)
|
|
||||||
|
|
||||||
|
|
||||||
def log_command_execution(cmd: str, output: Union[str, dict]) -> None:
|
def log_command_execution(cmd: str, output: Union[str, dict]) -> None:
|
||||||
logger.info(f'{cmd}: {output}')
|
logger.info(f'{cmd}: {output}')
|
||||||
if 'robot' not in sys.modules:
|
with suppress(Exception):
|
||||||
with suppress(Exception):
|
json_output = json.dumps(output, indent=4, sort_keys=True)
|
||||||
json_output = json.dumps(output, indent=4, sort_keys=True)
|
output = json_output
|
||||||
output = json_output
|
command_attachment = (
|
||||||
command_attachment = (
|
f"COMMAND: '{cmd}'\n"
|
||||||
f"COMMAND: '{cmd}'\n"
|
f'OUTPUT:\n {output}\n'
|
||||||
f'OUTPUT:\n {output}\n'
|
)
|
||||||
)
|
with allure.step(f'COMMAND: {shorten(cmd, width=60, placeholder="...")}'):
|
||||||
with allure.step(f'COMMAND: {shorten(cmd, width=60, placeholder="...")}'):
|
allure.attach(command_attachment, 'Command execution', allure.attachment_type.TEXT)
|
||||||
allure.attach(command_attachment, 'Command execution', allure.attachment_type.TEXT)
|
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
#!/usr/bin/python3.9
|
#!/usr/bin/python3.9
|
||||||
import sys
|
|
||||||
|
|
||||||
import allure
|
import allure
|
||||||
from robot.api import logger
|
from robot.api import logger
|
||||||
from robot.api.deco import keyword
|
from robot.api.deco import keyword
|
||||||
|
@ -40,12 +38,11 @@ def tick_epoch():
|
||||||
err = str(exc)
|
err = str(exc)
|
||||||
raise RuntimeError("Failed to tick epoch") from exc
|
raise RuntimeError("Failed to tick epoch") from exc
|
||||||
finally:
|
finally:
|
||||||
if 'allure' in sys.modules:
|
allure.attach((
|
||||||
allure.attach((
|
f'COMMAND: {cmd}\n'
|
||||||
f'COMMAND: {cmd}\n'
|
f'OUTPUT:\n {out}\n'
|
||||||
f'OUTPUT:\n {out}\n'
|
f'ERROR: {err}\n'
|
||||||
f'ERROR: {err}\n'
|
), 'Tick Epoch', allure.attachment_type.TEXT)
|
||||||
), 'Tick Epoch', allure.attachment_type.TEXT)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# Otherwise we tick epoch using transaction
|
# Otherwise we tick epoch using transaction
|
||||||
|
|
|
@ -173,10 +173,9 @@ def get_via_http_curl(cid: str, oid: str) -> str:
|
||||||
|
|
||||||
|
|
||||||
def _attach_allure_step(request: str, status_code: int, req_type='GET'):
|
def _attach_allure_step(request: str, status_code: int, req_type='GET'):
|
||||||
if 'allure' in sys.modules:
|
command_attachment = (
|
||||||
command_attachment = (
|
f"REQUEST: '{request}'\n"
|
||||||
f"REQUEST: '{request}'\n"
|
f'RESPONSE:\n {status_code}\n'
|
||||||
f'RESPONSE:\n {status_code}\n'
|
)
|
||||||
)
|
with allure.step(f'{req_type} Request'):
|
||||||
with allure.step(f'{req_type} Request'):
|
allure.attach(command_attachment, f'{req_type} Request', allure.attachment_type.TEXT)
|
||||||
allure.attach(command_attachment, f'{req_type} Request', allure.attachment_type.TEXT)
|
|
||||||
|
|
Loading…
Reference in a new issue