blob: bb1bbf18a01a03be06ea411d29a7b33bb5bde6f5 [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
114 Sleep 30
115 CORD Get /xosapi/v1/rcord/rcordsubscribers
116 CORD Delete /xosapi/v1/rcord/rcordsubscribers ${subscriber_id}
117 CORD Delete /xosapi/v1/volt/oltdevices ${oltdevice_id}
118 CORD Delete /xosapi/v1/att-workflow-driver/attworkflowdriverwhitelistentries ${whitelist_entry_id}
119 CORD Delete /xosapi/v1/att-workflow-driver/attworkflowdriverwhitelistentries ${whitelist_entry2_id}
120
121Send Kafka Event
122 [Documentation] Send event
123 [Arguments] ${topic} ${message}
124 Log Sending event
125 ${event}= evaluate json.dumps(${message}) json
126 Send ${topic} ${event}
127 Flush
128
129CORD Get
130 [Documentation] Make a GET call to XOS
131 [Arguments] ${service}
132 ${resp}= Get Request ${server_ip} ${service}
133 Log ${resp.content}
134 Should Be Equal As Strings ${resp.status_code} 200
135 [Return] ${resp}
136
137CORD Post
138 [Documentation] Make a POST call to XOS
139 [Arguments] ${service} ${data}
140 ${data}= Evaluate json.dumps(${data}) json
141 ${resp}= Post Request ${server_ip} uri=${service} data=${data}
142 Log ${resp.content}
143 Should Be Equal As Strings ${resp.status_code} 200
144 ${id}= Get Json Value ${resp.content} /id
145 Set Suite Variable ${id}
146 [Return] ${resp}
147
148CORD Delete
149 [Documentation] Make a DELETE call to the CORD controller
150 [Arguments] ${service} ${data_id}
151 ${resp}= Delete Request ${SERVER_IP} uri=${service}/${data_id}
152 Log ${resp.content}
153 Should Be Equal As Strings ${resp.status_code} 200
154 [Return] ${resp}
155
156Get ATT Service Instance ID
157 [Documentation] Returns the id of the newly created onu's att workflow service instance
158 [Arguments] ${serial_no} ${auth_state}
159 ${resp}= Get Request ${server_ip} ${att_si_api}
160 Log ${resp.content}
161 Should Be Equal As Strings ${resp.status_code} 200
162 ## validate sn exists
163 Should Contain ${resp.content} ${serial_no}
164 ${jsondata}= To Json ${resp.content}
165 Log ${jsondata}
166 ${length}= Get Length ${jsondata['items']}
167 : FOR ${INDEX} IN RANGE 0 ${length}
168 \ ${value}= Get From List ${jsondata['items']} ${INDEX}
169 \ ${id}= Get From Dictionary ${value} id
170 \ ${sn}= Get From Dictionary ${value} serial_number
171 \ ${as}= Get From Dictionary ${value} authentication_state
172 \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop
173 Should Be Equal ${as} ${auth_state}
174 [Return] ${id}
175
176Validate Service Chain Links
177 [Arguments] ${serial_no} ${expected_links}
178 ${resp}= CORD Get ${subscriber_api}
179 ${jsondata}= To Json ${resp.content}
180 Log ${jsondata}
181 ${length}= Get Length ${jsondata['items']}
182 : FOR ${INDEX} IN RANGE 0 ${length}
183 \ ${value}= Get From List ${jsondata['items']} ${INDEX}
184 \ ${subscribed_links}= Get From Dictionary ${value} subscribed_links_ids
185 \ ${id}= Get From Dictionary ${value} id
186 \ ${sn}= Get From Dictionary ${value} onu_device
187 \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop
188 Should Be Equal ${expected_links} ${subscribed_links}
189
190Validate Subscriber Status
191 [Arguments] ${serial_no} ${expected_status}
192 ${resp}= CORD Get ${subscriber_api}
193 ${jsondata}= To Json ${resp.content}
194 Log ${jsondata}
195 ${length}= Get Length ${jsondata['items']}
196 : FOR ${INDEX} IN RANGE 0 ${length}
197 \ ${value}= Get From List ${jsondata['items']} ${INDEX}
198 \ ${status}= Get From Dictionary ${value} status
199 \ ${sn}= Get From Dictionary ${value} onu_device
200 \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop
201 Should Be Equal ${status} ${expected_status}
202
203Validate Subscriber Service Chain
204 [Arguments] ${serial_no} ${expected_no_sc}
205 ${resp}= CORD Get ${subscriber_api}
206 ${jsondata}= To Json ${resp.content}
207 Log ${jsondata}
208 ${length}= Get Length ${jsondata['items']}
209 : FOR ${INDEX} IN RANGE 0 ${length}
210 \ ${value}= Get From List ${jsondata['items']} ${INDEX}
211 \ ${sl}= Get From Dictionary ${value} subscribed_links_ids
212 \ ${sl}= Get From List ${sl} 0
213 \ ${sn}= Get From Dictionary ${value} onu_device
214 \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop
215 Should Be Equal As Integers ${sl} ${expected_no_sc}
216
217Validate ONU Device Status
218 [Arguments] ${serial_no} ${expected_status}
219 ${resp}= CORD Get ${onu_device_api}
220 ${jsondata}= To Json ${resp.content}
221 Log ${jsondata}
222 ${length}= Get Length ${jsondata['items']}
223 : FOR ${INDEX} IN RANGE 0 ${length}
224 \ ${value}= Get From List ${jsondata['items']} ${INDEX}
225 \ ${status}= Get From Dictionary ${value} admin_state
226 \ ${sn}= Get From Dictionary ${value} serial_number
227 \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop
228 Should Be Equal ${status} ${expected_status}
229
230Validate Subscriber Settings
231 [Arguments] ${serial_no}
232 ${resp}= CORD Get ${subscriber_api}
233 ${jsondata}= To Json ${resp.content}
234 Log ${jsondata}
235 ${length}= Get Length ${jsondata['items']}
236 : FOR ${INDEX} IN RANGE 0 ${length}
237 \ ${value}= Get From List ${jsondata['items']} ${INDEX}
238 \ ${macAddress}= Get From Dictionary ${value} mac_address
239 \ ${ipAddress}= Get From Dictionary ${value} ip_address
240 \ ${sn}= Get From Dictionary ${value} onu_device
241 \ Run Keyword If '${sn}' == '${serial_no}' Exit For Loop
242 Should Be Equal ${macAddress} ${mac_address}
243 Should Be Equal ${ipAddress} ${ip_address}