Validate Deleted Device Cleanup in ONOS
Change-Id: I5f3ee1a0987e57be8f02685cb0b0a96abcc0d4f0
diff --git a/libraries/onos.robot b/libraries/onos.robot
index 6e8f6e4..c0fde9b 100755
--- a/libraries/onos.robot
+++ b/libraries/onos.robot
@@ -607,3 +607,37 @@
${ebs_value} Run Keyword If '${bandwidthparameter}' == ' exceededBurstSize' Set Variable ${value}
${limiting_BW}= Evaluate ${cir_value}+${eir_value}
[Return] ${limiting_BW}
+
+Validate Deleted Device Cleanup In ONOS
+ [Arguments] ${ip} ${port} ${olt_serial_number}
+ [Documentation] The keyword verifies that ports, flows, meters, subscribers, dhcp are all cleared in ONOS
+ # Fetch OF Id for OLT
+ ${olt_of_id}= Wait Until Keyword Succeeds ${timeout} 5s Validate OLT Device in ONOS ${olt_serial_number}
+ # Open ONOS SSH Connection
+ ${onos_ssh_connection} Open ONOS SSH Connection ${ip} ${port}
+ # Verify Ports are Removed
+ ${port_count}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
+ ... ports ${olt_of_id} | grep -v ${olt_of_id} | wc -l
+ Should Be Equal As Integers ${port_count} 0
+ # Verify Subscribers are Removed
+ ${sub_count}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
+ ... volt-programmed-subscribers | grep ${olt_of_id} | wc -l
+ Should Be Equal As Integers ${sub_count} 0
+ # Verify Flows are Removed
+ ${flow_count}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
+ ... flows -s -f ${olt_of_id} | grep -v deviceId | wc -l
+ Should Be Equal As Integers ${flow_count} 0
+ # Verify Meters are Removed
+ ${meter_count}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
+ ... meters ${olt_of_id} | wc -l
+ Should Be Equal As Integers ${meter_count} 0
+ # Verify AAA-Users are Removed
+ ${aaa_count}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
+ ... aaa-users ${olt_of_id} | wc -l
+ Should Be Equal As Integers ${aaa_count} 0
+ # Verify Dhcp-Allocations are Removed
+ ${dhcp_count}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
+ ... dhcpl2relay-allocations ${olt_of_id} | wc -l
+ Should Be Equal As Integers ${dhcp_count} 0
+ # Close ONOS SSH Connection
+ Close ONOS SSH Connection ${onos_ssh_connection}
diff --git a/libraries/utils.robot b/libraries/utils.robot
index 64be39b..36ccb6f 100755
--- a/libraries/utils.robot
+++ b/libraries/utils.robot
@@ -641,6 +641,11 @@
Delete Devices In Voltha Root=true
Run Keyword If ${has_dataplane} Sleep 30s
Wait Until Keyword Succeeds ${timeout} 2s Test Empty Device List
+ FOR ${I} IN RANGE 0 ${num_olts}
+ ${olt_serial_number}= Set Variable ${list_olts}[${I}][sn]
+ Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 15s
+ ... Validate Deleted Device Cleanup In ONOS ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${olt_serial_number}
+ END
# Clear devices from ONOS
#Remove All Devices From ONOS
#... http://karaf:karaf@${ONOS_REST_IP}:${ONOS_REST_PORT}
@@ -668,6 +673,8 @@
Run Keyword If ${has_dataplane} Sleep 50s
Should Be Equal As Integers ${rc} 0
Wait Until Keyword Succeeds ${timeout} 5s Validate Device Removed ${olt_device_id}
+ Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 15s
+ ... Validate Deleted Device Cleanup In ONOS ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${olt_serial_number}
Repeat Sanity Test
[Documentation] This keyword performs Sanity Test Procedure