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