Add reset_globals flag 51/56651/3
authorPeter Gubka <pgubka@cisco.com>
Sun, 7 May 2017 23:51:38 +0000 (01:51 +0200)
committerVratko Polák <vrpolak@cisco.com>
Mon, 8 May 2017 11:31:08 +0000 (11:31 +0000)
The potential problem is that if the test fail before
wait_for_transactions is called, the response may remain
in the queue and is used in the next test case when the
method is called.

Change-Id: Iab54321e64369844211f071fcb6c8502cdedc078
Signed-off-by: Peter Gubka <pgubka@cisco.com>
csit/libraries/MdsalLowlevelPy.py
csit/libraries/controller/DdbCommons.robot

index eda8654df9463e2eaf283dde4b515f81a4bf8733..7d8ccefecbbab0912e126102812943c101b1cdd6 100644 (file)
@@ -64,7 +64,8 @@ def _initiate_rpcs(host_list, prefix_list, url_templ, data_templ, subst_dict):
     _globals.update({'threads': lthreads, 'result_queue': resqueue})
 
 
-def start_write_transactions_on_nodes(host_list, prefix_list, id_prefix, duration, rate, chained_flag=False):
+def start_write_transactions_on_nodes(host_list, prefix_list, id_prefix, duration, rate, chained_flag=False,
+                                      reset_globals=True):
     """Invoke write-transactions rpc on given nodes.
 
     :param host_list: list of ip address of odl nodes
@@ -79,7 +80,12 @@ def start_write_transactions_on_nodes(host_list, prefix_list, id_prefix, duratio
     :type rate: int
     :param chained_flag: specify chained vs. simple transactions
     :type chained_flag: bool
+    :param reset_globals: reset global variable dict
+    :type reset_globals: bool
     """
+    if reset_globals:
+        _globals.clear()
+
     logger.info(
         "Input parameters: host_list:{}, prefix_list:{}, id_prefix:{}, duration:{}, rate:{}, chained_flag:{}".format(
             host_list, prefix_list, id_prefix, duration, rate, chained_flag))
@@ -95,7 +101,7 @@ def start_write_transactions_on_nodes(host_list, prefix_list, id_prefix, duratio
 
 
 def start_produce_transactions_on_nodes(host_list, prefix_list, id_prefix,
-                                        duration, rate, isolated_transactions_flag=True):
+                                        duration, rate, isolated_transactions_flag=True, reset_globals=True):
     """Invoke produce-transactions rpcs on given nodes.
 
     :param host_list: list of ip address of odl nodes
@@ -110,7 +116,12 @@ def start_produce_transactions_on_nodes(host_list, prefix_list, id_prefix,
     :type rate: int
     :param isolated_transactions_flag: isolated transactions flag
     :type isolated_transactions_flag: bool
+    :param reset_globals: reset global variable dict
+    :type reset_globals: bool
     """
+    if reset_globals:
+        _globals.clear()
+
     msg = "host_list:{}, prefix_list:{} ,id_prefix:{}, duration:{}, rate:{}, isolated_transactions:{}".format(
             host_list, prefix_list, id_prefix, duration, rate, isolated_transactions_flag)
     msg = "Input parameters: " + msg
index b6c99fa6cc49cd62aff1f2e16d28c46b314e1a41..a119b41fbec5dfb87f4c398c8b6d8fe8f2e3f9d3 100644 (file)
@@ -192,6 +192,7 @@ Module_Leader_Isolation_Heal_Default
     ${restart_producer_node_ip} =    ClusterManagement.Resolve_IP_Address_For_Member    ${isolated_node}
     ${restart_producer_node_ip_as_list}    BuiltIn.Create_List    ${restart_producer_node_ip}
     MdsalLowlevelPy.Start_Write_Transactions_On_Nodes    ${restart_producer_node_ip_as_list}    ${restart_producer_node_idx_as_list}    ${ID_PREFIX}    ${time_to_finish}    ${TRANSACTION_RATE_1K}    chained_flag=${CHAINED_TX}
+    ...    reset_globals=${False}
     ${resp_list} =    MdsalLowlevelPy.Wait_For_Transactions
     : FOR    ${resp}    IN    @{resp_list}
     \    TemplatedRequests.Check_Status_Code    ${resp}
@@ -206,7 +207,7 @@ Prefix_Leader_Isolation_Heal_Default
     ${restart_producer_node_idx_as_list}    BuiltIn.Create_List    ${isolated_node}
     ${restart_producer_node_ip} =    ClusterManagement.Resolve_IP_Address_For_Member    ${isolated_node}
     ${restart_producer_node_ip_as_list}    BuiltIn.Create_List    ${restart_producer_node_ip}
-    MdsalLowlevelPy.Start_Produce_Transactions_On_Nodes    ${restart_producer_node_ip_as_list}    ${restart_producer_node_idx_as_list}    ${ID_PREFIX}    ${time_to_finish}    ${TRANSACTION_RATE_1K}
+    MdsalLowlevelPy.Start_Produce_Transactions_On_Nodes    ${restart_producer_node_ip_as_list}    ${restart_producer_node_idx_as_list}    ${ID_PREFIX}    ${time_to_finish}    ${TRANSACTION_RATE_1K}    reset_globals=${False}
     ${resp_list} =    MdsalLowlevelPy.Wait_For_Transactions
     : FOR    ${resp}    IN    @{resp_list}
     \    TemplatedRequests.Check_Status_Code    ${resp}