blob: 73adfd6096a314d99afa678d51f54adbaf90561a [file] [log] [blame]
Rahul Maheshwari757d80c2016-10-17 01:09:55 -05001*** Settings ***
2
3Documentation This testsuite is for testing network setting
4... of host OS.
5
6Resource ../lib/rest_client.robot
7Resource ../lib/ipmi_client.robot
8Resource ../lib/utils.robot
9Resource ../lib/openbmc_ffdc.robot
10Library ../lib/utilities.py
11
12Suite Setup Open Connection And Log In
13Suite Teardown Close All Connections
14
15Test Teardown Post Test Execution
16
Sweta Potthuri5db43e42017-06-15 05:36:44 -050017Force Tags Host_Network
18
Rahul Maheshwari757d80c2016-10-17 01:09:55 -050019*** Variables ***
20${SET_ADDR_PREFIX} 0x00 0x08 0x61 0x80 0x21 0x70 0x62 0x21 0x00 0x01 0x06 0x04
21${STATIC} 0x00 0x01 #equivalent address type 1
22${DHCP} 0x00 0x00 #equivalent address type 0
23${CLEAR_ADDR} 0x00 0x08 0x61 0x80 0x00 0x00 0x00 0x00
24${INVALID_MAC} f4:52:14
25
26*** Test Cases ***
27
28Set Static Address With REST
29 [Documentation] This testcase is to set static address for host's network
30 ... setting using REST. Later verify using REST
31 ... that it is set correctly.
32 [Tags] Set_Static_Address_With_REST
33
34 ${ip_address}= utilities.random_ip
35 ${gateway}= utilities.random_ip
36 ${mac_address}= utilities.random_mac
37 ${subnet}= Evaluate random.randint(0, 32) modules=random
38
39 ${settings}= Catenate SEPARATOR=
40 ... ipaddress=${ip_address},prefix=${subnet},
41 ... gateway=${gateway},mac=${mac_address},addr_type=1
42
43 Set Network Override Setting ${settings}
44
45 ${resp}= Read Attribute /org/openbmc/settings/host0 network_config
46 Should Be Equal ${resp} ${settings}
47
48
49Set DHCP Address With REST
50 [Documentation] This testcase is to set dhcp address for host's network
51 ... setting using REST. Later verify using REST that it
52 ... is set correctly.
53 [Tags] Set_DHCP_Address_With_REST
54
55 ${mac_address}= utilities.random_mac
56
57 ${settings}= Catenate SEPARATOR=
58 ... ipaddress=,prefix=,gateway=,mac=${mac_address},addr_type=0
59
60 Set Network Override Setting ${settings}
61
62 ${resp}= Read Attribute /org/openbmc/settings/host0 network_config
63 Should Be Equal ${resp} ${settings}
64
65
66Set Static Address With IPMI
67 [Documentation] This testcase is to set static address for host's network
68 ... setting using IPMI. Later verify using REST that it is
69 ... set correctly.
70 [Tags] Set_Static_Address_With_IPMI
71
72 ${ip_address}= utilities.random_ip
73 ${gateway}= utilities.random_ip
74 ${mac_address}= utilities.random_mac
75 ${subnet}= Evaluate random.randint(0, 32) modules=random
76
77 ${mac_address_hex}= Mac Address To Hex String ${mac_address}
78 ${ip_address_hex}= IP Address To Hex String ${ip_address}
79 ${gateway_hex}= IP Address To Hex String ${gateway}
80 ${subnet_hex}= Convert To Hex ${subnet} prefix=0x
81 ... lowercase=yes
82
83 ${ipmi_raw_cmd}= Catenate SEPARATOR=
84 ... ${SET_ADDR_PREFIX}${SPACE}${mac_address_hex}${SPACE}${STATIC}${SPACE}
85 ... ${ip_address_hex}${SPACE}${subnet_hex}${SPACE}${gateway_hex}
86
87 Run IPMI command ${ipmi_raw_cmd}
88
89 ${resp}= Read Attribute /org/openbmc/settings/host0 network_config
90
91 ${settings}= Catenate SEPARATOR=
92 ... ipaddress=${ip_address},prefix=${subnet},gateway=${gateway},
93 ... mac=${mac_address},addr_type=1
94
95 Should Be Equal ${resp} ${settings}
96
97
98Set DHCP Address With IPMI
99 [Documentation] This testcase is to set dhcp address for host's network
100 ... setting using IPMI. Later verify using REST that it is
101 ... set correctly.
102 [Tags] Set_DHCP_Address_With_IPMI
103
104 ${mac_address}= utilities.random_mac
105 ${mac_address_hex}= Mac Address To Hex String ${mac_address}
106
107 ${ipmi_raw_cmd}= Catenate SEPARATOR=
108 ... ${SET_ADDR_PREFIX}${SPACE}${mac_address_hex}${SPACE}${DHCP}
109 Run IPMI command ${ipmi_raw_cmd}
110
111 ${resp}= Read Attribute /org/openbmc/settings/host0 network_config
112 Should Contain ${resp} addr_type=0
113
114
115Clear Address With IPMI
116 [Documentation] This testcase is to clear host's network setting
117 ... using IPMI. Later verify using REST that it is
118 ... cleared.
119 [Tags] Clear_Address_With_IPMI
120
121 Run IPMI command ${CLEAR_ADDR}
122
123 ${resp}= Read Attribute /org/openbmc/settings/host0 network_config
124 Should Be Equal ${resp} ipaddress=,prefix=,gateway=,mac=,addr_type=
125
126
127Set Invalid Address With REST
128 [Documentation] This testcase is to verify that proper error message is
129 ... prompted by REST with invalid mac address for
130 ... host's network setting.
131 [Tags] Set_Invalid_Address_With_REST
132
133 ${ip_address}= utilities.random_ip
134 ${gateway}= utilities.random_ip
135 ${subnet}= Evaluate random.randint(0, 32) modules=random
136
137 ${invalid_settings}= Catenate SEPARATOR=
138 ... ipaddress=${ip_address},prefix=${subnet},gateway=${gateway},
139 ... mac=${INVALID_MAC},addr_type=1
140
141 ${resp}= Set Network Override Setting ${invalid_settings}
142 Should Be Equal ${resp} error
143
144
145Set Invalid Address With IPMI
146 [Documentation] This testcase is to verify that invalid mac address for
147 ... host's network setting can not be set by IPMI.
148 [Tags] Set_Invalid_Address_With_IPMI
149
150 ${ip_address}= utilities.random_ip
151 ${gateway}= utilities.random_ip
152 ${subnet}= Evaluate random.randint(0, 32) modules=random
153
154 ${ip_address_hex}= IP Address To Hex String ${ip_address}
155 ${gateway_hex}= IP Address To Hex String ${gateway}
156 ${invalid_mac_hex}= Mac Address To Hex String ${INVALID_MAC}
157 ${subnet_hex}= Convert To Hex ${subnet} prefix=0x
158 ... lowercase=yes
159
160 ${ipmi_raw_cmd}= Catenate SEPARATOR=
161 ... ${SET_ADDR_PREFIX}${SPACE}${invalid_mac_hex}${SPACE}${STATIC}${SPACE}
162 ... ${ip_address_hex}${SPACE}${subnet_hex}${SPACE}${gateway_hex}
163 Run IPMI command ${ipmi_raw_cmd}
164
165 ${invalid_settings}= Catenate SEPARATOR=
166 ... ipaddress=${ip_address},prefix=${subnet},gateway=${gateway},
167 ... mac=${INVALID_MAC},addr_type=1
168
169 ${resp}= Read Attribute /org/openbmc/settings/host0 network_config
170 Should Not Be Equal ${resp} ${invalid_settings}
171
172
173*** Keywords ***
174
175Set Network Override Setting
176 [Documentation] Set host's network settings with passed arguments and
177 ... return its status.
178 ... Description of arguments:
179 ... settings Network settings which need to be set
180 [Arguments] ${settings}
181 ${host_network}= Set Variable ${settings}
182 ${valueDict}= create dictionary data=${host_network}
183 ${resp}= OpenBMC Put Request
184 ... /org/openbmc/settings/host0/attr/network_config data=${valueDict}
185 ${jsondata}= to json ${resp.content}
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600186 [Return] ${jsondata['status']}
Rahul Maheshwari757d80c2016-10-17 01:09:55 -0500187
188Post Test Execution
189 [Documentation] Perform operations after test execution. Captures FFDC
190 ... in case of test case failure and sets defaults values
191 ... for host's network settings.
192
193 FFDC On Test Case Fail
194
195 Run IPMI command ${CLEAR_ADDR}