blob: 23f42628b5f1b500dfe27e3ba468f08f8849dd2e [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
Kailash Khalasi80e27db2018-08-20 16:58:47 -070010Test Setup TSetup
11Test Teardown TTeardown
Kailash Khalasie6629eb2018-08-17 11:53:57 -070012
13*** Variables ***
14${cord_kafka} cord-kafka
15${server_ip} xos-chameleon
16${server_port} 9101
17${subscriber_api} /xosapi/v1/rcord/rcordsubscribers
18${att_si_api} /xosapi/v1/att-workflow-driver/attworkflowdriverserviceinstances
19${onu_device_api} /xosapi/v1/volt/onudevices
20${onu_serial_no} onudevice123
21${onu_invalid_sn} invalid_serial_no
22${mac_address} 00:AA:00:00:00:01
23${ip_address} 192.168.3.5
24${deviceId} of:robot_test
25${ponportno} 10
26${uniportno} 100
27
28*** Test Cases ***
29Create Two ONU Devices
30 [Documentation] Create two onu devices to be tested for valid + invalid paths
31 [Tags] play
32 ${resp}= CORD Get /xosapi/v1/volt/voltservices
33 ${jsondata}= To Json ${resp.content}
34 ${voltservice}= Get From List ${jsondata['items']} 0
35 ${voltservice_id}= Get From Dictionary ${voltservice} id
36 ${resp}= CORD Get /xosapi/v1/att-workflow-driver/attworkflowdriverservices
37 ${jsondata}= To Json ${resp.content}
38 ${attworkflowservice}= Get From List ${jsondata['items']} 0
39 ${attworkflowservice_id}= Get From Dictionary ${attworkflowservice} id
40 Set Suite Variable ${attworkflowservice_id}
41 ${resp}= CORD Post /xosapi/v1/rcord/rcordsubscribers {"onu_device": "${onu_serial_no}", "status": "pre-provisioned"}
42 ${subscriber_id}= Get Json Value ${resp.content} /id
43 Set Suite Variable ${subscriber_id}
44 ${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"}
45 ${oltdevice_id}= Get Json Value ${resp.content} /id
46 Set Suite Variable ${oltdevice_id}
47 ${resp}= CORD Post /xosapi/v1/volt/ponports {"olt_device_id": ${oltdevice_id}, "port_no": "${ponportno}", "name": "testponport1"}
48 ${ponport_id}= Get Json Value ${resp.content} /id
49 Set Suite Variable ${ponport_id}
50 ${resp}= CORD Post /xosapi/v1/volt/onudevices {"serial_number": "${onu_serial_no}", "pon_port_id": ${ponport_id}, "vendor": "abcdefg"}
51 ${onu_device1_id}= Get Json Value ${resp.content} /id
52 Set Suite Variable ${onu_device1_id}
53 ${resp}= CORD Post /xosapi/v1/volt/uniports {"onu_device_id": "${onu_device1_id}", "port_no": ${uniportno}, "name": "testuniport"}
54 ${uni_port_id}= Get Json Value ${resp.content} /id
55 Set Suite Variable ${uni_port_id}
56 ${resp}= CORD Post /xosapi/v1/volt/onudevices {"serial_number": "${onu_invalid_sn}", "pon_port_id": ${ponport_id}, "vendor": "abcdefg"}
57 ${onu_device2_id}= Get Json Value ${resp.content} /id
58 Set Suite Variable ${onu_device2_id}
59 ${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}}
60 ${whitelist_entry_id}= Get Json Value ${resp.content} /id
61 Set Suite Variable ${whitelist_entry_id}
62
63Activate Non-Whitelisted ONU
64 [Documentation] Validate that activating an ONU not in whitelist sets onu device to DISABLED
65 Send Kafka Event onu.events {'status': 'activated','serial_number': '${onu_invalid_sn}','uni_port_id': ${uniportno}, 'of_dpid': '${deviceId}'}
66 Wait Until Keyword Succeeds 30s 5s Validate ONU Device Status ${onu_invalid_sn} DISABLED
67
68Activate Whitelisted ONU in Wrong Location
69 [Documentation] Validate that activating an ONU in the whitelist but in the wrong location DISABLES the onu device
70 Send Kafka Event onu.events {'status': 'activated','serial_number': '${onu_serial_no}','uni_port_id': 52, 'of_dpid': '${deviceId}'}
71 ${att_wf_driver_si_id}= Wait Until Keyword Succeeds 30s 5s Get ATT Service Instance ID ${onu_serial_no} DISABLED
72
73Activate Whitelisted ONU
74 [Documentation] Validate that activating an ONU in the whitelist creates a attworkflow-driver-serviceinstance
75 Send Kafka Event onu.events {'status': 'activated','serial_number': '${onu_serial_no}','uni_port_id': ${uniportno}, 'of_dpid': '${deviceId}'}
76 ${att_wf_driver_si_id}= Wait Until Keyword Succeeds 30s 5s Get ATT Service Instance ID ${onu_serial_no} AWAITING
77
78Send Denied Auth Request
79 [Documentation] Validate that denied auth request to the onu will disabled the subscriber and remove a service chain
80 Send Kafka Event authentication.events {'authenticationState': 'DENIED', 'deviceId': '${deviceId}','portNumber': ${uniportno}}
81 Wait Until Keyword Succeeds 30s 5s Validate Subscriber Status ${onu_serial_no} disabled
82 Wait Until Keyword Succeeds 30s 5s Validate Subscriber Service Chain ${onu_serial_no} 0
83 ${att_wf_driver_si_id}= Wait Until Keyword Succeeds 30s 5s Get ATT Service Instance ID ${onu_serial_no} AWAITING
84
85Send Auth Request
86 [Documentation] Validate that sending an auth request to the onu will enable the subscriber and create a service chain
87 Send Kafka Event authentication.events {'authenticationState': 'APPROVED', 'deviceId': '${deviceId}','portNumber': ${uniportno}}
88 Wait Until Keyword Succeeds 30s 5s Validate Subscriber Status ${onu_serial_no} enabled
89 Wait Until Keyword Succeeds 30s 5s Validate Subscriber Service Chain ${onu_serial_no} 1
90 ${att_wf_driver_si_id}= Wait Until Keyword Succeeds 30s 5s Get ATT Service Instance ID ${onu_serial_no} APPROVED
91
92Send DHCP Request
93 [Documentation] Validate that sending an dhcp request to update the subscriber's mac+ip address
94 Send Kafka Event dhcp.events {'macAddress': '${mac_address}','ipAddress': '${ip_address}', 'deviceId': '${deviceId}', 'portNumber': ${uniportno}}
95 Wait Until Keyword Succeeds 30s 5s Validate Subscriber Settings ${onu_serial_no}
96
97Create New Whitelist Entry
98 [Documentation] Validate that creating a new whitelist entry for the "invalid" onu device will enable the onu
99 [Tags] notready
100 ${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}}
101 ${whitelist_entry2_id}= Get Json Value ${resp.content} /id
102 Set Suite Variable ${whitelist_entry2_id}
103 Wait Until Keyword Succeeds 30s 5s Validate ONU Device Status ${onu_invalid_sn} ENABLED
104
105*** Keywords ***
106Setup
107 Connect Producer ${cord_kafka}:9092 onu.events
108 Connect Producer ${cord_kafka}:9092 authentication.events
109 Connect Producer ${cord_kafka}:9092 dhcp.events
110 ${auth} = Create List admin@opencord.org letmein
111 ${HEADERS} Create Dictionary Content-Type=application/json
112 Create Session ${server_ip} http://${server_ip}:${server_port} auth=${AUTH} headers=${HEADERS}
113
114Teardown
115 [Documentation] Delete all models create
116 Sleep 30
117 CORD Get /xosapi/v1/rcord/rcordsubscribers
118 CORD Delete /xosapi/v1/rcord/rcordsubscribers ${subscriber_id}
119 CORD Delete /xosapi/v1/volt/oltdevices ${oltdevice_id}
120 CORD Delete /xosapi/v1/att-workflow-driver/attworkflowdriverwhitelistentries ${whitelist_entry_id}
121 CORD Delete /xosapi/v1/att-workflow-driver/attworkflowdriverwhitelistentries ${whitelist_entry2_id}
122
Kailash Khalasi80e27db2018-08-20 16:58:47 -0700123TSetup
124 [Documentation] Get ONU Devices for debugging purposes
125 CORD GET /xosapi/v1/volt/onudevices
126
127TTeardown
128 [Documentation] Get ONU Devices for debugging purposes
129 CORD GET /xosapi/v1/volt/onudevices
130
Kailash Khalasie6629eb2018-08-17 11:53:57 -0700131Send Kafka Event
132 [Documentation] Send event
133 [Arguments] ${topic} ${message}
134 Log Sending event
135 ${event}= evaluate json.dumps(${message}) json
136 Send ${topic} ${event}
137 Flush
138
139CORD Get
140 [Documentation] Make a GET call to XOS
141 [Arguments] ${service}
142 ${resp}= Get Request ${server_ip} ${service}
143 Log ${resp.content}
144 Should Be Equal As Strings ${resp.status_code} 200
145 [Return] ${resp}
146
147CORD Post
148 [Documentation] Make a POST call to XOS
149 [Arguments] ${service} ${data}
150 ${data}= Evaluate json.dumps(${data}) json
151 ${resp}= Post Request ${server_ip} uri=${service} data=${data}
152 Log ${resp.content}
153 Should Be Equal As Strings ${resp.status_code} 200
154 ${id}= Get Json Value ${resp.content} /id
155 Set Suite Variable ${id}
156 [Return] ${resp}
157
158CORD Delete
159 [Documentation] Make a DELETE call to the CORD controller
160 [Arguments] ${service} ${data_id}
161 ${resp}= Delete Request ${SERVER_IP} uri=${service}/${data_id}
162 Log ${resp.content}
163 Should Be Equal As Strings ${resp.status_code} 200
164 [Return] ${resp}
165
166Get ATT Service Instance ID
167 [Documentation] Returns the id of the newly created onu's att workflow service instance
168 [Arguments] ${serial_no} ${auth_state}
169 ${resp}= Get Request ${server_ip} ${att_si_api}
170 Log ${resp.content}
171 Should Be Equal As Strings ${resp.status_code} 200
172 ## validate sn exists
173 Should Contain ${resp.content} ${serial_no}
174 ${jsondata}= To Json ${resp.content}
175 Log ${jsondata}
176 ${length}= Get Length ${jsondata['items']}
177 : FOR ${INDEX} IN RANGE 0 ${length}
178 \ ${value}= Get From List ${jsondata['items']} ${INDEX}
179 \ ${id}= Get From Dictionary ${value} id
180 \ ${sn}= Get From Dictionary ${value} serial_number
181 \ ${as}= Get From Dictionary ${value} authentication_state
182 \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop
183 Should Be Equal ${as} ${auth_state}
184 [Return] ${id}
185
186Validate Service Chain Links
187 [Arguments] ${serial_no} ${expected_links}
188 ${resp}= CORD Get ${subscriber_api}
189 ${jsondata}= To Json ${resp.content}
190 Log ${jsondata}
191 ${length}= Get Length ${jsondata['items']}
192 : FOR ${INDEX} IN RANGE 0 ${length}
193 \ ${value}= Get From List ${jsondata['items']} ${INDEX}
194 \ ${subscribed_links}= Get From Dictionary ${value} subscribed_links_ids
195 \ ${id}= Get From Dictionary ${value} id
196 \ ${sn}= Get From Dictionary ${value} onu_device
197 \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop
198 Should Be Equal ${expected_links} ${subscribed_links}
199
200Validate Subscriber Status
201 [Arguments] ${serial_no} ${expected_status}
202 ${resp}= CORD Get ${subscriber_api}
203 ${jsondata}= To Json ${resp.content}
204 Log ${jsondata}
205 ${length}= Get Length ${jsondata['items']}
206 : FOR ${INDEX} IN RANGE 0 ${length}
207 \ ${value}= Get From List ${jsondata['items']} ${INDEX}
208 \ ${status}= Get From Dictionary ${value} status
209 \ ${sn}= Get From Dictionary ${value} onu_device
210 \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop
211 Should Be Equal ${status} ${expected_status}
212
213Validate Subscriber Service Chain
214 [Arguments] ${serial_no} ${expected_no_sc}
215 ${resp}= CORD Get ${subscriber_api}
216 ${jsondata}= To Json ${resp.content}
217 Log ${jsondata}
218 ${length}= Get Length ${jsondata['items']}
219 : FOR ${INDEX} IN RANGE 0 ${length}
220 \ ${value}= Get From List ${jsondata['items']} ${INDEX}
221 \ ${sl}= Get From Dictionary ${value} subscribed_links_ids
222 \ ${sl}= Get From List ${sl} 0
223 \ ${sn}= Get From Dictionary ${value} onu_device
224 \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop
225 Should Be Equal As Integers ${sl} ${expected_no_sc}
226
227Validate ONU Device Status
228 [Arguments] ${serial_no} ${expected_status}
229 ${resp}= CORD Get ${onu_device_api}
230 ${jsondata}= To Json ${resp.content}
231 Log ${jsondata}
232 ${length}= Get Length ${jsondata['items']}
233 : FOR ${INDEX} IN RANGE 0 ${length}
234 \ ${value}= Get From List ${jsondata['items']} ${INDEX}
235 \ ${status}= Get From Dictionary ${value} admin_state
236 \ ${sn}= Get From Dictionary ${value} serial_number
237 \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop
238 Should Be Equal ${status} ${expected_status}
239
240Validate Subscriber Settings
241 [Arguments] ${serial_no}
242 ${resp}= CORD Get ${subscriber_api}
243 ${jsondata}= To Json ${resp.content}
244 Log ${jsondata}
245 ${length}= Get Length ${jsondata['items']}
246 : FOR ${INDEX} IN RANGE 0 ${length}
247 \ ${value}= Get From List ${jsondata['items']} ${INDEX}
248 \ ${macAddress}= Get From Dictionary ${value} mac_address
249 \ ${ipAddress}= Get From Dictionary ${value} ip_address
250 \ ${sn}= Get From Dictionary ${value} onu_device
251 \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop
252 Should Be Equal ${macAddress} ${mac_address}
Kailash Khalasi80e27db2018-08-20 16:58:47 -0700253 Should Be Equal ${ipAddress} ${ip_address}