[VOL-4267] Added openonu-adapter restart scenario with continuous ping running in background for DT
Change-Id: I05e6bc4d085ec7f5921862e08496874a6ea90257
diff --git a/libraries/utils.robot b/libraries/utils.robot
index 64b4c84..c08d1ac 100755
--- a/libraries/utils.robot
+++ b/libraries/utils.robot
@@ -1328,6 +1328,33 @@
${object}= Evaluate json.loads(r'''${output}''') json
[Return] ${object}
+Run Ping In Background
+ [Arguments] ${output_file} ${dst_ip} ${iface} ${ip} ${user} ${pass}=${None}
+ ... ${container_type}=${None} ${container_name}=${None}
+ [Documentation] Runs the 'ping' on remote system in background and stores the result in a file
+ ${result}= Login And Run Command On Remote System
+ ... ping -I ${iface} ${dst_ip} > ${output_file} &
+ ... ${ip} ${user} ${pass} ${container_type} ${container_name}
+ Log ${result}
+
+Stop Ping Running In Background
+ [Arguments] ${ip} ${user} ${pass}=${None}
+ ... ${container_type}=${None} ${container_name}=${None}
+ [Documentation] Stops the 'ping' running in background on remote system
+ ${result}= Login And Run Command On Remote System
+ ... sudo kill -SIGINT `pgrep ping`
+ ... ${ip} ${user} ${pass} ${container_type} ${container_name}
+ Log ${result}
+
+Retrieve Remote File Contents
+ [Documentation] Retrieves the contents of the file on remote system
+ [Arguments] ${file} ${ip} ${user} ${pass}=${None}
+ ... ${container_type}=${None} ${container_name}=${None} ${prompt}=~$
+ ${output}= Login And Run Command On Remote System
+ ... cat ${file}
+ ... ${ip} ${user} ${pass} ${container_type} ${container_name} ${prompt}
+ [Return] ${output}
+
RestoreONUs
[Documentation] Restore all connected ONUs
[Arguments] ${num_all_onus}
diff --git a/tests/dt-workflow/Voltha_DT_FailureScenarios.robot b/tests/dt-workflow/Voltha_DT_FailureScenarios.robot
index 12110a9..11663b8 100755
--- a/tests/dt-workflow/Voltha_DT_FailureScenarios.robot
+++ b/tests/dt-workflow/Voltha_DT_FailureScenarios.robot
@@ -558,6 +558,55 @@
Run Keyword Wait Until Keyword Succeeds ${timeout} 5s Validate ONU Flows
... ${List_ONU_Serial} ${onu_flows}
+Verify restart openonu-adapter container while continuously running ping in background for DT
+ [Documentation] Restart openonu-adapter container after VOLTHA is operational.
+ ... Run the ping continuously in background during container restart,
+ ... and verify that there should be no affect on the dataplane.
+ [Tags] functionalDt RestartOpenOnuPingDt
+ [Setup] Start Logging RestartOpenOnuPingDt
+ [Teardown] Run Keywords Run Keyword If ${logging} Collect Logs
+ ... AND Stop Logging RestartOpenOnuPingDt
+ Clear All Devices Then Create New Device
+ # Performing Sanity Test to make sure subscribers are all DHCP and pingable
+ Run Keyword If ${has_dataplane} Clean Up Linux
+ Wait Until Keyword Succeeds ${timeout} 2s Perform Sanity Test DT
+ FOR ${I} IN RANGE 0 ${num_all_onus}
+ ${src}= Set Variable ${hosts.src[${I}]}
+ ${dst}= Set Variable ${hosts.dst[${I}]}
+ ${ping_output_file}= Set Variable /tmp/${src['onu']}_ping
+ Run Keyword If ${has_dataplane} Run Keyword And Continue On Failure
+ ... Wait Until Keyword Succeeds 60s 2s
+ ... Run Ping In Background ${ping_output_file} ${dst['dp_iface_ip_qinq']} ${src['dp_iface_name']}
+ ... ${src['ip']} ${src['user']} ${src['pass']} ${src['container_type']} ${src['container_name']}
+ END
+ ${podStatusOutput}= Run kubectl get pods -n ${NAMESPACE}
+ Log ${podStatusOutput}
+ ${countBeforeRestart}= Run kubectl get pods -n ${NAMESPACE} | grep Running | wc -l
+ ${podName} Set Variable adapter-open-onu
+ Wait Until Keyword Succeeds ${timeout} 15s Delete K8s Pods By Label ${NAMESPACE} app ${podName}
+ Wait Until Keyword Succeeds ${timeout} 2s Validate Pods Status By Label ${NAMESPACE}
+ ... app ${podName} Running
+ # Wait for 1 min after openonu adapter is restarted
+ Sleep 60s
+ ${podStatusOutput}= Run kubectl get pods -n ${NAMESPACE}
+ Log ${podStatusOutput}
+ ${countAfterRestart}= Run kubectl get pods -n ${NAMESPACE} | grep Running | wc -l
+ Should Be Equal As Strings ${countAfterRestart} ${countBeforeRestart}
+ FOR ${I} IN RANGE 0 ${num_all_onus}
+ ${src}= Set Variable ${hosts.src[${I}]}
+ ${dst}= Set Variable ${hosts.dst[${I}]}
+ ${ping_output_file}= Set Variable /tmp/${src['onu']}_ping
+ Run Keyword If ${has_dataplane} Run Keyword And Continue On Failure
+ ... Wait Until Keyword Succeeds 60s 2s
+ ... Stop Ping Running In Background ${src['ip']} ${src['user']} ${src['pass']}
+ ... ${src['container_type']} ${src['container_name']}
+ ${ping_output}= Run Keyword If ${has_dataplane} Run Keyword And Continue On Failure
+ ... Wait Until Keyword Succeeds 60s 2s
+ ... Retrieve Remote File Contents ${ping_output_file} ${src['ip']} ${src['user']} ${src['pass']}
+ ... ${src['container_type']} ${src['container_name']}
+ Check Ping Result True ${ping_output}
+ END
+
*** Keywords ***
Setup Suite
[Documentation] Set up the test suite