X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=csit%2Flibraries%2FTopoprocessingKeywords.robot;h=d4a47cf320dd91114cf1a8521835617da2bb224b;hb=4b2f0074adbfe9816444cafb6476e2ea7ef634f4;hp=adc6e6289cea08d7e71f5b6c0603d459db82743c;hpb=4df5af0d1e621a11fe293959c2243938b61f1bde;p=integration%2Ftest.git diff --git a/csit/libraries/TopoprocessingKeywords.robot b/csit/libraries/TopoprocessingKeywords.robot index adc6e6289c..d4a47cf320 100644 --- a/csit/libraries/TopoprocessingKeywords.robot +++ b/csit/libraries/TopoprocessingKeywords.robot @@ -5,13 +5,20 @@ 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} *** Keywords *** Basic Request Put @@ -19,17 +26,10 @@ 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 Be Equal As Strings ${resp.status_code} 200 + Should Match "${resp.status_code}" "20?" Wait For Karaf Log Correlation configuration successfully read Wait For Karaf Log Transaction successfully written -Basic Request Get And Test - [Arguments] ${overlay_topology_url} ${should_contain} ${times} - [Documentation] Send a simple HTTP GET request to a given URL and test if response contains the expected item X times - ${resp} Basic Request Get ${overlay_topology_url} - Should Contain X Times ${resp.content} ${should_contain} ${times} - [Return] ${resp} - Basic Request Get [Arguments] ${overlay_topology_url} [Documentation] Send a simple HTTP GET request to a given URL @@ -37,54 +37,93 @@ Basic Request Get Should Be Equal As Strings ${resp.status_code} 200 [Return] ${resp} -Send Basic Request And Test If Contain X Times - [Arguments] ${request} ${overlay_topology_url} ${should_contain} ${times} - [Documentation] Send a basic HTTP PUT request to a given URL and test if response contains the expexted item X times - Basic Request Put ${request} ${overlay_topology_url} - ${resp} Wait Until Keyword Succeeds 40x 250ms Basic Request Get And Test ${overlay_topology_url} ${should_contain} - ... ${times} - Log ${resp.content} +Send Basic Delete Request + [Arguments] ${url} + [Documentation] Sends a HTTP/DELETE request to a given URL + ${resp} Delete Request session ${CONFIG_API}/${url} + Log Deleting ${CONFIG_API}/${url} + [Return] ${resp} + +Delete Underlay Node + [Arguments] ${topology-id} ${node-id} + [Documentation] Deletes a node from an underlay topology + ${resp} Send Basic Delete Request ${TOPOLOGY_URL}/${topology-id}/node/${node-id} + [Return] ${resp} + +Delete Underlay Termination Point + [Arguments] ${topology-id} ${node-id} ${tp-id} + [Documentation] Deletes a termination point from an underlay topology + ${resp} Send Basic Delete Request ${TOPOLOGY_URL}/${topology-id}/node/${node-id}/termination-point/${tp-id} + [Return] ${resp} + +Delete Underlay Link + [Arguments] ${topology-id} ${link-id} + [Documentation] Deletes a link from an underlay topology + ${resp} Send Basic Delete Request ${TOPOLOGY_URL}/${topology-id}/link/${link-id} [Return] ${resp} 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 -Test Teardown - [Arguments] ${overlay_topology} +Delete Overlay Topology [Documentation] Delete overlay topologies from datastore + Run Keyword If Test Failed Print Output Topo Log ---- Test Teardown ---- - Log Deleting overlay topology from ${CONFIG_API}/${overlay_topology} - ${resp} Delete Request session ${CONFIG_API}/${overlay_topology} + Log Deleting overlay topology from ${CONFIG_API}/${OVERLAY_TOPO_URL} + ${resp} Delete Request session ${CONFIG_API}/${OVERLAY_TOPO_URL} Should Be Equal As Strings ${resp.status_code} 200 -Test Teardown With Underlay Topologies Refresh - [Arguments] ${overlay_topology} +Print Output Topo + [Documentation] Waits a while to allow any hanging transactions to finnish and then logs the output topology + Log ---- Output Topo Dump After Cooldown---- + Sleep 2s + ${resp} Wait Until Keyword Succeeds 5x 250ms Basic Request Get ${OVERLAY_TOPO_URL} + Log ${resp.text} + +Refresh Underlay Topologies And Delete Overlay Topology [Documentation] Deletes given overlay topology from datastore and overwrites the underlaying ones with initial topologies - Test Teardown ${overlay_topology} + Delete Overlay Topology Insert Underlay Topologies Prepare New Feature Installation @@ -97,21 +136,23 @@ Insert Underlay Topologies [Documentation] Insert underlay topologies used by following tests Log Inserting underlay topologies # Network 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 Be Equal As Strings ${resp.status_code} 200 - # Openflow underlay nodes + FOR ${index} IN RANGE 1 7 + ${resp} Put Request session ${CONFIG_API}/${TOPOLOGY_URL}/network-topo:${index} data=${NETWORK_UNDERLAY_TOPOLOGY_${index}} + Log ${resp.text} + Should Match "${resp.status_code}" "20?" + # Openflow underlay nodes + END ${resp} Put Request session ${CONFIG_API}/opendaylight-inventory:nodes data=${OPENFLOW_UNDERLAY_NODES} - Log ${resp.content} - Should Be Equal As Strings ${resp.status_code} 200 + Log ${resp.text} + 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 Be Equal As Strings ${resp.status_code} 200 + FOR ${index} IN RANGE 1 7 + ${resp} Put Request session ${CONFIG_API}/${TOPOLOGY_URL}/openflow-topo:${index} data=${OPENFLOW_UNDERLAY_TOPOLOGY_${index}} + Log ${resp.text} + Should Match "${resp.status_code}" "20?" + END Issue Command On Karaf Console log:clear - Log ${resp.content} + Log ${resp.text} Prepare Unification Inside Topology Request [Arguments] ${request_template} ${model} ${correlation_item} ${underlay_topo1} @@ -370,8 +411,9 @@ Check Aggregated Node in Topology Should Contain X Times ${aggregated_node} ${supp_node_count} Should Contain X Times ${aggregated_node} ${tp_count} Should Contain X Times ${aggregated_node} ${tp_count} - : FOR ${supp_node_id} IN @{supp_node_ids} - \ Element Text Should Be ${aggregated_node} ${supp_node_id} xpath=.//supporting-node[node-ref='${supp_node_id}']/node-ref + FOR ${supp_node_id} IN @{supp_node_ids} + Element Text Should Be ${aggregated_node} ${supp_node_id} xpath=.//supporting-node[node-ref='${supp_node_id}']/node-ref + END ${overlay_node_id} Get Element Text ${aggregated_node} xpath=./node-id [Return] ${overlay_node_id} @@ -382,18 +424,16 @@ Check Aggregated Termination Point in Node ${tp} Extract Termination Point from Topology ${model} ${topology} ${topology_id} ${node_id} ${tp_id} ${supp_tp_count} Get Length ${supp_tp_ids} Should Contain X Times ${tp} ${supp_tp_count} - : FOR ${supp_tp_id} IN @{supp_tp_ids} - \ Should Contain X Times ${tp} ${supp_tp_id} 1 + FOR ${supp_tp_id} IN @{supp_tp_ids} + Should Contain X Times ${tp} ${supp_tp_id} 1 + END Check Filtered Nodes in Topology [Arguments] ${topology} ${tp_count} @{node_ids} [Documentation] Checks nodes in filtered topology - ${node_count} Get Length ${node_ids} - Should Contain X Times ${topology} ${node_count} - Should Contain X Times ${topology} ${node_count} - Should Contain X Times ${topology} ${tp_count} - : FOR ${node_id} IN @{node_ids} - \ Element Text Should Be ${topology} ${node_id} xpath=.//node/supporting-node[node-ref='${node_id}']/node-ref + FOR ${node_id} IN @{node_ids} + Element Text Should Be ${topology} ${node_id} xpath=.//node/supporting-node[node-ref='${node_id}']/node-ref + END Check Filtered Termination Points in Node [Arguments] ${topology} ${supp_node_id} @{supp_tp_ids} @@ -403,17 +443,16 @@ Check Filtered Termination Points in Node Should Contain X Times ${node} 1 Should Contain X Times ${node} ${supp_tp_count} Should Contain X Times ${node} ${supp_tp_count} - : FOR ${supp_tp_id} IN @{supp_tp_ids} - \ Should Contain X Times ${node} ${supp_tp_id} 1 + FOR ${supp_tp_id} IN @{supp_tp_ids} + Should Contain X Times ${node} ${supp_tp_id} 1 + END Check Filtered Links In Topology [Arguments] ${topology} @{supp_link_ids} [Documentation] Checks links in filtered topology - ${supp_link_count} Get Length ${supp_link_ids} - Should Contain X Times ${topology} ${supp_link_count} - Should Contain X Times ${topology} ${supp_link_count} - : FOR ${supp_link_id} IN @{supp_link_ids} - \ Should Contain X Times ${topology} ${supp_link_id} 1 + FOR ${supp_link_id} IN @{supp_link_ids} + Should Contain X Times ${topology} ${supp_link_id} 1 + END Check Overlay Link Source And Destination [Arguments] ${model} ${topology} ${topo_id} ${link_id} ${expected_source} ${expected_destination} @@ -423,3 +462,25 @@ Check Overlay Link Source And Destination ${link_destination} Get Element Text ${link} xpath=.//dest-node Should Be Equal As Strings ${link_source} ${expected_source} Should Be Equal As Strings ${link_destination} ${expected_destination} + +Output Topo Should Be Complete + [Arguments] ${node_count}=-1 ${supporting-node_count}=-1 ${node-ref_count}=-1 ${tp_count}=-1 ${tp-ref_count}=-1 ${link_count}=-1 + ... ${link-ref_count}=-1 + [Documentation] Verifies that the output topology contains the expected amount of essential elements + ${resp} Wait Until Keyword Succeeds 5x 250ms Basic Request Get ${OVERLAY_TOPO_URL} + Should Contain ${resp.text} ${OUTPUT_TOPO_NAME} + Run Keyword If ${node_count}>-1 Should Contain X Times ${resp.text} ${node_count} + Run Keyword If ${supporting-node_count}>-1 Should Contain X Times ${resp.text} ${supporting-node_count} + Run Keyword If ${node-ref_count}>-1 Should Contain X Times ${resp.text} ${node-ref_count} + Run Keyword If ${link_count}>-1 Should Contain X Times ${resp.text} ${link_count} + Run Keyword If ${link-ref_count}>-1 Should Contain X Times ${resp.text} ${link-ref_count} + Run Keyword If ${tp_count}>-1 Should Contain X Times ${resp.text} ${tp_count} + Run Keyword If ${tp-ref_count}>-1 Should Contain X Times ${resp.text} ${tp-ref_count} + Log ---- Output Topo ---- + Log ${resp.text} + [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}