CSIT-158: Tap interface tests
[csit.git] / tests / func / dhcp / dhcp_client.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 | Resource | resources/libraries/robot/default.robot
16 | Resource | resources/libraries/robot/testing_path.robot
17 | Resource | resources/libraries/robot/dhcp_client.robot
18 | Resource | resources/libraries/robot/ipv4.robot
19 | Library | resources.libraries.python.Trace
20 | Force Tags | HW_ENV | VM_ENV | 3_NODE_DOUBLE_LINK_TOPO
21 | Test Setup | Run Keywords | Setup all DUTs before test
22 | ...        | AND          | Setup all TGs before traffic script
23 | Test Teardown | Run Keywords | Show Packet Trace on All DUTs | ${nodes}
24 | ...           | AND          | Show vpp trace dump on all DUTs
25 | Documentation | *DHCP Client related test cases*
26
27 *** Variables ***
28 | ${client_hostname}= | dhcp-client
29 | ${client_ip}= | 192.168.23.10
30 | ${client_mask}= | 255.255.255.0
31 | ${server_ip}= | 192.168.23.1
32 | ${own_xid}= | 11112222
33 | ${lease_time}= | ${15}
34
35 *** Test Cases ***
36 | VPP sends a DHCP DISCOVER
37 | | [Documentation] | Configure DHCP client on interface to TG without hostname
38 | | ...             | and check if DHCP DISCOVER message contains all required
39 | | ...             | fields with expected values.
40 | | ...
41 | | Given Path for 2-node testing is set
42 | |       ... | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['TG']}
43 | | And   Interfaces in 2-node path are up
44 | | When  Set DHCP client on Interface | ${dut_node} | ${dut_to_tg_if1}
45 | | Then  Check DHCP DISCOVER header | ${tg_node}
46 | |       ... | ${tg_to_dut_if1} | ${dut_to_tg_if1_mac}
47
48 | VPP sends a DHCP DISCOVER with hostname
49 | | [Documentation] | Configure DHCP client on interface to TG with hostname
50 | | ...             | and check if DHCP DISCOVER message contains all required
51 | | ...             | fields with expected values.
52 | | ...
53 | | Given Path for 2-node testing is set
54 | |       ... | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['TG']}
55 | | And   Interfaces in 2-node path are up
56 | | When  Set DHCP client on Interface | ${dut_node} | ${dut_to_tg_if1}
57 | |       ... | ${client_hostname}
58 | | Then  Check DHCP DISCOVER header | ${tg_node}
59 | |       ... | ${tg_to_dut_if1} | ${dut_to_tg_if1_mac} | ${client_hostname}
60
61 | VPP sends DHCP REQUEST after OFFER
62 | | [Documentation] | Configure DHCP client on interface to TG and check if
63 | | ...             | DHCP REQUEST message contains all required fields.
64 | | ...
65 | | Given Path for 2-node testing is set
66 | |       ... | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['TG']}
67 | | And   Interfaces in 2-node path are up
68 | | And   VPP Route Add | ${dut_node} | 255.255.255.255 | 32 | ${NONE} | local
69 | |       ... | ${FALSE} | ${NONE}
70 | | When  Set DHCP client on Interface | ${dut_node} | ${dut_to_tg_if1}
71 | | Then  Check DHCP REQUEST after OFFER | ${tg_node} | ${tg_to_dut_if1}
72 | |       ... | ${tg_to_dut_if1_mac} | ${server_ip}
73 | |       ... | ${dut_to_tg_if1_mac} | ${client_ip} | ${client_mask}
74
75 | VPP doesn't send DHCP REQUEST after OFFER with wrong XID
76 | | [ Tags ] | EXPECTED_FAILING
77 | | [Documentation] | Configure DHCP client on interface to TG. If server sends
78 | | ...             | DHCP OFFER with different XID as in DHCP DISCOVER,
79 | | ...             | DHCP REQUEST message shouldn't be sent.
80 | | ...
81 | | Given Path for 2-node testing is set
82 | |       ... | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['TG']}
83 | | And   Interfaces in 2-node path are up
84 | | And   VPP Route Add | ${dut_node} | 255.255.255.255 | 32 | ${NONE} | local
85 | |       ... | ${FALSE} | ${NONE}
86 | | When  Set DHCP client on Interface | ${dut_node} | ${dut_to_tg_if1}
87 | | Then  Run Keyword And Expect Error | DHCP REQUEST Rx timeout
88 | |       ... | Check DHCP REQUEST after OFFER | ${tg_node} | ${tg_to_dut_if1}
89 | |       ... | ${tg_to_dut_if1_mac} | ${server_ip}
90 | |       ... | ${dut_to_tg_if1_mac} | ${client_ip} | ${client_mask}
91 | |       ... | offer_xid=${own_xid}
92
93 | VPP honors DHCPv4 lease time
94 | | [Documentation] | Send IP configuration to the VPP client via DHCP. Address
95 | | ...             | is checked with ICMP echo request and there should be no
96 | | ...             | reply for echo request when lease has expired.
97 | | ...
98 | | Given Path for 2-node testing is set
99 | |       ... | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['TG']}
100 | | And   Interfaces in 2-node path are up
101 | | And   VPP Route Add | ${dut_node} | 255.255.255.255 | 32 | ${NONE} | local
102 | |       ... | ${FALSE} | ${NONE}
103 | | When  Set DHCP client on Interface | ${dut_node} | ${dut_to_tg_if1}
104 | | And   Send IP configuration to client via DHCP
105 | |       ... | ${tg_node} | ${tg_to_dut_if1}
106 | |       ... | ${tg_to_dut_if1_mac} | ${server_ip}
107 | |       ... | ${client_ip} | ${client_mask}
108 | |       ... | ${lease_time}
109 | | And   Add Arp On Dut | ${dut_node} | ${dut_to_tg_if1} | ${server_ip}
110 | |       ... | ${tg_to_dut_if1_mac}
111 | | Then  Node replies to ICMP echo request | ${tg_node} | ${tg_to_dut_if1}
112 | |       ... | ${dut_to_tg_if1_mac} | ${tg_to_dut_if1_mac} | ${client_ip}
113 | |       ... | ${server_ip}
114 | | And   Sleep | ${lease_time}
115 | | And   Run Keyword And Expect Error | ICMP echo Rx timeout
116 | |       ... | Node replies to ICMP echo request | ${tg_node}
117 | |       ... | ${tg_to_dut_if1} | ${dut_to_tg_if1_mac} | ${tg_to_dut_if1_mac}
118 | |       ... | ${client_ip} | ${server_ip}