delete device testcase + test improvements
Change-Id: Ia2b6d5c2912e5c513e2ac08efa1a691a89d4c5c0
diff --git a/Makefile b/Makefile
index efc6c38..8aacf10 100644
--- a/Makefile
+++ b/Makefile
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-LINT_ARGS ?= --verbose --configure LineTooLong:130 --ignore TooFewTestSteps --ignore TooFewKeywordSteps
+LINT_ARGS ?= --verbose --configure LineTooLong:130 --configure TooManyTestSteps:15 --ignore TooFewTestSteps --ignore TooFewKeywordSteps
lint:
diff --git a/libraries/utils.robot b/libraries/utils.robot
index ad14d72..4541bbd 100644
--- a/libraries/utils.robot
+++ b/libraries/utils.robot
@@ -39,7 +39,7 @@
[Arguments] ${serial_number} ${admin_state} ${oper_status} ${connect_status}
[Documentation] Parses the output of "voltctl device list" and inspects device ${serial_number}
... Arguments are matched for device states of: "admin_state", "oper_status", and "connect_status"
- ${output}= Run ${VOLTCTL_CONFIG} voltctl device list -o json
+ ${output}= Run ${VOLTCTL_CONFIG}; voltctl device list -o json
${jsondata}= To Json ${output}
Log ${jsondata}
${length}= Get Length ${jsondata}
@@ -54,6 +54,34 @@
Should Be Equal ${opstatus} ${oper_status} Device ${serial_number} oper_status != ACTIVE values=False
Should Be Equal ${cstatus} ${connect_status} Device ${serial_number} connect_status != REACHABLE values=False
+Get Device ID From SN
+ [Arguments] ${serial_number}
+ [Documentation] Gets the device id by matching for ${serial_number}
+ ${output}= Run ${VOLTCTL_CONFIG}; voltctl device list -o json
+ ${jsondata}= To Json ${output}
+ Log ${jsondata}
+ ${length}= Get Length ${jsondata}
+ : FOR ${INDEX} IN RANGE 0 ${length}
+ \ ${value}= Get From List ${jsondata} ${INDEX}
+ \ ${id}= Get From Dictionary ${value} id
+ \ ${sn}= Get From Dictionary ${value} serialnumber
+ \ Run Keyword If '${sn}' == '${serial_number}' Exit For Loop
+ [Return] ${id}
+
+Validate Device Removed
+ [Arguments] ${id}
+ [Documentation] Verifys that device, ${serial_number}, has been removed
+ ${output}= Run ${VOLTCTL_CONFIG}; voltctl device list -o json
+ ${jsondata}= To Json ${output}
+ Log ${jsondata}
+ ${length}= Get Length ${jsondata}
+ @{ids}= Create List
+ : FOR ${INDEX} IN RANGE 0 ${length}
+ \ ${value}= Get From List ${jsondata} ${INDEX}
+ \ ${device_id}= Get From Dictionary ${value} id
+ \ Append To List ${ids} ${device_id}
+ List Should Not Contain Value ${ids} ${id}
+
Check CLI Tools Configured
[Documentation] Tests that use 'voltctl' and 'kubectl' should execute this keyword in suite setup
# check voltctl and kubectl configured
diff --git a/tests/sanity/sanity.robot b/tests/sanity/sanity.robot
index ce107af..72ddd9b 100644
--- a/tests/sanity/sanity.robot
+++ b/tests/sanity/sanity.robot
@@ -27,7 +27,6 @@
${server_ip} localhost
${timeout} 90s
${num_onus} 1
-${SADIS_CONFIG} ${CURDIR}/../data/sadis-notp-1.json
*** Test Cases ***
Activate Device BBSIM OLT/ONU
@@ -36,15 +35,20 @@
... re-validate deployment
[Tags] activate
#create/preprovision device
- ${rc} ${device_id}= Run and Return Rc and Output ${VOLTCTL_CONFIG} voltctl device create -t openolt -H ${BBSIM_SERVICE}:${BBSIM_PORT}
+ ${rc} ${olt_device_id}= Run and Return Rc and Output
+ ... ${VOLTCTL_CONFIG}; voltctl device create -t openolt -H ${BBSIM_IP}:${BBSIM_PORT}
Should Be Equal As Integers ${rc} 0
+ Set Suite Variable ${olt_device_id}
#enable device
- ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG} voltctl device enable ${device_id}
+ ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device enable ${device_id}
Should Be Equal As Integers ${rc} 0
#validate olt states
Wait Until Keyword Succeeds 60s 5s Validate Device ${BBSIM_OLT_SN} ENABLED ACTIVE REACHABLE
#validate onu states
Wait Until Keyword Succeeds 60s 5s Validate Device ${BBSIM_ONU_SN} ENABLED ACTIVE REACHABLE
+ #get onu device id
+ ${onu_device_id}= Get Device ID From SN ${BBSIM_ONU_SN}
+ Set Suite Variable ${onu_device_id}
Validate OLT Connected to ONOS
[Documentation] Verifies the BBSIM-OLT device is activated in onos
@@ -54,20 +58,35 @@
Check EAPOL Flows in ONOS
[Documentation] Validates eapol flows for the onu are pushed from voltha
[Tags] eapol
- Wait Until Keyword Succeeds ${timeout} 5s Verify Eapol Flows Added
+ Wait Until Keyword Succeeds ${timeout} 5s Verify Eapol Flows Added ${num_onus}
Validate ONU Authenticated in ONOS
[Documentation] Validates onu is AUTHORIZED in ONOS as bbsim will attempt to authenticate
[Tags] aaa
- Wait Until Keyword Succeeds ${timeout} 5s Verify Number of AAA-Users ${number_of_onus}
-
-Provision ONU Subscriber in ONOS
- [Documentation] Through the olt-app in ONOS, execute 'volt-add-subscriber-access' and validate IP Flows
- [Tags] notready
+ Wait Until Keyword Succeeds ${timeout} 5s Verify Number of AAA-Users ${num_onus}
Validate DHCP Assignment in ONOS
[Documentation] After IP Flows are pushed to the device, BBSIM will start a dhclient for the ONU.
- [Tags] notready
+ [Tags] dhcp
+ Wait Until Keyword Succeeds 120s 15s Validate DHCP Allocations ${num_onus}
+
+Delete Device and Verify
+ [Documentation] Disable -> Delete devices via voltctl and verify its removed
+ [Tags] deletedevice
+ #disable/delete onu
+ ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device disable ${onu_device_id}
+ Should Be Equal As Integers ${rc} 0
+ Wait Until Keyword Succeeds 60s 5s Validate Device ${BBSIM_ONU_SN} DISABLED UNKNOWN UNREACHABLE
+ ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device delete ${onu_device_id}
+ Should Be Equal As Integers ${rc} 0
+ Wait Until Keyword Succeeds 60s 5s Validate Device Removed ${onu_device_id}
+ #disable/delete olt
+ ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device disable ${olt_device_id}
+ Should Be Equal As Integers ${rc} 0
+ Wait Until Keyword Succeeds 60s 5s Validate Device ${BBSIM_OLT_SN} DISABLED UNKNOWN UNREACHABLE
+ ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device delete ${olt_device_id}
+ Should Be Equal As Integers ${rc} 0
+ Wait Until Keyword Succeeds 60s 5s Validate Device Removed ${olt_device_id}
*** Keywords ***
Setup
@@ -79,8 +98,6 @@
${onos_auth}= Create List karaf karaf
${HEADERS} Create Dictionary Content-Type=application/json
Create Session ONOS http://${server_ip}:${ONOS_REST_PORT} auth=${ONOS_AUTH}
- ## TODO upload sadis ${sadis_config}
-
Teardown
[Documentation] Delete all http sessions
@@ -110,4 +127,10 @@
[Arguments] ${expected_onus}
[Documentation] Matches for number of aaa-users authorized based on number of onus
${aaa_users}= Execute ONOS Command aaa-users | grep AUTHORIZED | wc -l
- Should Contain ${aaa_users} ${expected_onus}
\ No newline at end of file
+ Should Contain ${aaa_users} ${expected_onus}
+
+Validate DHCP Allocations
+ [Arguments] ${expected_onus}
+ [Documentation] Matches for number of dhcpacks based on number of onus
+ ${allocations}= Execute ONOS Command dhcpl2relay-allocations | grep DHCPACK | wc -l
+ Should Contain ${allocations} ${expected_onus}
\ No newline at end of file
diff --git a/variables/variables.robot b/variables/variables.robot
index 927e5f6..e518ba6 100644
--- a/variables/variables.robot
+++ b/variables/variables.robot
@@ -13,7 +13,7 @@
# limitations under the License.
*** Variables ***
-${BBSIM_SERVICE} bbsim.voltha.svc
+${BBSIM_IP} bbsim.voltha.svc
${BBSIM_PORT} 50060
${BBSIM_DEVICE_ID} of:0000626273696d76
${BBSIM_OLT_SN} BBSIMOLT000