Delete data folder
[integration/test.git] / csit / libraries / Genius.robot
index 35ce2735f99f8a3acbfc535d2e93af578c276ff6..a53d5a7ae682ae2bd0442f7b1f56d9e296d627e3 100644 (file)
@@ -1,13 +1,95 @@
 *** Settings ***
 Documentation     This suite is a common keywordis file for genius project.
+Library           Collections
 Library           OperatingSystem
 Library           RequestsLibrary
 Library           SSHLibrary
-Resource          ../../variables/Variables.robot
+Library           re
+Library           string
+Resource          KarafKeywords.robot
+Resource          Utils.robot
+Resource          ../variables/Variables.robot
 
 *** Variables ***
 
 *** Keywords ***
+Genius Suite Setup
+    [Documentation]    Create Rest Session to http://${ODL_SYSTEM_IP}:${RESTCONFPORT}
+    Start Suite
+    Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}    timeout=5
+
+Genius Suite Teardown
+    [Documentation]    Delete all sessions
+    Delete All Sessions
+    Stop Suite
+
+Start Suite
+    [Documentation]    Initial setup for Genius test suites
+    Run_Keyword_If_At_Least_Oxygen    Check Service Status    ACTIVE    OPERATIONAL
+    Log    Start the tests
+    ${conn_id_1}=    Open Connection    ${TOOLS_SYSTEM_IP}    prompt=${DEFAULT_LINUX_PROMPT}    timeout=30s
+    Set Global Variable    ${conn_id_1}
+    KarafKeywords.Setup_Karaf_Keywords
+    ${karaf_debug_enabled}    BuiltIn.Get_Variable_Value    ${KARAF_DEBUG}    ${False}
+    BuiltIn.run_keyword_if    ${karaf_debug_enabled}    KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set DEBUG org.opendaylight.genius
+    Login With Public Key    ${TOOLS_SYSTEM_USER}    ${USER_HOME}/.ssh/${SSH_KEY}    any
+    Log    ${conn_id_1}
+    Execute Command    sudo ovs-vsctl add-br BR1
+    Execute Command    sudo ovs-vsctl set bridge BR1 protocols=OpenFlow13
+    Execute Command    sudo ovs-vsctl set-controller BR1 tcp:${ODL_SYSTEM_IP}:6633
+    Execute Command    sudo ifconfig BR1 up
+    Execute Command    sudo ovs-vsctl add-port BR1 tap8ed70586-6c -- set Interface tap8ed70586-6c type=tap
+    Execute Command    sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:6640
+    ${output_1}    Execute Command    sudo ovs-vsctl show
+    Log    ${output_1}
+    ${check}    Wait Until Keyword Succeeds    30    10    check establishment    ${conn_id_1}    6633
+    log    ${check}
+    ${check_2}    Wait Until Keyword Succeeds    30    10    check establishment    ${conn_id_1}    6640
+    log    ${check_2}
+    Log    >>>>>Switch 2 configuration <<<<<
+    ${conn_id_2}=    Open Connection    ${TOOLS_SYSTEM_2_IP}    prompt=${DEFAULT_LINUX_PROMPT}    timeout=30s
+    Set Global Variable    ${conn_id_2}
+    Login With Public Key    ${TOOLS_SYSTEM_USER}    ${USER_HOME}/.ssh/${SSH_KEY}    any
+    Log    ${conn_id_2}
+    Execute Command    sudo ovs-vsctl add-br BR2
+    Execute Command    sudo ovs-vsctl set bridge BR2 protocols=OpenFlow13
+    Execute Command    sudo ovs-vsctl set-controller BR2 tcp:${ODL_SYSTEM_IP}:6633
+    Execute Command    sudo ifconfig BR2 up
+    Execute Command    sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:6640
+    ${output_2}    Execute Command    sudo ovs-vsctl show
+    Log    ${output_2}
+
+Stop Suite
+    Log    Stop the tests
+    Switch Connection    ${conn_id_1}
+    Log    ${conn_id_1}
+    Execute Command    sudo ovs-vsctl del-br BR1
+    Execute Command    sudo ovs-vsctl del-manager
+    Write    exit
+    close connection
+    Switch Connection    ${conn_id_2}
+    Log    ${conn_id_2}
+    Execute Command    sudo ovs-vsctl del-br BR2
+    Execute Command    sudo ovs-vsctl del-manager
+    Write    exit
+    close connection
+
+check establishment
+    [Arguments]    ${conn_id}    ${port}
+    Switch Connection    ${conn_id}
+    ${check_establishment}    Execute Command    netstat -anp | grep ${port}
+    Should contain    ${check_establishment}    ESTABLISHED
+    [Return]    ${check_establishment}
+
+Check Service Status
+    [Arguments]    ${system_ready_state}    ${service_state}
+    [Documentation]    Issues the karaf shell command showSvcStatus to verify the ready and service states are the same as the arguments passed
+    ${service_status_output}    Issue_Command_On_Karaf_Console    showSvcStatus    ${ODL_SYSTEM_IP}    8101
+    Should Contain    ${service_status_output}    ${system_ready_state}
+    @{split}    Split To Lines    ${service_status_output}    3    7
+    : FOR    ${var}    IN    @{split}
+    \    Should Contain    ${var}    ${service_state}
+
 Create Vteps
     [Arguments]    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}    ${vlan}    ${gateway-ip}
     [Documentation]    This keyword creates VTEPs between ${TOOLS_SYSTEM_IP} and ${TOOLS_SYSTEM_2_IP}
@@ -53,7 +135,12 @@ Get Dpn Ids
     log    ${Dpn_id}
     [Return]    ${Dpn_id}
 
-Delete All Sessions
+BFD Suite Stop
+    [Documentation]    Run at end of BFD suite
+    Delete All Vteps
+    Stop Suite
+
+Delete All Vteps
     [Documentation]    This will delete vtep.
     ${resp}    RequestsLibrary.Delete Request    session    ${CONFIG_API}/itm:transport-zones/    data=${vtep_body}
     Log    ${resp.status_code}