[VOL-3686][VOL-3687][VOL-3688] Create Reconcile Testsuite for OpenOnu-Go-Adapter and refactoring of existing OpenOnu-Go-Adapter Testsuites and Library
- add new target in Makefile
- implement option to use delete (default) or kill for restart of onu adapter
Change-Id: Icbcbd6e8a74e0f8be2fbeb27f70c11da8a76b6aa
diff --git a/libraries/onos.robot b/libraries/onos.robot
index a1542a4..6e8f6e4 100755
--- a/libraries/onos.robot
+++ b/libraries/onos.robot
@@ -470,6 +470,14 @@
... Should Be Equal As Integers ${rc} 0
END
+Assert ONU Port Is Disabled
+ [Arguments] ${onos_ssh_connection} ${deviceId} ${onu_port}
+ [Documentation] Verifies if the ONU port is disabled in ONOS
+ ${onu_port_disabled}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
+ ... ports -d ${deviceId} | grep port=${onu_port}
+ Log ${onu_port_disabled}
+ Should Not Be Empty ${onu_port_disabled}
+
Assert Ports in ONOS
[Arguments] ${onos_ssh_connection} ${count} ${deviceId} ${filter}
[Documentation] Check that a certain number of ports are enabled in ONOS
diff --git a/libraries/Voltha_ONUUtilities.robot b/libraries/onu_utilities.robot
similarity index 78%
rename from libraries/Voltha_ONUUtilities.robot
rename to libraries/onu_utilities.robot
index 1389715..41f598e 100755
--- a/libraries/Voltha_ONUUtilities.robot
+++ b/libraries/onu_utilities.robot
@@ -19,16 +19,35 @@
${defaultstackname} minimal
*** Keywords ***
-Do Power On ONU Device
- [Documentation] This keyword power on all onus.
- ${namespace}= Set Variable voltha
+Calculate Timeout
+ [Documentation] Calculates the timeout regarding num-onus in case of more than 4 onus
+ [Arguments] ${basetimeout}=60s
+ ${new_timeout} Fetch From Left ${basetimeout} s
+ ${new_timeout}= evaluate ${new_timeout}+((${num_all_onus}-4)*10)
+ ${new_timeout}= Set Variable If (not ${debugmode}) and (${new_timeout}>300)
+ ... 300 ${new_timeout}
+ ${new_timeout}= Catenate SEPARATOR= ${new_timeout} s
+ [Return] ${new_timeout}
+
+Power On ONU Device
+ [Documentation] This keyword turns on the power for all onus.
+ [Arguments] ${namespace}
FOR ${I} IN RANGE 0 ${num_all_onus}
${src}= Set Variable ${hosts.src[${I}]}
${result}= Exec Pod In Kube ${namespace} bbsim bbsimctl onu poweron ${src['onu']}
Should Contain ${result} successfully msg=Can not poweron ${src['onu']} values=False
END
-Do Current State Test
+Power Off ONU Device
+ [Documentation] This keyword turns off the power for all onus.
+ [Arguments] ${namespace}
+ FOR ${I} IN RANGE 0 ${num_all_onus}
+ ${src}= Set Variable ${hosts.src[${I}]}
+ ${result}= Exec Pod In Kube ${namespace} bbsim bbsimctl onu shutdown ${src['onu']}
+ Should Contain ${result} successfully msg=Can not shutdown ${src['onu']} values=False
+ END
+
+Current State Test
[Documentation] This keyword checks the passed state of the given onu.
[Arguments] ${state} ${onu} ${reqadminstate}=${EMPTY} ${reqoperstatus}=${EMPTY}
... ${reqconnectstatus}=${EMPTY}
@@ -41,11 +60,12 @@
... Validate Device ${admin_state} ${oper_status} ${connect_status}
... ${onu} onu=True onu_reason=${onu_state}
-Do Current State Test All Onus
+Current State Test All Onus
[Documentation] This keyword checks the passed state of all onus.
... Hint: ${timeStart} will be not evaluated here!
[Arguments] ${state} ${reqadminstate}=${EMPTY} ${reqoperstatus}=${EMPTY} ${reqconnectstatus}=${EMPTY}
... ${alternativeonustate}=${EMPTY}
+ ${timeStart}= Get Current Date
${list_onus} Create List
Build ONU SN List ${list_onus}
${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Map State ${state}
@@ -58,17 +78,6 @@
... ${admin_state} ${oper_status} ${connect_status}
... ${onu_state} ${list_onus} ${timeStart} alternate_reason=${alternativeonustate}
-Do Current Reason Test All Onus
- [Documentation] This keyword checks the passed state of all onus.
- ... Hint: ${timeStart} will be not evaluated here!
- [Arguments] ${state}
- ${list_onus} Create List
- Build ONU SN List ${list_onus}
- ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Map State ${state}
- Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
- ... Validate ONU Devices MIB State With Duration
- ... ${onu_state} ${list_onus} ${timeStart}
-
Log Ports
[Documentation] This keyword logs all port data available in ONOS of first port per ONU
[Arguments] ${onlyenabled}=False
@@ -86,6 +95,47 @@
${rc} ${output}= Run and Return Rc and Output ${cmd}
Log ${output}
+Kill And Check Onu Adaptor
+ [Documentation] This keyword kills ONU Adaptor and waits for it to come up again
+ ... Following steps will be executed:
+ ... - kill openonu adaptor
+ ... - check openonu adaptor is ready again
+ [Arguments] ${namespace}
+ ${list_openonu_apps} Create List adapter-open-onu
+ ${adaptorname}= Set Variable open-onu
+ Kill Adaptor ${namespace} ${adaptorname}
+ Sleep 5s
+ Wait For Pods Ready ${namespace} ${list_openonu_apps}
+
+Restart And Check Onu Adaptor
+ [Documentation] This keyword restarts ONU Adaptor and waits for it to come up again
+ ... Following steps will be executed:
+ ... - restart openonu adaptor
+ ... - check openonu adaptor is ready again
+ [Arguments] ${namespace}
+ ${list_openonu_apps} Create List adapter-open-onu
+ ${adaptorname}= Set Variable open-onu
+ Restart Pod ${namespace} ${adaptorname}
+ Sleep 5s
+ Wait For Pods Ready ${namespace} ${list_openonu_apps}
+
+Disable Onu Device
+ [Documentation] This keyword disables all onus.
+ FOR ${I} IN RANGE 0 ${num_all_onus}
+ ${src}= Set Variable ${hosts.src[${I}]}
+ ${onu_device_id}= Get Device ID From SN ${src['onu']}
+ Disable Device ${onu_device_id}
+ Wait Until Keyword Succeeds 20s 2s Test Devices Disabled in VOLTHA Id=${onu_device_id}
+ END
+
+Enable Onu Device
+ [Documentation] This keyword enables all onus.
+ FOR ${I} IN RANGE 0 ${num_all_onus}
+ ${src}= Set Variable ${hosts.src[${I}]}
+ ${onu_device_id}= Get Device ID From SN ${src['onu']}
+ Enable Device ${onu_device_id}
+ END
+
Verify MIB Template Data Available
[Documentation] This keyword verifies MIB Template Data stored in etcd
${namespace}= Set Variable default
@@ -108,6 +158,34 @@
${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
Should Be Empty ${result} Could not delete MIB Template Data stored in etcd!
+Set Tech Profile
+ [Documentation] This keyword sets the passed TechProfile for the test
+ [Arguments] ${TechProfile}
+ Log To Console \nTechProfile:${TechProfile}
+ ${namespace}= Set Variable default
+ ${podname}= Set Variable etcd
+ ${src}= Set Variable ${data_dir}/TechProfile-${TechProfile}.json
+ ${dest}= Set Variable /tmp/flexpod.json
+ ${command} Catenate
+ ... /bin/sh -c 'cat ${dest} | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/XGS-PON/64'
+ Copy File To Pod ${namespace} ${podname} ${src} ${dest}
+ Exec Pod In Kube ${namespace} ${podname} ${command}
+ ${commandget} Catenate
+ ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64'
+ Exec Pod In Kube ${namespace} ${podname} ${commandget}
+
+Remove Tech Profile
+ [Documentation] This keyword removes TechProfile
+ Log To Console \nTechProfile:${TechProfile}
+ ${namespace}= Set Variable default
+ ${podname}= Set Variable etcd
+ ${command} Catenate
+ ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/voltha/technology_profiles/XGS-PON/64'
+ Exec Pod In Kube ${namespace} ${podname} ${command}
+ ${commandget} Catenate
+ ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64'
+ Exec Pod In Kube ${namespace} ${podname} ${commandget}
+
Validate Onu Data In Etcd
[Documentation] This keyword validates openonu-go-adapter Data stored in etcd.
... It checks unique of serial_number and combination of pon, onu and uni in tp_path.
@@ -186,7 +264,7 @@
... ELSE IF ${oldsetvidvalid} and not ${setvidequal}
... Should Not Be Equal As Integers ${prevsetvid} ${setvid}
END
- log Many ${vlan_rules}
+ log Many ${vlan_rules}
[Return] ${vlan_rules}
Get ONU Go Adapter ETCD Data
@@ -279,7 +357,7 @@
[Return] ${env_name}
Wait for Ports in ONOS for all OLTs
- [Documentation] Waits untill a certain number of ports are enabled in all ONOS
+ [Documentation] Waits untill a certain number of ports are enabled in all OLTs
[Arguments] ${onos_ssh_connection} ${count} ${filter} ${max_wait_time}=10m
FOR ${J} IN RANGE 0 ${num_olts}
${olt_serial_number}= Set Variable ${list_olts}[${J}][sn]
@@ -290,6 +368,18 @@
Wait for Ports in ONOS ${onos_ssh_connection} ${count} ${of_id} BBSM ${max_wait_time}
END
+Wait for all ONU Ports in ONOS Disabled
+ [Documentation] Waits untill a all ONU ports are disabled in all ONOS
+ [Arguments] ${onos_ssh_connection}
+ FOR ${I} IN RANGE 0 ${num_all_onus}
+ ${src}= Set Variable ${hosts.src[${I}]}
+ ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS
+ ... ${src['olt']}
+ ${onu_port}= Wait Until Keyword Succeeds ${timeout} 2s Get ONU Port in ONOS ${src['onu']} ${of_id}
+ Wait Until Keyword Succeeds ${timeout} 2s Assert ONU Port Is Disabled ${onos_ssh_connection} ${of_id}
+ ... ${onu_port}
+ END
+
Map State
[Documentation] This keyword converts the passed numeric value or name of a onu state to its state values.
[Arguments] ${state}