From 432e653b3aaa1ddd1bc4d1dd040b1e15ed51ec2a Mon Sep 17 00:00:00 2001 From: Jamo Luhrsen Date: Tue, 3 Mar 2020 12:20:42 -0800 Subject: [PATCH] Enable rfc8040 requests for notification suite also improves restconf lib to allow for rpc operations in addition to config and operational paths Change-Id: Ied029ef3f5d15b09aa54de7b2dd443633e567d57 Signed-off-by: Jamo Luhrsen --- csit/libraries/Restconf.robot | 22 +++++----- .../notifications/notifications_basic.robot | 41 +++++++++++-------- 2 files changed, 35 insertions(+), 28 deletions(-) diff --git a/csit/libraries/Restconf.robot b/csit/libraries/Restconf.robot index baed160b99..aec16a15b5 100644 --- a/csit/libraries/Restconf.robot +++ b/csit/libraries/Restconf.robot @@ -6,17 +6,18 @@ ${USE_RFC8040} = False *** Keywords *** Generate URI - [Arguments] ${identifier} ${datastore}=config @{node_value_list} + [Arguments] ${identifier} ${datastore_flag}=config @{node_value_list} [Documentation] Returns the proper URI to use depending on if RFC8040 is to be used or not. Variable input - ... error checking is done to ensure the ${USE_RFC8040} Flag is one of True or False and the ${datastore} variable - ... must be config or operational. @{node_value_list} is expected to be in the format of node=value. RFC8040 can + ... error checking is done to ensure the ${USE_RFC8040} Flag is one of True or False and the ${datastore_flag} variable + ... must be config, operational or rpc. @{node_value_list} is expected to be in the format of node=value. RFC8040 can ... use that as is with '=' delimiter, but older restconf URI will convert the '=' to a '/' - ${uri} = Run Keyword If "${USE_RFC8040}" == "True" Generate RFC8040 URI ${identifier} ${datastore} @{node_value_list} + ${uri} = Run Keyword If "${USE_RFC8040}" == "True" Generate RFC8040 URI ${identifier} ${datastore_flag} @{node_value_list} Return From Keyword If "${USE_RFC8040}" == "True" ${uri} Run Keyword If "${USE_RFC8040}" != "False" Fail Invalid Value for RFC8040 Flag: ${USE_RFC8040} - Run Keyword If "${datastore}"!="config" and "${datastore}"!="operational" Fail Invalid value for datastore: ${datastore} - ${uri} = Run Keyword If "${datastore}"=="config" Set Variable ${CONFIG_API}/${identifier} - ... ELSE Set Variable ${OPERATIONAL_API}/${identifier} + Run Keyword If "${datastore_flag}"!="config" and "${datastore_flag}"!="operational" and "${datastore_flag}"!="rpc" Fail Invalid value for datastore: ${datastore_flag} + ${uri} = Run Keyword If "${datastore_flag}"=="config" Set Variable ${CONFIG_API}/${identifier} + ... ELSE IF "${datastore_flag}"=="operational" Set Variable ${OPERATIONAL_API}/${identifier} + ... ELSE Set Variable ${OPERATIONS_API}/${identifier} ${node_value_path} = Set Variable ${EMPTY} FOR ${nv} IN @{node_value_list} ${nv} = String.Replace String ${nv} = / @@ -25,11 +26,12 @@ Generate URI [Return] ${uri}${node_value_path} Generate RFC8040 URI - [Arguments] ${identifier} ${datastore}=config @{node_value_list} + [Arguments] ${identifier} ${datastore_flag}=config @{node_value_list} ${node_value_path} = Set Variable ${EMPTY} FOR ${nv} IN @{node_value_list} ${node_value_path} = Set Variable ${node_value_path}/${nv} END - ${uri} = Run Keyword If "${datastore}" == "config" Set Variable rests/data/${identifier}${node_value_path}?content=config - ... ELSE Set Variable rests/data/${identifier}${node_value_path}?content=nonconfig + ${uri} = Run Keyword If "${datastore_flag}" == "config" Set Variable rests/data/${identifier}${node_value_path}?content=config + ... ELSE IF "${datastore_flag}"=="operational" Set Variable rests/data/${identifier}${node_value_path}?content=nonconfig + ... ELSE Set Variable rests/operations/${identifier} [Return] ${uri} diff --git a/csit/suites/netconf/notifications/notifications_basic.robot b/csit/suites/netconf/notifications/notifications_basic.robot index 155bfce1f9..be32bf32cf 100644 --- a/csit/suites/netconf/notifications/notifications_basic.robot +++ b/csit/suites/netconf/notifications/notifications_basic.robot @@ -28,13 +28,15 @@ Suite Setup Setup_Everything Suite Teardown Teardown_Everything Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing Test Teardown SetupUtils.Teardown_Test_Show_Bugs_And_Start_Fast_Failing_If_Test_Failed +Library Collections Library OperatingSystem -Library SSHLibrary timeout=10s Library RequestsLibrary -Library Collections -Variables ${CURDIR}/../../../variables/Variables.py +Library SSHLibrary timeout=10s +Library XML +Resource ${CURDIR}/../../../variables/Variables.robot Resource ${CURDIR}/../../../libraries/FailFast.robot Resource ${CURDIR}/../../../libraries/KarafKeywords.robot +Resource ${CURDIR}/../../../libraries/Restconf.robot Resource ${CURDIR}/../../../libraries/SetupUtils.robot Resource ${CURDIR}/../../../libraries/SSHKeywords.robot Resource ${CURDIR}/../../../libraries/TemplatedRequests.robot @@ -44,8 +46,9 @@ Resource ${CURDIR}/../../../libraries/WaitForFailure.robot ${TEMPLATE_FOLDER} ${CURDIR}/templates ${RESTCONF_SUBSCRIBE_URI} restconf/operations/sal-remote:create-data-change-event-subscription ${RESTCONF_SUBSCRIBE_DATA} subscribe.xml -${RESTCONF_GET_SUBSCRIPTION_URI} restconf/streams/stream/data-change-event-subscription/opendaylight-inventory:nodes/datastore=CONFIGURATION/scope=BASE -${RESTCONF_CONFIG_URI} restconf/config +${NODES_STREAM_PATH} opendaylight-inventory:nodes/datastore=CONFIGURATION/scope=BASE +${RESTCONF_GET_SUBSCRIPTION_URI} restconf/streams/stream/data-change-event-subscription/${NODES_STREAM_PATH} +${RFC8040_GET_SUBSCRIPTION_URI} rests/data/ietf-restconf-monitoring:restconf-state/streams/stream/data-change-event-subscription/${NODES_STREAM_PATH} ${RESTCONF_CONFIG_DATA} config_data.xml ${RECEIVER_LOG_FILE} wsreceiver.log ${RECEIVER_OPTIONS} ${EMPTY} @@ -55,8 +58,8 @@ ${CONTROLLER_LOG_LEVEL} INFO Clean_Config [Documentation] Make sure config inventory is empty. [Tags] critical - BuiltIn.Log ${CONFIG_NODES_API} - TemplatedRequests.Delete_From_Uri uri=${CONFIG_NODES_API} additional_allowed_status_codes=${DELETED_STATUS_CODE} + ${uri} = Restconf.Generate URI opendaylight-inventory:nodes config + TemplatedRequests.Delete_From_Uri uri=${uri} additional_allowed_status_codes=${DELETED_STATUS_CODE} # TODO: Rework also other test cases to use TemplatedRequests. Create_Subscribtion @@ -65,17 +68,19 @@ Create_Subscribtion ${body} = OperatingSystem.Get_File ${TEMPLATE_FOLDER}/${RESTCONF_SUBSCRIBE_DATA} BuiltIn.Log ${RESTCONF_SUBSCRIBE_URI} BuiltIn.Log ${body} - ${resp} = RequestsLibrary.Post_Request restconf ${RESTCONF_SUBSCRIBE_URI} headers=${SEND_ACCEPT_XML_HEADERS} data=${body} + ${uri} = Restconf.Generate URI sal-remote:create-data-change-event-subscription rpc + ${resp} = RequestsLibrary.Post_Request restconf ${uri} headers=${SEND_ACCEPT_XML_HEADERS} data=${body} Log_Response ${resp} - BuiltIn.Should_Be_Equal_As_Strings ${resp.status_code} 200 + BuiltIn.Should_Contain ${ALLOWED_STATUS_CODES} ${resp.status_code} Check_Subscribtion [Documentation] Get & check subscribtion ... [Tags] critical - ${resp} = RequestsLibrary.Get_Request restconf ${RESTCONF_GET_SUBSCRIPTION_URI} headers=${SEND_ACCEPT_XML_HEADERS} + ${uri} = Set Variable If "${USE_RFC8040}" == "False" ${RESTCONF_GET_SUBSCRIPTION_URI} ${RFC8040_GET_SUBSCRIPTION_URI} + ${resp} = RequestsLibrary.Get_Request restconf ${uri} headers=${SEND_ACCEPT_XML_HEADERS} Log_Response ${resp} - BuiltIn.Should_Be_Equal_As_Strings ${resp.status_code} 200 Response status code error - ${location} = Collections.Get_From_Dictionary ${resp.headers} location + BuiltIn.Should_Contain ${ALLOWED_STATUS_CODES} ${resp.status_code} + ${location} = XML.Get Element Text ${resp.content} BuiltIn.Log ${location} BuiltIn.Set_Suite_Variable ${location} @@ -90,15 +95,15 @@ Change_Config [Documentation] Make a change in configuration. [Tags] critical ${body} = OperatingSystem.Get_File ${TEMPLATE_FOLDER}/${RESTCONF_CONFIG_DATA} - BuiltIn.Log ${RESTCONF_CONFIG_URI} + ${uri} = Set Variable If "${USE_RFC8040}" == "False" ${CONFIG_API} rests/data BuiltIn.Log ${body} - ${resp} = RequestsLibrary.Post_Request restconf ${RESTCONF_CONFIG_URI} headers=${SEND_ACCEPT_XML_HEADERS} data=${body} + ${resp} = RequestsLibrary.Post_Request restconf ${uri} headers=${SEND_ACCEPT_XML_HEADERS} data=${body} Log_Response ${resp} - BuiltIn.Should_Be_Equal_As_Strings ${resp.status_code} 204 - BuiltIn.Log ${CONFIG_NODES_API} - ${resp} = RequestsLibrary.Delete_Request restconf ${CONFIG_NODES_API} headers=${SEND_ACCEPT_XML_HEADERS} + BuiltIn.Should_Contain ${ALLOWED_STATUS_CODES} ${resp.status_code} + ${uri} = Restconf.Generate URI opendaylight-inventory:nodes config + ${resp} = RequestsLibrary.Delete_Request restconf ${uri} headers=${SEND_ACCEPT_XML_HEADERS} Log_Response ${resp} - BuiltIn.Should_Be_Equal_As_Strings ${resp.status_code} 200 + BuiltIn.Should_Contain ${ALLOWED_STATUS_CODES} ${resp.status_code} Check_Create_Notification [Documentation] Check the websocket listener log for a change notification. -- 2.36.6