[VOL-4072] Added BBSim Device Creation to mock load on Soak Pod for DT and Soak specific Pre-Test Setup in DT Failure Suite

Change-Id: I7cb6576431418299cab46d8fae0039236987dd53
diff --git a/libraries/utils.robot b/libraries/utils.robot
index 6e9b01d..bba08e1 100755
--- a/libraries/utils.robot
+++ b/libraries/utils.robot
@@ -547,8 +547,9 @@
 
 Setup
     [Documentation]    Pre-test Setup
+    [Arguments]    ${skip_empty_device_list_test}=False
     #test for empty device list
-    Test Empty Device List
+    Run Keyword If    '${skip_empty_device_list_test}'=='False'    Test Empty Device List
     # TBD: Need for this Sleep
     Run Keyword If    ${has_dataplane}    Sleep    180s
     # Create a list of olt ids (logical and device_id)
diff --git a/tests/dt-workflow/Voltha_DT_FailureScenarios.robot b/tests/dt-workflow/Voltha_DT_FailureScenarios.robot
index 7389f51..0aef9c0 100755
--- a/tests/dt-workflow/Voltha_DT_FailureScenarios.robot
+++ b/tests/dt-workflow/Voltha_DT_FailureScenarios.robot
@@ -55,6 +55,9 @@
 # Per-test logging on failure is turned off by default; set this variable to enable
 ${container_log_dir}    ${None}
 
+# Flag specific to Soak Jobs
+${SOAK_TEST}    False
+
 *** Test Cases ***
 Verify ONU after Rebooting Physically for DT
     [Documentation]    Test the ONU functionality by physically turning on/off ONU.
@@ -235,7 +238,7 @@
     ...    simulate a POD crash. The test then scales the rw-core back to a single instance
     ...    and configures ONOS for access. The test succeeds if the device is able to
     ...    complete the DHCP sequence.
-    [Tags]    functionalDt    olt-adapter-restart-Dt
+    [Tags]    functionalDt    olt-adapter-restart-Dt    soak
     [Setup]    Start Logging    OltAdapterRestart-Dt
     #...        AND             Clear All Devices Then Create New Device
     [Teardown]   Run Keywords    Collect Logs
@@ -299,7 +302,7 @@
 Verify restart ofagent container after subscriber is provisioned for DT
     [Documentation]    Restart ofagent container after VOLTHA is operational.
     ...    Prerequisite : ONUs are authenticated and pingable.
-    [Tags]    functionalDt   ofagentRestart-Dt
+    [Tags]    functionalDt   ofagentRestart-Dt    soak
     [Setup]    Start Logging    ofagentRestart-Dt
     [Teardown]    Run Keywords    Collect Logs
     ...           AND             Stop Logging    ofagentRestart-Dt
@@ -362,7 +365,7 @@
     ...    simulate a POD crash. The test then scales the rw-core back to a single instance
     ...    and configures ONOS for access. The test succeeds if the device is able to
     ...    complete the DHCP sequence.
-    [Tags]    functionalDt    rwcore-restart-Dt
+    [Tags]    functionalDt    rwcore-restart-Dt    soak
     [Setup]    Run Keywords    Start Logging    RwCoreFailAndRestart-Dt
     ...        AND             Clear All Devices Then Create New Device
     [Teardown]   Run Keywords    Collect Logs
@@ -535,12 +538,34 @@
     ...    ${List_ONU_Serial}    ${onu_flows}
 
 *** Keywords ***
+Setup Soak
+    [Documentation]    Pre-test Setup for Soak Job
+    ${olt_ids}    Create List
+    FOR    ${I}    IN RANGE    0    ${num_olts}
+        ${olt_serial_number}=    Set Variable    ${list_olts}[${I}][sn]
+        ${olt_device_id}=    Get Device ID From SN    ${olt_serial_number}
+        ${logical_id}=    Get Logical Device ID From SN    ${olt_serial_number}
+        ${of_id}=    Wait Until Keyword Succeeds    ${timeout}    15s    Validate OLT Device in ONOS
+        ...    ${olt_serial_number}
+        ${nni_port}=    Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    2s
+        ...    Get NNI Port in ONOS    ${of_id}
+        Set Global Variable    ${nni_port}
+        ${olt}    Create Dictionary    device_id    ${olt_device_id}    logical_id    ${logical_id}
+        ...    of_id    ${of_id}    sn    ${olt_serial_number}
+        Append To List    ${olt_ids}    ${olt}
+    END
+    Set Global Variable    ${olt_ids}
+
 Setup Suite
     [Documentation]    Set up the test suite
     Common Test Suite Setup
     #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}
+    # Run Pre-test Setup for Soak Job
+    # Note: As soak requirement, it expects that the devices under test are already created and enabled
+    Run Keyword If    '${SOAK_TEST}'=='True'    Setup Soak
+
 
 Clear All Devices Then Create New Device
     [Documentation]    Remove any devices from VOLTHA and ONOS
diff --git a/tests/dt-workflow/Voltha_DT_PODTests.robot b/tests/dt-workflow/Voltha_DT_PODTests.robot
index bdb8f38..ea8ac82 100644
--- a/tests/dt-workflow/Voltha_DT_PODTests.robot
+++ b/tests/dt-workflow/Voltha_DT_PODTests.robot
@@ -63,6 +63,10 @@
 # Per-test logging on failure is turned off by default; set this variable to enable
 ${container_log_dir}    ${None}
 
+# Flag specific to Soak Jobs
+${SOAK_TEST}    False
+${bbsim_port}    50060
+
 *** Test Cases ***
 Reboot DT ONUs Physically
     [Documentation]   This test reboots ONUs physically before execution all the tests
@@ -81,6 +85,32 @@
         Enable Switch Outlet    ${src['power_switch_port']}
     END
 
+Create Soak BBSim Device
+    [Documentation]    This creates and enables the BBSim device as required by the soak testing
+    ...    The BBSim OLT and ONUs created as part of this test are not part of active testing
+    ...    but only to mock the load on Soak POD.
+    [Tags]    soak
+    [Setup]    Start Logging    soakPodCreateBBSimLoad
+    [Teardown]    Run Keywords    Collect Logs
+    ...           AND             Stop Logging    soakPodCreateBBSimLoad
+    ${num_bbsim}    Get Length    ${bbsim}
+    FOR    ${I}    IN RANGE    0    ${num_bbsim}
+        ${ip}    Evaluate    ${bbsim}[${I}].get("ip")
+        ${serial_number}    Evaluate    ${bbsim}[${I}].get("serial")
+        ${bbsim_olt_device_id}=    Create Device    ${ip}    ${bbsim_port}
+        Log    ${bbsim_olt_device_id}
+        Wait Until Keyword Succeeds    ${timeout}    5s
+        ...    Validate OLT Device    PREPROVISIONED    UNKNOWN    UNKNOWN    ${bbsim_olt_device_id}
+        Enable Device    ${bbsim_olt_device_id}
+        Run Keyword And Continue On Failure    Wait Until Keyword Succeeds    ${timeout}    5s
+        ...    Validate OLT Device    ENABLED    ACTIVE    REACHABLE    ${serial_number}
+        ${olt_of_id}=    Wait Until Keyword Succeeds    ${timeout}    15s    Validate OLT Device in ONOS
+        ...    ${serial_number}
+        Log    ${olt_of_id}
+    END
+    # Extra sleep time for ONUs to come up Active
+    Sleep    30s
+
 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
@@ -88,10 +118,10 @@
     ...    should reach the NNI port on the OLT with the expected double tagged vlan ids
     ...    Inner vlans from the RG should not change
     [Tags]    sanityDt   soak
-    [Setup]    Run Keywords    Start Logging    SanityTestDt
-    ...        AND             Setup
+    [Setup]    Start Logging    SanityTestDt
     [Teardown]    Run Keywords    Collect Logs
     ...           AND             Stop Logging    SanityTestDt
+    Setup    ${SOAK_TEST}
     Run Keyword If    ${has_dataplane}    Clean Up Linux
     Wait Until Keyword Succeeds    ${timeout}    2s    Perform Sanity Test DT