blob: 8f818cd7993a49ca50764d41c0a6315a3a4a9583 [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
15*** Variables ***
16
17&{DHCP_ENABLED} DHCPEnabled=${True}
18&{DHCP_DISABLED} DHCPEnabled=${False}
19&{ENABLE_DHCP} DHCPv4=${DHCP_ENABLED}
20&{DISABLE_DHCP} DHCPv4=${DHCP_DISABLED}
21${ethernet_interface} eth1
22
Sweta Potthuridda695e2023-04-26 02:10:38 -050023&{dns_enable_dict} UseDNSServers=${True}
24&{dns_disable_dict} UseDNSServers=${False}
25&{ntp_enable_dict} UseNTPServers=${True}
26&{ntp_disable_dict} UseNTPServers=${False}
27&{domain_name_enable_dict} UseDomainName=${True}
28&{domain_name_disable_dict} UseDomainName=${False}
29&{enable_multiple_properties} UseDomainName=${True}
30... UseNTPServers=${True}
31... UseDNSServers=${True}
32&{disable_multiple_properties} UseDomainName=${False}
33... UseNTPServers=${False}
34... UseDNSServers=${False}
35
Sweta Potthuri51ce1212023-10-11 02:18:12 -050036Force Tags Multiple_Interfaces_DHCP
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
65 [Teardown] Restore Configuration
66 [Template] Apply DHCP Config
67
68 # property
69 ${dns_enable_dict}
70 ${dns_disable_dict}
71 ${domain_name_enable_dict}
72 ${domain_name_disable_dict}
73 ${ntp_enable_dict}
74 ${ntp_disable_dict}
75 ${enable_multiple_properties}
76 ${disable_multiple_properties}
77
Sweta Potthuri51ce1212023-10-11 02:18:12 -050078Enable DHCP On Eth1 And Check No Impact On Eth0
79 [Documentation] Enable DHCP On Eth1 And Check No Impact On Eth0.
80 [Tags] Enable_DHCP_On_Eth1_And_Check_No_Impact_On_Eth0
81 [Setup] Set DHCPEnabled To Enable Or Disable False eth1
82
83 # Getting the eth0 details before enabling DHCP.
84 ${ip_data_before}= Get BMC IP Info
85
Sweta Potthuri49c86a02023-10-12 07:43:13 -050086 # Enable DHCP on eth1.
Sweta Potthuri51ce1212023-10-11 02:18:12 -050087 Set DHCPEnabled To Enable Or Disable True eth1
88
89 # Check the value of DHCPEnabled on eth0 is not impacted.
Sweta Potthuri0e3f3f82023-10-19 05:30:29 -050090 ${DHCPEnabled}= Get IPv4 DHCP Enabled Status ${1}
Sweta Potthuri51ce1212023-10-11 02:18:12 -050091 Should Be Equal ${DHCPEnabled} ${False}
92
93 # Getting eth0 details after enabling DHCP.
94 ${ip_data_after}= Get BMC IP Info
95
96 # Before and after IP details must match.
97 Should Be Equal ${ip_data_before} ${ip_data_after}
98
Sweta Potthuri49c86a02023-10-12 07:43:13 -050099Switch Between DHCP And Static
100 [Documentation] Switch between DHCP and static.
101 [Tags] Switch_Between_DHCP_And_Static
102 [Teardown] Set DHCPEnabled To Enable Or Disable True eth1
103
104 # Fetch the IP details before.
105 ${ip_addr_before} ${gateway_before} ${subnetmask_before} Get DHCP IP Info
106
107 # Switch Between Static and DHCP.
108 FOR ${i} IN RANGE ${10}
109 Set DHCPEnabled To Enable Or Disable False eth1
110 Set DHCPEnabled To Enable Or Disable True eth1
111 END
112 Sleep 5s
113
114 # Fetch the IP details after.
115 ${ip_addr_after} ${gateway_after} ${subnetmask_after} Get DHCP IP Info
116
117 # DHCP Details must be the same before and after.
118 Should Be Equal ${ip_addr_before} ${ip_addr_after}
119 Should Be Equal ${gateway_before} ${gateway_after}
120 Should Be Equal ${subnetmask_before} ${subnetmask_after}
121
Sweta Potthuri0e3f3f82023-10-19 05:30:29 -0500122Disable DHCP On Eth1 And Verify DHCP IP Erased
123 [Documentation] Disable DHCP on Eth1 and verify DHCP IP erased.
124 [Tags] Disable_DHCP_On_Eth1_And_Verify_DHCP_IP_Erased
125 [Teardown] Set DHCPEnabled To Enable Or Disable True eth1
126
127 Set DHCPEnabled To Enable Or Disable False eth1
128 ${DHCPEnabled}= Get IPv4 DHCP Enabled Status ${2}
129 Should Be Equal ${DHCPEnabled} ${False}
130
131 ${dhcp_ip_list}= Get Network Configuration Using Channel Number ${2}
132
133 Should Be Empty ${dhcp_ip_list}
134 ... msg=From switching from DHCP to Static DHCP IP is not erased.
135
Sweta Potthuriab871742023-02-20 11:08:42 -0600136*** Keywords ***
137
138Set DHCPEnabled To Enable Or Disable
139 [Documentation] Enable or Disable DHCP on the interface.
George Keishing618aff72023-03-09 09:55:19 +0530140 [Arguments] ${dhcp_enabled}=${False} ${interface}=${ethernet_interface}
141 ... ${valid_status_code}=[${HTTP_OK},${HTTP_ACCEPTED}]
Sweta Potthuriab871742023-02-20 11:08:42 -0600142
143 # Description of argument(s):
144 # dhcp_enabled False for disabling DHCP and True for Enabling DHCP.
145 # interface eth0 or eth1. Default is eth1.
George Keishing618aff72023-03-09 09:55:19 +0530146 # valid_status_code Expected valid status code from Patch request.
147 # Default is HTTP_OK.
Sweta Potthuriab871742023-02-20 11:08:42 -0600148
149 ${data}= Set Variable If ${dhcp_enabled} == ${False} ${DISABLE_DHCP} ${ENABLE_DHCP}
150 ${resp}= Redfish.Patch
ganesanb4d430282023-04-27 14:33:23 +0000151 ... /redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/${interface}
Sweta Potthuriab871742023-02-20 11:08:42 -0600152 ... body=${data} valid_status_codes=${valid_status_code}
153
Sweta Potthuridda695e2023-04-26 02:10:38 -0500154Apply DHCP Config
155 [Documentation] Apply DHCP Config
156 [Arguments] ${property}
157
158 # Description of Argument(s):
159 # property DHCP property values.
160
161 ${active_channel_config}= Get Active Channel Config
162 Redfish.Patch
ganesanb26e59572023-06-09 07:55:47 +0000163 ... /redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}/
Sweta Potthuridda695e2023-04-26 02:10:38 -0500164 ... body={"DHCPv4":${property}} valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
165
166 ${resp}= Redfish.Get
ganesanb26e59572023-06-09 07:55:47 +0000167 ... /redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
Sweta Potthuridda695e2023-04-26 02:10:38 -0500168 Verify Ethernet Config Property ${property} ${resp.dict["DHCPv4"]}
169
170
171Verify Ethernet Config Property
172 [Documentation] verify ethernet config properties.
173 [Arguments] ${property} ${response_data}
174
175 # Description of argument(s):
176 # ${property} DHCP Properties in dictionary.
177 # Example:
178 # property value
179 # DHCPEnabled :False
180 # UseDomainName :True
181 # UseNTPServers :True
182 # UseDNSServers :True
183 # ${response_data} DHCP Response data in dictionary.
184 # Example:
185 # property value
186 # DHCPEnabled :False
187 # UseDomainName :True
188 # UseNTPServers :True
189 # UseDNSServers :True
190
191 ${key_map}= Get Dictionary Items ${property}
192 FOR ${key} ${value} IN @{key_map}
193 Should Be Equal As Strings ${response_data['${key}']} ${value}
194 END
195
196Restore Configuration
197 [Documentation] Restore the configuration to Both Static Network
198
Sweta Potthuri0e3f3f82023-10-19 05:30:29 -0500199 Run Keyword If '${CHANNEL_NUMBER}' == '${1}' Add IP Address ${OPENBMC_HOST} ${eth0_subnet_mask} ${eth0_gateway}
200 ... ELSE IF '${CHANNEL_NUMBER}' == '{2}' Add IP Address ${OPENBMC_HOST_1} ${eth1_subnet_mask} ${eth1_gateway}
Sweta Potthuridda695e2023-04-26 02:10:38 -0500201
202Get Network Configuration Using Channel Number
203 [Documentation] Get ethernet interface.
204 [Arguments] ${channel_number}
205
206 # Description of argument(s):
207 # channel_number Ethernet channel number, 1 is for eth0 and 2 is for eth1 (e.g. "1").
208
209 ${active_channel_config}= Get Active Channel Config
210 ${ethernet_interface}= Set Variable ${active_channel_config['${channel_number}']['name']}
211 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
212
213 @{network_configurations}= Get From Dictionary ${resp.dict} IPv4StaticAddresses
214 [Return] @{network_configurations}
215
Sweta Potthuriab871742023-02-20 11:08:42 -0600216Suite Setup Execution
217 [Documentation] Do suite setup task.
218
219 Ping Host ${OPENBMC_HOST}
220 Redfish.Login
Sweta Potthuridda695e2023-04-26 02:10:38 -0500221
222 # Get the configuration of eth1
223 ${network_configurations}= Get Network Configuration Using Channel Number ${2}
224 FOR ${network_configuration} IN @{network_configurations}
225 Run Keyword If '${network_configuration['Address']}' == '${OPENBMC_HOST_1}'
226 ... Run Keywords Set Suite Variable ${eth1_subnet_mask} ${network_configuration['SubnetMask']}
227 ... AND Set Suite Variable ${eth1_gateway} ${network_configuration['Gateway']}
228 ... AND Exit For Loop
229 END
230
231 # Get the configuration of eth0
232 ${network_configurations}= Get Network Configuration Using Channel Number ${1}
233 FOR ${network_configuration} IN @{network_configurations}
234 Run Keyword If '${network_configuration['Address']}' == '${OPENBMC_HOST}'
235 ... Run Keywords Set Suite Variable ${eth0_subnet_mask} ${network_configuration['SubnetMask']}
236 ... AND Set Suite Variable ${eth0_gateway} ${network_configuration['Gateway']}
237 ... AND Exit For Loop
238 END