Rahul Maheshwari | 0141369 | 2016-09-05 21:35:24 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation This suite will test extended Network Configuration Rest Interfaces |
| 3 | |
| 4 | Resource ../lib/rest_client.robot |
| 5 | Resource ../lib/connection_client.robot |
| 6 | Resource ../lib/utils.robot |
| 7 | Resource ../lib/openbmc_ffdc.robot |
| 8 | Library ../lib/pythonutil.py |
| 9 | |
| 10 | Suite Setup Open Connection And Log In |
| 11 | Suite Teardown Close All Connections |
Gunnar Mills | eac1af2 | 2016-11-14 15:30:09 -0600 | [diff] [blame] | 12 | Test Teardown FFDC On Test Case Fail |
Rahul Maheshwari | 0141369 | 2016-09-05 21:35:24 -0500 | [diff] [blame] | 13 | |
Sweta Potthuri | b2c50f1 | 2017-06-28 03:53:30 -0500 | [diff] [blame] | 14 | Force Tags Networkd_Ext |
| 15 | |
Rahul Maheshwari | 0141369 | 2016-09-05 21:35:24 -0500 | [diff] [blame] | 16 | *** Test Cases *** |
| 17 | |
| 18 | Set IP address on valid Interface |
| 19 | [Tags] network_test |
| 20 | [Documentation] This test case sets the ip on the interface and validates |
| 21 | ... that ip address has been set or not. |
| 22 | ... Expectation is the ip address should get added. |
| 23 | |
| 24 | validateEnvVariables |
| 25 | |
| 26 | |
| 27 | ${networkInfo}= Get networkInfo from the interface eth0 |
| 28 | ${result}= convert to integer ${networkInfo['data'][1]} |
| 29 | |
| 30 | ${MASK}= calcDottedNetmask ${result} |
| 31 | set suite variable ${OLD_MASK} ${MASK} |
| 32 | Log ${OLD_MASK} |
| 33 | set suite variable ${OLD_IP} ${networkInfo['data'][2]} |
| 34 | set suite variable ${OLD_GATEWAY} ${networkInfo['data'][3]} |
| 35 | |
| 36 | Log ${OLD_IP} |
| 37 | Log ${OLD_GATEWAY} |
| 38 | |
| 39 | |
| 40 | ${NEW_IP}= Get Environment Variable NEW_BMC_IP |
| 41 | ${NEW_MASK}= Get Environment Variable NEW_SUBNET_MASK |
| 42 | ${NEW_GATEWAY}= Get Environment Variable NEW_GATEWAY |
| 43 | |
| 44 | ${arglist}= Create List eth0 ${NEW_IP} ${NEW_MASK} ${NEW_GATEWAY} |
| 45 | ${args}= Create Dictionary data=@{arglist} |
George Keishing | 0fd3b24 | 2016-11-24 09:01:41 -0600 | [diff] [blame] | 46 | run keyword and ignore error |
| 47 | ... Call Method |
| 48 | ... ${OPENBMC_BASE_URI}NetworkManager/Interface/ SetAddress4 data=${args} |
Rahul Maheshwari | 0141369 | 2016-09-05 21:35:24 -0500 | [diff] [blame] | 49 | |
| 50 | Wait For Host To Ping ${NEW_IP} |
| 51 | Set Suite Variable ${AUTH_URI} https://${NEW_IP} |
| 52 | Log ${AUTH_URI} |
| 53 | |
| 54 | ${networkInfo}= Get networkInfo from the interface eth0 |
| 55 | ${ipaddress}= set variable ${networkInfo['data'][2]} |
| 56 | ${gateway}= set variable ${networkInfo['data'][3]} |
| 57 | |
Gunnar Mills | 597ffa0 | 2016-12-06 11:26:53 -0600 | [diff] [blame] | 58 | ${isgatewayfound}= Set Variable If '${gateway}'=='${NEW_GATEWAY}' true false |
Rahul Maheshwari | 0141369 | 2016-09-05 21:35:24 -0500 | [diff] [blame] | 59 | Log ${isgatewayfound} |
| 60 | ${isIPfound}= Set Variable if '${ipaddress}' == '${NEW_IP}' true false |
| 61 | should be true '${isIPfound}' == 'true' and '${isgatewayfound}' == 'true' |
| 62 | |
| 63 | |
| 64 | Revert the last ip address change |
| 65 | [Tags] network_test |
| 66 | [Documentation] This test case sets the ip on the interface and validates |
| 67 | ... that ip address has been set or not. |
| 68 | ... Expectation is the ip address should get added. |
| 69 | |
| 70 | |
| 71 | ${arglist}= Create List eth0 ${OLD_IP} ${OLD_MASK} ${OLD_GATEWAY} |
| 72 | ${args}= Create Dictionary data=@{arglist} |
George Keishing | 0fd3b24 | 2016-11-24 09:01:41 -0600 | [diff] [blame] | 73 | run keyword and ignore error |
| 74 | ... Call Method |
| 75 | ... ${OPENBMC_BASE_URI}NetworkManager/Interface/ SetAddress4 data=${args} |
Rahul Maheshwari | 0141369 | 2016-09-05 21:35:24 -0500 | [diff] [blame] | 76 | |
| 77 | Wait For Host To Ping ${OLD_IP} |
| 78 | Set Suite Variable ${AUTH_URI} https://${OLD_IP} |
| 79 | Log ${AUTH_URI} |
| 80 | |
| 81 | |
| 82 | ${networkInfo}= Get networkInfo from the interface eth0 |
| 83 | ${ipaddress}= set variable ${networkInfo['data'][2]} |
| 84 | ${gateway}= set variable ${networkInfo['data'][3]} |
| 85 | |
Gunnar Mills | 597ffa0 | 2016-12-06 11:26:53 -0600 | [diff] [blame] | 86 | ${isgatewayfound}= Set Variable If '${gateway}'=='${OLD_GATEWAY}' true false |
Rahul Maheshwari | 0141369 | 2016-09-05 21:35:24 -0500 | [diff] [blame] | 87 | Log ${isgatewayfound} |
| 88 | ${isIPfound}= Set Variable if '${ipaddress}' == '${OLD_IP}' true false |
| 89 | should be true '${isIPfound}' == 'true' and '${isgatewayfound}' == 'true' |
| 90 | |
| 91 | |
| 92 | Persistency check for ip address |
| 93 | [Tags] reboot_test |
| 94 | [Documentation] we reboot the service processor and after reboot |
| 95 | ... will request for the ip address to check the persistency |
| 96 | ... of the ip address. |
| 97 | ... Expectation is the ip address should persist. |
| 98 | |
| 99 | Open Connection And Log In |
| 100 | Execute Command reboot |
| 101 | Log "System is getting rebooted wait for few seconds" |
| 102 | ${networkInfo}= Get networkInfo from the interface eth0 |
| 103 | ${ipaddress}= set variable ${networkInfo['data'][2]} |
| 104 | ${gateway}= set variable ${networkInfo['data'][3]} |
| 105 | |
Gunnar Mills | 597ffa0 | 2016-12-06 11:26:53 -0600 | [diff] [blame] | 106 | ${isgatewayfound}= Set Variable If '${gateway}'=='${OLD_GATEWAY}' true false |
Rahul Maheshwari | 0141369 | 2016-09-05 21:35:24 -0500 | [diff] [blame] | 107 | Log ${isgatewayfound} |
| 108 | ${isIPfound}= Set Variable if '${ipaddress}' == '${OLD_IP}' true false |
| 109 | should be true '${isIPfound}' == 'true' and '${isgatewayfound}' == 'true' |
| 110 | |
| 111 | |
George Keishing | f2f5f3b | 2016-09-28 10:55:11 -0500 | [diff] [blame] | 112 | Set invalid Mac address eth0 gg:hh:jj:kk:ll:mm error |
| 113 | [Tags] network_test Set_invalid_Mac_address |
| 114 | [Template] SetMacAddress_bad |
| 115 | [Documentation] This test case tries to set the invalid mac address |
| 116 | ... on the eth0 interface. |
| 117 | ... Expectation is that it should throw error. |
| 118 | |
| 119 | |
| 120 | Set valid Mac address eth0 00:21:cc:73:91:dd ok |
| 121 | [Tags] network_test Set_valid_Mac_address |
| 122 | [Template] SetMacAddress_good |
| 123 | [Documentation] ***GOOD PATH*** |
| 124 | ... This test case add the ip addresson the interface and validates |
| 125 | ... that ip address has been added or not. |
| 126 | ... Expectation is the ip address should get added. |
| 127 | |
| 128 | Revert old Mac address eth0 ${OLD_MAC_ADDRESS} ok |
| 129 | [Tags] network_test Revert_old_Mac_address |
| 130 | [Template] SetMacAddress_good |
| 131 | [Documentation] ***GOOD PATH*** |
| 132 | ... This test case add the ip addresson the interface and validates |
| 133 | ... that ip address has been added or not. |
| 134 | ... Expectation is the ip address should get added. |
| 135 | |
Gunnar Mills | 7c8923f | 2016-12-12 21:19:52 -0600 | [diff] [blame] | 136 | *** Keywords *** |
Rahul Maheshwari | 0141369 | 2016-09-05 21:35:24 -0500 | [diff] [blame] | 137 | |
| 138 | Get networkInfo from the interface |
| 139 | |
| 140 | [Documentation] This keyword is used to match the given ip with the configured one. |
| 141 | ... returns true if match successfull else false |
| 142 | ... eg:- Outout of getAddress4 |
| 143 | ... NewFormat:-{"data": [ 2,25,"9.3.164.147","9.3.164.129"],"message": "200 OK","status": "ok"} |
| 144 | ... OldFormat:- |
| 145 | ... {"data": [[[2,25,0,128,"9.3.164.177"],[2,8,254,128,"127.0.0.1"]],"9.3.164.129"], |
| 146 | ... "message": "200 OK", "status": "ok"} |
| 147 | |
Gunnar Mills | 3803280 | 2016-12-12 13:43:40 -0600 | [diff] [blame] | 148 | [Arguments] ${intf} |
Rahul Maheshwari | 0141369 | 2016-09-05 21:35:24 -0500 | [diff] [blame] | 149 | @{arglist}= Create List ${intf} |
| 150 | ${args}= Create Dictionary data=@{arglist} |
George Keishing | 0fd3b24 | 2016-11-24 09:01:41 -0600 | [diff] [blame] | 151 | ${resp}= Call Method |
| 152 | ... ${OPENBMC_BASE_URI}NetworkManager/Interface/ GetAddress4 data=${args} |
Rahul Maheshwari | 0141369 | 2016-09-05 21:35:24 -0500 | [diff] [blame] | 153 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
Gunnar Mills | 597ffa0 | 2016-12-06 11:26:53 -0600 | [diff] [blame] | 154 | ${json}= to json ${resp.content} |
Rahul Maheshwari | 0141369 | 2016-09-05 21:35:24 -0500 | [diff] [blame] | 155 | Log ${json['data'][2]} |
| 156 | Log ${json['data'][3]} |
Gunnar Mills | c9ea936 | 2016-12-13 16:21:13 -0600 | [diff] [blame] | 157 | [Return] ${json} |
Rahul Maheshwari | 0141369 | 2016-09-05 21:35:24 -0500 | [diff] [blame] | 158 | |
| 159 | |
| 160 | validateEnvVariables |
| 161 | |
| 162 | ${NEW_BMC_IP}= Get Environment Variable NEW_BMC_IP |
| 163 | ${NEW_SUBNET_MASK}= Get Environment Variable NEW_SUBNET_MASK |
| 164 | ${NEW_GATEWAY}= Get Environment Variable NEW_GATEWAY |
| 165 | |
| 166 | |
| 167 | should not be empty ${NEW_BMC_IP} |
| 168 | should not be empty ${NEW_GATEWAY} |
| 169 | should not be empty ${NEW_SUBNET_MASK} |
George Keishing | f2f5f3b | 2016-09-28 10:55:11 -0500 | [diff] [blame] | 170 | |
| 171 | SetMacAddress_bad |
| 172 | [Arguments] ${intf} ${address} ${result} |
| 173 | ${arglist}= Create List ${intf} ${address} |
| 174 | ${args}= Create Dictionary data=@{arglist} |
George Keishing | 0fd3b24 | 2016-11-24 09:01:41 -0600 | [diff] [blame] | 175 | ${resp}= Call Method |
| 176 | ... ${OPENBMC_BASE_URI}NetworkManager/Interface/ SetHwAddress data=${args} |
George Keishing | f2f5f3b | 2016-09-28 10:55:11 -0500 | [diff] [blame] | 177 | should not be equal as strings ${resp.status_code} ${HTTP_OK} |
Gunnar Mills | 597ffa0 | 2016-12-06 11:26:53 -0600 | [diff] [blame] | 178 | ${json}= to json ${resp.content} |
George Keishing | f2f5f3b | 2016-09-28 10:55:11 -0500 | [diff] [blame] | 179 | should be equal as strings ${json['status']} ${result} |
| 180 | |
| 181 | |
| 182 | SetMacAddress_good |
| 183 | [Arguments] ${intf} ${address} ${result} |
| 184 | ${arglist}= Create List ${intf} ${address} |
| 185 | ${args}= Create Dictionary data=@{arglist} |
George Keishing | 0fd3b24 | 2016-11-24 09:01:41 -0600 | [diff] [blame] | 186 | ${resp}= Call Method |
| 187 | ... ${OPENBMC_BASE_URI}NetworkManager/Interface/ SetHwAddress data=${args} |
George Keishing | f2f5f3b | 2016-09-28 10:55:11 -0500 | [diff] [blame] | 188 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
Gunnar Mills | 597ffa0 | 2016-12-06 11:26:53 -0600 | [diff] [blame] | 189 | ${json}= to json ${resp.content} |
George Keishing | f2f5f3b | 2016-09-28 10:55:11 -0500 | [diff] [blame] | 190 | should be equal as strings ${json['status']} ${result} |
| 191 | Wait For Host To Ping ${OPENBMC_HOST} |
| 192 | |
| 193 | Wait Until Keyword Succeeds 30 sec 5 sec Initialize OpenBMC |
| 194 | |
| 195 | @{arglist}= Create List ${intf} |
| 196 | ${args}= Create Dictionary data=@{arglist} |
George Keishing | 0fd3b24 | 2016-11-24 09:01:41 -0600 | [diff] [blame] | 197 | ${resp}= Call Method |
| 198 | ... ${OPENBMC_BASE_URI}NetworkManager/Interface/ GetHwAddress data=${args} |
Gunnar Mills | 597ffa0 | 2016-12-06 11:26:53 -0600 | [diff] [blame] | 199 | ${json}= to json ${resp.content} |
George Keishing | f2f5f3b | 2016-09-28 10:55:11 -0500 | [diff] [blame] | 200 | should be equal as strings ${json['data']} ${address} |