[VOL-3246] Added RebootONUs before the test executions, and ONURestore towards end of executions

Change-Id: Ie228afdd8656e15d89711ea5415bd9960fdc1a22
diff --git a/libraries/utils.robot b/libraries/utils.robot
index 64879c9..bda4aef 100644
--- a/libraries/utils.robot
+++ b/libraries/utils.robot
@@ -264,7 +264,7 @@
     Test Empty Device List
     #Run Keyword If    ${has_dataplane}    Wait Until Keyword Succeeds    120s    10s    Openolt is Up
     #...    ${olt_ip}    ${olt_user}    ${olt_pass}
-    Run Keyword If    ${has_dataplane}    Sleep    180s
+    Run Keyword If    ${has_dataplane}    Sleep    230s
     #create/preprovision device
     ${olt_device_id}=    Create Device    ${olt_ip}    ${OLT_PORT}
     Set Suite Variable    ${olt_device_id}
diff --git a/tests/dt-workflow/Voltha_DT_PODTests.robot b/tests/dt-workflow/Voltha_DT_PODTests.robot
index 304ebac..e542352 100644
--- a/tests/dt-workflow/Voltha_DT_PODTests.robot
+++ b/tests/dt-workflow/Voltha_DT_PODTests.robot
@@ -31,6 +31,7 @@
 Resource          ../../libraries/utils.robot
 Resource          ../../libraries/k8s.robot
 Resource          ../../variables/variables.robot
+Resource          ../../libraries/power_switch.robot
 
 *** Variables ***
 ${POD_NAME}       flex-ocp-cord
@@ -61,6 +62,24 @@
 ${container_log_dir}    ${None}
 
 *** Test Cases ***
+Reboot DT ONUs Physically
+    [Documentation]   This test reboots ONUs physically before execution all the tests
+    ...    Test case runs only on the PODs that are configured with PowerSwitch that
+    ...    controls the power off/on ONUs/OLT remotely (simulating a physical reboot)
+    [Tags]    functional   PowerSwitch    RebootAllDTONUs
+    [Setup]    Start Logging    RebootAllDTONUs
+    [Teardown]    Run Keywords    Collect Logs
+    ...           AND             Stop Logging    RebootAllDTONUs
+    Power Switch Connection Suite    ${web_power_switch.ip}    ${web_power_switch.user}    ${web_power_switch.password}
+    FOR    ${I}    IN RANGE    0    ${num_onus}
+        ${src}=    Set Variable    ${hosts.src[${I}]}
+        ${dst}=    Set Variable    ${hosts.dst[${I}]}
+        Disable Switch Outlet    ${src['power_switch_port']}
+        Sleep    60s
+        Enable Switch Outlet    ${src['power_switch_port']}
+        Sleep    60s
+    END
+
 Sanity E2E Test for OLT/ONU on POD for DT
     [Documentation]    Validates E2E Ping Connectivity and object states for the given scenario:
     ...    Validate successful DHCP/E2E ping (no EAPOL and DHCP flows) for the tech profile that is used
@@ -475,7 +494,10 @@
     [Documentation]    Set up the test suite
     Common Test Suite Setup
     #Restore all ONUs
-    Run Keyword If    ${has_dataplane}    RestoreONUs    ${num_onus}
+    #Run Keyword If    ${has_dataplane}    RestoreONUs    ${num_onus}
+    #power_switch.robot needs it to support different vendor's power switch
+    ${switch_type}=    Get Variable Value    ${web_power_switch.type}
+    Run Keyword If  "${switch_type}"!=""    Set Global Variable    ${powerswitch_type}    ${switch_type}
 
 Clear All Devices Then Create New Device
     [Documentation]    Remove any devices from VOLTHA and ONOS
diff --git a/tests/functional/Voltha_ErrorScenarios.robot b/tests/functional/Voltha_ErrorScenarios.robot
index 52eb6db..8f832ba 100644
--- a/tests/functional/Voltha_ErrorScenarios.robot
+++ b/tests/functional/Voltha_ErrorScenarios.robot
@@ -268,3 +268,7 @@
     [Documentation]    Set up the test suite
     Common Test Suite Setup
 
+#Teardown Suite
+#    [Documentation]    Teardown suite
+    #Restore all ONUs
+#    Run Keyword If    ${has_dataplane}    RestoreONUs    ${num_onus}
diff --git a/tests/functional/Voltha_PODTests.robot b/tests/functional/Voltha_PODTests.robot
index f81da96..8fb1fe2 100644
--- a/tests/functional/Voltha_PODTests.robot
+++ b/tests/functional/Voltha_PODTests.robot
@@ -31,6 +31,7 @@
 Resource          ../../libraries/utils.robot
 Resource          ../../libraries/k8s.robot
 Resource          ../../variables/variables.robot
+Resource          ../../libraries/power_switch.robot
 
 *** Variables ***
 ${POD_NAME}       flex-ocp-cord
@@ -61,6 +62,24 @@
 ${container_log_dir}    ${None}
 
 *** Test Cases ***
+Reboot ONUs Physically
+    [Documentation]   This test reboots ONUs physically before execution all the tests
+    ...    Test case runs only on the PODs that are configured with PowerSwitch that
+    ...    controls the power off/on ONUs/OLT remotely (simulating a physical reboot)
+    [Tags]    functional   PowerSwitch    RebootAllONUs
+    [Setup]    Start Logging    RebootAllONUs
+    [Teardown]    Run Keywords    Collect Logs
+    ...           AND             Stop Logging    RebootAllONUs
+    Power Switch Connection Suite    ${web_power_switch.ip}    ${web_power_switch.user}    ${web_power_switch.password}
+    FOR    ${I}    IN RANGE    0    ${num_onus}
+        ${src}=    Set Variable    ${hosts.src[${I}]}
+        ${dst}=    Set Variable    ${hosts.dst[${I}]}
+        Disable Switch Outlet    ${src['power_switch_port']}
+        Sleep    60s
+        Enable Switch Outlet    ${src['power_switch_port']}
+        Sleep    60s
+    END
+
 Sanity E2E Test for OLT/ONU on POD
     [Documentation]    Validates E2E Ping Connectivity and object states for the given scenario:
     ...    Validate successful authentication/DHCP/E2E ping for the tech profile that is used
@@ -565,7 +584,10 @@
     [Documentation]    Set up the test suite
     Common Test Suite Setup
     #Restore all ONUs
-    Run Keyword If    ${has_dataplane}    RestoreONUs    ${num_onus}
+    #Run Keyword If    ${has_dataplane}    RestoreONUs    ${num_onus}
+    #power_switch.robot needs it to support different vendor's power switch
+    ${switch_type}=    Get Variable Value    ${web_power_switch.type}
+    Run Keyword If  "${switch_type}"!=""    Set Global Variable    ${powerswitch_type}    ${switch_type}
 
 Clear All Devices Then Create New Device
     [Documentation]    Remove any devices from VOLTHA and ONOS