go.ligato.io/vpp-agent/v3@v3.5.0/tests/robot/libraries/linux.robot (about) 1 *** Settings *** 2 Library linux.py 3 4 *** Variables *** 5 ${interface_timeout}= 15s 6 ${PINGSERVER_UDP}= nc -uklp 7 ${PINGSERVER_TCP}= nc -klp 8 ${UDPPING}= nc -uzv 9 ${TCPPING}= nc -zv 10 11 12 *** Keywords *** 13 linux: Get Linux Interfaces 14 [Arguments] ${node} 15 ${out}= Execute In Container ${node} ip a 16 ${ints}= Parse Linux Interfaces ${out} 17 [Return] ${ints} 18 19 linux: Check Veth Interface State 20 [Arguments] ${node} ${name} @{desired_state} 21 ${veth_config}= Get Linux Interface Config As Json ${node} ${name} 22 ${peer}= Set Variable ${veth_config["veth"]["peer_if_name"]} 23 ${ints}= linux: Get Linux Interfaces ${node} 24 ${actual_state}= Pick Linux Interface ${ints} ${name}\@${peer} 25 List Should Contain Sub List ${actual_state} ${desired_state} 26 [Return] ${actual_state} 27 28 linux: Check Interface Is Present 29 [Arguments] ${node} ${mac} 30 [Documentation] Checking if specified interface with mac exists in linux 31 ${ints}= linux: Get Linux Interfaces ${node} 32 ${result}= Check Linux Interface Presence ${ints} ${mac} 33 Should Be Equal ${result} ${TRUE} values=False msg=Interface with MAC ${mac} is not present in Linux. 34 35 linux: Check Interface Is Not Present 36 [Arguments] ${node} ${mac} 37 [Documentation] Checking if specified interface with mac exists in linux 38 ${ints}= linux: Get Linux Interfaces ${node} 39 ${result}= Check Linux Interface Presence ${ints} ${mac} 40 Should Be Equal ${result} ${FALSE} values=False msg=Interface with MAC ${mac} is present in Linux but shouldn't. 41 42 linux: Check Interface With IP Presence 43 [Arguments] ${node} ${mac} ${ip} ${status}=${TRUE} 44 [Documentation] Checking if specified interface with mac and ip exists in linux 45 ${ints}= linux: Get Linux Interfaces ${node} 46 ${result}= Check Linux Interface IP Presence ${ints} ${mac} ${ip} 47 Should Be Equal ${result} ${status} 48 49 linux: Interface Is Created 50 [Arguments] ${node} ${mac} 51 Wait Until Keyword Succeeds ${interface_timeout} 3s linux: Check Interface Is Present ${node} ${mac} 52 53 linux: Interface With IP Is Created 54 [Arguments] ${node} ${mac} ${ipv4} 55 Wait Until Keyword Succeeds ${interface_timeout} 3s linux: Check Interface With IP Presence ${node} ${mac} ${ipv4} 56 57 linux: Interface Is Deleted 58 [Arguments] ${node} ${mac} 59 Wait Until Keyword Succeeds ${interface_timeout} 3s linux: Check Interface Is Not Present ${node} ${mac} 60 61 linux: Interface With IP Is Deleted 62 [Arguments] ${node} ${mac} ${ipv4} 63 Wait Until Keyword Succeeds ${interface_timeout} 3s linux: Check Interface With IP Presence ${node} ${mac} ${ipv4} ${FALSE} 64 65 linux: Interface Exists 66 [Arguments] ${node} ${mac} 67 linux: Check Interface Is Present ${node} ${mac} 68 69 linux: Interface Not Exists 70 [Arguments] ${node} ${mac} 71 linux: Check Interface Is Not Present ${node} ${mac} 72 73 linux: Check Ping 74 [Arguments] ${node} ${ip} ${count}=5 75 ${out}= Execute In Container ${node} ping -c ${count} ${ip} 76 Should Contain ${out} from ${ip} 77 Should Not Contain ${out} 100% packet loss 78 79 linux: Check Ping6 80 [Arguments] ${node} ${ip} ${count}=5 81 ${out}= Execute In Container ${node} ping6 -c ${count} ${ip} 82 Should Contain ${out} from ${ip} ignore_case=True 83 Should Not Contain ${out} 100% packet loss 84 85 linux: Install Executable Script 86 [Arguments] ${node} ${scriptContent} ${fileName} ${fileDirectory}=/usr/bin 87 ${fullFilePath}= Catenate SEPARATOR= ${fileDirectory} / ${fileName} 88 ${scriptContent}= Replace String ${scriptContent} " \\" # preparing " character for echoing from sh script 89 ${scriptContent}= Replace String ${scriptContent} ' \'\"\'\"\' # preparing ' character for echoing from sh script 90 ${scriptContent}= Replace String ${scriptContent} \n \\n # preparing linux EOL for echoing from sh script 91 ${scriptContent}= Replace String ${scriptContent} \r \\r # preparing windows EOL (\r\n) for echoing from sh script 92 Execute In Container ${node} sh -c 'echo "${scriptContent}" > ${fullFilePath}' 93 Execute In Container ${node} chmod a+x ${fullFilePath} 94 95 linux: Send Ethernet Frame 96 [Arguments] ${node} ${out_interface} ${source_address} ${destination_address} ${ethernet_type} ${payload} ${checksum} 97 ${script}= OperatingSystem.Get File ${CURDIR}/../../robot/resources/sendEthernetFrame.py 98 ${script}= replace variables ${script} 99 linux: Install Executable Script ${node} ${script} sendEthernetFrame.py 100 Execute In Container ${node} sendEthernetFrame.py 101 102 linux: Run TCP Ping Server On Node 103 [Arguments] ${node} ${port} 104 [Documentation] Run TCP PingServer as listener on node ${node} 105 ${out}= Execute In Container Background ${node} ${PINGSERVER_TCP} ${port} 106 107 linux: Run UDP Ping Server On Node 108 [Arguments] ${node} ${port} 109 [Documentation] Run UDP PingServer as listener on node ${node} 110 ${out}= Execute In Container Background ${node} ${PINGSERVER_UDP} ${port} 111 112 linux: TCPPing 113 [Arguments] ${node} ${ip} ${port} 114 #${out}= Execute In Container ${node} ${TCPPING} ${ip} ${port} 115 #${out}= Write To Container Until Prompt ${node} ${TCPPING} ${ip} ${port} 116 ${out}= Write Command to Container ${node} ${TCPPING} ${ip} ${port} 117 Should Contain ${out} Connection to ${ip} ${port} port [tcp/*] succeeded! 118 Should Not Contain ${out} Connection refused 119 120 linux: TCPPingNot 121 [Arguments] ${node} ${ip} ${port} 122 #${out}= Execute In Container ${node} ${TCPPING} ${ip} ${port} 123 #${out}= Write To Container Until Prompt ${node} ${TCPPING} ${ip} ${port} 124 ${out}= Write Command to Container ${node} ${TCPPING} ${ip} ${port} 125 Should Not Contain ${out} Connection to ${ip} ${port} port [tcp/*] succeeded! 126 Should Contain ${out} Connection refused 127 128 linux: UDPPing 129 [Arguments] ${node} ${ip} ${port} 130 #${out}= Execute In Container ${node} ${UDPPING} ${ip} ${port} 131 #${out}= Write To Container Until Prompt ${node} ${UDPPING} ${ip} ${port} 132 ${out}= Write Command to Container ${node} ${UDPPING} ${ip} ${port} 133 Should Contain ${out} Connection to ${ip} ${port} port [udp/*] succeeded! 134 Should Not Contain ${out} Connection refused 135 136 linux: UDPPingNot 137 [Arguments] ${node} ${ip} ${port} 138 #${out}= Execute In Container ${node} ${UDPPING} ${ip} ${port} 139 #${out}= Write To Container Until Prompt ${node} ${UDPPING} ${ip} ${port} 140 ${out}= Write Command to Container ${node} ${UDPPING} ${ip} ${port} 141 Should Not Contain ${out} Connection to ${ip} ${port} port [udp/*] succeeded! 142 Should Contain ${out} Connection refused 143 144 linux: Check Processes on Node 145 [Arguments] ${node} 146 ${out}= Execute In Container ${node} ps aux 147 148 linux: Set Host TAP Interface 149 [Arguments] ${node} ${host_if_name} ${ip} ${prefix} ${mac}= ${second_ip}= ${second_prefix}= 150 ${out}= Execute In Container ${node} ip link set dev ${host_if_name} up 151 ${out}= Execute In Container ${node} ip addr add ${ip}/${prefix} dev ${host_if_name} 152 Run Keyword If "${second_ip}" != "" Execute In Container ${node} ip addr add ${second_ip}/${second_prefix} dev ${host_if_name} 153 Run Keyword If "${mac}" != "" Execute In Container ${node} ip link set ${host_if_name} address ${mac} 154 155 linux: Add Route 156 [Arguments] ${node} ${destination_ip} ${prefix} ${next_hop_ip} 157 Execute In Container ${node} ip route add ${destination_ip}/${prefix} via ${next_hop_ip} 158 159 linux: Delete Route 160 [Arguments] ${node} ${destination_ip} ${prefix} ${next_hop_ip} 161 Execute In Container ${node} ip route del ${destination_ip}/${prefix} via ${next_hop_ip} 162 163 linux: Check ARP 164 [Arguments] ${node} ${interface} ${ipv4} ${MAC} ${presence} 165 [Documentation] Check ARP presence in linux 166 ${out}= Execute In Container ${node} cat /proc/net/arp 167 ${arps}= Parse Linux ARP Entries ${out} 168 ${wanted}= Create Dictionary interface=${interface} ip_addr=${ipv4} mac_addr=${MAC} 169 Run Keyword If "${presence}" == "True" 170 ... Should Contain ${arps} ${wanted} 171 ... ELSE Should Not Contain ${arps} ${wanted} 172 173 linux: Check IPv6 Neighbor 174 [Arguments] ${node} ${interface} ${ip_address} ${mac_address} ${presence} 175 [Documentation] Check IPv6 Neighbor presence in linux 176 ${out}= Execute In Container ${node} ip -6 neighbour 177 ${arps}= Parse Linux IPv6 Neighbor Entries ${out} 178 ${wanted}= Create Dictionary interface=${interface} ip_addr=${ip_address} mac_addr=${mac_address} 179 Run Keyword If "${presence}" == "True" 180 ... Should Contain ${arps} ${wanted} 181 ... ELSE Should Not Contain ${arps} ${wanted}