blob: 242b16338aec131a87be94af6edc2c8ecc0192a0 [file] [log] [blame]
Chris Austenb29d2e82016-06-07 12:25:35 -05001*** Settings ***
Gunnar Mills56b32892016-11-14 13:56:17 -06002Documentation This suite will verifiy the Network Configuration Rest Interfaces
3... Details of valid interfaces can be found here...
4... https://github.com/openbmc/docs/blob/master/rest-api.md
Chris Austenb29d2e82016-06-07 12:25:35 -05005
George Keishing4d6c1da2016-07-15 05:51:22 -05006Resource ../lib/rest_client.robot
7Resource ../lib/connection_client.robot
8Resource ../lib/utils.robot
George Keishingd55a4be2016-08-26 03:28:17 -05009Resource ../lib/openbmc_ffdc.robot
George Keishing4d6c1da2016-07-15 05:51:22 -050010Library ../lib/pythonutil.py
Chris Austenb29d2e82016-06-07 12:25:35 -050011
George Keishing4d6c1da2016-07-15 05:51:22 -050012Suite Setup Open Connection And Log In
13Suite Teardown Close All Connections
Gunnar Millseac1af22016-11-14 15:30:09 -060014Test Teardown FFDC On Test Case Fail
Chris Austenb29d2e82016-06-07 12:25:35 -050015
George Keishingab1bd922016-12-05 05:29:59 -060016*** Variables ***
17
18${NW_MANAGER} ${NETWORK_MANAGER_URI}Interface
19
George Keishing4d6c1da2016-07-15 05:51:22 -050020*** Test Cases ***
Chris Austenb29d2e82016-06-07 12:25:35 -050021
22Get the Mac address
23
24 [Documentation] This test case is to get the mac address
25 [Tags] network_test
26 @{arglist}= Create List eth0
27 ${args}= Create Dictionary data=@{arglist}
George Keishingab1bd922016-12-05 05:29:59 -060028 ${resp}= Call Method ${NW_MANAGER} GetHwAddress data=${args}
Chris Austenb29d2e82016-06-07 12:25:35 -050029 should not be empty ${resp.content}
Gunnar Mills1cd544d2016-12-06 11:19:22 -060030 ${json}= to json ${resp.content}
Chris Austenb29d2e82016-06-07 12:25:35 -050031 should be equal as strings ${json['status']} ok
George Keishing06ae4aa2016-08-30 01:41:28 -050032 set suite variable ${OLD_MAC_ADDRESS} ${json['data']}
Chris Austenb29d2e82016-06-07 12:25:35 -050033
34
35Get IP Address with invalid interface
36
37 [Documentation] This test case tries to get the ip addrees with the invalid
38 ... interface,Expectation is it should get error.
39 [Tags] network_test
40
41 @{arglist}= Create List lo01
42 ${args}= Create Dictionary data=@{arglist}
George Keishingab1bd922016-12-05 05:29:59 -060043 ${resp}= Call Method ${NW_MANAGER} GetAddress4 data=${args}
Chris Austenb29d2e82016-06-07 12:25:35 -050044 should not be equal as strings ${resp.status_code} ${HTTP_OK}
Gunnar Mills1cd544d2016-12-06 11:19:22 -060045 ${json}= to json ${resp.content}
Chris Austenb29d2e82016-06-07 12:25:35 -050046 should be equal as strings ${json['status']} error
47
48Get IP Address with valid interface
49
50 [Documentation] This test case tries to get the ip addrees with the invalid
51 ... interface,Expectation is it should get error.
52 [Tags] network_test
53
54 @{arglist}= Create List eth0
55 ${args}= Create Dictionary data=@{arglist}
George Keishingab1bd922016-12-05 05:29:59 -060056 ${resp}= Call Method ${NW_MANAGER} GetAddress4 data=${args}
Chris Austenb29d2e82016-06-07 12:25:35 -050057 should be equal as strings ${resp.status_code} ${HTTP_OK}
Gunnar Mills1cd544d2016-12-06 11:19:22 -060058 ${json}= to json ${resp.content}
Chris Austenb29d2e82016-06-07 12:25:35 -050059 should be equal as strings ${json['status']} ok
60
61
62Set the IP address on invalid Interface lo01 1.1.1.1 255.255.255.0 1.1.1.1 error
63
64 [Tags] network_test
65 [Template] AddNetworkInfo
66 [Documentation] This test case tries to set the ip addrees with the invalid
67 ... interface,Expectation is it should get error
68
69Set invalid IP address on the valid interface eth0 ab.cd.ef.gh 255.255.255.0 1.1.1.1 error
70
71 [Tags] network_test
72 [Template] AddNetworkInfo
73 [Documentation] This test case tries to set the invalid ip addrees on the interface
74 ... Expectation is it should get error.
75
76
77Set IP address with invalid subnet mask eth0 2.2.2.2 av.ih.jk.lm 1.1.1.1 error
78
79 [Tags] network_test
80 [Template] AddNetworkInfo
81 [Documentation] This test case tries to set the ip addrees on the interface
82 ... with invalid subnet mask,Expectation is it should get error.
83
84Set empty IP address eth0 ${EMPTY} 255.255.255.0 1.1.1.1 error
85
86 [Tags] network_test
87 [Template] AddNetworkInfo
88 [Documentation] This test case tries to set the NULL ip addrees on the interface
89 ... Expectation is it should get error.
90
91Set empty subnet mask eth0 2.2.2.2 ${EMPTY} 1.1.1.1 error
92
93 [Tags] network_test
94 [Template] AddNetworkInfo
95 [Documentation] This test case tries to set the ip addrees on the interface
96 ... with empty subnet mask,Expectation is it should get error.
97
98Set empty gateway eth0 2.2.2.2 255.255.255.0 ${EMPTY} error
99
100 [Tags] network_test
101 [Template] AddNetworkInfo
102 [Documentation] This test case tries to set the ip addrees on the interface
103 ... with empty gateway,Expectation is it should get error.
104
105
Chris Austenb29d2e82016-06-07 12:25:35 -0500106Get IP Address type
107 [Tags] GOOD-PATH
George Keishing06ae4aa2016-08-30 01:41:28 -0500108 [Documentation] This test case tries to set existing ipaddress address and
109 ... later tries to verify that ip address type is set to static
Chris Austenb29d2e82016-06-07 12:25:35 -0500110 ... due to the operation.
111
112 ${networkInfo}= Get networkInfo from the interface eth0
113 ${result}= convert to integer ${networkInfo['data'][1]}
114
115 ${CURRENT_MASK}= calcDottedNetmask ${result}
116 ${CURRENT_IP}= set variable ${networkInfo['data'][2]}
117 ${CURRENT_GATEWAY}= set variable ${networkInfo['data'][3]}
118
119 ${arglist}= Create List eth0 ${CURRENT_IP} ${CURRENT_MASK} ${CURRENT_GATEWAY}
120 ${args}= Create Dictionary data=@{arglist}
George Keishingab1bd922016-12-05 05:29:59 -0600121 run keyword and ignore error Call Method ${NW_MANAGER} SetAddress4 data=${args}
Chris Austenb29d2e82016-06-07 12:25:35 -0500122
123 Wait For Host To Ping ${CURRENT_IP}
George Keishing06ae4aa2016-08-30 01:41:28 -0500124
Rahul Maheshwari4f467f32016-09-03 15:02:57 -0500125 Wait Until Keyword Succeeds 30 sec 5 sec Initialize OpenBMC
126
Chris Austenb29d2e82016-06-07 12:25:35 -0500127 @{arglist}= Create List eth0
128 ${args}= Create Dictionary data=@{arglist}
George Keishingab1bd922016-12-05 05:29:59 -0600129 ${resp}= Call Method ${NW_MANAGER} GetAddressType data=${args}
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600130 ${json}= to json ${resp.content}
Chris Austenb29d2e82016-06-07 12:25:35 -0500131 Should Be Equal ${json['data']} STATIC
132 should be equal as strings ${json['status']} ok
133
Gunnar Mills7c8923f2016-12-12 21:19:52 -0600134*** Keywords ***
Chris Austenb29d2e82016-06-07 12:25:35 -0500135
136Get 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 Mills38032802016-12-12 13:43:40 -0600146 [Arguments] ${intf}
Chris Austenb29d2e82016-06-07 12:25:35 -0500147 @{arglist}= Create List ${intf}
148 ${args}= Create Dictionary data=@{arglist}
George Keishingab1bd922016-12-05 05:29:59 -0600149 ${resp}= Call Method ${NW_MANAGER} GetAddress4 data=${args}
Chris Austenb29d2e82016-06-07 12:25:35 -0500150 should be equal as strings ${resp.status_code} ${HTTP_OK}
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600151 ${json}= to json ${resp.content}
Chris Austenb29d2e82016-06-07 12:25:35 -0500152 log to console ${json['data'][2]}
153 log to console ${json['data'][3]}
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600154 [Return] ${json}
Chris Austenb29d2e82016-06-07 12:25:35 -0500155
156AddNetworkInfo
157 [Arguments] ${intf} ${address} ${mask} ${gateway} ${result}
158
159 ${arglist}= Create List ${intf} ${address} ${mask} ${gateway}
160 ${args}= Create Dictionary data=@{arglist}
George Keishingab1bd922016-12-05 05:29:59 -0600161 ${resp}= Call Method ${NW_MANAGER} SetAddress4 data=${args}
Chris Austenb29d2e82016-06-07 12:25:35 -0500162 should not be equal as strings ${resp.status_code} ${HTTP_OK}
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600163 ${json}= to json ${resp.content}
Chris Austenb29d2e82016-06-07 12:25:35 -0500164 should be equal as strings ${json['status']} ${result}