blob: 7951b54c76317e5b2fd99609cc35ca06452c7838 [file] [log] [blame]
Zack Williams821c5022020-01-15 15:11:46 -07001# Copyright 2017-present Open Networking Foundation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15*** Settings ***
16Documentation Library of functions related a subscriber (RG)
17Resource ATTWorkFlowDriver.resource
18Resource DHCP.resource
19Resource Network.resource
20Resource ONOS.resource
21Resource utils.resource
22Resource XOS.resource
23
24*** Keywords ***
25Subscriber Status Check
26 [Documentation] Returns Status from Subscribers List for a particular ONU device
27 [Arguments] ${onu_device}
28 ${json_result}= CORDRobot.ApiGet VOLT_SUBSCRIBER
29 Log ${json_result}
30 ${json_result_list}= Get From dictionary ${json_result} items
31 ${getJsonDict}= CORDRobot.getDictFromListOfDict ${json_result_list}
32 ... onu_device ${onu_device}
33 ${status}= Get From Dictionary ${getJsonDict} status
34 [Return] ${status}
35
36Validate Subscriber Status
37 [Documentation] Check that a subscriber has the expected status
38 [Arguments] ${expected_status} ${onu_device} ${accepted_status}=${EMPTY}
39 ${status} Subscriber Status Check ${onu_device}
40 Run Keyword If '${accepted_status}' == '${EMPTY}'
41 ... Should Be Equal ${status} ${expected_status}
42 ... ELSE
43 ... Should Contain Any ${status} ${expected_status} ${accepted_status}
44
45Create Subscriber
46 [Documentation] Sends a POST to create a subscriber in XOS
47 [Arguments] ${subscriber_list} ${list_index}
48 ${slist} = Get Variable Value ${subscriber_list}
49 ${subscriber_dictionary}= CORDRobot.listToDict ${slist} ${list_index}
50 ${api_result}= CORDRobot.ApiPost VOLT_SUBSCRIBER ${subscriber_dictionary}
51 Should Be True ${api_result}
52 ${Subscriber_id}= Get From Dictionary ${api_result} id
53 Set Global Variable ${Subscriber_id}
54 [Return] ${Subscriber_id}
55
56Retrieve Subscriber
57 [Documentation] Returns the subscriber id based on the subscriber's C-Tag
58 [Arguments] ${ctag}
59 ${json_result}= CORDRobot.ApiGet VOLT_SUBSCRIBER
60 Log ${json_result}
61 ${json_result_list}= Get From dictionary ${json_result} items
62 ${getJsonDict}= CORDRobot.getDictFromListOfDict ${json_result_list}
63 ... c_tag ${ctag}
64 ${id}= Get From Dictionary ${getJsonDict} id
65 [Return] ${id}
66
67Delete Subscriber
68 [Documentation] Deletes a given subscriber based on its c_tag
69 [Arguments] ${ctag}
70 ${id}= Retrieve Subscriber ${ctag}
71 ${api_result}= CORDRobot.ApiChameleonDelete VOLT_SUBSCRIBER ${id}
72 Should Be True ${api_result}
73
74Send EAPOL Message
75 [Documentation] Executes a particular auth request on the RG via wpa_supplicant
76 ... Requested packet should exist on src.
77 [Arguments] ${iface} ${conf_file} ${ip} ${user} ${pass}=${None}
78 ... ${container_type}=${None} ${container_name}=${None}
Andy Bavier95032202020-02-26 06:25:56 -070079 ... ${wpa_log}='/tmp/wpa.log'
Zack Williams821c5022020-01-15 15:11:46 -070080 Login And Run Command On Remote System
Andy Bavier95032202020-02-26 06:25:56 -070081 ... rm -f ${wpa_log}; wpa_supplicant -B -i ${iface} -Dwired -c /etc/wpa_supplicant/${conf_file} -f ${wpa_log}
Zack Williams821c5022020-01-15 15:11:46 -070082 ... ${ip} ${user} ${pass} ${container_type} ${container_name}
83
84Validate Authentication
85 [Documentation] Executes a particular auth request on the RG and verifies if it succeeds
86 ... auth_pass determines if authentication should pass
87 [Arguments] ${auth_pass} ${iface} ${conf_file} ${ip} ${user} ${pass}=${None}
88 ... ${container_type}=${None} ${container_name}=${None}
Andy Bavier95032202020-02-26 06:25:56 -070089 ... ${wpa_log}='/tmp/wpa.log'
Zack Williams821c5022020-01-15 15:11:46 -070090 Send EAPOL Message ${iface} ${conf_file} ${ip} ${user} ${pass}
Andy Bavier95032202020-02-26 06:25:56 -070091 ... ${container_type} ${container_name} ${wpa_log}
Zack Williams821c5022020-01-15 15:11:46 -070092 # FIXME: Use an If/Else block, not Three separate checks, bools instead of truthy strings
93 Run Keyword If '${auth_pass}' == 'True'
94 ... Wait Until Keyword Succeeds 120s 2s
95 ... Check Remote File Contents True
Andy Bavier95032202020-02-26 06:25:56 -070096 ... ${wpa_log} ${iface}.*authentication completed successfully
Zack Williams821c5022020-01-15 15:11:46 -070097 ... ${ip} ${user} ${pass} ${container_type} ${container_name}
98 Run Keyword If '${auth_pass}' == 'False'
99 ... Sleep 20s
100 Run Keyword If '${auth_pass}' == 'False'
101 ... Check Remote File Contents False
Andy Bavier95032202020-02-26 06:25:56 -0700102 ... ${wpa_log} ${iface}.*authentication completed successfully
Zack Williams821c5022020-01-15 15:11:46 -0700103 ... ${ip} ${user} ${pass} ${container_type} ${container_name}
104
105Run Multicast Client
106 [Documentation] Executes mcjoin (a simple multicast client) on the RG.
107 [Arguments] ${iface} ${ip} ${user} ${pass}=${None}
108 ... ${container_type}=${None} ${container_name}=${None}
109 Login And Run Command On Remote System
110 ... rm -f /tmp/mcjoin.log; timeout 10 mcjoin -c 5 -i eth0 > /tmp/mcjoin.log || true
111 ... ${ip} ${user} ${pass} ${container_type} ${container_name}
112
113Validate Multicast
114 [Documentation] Executes a particular auth request on the RG and verifies
115 ... if it succeeds. auth_pass determines if authentication should pass
116 [Arguments] ${auth_pass} ${iface} ${ip} ${user} ${pass}=${None}
117 ... ${container_type}=${None} ${container_name}=${None}
118 Run Multicast Client ${iface} ${ip} ${user} ${pass}
119 ... ${container_type} ${container_name}
120 Run Keyword If '${auth_pass}' == 'True'
121 ... Check Remote File Contents True
122 ... /tmp/mcjoin.log Received total: 5 packets
123 ... ${ip} ${user} ${pass} ${container_type} ${container_name}
124 Run Keyword If '${auth_pass}' == 'False'
125 ... Check Remote File Contents True
126 ... /tmp/mcjoin.log Received total: 0 packets
127 ... ${ip} ${user} ${pass} ${container_type} ${container_name}
128
129Validate DHCP and Ping
130 [Documentation] Check that DHCP address has been acquired and Ping works
131 [Arguments] ${dhcp_should_pass} ${ping_should_pass}
132 ... ${src_iface} ${s_tag} ${c_tag}
133 ... ${dst_dp_ip} ${src_ip} ${src_user} ${src_pass}=${None}
134 ... ${src_container_type}=${None} ${src_container_name}=${None}
135 ... ${dst_dp_iface}=${None} ${dst_ip}=${None}
136 ... ${dst_user}=${None} ${dst_pass}=${None}
137 ... ${dst_container_type}=${None} ${dst_container_name}=${None}
138 Run Keyword If '${dst_ip}' != '${None}' Run Keywords
139 ... Add Double Vlan Interface on Host ${dst_dp_iface} ${s_tag} ${c_tag}
140 ... ${dst_ip} ${dst_user} ${dst_pass} ${dst_container_type} ${dst_container_name}
141 ... AND
142 ... Add IP Address on Interface on Host
143 ... ${dst_dp_ip}/24 ${dst_dp_iface}.${s_tag}.${c_tag}
144 ... ${dst_ip} ${dst_user} ${dst_pass} ${dst_container_type} ${dst_container_name}
145 ... AND
146 ... Start DHCP Server on Remote Host ${dst_dp_iface}.${s_tag}.${c_tag} ${dst_ip}
147 ... ${dst_user} ${dst_pass} ${dst_container_type} ${dst_container_name}
148 Run Keyword If '${src_container_type}' != 'K8S'
149 ... Send Dhclient Request ${src_iface} ${src_ip}
150 ... ${src_user} ${src_pass} ${src_container_type} ${src_container_name}
151 ... ELSE
152 ... Send Dhclient Request K8S
153 Run Keyword If '${dhcp_should_pass}' == 'True'
154 ... Wait Until Keyword Succeeds 90s 5s
155 ... Check IPv4 Address on DHCP Client True ${src_iface} ${src_ip}
156 ... ${src_user} ${src_pass} ${src_container_type} ${src_container_name}
157 Run Keyword If '${dhcp_should_pass}' == 'False'
158 ... Sleep 15s
159 Run Keyword If '${dhcp_should_pass}' == 'False'
160 ... Check IPv4 Address on DHCP Client False ${src_iface} ${src_ip}
161 ... ${src_user} ${src_pass} ${src_container_type} ${src_container_name}
162 Run Keyword If '${ping_should_pass}' == 'True'
163 ... Wait Until Keyword Succeeds 60s 2s
164 ... Check Ping True ${dst_dp_ip} ${src_iface} ${src_ip}
165 ... ${src_user} ${src_pass} ${src_container_type} ${src_container_name}
166 ... ELSE
167 ... Wait Until Keyword Succeeds 60s 2s
168 ... Check Ping False ${dst_dp_ip} ${src_iface} ${src_ip}
169 ... ${src_user} ${src_pass} ${src_container_type} ${src_container_name}
170
171Validate Subscriber Service Chain
172 [Documentation] Check if serial number is list of subcribed_links_ids
173 [Arguments] ${serial_no} ${expected}=True
174 ${resp}= CORD Get ${VOLT_SUBSCRIBER}
175 ${jsondata}= To Json ${resp.content}
176 Log ${jsondata}
177 ${length}= Get Length ${jsondata['items']}
178 FOR ${INDEX} IN RANGE 0 ${length}
179 ${value}= Get From List ${jsondata['items']} ${INDEX}
180 ${sl}= Get From Dictionary ${value} subscribed_links_ids
181 ${result} ${slinks}= Run Keyword And Ignore Error
182 ... Get From List ${sl} 0
183 ${sn}= Get From Dictionary ${value} onu_device
184 Run Keyword If '${sn}' == '${serial_no}' Exit For Loop
185 END
186
187Validate Fabric CrossConnect SI
188 [Documentation] Build list of s_tags in fabric crossconnect
189 [Arguments] ${stag} ${expected}=True
190 ${resp}= CORD Get ${FABRIC_CROSSCONNECT_SERVICEINSTANCES}
191 ${jsondata}= To Json ${resp.content}
192 Log ${jsondata}
193 ${length}= Get Length ${jsondata['items']}
194 @{tags}= Create List
195 FOR ${INDEX} IN RANGE 0 ${length}
196 ${value}= Get From List ${jsondata['items']} ${INDEX}
197 ${tag}= Get From Dictionary ${value} s_tag
198 Append To List ${tags} ${tag}
199 END
200
201Validate Subscriber Count
202 [Documentation] Check if subscriber count matches passed value
203 [Arguments] ${expected_no}
204 ${resp}= CORD Get ${VOLT_SUBSCRIBER}
205 ${jsondata}= To Json ${resp.content}
206 Log ${jsondata}
207 ${length}= Get Length ${jsondata['items']}
208 Should Be Equal As Integers ${length} ${expected_no}
209
210Subscriber Ready to Authenticate
211 [Documentation] Check if subscriber is in awaiting-auth state
212 [Arguments] ${onu_device}
213 Wait Until Keyword Succeeds 60s 15s
214 ... Validate ONU States ACTIVE ENABLED ${onu_device}
215 Wait Until Keyword Succeeds 60s 2s
216 ... Validate ATT Workflow Driver SI ENABLED AWAITING ${onu_device}
217 ... ONU has been validated - Awaiting Authentication
218 Wait Until Keyword Succeeds 60s 2s
219 ... Validate Subscriber Status awaiting-auth ${onu_device}
220
221Subscriber Provisioned
222 [Documentation] Check if subscriber has successfully authenticated
223 [Arguments] ${server_ip} ${onu_device} ${stag}
224 Wait Until Keyword Succeeds 60s 2s
225 ... Validate ATT Workflow Driver SI ENABLED APPROVED ${onu_device}
226 ... ONU has been validated - Authentication succeeded
227 Wait Until Keyword Succeeds 60s 2s
228 ... Validate Subscriber Status enabled ${onu_device}
229 Wait Until Keyword Succeeds 60s 2s
230 ... Validate Subscriber Service Chain ${onu_device} True
231 Wait Until Keyword Succeeds 60s 2s
232 ... Validate XConnect in ONOS ${server_ip} ${stag} True
233
234Subscriber Service Chain Created
235 [Documentation] Check if subscriber service chain has been created
236 [Arguments] ${onu_device} ${stag}
237 Wait Until Keyword Succeeds 60s 2s
238 ... Validate ATT Workflow Driver SI ENABLED APPROVED ${onu_device}
239 ... ONU has been validated - Authentication succeeded
240 Wait Until Keyword Succeeds 60s 2s
241 ... Validate Subscriber Status enabled ${onu_device}
242 Wait Until Keyword Succeeds 60s 2s
243 ... Validate Subscriber Service Chain ${onu_device} True
244 Wait Until Keyword Succeeds 60s 2s
245 ... Validate Fabric CrossConnect SI ${stag} True
246 Wait Until Keyword Succeeds 60s 2s
247 ... Validate XConnect in ONOS ${server_ip} ${stag} True