pcepuser update
[integration/test.git] / csit / suites / bgpcep / pcepuser / pcepuser.robot
index f95b29e7cfd16b5ed90b6aee44f636269841cd61..62b5d487002d31ed1e28e354766ba67647bacd18 100644 (file)
@@ -11,25 +11,26 @@ Suite Teardown    Tear_It_Down
 Library           OperatingSystem
 Library           SSHLibrary
 Library           RequestsLibrary
-Library           ${CURDIR}/../../../libraries/norm_json.py
-Resource          ${CURDIR}/../../../libraries/NexusKeywords.robot
-Resource          ${CURDIR}/../../../libraries/PcepOperations.robot
-Resource          ${CURDIR}/../../../libraries/Utils.robot
-Variables         ${CURDIR}/../../../variables/Variables.py
-Variables         ${CURDIR}/../../../variables/pcepuser/variables.py    ${TOOLS_SYSTEM_IP}
+Library           ../../../libraries/norm_json.py
+Resource          ../../../libraries/NexusKeywords.robot
+Resource          ../../../libraries/PcepOperations.robot
+Resource          ../../../libraries/Utils.robot
+Resource          ../../../libraries/RemoteBash.robot
+Resource          ../../../libraries/TemplatedRequests.robot
+Resource          ../../../libraries/KarafKeywords.robot
+Variables         ../../../variables/Variables.py
+Variables         ../../../variables/pcepuser/variables.py    ${TOOLS_SYSTEM_IP}
 
 *** Variables ***
-${OUTPUT_TIMEOUT}    10
-# FIXME: Unify parameter naming and case.
-${ExpDir}         ${CURDIR}/expected
-${ActDir}         ${CURDIR}/actual
+${CONFIG_SESSION}    session
+${PATH_SESSION_URI}    node/pcc:%2F%2F${TOOLS_SYSTEM_IP}/path-computation-client
 
 *** Test Cases ***
 Topology_Precondition
     [Documentation]    Compare current pcep-topology to off_json variable.
     ...    Timeout is long enough to ODL boot, to see that pcep is ready, with no PCC is connected.
     [Tags]    critical
-    Wait_Until_Keyword_Succeeds    300    1    Compare_Topology    ${off_json}    010_Topology_Precondition
+    Wait_Until_Keyword_Succeeds    300s    1s    Compare_Topology    ${off_json}
 
 Start_Pcc_Mock
     [Documentation]    Execute pcc-mock on Mininet, fail is Open is not sent, keep it running for next tests.
@@ -42,7 +43,7 @@ Topology_Default
     [Documentation]    Compare pcep-topology to default_json, which includes a tunnel from pcc-mock.
     ...    Timeout is lower than in Precondition, as state from pcc-mock should be updated quickly.
     [Tags]    critical
-    Wait_Until_Keyword_succeeds    5    1    Compare_Topology    ${default_json}    020_Topology_Default
+    Wait_Until_Keyword_succeeds    10s    1s    Compare_Topology    ${default_json}    ${PATH_SESSION_URI}
 
 Update_Delegated
     [Documentation]    Perform update-lsp on the mocked tunnel, check response is success.
@@ -53,7 +54,7 @@ Update_Delegated
 Topology_Updated
     [Documentation]    Compare pcep-topology to default_json, which includes the updated tunnel.
     [Tags]    critical
-    Wait_Until_Keyword_succeeds    5    1    Compare_Topology    ${updated_json}    030_Topology_Updated
+    Wait_Until_Keyword_succeeds    10s    1s    Compare_Topology    ${updated_json}    ${PATH_SESSION_URI}
 
 Refuse_Remove_Delegated
     [Documentation]    Perform remove-lsp on the mocked tunnel, check that mock-pcc has refused to remove it.
@@ -64,7 +65,7 @@ Refuse_Remove_Delegated
 Topology_Still_Updated
     [Documentation]    Compare pcep-topology to default_json, which includes the updated tunnel, to verify that refusal did not break topology.
     [Tags]    critical
-    Wait_Until_Keyword_succeeds    5    1    Compare_Topology    ${updated_json}    040_Topology_Still_Updated
+    Wait_Until_Keyword_succeeds    10s    1s    Compare_Topology    ${updated_json}    ${PATH_SESSION_URI}
 
 Add_Instantiated
     [Documentation]    Perform add-lsp to create new tunnel, check that response is success.
@@ -75,7 +76,7 @@ Add_Instantiated
 Topology_Second_Default
     [Documentation]    Compare pcep-topology to default_json, which includes the updated delegated and default instantiated tunnel.
     [Tags]    critical
-    Wait_Until_Keyword_succeeds    5    1    Compare_Topology    ${updated_default_json}    050_Topology_Second_Default
+    Wait_Until_Keyword_succeeds    10s    1s    Compare_Topology    ${updated_default_json}    ${PATH_SESSION_URI}
 
 Update_Instantiated
     [Documentation]    Perform update-lsp on the newly instantiated tunnel, check that response is success.
@@ -86,7 +87,7 @@ Update_Instantiated
 Topology_Second_Updated
     [Documentation]    Compare pcep-topology to default_json, which includes the updated delegated and updated instantiated tunnel.
     [Tags]    critical
-    Wait_Until_Keyword_succeeds    5    1    Compare_Topology    ${updated_updated_json}    060_Topology_Second_Updated
+    Wait_Until_Keyword_succeeds    10s    1s    Compare_Topology    ${updated_updated_json}    ${PATH_SESSION_URI}
 
 Remove_Instantiated
     [Documentation]    Perform remove-lsp on the instantiated tunnel, check that response is success.
@@ -97,63 +98,47 @@ Remove_Instantiated
 Topology_Again_Updated
     [Documentation]    Compare pcep-topology to default_json, which includes the updated tunnel, to verify that instantiated tunnel was removed.
     [Tags]    critical
-    Wait_Until_Keyword_succeeds    5    1    Compare_Topology    ${updated_json}    070_Topology_Again_Updated
+    Wait_Until_Keyword_succeeds    10s    1s    Compare_Topology    ${updated_json}    ${PATH_SESSION_URI}
 
 Stop_Pcc_Mock
     [Documentation]    Send ctrl+c to pcc-mock, fails if no prompt is seen
     ...    after 3 seconds (the default for SSHLibrary)
-    ${command}=    Evaluate    chr(int(3))
-    Log    ${command}
-    Write    ${command}
-    Read_Until_Prompt
+    RemoteBash.Write_Bare_Ctrl_C
+    ${output}=    SSHLibrary.Read_Until_Prompt
+    BuiltIn.Log    ${output}
 
 Topology_Postcondition
     [Documentation]    Compare curent pcep-topology to "off_json" again.
     [Tags]    critical
-    Wait_Until_Keyword_Succeeds    5    1    Compare_Topology    ${off_json}    080_Topology_Postcondition
+    Wait_Until_Keyword_Succeeds    10s    1s    Compare_Topology    ${off_json}
 
 *** Keywords ***
 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.
     NexusKeywords.Initialize_Artifact_Deployment_And_Usage
-    # FIXME: Unify Module prefix usage across whole file.
-    Create_Session    ses    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}/restconf/operational/network-topology:network-topology    auth=${AUTH}
+    RequestsLibrary.Create_Session    ${CONFIG_SESSION}    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}
     ${name}=    NexusKeywords.Deploy_Test_Tool    bgpcep    pcep-pcc-mock
     BuiltIn.Set_Suite_Variable    ${filename}    ${name}
-    Remove_Directory    ${ExpDir}
-    Remove_Directory    ${ActDir}
-    Create_Directory    ${ExpDir}
-    Create_Directory    ${ActDir}
-    Setup_Pcep_Operations
-
-Compare_Topology
-    [Arguments]    ${expected}    ${name}
-    [Documentation]    Get current pcep-topology as json, normalize both expected and actual json.
-    ...    Save normalized jsons to files for later processing.
-    ...    Error codes and normalized jsons should match exactly.
-    ${normexp}=    norm_json.normalize_json_text    ${expected}
-    Log    ${normexp}
-    Create_File    ${ExpDir}${/}${name}    ${normexp}
-    ${resp}=    RequestsLibrary.Get Request    ses    topology/pcep-topology
-    Log    ${resp}
-    Log    ${resp.text}
-    ${normresp}=    norm_json.normalize_json_text    ${resp.text}
-    Log    ${normresp}
-    Create_File    ${ActDir}${/}${name}    ${normresp}
-    Should_Be_Equal_As_Strings    ${resp.status_code}    200
-    Should_Be_Equal    ${normresp}    ${normexp}
+    PcepOperations.Setup_Pcep_Operations
 
 Tear_It_Down
     [Documentation]    Download pccmock.log and Log its contents.
     ...    Compute and Log the diff between expected and actual normalized responses.
     ...    Close both HTTP client session and SSH connection to Mininet.
     SSHLibrary.Get_File    pccmock.log
-    ${pccmocklog}=    Run    cat pccmock.log
-    Log    ${pccmocklog}
-    ${diff}=    Run    diff -dur ${ExpDir} ${ActDir}
-    Log    ${diff}
-    Teardown_Pcep_Operations
+    ${pccmocklog}=    OperatingSystem.Run    cat pccmock.log
+    BuiltIn.Log    ${pccmocklog}
+    PcepOperations.Teardown_Pcep_Operations
     Delete_All_Sessions
     Close_All_Connections
+
+Compare_Topology
+    [Arguments]    ${exp}    ${uri}=${EMPTY}
+    [Documentation]    Get current pcep-topology as json, compare both expected and actual json.
+    ...    Error codes and normalized jsons should match exactly.
+    # TODO: Add Node Session State Check For Oxygen, see tcpmd5user
+    # TODO: Possibly remake all tests with TemplatedRequests
+    ${response}=    RequestsLibrary.Get Request    ${CONFIG_SESSION}    ${OPERATIONAL_TOPO_API}/topology/pcep-topology/${uri}
+    BuiltIn.Should_Be_Equal_As_Strings    ${response.status_code}    200
+    TemplatedRequests.Normalize_Jsons_And_Compare    ${exp}    ${response.text}