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