fix etcd data check - part III
- delete onu etcd data in suite setup to ensure clean etcd data
- validate etcd in both teardown, test as well suite with Wait Until Keyword Succeeds
- add a flag to decide etcd check is executed in test or suite teardown
- some small further improvements

Change-Id: If323a0ce85e46fda46ed5aaa229788260df27c83
diff --git a/tests/openonu-go-adapter/Voltha_ONUReconcileTests.robot b/tests/openonu-go-adapter/Voltha_ONUReconcileTests.robot
index 00860fc..8aa9ccb 100755
--- a/tests/openonu-go-adapter/Voltha_ONUReconcileTests.robot
+++ b/tests/openonu-go-adapter/Voltha_ONUReconcileTests.robot
@@ -68,6 +68,9 @@
 # if True (hard) kill will be used to restart onu adapter, else (soft) restart mechanism of k8s will be used
 # example: -v usekill2restart:True
 ${usekill2restart}    False
+# if True etcd check will be executed in test case teardown, if False etcd check will be executed in suite teardown
+# example: -v etcdcheckintestteardown:False
+${etcdcheckintestteardown}    True
 ${data_dir}    ../data
 ${suppressaddsubscriber}    True
 
@@ -169,6 +172,8 @@
     Set Suite Variable  ${onos_ssh_connection}
     # delete etcd MIB Template Data
     Delete MIB Template Data
+    # delete etcd onu data
+    Delete ONU Go Adapter ETCD Data    validate=True
 
 
 Teardown Suite
@@ -180,7 +185,8 @@
     Run Keyword If    ${pausebeforecleanup}    Log    Teardown will be continued...    console=yes
     Run Keyword If    ${teardown_device}    Delete All Devices and Verify
     Run Keyword If    ${usekill2restart}    Restart Pod    ${namespace}    open-onu
-    Validate Onu Data In Etcd    0    without_pm_data=False
+    Run Keyword Unless    ${etcdcheckintestteardown}    Wait Until Keyword Succeeds    ${timeout}    1s
+    ...    Validate Onu Data In Etcd    0    without_pm_data=False
     Wait for Ports in ONOS for all OLTs      ${onos_ssh_connection}  0   BBSM    ${timeout}
     Close All ONOS SSH Connections
 
@@ -217,11 +223,15 @@
 
 Teardown Test
     [Documentation]    Post-test Teardown
+    Run Keyword If    ${pausebeforecleanup}    Import Library    Dialogs
+    Run Keyword If    ${pausebeforecleanup}    Pause Execution    Press OK to continue with clean up!
+    Run Keyword If    ${pausebeforecleanup}    Log    Teardown will be continued...    console=yes
     Run Keyword If    ${teardown_device}    Delete All Devices and Verify
     # delete etcd MIB Template Data
     Delete MIB Template Data
     # check etcd data are empty
-    Validate Onu Data In Etcd    0    without_pm_data=False
+    Run Keyword If    ${etcdcheckintestteardown}    Wait Until Keyword Succeeds    ${timeout}    1s
+    ...    Validate Onu Data In Etcd    0    without_pm_data=False
     Sleep    5s
 
 Do Reconcile In Determined State