blob: 0c24908e697c7890f36a8932b50860d613951dc3 [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
Sweta Potthuridda695e2023-04-26 02:10:38 -0500163Apply DHCP Config
164 [Documentation] Apply DHCP Config
165 [Arguments] ${property}
166
167 # Description of Argument(s):
168 # property DHCP property values.
169
Sweta Potthurid5979842025-05-21 23:17:17 -0500170 Redfish.Patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
Sweta Potthuridda695e2023-04-26 02:10:38 -0500171 ... body={"DHCPv4":${property}} valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
172
Sweta Potthurid5979842025-05-21 23:17:17 -0500173 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
Sweta Potthuridda695e2023-04-26 02:10:38 -0500174 Verify Ethernet Config Property ${property} ${resp.dict["DHCPv4"]}
175
Sweta Potthurid5979842025-05-21 23:17:17 -0500176Apply DHCPv6 Config And Verify
177 [Documentation] Apply DHCPv6 config and verify.
178 [Arguments] ${property}
179
180 # Description of Argument(s):
181 # property DHCPv6 property values.
182
183 Redfish.Patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
184 ... body={"DHCPv6":${property}} valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
185 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
186
187 Verify Ethernet Config Property ${property} ${resp.dict["DHCPv6"]}
Sweta Potthuridda695e2023-04-26 02:10:38 -0500188
189Verify Ethernet Config Property
190 [Documentation] verify ethernet config properties.
191 [Arguments] ${property} ${response_data}
192
193 # Description of argument(s):
Sridevi Rameshed94c692025-09-07 23:41:10 -0500194 # property DHCP Properties in dictionary.
195 # Example:
196 # property value
197 # DHCPEnabled :False
198 # UseDomainName :True
199 # UseNTPServers :True
200 # UseDNSServers :True
201 # response_data DHCP Response data in dictionary.
202 # Example:
203 # property value
204 # DHCPEnabled :False
205 # UseDomainName :True
206 # UseNTPServers :True
207 # UseDNSServers :True
Sweta Potthuridda695e2023-04-26 02:10:38 -0500208
209 ${key_map}= Get Dictionary Items ${property}
210 FOR ${key} ${value} IN @{key_map}
211 Should Be Equal As Strings ${response_data['${key}']} ${value}
212 END
213
214Restore Configuration
215 [Documentation] Restore the configuration to Both Static Network
216
George Keishinge6e161e2025-05-08 10:18:30 +0530217 IF '${CHANNEL_NUMBER}' == '${1}'
218 Add IP Address ${OPENBMC_HOST} ${eth0_subnet_mask} ${eth0_gateway}
219 ELSE IF '${CHANNEL_NUMBER}' == '{2}'
220 Add IP Address ${OPENBMC_HOST_ETH1} ${eth1_subnet_mask} ${eth1_gateway}
221 END
Sweta Potthuridda695e2023-04-26 02:10:38 -0500222
223Get Network Configuration Using Channel Number
224 [Documentation] Get ethernet interface.
225 [Arguments] ${channel_number}
226
227 # Description of argument(s):
228 # channel_number Ethernet channel number, 1 is for eth0 and 2 is for eth1 (e.g. "1").
229
Sweta Potthuridda695e2023-04-26 02:10:38 -0500230 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
231
232 @{network_configurations}= Get From Dictionary ${resp.dict} IPv4StaticAddresses
George Keishing409df052024-01-17 22:36:14 +0530233 RETURN @{network_configurations}
Sweta Potthuridda695e2023-04-26 02:10:38 -0500234
Sweta Potthuriab871742023-02-20 11:08:42 -0600235Suite Setup Execution
236 [Documentation] Do suite setup task.
237
238 Ping Host ${OPENBMC_HOST}
239 Redfish.Login
Sweta Potthuridda695e2023-04-26 02:10:38 -0500240
Sweta Potthurid5979842025-05-21 23:17:17 -0500241 ${active_channel_config}= Get Active Channel Config
242 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
243
Sweta Potthuridda695e2023-04-26 02:10:38 -0500244 # Get the configuration of eth1
245 ${network_configurations}= Get Network Configuration Using Channel Number ${2}
246 FOR ${network_configuration} IN @{network_configurations}
Sridevi Ramesh6dcfc392025-05-06 11:09:43 -0500247 IF '${network_configuration['Address']}' == '${OPENBMC_HOST_ETH1}'
248 Set Suite Variable ${eth1_subnet_mask} ${network_configuration['SubnetMask']}
249 Set Suite Variable ${eth1_gateway} ${network_configuration['Gateway']}
250 BREAK
251 END
Sweta Potthuridda695e2023-04-26 02:10:38 -0500252 END
253
254 # Get the configuration of eth0
255 ${network_configurations}= Get Network Configuration Using Channel Number ${1}
256 FOR ${network_configuration} IN @{network_configurations}
Sridevi Ramesh6dcfc392025-05-06 11:09:43 -0500257 IF '${network_configuration['Address']}' == '${OPENBMC_HOST}'
258 Set Suite Variable ${eth0_subnet_mask} ${network_configuration['SubnetMask']}
259 Set Suite Variable ${eth0_gateway} ${network_configuration['Gateway']}
260 BREAK
261 END
Sweta Potthuridda695e2023-04-26 02:10:38 -0500262 END