[VOL-4237] Keep log files unless  is set to false

Change-Id: I2d11554b49c12d13c354f0c5f883962e4d8f10bc
diff --git a/libraries/utils.robot b/libraries/utils.robot
index bd03aa3..d1cc9be 100755
--- a/libraries/utils.robot
+++ b/libraries/utils.robot
@@ -1109,12 +1109,15 @@
 
 Stop Logging
     [Arguments]    ${label}
-    [Documentation]    End logging for test; remove logfile if test passed
+    [Documentation]    End logging for test; remove logfile if test passed and ${logging} is set to False
     Run    sync
     Run Keyword If    ${kail_process}    Terminate Process    ${kail_process}
     ${test_logfile}=    Run Keyword If    "${container_log_dir}" != "${None}"
     ...    Join Path    ${container_log_dir}    ${label}-combined.log
-    Run Keyword If Test Passed    Run Keyword If    "${test_logfile}" != "${None}"    Remove File    ${test_logfile}
+    Run Keyword If Test Passed
+    ...    Run Keyword If    "${logging}" == "False"
+    ...    Run Keyword If    "${test_logfile}" != "${None}"
+    ...    Remove File    ${test_logfile}
     Run Keyword If    ${has_dataplane}    Echo Message to OLT Logs     END ${label}
 
 Clean Up Linux
diff --git a/tests/dt-workflow/Voltha_DT_MultiOLT_Tests.robot b/tests/dt-workflow/Voltha_DT_MultiOLT_Tests.robot
index d1c1593..91af1c9 100644
--- a/tests/dt-workflow/Voltha_DT_MultiOLT_Tests.robot
+++ b/tests/dt-workflow/Voltha_DT_MultiOLT_Tests.robot
@@ -54,6 +54,10 @@
 # Per-test logging on failure is turned off by default; set this variable to enable
 ${container_log_dir}    ${None}
 
+# logging flag to enable Collect Logs, can be passed via the command line too
+# example: -v logging:False
+${logging}    True
+
 *** Test Cases ***
 Verify OLT after Rebooting Physically for DT - Multiple OLT
     [Documentation]    Test the physical reboot of the OLT
diff --git a/tests/functional/K8S_SystemTest.robot b/tests/functional/K8S_SystemTest.robot
index 2fd906b..9bdcc85 100644
--- a/tests/functional/K8S_SystemTest.robot
+++ b/tests/functional/K8S_SystemTest.robot
@@ -43,6 +43,10 @@
 # Per-test logging on failure is turned off by default; set this variable to enable
 ${container_log_dir}    ${None}
 
+# logging flag to enable Collect Logs, can be passed via the command line too
+# example: -v logging:False
+${logging}    True
+
 *** Test Cases ***
 ETCD Scale Test
     [Documentation]    Perform the sanity test if some ETCD endpoints crash
diff --git a/tests/functional/Voltha_ErrorScenarios.robot b/tests/functional/Voltha_ErrorScenarios.robot
index d41a7d6..be8bae1 100755
--- a/tests/functional/Voltha_ErrorScenarios.robot
+++ b/tests/functional/Voltha_ErrorScenarios.robot
@@ -55,6 +55,10 @@
 # Per-test logging on failure is turned off by default; set this variable to enable
 ${container_log_dir}    ${None}
 
+# logging flag to enable Collect Logs, can be passed via the command line too
+# example: -v logging:False
+${logging}    True
+
 *** Test Cases ***
 Adding the same OLT before and after enabling the device
     [Documentation]    Create OLT, Create the same OLT again and Check for the Error message
diff --git a/tests/functional/Voltha_FailureScenarios.robot b/tests/functional/Voltha_FailureScenarios.robot
index e7a91ad..d7e35ae 100755
--- a/tests/functional/Voltha_FailureScenarios.robot
+++ b/tests/functional/Voltha_FailureScenarios.robot
@@ -57,6 +57,10 @@
 # Per-test logging on failure is turned off by default; set this variable to enable
 ${container_log_dir}    ${None}
 
+# logging flag to enable Collect Logs, can be passed via the command line too
+# example: -v logging:False
+${logging}    True
+
 *** Test Cases ***
 Verify ONU after rebooting physically
     [Documentation]    Test the ONU functionality by physically turning on/off ONU.
diff --git a/tests/functional/Voltha_FailureScenarios2.robot b/tests/functional/Voltha_FailureScenarios2.robot
index 137fc9b..cc9cfbe 100755
--- a/tests/functional/Voltha_FailureScenarios2.robot
+++ b/tests/functional/Voltha_FailureScenarios2.robot
@@ -55,6 +55,10 @@
 # Per-test logging on failure is turned off by default; set this variable to enable
 ${container_log_dir}    ${None}
 
+# logging flag to enable Collect Logs, can be passed via the command line too
+# example: -v logging:False
+${logging}    True
+
 *** Test Cases ***
 Verify OLT Soft Reboot
     [Documentation]    Test soft reboot of the OLT using voltctl command
diff --git a/tests/functional/Voltha_MultiOLT_Tests.robot b/tests/functional/Voltha_MultiOLT_Tests.robot
index bfff1d3..c955ff8 100755
--- a/tests/functional/Voltha_MultiOLT_Tests.robot
+++ b/tests/functional/Voltha_MultiOLT_Tests.robot
@@ -55,6 +55,10 @@
 # Per-test logging on failure is turned off by default; set this variable to enable
 ${container_log_dir}    ${None}
 
+# logging flag to enable Collect Logs, can be passed via the command line too
+# example: -v logging:False
+${logging}    True
+
 *** Test Cases ***
 Verify OLT after rebooting physically - MultipleOLT
     [Documentation]    Test the physical reboot of the OLT
diff --git a/tests/functional/Voltha_ONOSHATests.robot b/tests/functional/Voltha_ONOSHATests.robot
index 809a945..234733c 100644
--- a/tests/functional/Voltha_ONOSHATests.robot
+++ b/tests/functional/Voltha_ONOSHATests.robot
@@ -57,6 +57,10 @@
 # Per-test logging on failure is turned off by default; set this variable to enable
 ${container_log_dir}    ${None}
 
+# logging flag to enable Collect Logs, can be passed via the command line too
+# example: -v logging:False
+${logging}    True
+
 *** Test Cases ***
 Verify restart ONOS instace master of device after subscriber is provisioned
     [Documentation]    Restat ONOS instance master of a given device and check that during restart and after the
diff --git a/tests/functional/Voltha_PODTests.robot b/tests/functional/Voltha_PODTests.robot
index 111220e..85c65cc 100755
--- a/tests/functional/Voltha_PODTests.robot
+++ b/tests/functional/Voltha_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}
 
+# logging flag to enable Collect Logs, can be passed via the command line too
+# example: -v logging:False
+${logging}    True
+
 *** Test Cases ***
 Reboot ONUs Physically
     [Documentation]   This test reboots ONUs physically before execution all the tests
diff --git a/tests/functional/Voltha_StartContainerPODTests.robot b/tests/functional/Voltha_StartContainerPODTests.robot
index fd6e0c4..e0c69c4 100755
--- a/tests/functional/Voltha_StartContainerPODTests.robot
+++ b/tests/functional/Voltha_StartContainerPODTests.robot
@@ -56,6 +56,11 @@
 ${kind_voltha_dir}    ~/kind-voltha
 # Per-test logging on failure is turned off by default; set this variable to enable
 ${container_log_dir}    ${None}
+
+# logging flag to enable Collect Logs, can be passed via the command line too
+# example: -v logging:False
+${logging}    True
+
 ${pausebeforesanity}    False
 ${onos_version}    ${EMPTY}
 
diff --git a/tests/software-upgrades/ONOS_AppsUpgrade.robot b/tests/software-upgrades/ONOS_AppsUpgrade.robot
index fbd04db..b4e3596 100755
--- a/tests/software-upgrades/ONOS_AppsUpgrade.robot
+++ b/tests/software-upgrades/ONOS_AppsUpgrade.robot
@@ -56,6 +56,10 @@
 # Per-test logging on failure is turned off by default; set this variable to enable
 ${container_log_dir}    ${None}
 
+# logging flag to enable Collect Logs, can be passed via the command line too
+# example: -v logging:False
+${logging}    True
+
 # ONOS Apps to Test for Software Upgrade need to be passed in the following variable in format:
 # <app-name>,<version>,<oar-url>*<app-name>,<version>,<oar-url>*
 # Example: org.opencord.aaa,2.3.0.SNAPSHOT,
diff --git a/tests/software-upgrades/Voltha_ComponentsUpgrade.robot b/tests/software-upgrades/Voltha_ComponentsUpgrade.robot
index c3ef8aa..8017348 100755
--- a/tests/software-upgrades/Voltha_ComponentsUpgrade.robot
+++ b/tests/software-upgrades/Voltha_ComponentsUpgrade.robot
@@ -55,6 +55,10 @@
 # Per-test logging on failure is turned off by default; set this variable to enable
 ${container_log_dir}    ${None}
 
+# logging flag to enable Collect Logs, can be passed via the command line too
+# example: -v logging:False
+${logging}    True
+
 ${suppressaddsubscriber}    True
 
 # Voltha Components to Test for Software Upgrade need to be passed in the following variable in format:
diff --git a/tests/tt-workflow/Voltha_TT_FailureScenarios.robot b/tests/tt-workflow/Voltha_TT_FailureScenarios.robot
index 0c87b30..c4a656e 100755
--- a/tests/tt-workflow/Voltha_TT_FailureScenarios.robot
+++ b/tests/tt-workflow/Voltha_TT_FailureScenarios.robot
@@ -55,6 +55,10 @@
 # Per-test logging on failure is turned off by default; set this variable to enable
 ${container_log_dir}    ${None}
 
+# logging flag to enable Collect Logs, can be passed via the command line too
+# example: -v logging:False
+${logging}    True
+
 ${suppressaddsubscriber}    True
 
 *** Test Cases ***
diff --git a/tests/tt-workflow/Voltha_TT_MultiTcontTests.robot b/tests/tt-workflow/Voltha_TT_MultiTcontTests.robot
index 4adfcc6..0bcd263 100755
--- a/tests/tt-workflow/Voltha_TT_MultiTcontTests.robot
+++ b/tests/tt-workflow/Voltha_TT_MultiTcontTests.robot
@@ -55,6 +55,10 @@
 # Per-test logging on failure is turned off by default; set this variable to enable
 ${container_log_dir}    ${None}
 
+# logging flag to enable Collect Logs, can be passed via the command line too
+# example: -v logging:False
+${logging}    True
+
 # For dataplane bandwidth testing
 ${lower_margin_pct}      90      # Allow 10% under the limit
 ${upper_margin_pct}      120      # Allow 20% under the limit
diff --git a/tests/tt-workflow/Voltha_TT_PODTests.robot b/tests/tt-workflow/Voltha_TT_PODTests.robot
index 2bb332a..6f4b76b 100755
--- a/tests/tt-workflow/Voltha_TT_PODTests.robot
+++ b/tests/tt-workflow/Voltha_TT_PODTests.robot
@@ -55,6 +55,10 @@
 # Per-test logging on failure is turned off by default; set this variable to enable
 ${container_log_dir}    ${None}
 
+# logging flag to enable Collect Logs, can be passed via the command line too
+# example: -v logging:False
+${logging}    True
+
 ${suppressaddsubscriber}    True
 
 *** Test Cases ***