CSIT-562 HC Test: Persistence suite rework, part1
[csit.git] / resources / libraries / robot / 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 | Library  | Collections
16 | Resource | resources/libraries/robot/default.robot
17 | Library  | resources.libraries.python.Dhcp.DhcpClient
18 | Library  | resources.libraries.python.TrafficScriptExecutor
19 | Documentation | DHCP Client specific keywords.
20
21 *** Keywords ***
22 | Check DHCP DISCOVER header
23 | | [Documentation] | Check if DHCP DISCOVER message contains all required
24 | | ... | fields.
25 | | ...
26 | | ... | *Arguments:*
27 | | ... | - tg_node - TG node. Type: dictionary
28 | | ... | - interface - TG interface where listen for DHCP DISCOVER message.
29 | | ... |   Type: string
30 | | ... | - src_mac - DHCP client MAC address. Type: string
31 | | ... | - hostname - DHCP client hostname (Optional, Default="", if not
32 | | ... |   specified, the hostname is not checked). Type: string
33 | | ...
34 | | ... | *Return:*
35 | | ... | - No value returned.
36 | | ...
37 | | ... | *Example:*
38 | | ...
39 | | ... | \| Check DHCP DISCOVER header \| ${nodes['TG']} \
40 | | ... | \| eth2 \| 08:00:27:66:b8:57 \|
41 | | ... | \| Check DHCP DISCOVER header \| ${nodes['TG']} \
42 | | ... | \| eth2 \| 08:00:27:66:b8:57 \| client-hostname \|
43 | | ...
44 | | [Arguments] | ${tg_node} | ${interface} | ${src_mac} | ${hostname}=${EMPTY}
45 | | ${interface_name}= | Get interface name | ${tg_node} | ${interface}
46 | | ${args}= | Catenate | --rx_if | ${interface_name} | --rx_src_mac | ${src_mac}
47 | | ${args}= | Run Keyword If | "${hostname}" == "" | Set Variable | ${args}
48 | | ...      | ELSE | Catenate | ${args} | --hostname | ${hostname}
49 | | Run Traffic Script On Node | dhcp/check_dhcp_discover.py
50 | | ... | ${tg_node} | ${args}
51
52
53 | Check DHCP REQUEST after OFFER
54 | | [Documentation] | Check if DHCP REQUEST message contains all required
55 | | ... | fields. DHCP REQUEST should be send by a client after DHCP OFFER
56 | | ... | message sent by a server.
57 | | ...
58 | | ... | *Arguments:*
59 | | ... | - tg_node - TG node. Type: dictionary
60 | | ... | - tg_interface - TG interface where listen for DHCP DISCOVER,
61 | | ... |   send DHCP OFFER and listen for DHCP REQUEST messages. Type: string
62 | | ... | - server_mac - DHCP server MAC address. Type: string
63 | | ... | - server_ip - DHCP server IP address. Type: string
64 | | ... | - client_mac - DHCP client MAC address. Type: string
65 | | ... | - client_ip - IP address that should be offered to client.
66 | | ... |   Type: string
67 | | ... | - client_mask - IP netmask that should be offered to client.
68 | | ... |   Type: string
69 | | ... | - hostname - DHCP client hostname (Optional, Default="", if not
70 | | ... |   specified, the hostname is not checked). Type: string
71 | | ... | - offer_xid - Transaction ID (Optional, Default="", if not specified
72 | | ... |   xid field in DHCP OFFER is same as in DHCP DISCOVER message).
73 | | ... |   Type: integer
74 | | ...
75 | | ... | *Return:*
76 | | ... | - No value returned.
77 | | ...
78 | | ... | *Raises:*
79 | | ... | - DHCP REQUEST Rx timeout - if no DHCP REQUEST is received.
80 | | ...
81 | | ... | *Example:*
82 | | ...
83 | | ... | \| Check DHCP REQUEST after OFFER \| ${nodes['TG']} \
84 | | ... | \| eth2 \| 08:00:27:66:b8:57 \| 192.168.23.1 \
85 | | ... | \| 08:00:27:46:2b:4c \| 192.168.23.10 \| 255.255.255.0 \|
86 | | ...
87 | | ... | \| Run Keyword And Expect Error \| DHCP REQUEST Rx timeout \
88 | | ... | \| Check DHCP REQUEST after OFFER \
89 | | ... | \| ${nodes['TG']} \| eth2 \| 08:00:27:66:b8:57 \| 192.168.23.1 \
90 | | ... | \| 08:00:27:46:2b:4c \| 192.168.23.10 \| 255.255.255.0 \
91 | | ... | \| offer_xid=11113333 \|
92 | | ...
93 | | [Arguments] | ${tg_node} | ${tg_interface} | ${server_mac} | ${server_ip}
94 | | ... | ${client_mac} | ${client_ip} | ${client_mask}
95 | | ... | ${hostname}=${EMPTY} | ${offer_xid}=${EMPTY}
96 | | ${tg_interface_name}= | Get interface name | ${tg_node} | ${tg_interface}
97 | | ${args}= | Catenate | --rx_if | ${tg_interface_name} | --server_mac
98 | | ... | ${server_mac} | --server_ip | ${server_ip} | --client_mac
99 | | ... | ${client_mac} | --client_ip | ${client_ip} | --client_mask
100 | | ... | ${client_mask}
101 | | ${args}= | Run Keyword If | "${hostname}" == "" | Set Variable | ${args}
102 | | ...      | ELSE | Catenate | ${args} | --hostname | ${hostname}
103 | | ${args}= | Run Keyword If | "${offer_xid}" == "" | Set Variable | ${args}
104 | | ...      | ELSE | Catenate | ${args} | --offer_xid | ${offer_xid}
105 | | Run Traffic Script On Node | dhcp/check_dhcp_request.py
106 | | ... | ${tg_node} | ${args}
107
108
109 | Send IP configuration to client via DHCP
110 | | [Documentation] | Run script that sends IP configuration to the DHCP client.
111 | | ...
112 | | ... | *Arguments:*
113 | | ... | - tg_node - TG node. Type: dictionary
114 | | ... | - tg_interface - TG interface where listen for DHCP DISCOVER,
115 | | ... |   send DHCP OFFER and DHCP ACK after DHCP REQUEST messages.
116 | | ... |   Type: string
117 | | ... | - server_mac - DHCP server MAC address. Type: string
118 | | ... | - server_ip - DHCP server IP address. Type: string
119 | | ... | - client_ip - IP address that is offered to client. Type: string
120 | | ... | - client_mask - IP netmask that is offered to client. Type: string
121 | | ... | - lease_time - IP lease time in seconds. Type: integer
122 | | ...
123 | | ... | *Return:*
124 | | ... | - No value returned.
125 | | ...
126 | | ... | *Example:*
127 | | ...
128 | | ... | \| Send IP configuration to client via DHCP \| ${nodes['TG']} \
129 | | ... | \| eth2 \| 08:00:27:66:b8:57 \| 192.168.23.1 \
130 | | ... | \| 192.168.23.10 \| 255.255.255.0 \| 86400 \|
131 | | ...
132 | | [Arguments] | ${tg_node} | ${tg_interface}
133 | | ... | ${server_mac} | ${server_ip} | ${client_ip} | ${client_mask}
134 | | ... | ${lease_time}
135 | | ${tg_interface_name}= | Get interface name | ${tg_node} | ${tg_interface}
136 | | ${args}= | Catenate | --rx_if | ${tg_interface_name}
137 | | ... | --server_mac | ${server_mac} | --server_ip | ${server_ip}
138 | | ... | --client_ip | ${client_ip} | --client_mask | ${client_mask}
139 | | ... | --lease_time | ${lease_time}
140 | | Run Traffic Script On Node | dhcp/check_dhcp_request_ack.py
141 | | ... | ${tg_node} | ${args}