Append 3 more punt path protection TCs
[integration/test.git] / csit / libraries / TopoprocessingKeywords.robot
index 99a63b3ceaa73db1f021f172d350e3e1e2f79d0d..ede3e594e15b284d3c2628a2dd3da5621be7c031 100644 (file)
@@ -5,13 +5,18 @@ Variables         ../variables/topoprocessing/TopologyRequests.py
 Library           RequestsLibrary
 Library           SSHLibrary
 Library           XML
+Resource          CompareStream.robot
 Resource          KarafKeywords.robot
+Resource          SetupUtils.robot
 Resource          Utils.robot
 
 *** Variables ***
 ${CONFIGURATION_XML}    ${CURDIR}/../suites/topoprocessing/configuration.xml
 ${OPERATIONAL_XML}    ${CURDIR}/../suites/topoprocessing/operational.xml
-${REMOTE_FILE}    ${WORKSPACE}/${BUNDLEFOLDER}/etc/opendaylight/karaf/80-topoprocessing-config.xml
+${CONFIGURATION_CFG}    ${CURDIR}/../suites/topoprocessing/configuration.cfg
+${OPERATIONAL_CFG}    ${CURDIR}/../suites/topoprocessing/operational.cfg
+${REMOTE_XML_FILE}    ${WORKSPACE}/${BUNDLEFOLDER}/etc/opendaylight/karaf/80-topoprocessing-config.xml
+${REMOTE_CFG_FILE}    ${WORKSPACE}/${BUNDLEFOLDER}/etc/org.opendaylight.topoprocessing.cfg
 ${OUTPUT_TOPO_NAME}    topo:1
 ${OVERLAY_TOPO_URL}    ${TOPOLOGY_URL}/${OUTPUT_TOPO_NAME}
 
@@ -21,7 +26,7 @@ Basic Request Put
     [Documentation]    Send a simple HTTP PUT request to Configurational datastore
     ${resp}    Put Request    session    ${CONFIG_API}/${overlay_topology_url}    data=${request}
     Log    ${CONFIG_API}/${overlay_topology_url}
-    Should Match    ${resp.status_code}    "20?"
+    Should Match    "${resp.status_code}"    "20?"
     Wait For Karaf Log    Correlation configuration successfully read
     Wait For Karaf Log    Transaction successfully written
 
@@ -60,27 +65,44 @@ Delete Underlay Link
 Setup Environment
     [Documentation]    Setup karaf enviroment for following tests
     Log    ---- Setup Environment ----
+    SetupUtils.Setup_Utils_For_Setup_And_Teardown
     Open Connection    ${ODL_SYSTEM_IP}
     Flexible Controller Login
-    Put File    ${CONFIGURATION_XML}    ${REMOTE_FILE}
+    Put File    ${CONFIGURATION_CFG}    ${REMOTE_CFG_FILE}
     Close Connection
-    Issue Command On Karaf Console    log:set DEBUG org.opendaylight.topoprocessing
-    Install a Feature    odl-restconf-noauth    timeout=30
+    Wait Until Keyword Succeeds    2x    2s    Issue Command On Karaf Console    log:set DEBUG org.opendaylight.topoprocessing
     Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${SEND_ACCEPT_XML_HEADERS}
-    ${features}    Issue Command On Karaf Console    feature:list -i
-    ${lines}    Get Lines Containing String    ${features}    odl-topoprocessing-framework
-    ${length}    Get Length    ${lines}
-    Install a Feature    odl-openflowplugin-nsf-model odl-topoprocessing-framework odl-topoprocessing-network-topology odl-topoprocessing-inventory odl-mdsal-models odl-ovsdb-southbound-impl    timeout=120
-    Run Keyword If    ${length} == 0    Wait For Karaf Log    Registering Topology Request Listener    60
     Prepare New Feature Installation
     Insert Underlay topologies
 
+Install Features
+    [Arguments]    ${features}    ${timeout}=180
+    [Documentation]    Install features according to tested distribution
+    Install Features for Other Distributions    ${features}    ${timeout}
+
+Install Features for Beryllium Distribution
+    [Arguments]    ${features}    ${timeout}
+    [Documentation]    Will wait for features to install only once per run
+    Install a Feature    ${features}    timeout=${timeout}
+    Set Global Variable If It Does Not Exist    \${WAIT_FOR_FEATURES_TO_INSTALL}    ${TRUE}
+    Run Keyword If    ${WAIT_FOR_FEATURES_TO_INSTALL}    Run Keywords    Wait For Karaf Log    Registering Topology Request Listener    ${timeout}
+    ...    AND    Set Global Variable    \${WAIT_FOR_FEATURES_TO_INSTALL}    ${FALSE}
+
+Install Features for Other Distributions
+    [Arguments]    ${features}    ${timeout}
+    [Documentation]    Will wait for features to install only if no topoprocessing feature was installed
+    ${installed_features}    Issue Command On Karaf Console    feature:list -i
+    ${lines}    Get Lines Containing String    ${installed_features}    odl-topoprocessing-framework
+    ${length}    Get Length    ${lines}
+    Install a Feature    ${features}    timeout=${timeout}
+    Run Keyword If    ${length} == 0    Wait For Karaf Log    Registering Topology Request Listener    ${timeout}
+
 Clean Environment
     [Documentation]    Revert startup changes
     Log    ---- Clean Environment ----
     Open Connection    ${ODL_SYSTEM_IP}
     Flexible Controller Login
-    Put File    ${OPERATIONAL_XML}    ${REMOTE_FILE}
+    Put File    ${OPERATIONAL_CFG}    ${REMOTE_CFG_FILE}
     Close Connection
     Delete All Sessions
 
@@ -117,16 +139,16 @@ Insert Underlay Topologies
     : FOR    ${index}    IN RANGE    1    7
     \    ${resp}    Put Request    session    ${CONFIG_API}/${TOPOLOGY_URL}/network-topo:${index}    data=${NETWORK_UNDERLAY_TOPOLOGY_${index}}
     \    Log    ${resp.content}
-    \    Should Match    ${resp.status_code}    "20?"
+    \    Should Match    "${resp.status_code}"    "20?"
     # Openflow underlay nodes
     ${resp}    Put Request    session    ${CONFIG_API}/opendaylight-inventory:nodes    data=${OPENFLOW_UNDERLAY_NODES}
     Log    ${resp.content}
-    Should Match    ${resp.status_code}    "20?"
+    Should Match    "${resp.status_code}"    "20?"
     # Openflow underlay topologies
     : FOR    ${index}    IN RANGE    1    7
     \    ${resp}    Put Request    session    ${CONFIG_API}/${TOPOLOGY_URL}/openflow-topo:${index}    data=${OPENFLOW_UNDERLAY_TOPOLOGY_${index}}
     \    Log    ${resp.content}
-    \    Should Match    ${resp.status_code}    "20?"
+    \    Should Match    "${resp.status_code}"    "20?"
     Issue Command On Karaf Console    log:clear
     Log    ${resp.content}
 
@@ -450,3 +472,8 @@ Output Topo Should Be Complete
     Log    ---- Output Topo ----
     Log    ${resp.content}
     [Return]    ${resp}
+
+Set Global Variable If It Does Not Exist
+    [Arguments]    ${name}    ${value}
+    ${status}    ${message} =    Run Keyword And Ignore Error    Variable Should Exist    ${name}
+    Run Keyword If    "${status}" == "FAIL"    Set Global Variable    ${name}    ${value}