blob: 0b820307d126912333f44ff82569bb1090b271d3 [file] [log] [blame]
Rahul Maheshwari01413692016-09-05 21:35:24 -05001*** Settings ***
2Documentation This suite will test extended Network Configuration Rest Interfaces
3
4Resource ../lib/rest_client.robot
5Resource ../lib/connection_client.robot
6Resource ../lib/utils.robot
7Resource ../lib/openbmc_ffdc.robot
8Library ../lib/pythonutil.py
9
10Suite Setup Open Connection And Log In
11Suite Teardown Close All Connections
12Test Teardown Log FFDC
13
14*** Test Cases ***
15
16Set 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}
44 run keyword and ignore error Call Method /org/openbmc/NetworkManager/Interface/ SetAddress4 data=${args}
45
46 Wait For Host To Ping ${NEW_IP}
47 Set Suite Variable ${AUTH_URI} https://${NEW_IP}
48 Log ${AUTH_URI}
49
50 ${networkInfo}= Get networkInfo from the interface eth0
51 ${ipaddress}= set variable ${networkInfo['data'][2]}
52 ${gateway}= set variable ${networkInfo['data'][3]}
53
54 ${isgatewayfound} = Set Variable If '${gateway}'=='${NEW_GATEWAY}' true false
55 Log ${isgatewayfound}
56 ${isIPfound}= Set Variable if '${ipaddress}' == '${NEW_IP}' true false
57 should be true '${isIPfound}' == 'true' and '${isgatewayfound}' == 'true'
58
59
60Revert the last ip address change
61 [Tags] network_test
62 [Documentation] This test case sets the ip on the interface and validates
63 ... that ip address has been set or not.
64 ... Expectation is the ip address should get added.
65
66
67 ${arglist}= Create List eth0 ${OLD_IP} ${OLD_MASK} ${OLD_GATEWAY}
68 ${args}= Create Dictionary data=@{arglist}
69 run keyword and ignore error Call Method /org/openbmc/NetworkManager/Interface/ SetAddress4 data=${args}
70
71 Wait For Host To Ping ${OLD_IP}
72 Set Suite Variable ${AUTH_URI} https://${OLD_IP}
73 Log ${AUTH_URI}
74
75
76 ${networkInfo}= Get networkInfo from the interface eth0
77 ${ipaddress}= set variable ${networkInfo['data'][2]}
78 ${gateway}= set variable ${networkInfo['data'][3]}
79
80 ${isgatewayfound} = Set Variable If '${gateway}'=='${OLD_GATEWAY}' true false
81 Log ${isgatewayfound}
82 ${isIPfound}= Set Variable if '${ipaddress}' == '${OLD_IP}' true false
83 should be true '${isIPfound}' == 'true' and '${isgatewayfound}' == 'true'
84
85
86Persistency check for ip address
87 [Tags] reboot_test
88 [Documentation] we reboot the service processor and after reboot
89 ... will request for the ip address to check the persistency
90 ... of the ip address.
91 ... Expectation is the ip address should persist.
92
93 Open Connection And Log In
94 Execute Command reboot
95 Log "System is getting rebooted wait for few seconds"
96 ${networkInfo}= Get networkInfo from the interface eth0
97 ${ipaddress}= set variable ${networkInfo['data'][2]}
98 ${gateway}= set variable ${networkInfo['data'][3]}
99
100 ${isgatewayfound} = Set Variable If '${gateway}'=='${OLD_GATEWAY}' true false
101 Log ${isgatewayfound}
102 ${isIPfound}= Set Variable if '${ipaddress}' == '${OLD_IP}' true false
103 should be true '${isIPfound}' == 'true' and '${isgatewayfound}' == 'true'
104
105
106***keywords***
107
108Get networkInfo from the interface
109
110 [Documentation] This keyword is used to match the given ip with the configured one.
111 ... returns true if match successfull else false
112 ... eg:- Outout of getAddress4
113 ... NewFormat:-{"data": [ 2,25,"9.3.164.147","9.3.164.129"],"message": "200 OK","status": "ok"}
114 ... OldFormat:-
115 ... {"data": [[[2,25,0,128,"9.3.164.177"],[2,8,254,128,"127.0.0.1"]],"9.3.164.129"],
116 ... "message": "200 OK", "status": "ok"}
117
118 [arguments] ${intf}
119 @{arglist}= Create List ${intf}
120 ${args}= Create Dictionary data=@{arglist}
121 ${resp}= Call Method /org/openbmc/NetworkManager/Interface/ GetAddress4 data=${args}
122 should be equal as strings ${resp.status_code} ${HTTP_OK}
123 ${json} = to json ${resp.content}
124 Log ${json['data'][2]}
125 Log ${json['data'][3]}
126 [return] ${json}
127
128
129validateEnvVariables
130
131 ${NEW_BMC_IP}= Get Environment Variable NEW_BMC_IP
132 ${NEW_SUBNET_MASK}= Get Environment Variable NEW_SUBNET_MASK
133 ${NEW_GATEWAY}= Get Environment Variable NEW_GATEWAY
134
135
136 should not be empty ${NEW_BMC_IP}
137 should not be empty ${NEW_GATEWAY}
138 should not be empty ${NEW_SUBNET_MASK}