blob: 232d87aa58f06de7b4efd07ee008d9ab34a7ae89 [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}
79 Login And Run Command On Remote System
80 ... rm -f /tmp/wpa.log; wpa_supplicant -B -i ${iface} -Dwired -c /etc/wpa_supplicant/${conf_file} -f /tmp/wpa.log
81 ... ${ip} ${user} ${pass} ${container_type} ${container_name}
82
83Validate Authentication
84 [Documentation] Executes a particular auth request on the RG and verifies if it succeeds
85 ... auth_pass determines if authentication should pass
86 [Arguments] ${auth_pass} ${iface} ${conf_file} ${ip} ${user} ${pass}=${None}
87 ... ${container_type}=${None} ${container_name}=${None}
88 Send EAPOL Message ${iface} ${conf_file} ${ip} ${user} ${pass}
89 ... ${container_type} ${container_name}
90 # FIXME: Use an If/Else block, not Three separate checks, bools instead of truthy strings
91 Run Keyword If '${auth_pass}' == 'True'
92 ... Wait Until Keyword Succeeds 120s 2s
93 ... Check Remote File Contents True
94 ... /tmp/wpa.log authentication completed successfully
95 ... ${ip} ${user} ${pass} ${container_type} ${container_name}
96 Run Keyword If '${auth_pass}' == 'False'
97 ... Sleep 20s
98 Run Keyword If '${auth_pass}' == 'False'
99 ... Check Remote File Contents False
100 ... /tmp/wpa.log authentication completed successfully
101 ... ${ip} ${user} ${pass} ${container_type} ${container_name}
102
103Run Multicast Client
104 [Documentation] Executes mcjoin (a simple multicast client) on the RG.
105 [Arguments] ${iface} ${ip} ${user} ${pass}=${None}
106 ... ${container_type}=${None} ${container_name}=${None}
107 Login And Run Command On Remote System
108 ... rm -f /tmp/mcjoin.log; timeout 10 mcjoin -c 5 -i eth0 > /tmp/mcjoin.log || true
109 ... ${ip} ${user} ${pass} ${container_type} ${container_name}
110
111Validate Multicast
112 [Documentation] Executes a particular auth request on the RG and verifies
113 ... if it succeeds. auth_pass determines if authentication should pass
114 [Arguments] ${auth_pass} ${iface} ${ip} ${user} ${pass}=${None}
115 ... ${container_type}=${None} ${container_name}=${None}
116 Run Multicast Client ${iface} ${ip} ${user} ${pass}
117 ... ${container_type} ${container_name}
118 Run Keyword If '${auth_pass}' == 'True'
119 ... Check Remote File Contents True
120 ... /tmp/mcjoin.log Received total: 5 packets
121 ... ${ip} ${user} ${pass} ${container_type} ${container_name}
122 Run Keyword If '${auth_pass}' == 'False'
123 ... Check Remote File Contents True
124 ... /tmp/mcjoin.log Received total: 0 packets
125 ... ${ip} ${user} ${pass} ${container_type} ${container_name}
126
127Validate DHCP and Ping
128 [Documentation] Check that DHCP address has been acquired and Ping works
129 [Arguments] ${dhcp_should_pass} ${ping_should_pass}
130 ... ${src_iface} ${s_tag} ${c_tag}
131 ... ${dst_dp_ip} ${src_ip} ${src_user} ${src_pass}=${None}
132 ... ${src_container_type}=${None} ${src_container_name}=${None}
133 ... ${dst_dp_iface}=${None} ${dst_ip}=${None}
134 ... ${dst_user}=${None} ${dst_pass}=${None}
135 ... ${dst_container_type}=${None} ${dst_container_name}=${None}
136 Run Keyword If '${dst_ip}' != '${None}' Run Keywords
137 ... Add Double Vlan Interface on Host ${dst_dp_iface} ${s_tag} ${c_tag}
138 ... ${dst_ip} ${dst_user} ${dst_pass} ${dst_container_type} ${dst_container_name}
139 ... AND
140 ... Add IP Address on Interface on Host
141 ... ${dst_dp_ip}/24 ${dst_dp_iface}.${s_tag}.${c_tag}
142 ... ${dst_ip} ${dst_user} ${dst_pass} ${dst_container_type} ${dst_container_name}
143 ... AND
144 ... Start DHCP Server on Remote Host ${dst_dp_iface}.${s_tag}.${c_tag} ${dst_ip}
145 ... ${dst_user} ${dst_pass} ${dst_container_type} ${dst_container_name}
146 Run Keyword If '${src_container_type}' != 'K8S'
147 ... Send Dhclient Request ${src_iface} ${src_ip}
148 ... ${src_user} ${src_pass} ${src_container_type} ${src_container_name}
149 ... ELSE
150 ... Send Dhclient Request K8S
151 Run Keyword If '${dhcp_should_pass}' == 'True'
152 ... Wait Until Keyword Succeeds 90s 5s
153 ... Check IPv4 Address on DHCP Client True ${src_iface} ${src_ip}
154 ... ${src_user} ${src_pass} ${src_container_type} ${src_container_name}
155 Run Keyword If '${dhcp_should_pass}' == 'False'
156 ... Sleep 15s
157 Run Keyword If '${dhcp_should_pass}' == 'False'
158 ... Check IPv4 Address on DHCP Client False ${src_iface} ${src_ip}
159 ... ${src_user} ${src_pass} ${src_container_type} ${src_container_name}
160 Run Keyword If '${ping_should_pass}' == 'True'
161 ... Wait Until Keyword Succeeds 60s 2s
162 ... Check Ping True ${dst_dp_ip} ${src_iface} ${src_ip}
163 ... ${src_user} ${src_pass} ${src_container_type} ${src_container_name}
164 ... ELSE
165 ... Wait Until Keyword Succeeds 60s 2s
166 ... Check Ping False ${dst_dp_ip} ${src_iface} ${src_ip}
167 ... ${src_user} ${src_pass} ${src_container_type} ${src_container_name}
168
169Validate Subscriber Service Chain
170 [Documentation] Check if serial number is list of subcribed_links_ids
171 [Arguments] ${serial_no} ${expected}=True
172 ${resp}= CORD Get ${VOLT_SUBSCRIBER}
173 ${jsondata}= To Json ${resp.content}
174 Log ${jsondata}
175 ${length}= Get Length ${jsondata['items']}
176 FOR ${INDEX} IN RANGE 0 ${length}
177 ${value}= Get From List ${jsondata['items']} ${INDEX}
178 ${sl}= Get From Dictionary ${value} subscribed_links_ids
179 ${result} ${slinks}= Run Keyword And Ignore Error
180 ... Get From List ${sl} 0
181 ${sn}= Get From Dictionary ${value} onu_device
182 Run Keyword If '${sn}' == '${serial_no}' Exit For Loop
183 END
184
185Validate Fabric CrossConnect SI
186 [Documentation] Build list of s_tags in fabric crossconnect
187 [Arguments] ${stag} ${expected}=True
188 ${resp}= CORD Get ${FABRIC_CROSSCONNECT_SERVICEINSTANCES}
189 ${jsondata}= To Json ${resp.content}
190 Log ${jsondata}
191 ${length}= Get Length ${jsondata['items']}
192 @{tags}= Create List
193 FOR ${INDEX} IN RANGE 0 ${length}
194 ${value}= Get From List ${jsondata['items']} ${INDEX}
195 ${tag}= Get From Dictionary ${value} s_tag
196 Append To List ${tags} ${tag}
197 END
198
199Validate Subscriber Count
200 [Documentation] Check if subscriber count matches passed value
201 [Arguments] ${expected_no}
202 ${resp}= CORD Get ${VOLT_SUBSCRIBER}
203 ${jsondata}= To Json ${resp.content}
204 Log ${jsondata}
205 ${length}= Get Length ${jsondata['items']}
206 Should Be Equal As Integers ${length} ${expected_no}
207
208Subscriber Ready to Authenticate
209 [Documentation] Check if subscriber is in awaiting-auth state
210 [Arguments] ${onu_device}
211 Wait Until Keyword Succeeds 60s 15s
212 ... Validate ONU States ACTIVE ENABLED ${onu_device}
213 Wait Until Keyword Succeeds 60s 2s
214 ... Validate ATT Workflow Driver SI ENABLED AWAITING ${onu_device}
215 ... ONU has been validated - Awaiting Authentication
216 Wait Until Keyword Succeeds 60s 2s
217 ... Validate Subscriber Status awaiting-auth ${onu_device}
218
219Subscriber Provisioned
220 [Documentation] Check if subscriber has successfully authenticated
221 [Arguments] ${server_ip} ${onu_device} ${stag}
222 Wait Until Keyword Succeeds 60s 2s
223 ... Validate ATT Workflow Driver SI ENABLED APPROVED ${onu_device}
224 ... ONU has been validated - Authentication succeeded
225 Wait Until Keyword Succeeds 60s 2s
226 ... Validate Subscriber Status enabled ${onu_device}
227 Wait Until Keyword Succeeds 60s 2s
228 ... Validate Subscriber Service Chain ${onu_device} True
229 Wait Until Keyword Succeeds 60s 2s
230 ... Validate XConnect in ONOS ${server_ip} ${stag} True
231
232Subscriber Service Chain Created
233 [Documentation] Check if subscriber service chain has been created
234 [Arguments] ${onu_device} ${stag}
235 Wait Until Keyword Succeeds 60s 2s
236 ... Validate ATT Workflow Driver SI ENABLED APPROVED ${onu_device}
237 ... ONU has been validated - Authentication succeeded
238 Wait Until Keyword Succeeds 60s 2s
239 ... Validate Subscriber Status enabled ${onu_device}
240 Wait Until Keyword Succeeds 60s 2s
241 ... Validate Subscriber Service Chain ${onu_device} True
242 Wait Until Keyword Succeeds 60s 2s
243 ... Validate Fabric CrossConnect SI ${stag} True
244 Wait Until Keyword Succeeds 60s 2s
245 ... Validate XConnect in ONOS ${server_ip} ${stag} True