Sweta Potthuri | ab87174 | 2023-02-20 11:08:42 -0600 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Test BMC DHCP multiple network interface functionalities. |
Sweta Potthuri | 49c86a0 | 2023-10-12 07:43:13 -0500 | [diff] [blame] | 3 | ... Run on setup eth0 in static and eth1 in DHCP. |
Sweta Potthuri | ab87174 | 2023-02-20 11:08:42 -0600 | [diff] [blame] | 4 | |
| 5 | Resource ../../lib/resource.robot |
| 6 | Resource ../../lib/common_utils.robot |
| 7 | Resource ../../lib/connection_client.robot |
| 8 | Resource ../../lib/bmc_network_utils.robot |
| 9 | Resource ../../lib/openbmc_ffdc.robot |
| 10 | |
| 11 | Suite Setup Suite Setup Execution |
| 12 | Test Teardown FFDC On Test Case Fail |
| 13 | Suite 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 Potthuri | dda695e | 2023-04-26 02:10:38 -0500 | [diff] [blame] | 23 | &{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 Potthuri | 51ce121 | 2023-10-11 02:18:12 -0500 | [diff] [blame] | 36 | Force Tags Multiple_Interfaces_DHCP |
| 37 | |
Sweta Potthuri | ab87174 | 2023-02-20 11:08:42 -0600 | [diff] [blame] | 38 | *** Test Cases *** |
| 39 | |
| 40 | Disable DHCP On Eth1 And Verify System Is Accessible By Eth0 |
George Keishing | 618aff7 | 2023-03-09 09:55:19 +0530 | [diff] [blame] | 41 | [Documentation] Disable DHCP on eth1 using Redfish and verify |
| 42 | ... if system is accessible by eth0. |
Sweta Potthuri | ab87174 | 2023-02-20 11:08:42 -0600 | [diff] [blame] | 43 | [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 Potthuri | 0e3f3f8 | 2023-10-19 05:30:29 -0500 | [diff] [blame] | 47 | ${DHCPEnabled}= Get IPv4 DHCP Enabled Status ${2} |
Sweta Potthuri | 49c86a0 | 2023-10-12 07:43:13 -0500 | [diff] [blame] | 48 | Should Be Equal ${DHCPEnabled} ${False} |
Sweta Potthuri | ab87174 | 2023-02-20 11:08:42 -0600 | [diff] [blame] | 49 | Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT} |
| 50 | |
| 51 | Enable DHCP On Eth1 And Verify System Is Accessible By Eth0 |
George Keishing | 618aff7 | 2023-03-09 09:55:19 +0530 | [diff] [blame] | 52 | [Documentation] Enable DHCP on eth1 using Redfish and verify if system |
| 53 | ... is accessible by eth0. |
Sweta Potthuri | ab87174 | 2023-02-20 11:08:42 -0600 | [diff] [blame] | 54 | [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 Potthuri | 0e3f3f8 | 2023-10-19 05:30:29 -0500 | [diff] [blame] | 58 | ${DHCPEnabled}= Get IPv4 DHCP Enabled Status ${2} |
Sweta Potthuri | 49c86a0 | 2023-10-12 07:43:13 -0500 | [diff] [blame] | 59 | Should Be Equal ${DHCPEnabled} ${True} |
Sweta Potthuri | ab87174 | 2023-02-20 11:08:42 -0600 | [diff] [blame] | 60 | Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT} |
| 61 | |
Sweta Potthuri | dda695e | 2023-04-26 02:10:38 -0500 | [diff] [blame] | 62 | Set 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 Potthuri | 51ce121 | 2023-10-11 02:18:12 -0500 | [diff] [blame] | 78 | Enable 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 Potthuri | 49c86a0 | 2023-10-12 07:43:13 -0500 | [diff] [blame] | 86 | # Enable DHCP on eth1. |
Sweta Potthuri | 51ce121 | 2023-10-11 02:18:12 -0500 | [diff] [blame] | 87 | Set DHCPEnabled To Enable Or Disable True eth1 |
| 88 | |
| 89 | # Check the value of DHCPEnabled on eth0 is not impacted. |
Sweta Potthuri | 0e3f3f8 | 2023-10-19 05:30:29 -0500 | [diff] [blame] | 90 | ${DHCPEnabled}= Get IPv4 DHCP Enabled Status ${1} |
Sweta Potthuri | 51ce121 | 2023-10-11 02:18:12 -0500 | [diff] [blame] | 91 | 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 Potthuri | dad3b9b | 2024-01-03 08:19:38 -0600 | [diff] [blame] | 99 | Enable DHCP On Eth1 And Check Persistency On Reboot |
| 100 | [Documentation] Enable DHCP on Eth1 and check persistency |
| 101 | ... on reboot and should not switch to static. |
| 102 | [Tags] Enable_DHCP_On_Eth1_And_Check_Persistency_On_Reboot |
| 103 | [Setup] Set DHCPEnabled To Enable Or Disable False eth1 |
| 104 | |
| 105 | Set DHCPEnabled To Enable Or Disable True eth1 |
| 106 | Redfish OBMC Reboot (off) stack_mode=skip |
| 107 | ${DHCPEnabled}= Get IPv4 DHCP Enabled Status ${2} |
| 108 | Should Be Equal ${DHCPEnabled} ${True} |
| 109 | |
Sweta Potthuri | 49c86a0 | 2023-10-12 07:43:13 -0500 | [diff] [blame] | 110 | Switch Between DHCP And Static |
| 111 | [Documentation] Switch between DHCP and static. |
| 112 | [Tags] Switch_Between_DHCP_And_Static |
| 113 | [Teardown] Set DHCPEnabled To Enable Or Disable True eth1 |
| 114 | |
| 115 | # Fetch the IP details before. |
| 116 | ${ip_addr_before} ${gateway_before} ${subnetmask_before} Get DHCP IP Info |
| 117 | |
| 118 | # Switch Between Static and DHCP. |
| 119 | FOR ${i} IN RANGE ${10} |
| 120 | Set DHCPEnabled To Enable Or Disable False eth1 |
| 121 | Set DHCPEnabled To Enable Or Disable True eth1 |
| 122 | END |
| 123 | Sleep 5s |
| 124 | |
| 125 | # Fetch the IP details after. |
| 126 | ${ip_addr_after} ${gateway_after} ${subnetmask_after} Get DHCP IP Info |
| 127 | |
| 128 | # DHCP Details must be the same before and after. |
| 129 | Should Be Equal ${ip_addr_before} ${ip_addr_after} |
| 130 | Should Be Equal ${gateway_before} ${gateway_after} |
| 131 | Should Be Equal ${subnetmask_before} ${subnetmask_after} |
| 132 | |
Sweta Potthuri | 0e3f3f8 | 2023-10-19 05:30:29 -0500 | [diff] [blame] | 133 | Disable DHCP On Eth1 And Verify DHCP IP Erased |
| 134 | [Documentation] Disable DHCP on Eth1 and verify DHCP IP erased. |
| 135 | [Tags] Disable_DHCP_On_Eth1_And_Verify_DHCP_IP_Erased |
| 136 | [Teardown] Set DHCPEnabled To Enable Or Disable True eth1 |
| 137 | |
| 138 | Set DHCPEnabled To Enable Or Disable False eth1 |
| 139 | ${DHCPEnabled}= Get IPv4 DHCP Enabled Status ${2} |
| 140 | Should Be Equal ${DHCPEnabled} ${False} |
| 141 | |
| 142 | ${dhcp_ip_list}= Get Network Configuration Using Channel Number ${2} |
| 143 | |
| 144 | Should Be Empty ${dhcp_ip_list} |
| 145 | ... msg=From switching from DHCP to Static DHCP IP is not erased. |
| 146 | |
Sweta Potthuri | ab87174 | 2023-02-20 11:08:42 -0600 | [diff] [blame] | 147 | *** Keywords *** |
| 148 | |
| 149 | Set DHCPEnabled To Enable Or Disable |
| 150 | [Documentation] Enable or Disable DHCP on the interface. |
George Keishing | 618aff7 | 2023-03-09 09:55:19 +0530 | [diff] [blame] | 151 | [Arguments] ${dhcp_enabled}=${False} ${interface}=${ethernet_interface} |
| 152 | ... ${valid_status_code}=[${HTTP_OK},${HTTP_ACCEPTED}] |
Sweta Potthuri | ab87174 | 2023-02-20 11:08:42 -0600 | [diff] [blame] | 153 | |
| 154 | # Description of argument(s): |
| 155 | # dhcp_enabled False for disabling DHCP and True for Enabling DHCP. |
| 156 | # interface eth0 or eth1. Default is eth1. |
George Keishing | 618aff7 | 2023-03-09 09:55:19 +0530 | [diff] [blame] | 157 | # valid_status_code Expected valid status code from Patch request. |
| 158 | # Default is HTTP_OK. |
Sweta Potthuri | ab87174 | 2023-02-20 11:08:42 -0600 | [diff] [blame] | 159 | |
| 160 | ${data}= Set Variable If ${dhcp_enabled} == ${False} ${DISABLE_DHCP} ${ENABLE_DHCP} |
| 161 | ${resp}= Redfish.Patch |
ganesanb | 4d43028 | 2023-04-27 14:33:23 +0000 | [diff] [blame] | 162 | ... /redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/${interface} |
Sweta Potthuri | ab87174 | 2023-02-20 11:08:42 -0600 | [diff] [blame] | 163 | ... body=${data} valid_status_codes=${valid_status_code} |
| 164 | |
Sweta Potthuri | dda695e | 2023-04-26 02:10:38 -0500 | [diff] [blame] | 165 | Apply DHCP Config |
| 166 | [Documentation] Apply DHCP Config |
| 167 | [Arguments] ${property} |
| 168 | |
| 169 | # Description of Argument(s): |
| 170 | # property DHCP property values. |
| 171 | |
| 172 | ${active_channel_config}= Get Active Channel Config |
| 173 | Redfish.Patch |
ganesanb | 26e5957 | 2023-06-09 07:55:47 +0000 | [diff] [blame] | 174 | ... /redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}/ |
Sweta Potthuri | dda695e | 2023-04-26 02:10:38 -0500 | [diff] [blame] | 175 | ... body={"DHCPv4":${property}} valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] |
| 176 | |
| 177 | ${resp}= Redfish.Get |
ganesanb | 26e5957 | 2023-06-09 07:55:47 +0000 | [diff] [blame] | 178 | ... /redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']} |
Sweta Potthuri | dda695e | 2023-04-26 02:10:38 -0500 | [diff] [blame] | 179 | Verify Ethernet Config Property ${property} ${resp.dict["DHCPv4"]} |
| 180 | |
| 181 | |
| 182 | Verify Ethernet Config Property |
| 183 | [Documentation] verify ethernet config properties. |
| 184 | [Arguments] ${property} ${response_data} |
| 185 | |
| 186 | # Description of argument(s): |
| 187 | # ${property} DHCP Properties in dictionary. |
| 188 | # Example: |
| 189 | # property value |
| 190 | # DHCPEnabled :False |
| 191 | # UseDomainName :True |
| 192 | # UseNTPServers :True |
| 193 | # UseDNSServers :True |
| 194 | # ${response_data} DHCP Response data in dictionary. |
| 195 | # Example: |
| 196 | # property value |
| 197 | # DHCPEnabled :False |
| 198 | # UseDomainName :True |
| 199 | # UseNTPServers :True |
| 200 | # UseDNSServers :True |
| 201 | |
| 202 | ${key_map}= Get Dictionary Items ${property} |
| 203 | FOR ${key} ${value} IN @{key_map} |
| 204 | Should Be Equal As Strings ${response_data['${key}']} ${value} |
| 205 | END |
| 206 | |
| 207 | Restore Configuration |
| 208 | [Documentation] Restore the configuration to Both Static Network |
| 209 | |
Sweta Potthuri | 0e3f3f8 | 2023-10-19 05:30:29 -0500 | [diff] [blame] | 210 | Run Keyword If '${CHANNEL_NUMBER}' == '${1}' Add IP Address ${OPENBMC_HOST} ${eth0_subnet_mask} ${eth0_gateway} |
| 211 | ... ELSE IF '${CHANNEL_NUMBER}' == '{2}' Add IP Address ${OPENBMC_HOST_1} ${eth1_subnet_mask} ${eth1_gateway} |
Sweta Potthuri | dda695e | 2023-04-26 02:10:38 -0500 | [diff] [blame] | 212 | |
| 213 | Get Network Configuration Using Channel Number |
| 214 | [Documentation] Get ethernet interface. |
| 215 | [Arguments] ${channel_number} |
| 216 | |
| 217 | # Description of argument(s): |
| 218 | # channel_number Ethernet channel number, 1 is for eth0 and 2 is for eth1 (e.g. "1"). |
| 219 | |
| 220 | ${active_channel_config}= Get Active Channel Config |
| 221 | ${ethernet_interface}= Set Variable ${active_channel_config['${channel_number}']['name']} |
| 222 | ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface} |
| 223 | |
| 224 | @{network_configurations}= Get From Dictionary ${resp.dict} IPv4StaticAddresses |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 225 | RETURN @{network_configurations} |
Sweta Potthuri | dda695e | 2023-04-26 02:10:38 -0500 | [diff] [blame] | 226 | |
Sweta Potthuri | ab87174 | 2023-02-20 11:08:42 -0600 | [diff] [blame] | 227 | Suite Setup Execution |
| 228 | [Documentation] Do suite setup task. |
| 229 | |
| 230 | Ping Host ${OPENBMC_HOST} |
| 231 | Redfish.Login |
Sweta Potthuri | dda695e | 2023-04-26 02:10:38 -0500 | [diff] [blame] | 232 | |
| 233 | # Get the configuration of eth1 |
| 234 | ${network_configurations}= Get Network Configuration Using Channel Number ${2} |
| 235 | FOR ${network_configuration} IN @{network_configurations} |
| 236 | Run Keyword If '${network_configuration['Address']}' == '${OPENBMC_HOST_1}' |
| 237 | ... Run Keywords Set Suite Variable ${eth1_subnet_mask} ${network_configuration['SubnetMask']} |
| 238 | ... AND Set Suite Variable ${eth1_gateway} ${network_configuration['Gateway']} |
| 239 | ... AND Exit For Loop |
| 240 | END |
| 241 | |
| 242 | # Get the configuration of eth0 |
| 243 | ${network_configurations}= Get Network Configuration Using Channel Number ${1} |
| 244 | FOR ${network_configuration} IN @{network_configurations} |
| 245 | Run Keyword If '${network_configuration['Address']}' == '${OPENBMC_HOST}' |
| 246 | ... Run Keywords Set Suite Variable ${eth0_subnet_mask} ${network_configuration['SubnetMask']} |
| 247 | ... AND Set Suite Variable ${eth0_gateway} ${network_configuration['Gateway']} |
| 248 | ... AND Exit For Loop |
| 249 | END |