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