From 840cb7157438ee8f34d20908424729fe9c503f4b Mon Sep 17 00:00:00 2001 From: "samuel.elias" Date: Mon, 7 Oct 2019 11:58:35 +0200 Subject: [PATCH 1/2] Test: fix IPv6 ARP CRUD tests using ipv4 addresses - implement keywords for reading IPv6 neighbor list - use IPv6 addresses in test Signed-off-by: samuel.elias --- tests/robot/libraries/linux.py | 20 ++++ tests/robot/libraries/linux.robot | 10 ++ tests/robot/libraries/vpp_term.py | 11 +++ tests/robot/libraries/vpp_term.robot | 19 +++- .../robot/suites/crudIPv6/arp_crudIPv6.robot | 91 +++++++++---------- 5 files changed, 102 insertions(+), 49 deletions(-) diff --git a/tests/robot/libraries/linux.py b/tests/robot/libraries/linux.py index aeec3e28bb..e648a84cd7 100644 --- a/tests/robot/libraries/linux.py +++ b/tests/robot/libraries/linux.py @@ -76,3 +76,23 @@ def parse_linux_arp_entries(data): entries.append(entry) return entries + + +def parse_linux_ipv6_neighbor_entries(data): + + entries = [] + + for line in data.splitlines(): + if "ip address" in line.lower(): + # skip column headers line + continue + entry_data = line.split() + entry = { + "interface": entry_data[2], + "ip_addr": entry_data[0], + "mac_addr": entry_data[4] + } + entries.append(entry) + + return entries + diff --git a/tests/robot/libraries/linux.robot b/tests/robot/libraries/linux.robot index bb9f7d4c5c..5592b2f23e 100644 --- a/tests/robot/libraries/linux.robot +++ b/tests/robot/libraries/linux.robot @@ -169,3 +169,13 @@ linux: Check ARP Run Keyword If "${presence}" == "True" ... Should Contain ${arps} ${wanted} ... ELSE Should Not Contain ${arps} ${wanted} + +linux: Check IPv6 Neighbor + [Arguments] ${node} ${interface} ${ip_address} ${mac_address} ${presence} + [Documentation] Check IPv6 Neighbor presence in linux + ${out}= Execute In Container ${node} ip -6 neighbour + ${arps}= Parse Linux IPv6 Neighbor Entries ${out} + ${wanted}= Create Dictionary interface=${interface} ip_addr=${ip_address} mac_addr=${mac_address} + Run Keyword If "${presence}" == "True" + ... Should Contain ${arps} ${wanted} + ... ELSE Should Not Contain ${arps} ${wanted} diff --git a/tests/robot/libraries/vpp_term.py b/tests/robot/libraries/vpp_term.py index 5d30a959e7..42be235cfd 100644 --- a/tests/robot/libraries/vpp_term.py +++ b/tests/robot/libraries/vpp_term.py @@ -49,6 +49,17 @@ def Parse_ARP(info, intf, ip, mac): return False +# input - output from sh ip arp command +# output - state info list +def parse_neighbor(info, intf, ip, mac): + for line in info.splitlines(): + if intf in line and ip in line and mac in line: + print("Neighbor Found:"+line) + return True + print("Neighbor Found") + return False + + # input - output from sh ip arp command # output - state info list def parse_stn_rule(info): diff --git a/tests/robot/libraries/vpp_term.robot b/tests/robot/libraries/vpp_term.robot index ca68acf27b..96b84df847 100644 --- a/tests/robot/libraries/vpp_term.robot +++ b/tests/robot/libraries/vpp_term.robot @@ -280,7 +280,7 @@ vpp_term: Add Route vpp_term: Show ARP [Arguments] ${node} [Documentation] Show ARPs through vpp terminal - ${out}= vpp_term: Issue Command ${node} sh ip arp + ${out}= vpp_term: Issue Command ${node} show ip arp #OperatingSystem.Create File ${REPLY_DATA_FOLDER}/reply_arp.json ${out} [Return] ${out} @@ -289,10 +289,25 @@ vpp_term: Check ARP [Documentation] Check ARPs presence on interface ${out}= vpp_term: Show ARP ${node} ${internal_name}= Get Interface Internal Name ${node} ${interface} - #Should Not Be Equal ${internal_name} ${None} ${status}= Run Keyword If '${internal_name}'!='${None}' Parse ARP ${out} ${internal_name} ${ipv4} ${MAC} ELSE Set Variable False Should Be Equal As Strings ${status} ${presence} +vpp_term: Show IPv6 Neighbor + [Arguments] ${node} + [Documentation] Show Neighbbor list through vpp terminal + ${out}= vpp_term: Issue Command ${node} show ip6 neighbors + #OperatingSystem.Create File ${REPLY_DATA_FOLDER}/reply_arp.json ${out} + [Return] ${out} + +vpp_term: Check IPv6 Neighbor + [Arguments] ${node} ${interface} ${ip_address} ${mac_address} ${presence} + [Documentation] Check IPv6 neighbor presence on interface + ${out}= vpp_term: Show IPv6 neighbor ${node} + ${internal_name}= Get Interface Internal Name ${node} ${interface} + ${status}= Run Keyword If '${internal_name}'!='${None}' Parse Neighbor ${out} ${internal_name} ${ip_address} ${mac_address} ELSE Set Variable False + Should Be Equal As Strings ${status} ${presence} + + vpp_term: Set IPv6 neighbor [Arguments] ${node} ${interface} ${ipv6} ${MAC} [Documentation] Sets IPv6 neighbors diff --git a/tests/robot/suites/crudIPv6/arp_crudIPv6.robot b/tests/robot/suites/crudIPv6/arp_crudIPv6.robot index 3f02bb5cc2..1ebe5215fc 100644 --- a/tests/robot/suites/crudIPv6/arp_crudIPv6.robot +++ b/tests/robot/suites/crudIPv6/arp_crudIPv6.robot @@ -1,8 +1,5 @@ *** Settings *** Library OperatingSystem -#Library RequestsLibrary -#Library SSHLibrary timeout=60s -#Library String Resource ../../variables/${VARIABLES}_variables.robot @@ -41,8 +38,8 @@ ${VXLAN_IP_SRC}= fd31::1:1:0:0:1 ${VXLAN_IP_DST}= fd31::1:1:0:0:2 ${LOOPBACK_IP}= fd32::1:1:0:0:1 ${TAP_IP}= fd33::1:1:0:0:1 -${ARP1_IP}= 155.155.155.155 -${ARP2_IP}= 155.155.155.150 +${ARP1_IP}= ab:cd:12:34:: +${ARP2_IP}= ab:cd:12:35:: ${ARP1_MAC}= 32:51:51:51:51:51 ${ARP2_MAC}= 32:51:51:51:51:52 ${ARP1_MAC_MODIFIED}= 32:51:51:51:51:53 @@ -138,58 +135,58 @@ Add ARPs Check Memif ARP Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... vpp_term: Check ARP agent_vpp_1 vpp1_memif1 + ... vpp_term: Check IPv6 Neighbor agent_vpp_1 vpp1_memif1 ... ${ARP1_IP} ${ARP1_MAC} True Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... vpp_term: Check ARP agent_vpp_1 vpp1_memif1 + ... vpp_term: Check IPv6 Neighbor agent_vpp_1 vpp1_memif1 ... ${ARP2_IP} ${ARP2_MAC} True Check Veth1 ARP Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... linux: Check ARP agent_vpp_1 vpp1_veth1 + ... linux: Check IPv6 Neighbor agent_vpp_1 vpp1_veth1 ... ${ARP1_IP} ${ARP1_MAC} True Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... linux: Check ARP agent_vpp_1 vpp1_veth1 + ... linux: Check IPv6 Neighbor agent_vpp_1 vpp1_veth1 ... ${ARP2_IP} ${ARP2_MAC} True Check Veth2 ARP Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... linux: Check ARP agent_vpp_1 vpp1_veth2 + ... linux: Check IPv6 Neighbor agent_vpp_1 vpp1_veth2 ... ${ARP1_IP} ${ARP1_MAC} True Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... linux: Check ARP agent_vpp_1 vpp1_veth2 + ... linux: Check IPv6 Neighbor agent_vpp_1 vpp1_veth2 ... ${ARP2_IP} ${ARP2_MAC} True Check VXLan ARP Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... vpp_term: Check ARP agent_vpp_1 vpp1_vxlan1 + ... vpp_term: Check IPv6 Neighbor agent_vpp_1 vpp1_vxlan1 ... ${ARP1_IP} ${ARP1_MAC} True Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... vpp_term: Check ARP agent_vpp_1 vpp1_vxlan1 + ... vpp_term: Check IPv6 Neighbor agent_vpp_1 vpp1_vxlan1 ... ${ARP2_IP} ${ARP2_MAC} True Check Loopback ARP Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... vpp_term: Check ARP agent_vpp_1 vpp1_loop1 + ... vpp_term: Check IPv6 Neighbor agent_vpp_1 vpp1_loop1 ... ${ARP1_IP} ${ARP1_MAC} True Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... vpp_term: Check ARP agent_vpp_1 vpp1_loop1 + ... vpp_term: Check IPv6 Neighbor agent_vpp_1 vpp1_loop1 ... ${ARP2_IP} ${ARP2_MAC} True Check TAP ARP Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... vpp_term: Check ARP agent_vpp_1 vpp1_tap1 + ... vpp_term: Check IPv6 Neighbor agent_vpp_1 vpp1_tap1 ... ${ARP1_IP} ${ARP1_MAC} True Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... vpp_term: Check ARP agent_vpp_1 vpp1_tap1 + ... vpp_term: Check IPv6 Neighbor agent_vpp_1 vpp1_tap1 ... ${ARP2_IP} ${ARP2_MAC} True Check Afpacket ARP Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... vpp_term: Check ARP agent_vpp_1 vpp1_afpacket1 + ... vpp_term: Check IPv6 Neighbor agent_vpp_1 vpp1_afpacket1 ... ${ARP1_IP} ${ARP1_MAC} True Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... vpp_term: Check ARP agent_vpp_1 vpp1_afpacket1 + ... vpp_term: Check IPv6 Neighbor agent_vpp_1 vpp1_afpacket1 ... ${ARP2_IP} ${ARP2_MAC} True Modify ARPs @@ -205,58 +202,58 @@ Modify ARPs Check Memif ARP After Modify Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... vpp_term: Check ARP agent_vpp_1 vpp1_memif1 + ... vpp_term: Check IPv6 Neighbor agent_vpp_1 vpp1_memif1 ... ${ARP1_IP} ${ARP1_MAC_MODIFIED} True Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... vpp_term: Check ARP agent_vpp_1 vpp1_memif1 + ... vpp_term: Check IPv6 Neighbor agent_vpp_1 vpp1_memif1 ... ${ARP1_IP} ${ARP1_MAC} False Check Veth1 ARP After Modify Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... linux: Check ARP agent_vpp_1 vpp1_veth1 + ... linux: Check IPv6 Neighbor agent_vpp_1 vpp1_veth1 ... ${ARP1_IP} ${ARP1_MAC_MODIFIED} True Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... linux: Check ARP agent_vpp_1 vpp1_veth1 + ... linux: Check IPv6 Neighbor agent_vpp_1 vpp1_veth1 ... ${ARP1_IP} ${ARP1_MAC} False Check Veth2 ARP After Modify Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... linux: Check ARP agent_vpp_1 vpp1_veth2 + ... linux: Check IPv6 Neighbor agent_vpp_1 vpp1_veth2 ... ${ARP1_IP} ${ARP1_MAC_MODIFIED} True Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... linux: Check ARP agent_vpp_1 vpp1_veth2 + ... linux: Check IPv6 Neighbor agent_vpp_1 vpp1_veth2 ... ${ARP1_IP} ${ARP1_MAC} False Check VXLan ARP After Modify Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... vpp_term: Check ARP agent_vpp_1 vpp1_vxlan1 + ... vpp_term: Check IPv6 Neighbor agent_vpp_1 vpp1_vxlan1 ... ${ARP1_IP} ${ARP1_MAC_MODIFIED} True Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... linux: Check ARP agent_vpp_1 vpp1_veth1 + ... linux: Check IPv6 Neighbor agent_vpp_1 vpp1_veth1 ... ${ARP1_IP} ${ARP1_MAC} False Check Loopback ARP After Modify Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... vpp_term: Check ARP agent_vpp_1 vpp1_loop1 + ... vpp_term: Check IPv6 Neighbor agent_vpp_1 vpp1_loop1 ... ${ARP1_IP} ${ARP1_MAC_MODIFIED} True Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... linux: Check ARP agent_vpp_1 vpp1_veth1 + ... linux: Check IPv6 Neighbor agent_vpp_1 vpp1_veth1 ... ${ARP1_IP} ${ARP1_MAC} False Check TAP ARP After Modify Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... vpp_term: Check ARP agent_vpp_1 vpp1_tap1 + ... vpp_term: Check IPv6 Neighbor agent_vpp_1 vpp1_tap1 ... ${ARP1_IP} ${ARP1_MAC_MODIFIED} True Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... linux: Check ARP agent_vpp_1 vpp1_veth1 + ... linux: Check IPv6 Neighbor agent_vpp_1 vpp1_veth1 ... ${ARP1_IP} ${ARP1_MAC} False Check Afpacket ARP After Modify Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... vpp_term: Check ARP agent_vpp_1 vpp1_afpacket1 + ... vpp_term: Check IPv6 Neighbor agent_vpp_1 vpp1_afpacket1 ... ${ARP1_IP} ${ARP1_MAC_MODIFIED} True Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... linux: Check ARP agent_vpp_1 vpp1_veth1 + ... linux: Check IPv6 Neighbor agent_vpp_1 vpp1_veth1 ... ${ARP1_IP} ${ARP1_MAC} False Delete ARPs @@ -274,58 +271,58 @@ Delete ARPs Check Memif ARP After Delete Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... vpp_term: Check ARP agent_vpp_1 vpp1_memif1 + ... vpp_term: Check IPv6 Neighbor agent_vpp_1 vpp1_memif1 ... ${ARP1_IP} ${ARP1_MAC_MODIFIED} True Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... vpp_term: Check ARP agent_vpp_1 vpp1_memif1 + ... vpp_term: Check IPv6 Neighbor agent_vpp_1 vpp1_memif1 ... ${ARP2_IP} ${ARP2_MAC} False Check Veth1 ARP After Delete Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... linux: Check ARP agent_vpp_1 vpp1_veth1 + ... linux: Check IPv6 Neighbor agent_vpp_1 vpp1_veth1 ... ${ARP1_IP} ${ARP1_MAC_MODIFIED} True Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... linux: Check ARP agent_vpp_1 vpp1_veth1 + ... linux: Check IPv6 Neighbor agent_vpp_1 vpp1_veth1 ... ${ARP1_IP} ${ARP2_MAC} False Check Veth2 ARP After Delete Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... linux: Check ARP agent_vpp_1 vpp1_veth2 + ... linux: Check IPv6 Neighbor agent_vpp_1 vpp1_veth2 ... ${ARP1_IP} ${ARP1_MAC_MODIFIED} True Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... linux: Check ARP agent_vpp_1 vpp1_veth2 + ... linux: Check IPv6 Neighbor agent_vpp_1 vpp1_veth2 ... ${ARP1_IP} ${ARP2_MAC} False Check VXLan ARP After Delete Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... vpp_term: Check ARP agent_vpp_1 vpp1_vxlan1 + ... vpp_term: Check IPv6 Neighbor agent_vpp_1 vpp1_vxlan1 ... ${ARP1_IP} ${ARP1_MAC_MODIFIED} True Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... vpp_term: Check ARP agent_vpp_1 vpp1_vxlan1 + ... vpp_term: Check IPv6 Neighbor agent_vpp_1 vpp1_vxlan1 ... ${ARP2_IP} ${ARP2_MAC} False Check Loopback ARP After Delete Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... vpp_term: Check ARP agent_vpp_1 vpp1_loop1 + ... vpp_term: Check IPv6 Neighbor agent_vpp_1 vpp1_loop1 ... ${ARP1_IP} ${ARP1_MAC_MODIFIED} True Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... vpp_term: Check ARP agent_vpp_1 vpp1_loop1 + ... vpp_term: Check IPv6 Neighbor agent_vpp_1 vpp1_loop1 ... ${ARP2_IP} ${ARP2_MAC} False Check TAP ARP After Delete Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... vpp_term: Check ARP agent_vpp_1 vpp1_tap1 + ... vpp_term: Check IPv6 Neighbor agent_vpp_1 vpp1_tap1 ... ${ARP1_IP} ${ARP1_MAC_MODIFIED} True Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... vpp_term: Check ARP agent_vpp_1 vpp1_tap1 + ... vpp_term: Check IPv6 Neighbor agent_vpp_1 vpp1_tap1 ... ${ARP2_IP} ${ARP2_MAC} False Check Afpacket ARP After Delete Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... vpp_term: Check ARP agent_vpp_1 vpp1_afpacket1 + ... vpp_term: Check IPv6 Neighbor agent_vpp_1 vpp1_afpacket1 ... ${ARP1_IP} ${ARP1_MAC_MODIFIED} True Wait Until Keyword Succeeds ${WAIT_TIMEOUT} ${SYNC_SLEEP} - ... vpp_term: Check ARP agent_vpp_1 vpp1_afpacket1 + ... vpp_term: Check IPv6 Neighbor agent_vpp_1 vpp1_afpacket1 ... ${ARP2_IP} ${ARP2_MAC} False From 0279a8515397cd30c41b3cc74d1cbba6ca5fc72b Mon Sep 17 00:00:00 2001 From: "samuel.elias" Date: Mon, 7 Oct 2019 12:16:00 +0200 Subject: [PATCH 2/2] Test: document library keywords for ARPs and neighbors Signed-off-by: samuel.elias --- tests/robot/libraries/linux.py | 12 ++++++++++ tests/robot/libraries/vpp_term.py | 40 ++++++++++++++++++++++++++----- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/tests/robot/libraries/linux.py b/tests/robot/libraries/linux.py index e648a84cd7..e334d42af0 100644 --- a/tests/robot/libraries/linux.py +++ b/tests/robot/libraries/linux.py @@ -60,7 +60,13 @@ def Check_Linux_Interface_IP_Presence(data, mac, ip): def parse_linux_arp_entries(data): + """Parse output of arp command and return list of ARP entries. + :param data: output of 'arp' command. + :type data: str + :returns: Parsed ARP entries. + :rtype: list of dict + """ entries = [] for line in data.splitlines(): @@ -79,7 +85,13 @@ def parse_linux_arp_entries(data): def parse_linux_ipv6_neighbor_entries(data): + """Parse output of ip neighbor command and return list of neighbor entries. + :param data: output of 'ip neighbor' command. + :type data: str + :returns: Parsed neighbor entries. + :rtype: list of dict + """ entries = [] for line in data.splitlines(): diff --git a/tests/robot/libraries/vpp_term.py b/tests/robot/libraries/vpp_term.py index 42be235cfd..6b5331c6a4 100644 --- a/tests/robot/libraries/vpp_term.py +++ b/tests/robot/libraries/vpp_term.py @@ -40,23 +40,51 @@ def Find_MAC_In_Text(text): # input - output from sh ip arp command # output - state info list -def Parse_ARP(info, intf, ip, mac): +def parse_arp(info, intf, ip, mac): + """Parse ARP list from vpp console and find a specific entry using the provided arguments. + + :param info: ARP list from VPP console. + :param intf: VPP-internal name of the interface configured with this ARP entry. + :param ip: IP address of the ARP entry. + :param mac: MAC address of the ARP entry. + :type info: str + :type intf: str + :type ip: str + :type mac: str + :returns: True if a matching entry is found, else False + :rtype: bool + """ + for line in info.splitlines(): - if intf in line and ip in line and mac in line: - print("ARP Found:"+line) - return True - print("ARP Found") + if intf in line and ip in line and mac in line: + print("ARP Found:"+line) + return True + logger.debug("ARP not Found") return False # input - output from sh ip arp command # output - state info list def parse_neighbor(info, intf, ip, mac): + """Parse neighbor list from vpp console and find a specific entry using the provided arguments. + + :param info: Neighbor list from VPP console. + :param intf: VPP-internal name of the interface configured with this neighbor. + :param ip: IP address of the neighbor entry. + :param mac: MAC address of the neighbor entry. + :type info: str + :type intf: str + :type ip: str + :type mac: str + :returns: True if a matching entry is found, else False + :rtype: bool + """ + for line in info.splitlines(): if intf in line and ip in line and mac in line: print("Neighbor Found:"+line) return True - print("Neighbor Found") + logger.debug("Neighbor not Found") return False