Rework DnbCommons.robot due to api change 97/53897/29
authorPeter Gubka <pgubka@cisco.com>
Mon, 27 Mar 2017 12:55:05 +0000 (14:55 +0200)
committerPeter Gubka <pgubka@cisco.com>
Mon, 3 Apr 2017 08:41:50 +0000 (10:41 +0200)
The blocking rpc publish-notifications was changed to non-blocking
start- and check-publish-notifications.

Change-Id: I199e0ee72ae7315e2e225cef548cd97d77fefbf3
Signed-off-by: Peter Gubka <pgubka@cisco.com>
csit/libraries/MdsalLowlevel.robot
csit/libraries/controller/DnbCommons.robot
csit/variables/mdsal/lowlevelrpc/check_publish_notifications/location.uri [new file with mode: 0644]
csit/variables/mdsal/lowlevelrpc/check_publish_notifications/post_data.xml [new file with mode: 0644]
csit/variables/mdsal/lowlevelrpc/publish_notifications/location.uri [deleted file]
csit/variables/mdsal/lowlevelrpc/start_publish_notifications/location.uri [new file with mode: 0644]
csit/variables/mdsal/lowlevelrpc/start_publish_notifications/post_data.xml [moved from csit/variables/mdsal/lowlevelrpc/publish_notifications/post_data.xml with 100% similarity]

index e1f22df3bc7d2162fe3472542b60f087583517e7..dcb82c50d42a347f3eee14fd26efee9448d9745b 100644 (file)
@@ -20,19 +20,20 @@ ${RPC_DIR}        ${CURDIR}/../variables/mdsal/lowlevelrpc
 ${ADD_SHARD_REPLICA_DIR}    ${RPC_DIR}/add_shard_replica
 ${BECOME_MODULE_LEADER_DIR}    ${RPC_DIR}/become_module_leader
 ${BECOME_PREFIX_LEADER_DIR}    ${RPC_DIR}/become_prefix_leader
+${CHECK_PUBLISH_NOTIFICATIONS_DIR}    ${RPC_DIR}/check_publish_notifications
 ${DECONFIGURE_ID_INTS_SHARD_DIR}    ${RPC_DIR}/deconfigure_id_ints_shard
 ${GET_CONSTANT_DIR}    ${RPC_DIR}/get_constant
 ${GET_CONTEXTED_CONSTANT_DIR}    ${RPC_DIR}/get_contexted_constant
 ${GET_SINGLETON_CONSTANT_DIR}    ${RPC_DIR}/get_singleton_constant
 ${IS_CLIENT_ABORTED_DIR}    ${RPC_DIR}/is_client_aborted
 ${PRODUCE_TRANSACTIONS_DIR}    ${RPC_DIR}/produce_transactions
-${PUBLISH_NOTIFICATIONS_DIR}    ${RPC_DIR}/publish_notifications
 ${REGISTER_BOUND_CONSTANT_DIR}    ${RPC_DIR}/register_bound_constant
 ${REGISTER_CONSTANT_DIR}    ${RPC_DIR}/register_constant
 ${REGISTER_DEFAULT_CONSTANT_DIR}    ${RPC_DIR}/register_default_constant
 ${REGISTER_FLAPPING_SINGLETON_DIR}    ${RPC_DIR}/register_flapping_singleton
 ${REGISTER_SINGLETON_CONSTANT_DIR}    ${RPC_DIR}/register_singleton_constant
 ${REMOVE_SHARD_REPLICA_DIR}    ${RPC_DIR}/remove_shard_replica
+${START_PUBLISH_NOTIFICATIONS_DIR}    ${RPC_DIR}/start_publish_notifications
 ${SUBSCRIBE_DDTL_DIR}    ${RPC_DIR}/subscribe_ddtl
 ${SUBSCRIBE_DTCL_DIR}    ${RPC_DIR}/subscribe_dtcl
 ${SUBSCRIBE_YNL_DIR}    ${RPC_DIR}/subscribe_ynl
@@ -204,13 +205,29 @@ Unsubscribe_Ddtl
     ${uri} =    TemplatedRequests.Resolve_Text_From_Template_Folder    folder=${UNSUBSCRIBE_DDTL_DIR}    base_name=location    extension=uri
     ${text} =    TemplatedRequests.Post_To_Uri    uri=${uri}    data=${EMPTY}    accept=${ACCEPT_JSON}    content_type=${HEADERS_YANG_JSON}    session=${session}
 
-Publish_Notifications
+Start_Publish_Notifications
     [Arguments]    ${member_index}    ${gid}    ${seconds}    ${notif_per_sec}
-    [Documentation]    Start publishing notifications by invoking publish-notifications rpc. This call is blocking
-    ...    and it returns when publishing is over. It suppose to take as long as ${seconds}.
+    [Documentation]    Start publishing notifications by invoking publish-notifications rpc.
     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
     &{mapping}    BuiltIn.Create_Dictionary    ID=${gid}    DURATION=${seconds}    RATE=${notif_per_sec}
-    TemplatedRequests.Post_As_Xml_Templated    ${PUBLISH_NOTIFICATIONS_DIR}    mapping=${mapping}    session=${session}
+    TemplatedRequests.Post_As_Xml_Templated    ${START_PUBLISH_NOTIFICATIONS_DIR}    mapping=${mapping}    session=${session}
+
+Check_Publish_Notifications
+    [Arguments]    ${member_index}    ${gid}
+    [Documentation]    Publishing notifications check by invoking check-publish-notifications rpc. Return publising process state details.
+    ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
+    &{mapping}    BuiltIn.Create_Dictionary    ID=${gid}
+    ${text} =    TemplatedRequests.Post_As_Xml_Templated    ${CHECK_PUBLISH_NOTIFICATIONS_DIR}    mapping=${mapping}    session=${session}
+    ${xml} =    XML.Parse_Xml    ${text}
+    ${active} =    XML.Get_Element_Text    ${xml}    xpath=active
+    ${active} =    BuiltIn.Convert_To_Boolean    ${active}
+    ${status}    ${publish_count}=    BuiltIn.Run_Keyword_And_Ignore_Error    XML.Get_Element_Text    ${xml}    xpath=publish-count
+    BuiltIn.Run_Keyword_If    """${status}""" == """FAIL""" and """${publish_count}""" != """No element matching 'publish-count' found."""    BuiltIn.Fail    ${publish_count}
+    ${publish_count}    BuiltIn.Set_Variable_If    """${status}""" == """FAIL"""    ${EMPTY}    ${publish_count}
+    ${status}    ${last_error}=    BuiltIn.Run_Keyword_And_Ignore_Error    XML.Get_Element_Text    ${xml}    xpath=last-error
+    BuiltIn.Run_Keyword_If    """${status}""" == """FAIL""" and """${last_error}""" != """No element matching 'last-error' found."""    BuiltIn.Fail    ${last_error}
+    ${last_error}    BuiltIn.Set_Variable_If    """${status}""" == """FAIL"""    ${EMPTY}    ${last_error}
+    BuiltIn.Return_From_Keyword    ${active}    ${publish_count}    ${last_error}
 
 Subscribe_Ynl
     [Arguments]    ${member_index}    ${gid}
index ddb4334df7873356f685eb245fe327fe27b4dfcc..e3de9e5b94b95c4cc02df6107710c0bef8049e73 100644 (file)
@@ -6,8 +6,10 @@ Documentation     DOMNotificationBroker testing: Common keywords
 ...               This program and the accompanying materials are made available under the
 ...               terms of the Eclipse Public License v1.0 which accompanies this distribution,
 ...               and is available at http://www.eclipse.org/legal/epl-v10.html
-Library           ${CURDIR}/../MdsalLowlevelPy.py
+Library           Collections
 Resource          ${CURDIR}/../MdsalLowlevel.robot
+Resource          ${CURDIR}/../ScalarClosures.robot
+Resource          ${CURDIR}/../WaitUtils.robot
 
 *** Variables ***
 ${DNB_PUBLISHER_SUBSCRIBER_PAIR_RATE}    ${5000}
@@ -22,12 +24,18 @@ Dom_Notification_Broker_Test_Templ
     ...    The test case itself firstly subscribe listeners, then run publishers and at the end unsubscribe listeners
     ...    and check achieved rates.
     BuiltIn.Log    Overall requested rate: ${total_notification_rate}, test duration: ${test_duration_in_seconds} seconds.
+    WaitUtils.WU_Setup
     ${count} =    BuiltIn.Set_variable    ${0}
     : FOR    ${suffix}    IN RANGE    ${DNB_PUBLISHER_SUBSCRIBER_PAIR_RATE}    ${total_notification_rate}+1    ${DNB_PUBLISHER_SUBSCRIBER_PAIR_RATE}
     \    ${count} =    BuiltIn.Evaluate    ${count}+1
     \    MdsalLowlevel.Subscribe_Ynl    ${DNB_TESTED_MEMBER_INDEX}    ${DNB_PUBLISHER_LISTENER_PREFIX}${count}
     ${count} =    BuiltIn.Convert_To_Integer    ${count}
-    MdsalLowlevelPy.Publish_Notifications    ${ODL_SYSTEM_${DNB_TESTED_MEMBER_INDEX}_IP}    ${DNB_PUBLISHER_LISTENER_PREFIX}    ${test_duration_in_seconds}    ${DNB_PUBLISHER_SUBSCRIBER_PAIR_RATE}    nrpairs=${count}
+    : FOR    ${index}    IN RANGE    1    ${count}+1
+    \    MdsalLowlevel.Start_Publish_Notifications    ${DNB_TESTED_MEMBER_INDEX}    ${DNB_PUBLISHER_LISTENER_PREFIX}${index}    ${test_duration_in_seconds}    ${DNB_PUBLISHER_SUBSCRIBER_PAIR_RATE}
+    ${getter} =    ScalarClosures.Closure_From_Keyword_And_Arguments    Get_Notifications_Active_Status    ${DNB_TESTED_MEMBER_INDEX}    ${count}
+    ${validator} =    ScalarClosures.Closure_From_Keyword_And_Arguments    Check_Notifications_Active_Status    data_holder
+    ${validation_timeout} =    BuiltIn.Evaluate    ${test_duration_in_seconds}+${60}
+    WaitUtils.Wait_For_Getter_Failure_Or_Stateless_Validator_Pass    timeout=${validation_timeout}    period=15s    getter=${getter}    stateless_validator=${validator}
     ${sum_local_number}    BuiltIn.Set_Variable    ${0}
     ${low_limit_pair_rate} =    BuiltIn.Evaluate    0.9*${DNB_PUBLISHER_SUBSCRIBER_PAIR_RATE}
     ${high_limit_pair_rate} =    BuiltIn.Evaluate    1.1*${DNB_PUBLISHER_SUBSCRIBER_PAIR_RATE}
@@ -46,3 +54,17 @@ Dom_Notification_Broker_Test_Templ
     ${high_limit_final_rate} =    BuiltIn.Evaluate    1.1*${total_notification_rate}
     BuiltIn.Should_Be_True    ${final_rate} > ${low_limit_final_rate}
     BuiltIn.Should_Be_True    ${final_rate} < ${high_limit_final_rate}
+
+Get_Notifications_Active_Status
+    [Arguments]    ${node_to_ask}    ${nr_pairs}
+    ${active_list} =    BuiltIn.Create_List
+    : FOR    ${index}    IN RANGE    1    ${nr_pairs}+1
+    \    ${active}    ${publ_count}    ${last_error}    MdsalLowlevel.Check_Publish_Notifications    ${node_to_ask}    ${DNB_PUBLISHER_LISTENER_PREFIX}${index}
+    \    Collections.Append_To_List    ${active_list}    ${active}
+    \    BuiltIn.Should_Be_Equal    ${EMPTY}    ${last_error}
+    BuiltIn.Return_From_Keyword    ${active_list}
+
+Check_Notifications_Active_Status
+    [Arguments]    ${active_list}
+    : FOR    ${active}    IN    @{active_list}
+    \    BuiltIn.Should_Be_Equal    ${False}    ${active}
diff --git a/csit/variables/mdsal/lowlevelrpc/check_publish_notifications/location.uri b/csit/variables/mdsal/lowlevelrpc/check_publish_notifications/location.uri
new file mode 100644 (file)
index 0000000..14a3526
--- /dev/null
@@ -0,0 +1 @@
+/restconf/operations/odl-mdsal-lowlevel-control:check-publish-notifications
diff --git a/csit/variables/mdsal/lowlevelrpc/check_publish_notifications/post_data.xml b/csit/variables/mdsal/lowlevelrpc/check_publish_notifications/post_data.xml
new file mode 100644 (file)
index 0000000..ec4e3f9
--- /dev/null
@@ -0,0 +1,4 @@
+<input xmlns="tag:opendaylight.org,2017:controller:yang:lowlevel:control">
+  <id>$ID</id>
+</input>
+
diff --git a/csit/variables/mdsal/lowlevelrpc/publish_notifications/location.uri b/csit/variables/mdsal/lowlevelrpc/publish_notifications/location.uri
deleted file mode 100644 (file)
index 6841fe9..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/restconf/operations/odl-mdsal-lowlevel-control:publish-notifications
\ No newline at end of file
diff --git a/csit/variables/mdsal/lowlevelrpc/start_publish_notifications/location.uri b/csit/variables/mdsal/lowlevelrpc/start_publish_notifications/location.uri
new file mode 100644 (file)
index 0000000..7c0fbb1
--- /dev/null
@@ -0,0 +1 @@
+/restconf/operations/odl-mdsal-lowlevel-control:start-publish-notifications