[VOL-2409]Restart ofagent

Change-Id: I9e75770b9d1836d273c24a5197453719f9a02102
diff --git a/libraries/utils.robot b/libraries/utils.robot
index 6d0828b..97433ff 100644
--- a/libraries/utils.robot
+++ b/libraries/utils.robot
@@ -271,3 +271,10 @@
         Run Keyword and Ignore Error   Get Device Output from Voltha    ${onu_device_id}
         Run Keyword and Ignore Error   Collect Logs
     END
+
+Collect Logs
+    [Documentation]    Collect Logs from voltha and onos cli for various commands
+    Run Keyword and Ignore Error    Get Device List from Voltha
+    Run Keyword and Ignore Error    Get Device Output from Voltha    ${olt_device_id}
+    Run Keyword and Ignore Error    Get Logical Device Output from Voltha    ${logical_id}
+    Run Keyword If    ${external_libs}    Get ONOS Status    ${k8s_node_ip}
diff --git a/tests/functional/Voltha_FailureScenarios.robot b/tests/functional/Voltha_FailureScenarios.robot
index 3d173cd..ab1a238 100644
--- a/tests/functional/Voltha_FailureScenarios.robot
+++ b/tests/functional/Voltha_FailureScenarios.robot
@@ -53,6 +53,28 @@
 ${scripts}        ../../scripts
 
 *** Test Cases ***
+Verify restart ofagent container after VOLTHA is operational
+    [Documentation]    Restart ofagent container after VOLTHA is operational.
+    ...    Please note this test case should be run before the restart of other containers.
+    ...    Prerequisite : ONUs are authenticated and pingable.
+    [Tags]    functional   VOL-2409   RestartPods   notready
+    [Setup]    NONE
+    [Teardown]    NONE
+    ${waitforRestart}    Set Variable    120s
+    ${podStatusOutput}=    Run    ${KUBECTL_CONFIG};kubectl get pods -n ${NAMESPACE}
+    Log    ${podStatusOutput}
+    ${countBforRestart}=    Run    ${KUBECTL_CONFIG};kubectl get pods -n ${NAMESPACE} | grep Running | wc -l
+    Restart Pod    ${NAMESPACE}    ofagent
+    Sleep    60s
+    Wait Until Keyword Succeeds    ${waitforRestart}    2s    Validate Pod Status    ofagent    ${NAMESPACE}
+    ...    Running
+    Repeat Sanity Test
+    ${podStatusOutput}=    Run    ${KUBECTL_CONFIG};kubectl get pods -n ${NAMESPACE}
+    Log    ${podStatusOutput}
+    ${countAfterRestart}=    Run    ${KUBECTL_CONFIG};kubectl get pods -n ${NAMESPACE} | grep Running | wc -l
+    Should Be Equal As Strings    ${countAfterRestart}    ${countBforRestart}
+    Run Keyword and Ignore Error   Collect Logs
+
 Verify restart any container after VOLTHA is operational
     [Documentation]    Restart any container after VOLTHA is operational.
     ...    Prerequisite : ONUs are authenticated and pingable.
@@ -73,3 +95,4 @@
     ${countAfterRestart}=    Run    ${KUBECTL_CONFIG};kubectl get pods -n ${NAMESPACE} | grep Running | wc -l
     Should Be Equal As Strings    ${countAfterRestart}    ${countBforRestart}
     Log to console    Pod ${podName} restarted and sanity checks passed successfully
+