aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Gelety <jgelety@cisco.com>2017-01-20 17:17:43 +0100
committerPeter Mikus <pmikus@cisco.com>2017-03-10 11:19:58 +0000
commit3a761053c1dacc9d5f21ec1ddf75e1f192473f2c (patch)
tree696211862c6f861cf397e4a116dff18f97a90943
parentfe29ca4b7e6c412c69f1c56404513a33236aa617 (diff)
SPAN test - improvement of packet check
Change-Id: Ic95fbe288495ee4cd75178d74c220f6af5d2b11a Signed-off-by: Jan Gelety <jgelety@cisco.com>
-rw-r--r--resources/libraries/robot/telemetry/span.robot4
-rwxr-xr-xresources/traffic_scripts/span_check.py128
-rw-r--r--tests/func/telemetry/span/eth2p-ethip4-ip4base-spanrx-func.robot3
-rw-r--r--tests/func/telemetry/span/eth2p-ethip6-ip6base-spanrx-func.robot17
4 files changed, 110 insertions, 42 deletions
diff --git a/resources/libraries/robot/telemetry/span.robot b/resources/libraries/robot/telemetry/span.robot
index d994e95e3e..3ef8716cfa 100644
--- a/resources/libraries/robot/telemetry/span.robot
+++ b/resources/libraries/robot/telemetry/span.robot
@@ -31,7 +31,7 @@
| | ... | - rx_port - Second interface on TG. Type: string
| | ... | - src_ip - Packet source IP address. Type: string
| | ... | - dst_ip - Packet destination IP address. Type: string
-| | ... | - ptype - Type of payload, ARP or ICMP. Type: string
+| | ... | - ptype - Type of payload, ARP, ICMP or ICMPv6. Type: string
| | ...
| | ... | *Return:*
| | ... | - No value returned
@@ -53,4 +53,4 @@
| | ... | --tx_if ${tx_port_name} --rx_if | ${rx_port_name}
| | ... | --ptype ${ptype}
| | Run Traffic Script On Node | span_check.py | ${tg_node} |
-| | ... | ${args} \ No newline at end of file
+| | ... | ${args}
diff --git a/resources/traffic_scripts/span_check.py b/resources/traffic_scripts/span_check.py
index 66400d9dfb..c7ca8a7374 100755
--- a/resources/traffic_scripts/span_check.py
+++ b/resources/traffic_scripts/span_check.py
@@ -75,9 +75,12 @@ def main():
rx_if = args.get_arg('rx_if')
ptype = args.get_arg('ptype')
- rxq = RxQueue(rx_if)
+ rxq_mirrored = RxQueue(rx_if)
+ rxq_tx = RxQueue(tx_if)
txq = TxQueue(tx_if)
+ sent = []
+
if ptype == "ARP":
pkt_raw = (Ether(src=src_mac, dst=dst_mac) /
ARP(hwsrc=src_mac, hwdst="00:00:00:00:00:00",
@@ -87,50 +90,113 @@ def main():
pkt_raw = (Ether(src=src_mac, dst=dst_mac) /
IP(src=src_ip, dst=dst_ip) /
ICMP(type="echo-request"))
- elif valid_ipv6(src_ip) and valid_ipv6(dst_ip):
+ else:
+ raise ValueError("IP addresses not in correct format")
+ elif ptype == "ICMPv6":
+ if valid_ipv6(src_ip) and valid_ipv6(dst_ip):
pkt_raw = (Ether(src=src_mac, dst=dst_mac) /
IPv6(src=src_ip, dst=dst_ip) /
ICMPv6EchoRequest())
else:
- raise ValueError("IP not in correct format")
+ raise ValueError("IPv6 addresses not in correct format")
else:
raise RuntimeError("Unexpected payload type.")
txq.send(pkt_raw)
- ether = rxq.recv(2)
+ sent.append(auto_pad(pkt_raw))
+ ether = rxq_mirrored.recv(2)
- # Receive copy of sent packet.
+ # Receive copy of Rx packet.
if ether is None:
- raise RuntimeError("Rx timeout")
+ raise RuntimeError("Rx timeout of mirrored Rx packet")
pkt = auto_pad(pkt_raw)
if str(ether) != str(pkt):
- raise RuntimeError("Mirrored packet does not match packet sent.")
+ print("Mirrored Rx packet doesn't match the original Rx packet.")
+ if ether.src != src_mac or ether.dst != dst_mac:
+ raise RuntimeError("MAC mismatch in mirrored Rx packet.")
+ if ptype == "ARP":
+ if not ether.haslayer(ARP):
+ raise RuntimeError("Mirrored Rx packet is not an ARP packet.")
+ if ether['ARP'].op != 1: # 1=who-has
+ raise RuntimeError("Mirrored Rx packet is not an ARP request.")
+ if ether['ARP'].hwsrc != src_mac or ether['ARP'].hwdst != dst_mac:
+ raise RuntimeError("MAC mismatch in mirrored Rx ARP packet.")
+ if ether['ARP'].psrc != src_ip or ether['ARP'].pdst != dst_ip:
+ raise RuntimeError("IP address mismatch in mirrored "
+ "Rx ARP packet.")
+ elif ptype == "ICMP":
+ if not ether.haslayer(IP):
+ raise RuntimeError("Mirrored Rx packet is not an IPv4 packet.")
+ if ether['IP'].src != src_ip or ether['IP'].dst != dst_ip:
+ raise RuntimeError("IP address mismatch in mirrored "
+ "Rx IPv4 packet.")
+ if not ether.haslayer(ICMP):
+ raise RuntimeError("Mirrored Rx packet is not an ICMP packet.")
+ if ether['ICMP'].type != 8: # 8=echo-request
+ raise RuntimeError("Mirrored Rx packet is not an ICMP "
+ "echo request.")
+ elif ptype == "ICMPv6":
+ if not ether.haslayer(IPv6):
+ raise RuntimeError("Mirrored Rx packet is not an IPv6 packet.")
+ if ether['IPv6'].src != src_ip or ether['IPv6'].dst != dst_ip:
+ raise RuntimeError("IP address mismatch in mirrored "
+ "Rx IPv6 packet.")
+ if not ether.haslayer(ICMPv6EchoRequest):
+ raise RuntimeError("Mirrored Rx packet is not an ICMPv6 "
+ "echo request.")
+ print("Mirrored Rx packet check OK.\n")
+
+ # Receive reply on TG Tx port.
+ ether_repl = rxq_tx.recv(2, sent)
+ if ether_repl is None:
+ raise RuntimeError("Reply not received on TG Tx port.")
+ else:
+ print("Reply received on TG Tx port.\n")
- # Receive copy of reply to sent packet.
- ether = rxq.recv(2)
+ # Receive copy of Tx packet.
+ ether = rxq_mirrored.recv(2)
if ether is None:
- raise RuntimeError("Rx timeout")
- if ether.src != dst_mac or ether.dst != src_mac:
- raise RuntimeError("MAC mismatch in mirrored response.")
- if ptype == "ARP":
- if ether['ARP'].op != 2:
- raise RuntimeError("Mirrored packet is not an ARP reply.")
- if ether['ARP'].hwsrc != dst_mac or ether['ARP'].hwdst != src_mac:
- raise RuntimeError("ARP MAC does not match l2 MAC "
- "in mirrored response.")
- if ether['ARP'].psrc != dst_ip or ether['ARP'].pdst != src_ip:
- raise RuntimeError("ARP IP address mismatch in mirrored response.")
- elif ptype == "ICMP" and ether.haslayer(IP):
- if ether['IP'].src != dst_ip or ether['IP'].dst != src_ip:
- raise RuntimeError("IP address mismatch in mirrored reply.")
- if ether['ICMP'].type != 0:
- raise RuntimeError("Mirrored packet is not an ICMP reply.")
- elif ptype == "ICMP" and ether.haslayer(IPv6):
- if ether['IPv6'].src != dst_ip or ether['IPv6'].dst != src_ip:
- raise RuntimeError("IP address mismatch in mirrored reply.")
- if not ether.haslayer(ICMPv6EchoReply):
- raise RuntimeError("Mirrored packet is not an ICMP reply.")
-
+ raise RuntimeError("Rx timeout of mirrored Tx packet")
+ if str(ether) != str(ether_repl):
+ print("Mirrored Tx packet doesn't match the received Tx packet.")
+ if ether.src != ether_repl.src or ether.dst != ether_repl.dst:
+ raise RuntimeError("MAC mismatch in mirrored Tx packet.")
+ if ptype == "ARP":
+ if not ether.haslayer(ARP):
+ raise RuntimeError("Mirrored Tx packet is not an ARP packet.")
+ if ether['ARP'].op != ether_repl['ARP'].op: # 2=is_at
+ raise RuntimeError("ARP operational code mismatch "
+ "in mirrored Tx packet.")
+ if ether['ARP'].hwsrc != ether_repl['ARP'].hwsrc\
+ or ether['ARP'].hwdst != ether_repl['ARP'].hwdst:
+ raise RuntimeError("MAC mismatch in mirrored Tx ARP packet.")
+ if ether['ARP'].psrc != ether_repl['ARP'].psrc\
+ or ether['ARP'].pdst != ether_repl['ARP'].pdst:
+ raise RuntimeError("IP address mismatch in mirrored "
+ "Tx ARP packet.")
+ elif ptype == "ICMP":
+ if not ether.haslayer(IP):
+ raise RuntimeError("Mirrored Tx packet is not an IPv4 packet.")
+ if ether['IP'].src != ether_repl['IP'].src\
+ or ether['IP'].dst != ether_repl['IP'].dst:
+ raise RuntimeError("IP address mismatch in mirrored "
+ "Tx IPv4 packet.")
+ if not ether.haslayer(ICMP):
+ raise RuntimeError("Mirrored Tx packet is not an ICMP packet.")
+ if ether['ICMP'].type != ether_repl['ICMP'].type: # 0=echo-reply
+ raise RuntimeError("ICMP packet type mismatch "
+ "in mirrored Tx packet.")
+ elif ptype == "ICMPv6":
+ if not ether.haslayer(IPv6):
+ raise RuntimeError("Mirrored Tx packet is not an IPv6 packet.")
+ if ether['IPv6'].src != ether_repl['IPv6'].src\
+ or ether['IPv6'].dst != ether_repl['IPv6'].dst:
+ raise RuntimeError("IP address mismatch in mirrored "
+ "Tx IPv6 packet.")
+ if ether[2].name != ether_repl[2].name:
+ raise RuntimeError("ICMPv6 message type mismatch "
+ "in mirrored Tx packet.")
+ print("Mirrored Tx packet check OK.\n")
sys.exit(0)
diff --git a/tests/func/telemetry/span/eth2p-ethip4-ip4base-spanrx-func.robot b/tests/func/telemetry/span/eth2p-ethip4-ip4base-spanrx-func.robot
index 62f76d847d..d8668835e7 100644
--- a/tests/func/telemetry/span/eth2p-ethip4-ip4base-spanrx-func.robot
+++ b/tests/func/telemetry/span/eth2p-ethip4-ip4base-spanrx-func.robot
@@ -19,8 +19,7 @@
| Library | resources.libraries.python.IPv4Util
| Library | resources.libraries.python.IPv4Setup
| Library | resources.libraries.python.telemetry.SPAN
-| Force Tags | HW_ENV | VM_ENV | 3_NODE_DOUBLE_LINK_TOPO | EXPECTED_FAILING
-# TODO: Remove EXPECTED_FAILING tag once functionality is implemented (VPP-185)
+| Force Tags | HW_ENV | VM_ENV | 3_NODE_DOUBLE_LINK_TOPO
| Test Setup | Func Test Setup
| Test Teardown | Func Test Teardown
| Documentation | *SPAN test suite*
diff --git a/tests/func/telemetry/span/eth2p-ethip6-ip6base-spanrx-func.robot b/tests/func/telemetry/span/eth2p-ethip6-ip6base-spanrx-func.robot
index 5fa7d0c5e4..e3acc0362a 100644
--- a/tests/func/telemetry/span/eth2p-ethip6-ip6base-spanrx-func.robot
+++ b/tests/func/telemetry/span/eth2p-ethip6-ip6base-spanrx-func.robot
@@ -16,11 +16,11 @@
| Resource | resources/libraries/robot/testing_path.robot
| Resource | resources/libraries/robot/telemetry/span.robot
| Library | resources.libraries.python.Trace
-| Library | resources.libraries.python.IPv4Util
-| Library | resources.libraries.python.IPv4Setup
+| Library | resources.libraries.python.IPv6Util
+| Library | resources.libraries.python.IPv6Setup
+| Library | resources.libraries.python.Routing
| Library | resources.libraries.python.telemetry.SPAN
-| Force Tags | HW_ENV | VM_ENV | 3_NODE_DOUBLE_LINK_TOPO | EXPECTED_FAILING
-# TODO: Remove EXPECTED_FAILING tag once functionality is implemented (VPP-185)
+| Force Tags | HW_ENV | VM_ENV | 3_NODE_DOUBLE_LINK_TOPO
| Test Setup | Func Test Setup
| Test Teardown | Func Test Teardown
| Documentation | *SPAN test suite*
@@ -50,12 +50,15 @@
| | Given Path For 2-node Testing Is Set | ${nodes['TG']} | ${nodes['DUT1']}
| | ... | ${nodes['TG']}
| | And Interfaces In 2-node Path Are Up
-| | And Set interface Address | ${dut_node} | ${dut_to_tg_if1}
+| | And Vpp Ra Suppress Link Layer | ${dut_node} | ${dut_to_tg_if1}
+| | And Vpp Set If Ipv6 Addr | ${dut_node} | ${dut_to_tg_if1}
| | ... | ${dut_to_tg_if1_ip6} | ${prefix}
-| | And Add ARP on DUT | ${dut_node} | ${dut_to_tg_if1} | ${tg_to_dut_if1_ip6}
+| | And Add Ip Neighbor | ${dut_node} | ${dut_to_tg_if1} | ${tg_to_dut_if1_ip6}
| | ... | ${tg_to_dut_if1_mac}
+| | And Vpp Route Add | ${dut_node} | ${tg_to_dut_if1_ip6} | ${prefix}
+| | ... | ${dut_to_tg_if1_ip6} | ${dut_to_tg_if1}
| | And Set SPAN Mirroring | ${dut_node} | ${dut_to_tg_if1} | ${dut_to_tg_if2}
| | Then Send Packet And Check Received Copies | ${tg_node}
| | ... | ${tg_to_dut_if1} | ${tg_to_dut_if1_mac}
| | ... | ${dut_to_tg__if1_mac} | ${tg_to_dut_if2}
-| | ... | ${tg_to_dut_if1_ip6} | ${dut_to_tg_if1_ip6} | ICMP
+| | ... | ${tg_to_dut_if1_ip6} | ${dut_to_tg_if1_ip6} | ICMPv6