blob: eea715070c047a7e6f4cab565fdcc937faa2cd66 [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}
Kailash Khalasi1fefd6a2018-09-05 15:00:20 -070041 ${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", "uplink": "128"}
Kailash Khalasie6629eb2018-08-17 11:53:57 -070042 ${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}
Kailash Khalasi8f42b322018-08-21 09:36:53 -0700107
Kailash Khalasie6629eb2018-08-17 11:53:57 -0700108*** Keywords ***
109Setup
110 Connect Producer ${cord_kafka}:9092 onu.events
111 Connect Producer ${cord_kafka}:9092 authentication.events
112 Connect Producer ${cord_kafka}:9092 dhcp.events
113 ${auth} = Create List admin@opencord.org letmein
114 ${HEADERS} Create Dictionary Content-Type=application/json
115 Create Session ${server_ip} http://${server_ip}:${server_port} auth=${AUTH} headers=${HEADERS}
116
117Teardown
Kailash Khalasi8f42b322018-08-21 09:36:53 -0700118 [Documentation] Delete all models created
Kailash Khalasie6629eb2018-08-17 11:53:57 -0700119 CORD Get /xosapi/v1/rcord/rcordsubscribers
120 CORD Delete /xosapi/v1/rcord/rcordsubscribers ${subscriber_id}
Kailash Khalasi8f42b322018-08-21 09:36:53 -0700121 Wait Until Keyword Succeeds 60s 5s CORD Delete /xosapi/v1/volt/oltdevices ${oltdevice_id}
Kailash Khalasie6629eb2018-08-17 11:53:57 -0700122 CORD Delete /xosapi/v1/att-workflow-driver/attworkflowdriverwhitelistentries ${whitelist_entry2_id}
123
124Send Kafka Event
125 [Documentation] Send event
126 [Arguments] ${topic} ${message}
127 Log Sending event
128 ${event}= evaluate json.dumps(${message}) json
129 Send ${topic} ${event}
130 Flush
131
132CORD Get
133 [Documentation] Make a GET call to XOS
134 [Arguments] ${service}
135 ${resp}= Get Request ${server_ip} ${service}
136 Log ${resp.content}
137 Should Be Equal As Strings ${resp.status_code} 200
138 [Return] ${resp}
139
140CORD Post
141 [Documentation] Make a POST call to XOS
142 [Arguments] ${service} ${data}
143 ${data}= Evaluate json.dumps(${data}) json
144 ${resp}= Post Request ${server_ip} uri=${service} data=${data}
145 Log ${resp.content}
146 Should Be Equal As Strings ${resp.status_code} 200
147 ${id}= Get Json Value ${resp.content} /id
148 Set Suite Variable ${id}
149 [Return] ${resp}
150
151CORD Delete
152 [Documentation] Make a DELETE call to the CORD controller
153 [Arguments] ${service} ${data_id}
154 ${resp}= Delete Request ${SERVER_IP} uri=${service}/${data_id}
155 Log ${resp.content}
156 Should Be Equal As Strings ${resp.status_code} 200
157 [Return] ${resp}
158
159Get ATT Service Instance ID
160 [Documentation] Returns the id of the newly created onu's att workflow service instance
161 [Arguments] ${serial_no} ${auth_state}
162 ${resp}= Get Request ${server_ip} ${att_si_api}
163 Log ${resp.content}
164 Should Be Equal As Strings ${resp.status_code} 200
165 ## validate sn exists
166 Should Contain ${resp.content} ${serial_no}
167 ${jsondata}= To Json ${resp.content}
168 Log ${jsondata}
169 ${length}= Get Length ${jsondata['items']}
170 : FOR ${INDEX} IN RANGE 0 ${length}
171 \ ${value}= Get From List ${jsondata['items']} ${INDEX}
172 \ ${id}= Get From Dictionary ${value} id
173 \ ${sn}= Get From Dictionary ${value} serial_number
174 \ ${as}= Get From Dictionary ${value} authentication_state
175 \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop
176 Should Be Equal ${as} ${auth_state}
177 [Return] ${id}
178
Kailash Khalasie6629eb2018-08-17 11:53:57 -0700179Validate Subscriber Status
180 [Arguments] ${serial_no} ${expected_status}
181 ${resp}= CORD Get ${subscriber_api}
182 ${jsondata}= To Json ${resp.content}
183 Log ${jsondata}
184 ${length}= Get Length ${jsondata['items']}
185 : FOR ${INDEX} IN RANGE 0 ${length}
186 \ ${value}= Get From List ${jsondata['items']} ${INDEX}
187 \ ${status}= Get From Dictionary ${value} status
188 \ ${sn}= Get From Dictionary ${value} onu_device
189 \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop
190 Should Be Equal ${status} ${expected_status}
191
192Validate Subscriber Service Chain
Kailash Khalasic53eee92018-08-21 11:49:19 -0700193 [Arguments] ${serial_no} ${expected_no_sc}=${EMPTY}
Kailash Khalasie6629eb2018-08-17 11:53:57 -0700194 ${resp}= CORD Get ${subscriber_api}
195 ${jsondata}= To Json ${resp.content}
196 Log ${jsondata}
197 ${length}= Get Length ${jsondata['items']}
198 : FOR ${INDEX} IN RANGE 0 ${length}
199 \ ${value}= Get From List ${jsondata['items']} ${INDEX}
200 \ ${sl}= Get From Dictionary ${value} subscribed_links_ids
Kailash Khalasi5cd95a52018-08-22 08:55:04 -0700201 \ ${result} ${slinks}= Run Keyword And Ignore Error Get From List ${sl} 0
Kailash Khalasie6629eb2018-08-17 11:53:57 -0700202 \ ${sn}= Get From Dictionary ${value} onu_device
203 \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop
Kailash Khalasic53eee92018-08-21 11:49:19 -0700204 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 -0700205
206Validate ONU Device Status
207 [Arguments] ${serial_no} ${expected_status}
208 ${resp}= CORD Get ${onu_device_api}
209 ${jsondata}= To Json ${resp.content}
210 Log ${jsondata}
211 ${length}= Get Length ${jsondata['items']}
212 : FOR ${INDEX} IN RANGE 0 ${length}
213 \ ${value}= Get From List ${jsondata['items']} ${INDEX}
214 \ ${status}= Get From Dictionary ${value} admin_state
215 \ ${sn}= Get From Dictionary ${value} serial_number
216 \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop
217 Should Be Equal ${status} ${expected_status}
218
219Validate Subscriber Settings
220 [Arguments] ${serial_no}
221 ${resp}= CORD Get ${subscriber_api}
222 ${jsondata}= To Json ${resp.content}
223 Log ${jsondata}
224 ${length}= Get Length ${jsondata['items']}
225 : FOR ${INDEX} IN RANGE 0 ${length}
226 \ ${value}= Get From List ${jsondata['items']} ${INDEX}
227 \ ${macAddress}= Get From Dictionary ${value} mac_address
228 \ ${ipAddress}= Get From Dictionary ${value} ip_address
229 \ ${sn}= Get From Dictionary ${value} onu_device
230 \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop
231 Should Be Equal ${macAddress} ${mac_address}
Kailash Khalasi80e27db2018-08-20 16:58:47 -0700232 Should Be Equal ${ipAddress} ${ip_address}