blob: 5b7498f316f073c634ba5e4543e3c1f5d48e701d [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
Hardik Windlassaa6aa7e2019-04-11 21:28:47 +053062 Send Kafka Event onu.events {'status': 'activated','serialNumber': '${onu_invalid_sn}','portNumber': '${uniportno}', 'deviceId': '${deviceId}'}
Kailash Khalasie6629eb2018-08-17 11:53:57 -070063 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
Hardik Windlassaa6aa7e2019-04-11 21:28:47 +053067 Send Kafka Event onu.events {'status': 'activated', 'serialNumber': '${onu_serial_no}','portNumber': '52', 'deviceId': 'wrongofdpid'}
Kailash Khalasic53eee92018-08-21 11:49:19 -070068 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
Hardik Windlassaa6aa7e2019-04-11 21:28:47 +053072 Send Kafka Event onu.events {'status': 'activated','serialNumber': '${onu_serial_no}','portNumber': '${uniportno}', 'deviceId': '${deviceId}'}
Kailash Khalasie6629eb2018-08-17 11:53:57 -070073 ${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
Kailash Khalasic53eee92018-08-21 11:49:19 -070083Send Denied Auth Request
84 [Documentation] Validate that denied auth request to the onu will disable the subscriber and remove a service chain
85 Send Kafka Event authentication.events {'authenticationState': 'DENIED', 'deviceId': '${deviceId}','portNumber': ${uniportno}}
86 Wait Until Keyword Succeeds 120s 5s Validate Subscriber Status ${onu_serial_no} auth-failed
87 Wait Until Keyword Succeeds 120s 5s Validate Subscriber Service Chain ${onu_serial_no}
88 ${att_wf_driver_si_id}= Wait Until Keyword Succeeds 30s 5s Get ATT Service Instance ID ${onu_serial_no} DENIED
89
Kailash Khalasie6629eb2018-08-17 11:53:57 -070090Create New Whitelist Entry
91 [Documentation] Validate that creating a new whitelist entry for the "invalid" onu device will enable the onu
Kailash Khalasie6629eb2018-08-17 11:53:57 -070092 ${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}}
93 ${whitelist_entry2_id}= Get Json Value ${resp.content} /id
94 Set Suite Variable ${whitelist_entry2_id}
95 Wait Until Keyword Succeeds 30s 5s Validate ONU Device Status ${onu_invalid_sn} ENABLED
96
Kailash Khalasi8f42b322018-08-21 09:36:53 -070097Remove Whitelist Entry
98 [Documentation] Validate that removing a whitelist entry for an onu device will disable the subscriber and remove it's service chain
99 CORD Delete /xosapi/v1/att-workflow-driver/attworkflowdriverwhitelistentries ${whitelist_entry_id}
Kailash Khalasic53eee92018-08-21 11:49:19 -0700100 Wait Until Keyword Succeeds 120s 5s Validate Subscriber Status ${onu_serial_no} auth-failed
101 Wait Until Keyword Succeeds 120s 5s Validate Subscriber Service Chain ${onu_serial_no}
Kailash Khalasi8f42b322018-08-21 09:36:53 -0700102
Kailash Khalasie6629eb2018-08-17 11:53:57 -0700103*** Keywords ***
104Setup
105 Connect Producer ${cord_kafka}:9092 onu.events
106 Connect Producer ${cord_kafka}:9092 authentication.events
107 Connect Producer ${cord_kafka}:9092 dhcp.events
108 ${auth} = Create List admin@opencord.org letmein
109 ${HEADERS} Create Dictionary Content-Type=application/json
110 Create Session ${server_ip} http://${server_ip}:${server_port} auth=${AUTH} headers=${HEADERS}
111
112Teardown
Kailash Khalasi8f42b322018-08-21 09:36:53 -0700113 [Documentation] Delete all models created
Kailash Khalasie6629eb2018-08-17 11:53:57 -0700114 CORD Get /xosapi/v1/rcord/rcordsubscribers
115 CORD Delete /xosapi/v1/rcord/rcordsubscribers ${subscriber_id}
Kailash Khalasi8f42b322018-08-21 09:36:53 -0700116 Wait Until Keyword Succeeds 60s 5s CORD Delete /xosapi/v1/volt/oltdevices ${oltdevice_id}
Kailash Khalasie6629eb2018-08-17 11:53:57 -0700117 CORD Delete /xosapi/v1/att-workflow-driver/attworkflowdriverwhitelistentries ${whitelist_entry2_id}
118
119Send Kafka Event
120 [Documentation] Send event
121 [Arguments] ${topic} ${message}
122 Log Sending event
123 ${event}= evaluate json.dumps(${message}) json
124 Send ${topic} ${event}
125 Flush
126
127CORD Get
128 [Documentation] Make a GET call to XOS
129 [Arguments] ${service}
130 ${resp}= Get Request ${server_ip} ${service}
131 Log ${resp.content}
132 Should Be Equal As Strings ${resp.status_code} 200
133 [Return] ${resp}
134
135CORD Post
136 [Documentation] Make a POST call to XOS
137 [Arguments] ${service} ${data}
138 ${data}= Evaluate json.dumps(${data}) json
139 ${resp}= Post Request ${server_ip} uri=${service} data=${data}
140 Log ${resp.content}
141 Should Be Equal As Strings ${resp.status_code} 200
142 ${id}= Get Json Value ${resp.content} /id
143 Set Suite Variable ${id}
144 [Return] ${resp}
145
146CORD Delete
147 [Documentation] Make a DELETE call to the CORD controller
148 [Arguments] ${service} ${data_id}
149 ${resp}= Delete Request ${SERVER_IP} uri=${service}/${data_id}
150 Log ${resp.content}
151 Should Be Equal As Strings ${resp.status_code} 200
152 [Return] ${resp}
153
154Get ATT Service Instance ID
155 [Documentation] Returns the id of the newly created onu's att workflow service instance
156 [Arguments] ${serial_no} ${auth_state}
157 ${resp}= Get Request ${server_ip} ${att_si_api}
158 Log ${resp.content}
159 Should Be Equal As Strings ${resp.status_code} 200
160 ## validate sn exists
161 Should Contain ${resp.content} ${serial_no}
162 ${jsondata}= To Json ${resp.content}
163 Log ${jsondata}
164 ${length}= Get Length ${jsondata['items']}
165 : FOR ${INDEX} IN RANGE 0 ${length}
166 \ ${value}= Get From List ${jsondata['items']} ${INDEX}
167 \ ${id}= Get From Dictionary ${value} id
168 \ ${sn}= Get From Dictionary ${value} serial_number
169 \ ${as}= Get From Dictionary ${value} authentication_state
170 \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop
171 Should Be Equal ${as} ${auth_state}
172 [Return] ${id}
173
Kailash Khalasie6629eb2018-08-17 11:53:57 -0700174Validate Subscriber Status
175 [Arguments] ${serial_no} ${expected_status}
176 ${resp}= CORD Get ${subscriber_api}
177 ${jsondata}= To Json ${resp.content}
178 Log ${jsondata}
179 ${length}= Get Length ${jsondata['items']}
180 : FOR ${INDEX} IN RANGE 0 ${length}
181 \ ${value}= Get From List ${jsondata['items']} ${INDEX}
182 \ ${status}= Get From Dictionary ${value} status
183 \ ${sn}= Get From Dictionary ${value} onu_device
184 \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop
185 Should Be Equal ${status} ${expected_status}
186
187Validate Subscriber Service Chain
Kailash Khalasic53eee92018-08-21 11:49:19 -0700188 [Arguments] ${serial_no} ${expected_no_sc}=${EMPTY}
Kailash Khalasie6629eb2018-08-17 11:53:57 -0700189 ${resp}= CORD Get ${subscriber_api}
190 ${jsondata}= To Json ${resp.content}
191 Log ${jsondata}
192 ${length}= Get Length ${jsondata['items']}
193 : FOR ${INDEX} IN RANGE 0 ${length}
194 \ ${value}= Get From List ${jsondata['items']} ${INDEX}
195 \ ${sl}= Get From Dictionary ${value} subscribed_links_ids
Kailash Khalasi5cd95a52018-08-22 08:55:04 -0700196 \ ${result} ${slinks}= Run Keyword And Ignore Error Get From List ${sl} 0
Kailash Khalasie6629eb2018-08-17 11:53:57 -0700197 \ ${sn}= Get From Dictionary ${value} onu_device
198 \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop
Kailash Khalasic53eee92018-08-21 11:49:19 -0700199 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 -0700200
201Validate ONU Device Status
202 [Arguments] ${serial_no} ${expected_status}
203 ${resp}= CORD Get ${onu_device_api}
204 ${jsondata}= To Json ${resp.content}
205 Log ${jsondata}
206 ${length}= Get Length ${jsondata['items']}
207 : FOR ${INDEX} IN RANGE 0 ${length}
208 \ ${value}= Get From List ${jsondata['items']} ${INDEX}
209 \ ${status}= Get From Dictionary ${value} admin_state
210 \ ${sn}= Get From Dictionary ${value} serial_number
211 \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop
212 Should Be Equal ${status} ${expected_status}
213
214Validate Subscriber Settings
215 [Arguments] ${serial_no}
216 ${resp}= CORD Get ${subscriber_api}
217 ${jsondata}= To Json ${resp.content}
218 Log ${jsondata}
219 ${length}= Get Length ${jsondata['items']}
220 : FOR ${INDEX} IN RANGE 0 ${length}
221 \ ${value}= Get From List ${jsondata['items']} ${INDEX}
222 \ ${macAddress}= Get From Dictionary ${value} mac_address
223 \ ${ipAddress}= Get From Dictionary ${value} ip_address
224 \ ${sn}= Get From Dictionary ${value} onu_device
225 \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop
226 Should Be Equal ${macAddress} ${mac_address}
Kailash Khalasi80e27db2018-08-20 16:58:47 -0700227 Should Be Equal ${ipAddress} ${ip_address}