HC Test: create Vlan sub-interface using netconf
[csit.git] / resources / libraries / robot / l2_traffic.robot
1 # Copyright (c) 2016 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 *** Settings ***
15 | Documentation | Keywords to send and receive different types of traffic \
16 | ...           | through L2 network.
17 | Library | resources.libraries.python.topology.Topology
18 | Library | resources.libraries.python.TrafficScriptExecutor
19
20 *** Keywords ***
21 | Send and receive ICMP Packet
22 | | [Documentation] | Send ICMPv4/ICMPv6 echo request from source interface to \
23 | | ...             | destination interface. Packet can be set with Dot1q or
24 | | ...             | Dot1ad tag(s) when required.
25 | | ...
26 | | ... | *Arguments:*
27 | | ...
28 | | ... | - tg_node - TG node. Type: dictionary
29 | | ... | - src_int - Source interface. Type: string
30 | | ... | - dst_int - Destination interface. Type: string
31 | | ... | - src_ip - Source IP address (Optional). Type: string
32 | | ... | - dst_ip - Destination IP address (Optional). Type: string
33 | | ... | - encaps - Encapsulation: Dot1q or Dot1ad (Optional). Type: string
34 | | ... | - vlan1 - VLAN (outer) tag (Optional). Type: integer
35 | | ... | - vlan2 - VLAN inner tag (Optional). Type: integer
36 | | ... | - encaps_rx - Expected encapsulation on RX side: Dot1q or Dot1ad
37 | | ... | (Optional). Type: string
38 | | ... | - vlan1_rx - VLAN (outer) tag on RX side (Optional). Type: integer
39 | | ... | - vlan2_rx - VLAN inner tag on RX side (Optional). Type: integer
40 | | ...
41 | | ... | *Return:*
42 | | ...
43 | | ... | - No value returned
44 | | ...
45 | | ... | *Example:*
46 | | ...
47 | | ... | _NOTE:_ Default IP is IPv4
48 | | ...
49 | | ... | \| Send and receive ICMP Packet \| ${nodes['TG']} \
50 | | ... | \| ${tg_to_dut_if1} \| ${tg_to_dut_if2} \|
51 | | ... | \| Send and receive ICMP Packet \| ${nodes['TG']} \| ${tg_to_dut1} \
52 | | ... | \| ${tg_to_dut2} \| encaps=Dot1q \| vlan1=100 \|
53 | | ... | \| Send and receive ICMP Packet \| ${nodes['TG']} \| ${tg_to_dut1} \
54 | | ... | \| ${tg_to_dut2} \| encaps=Dot1ad \| vlan1=110 \| vlan2=220 \|
55 | | ... | \| Send and receive ICMP Packet \| ${nodes['TG']} \| ${tg_to_dut1} \
56 | | ... | \| ${tg_to_dut2} \| encaps=Dot1q \| vlan1=110 \| encaps_rx=Dot1q \|
57 | | ... | \| Send and receive ICMP Packet \| ${nodes['TG']} \| ${tg_to_dut1} \
58 | | ... | \| ${tg_to_dut2} \| encaps=Dot1q \| vlan1=110 \| encaps_rx=Dot1q \
59 | | ... | \| vlan1_rx=120 \|
60 | | ...
61 | | [Arguments] | ${tg_node} | ${src_int} | ${dst_int}
62 | | ... | ${src_ip}=192.168.100.1 | ${dst_ip}=192.168.100.2 | ${encaps}=${EMPTY}
63 | | ... | ${vlan1}=${EMPTY} | ${vlan2}=${EMPTY} | ${encaps_rx}=${EMPTY}
64 | | ... | ${vlan1_rx}=${EMPTY} | ${vlan2_rx}=${EMPTY}
65 | | ${src_mac}= | Get Interface Mac | ${tg_node} | ${src_int}
66 | | ${dst_mac}= | Get Interface Mac | ${tg_node} | ${dst_int}
67 | | ${src_int_name}= | Get interface name | ${tg_node} | ${src_int}
68 | | ${dst_int_name}= | Get interface name | ${tg_node} | ${dst_int}
69 | | ${args}= | Traffic Script Gen Arg | ${dst_int_name} | ${src_int_name}
70 | | ... | ${src_mac} | ${dst_mac} | ${src_ip} | ${dst_ip}
71 | | ${args}= | Run Keyword If | '${encaps}' == '${EMPTY}'
72 | | | ...                     | Set Variable | ${args}
73 | | ... | ELSE | Catenate | ${args} | --encaps ${encaps} | --vlan1 ${vlan1}
74 | | ${args}= | Run Keyword If | '${vlan2}' == '${EMPTY}'
75 | | | ...                     | Set Variable | ${args}
76 | | ... | ELSE | Catenate | ${args} | --vlan2 ${vlan2}
77 | | ${args}= | Run Keyword If | '${encaps_rx}' == '${EMPTY}'
78 | | | ...                     | Set Variable | ${args}
79 | | ... | ELSE | Catenate | ${args} | --encaps_rx ${encaps_rx}
80 | | ${args}= | Run Keyword If | '${vlan1_rx}' == '${EMPTY}'
81 | | | ...                     | Set Variable | ${args}
82 | | ... | ELSE | Catenate | ${args} | --vlan1_rx ${vlan1_rx}
83 | | ${args}= | Run Keyword If | '${vlan2_rx}' == '${EMPTY}'
84 | | | ...                     | Set Variable | ${args}
85 | | ... | ELSE | Catenate | ${args} | --vlan2_rx ${vlan2_rx}
86 | | Run Traffic Script On Node | send_ip_icmp.py | ${tg_node} | ${args}
87
88 | Send and receive ICMP Packet should fail
89 | | [Documentation] | Send ICMPv4/ICMPv6 echo request from source interface to
90 | | ...             | destination interface and expect failure with
91 | | ...             | ICMP echo Rx timeout error message.
92 | | ...
93 | | ... | *Arguments:*
94 | | ...
95 | | ... | - tg_node - TG node. Type: dictionary
96 | | ... | - src_int - Source interface. Type: string
97 | | ... | - dst_int - Destination interface. Type: string
98 | | ... | - src_ip - Source IP address (Optional). Type: string
99 | | ... | - dst_ip - Destination IP address (Optional). Type: string
100 | | ...
101 | | ... | *Return:*
102 | | ...
103 | | ... | - No value returned
104 | | ...
105 | | ... | *Example:*
106 | | ...
107 | | ... | _NOTE:_ Default IP is IPv4
108 | | ...
109 | | ... | \| Send and receive ICMP Packet should fail\| ${nodes['TG']} \
110 | | ... | \| ${tg_to_dut_if1} \| ${tg_to_dut_if2} \|
111 | | ...
112 | | [Arguments] | ${tg_node} | ${src_int} | ${dst_int} |
113 | | ... | ${src_ip}=192.168.100.1 | ${dst_ip}=192.168.100.2
114 | | ${src_mac}= | Get Interface Mac | ${tg_node} | ${src_int}
115 | | ${dst_mac}= | Get Interface Mac | ${tg_node} | ${dst_int}
116 | | ${src_int_name}= | Get interface name | ${tg_node} | ${src_int}
117 | | ${dst_int_name}= | Get interface name | ${tg_node} | ${dst_int}
118 | | ${args}= | Traffic Script Gen Arg | ${dst_int_name} | ${src_int_name}
119 | | ... | ${src_mac} | ${dst_mac} | ${src_ip} | ${dst_ip}
120 | | Run Keyword And Expect Error | ICMP echo Rx timeout |
121 | | ... | Run Traffic Script On Node | send_ip_icmp.py | ${tg_node} | ${args}
122
123 | Send and receive ICMPv4 bidirectionally
124 | | [Documentation] | Send ICMPv4 echo request from both directions,
125 | | ...             | from interface1 to interface2 and
126 | | ...             | from interface2 to interface1.
127 | | ...
128 | | ... | *Arguments:*
129 | | ...
130 | | ... | - tg_node - TG node. Type: dictionary
131 | | ... | - src_int - Source interface. Type: string
132 | | ... | - dst_int - Destination interface. Type: string
133 | | ... | - src_ip - Source IP address (Optional). Type: string
134 | | ... | - dst_ip - Destination IP address (Optional). Type: string
135 | | ...
136 | | ... | *Return:*
137 | | ...
138 | | ... | - No value returned
139 | | ...
140 | | ... | *Example:*
141 | | ...
142 | | ... | \| Send and receive ICMPv4 bidirectionally \| ${nodes['TG']} \
143 | | ... | \| ${tg_to_dut_if1} \| ${tg_to_dut_if2} \|
144 | | ...
145 | | [Arguments] | ${tg_node} | ${int1} | ${int2} | ${src_ip}=192.168.100.1 |
146 | | ... | ${dst_ip}=192.168.100.2
147 | | Send and receive ICMP Packet | ${tg_node} | ${int1} | ${int2} |
148 | | ... | ${src_ip} | ${dst_ip}
149 | | Send and receive ICMP Packet | ${tg_node} | ${int2} | ${int1} |
150 | | ... | ${dst_ip} | ${src_ip}
151
152 | Send and receive ICMPv6 bidirectionally
153 | | [Documentation] | Send ICMPv6 echo request from both directions,
154 | | ...             | from interface1 to interface2 and
155 | | ...             | from interface2 to interface1.
156 | | ...
157 | | ... | *Arguments:*
158 | | ...
159 | | ... | - tg_node - TG node. Type: dictionary
160 | | ... | - src_int - Source interface. Type: string
161 | | ... | - dst_int - Destination interface. Type: string
162 | | ... | - src_ip - Source IP address (Optional). Type: string
163 | | ... | - dst_ip - Destination IP address (Optional). Type: string
164 | | ...
165 | | ... | *Return:*
166 | | ...
167 | | ... | - No value returned
168 | | ...
169 | | ... | *Example:*
170 | | ...
171 | | ... | \| Send and receive ICMPv6 bidirectionally \| ${nodes['TG']} \
172 | | ... | \| ${tg_to_dut_if1} \| ${tg_to_dut_if2} \|
173 | | ...
174 | | [Arguments] | ${tg_node} | ${int1} | ${int2} | ${src_ip}=3ffe:63::1 |
175 | | ... | ${dst_ip}=3ffe:63::2
176 | | Send and receive ICMP Packet | ${tg_node} | ${int1} | ${int2} |
177 | | ... | ${src_ip} | ${dst_ip}
178 | | Send and receive ICMP Packet | ${tg_node} | ${int2} | ${int1} |
179 | | ... | ${dst_ip} | ${src_ip}