Pcepuser fixes: Better handling of prompt and json ordering 72/27972/4
authorVratko Polak <vrpolak@cisco.com>
Tue, 6 Oct 2015 16:58:21 +0000 (18:58 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Sat, 17 Oct 2015 02:36:20 +0000 (02:36 +0000)
Change-Id: Ia3bd570befc61d4dd4d18bef5c2aa426138757ff
Signed-off-by: Vratko Polak <vrpolak@cisco.com>
csit/libraries/PcepOperations.robot
csit/suites/bgpcep/pcepuser/pcepuser.robot

index fb00068644d4c026f8670234f7a4386e940370ec..d9c81d78f9fcd25130082ff5d7104c11fbc7bffe 100644 (file)
@@ -7,6 +7,7 @@ Documentation     Robot keyword library (Resource) for performing PCEP operation
 ...               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           RequestsLibrary
+Library           ${CURDIR}/HsfJson/hsf_json.py
 Variables         ${CURDIR}/../variables/Variables.py
 
 *** Keywords ***
@@ -54,7 +55,11 @@ Pcep_Json_Is_Success
     Should_Be_Equal_As_Strings    ${text}    {"output":{}}
 
 Pcep_Json_Is_Refused
-    [Arguments]    ${text}
+    [Arguments]    ${actual_raw}
     [Documentation]    Given text should be equal to json response when device refuses tunnel removal.
-    # FIXME: We probably should normalize text as json (and by that, test whether it is a json at all).
-    Should_Be_Equal_As_Strings    ${text}    {"output":{"error":[{"error-object":{"ignore":false,"processing-rule":false,"type":19,"value":9}}],"failure":"failed"}}
+    ${expected_raw}=    BuiltIn.Set_Variable    {"output":{"error":[{"error-object":{"ignore":false,"processing-rule":false,"type":19,"value":9}}],"failure":"failed"}}
+    # TODO: Is that JSON worth referencing pcepuser variables from this library?
+    ${expected_normalized}=    hsf_json.hsf_json    ${expected_raw}
+    ${actual_normalized}=    hsf_json.hsf_json    ${actual_raw}
+    BuiltIn.Should_Be_Equal    ${actual_normalized}    ${expected_normalized}
+    # TODO: Would the diff approach be more useful?
index 4c320b4a1a0ca2b275fc3d2d2804c25dc2fbf8c7..0085821084c34a87bf19a41529a71520fe109a37 100644 (file)
@@ -9,14 +9,18 @@ Documentation     Basic tests for odl-bgpcep-pcep-all feature.
 Suite Setup       Set_It_Up
 Suite Teardown    Tear_It_Down
 Library           OperatingSystem
-Library           SSHLibrary    prompt=]>
+Library           SSHLibrary
 Library           RequestsLibrary
 Library           ${CURDIR}/../../../libraries/HsfJson/hsf_json.py
 Resource          ${CURDIR}/../../../libraries/PcepOperations.robot
+Resource          ${CURDIR}/../../../libraries/Utils.robot
 Variables         ${CURDIR}/../../../variables/Variables.py
 Variables         ${CURDIR}/../../../variables/pcepuser/variables.py    ${MININET}
 
 *** Variables ***
+${MININET_PROMPT}    ${DEFAULT_LINUX_PROMPT}
+${OUTPUT_TIMEOUT}    10
+# FIXME: Unify parameter naming and case.
 ${ExpDir}         ${CURDIR}/expected
 ${ActDir}         ${CURDIR}/actual
 
@@ -113,8 +117,9 @@ Set_It_Up
     [Documentation]    Create SSH session to Mininet machine, prepare HTTP client session to Controller.
     ...    Figure out latest pcc-mock version and download it from Nexus to Mininet.
     ...    Also, delete and create directories for json diff handling.
-    Open_Connection    ${MININET}
-    Login_With_Public_Key    ${MININET_USER}    ${USER_HOME}/.ssh/${SSH_KEY}    any
+    SSHLibrary.Open_Connection    ${MININET}    prompt=${MININET_PROMPT}    timeout=${OUTPUT_TIMEOUT}
+    Utils.Flexible_Mininet_Login
+    # FIXME: Unify Module prefix usage across whole file.
     Create_Session    ses    http://${CONTROLLER}:${RESTCONFPORT}/restconf/operational/network-topology:network-topology    auth=${AUTH}
     ${urlbase}=    Set_Variable    ${NEXUSURL_PREFIX}/content/repositories/opendaylight.snapshot/org/opendaylight/bgpcep/pcep-pcc-mock
     ${version}=    Execute_Command    curl ${urlbase}/maven-metadata.xml | grep latest | cut -d '>' -f 2 | cut -d '<' -f 1