blob: e1e904493572a28092326b8803bb7e5e41ed4bf8 [file] [log] [blame]
Kailash Khalasic930eac2018-09-05 12:18:23 -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 ***
Suchitra Vemuri6357e692018-09-07 11:11:47 -070016Documentation Library of functions related to RG (source host)
Kailash Khalasic930eac2018-09-05 12:18:23 -070017Library OperatingSystem
18Library SSHLibrary
Suchitra Vemurief989602018-09-10 13:45:26 -070019Library restApi.py
Zack Williamsc6722d52020-01-13 16:34:33 -070020Resource utils/utils.robot
21Resource DHCP.robot
Kailash Khalasic930eac2018-09-05 12:18:23 -070022
23*** Keywords ***
Suchitra Vemuri6357e692018-09-07 11:11:47 -070024Subscriber Status Check
25 [Arguments] ${onu_device}
26 [Documentation] Returns Status from Subscribers List for a particular ONU device
27 ${json_result}= restApi.ApiGet VOLT_SUBSCRIBER
28 Log ${json_result}
29 ${json_result_list}= Get From dictionary ${json_result} items
Suchitra Vemurief989602018-09-10 13:45:26 -070030 ${getJsonDict}= utils.getDictFromListOfDict ${json_result_list} onu_device ${onu_device}
Suchitra Vemuri32fc2f22018-09-10 12:06:01 -070031 ${status}= Get From Dictionary ${getJsonDict} status
Suchitra Vemuri6357e692018-09-07 11:11:47 -070032 [Return] ${status}
Kailash Khalasi30a6a392018-09-10 14:32:39 -070033
34Create Subscriber
35 [Arguments] ${subscriber_list} ${list_index}
36 [Documentation] Sends a POST to create a subscriber in XOS
37 ${slist} = Get Variable Value ${subscriber_list}
38 ${subscriber_dictionary}= utils.listToDict ${slist} ${list_index}
39 ${api_result}= restApi.ApiPost VOLT_SUBSCRIBER ${subscriber_dictionary}
40 Should Be True ${api_result}
41 ${Subscriber_id}= Get From Dictionary ${api_result} id
42 Set Global Variable ${Subscriber_id}
43 [Return] ${Subscriber_id}
44
45Retrieve Subscriber
46 [Arguments] ${ctag}
47 [Documentation] Returns the subscriber id based on the subscriber's C-Tag
48 ${json_result}= restApi.ApiGet VOLT_SUBSCRIBER
49 Log ${json_result}
50 ${json_result_list}= Get From dictionary ${json_result} items
51 ${getJsonDict}= utils.getDictFromListOfDict ${json_result_list} c_tag ${ctag}
52 ${id}= Get From Dictionary ${getJsonDict} id
53 [Return] ${id}
54
55Delete Subscriber
56 [Arguments] ${ctag}
57 [Documentation] Deletes a given subscriber based on its c_tag
58 ${id}= Retrieve Subscriber ${ctag}
59 ${api_result}= restApi.ApiChameleonDelete VOLT_SUBSCRIBER ${id}
60 Should Be True ${api_result}
Kailash Khalasi052cbb12018-09-13 16:50:13 -070061
You Wang5be816a2018-10-11 16:45:31 -070062Validate Subscriber Status
Kailash Khalasi8b3523c2018-11-08 15:31:49 -080063 [Arguments] ${expected_status} ${onu_device} ${accepted_status}=${EMPTY}
You Wang5be816a2018-10-11 16:45:31 -070064 ${status} Subscriber Status Check ${onu_device}
Kailash Khalasi8b3523c2018-11-08 15:31:49 -080065 Run Keyword If '${accepted_status}' == '${EMPTY}' Should Be Equal ${status} ${expected_status} ELSE Should Contain Any ${status} ${expected_status} ${accepted_status}
You Wang5be816a2018-10-11 16:45:31 -070066
You Wang88e1d852018-10-05 11:44:19 -070067Send EAPOL Message
You Wang5be816a2018-10-11 16:45:31 -070068 [Arguments] ${iface} ${conf_file} ${ip} ${user} ${pass}=${None} ${container_type}=${None} ${container_name}=${None}
You Wang88e1d852018-10-05 11:44:19 -070069 [Documentation] Executes a particular auth request on the RG via wpa_supplicant client. Requested packet should exist on src.
You Wang5be816a2018-10-11 16:45:31 -070070 Login And Run Command On Remote System rm -f /tmp/wpa.log; wpa_supplicant -B -i ${iface} -Dwired -c /etc/wpa_supplicant/${conf_file} -f /tmp/wpa.log ${ip} ${user} ${pass} ${container_type} ${container_name}
71
72Validate Authentication
73 [Arguments] ${auth_pass} ${iface} ${conf_file} ${ip} ${user} ${pass}=${None} ${container_type}=${None} ${container_name}=${None}
74 [Documentation] Executes a particular auth request on the RG and verifies if it succeeds. auth_pass determines if authentication should pass
75 Send EAPOL Message ${iface} ${conf_file} ${ip} ${user} ${pass} ${container_type} ${container_name}
Kailash Khalasic456d152018-10-26 11:02:06 -070076 Run Keyword If '${auth_pass}' == 'True' Wait Until Keyword Succeeds 120s 2s Check Remote File Contents True /tmp/wpa.log authentication completed successfully ${ip} ${user} ${pass} ${container_type} ${container_name}
Andy Bavier3d6ac1a2018-11-20 15:23:40 -070077 Run Keyword If '${auth_pass}' == 'False' Sleep 20s
You Wang5be816a2018-10-11 16:45:31 -070078 Run Keyword If '${auth_pass}' == 'False' Check Remote File Contents False /tmp/wpa.log authentication completed successfully ${ip} ${user} ${pass} ${container_type} ${container_name}
Kailash Khalasi6dab16e2018-09-17 20:24:08 -070079
Andy Baviera09626a2019-05-22 14:13:39 -070080Run Multicast Client
81 [Arguments] ${iface} ${ip} ${user} ${pass}=${None} ${container_type}=${None} ${container_name}=${None}
82 [Documentation] Executes mcjoin (a simple multicast client) on the RG.
83 Login And Run Command On Remote System rm -f /tmp/mcjoin.log; timeout 10 mcjoin -c 5 -i eth0 > /tmp/mcjoin.log || true ${ip} ${user} ${pass} ${container_type} ${container_name}
84
85Validate Multicast
86 [Arguments] ${auth_pass} ${iface} ${ip} ${user} ${pass}=${None} ${container_type}=${None} ${container_name}=${None}
87 [Documentation] Executes a particular auth request on the RG and verifies if it succeeds. auth_pass determines if authentication should pass
88 Run Multicast Client ${iface} ${ip} ${user} ${pass} ${container_type} ${container_name}
89 Run Keyword If '${auth_pass}' == 'True' Check Remote File Contents True /tmp/mcjoin.log Received total: 5 packets ${ip} ${user} ${pass} ${container_type} ${container_name}
90 Run Keyword If '${auth_pass}' == 'False' Check Remote File Contents True /tmp/mcjoin.log Received total: 0 packets ${ip} ${user} ${pass} ${container_type} ${container_name}
91
Kailash Khalasi6dab16e2018-09-17 20:24:08 -070092Start DHCP Server on Remote Host
You Wang5be816a2018-10-11 16:45:31 -070093 [Arguments] ${interface} ${ip} ${user} ${pass}=${None} ${container_type}=${None} ${container_name}=${None}
94 ${result}= Login And Run Command On Remote System dhcpd -cf /etc/dhcp/dhcpd.conf ${interface} ${ip} ${user} ${pass} ${container_type} ${container_name}
Kailash06c7fcf2019-07-04 15:11:26 -070095 ## many tests running now, we should not assume the dhcp server is not already started. so ignore if this it's already started
96 #Should Contain ${result} Listening on LPF/${interface}
You Wang88e1d852018-10-05 11:44:19 -070097
98Delete IP Addresses from Interface on Remote Host
You Wang5be816a2018-10-11 16:45:31 -070099 [Arguments] ${interface} ${ip} ${user} ${pass}=${None} ${container_type}=${None} ${container_name}=${None}
100 Login And Run Command On Remote System ip addr flush dev ${interface} ${ip} ${user} ${pass} ${container_type} ${container_name}
You Wang88e1d852018-10-05 11:44:19 -0700101
102Add Double Vlan Interface on Host
You Wang5be816a2018-10-11 16:45:31 -0700103 [Arguments] ${interface} ${stag} ${ctag} ${ip} ${user} ${pass}=${None} ${container_type}=${None} ${container_name}=${None}
104 Login And Run Command On Remote System ip link add link ${interface} name ${interface}.${stag} type vlan id ${stag} ${ip} ${user} ${pass} ${container_type} ${container_name}
105 Login And Run Command On Remote System ip link set ${interface}.${stag} up ${ip} ${user} ${pass} ${container_type} ${container_name}
106 Login And Run Command On Remote System ip link add link ${interface}.${stag} name ${interface}.${stag}.${ctag} type vlan id ${ctag} ${ip} ${user} ${pass} ${container_type} ${container_name}
107 Login And Run Command On Remote System ip link set ${interface}.${stag}.${ctag} up ${ip} ${user} ${pass} ${container_type} ${container_name}
108 Login And Run Command On Remote System ifconfig ${interface}.${stag}.${ctag} ${ip} ${user} ${pass} ${container_type} ${container_name}
You Wang88e1d852018-10-05 11:44:19 -0700109
110Delete Interface on Remote Host
You Wang5be816a2018-10-11 16:45:31 -0700111 [Arguments] ${interface} ${ip} ${user} ${pass}=${None} ${container_type}=${None} ${container_name}=${None}
112 Login And Run Command On Remote System ip link del ${interface} ${ip} ${user} ${pass} ${container_type} ${container_name}
You Wang88e1d852018-10-05 11:44:19 -0700113
114Add Ip Address on Interface on Host
You Wang5be816a2018-10-11 16:45:31 -0700115 [Arguments] ${ip_address} ${interface} ${ip} ${user} ${pass}=${None} ${container_type}=${None} ${container_name}=${None}
116 Login And Run Command On Remote System ip addr add ${ip_address} dev ${interface} ${ip} ${user} ${pass} ${container_type} ${container_name}
Kailash Khalasi6dab16e2018-09-17 20:24:08 -0700117
118Add Route to Remote Host
You Wang5be816a2018-10-11 16:45:31 -0700119 [Arguments] ${subnet} ${gateway} ${interface} ${ip} ${user} ${pass}=${None} ${container_type}=${None} ${container_name}=${None}
120 Login And Run Command On Remote System ip route add ${subnet} via ${gateway} dev ${interface} ${ip} ${user} ${pass} ${container_type} ${container_name}
121
122Validate DHCP and Ping
123 [Arguments] ${dhcp_should_pass} ${ping_should_pass} ${src_iface} ${s_tag} ${c_tag} ${dst_dp_ip} ${src_ip} ${src_user} ${src_pass}=${None} ${src_container_type}=${None} ${src_container_name}=${None} ${dst_dp_iface}=${None} ${dst_ip}=${None} ${dst_user}=${None} ${dst_pass}=${None} ${dst_container_type}=${None} ${dst_container_name}=${None}
124 Run Keyword If '${dst_ip}' != '${None}' Run Keywords
125 ... Add Double Vlan Interface on Host ${dst_dp_iface} ${s_tag} ${c_tag} ${dst_ip} ${dst_user} ${dst_pass} ${dst_container_type} ${dst_container_name} AND
126 ... Add IP Address on Interface on Host ${dst_dp_ip}/24 ${dst_dp_iface}.${s_tag}.${c_tag} ${dst_ip} ${dst_user} ${dst_pass} ${dst_container_type} ${dst_container_name} AND
127 ... Start DHCP Server on Remote Host ${dst_dp_iface}.${s_tag}.${c_tag} ${dst_ip} ${dst_user} ${dst_pass} ${dst_container_type} ${dst_container_name}
Kailash Khalasibf1478b2018-10-17 11:58:58 -0700128 Run Keyword If '${src_container_type}' != 'K8S' Send Dhclient Request ${src_iface} ${src_ip} ${src_user} ${src_pass} ${src_container_type} ${src_container_name}
129 ... ELSE Send Dhclient Request K8S
130 Run Keyword If '${dhcp_should_pass}' == 'True' Wait Until Keyword Succeeds 90s 5s Check IPv4 Address on DHCP Client True ${src_iface} ${src_ip} ${src_user} ${src_pass} ${src_container_type} ${src_container_name}
131 Run Keyword If '${dhcp_should_pass}' == 'False' Sleep 15s
132 Run Keyword If '${dhcp_should_pass}' == 'False' Check IPv4 Address on DHCP Client False ${src_iface} ${src_ip} ${src_user} ${src_pass} ${src_container_type} ${src_container_name}
133 Run Keyword If '${ping_should_pass}' == 'True' Wait Until Keyword Succeeds 60s 2s Check Ping True ${dst_dp_ip} ${src_iface} ${src_ip} ${src_user} ${src_pass} ${src_container_type} ${src_container_name}
134 ... ELSE Wait Until Keyword Succeeds 60s 2s Check Ping False ${dst_dp_ip} ${src_iface} ${src_ip} ${src_user} ${src_pass} ${src_container_type} ${src_container_name}
135
136Send Dhclient Request K8S
Andy Bavier8d74e8a2019-05-28 15:36:53 -0700137 ${RG_CONTAINER}= Wait Until Keyword Succeeds 60s 1s Run kubectl -n voltha get pod|grep "^rg[0-]"|cut -d' ' -f1
Andy Bavier57eaf152018-11-06 09:41:28 -0700138 Run kubectl -n voltha exec ${RG_CONTAINER} -- sed -i 's/timeout 300;/timeout 30;/' /etc/dhcp/dhclient.conf
Andy Bavierc615b912018-11-08 10:32:19 -0700139 Run kubectl -n voltha exec ${RG_CONTAINER} -- ifconfig eth0 0.0.0.0
Kailash3488a3a2018-11-05 10:31:25 -0800140 Run kubectl -n voltha exec ${RG_CONTAINER} -- dhclient
Kailash Khalasif56a4fb2018-10-23 12:38:16 -0700141
142Validate Subscriber Service Chain
143 [Arguments] ${serial_no} ${expected}=True
144 ${resp}= CORD Get ${VOLT_SUBSCRIBER}
145 ${jsondata}= To Json ${resp.content}
146 Log ${jsondata}
147 ${length}= Get Length ${jsondata['items']}
148 : FOR ${INDEX} IN RANGE 0 ${length}
149 \ ${value}= Get From List ${jsondata['items']} ${INDEX}
150 \ ${sl}= Get From Dictionary ${value} subscribed_links_ids
151 \ ${result} ${slinks}= Run Keyword And Ignore Error Get From List ${sl} 0
152 \ ${sn}= Get From Dictionary ${value} onu_device
153 \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop
Kailash017112f2018-11-01 09:57:37 -0700154 #Run Keyword If '${expected}' == 'True' Should Be Equal As Integers ${slinks} 1 ELSE Should Be Empty ${sl}
Kailash Khalasif56a4fb2018-10-23 12:38:16 -0700155
156Validate Fabric CrossConnect SI
Kailash Khalasia2e6aa82018-10-23 14:56:02 -0700157 [Arguments] ${stag} ${expected}=True
Kailash Khalasif56a4fb2018-10-23 12:38:16 -0700158 ${resp}= CORD Get ${FABRIC_CROSSCONNECT_SERVICEINSTANCES}
159 ${jsondata}= To Json ${resp.content}
160 Log ${jsondata}
161 ${length}= Get Length ${jsondata['items']}
162 @{tags}= Create List
163 : FOR ${INDEX} IN RANGE 0 ${length}
164 \ ${value}= Get From List ${jsondata['items']} ${INDEX}
165 \ ${tag}= Get From Dictionary ${value} s_tag
166 \ Append To List ${tags} ${tag}
Kailashc399f072019-06-14 12:41:39 -0700167 #Run Keyword If '${expected}' == 'True' List Should Contain Value ${tags} ${stag} ELSE List Should Not Contain Value ${tags} ${stag}
Kailashb78cf272018-11-20 12:25:16 -0800168
169Validate Subscriber Count
170 [Arguments] ${expected_no}
171 ${resp}= CORD Get ${VOLT_SUBSCRIBER}
172 ${jsondata}= To Json ${resp.content}
173 Log ${jsondata}
174 ${length}= Get Length ${jsondata['items']}
Kailashc399f072019-06-14 12:41:39 -0700175 Should Be Equal As Integers ${length} ${expected_no}
176
177Subscriber Ready to Authenticate
178 [Arguments] ${onu_device}
179 Wait Until Keyword Succeeds 60s 15s Validate ONU States ACTIVE ENABLED ${onu_device}
180 Wait Until Keyword Succeeds 60s 2s Validate ATT Workflow Driver SI ENABLED AWAITING ${onu_device} ONU has been validated - Awaiting Authentication
181 Wait Until Keyword Succeeds 60s 2s Validate Subscriber Status awaiting-auth ${onu_device}
182
183Subscriber Provisioned
184 [Arguments] ${server_ip} ${onu_device} ${stag}
185 Wait Until Keyword Succeeds 60s 2s Validate ATT Workflow Driver SI ENABLED APPROVED ${onu_device} ONU has been validated - Authentication succeeded
186 Wait Until Keyword Succeeds 60s 2s Validate Subscriber Status enabled ${onu_device}
187 Wait Until Keyword Succeeds 60s 2s Validate Subscriber Service Chain ${onu_device} True
188 Wait Until Keyword Succeeds 60s 2s Validate XConnect in ONOS ${server_ip} ${stag} True
189
190Subscriber Service Chain Created
191 [Arguments] ${onu_device} ${stag}
192 Wait Until Keyword Succeeds 60s 2s Validate ATT Workflow Driver SI ENABLED APPROVED ${onu_device} ONU has been validated - Authentication succeeded
193 Wait Until Keyword Succeeds 60s 2s Validate Subscriber Status enabled ${onu_device}
194 Wait Until Keyword Succeeds 60s 2s Validate Subscriber Service Chain ${onu_device} True
195 Wait Until Keyword Succeeds 60s 2s Validate Fabric CrossConnect SI ${stag} True
196 Wait Until Keyword Succeeds 60s 2s Validate XConnect in ONOS ${server_ip} ${stag} True
197
198Validate XConnect in ONOS
199 [Arguments] ${server_ip} ${stag} ${exists}=True
200 ${rc}= Run And Return RC http -a karaf:karaf GET http://${server_ip}:30120/onos/segmentrouting/xconnect|jq -r '.xconnects[].vlanId'|grep ${stag}
201 Run Keyword If '${exists}' == 'True' Should Be Equal As Integers ${rc} 0
202 ... ELSE Should Be Equal As Integers ${rc} 1