go.ligato.io/vpp-agent/v3@v3.5.0/tests/robot/libraries/setup-teardown.robot (about) 1 [Documentation] Reusable keywords for testsuite setup and teardown 2 3 *** Settings *** 4 Library String 5 Library RequestsLibrary 6 Library SSHLibrary timeout=15s loglevel=TRACE 7 #Resource ssh.robot 8 Resource ${ENV}_setup-teardown.robot 9 10 *** Variables *** 11 ${VM_SSH_ALIAS_PREFIX} vm_ 12 ${snapshot_num} 0 13 @{NODES} 14 15 *** Keywords *** 16 Open SSH Connection 17 [Arguments] ${name} ${ip} ${user} ${pswd} 18 Open Connection ${ip} ${name} 19 Run Keyword If "${pswd}"!="rsa_id" Login ${user} ${pswd} 20 Run Keyword If "${pswd}"=="rsa_id" SSHLibrary.Login_With_Public_Key ${user} %{HOME}/.ssh/id_rsa any 21 22 Testsuite Setup 23 Discard old results 24 #Remove File ${OUTPUTDIR}/ssh.log 25 Enable SSH Logging ${OUTPUTDIR}/ssh.log 26 Open Connection To Docker Host 27 Create Connections For ETCD And Kafka 28 Start ETCD Server 29 Get Env And SW Version docker 30 Make Datastore Snapshots startup 31 Copy File To Machine docker ${CURDIR}/../tools/vpp_api_executor.py ${DOCKER_PAPI_FOLDER}/vpp_api_executor.py 32 33 Testsuite Teardown 34 Make Datastore Snapshots teardown 35 Remove All Nodes 36 Stop ETCD Server 37 Get Connections 38 Close All Connections 39 Check Agent Logs For Errors 40 #Copy File ${OUTPUTDIR}/ssh.log ${RESULTS_FOLDER_SUITE}/ssh.log 41 42 Test Setup 43 Open Connection To Docker Host 44 Create Connections For ETCD And Kafka 45 Start ETCD Server 46 Make Datastore Snapshots startup 47 48 Test Teardown 49 Make Datastore Snapshots teardown 50 Stop ETCD Server 51 Remove All Nodes 52 Get Connections 53 Close All Connections 54 55 Discard old results 56 [Documentation] Remove and re-create ${RESULTS_FOLDER} and ${RESULTS_FOLDER}/SUTIE_NAME specific folder. 57 Remove File ${RESULTS_FOLDER}/*.txt 58 Remove File ${RESULTS_FOLDER}/*.log 59 #Create Directory ${RESULTS_FOLDER} 60 Remove Directory ${RESULTS_FOLDER_SUITE} recursive=true 61 Create Directory ${RESULTS_FOLDER} 62 Create Directory ${RESULTS_FOLDER_SUITE} 63 64 65 Log All SSH Outputs 66 ... Logs all connections outputs 67 [Timeout] 120s 68 :FOR ${id} IN @{NODES} 69 \ Log ${id} Output 70 \ Run Keyword If "vpp" in "${id}" Log ${id}_term Output 71 \ Run Keyword If "vpp" in "${id}" Log ${id}_vat Output 72 Log docker Output 73 74 Log ${machine} Output 75 [Documentation] *Log ${machine} Output* 76 ... Logs actual ${machine} output from begining 77 Switch Connection ${machine} 78 ${out}= Read delay=${SSH_READ_DELAY}s 79 Append To File ${RESULTS_FOLDER}/output_${machine}.log ${out} 80 Append To File ${RESULTS_FOLDER_SUITE}/output_${machine}.log ${out} 81 82 Get Machine Status 83 [Arguments] ${machine} 84 [Documentation] *Get Machine Status ${machine}* 85 ... Executing df, free, ifconfig -a, ps -aux... on ${machine} 86 Execute On Machine ${machine} df 87 Execute On Machine ${machine} free 88 Execute On Machine ${machine} ifconfig -a 89 Execute On Machine ${machine} ps aux 90 Execute On Machine ${machine} echo $PATH 91 92 Get Env And SW Version 93 [Arguments] ${machine} 94 [Documentation] *Get Machine Status ${machine}* 95 ... Executing df, free, ifconfig -a, ps -aux... on ${machine} 96 Execute On Machine ${machine} env 97 Execute On Machine ${machine} curl -V 98 99 Open Connection To Docker Host 100 Open SSH Connection docker ${DOCKER_HOST_IP} ${DOCKER_HOST_USER} ${DOCKER_HOST_PSWD} 101 Get Machine Status docker 102 Execute On Machine docker ${DOCKER_COMMAND} images 103 Execute On Machine docker ${DOCKER_COMMAND} ps -as 104 105 Create Connections For ETCD And Kafka 106 Open SSH Connection etcd ${DOCKER_HOST_IP} ${DOCKER_HOST_USER} ${DOCKER_HOST_PSWD} 107 #Open SSH Connection kafka ${DOCKER_HOST_IP} ${DOCKER_HOST_USER} ${DOCKER_HOST_PSWD} 108 109 Make Datastore Snapshots 110 [Arguments] ${tag}=notag 111 ${prefix}= Create Next Snapshot Prefix 112 Take ETCD Snapshots ${prefix}_${tag} 113 114 Take ETCD Snapshots 115 [Arguments] ${tag} ${machine}=docker 116 ${dump}= Get ETCD Dump ${machine} 117 Append To File ${RESULTS_FOLDER}/etcd_dump-${tag}.txt ${dump} 118 Append To File ${RESULTS_FOLDER_SUITE}/etcd_dump-${tag}.txt ${dump} 119 ${errors}= Get Lines Containing String ${dump} /error/ 120 ${errorscount}= Get Line Count ${errors} 121 ${nullerrors}= Get Regexp Matches ${dump} /error/.*\nnull\n 122 ${nullerrorscount}= Get Length ${nullerrors} 123 Run Keyword If ${errorscount} > 0 and ${errorscount} != ${nullerrorscount} Log Errors detected in keys: ${errors} level=WARN 124 125 Create Next Snapshot Prefix 126 ${prefix}= Evaluate str(${snapshot_num}).zfill(3) 127 ${snapshot_num}= Evaluate ${snapshot_num}+1 128 Set Global Variable ${snapshot_num} 129 [Return] ${prefix} 130 131 Check Agent Logs For Errors 132 @{logs}= OperatingSystem.List Files In Directory ${RESULTS_FOLDER}/ *_container_agent.log 133 :FOR ${log} IN @{logs} 134 \ ${data}= OperatingSystem.Get File ${RESULTS_FOLDER}/${log} 135 \ Should Not Contain ${data} exited: agent (exit status 136 \ Should Not Contain ${data} exited: vpp (exit status