blob: dc9c7b235e5216c42762d6960876dc669f196566 [file] [log] [blame]
Sweta Potthuriab871742023-02-20 11:08:42 -06001*** Settings ***
2Documentation Test BMC DHCP multiple network interface functionalities.
Sweta Potthuri49c86a02023-10-12 07:43:13 -05003 ... Run on setup eth0 in static and eth1 in DHCP.
Sweta Potthuriab871742023-02-20 11:08:42 -06004
5Resource ../../lib/resource.robot
6Resource ../../lib/common_utils.robot
7Resource ../../lib/connection_client.robot
8Resource ../../lib/bmc_network_utils.robot
9Resource ../../lib/openbmc_ffdc.robot
10
11Suite Setup Suite Setup Execution
12Test Teardown FFDC On Test Case Fail
13Suite Teardown Redfish.Logout
14
George Keishing3d87b0e2025-02-06 18:35:23 +053015Test Tags Multiple_Interfaces_DHCP
16
Sweta Potthuriab871742023-02-20 11:08:42 -060017*** Variables ***
18
19&{DHCP_ENABLED} DHCPEnabled=${True}
20&{DHCP_DISABLED} DHCPEnabled=${False}
21&{ENABLE_DHCP} DHCPv4=${DHCP_ENABLED}
22&{DISABLE_DHCP} DHCPv4=${DHCP_DISABLED}
23${ethernet_interface} eth1
24
Sweta Potthuridda695e2023-04-26 02:10:38 -050025&{dns_enable_dict} UseDNSServers=${True}
26&{dns_disable_dict} UseDNSServers=${False}
27&{ntp_enable_dict} UseNTPServers=${True}
28&{ntp_disable_dict} UseNTPServers=${False}
29&{domain_name_enable_dict} UseDomainName=${True}
30&{domain_name_disable_dict} UseDomainName=${False}
31&{enable_multiple_properties} UseDomainName=${True}
32... UseNTPServers=${True}
33... UseDNSServers=${True}
34&{disable_multiple_properties} UseDomainName=${False}
35... UseNTPServers=${False}
36... UseDNSServers=${False}
37
Sweta Potthuriab871742023-02-20 11:08:42 -060038*** Test Cases ***
39
40Disable DHCP On Eth1 And Verify System Is Accessible By Eth0
George Keishing618aff72023-03-09 09:55:19 +053041 [Documentation] Disable DHCP on eth1 using Redfish and verify
42 ... if system is accessible by eth0.
Sweta Potthuriab871742023-02-20 11:08:42 -060043 [Tags] Disable_DHCP_On_Eth1_And_Verify_System_Is_Accessible_By_Eth0
44 [Teardown] Set DHCPEnabled To Enable Or Disable True eth1
45
46 Set DHCPEnabled To Enable Or Disable False eth1
Sweta Potthuri0e3f3f82023-10-19 05:30:29 -050047 ${DHCPEnabled}= Get IPv4 DHCP Enabled Status ${2}
Sweta Potthuri49c86a02023-10-12 07:43:13 -050048 Should Be Equal ${DHCPEnabled} ${False}
Sweta Potthuriab871742023-02-20 11:08:42 -060049 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT}
50
51Enable DHCP On Eth1 And Verify System Is Accessible By Eth0
George Keishing618aff72023-03-09 09:55:19 +053052 [Documentation] Enable DHCP on eth1 using Redfish and verify if system
53 ... is accessible by eth0.
Sweta Potthuriab871742023-02-20 11:08:42 -060054 [Tags] Enable_DHCP_On_Eth1_And_Verify_System_Is_Accessible_By_Eth0
55 [Setup] Set DHCPEnabled To Enable Or Disable False eth1
56
57 Set DHCPEnabled To Enable Or Disable True eth1
Sweta Potthuri0e3f3f82023-10-19 05:30:29 -050058 ${DHCPEnabled}= Get IPv4 DHCP Enabled Status ${2}
Sweta Potthuri49c86a02023-10-12 07:43:13 -050059 Should Be Equal ${DHCPEnabled} ${True}
Sweta Potthuriab871742023-02-20 11:08:42 -060060 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT}
61
Sweta Potthuridda695e2023-04-26 02:10:38 -050062Set Network Property via Redfish And Verify
63 [Documentation] Set network property via Redfish and verify.
64 [Tags] Set_Network_Property_via_Redfish_And_Verify
Sweta Potthuridda695e2023-04-26 02:10:38 -050065 [Template] Apply DHCP Config
66
67 # property
68 ${dns_enable_dict}
69 ${dns_disable_dict}
70 ${domain_name_enable_dict}
71 ${domain_name_disable_dict}
72 ${ntp_enable_dict}
73 ${ntp_disable_dict}
74 ${enable_multiple_properties}
75 ${disable_multiple_properties}
76
Sweta Potthurid5979842025-05-21 23:17:17 -050077Set Network Property For DHCPv6 via Redfish And Verify
78 [Documentation] Set network property for DHCPv6 via Redfish and verify.
79 [Tags] Set_Network_Property_For_DHCPv6_via_Redfish_And_Verify
80 [Template] Apply DHCPv6 Config And Verify
81
82 # property
83 ${dns_enable_dict}
84 ${dns_disable_dict}
85 ${domain_name_enable_dict}
86 ${domain_name_disable_dict}
87 ${ntp_enable_dict}
88 ${ntp_disable_dict}
89 ${enable_multiple_properties}
90 ${disable_multiple_properties}
91
Sweta Potthuri51ce1212023-10-11 02:18:12 -050092Enable DHCP On Eth1 And Check No Impact On Eth0
93 [Documentation] Enable DHCP On Eth1 And Check No Impact On Eth0.
94 [Tags] Enable_DHCP_On_Eth1_And_Check_No_Impact_On_Eth0
95 [Setup] Set DHCPEnabled To Enable Or Disable False eth1
96
97 # Getting the eth0 details before enabling DHCP.
98 ${ip_data_before}= Get BMC IP Info
99
Sweta Potthuri49c86a02023-10-12 07:43:13 -0500100 # Enable DHCP on eth1.
Sweta Potthuri51ce1212023-10-11 02:18:12 -0500101 Set DHCPEnabled To Enable Or Disable True eth1
102
103 # Check the value of DHCPEnabled on eth0 is not impacted.
Sweta Potthuri0e3f3f82023-10-19 05:30:29 -0500104 ${DHCPEnabled}= Get IPv4 DHCP Enabled Status ${1}
Sweta Potthuri51ce1212023-10-11 02:18:12 -0500105 Should Be Equal ${DHCPEnabled} ${False}
106
107 # Getting eth0 details after enabling DHCP.
108 ${ip_data_after}= Get BMC IP Info
109
110 # Before and after IP details must match.
111 Should Be Equal ${ip_data_before} ${ip_data_after}
112
Sweta Potthuridad3b9b2024-01-03 08:19:38 -0600113Enable DHCP On Eth1 And Check Persistency On Reboot
114 [Documentation] Enable DHCP on Eth1 and check persistency
115 ... on reboot and should not switch to static.
116 [Tags] Enable_DHCP_On_Eth1_And_Check_Persistency_On_Reboot
117 [Setup] Set DHCPEnabled To Enable Or Disable False eth1
118
119 Set DHCPEnabled To Enable Or Disable True eth1
120 Redfish OBMC Reboot (off) stack_mode=skip
121 ${DHCPEnabled}= Get IPv4 DHCP Enabled Status ${2}
122 Should Be Equal ${DHCPEnabled} ${True}
123
Sweta Potthuri49c86a02023-10-12 07:43:13 -0500124Switch Between DHCP And Static
125 [Documentation] Switch between DHCP and static.
126 [Tags] Switch_Between_DHCP_And_Static
127 [Teardown] Set DHCPEnabled To Enable Or Disable True eth1
128
129 # Fetch the IP details before.
130 ${ip_addr_before} ${gateway_before} ${subnetmask_before} Get DHCP IP Info
131
132 # Switch Between Static and DHCP.
133 FOR ${i} IN RANGE ${10}
134 Set DHCPEnabled To Enable Or Disable False eth1
135 Set DHCPEnabled To Enable Or Disable True eth1
136 END
137 Sleep 5s
138
139 # Fetch the IP details after.
140 ${ip_addr_after} ${gateway_after} ${subnetmask_after} Get DHCP IP Info
141
142 # DHCP Details must be the same before and after.
143 Should Be Equal ${ip_addr_before} ${ip_addr_after}
144 Should Be Equal ${gateway_before} ${gateway_after}
145 Should Be Equal ${subnetmask_before} ${subnetmask_after}
146
Sweta Potthuri0e3f3f82023-10-19 05:30:29 -0500147Disable DHCP On Eth1 And Verify DHCP IP Erased
148 [Documentation] Disable DHCP on Eth1 and verify DHCP IP erased.
149 [Tags] Disable_DHCP_On_Eth1_And_Verify_DHCP_IP_Erased
150 [Teardown] Set DHCPEnabled To Enable Or Disable True eth1
151
152 Set DHCPEnabled To Enable Or Disable False eth1
153 ${DHCPEnabled}= Get IPv4 DHCP Enabled Status ${2}
154 Should Be Equal ${DHCPEnabled} ${False}
155
156 ${dhcp_ip_list}= Get Network Configuration Using Channel Number ${2}
157
158 Should Be Empty ${dhcp_ip_list}
159 ... msg=From switching from DHCP to Static DHCP IP is not erased.
160
Sweta Potthuriab871742023-02-20 11:08:42 -0600161*** Keywords ***
162
163Set DHCPEnabled To Enable Or Disable
164 [Documentation] Enable or Disable DHCP on the interface.
George Keishing618aff72023-03-09 09:55:19 +0530165 [Arguments] ${dhcp_enabled}=${False} ${interface}=${ethernet_interface}
George Keishing45e1d5f2025-03-11 19:24:36 +0530166 ... ${valid_status_code}=[${HTTP_OK},${HTTP_ACCEPTED},${HTTP_NO_CONTENT}]
Sweta Potthuriab871742023-02-20 11:08:42 -0600167
168 # Description of argument(s):
169 # dhcp_enabled False for disabling DHCP and True for Enabling DHCP.
170 # interface eth0 or eth1. Default is eth1.
George Keishing618aff72023-03-09 09:55:19 +0530171 # valid_status_code Expected valid status code from Patch request.
172 # Default is HTTP_OK.
Sweta Potthuriab871742023-02-20 11:08:42 -0600173
174 ${data}= Set Variable If ${dhcp_enabled} == ${False} ${DISABLE_DHCP} ${ENABLE_DHCP}
175 ${resp}= Redfish.Patch
ganesanb4d430282023-04-27 14:33:23 +0000176 ... /redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/${interface}
Sweta Potthuriab871742023-02-20 11:08:42 -0600177 ... body=${data} valid_status_codes=${valid_status_code}
178
Sweta Potthuridda695e2023-04-26 02:10:38 -0500179Apply DHCP Config
180 [Documentation] Apply DHCP Config
181 [Arguments] ${property}
182
183 # Description of Argument(s):
184 # property DHCP property values.
185
Sweta Potthurid5979842025-05-21 23:17:17 -0500186 Redfish.Patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
Sweta Potthuridda695e2023-04-26 02:10:38 -0500187 ... body={"DHCPv4":${property}} valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
188
Sweta Potthurid5979842025-05-21 23:17:17 -0500189 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
Sweta Potthuridda695e2023-04-26 02:10:38 -0500190 Verify Ethernet Config Property ${property} ${resp.dict["DHCPv4"]}
191
Sweta Potthurid5979842025-05-21 23:17:17 -0500192Apply DHCPv6 Config And Verify
193 [Documentation] Apply DHCPv6 config and verify.
194 [Arguments] ${property}
195
196 # Description of Argument(s):
197 # property DHCPv6 property values.
198
199 Redfish.Patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
200 ... body={"DHCPv6":${property}} valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
201 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
202
203 Verify Ethernet Config Property ${property} ${resp.dict["DHCPv6"]}
Sweta Potthuridda695e2023-04-26 02:10:38 -0500204
205Verify Ethernet Config Property
206 [Documentation] verify ethernet config properties.
207 [Arguments] ${property} ${response_data}
208
209 # Description of argument(s):
210 # ${property} DHCP Properties in dictionary.
211 # Example:
212 # property value
213 # DHCPEnabled :False
214 # UseDomainName :True
215 # UseNTPServers :True
216 # UseDNSServers :True
217 # ${response_data} DHCP Response data in dictionary.
218 # Example:
219 # property value
220 # DHCPEnabled :False
221 # UseDomainName :True
222 # UseNTPServers :True
223 # UseDNSServers :True
224
225 ${key_map}= Get Dictionary Items ${property}
226 FOR ${key} ${value} IN @{key_map}
227 Should Be Equal As Strings ${response_data['${key}']} ${value}
228 END
229
230Restore Configuration
231 [Documentation] Restore the configuration to Both Static Network
232
George Keishinge6e161e2025-05-08 10:18:30 +0530233 IF '${CHANNEL_NUMBER}' == '${1}'
234 Add IP Address ${OPENBMC_HOST} ${eth0_subnet_mask} ${eth0_gateway}
235 ELSE IF '${CHANNEL_NUMBER}' == '{2}'
236 Add IP Address ${OPENBMC_HOST_ETH1} ${eth1_subnet_mask} ${eth1_gateway}
237 END
Sweta Potthuridda695e2023-04-26 02:10:38 -0500238
239Get Network Configuration Using Channel Number
240 [Documentation] Get ethernet interface.
241 [Arguments] ${channel_number}
242
243 # Description of argument(s):
244 # channel_number Ethernet channel number, 1 is for eth0 and 2 is for eth1 (e.g. "1").
245
Sweta Potthuridda695e2023-04-26 02:10:38 -0500246 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
247
248 @{network_configurations}= Get From Dictionary ${resp.dict} IPv4StaticAddresses
George Keishing409df052024-01-17 22:36:14 +0530249 RETURN @{network_configurations}
Sweta Potthuridda695e2023-04-26 02:10:38 -0500250
Sweta Potthuriab871742023-02-20 11:08:42 -0600251Suite Setup Execution
252 [Documentation] Do suite setup task.
253
254 Ping Host ${OPENBMC_HOST}
255 Redfish.Login
Sweta Potthuridda695e2023-04-26 02:10:38 -0500256
Sweta Potthurid5979842025-05-21 23:17:17 -0500257 ${active_channel_config}= Get Active Channel Config
258 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
259
Sweta Potthuridda695e2023-04-26 02:10:38 -0500260 # Get the configuration of eth1
261 ${network_configurations}= Get Network Configuration Using Channel Number ${2}
262 FOR ${network_configuration} IN @{network_configurations}
Sridevi Ramesh6dcfc392025-05-06 11:09:43 -0500263 IF '${network_configuration['Address']}' == '${OPENBMC_HOST_ETH1}'
264 Set Suite Variable ${eth1_subnet_mask} ${network_configuration['SubnetMask']}
265 Set Suite Variable ${eth1_gateway} ${network_configuration['Gateway']}
266 BREAK
267 END
Sweta Potthuridda695e2023-04-26 02:10:38 -0500268 END
269
270 # Get the configuration of eth0
271 ${network_configurations}= Get Network Configuration Using Channel Number ${1}
272 FOR ${network_configuration} IN @{network_configurations}
Sridevi Ramesh6dcfc392025-05-06 11:09:43 -0500273 IF '${network_configuration['Address']}' == '${OPENBMC_HOST}'
274 Set Suite Variable ${eth0_subnet_mask} ${network_configuration['SubnetMask']}
275 Set Suite Variable ${eth0_gateway} ${network_configuration['Gateway']}
276 BREAK
277 END
Sweta Potthuridda695e2023-04-26 02:10:38 -0500278 END