Edit verification that two hex messages are equal 46/76446/4
authorDasa Simkova <dasa.simkova@pantheon.tech>
Tue, 25 Sep 2018 15:10:57 +0000 (17:10 +0200)
committerTomas Markovic <tomas.markovic@pantheon.tech>
Wed, 26 Sep 2018 13:18:13 +0000 (13:18 +0000)
- this verification considers two hex messages equal
  even if their arguments are misplaced. It compares
  the length of two hex messages and then converts each
  argument into integer and sums these arguments up for
  each hex message and compares the results.

Change-Id: Ia85ef0ab49e5ddf7939a9a7583715c414552c29d
Signed-off-by: Dasa Simkova <dasa.simkova@pantheon.tech>
csit/libraries/BgpOperations.robot
csit/suites/bgpcep/bgpfunct/030_bgp_functional_evpn.robot

index 45342ff1100bcb2baadac62e46b838a9834eaf2e..c16b4bb57776c4aa2484d6d54157ba9fee4d0006 100644 (file)
@@ -315,11 +315,11 @@ Odl_To_Play_Template
     BuiltIn.Run_Keyword_If    '${remove}' == 'True'    BgpRpcClient.play_clean
     TemplatedRequests.Post_As_Xml_Templated    ${dir}/${totest}/app    mapping=${APP_PEER}    session=${CONFIG_SESSION}
     ${update}    BuiltIn.Wait_Until_Keyword_Succeeds    3x    2s    Get_Update_Message
-    BuiltIn.Should_Be_Equal_As_Strings    ${update}    ${announce_hex}
+    Verify_Two_Hex_Messages_Are_Equal    ${update}    ${announce_hex}
     BgpRpcClient.play_clean
     Remove_Configured_Routes    ${totest}    ${dir}
     ${update}    BuiltIn.Wait_Until_Keyword_Succeeds    3x    2s    Get_Update_Message
-    BuiltIn.Should_Be_Equal_As_Strings    ${update}    ${withdraw_hex}
+    Verify_Two_Hex_Messages_Are_Equal    ${update}    ${withdraw_hex}
     [Teardown]    Remove_Configured_Routes    ${totest}    ${dir}
 
 Play_To_Odl_Template
@@ -357,3 +357,27 @@ Remove_Configured_Routes
     [Arguments]    ${totest}    ${dir}
     [Documentation]    Removes the route if present.
     BuiltIn.Run_Keyword_And_Ignore_Error    TemplatedRequests.Delete_Templated    ${dir}/${totest}/app    mapping=${APP_PEER}    session=${CONFIG_SESSION}
+
+Verify_Two_Hex_Messages_Are_Equal
+    [Arguments]    ${hex_1}    ${hex_2}
+    [Documentation]    Verifies two hex messages are equal even in case, their arguments are misplaced.
+    ...    Compares length of the hex messages and sums hex messages arguments as integers and compares results.
+    ${len_1}=    BuiltIn.Get_Length    ${hex_1}
+    ${len_2}=    BuiltIn.Get_Length    ${hex_2}
+    BuiltIn.Should_Be_Equal    ${len_1}    ${len_2}
+    ${sum_1}=    Sum_Hex_Message_Arguments_To_Integer    ${hex_1}
+    ${sum_2}=    Sum_Hex_Message_Arguments_To_Integer    ${hex_2}
+    BuiltIn.Should_Be_Equal    ${sum_1}    ${sum_2}
+
+Sum_Hex_Message_Arguments_To_Integer
+    [Arguments]    ${hex_string}
+    [Documentation]    Converts hex message arguments to integers and sums them up and returns the sum.
+    ${partial_results}=    BuiltIn.Create_List
+    ${string}=    String.Get_Substring    ${hex_string}    32
+    @{list}=    String.Get_Regexp_Matches    ${string}    [a-f0-9][a-f0-9]
+    : FOR    ${i}    IN    @{list}
+    \    ${item_int}=    BuiltIn.Convert_To_Integer    ${i}    16
+    \    Collections.Append_To_List    ${partial_results}    ${item_int}
+    \    BuiltIn.Log    ${partial_results}
+    ${final_sum}=    BuiltIn.Evaluate    sum(${partial_results})
+    [Return]    ${final_sum}
index a6cdefc20742d6f4baab305413cd44575fd5bb5c..159d21cbcbe44dce72862011684f40a8342b2977 100644 (file)
@@ -22,6 +22,7 @@ Library           SSHLibrary
 Library           String
 Library           ../../../libraries/BgpRpcClient.py    ${TOOLS_SYSTEM_IP}
 Resource          ../../../libraries/BGPcliKeywords.robot
+Resource          ../../../libraries/BgpOperations.robot
 Resource          ../../../libraries/BGPSpeaker.robot
 Resource          ../../../libraries/CompareStream.robot
 Resource          ../../../libraries/SetupUtils.robot
@@ -385,12 +386,12 @@ Odl_To_Play_Template
     BuiltIn.Log    ${resp.content}
     ${aupdate} =    BuiltIn.Wait_Until_Keyword_Succeeds    4x    2s    Get_Update_Content
     BuiltIn.Log    ${aupdate}
-    BuiltIn.Should_Be_Equal_As_Strings    ${aupdate}    ${announce_hex}
+    BgpOperations.Verify_Two_Hex_Messages_Are_Equal    ${aupdate}    ${announce_hex}
     BgpRpcClient.play_clean
     Remove_Configured_Routes
     ${wupdate} =    BuiltIn.Wait_Until_Keyword_Succeeds    4x    2s    Get_Update_Content
     BuiltIn.Log    ${wupdate}
-    BuiltIn.Should Be Equal As Strings    ${wupdate}    ${withdraw_hex}
+    BgpOperations.Verify_Two_Hex_Messages_Are_Equal    ${wupdate}    ${withdraw_hex}
     [Teardown]    Remove_Configured_Routes
 
 Play_To_Odl_Template