diff --git a/.gitignore b/.gitignore index 720bb258..82ca1156 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ **/log.html **/output.xml **/report.html +**/dockerlogs*.tar.gz # ignore pycache under any path **/__pycache__ diff --git a/robot/resources/lib/neofs.py b/robot/resources/lib/neofs.py index 6548219e..08aa4156 100644 --- a/robot/resources/lib/neofs.py +++ b/robot/resources/lib/neofs.py @@ -18,7 +18,6 @@ import shutil import time from datetime import datetime - from common import * ROBOT_AUTO_KEYWORDS = False diff --git a/robot/resources/lib/utility_keywords.py b/robot/resources/lib/utility_keywords.py index cc60f26a..f53eda29 100644 --- a/robot/resources/lib/utility_keywords.py +++ b/robot/resources/lib/utility_keywords.py @@ -7,12 +7,11 @@ import uuid from robot.api.deco import keyword from robot.api import logger +from robot.libraries.BuiltIn import BuiltIn from common import * ROBOT_AUTO_KEYWORDS = False -# TODO: get this variable from env -LOGS_DIR = 'artifacts/' @keyword('Generate file of bytes') def generate_file_of_bytes(size: str) -> str: @@ -30,12 +29,13 @@ def generate_file_of_bytes(size: str) -> str: @keyword('Get Docker Logs') def get_container_logs(testcase_name: str) -> None: client = docker.APIClient(base_url='unix://var/run/docker.sock') - tar_name = f"{LOGS_DIR}/dockerlogs({testcase_name}).tar.gz" + logs_dir = BuiltIn().get_variable_value("${OUTPUT_DIR}") + tar_name = f"{logs_dir}/dockerlogs({testcase_name}).tar.gz" tar = tarfile.open(tar_name, "w:gz") for container in client.containers(): container_name = container['Names'][0][1:] if client.inspect_container(container_name)['Config']['Domainname'] == "neofs.devenv": - file_name = f"{LOGS_DIR}/docker_log_{container_name}" + file_name = f"{logs_dir}/docker_log_{container_name}" with open(file_name,'wb') as out: out.write(client.logs(container_name)) logger.info(f"Collected logs from container {container_name}") diff --git a/robot/testsuites/integration/network/networkinfor_rpc_method.robot b/robot/testsuites/integration/network/networkinfor_rpc_method.robot new file mode 100644 index 00000000..5a7d3dd5 --- /dev/null +++ b/robot/testsuites/integration/network/networkinfor_rpc_method.robot @@ -0,0 +1,92 @@ +*** Settings *** +Variables ../../../variables/common.py + +Library Collections +Library Process +Library String +Library ${KEYWORDS}/contract_keywords.py + +Resource ../${RESOURCES}/setup_teardown.robot + +*** Variables *** +${SN_01_ADDR} = s01.neofs.devenv:8080 +${SN_02_ADDR} = s02.neofs.devenv:8080 + +*** Test cases *** +NetworkInfo RPC Method + [Documentation] Testcase to check NetworkInfo RPC method. + [Tags] RPC NeoFS NeoCLI NetworkInfo + [Timeout] 10 min + + [Setup] Setup + + ###################################################################### + # Checking if the command returns equal results for two storage nodes + ###################################################################### + + ${RESULT1_S01} Run Process neofs-cli netmap netinfo -r ${SN_01_ADDR} -k ${MAINNET_WALLET_WIF} shell=True + Should Be Equal As Integers ${RESULT1_S01.rc} 0 + ${RESULT1_S02} Run Process neofs-cli netmap netinfo -r ${SN_02_ADDR} -k ${MAINNET_WALLET_WIF} shell=True + Should Be Equal As Integers ${RESULT1_S02.rc} 0 + + ############################################# + # Checking if morph magic number is relevant + ############################################# + + ${NETWORK_MAGIC_S01} = Parse Magic ${RESULT1_S01.stdout} + Should Be Equal ${NETWORK_MAGIC_S01} ${MORPH_MAGIC} + + ${NETWORK_MAGIC_S02} = Parse Magic ${RESULT1_S02.stdout} + Should Be Equal ${NETWORK_MAGIC_S02} ${MORPH_MAGIC} + + ####################################################################### + # Checking if epoch numbers requested from two storage nodes are equal + ####################################################################### + + ${EPOCH1_S01} = Parse Epoch ${RESULT1_S01.stdout} + ${EPOCH1_S02} = Parse Epoch ${RESULT1_S02.stdout} + Should Be Equal As Integers ${EPOCH1_S01} ${EPOCH1_S02} + + ######################################## + # Ticking epoch and getting new netinfo + ######################################## + + Tick Epoch + + ${RESULT2_S01} Run Process neofs-cli netmap netinfo -r ${SN_01_ADDR} -k ${MAINNET_WALLET_WIF} shell=True + Should Be Equal As Integers ${RESULT2_S01.rc} 0 + ${RESULT2_S02} Run Process neofs-cli netmap netinfo -r ${SN_02_ADDR} -k ${MAINNET_WALLET_WIF} shell=True + Should Be Equal As Integers ${RESULT2_S02.rc} 0 + + Should Be Equal As Strings ${RESULT2_S01.stdout} ${RESULT2_S02.stdout} + + ${EPOCH2_S01} = Parse Epoch ${RESULT2_S01.stdout} + + ################################################################# + # Checking if the second epoch value is more than the first by 1 + ################################################################# + + ${NEW_EPOCH} = Evaluate ${EPOCH1_S01}+${1} + Should Be Equal ${EPOCH2_S01} ${NEW_EPOCH} + + + [Teardown] Teardown network_rpc_method + +*** Keywords *** + +Parse Magic + [Arguments] ${RESULT_STDOUT} + @{MAGIC} = Split String ${RESULT_STDOUT} ${\n} + ${NETWORK_MAGIC} = Get From List ${MAGIC} ${1} + @{MAGIC_INFO} = Split String ${NETWORK_MAGIC} ${SPACE} + ${MAGIC_VALUE} = Get From List ${MAGIC_INFO} ${4} + [Return] ${MAGIC_VALUE} + +Parse Epoch + [Arguments] ${RESULT_STDOUT} + @{EPOCH} = Split String ${RESULT_STDOUT} ${\n} + ${NETWORK_EPOCH} = Get From List ${EPOCH} ${0} + @{EPOCH_INFO} = Split String ${NETWORK_EPOCH} ${SPACE} + ${EPOCH_VALUE} = Get From List ${EPOCH_INFO} ${1} + ${EPOCH_VALUE_INT} = Convert To Integer ${EPOCH_VALUE} + [Return] ${EPOCH_VALUE_INT} diff --git a/robot/variables/common.py b/robot/variables/common.py index 230a4708..51db8df1 100644 --- a/robot/variables/common.py +++ b/robot/variables/common.py @@ -44,3 +44,5 @@ NEOFS_CONTRACT = (os.getenv("NEOFS_CONTRACT") if os.getenv("NEOFS_CONTRACT") COMMON_PLACEMENT_RULE = "REP 2 IN X CBF 1 SELECT 2 FROM * AS X" ASSETS_DIR = os.getenv("ASSETS_DIR", "TemporaryDir/") + +MORPH_MAGIC = os.environ["MORPH_MAGIC"]