Fix Get On Session errors 10/103710/3
authorSangwook Ha <sangwook.ha@verizon.com>
Tue, 20 Dec 2022 06:32:05 +0000 (22:32 -0800)
committerSangwook Ha <sangwook.ha@verizon.com>
Tue, 20 Dec 2022 07:24:21 +0000 (23:24 -0800)
'Get On Session' has different arguments and requirements but some of
the conversions from 'Get Request' to 'Get On Session' didn't take those
into account.

To prevent confusion that '=' is used for parameters when it is in fact
part of the URL path, specify 'url' a keyword argument, instead of
positional, and separate parameters into 'params' when possible.

Also, set 'odl-pretty-print' parameter for Phosphorus or later since it
is not available before the version. Accept any status code when there
is a separate step to check valid status codes.

Change-Id: Ibd41fe31090eb0406abd16e80b3e6168d424bc74
Signed-off-by: Sangwook Ha <sangwook.ha@verizon.com>
csit/libraries/TemplatedRequests.robot
csit/libraries/Utils.robot
csit/suites/netconf/KeyAuth/keyauth.robot
csit/suites/netconf/notifications/notifications_basic.robot
csit/suites/netconf/ready/netconfready.robot

index 30b743a65c89e1ae548788ca62cb226a78cfda8f..58d918df4cffd8570e7a22d5589fe41cf15a4925 100644 (file)
@@ -664,11 +664,11 @@ Get_From_Uri
     BuiltIn.Log    ${uri}
     BuiltIn.Log    ${accept}
     IF    """${http_timeout}""" == """${EMPTY}"""
-        ${response} =    RequestsLibrary.Get_On_Session    ${session}    ${uri}    headers=${accept}
+        ${response} =    RequestsLibrary.Get_On_Session    ${session}    url=${uri}    headers=${accept}
     ELSE
         ${response} =    RequestsLibrary.Get_On_Session
         ...    ${session}
-        ...    ${uri}
+        ...    url=${uri}
         ...    headers=${accept}
         ...    timeout=${http_timeout}
     END
index 914fc47ef79144b543ef803dc7fed891e5b417ce..8da7c254d0ebbd13a96568f78afa4a08cbaccfc3 100644 (file)
@@ -96,7 +96,8 @@ Check Nodes Stats
     [Arguments]    ${node}    ${session}=session
     ${resp}=    RequestsLibrary.Get On Session
     ...    ${session}
-    ...    ${RFC8040_NODES_API}/node=${node}?${RFC8040_OPERATIONAL_CONTENT}
+    ...    url=${RFC8040_NODES_API}/node=${node}
+    ...    params=${RFC8040_OPERATIONAL_CONTENT}
     Should Be Equal As Strings    ${resp.status_code}    200
     Should Contain    ${resp.text}    flow-capable-node-connector-statistics
     Should Contain    ${resp.text}    flow-table-statistics
@@ -105,7 +106,7 @@ Check For Specific Number Of Elements At URI
     [Documentation]    A GET is made to the specified ${URI} and the specific count of a
     ...    given element is done (as supplied by ${element} and ${expected_count})
     [Arguments]    ${uri}    ${element}    ${expected_count}    ${session}=session
-    ${resp}=    RequestsLibrary.Get On Session    ${session}    ${uri}
+    ${resp}=    RequestsLibrary.Get On Session    ${session}    url=${uri}
     Log    ${resp.text}
     Should Be Equal As Strings    ${resp.status_code}    200
     Should Contain X Times    ${resp.text}    ${element}    ${expected_count}
@@ -124,7 +125,7 @@ Check For Elements At URI
     [Documentation]    A GET is made at the supplied ${URI} and every item in the list of
     ...    ${elements} is verified to exist in the response
     [Arguments]    ${uri}    ${elements}    ${session}=session    ${pretty_print_json}=False
-    ${resp}=    RequestsLibrary.Get On Session    ${session}    ${uri}
+    ${resp}=    RequestsLibrary.Get On Session    ${session}    url=${uri}
     IF    "${pretty_print_json}" == "True"
         Log Content    ${resp.text}
     ELSE
@@ -141,7 +142,7 @@ Check For Elements Not At URI
     ...    return of 404 is treated as empty list. From Neon onwards, an empty list is always
     ...    returned as null, giving 404 on rest call.
     [Arguments]    ${uri}    ${elements}    ${session}=session    ${pretty_print_json}=False    ${check_for_null}=False
-    ${resp}=    RequestsLibrary.Get On Session    ${session}    ${uri}
+    ${resp}=    RequestsLibrary.Get On Session    ${session}    url=${uri}
     IF    "${pretty_print_json}" == "True"
         Log Content    ${resp.text}
     ELSE
@@ -377,13 +378,13 @@ Remove All Elements At URI And Verify
     [Arguments]    ${uri}    ${session}=session
     ${resp}=    RequestsLibrary.Delete On Session    ${session}    ${uri}
     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
-    ${resp}=    RequestsLibrary.Get On Session    ${session}    ${uri}
+    ${resp}=    RequestsLibrary.Get On Session    ${session}    url=${uri}
     Should Contain    ${DELETED_STATUS_CODES}    ${resp.status_code}
 
 Remove All Elements If Exist
     [Documentation]    Delete all elements from an URI if the configuration was not empty
     [Arguments]    ${uri}    ${session}=session
-    ${resp}=    RequestsLibrary.Get On Session    ${session}    ${uri}
+    ${resp}=    RequestsLibrary.Get On Session    ${session}    url=${uri}
     IF    '${resp.status_code}'!='404' and '${resp.status_code}'!='409'
         Remove All Elements At URI    ${uri}    ${session}
     END
@@ -406,7 +407,7 @@ Add Elements To URI And Verify
     [Arguments]    ${dest_uri}    ${data}    ${headers}=${headers}    ${session}=session
     ${resp}=    RequestsLibrary.Put On Session    ${session}    ${dest_uri}    ${data}    headers=${headers}
     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
-    ${resp}=    RequestsLibrary.Get On Session    ${session}    ${dest_uri}
+    ${resp}=    RequestsLibrary.Get On Session    ${session}    url=${dest_uri}
     Should Not Contain    ${DELETED_STATUS_CODES}    ${resp.status_code}
 
 Add Elements To URI From File And Check Validation Error
@@ -447,7 +448,7 @@ Get Data From URI
     ...    ${headers}. If the request returns a HTTP error, fails. Otherwise
     ...    returns the data obtained by the request.
     [Arguments]    ${session}    ${uri}    ${headers}=${NONE}
-    ${resp}=    RequestsLibrary.Get On Session    ${session}    ${uri}    ${headers}
+    ${resp}=    RequestsLibrary.Get On Session    ${session}    url=${uri}    headers=${headers}
     IF    ${resp.status_code} == 200    RETURN    ${resp.text}
     Builtin.Log    ${resp.text}
     Builtin.Fail    The request failed with code ${resp.status_code}
@@ -456,7 +457,7 @@ Get URI And Verify
     [Documentation]    Issue a Get On Session and verify a successfull HTTP return.
     ...    Issues a Get On Session for ${uri} in ${session} using headers from ${headers}.
     [Arguments]    ${uri}    ${session}=session    ${headers}=${NONE}
-    ${resp}=    RequestsLibrary.Get On Session    ${session}    ${uri}    ${headers}
+    ${resp}=    RequestsLibrary.Get On Session    ${session}    url=${uri}    headers=${headers}
     Builtin.Log    ${resp.status_code}
     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
 
@@ -466,7 +467,7 @@ No Content From URI
     ...    ${headers}. If the request returns a HTTP error, fails. Otherwise
     ...    returns the data obtained by the request.
     [Arguments]    ${session}    ${uri}    ${headers}=${NONE}
-    ${resp}=    RequestsLibrary.Get On Session    ${session}    ${uri}    ${headers}     expected_status=409
+    ${resp}=    RequestsLibrary.Get On Session    ${session}    url=${uri}    expected_status=any    headers=${headers}
     IF    ${resp.status_code} == 404 or ${resp.status_code} == 409    RETURN
     Builtin.Log    ${resp.text}
     Builtin.Fail    The request failed with code ${resp.status_code}
@@ -658,7 +659,7 @@ Check Diagstatus
     ...    By default, this keyword will pass if the status code returned is 200, and fail otherwise.
     [Arguments]    ${ip_address}=${ODL_SYSTEM_IP}    ${check_status}=True    ${expected_status}=${200}
     RequestsLibrary.Create Session    diagstatus_session    http://${ip_address}:${RESTCONFPORT}
-    ${resp}=    RequestsLibrary.Get On Session    diagstatus_session    /diagstatus
+    ${resp}=    RequestsLibrary.Get On Session    diagstatus_session    url=/diagstatus
     IF    "${check_status}" == "True"
         BuiltIn.Should Be Equal As Strings    ${resp.status_code}    ${expected_status}
     END
index c9644ef046c161334c4637536e658a062eb48daa..4ea3f55c6ecffd9c66c535e1e0510af20085ca96 100644 (file)
@@ -108,7 +108,7 @@ Restart Controller
 
 Get Controller Modules
     [Documentation]    Get the restconf modules, check 200 status and ietf-restconf presence
-    ${resp}=    RequestsLibrary.Get_On_Session    default    ${MODULES_API}
+    ${resp}=    RequestsLibrary.Get_On_Session    default    url=${MODULES_API}
     BuiltIn.Log    ${resp.content}
     BuiltIn.Should_Be_Equal    ${resp.status_code}    ${200}
     BuiltIn.Should_Contain    ${resp.content}    ietf-restconf
index e4a51514b257ce261adebef5a993e72f335015c8..289069385c82c42dd8d4966355f74b6ce71debd7 100644 (file)
@@ -80,7 +80,7 @@ Subscribe_To_DCN_Stream
     [Documentation]    Subscribe to DCN streams.
     [Tags]    critical
     ${uri} =    Set Variable If    "${USE_RFC8040}" == "False"    ${DRAFT_DCN_STREAM_URI}    ${RFC8040_DCN_STREAM_URI}
-    ${resp} =    RequestsLibrary.Get_On_Session    restconf    ${uri}    headers=${SEND_ACCEPT_XML_HEADERS}
+    ${resp} =    RequestsLibrary.Get_On_Session    restconf    url=${uri}    headers=${SEND_ACCEPT_XML_HEADERS}
     Log_Response    ${resp}
     BuiltIn.Should_Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
     ${location} =    XML.Get_Element_Text    ${resp.content}
@@ -96,7 +96,7 @@ List_DCN_Streams
     ...    "${USE_RFC8040}" == "False"
     ...    ${DRAFT_STREAMS_URI}
     ...    ${RFC8040_STREAMS_URI}
-    ${resp} =    RequestsLibrary.Get_On_Session    restconf    ${uri}    headers=${SEND_ACCEPT_XML_HEADERS}
+    ${resp} =    RequestsLibrary.Get_On_Session    restconf    url=${uri}    headers=${SEND_ACCEPT_XML_HEADERS}
     Log_Response    ${resp}
     BuiltIn.Should_Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
     Comment    Stream only shows in RFC URL.
index 0ff14f34170bd9e4cc24a0fbcb9ba9e1f2b0d66a..087399c41711841a5112664de7fbe499bb6d9f6d 100644 (file)
@@ -136,7 +136,8 @@ Check_Whether_Netconf_Can_Pretty_Print
     IF    not ${netconf_is_ready}
         Fail    Netconf is not ready so it can't pretty-print now.
     END
-    Check_Netconf_Up_And_Running    ?odl-pretty-print=true
+    CompareStream.Run_Keyword_If_At_Least_Phosphorus
+    ...    Check_Netconf_Up_And_Running    pretty_print=odl-pretty-print=true
 
 Wait_For_MDSAL
     [Documentation]    Wait for the MDSAL feature to become online
@@ -239,7 +240,8 @@ Check_Netconf_Up_And_Running
     [Arguments]    ${pretty_print}=${EMPTY}
     ${response}=    RequestsLibrary.Get_On_Session
     ...    ses
-    ...    rests/data/network-topology:network-topology/topology\=topology-netconf${netconf_connector}${pretty_print}
+    ...    url=rests/data/network-topology:network-topology/topology=topology-netconf${netconf_connector}
+    ...    params=${pretty_print}
     BuiltIn.Log    ${response.text}
     ${status}=    BuiltIn.Run_Keyword_And_Return_Status
     ...    BuiltIn.Should_Contain