blob: 057b88eb58e5fc05e6eefa451d64f1fd9e4a874a [file] [log] [blame]
Kailash Khalasie6629eb2018-08-17 11:53:57 -07001*** Settings ***
2Library KafkaLibrary
3Library RequestsLibrary
4Library HttpLibrary.HTTP
5Library Collections
6Library String
7Library OperatingSystem
8Suite Setup Setup
9Suite Teardown Teardown
10
11*** Variables ***
12${cord_kafka} cord-kafka
13${server_ip} xos-chameleon
14${server_port} 9101
15${subscriber_api} /xosapi/v1/rcord/rcordsubscribers
16${att_si_api} /xosapi/v1/att-workflow-driver/attworkflowdriverserviceinstances
17${onu_device_api} /xosapi/v1/volt/onudevices
18${onu_serial_no} onudevice123
19${onu_invalid_sn} invalid_serial_no
20${mac_address} 00:AA:00:00:00:01
21${ip_address} 192.168.3.5
22${deviceId} of:robot_test
23${ponportno} 10
24${uniportno} 100
25
26*** Test Cases ***
27Create Two ONU Devices
Kailash Khalasi8f42b322018-08-21 09:36:53 -070028 [Documentation] Create two onu devices to be tested for valid/invalid paths
Kailash Khalasie6629eb2018-08-17 11:53:57 -070029 ${resp}= CORD Get /xosapi/v1/volt/voltservices
30 ${jsondata}= To Json ${resp.content}
31 ${voltservice}= Get From List ${jsondata['items']} 0
32 ${voltservice_id}= Get From Dictionary ${voltservice} id
33 ${resp}= CORD Get /xosapi/v1/att-workflow-driver/attworkflowdriverservices
34 ${jsondata}= To Json ${resp.content}
35 ${attworkflowservice}= Get From List ${jsondata['items']} 0
36 ${attworkflowservice_id}= Get From Dictionary ${attworkflowservice} id
37 Set Suite Variable ${attworkflowservice_id}
38 ${resp}= CORD Post /xosapi/v1/rcord/rcordsubscribers {"onu_device": "${onu_serial_no}", "status": "pre-provisioned"}
39 ${subscriber_id}= Get Json Value ${resp.content} /id
40 Set Suite Variable ${subscriber_id}
41 ${resp}= CORD Post /xosapi/v1/volt/oltdevices {"volt_service_id": ${voltservice_id}, "name": "testoltdevice1", "device_type": "ponism", "host": "172.17.0.1", "port": 50060, "switch_port": "1", "dp_id": "${deviceId}", "outer_tpid": "0x8100"}
42 ${oltdevice_id}= Get Json Value ${resp.content} /id
43 Set Suite Variable ${oltdevice_id}
44 ${resp}= CORD Post /xosapi/v1/volt/ponports {"olt_device_id": ${oltdevice_id}, "port_no": "${ponportno}", "name": "testponport1"}
45 ${ponport_id}= Get Json Value ${resp.content} /id
46 Set Suite Variable ${ponport_id}
47 ${resp}= CORD Post /xosapi/v1/volt/onudevices {"serial_number": "${onu_serial_no}", "pon_port_id": ${ponport_id}, "vendor": "abcdefg"}
48 ${onu_device1_id}= Get Json Value ${resp.content} /id
49 Set Suite Variable ${onu_device1_id}
50 ${resp}= CORD Post /xosapi/v1/volt/uniports {"onu_device_id": "${onu_device1_id}", "port_no": ${uniportno}, "name": "testuniport"}
51 ${uni_port_id}= Get Json Value ${resp.content} /id
52 Set Suite Variable ${uni_port_id}
53 ${resp}= CORD Post /xosapi/v1/volt/onudevices {"serial_number": "${onu_invalid_sn}", "pon_port_id": ${ponport_id}, "vendor": "abcdefg"}
54 ${onu_device2_id}= Get Json Value ${resp.content} /id
55 Set Suite Variable ${onu_device2_id}
56 ${resp}= CORD Post /xosapi/v1/att-workflow-driver/attworkflowdriverwhitelistentries {"serial_number": "${onu_serial_no}", "device_id": "${deviceId}", "pon_port_id": ${ponportno}, "owner_id": ${attworkflowservice_id}}
57 ${whitelist_entry_id}= Get Json Value ${resp.content} /id
58 Set Suite Variable ${whitelist_entry_id}
59
60Activate Non-Whitelisted ONU
61 [Documentation] Validate that activating an ONU not in whitelist sets onu device to DISABLED
62 Send Kafka Event onu.events {'status': 'activated','serial_number': '${onu_invalid_sn}','uni_port_id': ${uniportno}, 'of_dpid': '${deviceId}'}
63 Wait Until Keyword Succeeds 30s 5s Validate ONU Device Status ${onu_invalid_sn} DISABLED
64
65Activate Whitelisted ONU in Wrong Location
66 [Documentation] Validate that activating an ONU in the whitelist but in the wrong location DISABLES the onu device
Kailash Khalasic53eee92018-08-21 11:49:19 -070067 Send Kafka Event onu.events {'status': 'activated', 'serial_number': '${onu_serial_no}','uni_port_id': 52, 'of_dpid': 'wrongofdpid'}
68 Wait Until Keyword Succeeds 30s 5s Validate ONU Device Status ${onu_serial_no} DISABLED
Kailash Khalasie6629eb2018-08-17 11:53:57 -070069
70Activate Whitelisted ONU
71 [Documentation] Validate that activating an ONU in the whitelist creates a attworkflow-driver-serviceinstance
72 Send Kafka Event onu.events {'status': 'activated','serial_number': '${onu_serial_no}','uni_port_id': ${uniportno}, 'of_dpid': '${deviceId}'}
73 ${att_wf_driver_si_id}= Wait Until Keyword Succeeds 30s 5s Get ATT Service Instance ID ${onu_serial_no} AWAITING
Kailash Khalasic53eee92018-08-21 11:49:19 -070074 Wait Until Keyword Succeeds 60s 5s Validate ONU Device Status ${onu_serial_no} ENABLED
Kailash Khalasie6629eb2018-08-17 11:53:57 -070075
76Send Auth Request
77 [Documentation] Validate that sending an auth request to the onu will enable the subscriber and create a service chain
78 Send Kafka Event authentication.events {'authenticationState': 'APPROVED', 'deviceId': '${deviceId}','portNumber': ${uniportno}}
79 Wait Until Keyword Succeeds 30s 5s Validate Subscriber Status ${onu_serial_no} enabled
80 Wait Until Keyword Succeeds 30s 5s Validate Subscriber Service Chain ${onu_serial_no} 1
81 ${att_wf_driver_si_id}= Wait Until Keyword Succeeds 30s 5s Get ATT Service Instance ID ${onu_serial_no} APPROVED
82
83Send DHCP Request
84 [Documentation] Validate that sending an dhcp request to update the subscriber's mac+ip address
85 Send Kafka Event dhcp.events {'macAddress': '${mac_address}','ipAddress': '${ip_address}', 'deviceId': '${deviceId}', 'portNumber': ${uniportno}}
86 Wait Until Keyword Succeeds 30s 5s Validate Subscriber Settings ${onu_serial_no}
87
Kailash Khalasic53eee92018-08-21 11:49:19 -070088Send Denied Auth Request
89 [Documentation] Validate that denied auth request to the onu will disable the subscriber and remove a service chain
90 Send Kafka Event authentication.events {'authenticationState': 'DENIED', 'deviceId': '${deviceId}','portNumber': ${uniportno}}
91 Wait Until Keyword Succeeds 120s 5s Validate Subscriber Status ${onu_serial_no} auth-failed
92 Wait Until Keyword Succeeds 120s 5s Validate Subscriber Service Chain ${onu_serial_no}
93 ${att_wf_driver_si_id}= Wait Until Keyword Succeeds 30s 5s Get ATT Service Instance ID ${onu_serial_no} DENIED
94
Kailash Khalasie6629eb2018-08-17 11:53:57 -070095Create New Whitelist Entry
96 [Documentation] Validate that creating a new whitelist entry for the "invalid" onu device will enable the onu
Kailash Khalasie6629eb2018-08-17 11:53:57 -070097 ${resp}= CORD Post /xosapi/v1/att-workflow-driver/attworkflowdriverwhitelistentries {"serial_number": "${onu_invalid_sn}", "device_id": "${deviceId}", "pon_port_id": ${ponportno}, "owner_id": ${attworkflowservice_id}}
98 ${whitelist_entry2_id}= Get Json Value ${resp.content} /id
99 Set Suite Variable ${whitelist_entry2_id}
100 Wait Until Keyword Succeeds 30s 5s Validate ONU Device Status ${onu_invalid_sn} ENABLED
101
Kailash Khalasi8f42b322018-08-21 09:36:53 -0700102Remove Whitelist Entry
103 [Documentation] Validate that removing a whitelist entry for an onu device will disable the subscriber and remove it's service chain
104 CORD Delete /xosapi/v1/att-workflow-driver/attworkflowdriverwhitelistentries ${whitelist_entry_id}
Kailash Khalasic53eee92018-08-21 11:49:19 -0700105 Wait Until Keyword Succeeds 120s 5s Validate Subscriber Status ${onu_serial_no} auth-failed
106 Wait Until Keyword Succeeds 120s 5s Validate Subscriber Service Chain ${onu_serial_no}
107 Wait Until Keyword Succeeds 30s 5s Validate ONU Device Status ${onu_invalid_sn} DISABLED
Kailash Khalasi8f42b322018-08-21 09:36:53 -0700108
Kailash Khalasie6629eb2018-08-17 11:53:57 -0700109*** Keywords ***
110Setup
111 Connect Producer ${cord_kafka}:9092 onu.events
112 Connect Producer ${cord_kafka}:9092 authentication.events
113 Connect Producer ${cord_kafka}:9092 dhcp.events
114 ${auth} = Create List admin@opencord.org letmein
115 ${HEADERS} Create Dictionary Content-Type=application/json
116 Create Session ${server_ip} http://${server_ip}:${server_port} auth=${AUTH} headers=${HEADERS}
117
118Teardown
Kailash Khalasi8f42b322018-08-21 09:36:53 -0700119 [Documentation] Delete all models created
Kailash Khalasie6629eb2018-08-17 11:53:57 -0700120 CORD Get /xosapi/v1/rcord/rcordsubscribers
121 CORD Delete /xosapi/v1/rcord/rcordsubscribers ${subscriber_id}
Kailash Khalasi8f42b322018-08-21 09:36:53 -0700122 Wait Until Keyword Succeeds 60s 5s CORD Delete /xosapi/v1/volt/oltdevices ${oltdevice_id}
Kailash Khalasie6629eb2018-08-17 11:53:57 -0700123 CORD Delete /xosapi/v1/att-workflow-driver/attworkflowdriverwhitelistentries ${whitelist_entry2_id}
124
125Send Kafka Event
126 [Documentation] Send event
127 [Arguments] ${topic} ${message}
128 Log Sending event
129 ${event}= evaluate json.dumps(${message}) json
130 Send ${topic} ${event}
131 Flush
132
133CORD Get
134 [Documentation] Make a GET call to XOS
135 [Arguments] ${service}
136 ${resp}= Get Request ${server_ip} ${service}
137 Log ${resp.content}
138 Should Be Equal As Strings ${resp.status_code} 200
139 [Return] ${resp}
140
141CORD Post
142 [Documentation] Make a POST call to XOS
143 [Arguments] ${service} ${data}
144 ${data}= Evaluate json.dumps(${data}) json
145 ${resp}= Post Request ${server_ip} uri=${service} data=${data}
146 Log ${resp.content}
147 Should Be Equal As Strings ${resp.status_code} 200
148 ${id}= Get Json Value ${resp.content} /id
149 Set Suite Variable ${id}
150 [Return] ${resp}
151
152CORD Delete
153 [Documentation] Make a DELETE call to the CORD controller
154 [Arguments] ${service} ${data_id}
155 ${resp}= Delete Request ${SERVER_IP} uri=${service}/${data_id}
156 Log ${resp.content}
157 Should Be Equal As Strings ${resp.status_code} 200
158 [Return] ${resp}
159
160Get ATT Service Instance ID
161 [Documentation] Returns the id of the newly created onu's att workflow service instance
162 [Arguments] ${serial_no} ${auth_state}
163 ${resp}= Get Request ${server_ip} ${att_si_api}
164 Log ${resp.content}
165 Should Be Equal As Strings ${resp.status_code} 200
166 ## validate sn exists
167 Should Contain ${resp.content} ${serial_no}
168 ${jsondata}= To Json ${resp.content}
169 Log ${jsondata}
170 ${length}= Get Length ${jsondata['items']}
171 : FOR ${INDEX} IN RANGE 0 ${length}
172 \ ${value}= Get From List ${jsondata['items']} ${INDEX}
173 \ ${id}= Get From Dictionary ${value} id
174 \ ${sn}= Get From Dictionary ${value} serial_number
175 \ ${as}= Get From Dictionary ${value} authentication_state
176 \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop
177 Should Be Equal ${as} ${auth_state}
178 [Return] ${id}
179
Kailash Khalasie6629eb2018-08-17 11:53:57 -0700180Validate Subscriber Status
181 [Arguments] ${serial_no} ${expected_status}
182 ${resp}= CORD Get ${subscriber_api}
183 ${jsondata}= To Json ${resp.content}
184 Log ${jsondata}
185 ${length}= Get Length ${jsondata['items']}
186 : FOR ${INDEX} IN RANGE 0 ${length}
187 \ ${value}= Get From List ${jsondata['items']} ${INDEX}
188 \ ${status}= Get From Dictionary ${value} status
189 \ ${sn}= Get From Dictionary ${value} onu_device
190 \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop
191 Should Be Equal ${status} ${expected_status}
192
193Validate Subscriber Service Chain
Kailash Khalasic53eee92018-08-21 11:49:19 -0700194 [Arguments] ${serial_no} ${expected_no_sc}=${EMPTY}
Kailash Khalasie6629eb2018-08-17 11:53:57 -0700195 ${resp}= CORD Get ${subscriber_api}
196 ${jsondata}= To Json ${resp.content}
197 Log ${jsondata}
198 ${length}= Get Length ${jsondata['items']}
199 : FOR ${INDEX} IN RANGE 0 ${length}
200 \ ${value}= Get From List ${jsondata['items']} ${INDEX}
201 \ ${sl}= Get From Dictionary ${value} subscribed_links_ids
Kailash Khalasi5cd95a52018-08-22 08:55:04 -0700202 \ ${result} ${slinks}= Run Keyword And Ignore Error Get From List ${sl} 0
Kailash Khalasie6629eb2018-08-17 11:53:57 -0700203 \ ${sn}= Get From Dictionary ${value} onu_device
204 \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop
Kailash Khalasic53eee92018-08-21 11:49:19 -0700205 Run Keyword If '${expected_no_sc}' != '${EMPTY}' Should Be Equal As Integers ${slinks} ${expected_no_sc} ELSE Should Be Empty ${sl}
Kailash Khalasie6629eb2018-08-17 11:53:57 -0700206
207Validate ONU Device Status
208 [Arguments] ${serial_no} ${expected_status}
209 ${resp}= CORD Get ${onu_device_api}
210 ${jsondata}= To Json ${resp.content}
211 Log ${jsondata}
212 ${length}= Get Length ${jsondata['items']}
213 : FOR ${INDEX} IN RANGE 0 ${length}
214 \ ${value}= Get From List ${jsondata['items']} ${INDEX}
215 \ ${status}= Get From Dictionary ${value} admin_state
216 \ ${sn}= Get From Dictionary ${value} serial_number
217 \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop
218 Should Be Equal ${status} ${expected_status}
219
220Validate Subscriber Settings
221 [Arguments] ${serial_no}
222 ${resp}= CORD Get ${subscriber_api}
223 ${jsondata}= To Json ${resp.content}
224 Log ${jsondata}
225 ${length}= Get Length ${jsondata['items']}
226 : FOR ${INDEX} IN RANGE 0 ${length}
227 \ ${value}= Get From List ${jsondata['items']} ${INDEX}
228 \ ${macAddress}= Get From Dictionary ${value} mac_address
229 \ ${ipAddress}= Get From Dictionary ${value} ip_address
230 \ ${sn}= Get From Dictionary ${value} onu_device
231 \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop
232 Should Be Equal ${macAddress} ${mac_address}
Kailash Khalasi80e27db2018-08-20 16:58:47 -0700233 Should Be Equal ${ipAddress} ${ip_address}