Fix clustering sanity suites 59/59459/10
authorVratko Polak <vrpolak@cisco.com>
Wed, 28 Jun 2017 07:37:59 +0000 (09:37 +0200)
committerVratko Polak <vrpolak@cisco.com>
Wed, 28 Jun 2017 07:37:59 +0000 (09:37 +0200)
The fix tolerates two behaviors,
as sometimes unsubscibing reports no notifications,
and other times it reports that data matches.

Change-Id: I6135962ac73fab57e72ea09b2b430f49fd644117
Signed-off-by: Vratko Polak <vrpolak@cisco.com>
csit/libraries/MdsalLowlevel.robot
csit/suites/controller/dom_data_broker/ddb-sanity-module-based.robot
csit/suites/controller/dom_data_broker/ddb-sanity-prefix-based.robot

index 03861c8dea80a741f50bb13493ae3259ae249a55..7af26d4c920f33f7ee52b1b309f4fa5932c7851b 100644 (file)
@@ -164,13 +164,17 @@ Subscribe_Dtcl
 
 Unsubscribe_Dtcl
     [Arguments]    ${member_index}
-    [Documentation]    Unsubscribe a listener from the data changes. Invoke unsubscribe-dtcl rpc.
+    [Documentation]    Invoke unsubscribe-dtcl rpc, return copy-matches field as boolean.
     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
     ${text} =    TemplatedRequests.Post_As_Xml_Templated    ${UNSUBSCRIBE_DTCL_DIR}    session=${session}
-    ${xml} =    XML.Parse_Xml    ${text}
-    ${matches} =    XML.Get_Element_Text    ${xml}    xpath=copy-matches
-    ${matches} =    BuiltIn.Convert_To_Boolean    ${matches}
-    BuiltIn.Return_From_Keyword    ${matches}
+    BuiltIn.Run_Keyword_And_Return    MdsalLowLevel__Parse_Matches    ${text}
+
+Unsubscribe_Dtcl_No_Tx
+    [Arguments]    ${member_index}
+    [Documentation]    Unsubscribe a listener from the data changes. Expect success no notifications received. Return boolean status.
+    ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
+    ${text} =    TemplatedRequests.Post_As_Xml_Templated    ${UNSUBSCRIBE_DTCL_DIR}    session=${session}    additional_allowed_status_codes=${INTERNAL_SERVER_ERROR}
+    BuiltIn.Run_Keyword_And_Return    MdsalLowLevel__Parse_Maybe_No_Tx    ${text}
 
 Subscribe_Ddtl
     [Arguments]    ${member_index}
@@ -180,14 +184,37 @@ Subscribe_Ddtl
 
 Unsubscribe_Ddtl
     [Arguments]    ${member_index}
-    [Documentation]    Unsubscribe DOMDataTreeListener from listening to the data changes.
+    [Documentation]    Invoke unsubscribe-ddtl rpc, return copy-matches field as boolean.
     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
     ${text} =    TemplatedRequests.Post_As_Xml_Templated    ${UNSUBSCRIBE_DDTL_DIR}    session=${session}
+    BuiltIn.Run_Keyword_And_Return    MdsalLowLevel__Parse_Matches    ${text}
+
+Unsubscribe_Ddtl_No_Tx
+    [Arguments]    ${member_index}
+    [Documentation]    Unsubscribe a listener from the data changes. Expect success no notifications received. Return boolean status.
+    ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
+    ${text} =    TemplatedRequests.Post_As_Xml_Templated    ${UNSUBSCRIBE_DDTL_DIR}    session=${session}    additional_allowed_status_codes=${INTERNAL_SERVER_ERROR}
+    BuiltIn.Run_Keyword_And_Return    MdsalLowLevel__Parse_Maybe_No_Tx    ${text}
+
+MdsalLowLevel__Parse_Matches
+    [Arguments]    ${text}
+    [Documentation]    Interpret the \${text} as XML response to an unsubscribe call and return copy-matches as boolean.
     ${xml} =    XML.Parse_Xml    ${text}
     ${matches} =    XML.Get_Element_Text    ${xml}    xpath=copy-matches
     ${matches} =    BuiltIn.Convert_To_Boolean    ${matches}
     BuiltIn.Return_From_Keyword    ${matches}
 
+MdsalLowLevel__Parse_Maybe_No_Tx
+    [Arguments]    ${text}
+    [Documentation]    Attempt to parse the \${text} as successful unsubscribe. If that fails, extract the error message and expect no notifications.
+    ${status}    ${message} =    BuiltIn.Run_Keyword_And_Ignore_Error    MdsalLowLevel__Parse_Matches    ${text}
+    BuiltIn.Return_From_Keyword_If    "${status}" == "PASS"    ${message}
+    ${xml} =    XML.Parse_Xml    ${text}
+    ${message} =    XML.Get_Element_Text    ${xml}    xpath=error/error-message
+    ${status}    ${message} =    BuiltIn.Run_Keyword_And_Ignore_Error    BuiltIn.Should_Contain    ${message}    listener has not received
+    BuiltIn.Return_From_Keyword_If    "${status}" == "PASS"    ${TRUE}
+    [Return]    ${FALSE}
+
 Start_Publish_Notifications
     [Arguments]    ${member_index}    ${gid}    ${seconds}    ${notif_per_sec}
     [Documentation]    Start publishing notifications by invoking publish-notifications rpc.
index ebf7478c1f0709b8fe9fa48f5bf2f02865ddb917..327997b5c25ae91246f6763bc30fc615c026bcf1 100644 (file)
@@ -46,7 +46,7 @@ Subscribe_Listener_To_Leader
     ${leader}    ${follower_list} =    ClusterManagement.Get_Leader_And_Followers_For_Shard    shard_name=${SHARD_NAME}    shard_type=${SHARD_TYPE}    member_index_list=${all_indices}    verify_restconf=False
     MdsalLowlevel.Subscribe_Dtcl    ${leader}
     BuiltIn.Sleep    5s
-    ${copy_matches} =    MdsalLowlevel.Unsubscribe_Dtcl    ${leader}
+    ${copy_matches} =    MdsalLowlevel.Unsubscribe_Dtcl_No_Tx    ${leader}
     BuiltIn.Should_Be_True    ${copy_matches}
 
 Subscribe_Listener_To_Follower
@@ -56,7 +56,7 @@ Subscribe_Listener_To_Follower
     ${follower_idx} =    Collections.Get_From_List    ${follower_list}    ${0}
     MdsalLowlevel.Subscribe_Dtcl    ${follower_idx}
     BuiltIn.Sleep    5s
-    ${copy_matches} =    MdsalLowlevel.Unsubscribe_Dtcl    ${follower_idx}
+    ${copy_matches} =    MdsalLowlevel.Unsubscribe_Dtcl_No_Tx    ${follower_idx}
     BuiltIn.Should_Be_True    ${copy_matches}
 
 Make_Leader_Local
@@ -78,7 +78,7 @@ Remove_Leader_Shard_Replica_And_Add_It_Back
     ${all_indices} =    ClusterManagement.List_All_Indices
     ${old_leader}    ${follower_list} =    ClusterManagement.Get_Leader_And_Followers_For_Shard    shard_name=${shard_name}    shard_type=${shard_type}    member_index_list=${all_indices}    verify_restconf=False
     ClusterAdmin.Remove_Shard_Replica    ${old_leader}    ${shard_name}    member-${old_leader}    ${shard_type}
-    BuiltIn.Wait_Until_Keyword_Succeeds    60s    5s    DdbCommons.Verify_Shard_Replica_Removed    ${old_leader}    ${shard_name}    ${shard_type}
+    BuiltIn.Wait_Until_Keyword_Succeeds    60s    5s    DdbCommons.Verify_Shard_Replica_Not_Present    ${old_leader}    ${shard_name}    ${shard_type}
     ${actual_leader}    ${actual_follower_list} =    BuiltIn.Wait_Until_Keyword_Succeeds    60s    5s    ClusterManagement.Get_Leader_And_Followers_For_Shard    shard_name=${shard_name}
     ...    verify_restconf=False    shard_type=${shard_type}    member_index_list=${follower_list}
     BuiltIn.Should_Not_Be_Equal_As_Numbers    ${old_leader}    ${actual_leader}
@@ -94,7 +94,7 @@ Remove_Follower_Shard_Replica_And_Add_It_Back
     ${leader}    ${follower_list} =    ClusterManagement.Get_Leader_And_Followers_For_Shard    shard_name=${shard_name}    shard_type=${shard_type}    member_index_list=${all_indices}    verify_restconf=False
     ${follower1} =    Collections.Get_From_List    ${follower_list}    ${0}
     ClusterAdmin.Remove_Shard_Replica    ${follower1}    ${shard_name}    member-${follower1}    ${shard_type}
-    BuiltIn.Wait_Until_Keyword_Succeeds    60s    5s    DdbCommons.Verify_Shard_Replica_Removed    ${follower1}    ${shard_name}    ${shard_type}
+    BuiltIn.Wait_Until_Keyword_Succeeds    60s    5s    DdbCommons.Verify_Shard_Replica_Not_Present    ${follower1}    ${shard_name}    ${shard_type}
     ${new_indices_list} =    ClusterManagement.List_Indices_Minus_Member    ${follower1}
     ClusterManagement.Verify_Shard_Leader_Elected    ${shard_name}    ${shard_type}    ${False}    ${leader}    member_index_list=${new_indices_list}
     BuiltIn.Wait_Until_Keyword_Succeeds    60s    5s    ClusterAdmin.Add_Shard_Replica    ${follower1}    ${shard_name}    ${shard_type}
index f27dc79000e9053e7016b1839fe41b8a5ae1ccba..bd563a09cc6aa7b601c6c350804d075f5b50f03d 100644 (file)
@@ -48,7 +48,7 @@ Subscribe_Listener_To_Leader
     ${leader}    ${follower_list} =    ClusterManagement.Get_Leader_And_Followers_For_Shard    shard_name=${SHARD_NAME}    shard_type=${SHARD_TYPE}    member_index_list=${all_indices}    verify_restconf=False
     MdsalLowlevel.Subscribe_Ddtl    ${leader}
     BuiltIn.Sleep    5s
-    ${copy_matches} =    MdsalLowlevel.Unsubscribe_Ddtl    ${leader}
+    ${copy_matches} =    MdsalLowlevel.Unsubscribe_Ddtl_No_Tx    ${leader}
     BuiltIn.Should_Be_True    ${copy_matches}
 
 Subscribe_Listener_To_Follower
@@ -58,7 +58,7 @@ Subscribe_Listener_To_Follower
     ${follower_idx} =    Collections.Get_From_List    ${follower_list}    ${0}
     MdsalLowlevel.Subscribe_Ddtl    ${follower_idx}
     BuiltIn.Sleep    5s
-    ${copy_matches} =    MdsalLowlevel.Unsubscribe_Ddtl    ${follower_idx}
+    ${copy_matches} =    MdsalLowlevel.Unsubscribe_Ddtl_No_Tx    ${follower_idx}
     BuiltIn.Should_Be_True    ${copy_matches}
 
 Become_Prefix_Leader
@@ -80,7 +80,7 @@ Remove_Leader_Prefix_Shard_Replica_And_Add_It_Back
     ${all_indices} =    ClusterManagement.List_All_Indices
     ${old_leader}    ${follower_list} =    ClusterManagement.Get_Leader_And_Followers_For_Shard    shard_name=${shard_name}!!    shard_type=${shard_type}    member_index_list=${all_indices}    verify_restconf=False
     ClusterAdmin.Remove_Prefix_Shard_Replica    ${old_leader}    ${shard_name}    member-${old_leader}    ${shard_type}
-    BuiltIn.Wait_Until_Keyword_Succeeds    60s    5s    Verify_Shard_Replica_Removed    ${old_leader}    ${shard_name}!!    ${shard_type}
+    BuiltIn.Wait_Until_Keyword_Succeeds    60s    5s    Verify_Shard_Replica_Not_Present    ${old_leader}    ${shard_name}!!    ${shard_type}
     ${actual_leader}    ${actual_follower_list} =    BuiltIn.Wait_Until_Keyword_Succeeds    60s    5s    ClusterManagement.Get_Leader_And_Followers_For_Shard    shard_name=${shard_name}!!
     ...    verify_restconf=False    shard_type=${shard_type}    member_index_list=${follower_list}
     BuiltIn.Should_Not_Be_Equal_As_Numbers    ${old_leader}    ${actual_leader}
@@ -96,7 +96,7 @@ Remove_Follower_Prefix_Shard_Replica_And_Add_It_Back
     ${leader}    ${follower_list} =    ClusterManagement.Get_Leader_And_Followers_For_Shard    shard_name=${shard_name}!!    shard_type=${shard_type}    member_index_list=${all_indices}    verify_restconf=False
     ${follower1} =    Collections.Get_From_List    ${follower_list}    ${0}
     ClusterAdmin.Remove_Prefix_Shard_Replica    ${follower1}    ${shard_name}    member-${follower1}    ${shard_type}
-    BuiltIn.Wait_Until_Keyword_Succeeds    60s    5s    DdbCommons.Verify_Shard_Replica_Removed    ${follower1}    ${shard_name}!!    ${shard_type}
+    BuiltIn.Wait_Until_Keyword_Succeeds    60s    5s    DdbCommons.Verify_Shard_Replica_Not_Present    ${follower1}    ${shard_name}!!    ${shard_type}
     ${new_indices_list} =    ClusterManagement.List_Indices_Minus_Member    ${follower1}
     ClusterManagement.Verify_Shard_Leader_Elected    ${shard_name}!!    ${shard_type}    ${False}    ${leader}    member_index_list=${new_indices_list}
     BuiltIn.Wait_Until_Keyword_Succeeds    60s    5s    ClusterAdmin.Add_Prefix_Shard_Replica    ${follower1}    ${shard_name}    ${shard_type}