Genius CSIT - Add AutoTunnels Suite
[integration/test.git] / csit / suites / genius / ITM_Vtep_Auto_Tunnel.robot
1 *** Settings ***
2 Documentation     Test suite to validate ITM VTEP auto-configuration functionality in openstack integrated environment.
3 Suite Setup       BuiltIn.Run Keywords    Genius.Genius Suite Setup
4 ...               AND    OvsManager.Verify Ovs Version Greater Than Or Equal To    ${OVS_VERSION}    @{COMPUTE-NODE-LIST}
5 Suite Teardown    Genius.Genius Suite Teardown
6 Test Setup        Genius Test Setup
7 Test Teardown     Genius Test Teardown    ${data_models}
8 Library           OperatingSystem
9 Library           RequestsLibrary
10 Library           SSHLibrary
11 Library           String
12 Resource          ../../libraries/Genius.robot
13 Resource          ../../libraries/KarafKeywords.robot
14 Resource          ../../libraries/OVSDB.robot
15 Resource          ../../libraries/OvsManager.robot
16 Resource          ../../libraries/Utils.robot
17 Resource          ../../libraries/VpnOperations.robot
18 Resource          ../../variables/netvirt/Variables.robot
19 Resource          ../../variables/Variables.robot
20 Variables         ../../variables/genius/Modules.py
21
22 *** Variables ***
23 ${CHANGE_TRANSPORT_ZONE}    sudo ovs-vsctl set O . external_ids:transport-zone
24 ${SET_LOCAL_IP}    sudo ovs-vsctl set O . other_config:local_ip=
25 ${TZA_JSON}       ${GENIUS_VAR_DIR}/Itm_Auto_Tunnel_Create.json
26 ${DEFAULT_TRANSPORT_ZONE}    default-transport-zone
27 ${DELETE_TRANSPORT_ZONE}    sudo ovs-vsctl remove O . external_ids transport-zone
28 ${GET_EXTERNAL_IDS}    sudo ovsdb-client dump -f list Open_vSwitch | grep external_ids
29 ${GET_NETWORK_TOPOLOGY_URL}    ${OPERATIONAL_API}/network-topology:network-topology/topology/ovsdb:1/
30 ${OVS_VERSION}    2.5
31 ${REMOVE_LOCAL_IP}    sudo ovs-vsctl remove O . other_config local_ip
32 ${SHOW_OTHER_CONFIG}    sudo ovsdb-client dump -f list Open_vSwitch | grep other_config
33 ${STATUS_CHECK}    DOWN
34 ${TRANSPORT_ZONE}    TZA
35 ${TRANSPORTZONE_POST_URL}    ${CONFIG_API}/itm:transport-zones
36 @{COMPUTE-NODE-LIST}    ${TOOLS_SYSTEM_1_IP}    ${TOOLS_SYSTEM_2_IP}
37
38 *** Test Cases ***
39 Verify TEP in controller and transport zone in OVSDB table of compute nodes
40     [Documentation]    Set local ip in compute nodes and verify default transport zone tunnels are up in controller
41     : FOR    ${ip}    IN    @{COMPUTE-NODE-LIST}
42     \    ${localip} =    Utils.Run Command On Remote System    ${ip}    ${SET_LOCAL_IP}${ip}
43     ${dpn} =    OVSDB.Get DPID    ${TOOLS_SYSTEM_1_IP}
44     ${dpn} =    BuiltIn.Convert To String    ${dpn}
45     BuiltIn.Set Suite Variable    ${DPN1}    ${dpn}
46     ${dpn} =    OVSDB.Get DPID    ${TOOLS_SYSTEM_2_IP}
47     ${dpn} =    BuiltIn.Convert To String    ${dpn}
48     BuiltIn.Set Suite Variable    ${DPN2}    ${dpn}
49     ${ip} =    OvsManager.Get OVS Local Ip    ${TOOLS_SYSTEM_1_IP}
50     BuiltIn.Set Suite Variable    ${LOCAL_IP_COMPUTE1}    ${ip}
51     ${ip} =    OvsManager.Get OVS Local Ip    ${TOOLS_SYSTEM_2_IP}
52     BuiltIn.Set Suite Variable    ${LOCAL_IP_COMPUTE2}    ${ip}
53     BuiltIn.Wait Until Keyword Succeeds    3x    10 sec    Genius.Verify Tunnel Status as UP    ${DEFAULT_TRANSPORT_ZONE}
54
55 Verify TEPs with transport zone configured from OVS will be added to corresponding transport zone
56     [Documentation]    To Verify transport zone name change in external id field of ovsdb and check status when moved from tep nohosted zone to TZA
57     Change Transport Zone In Compute    ${TOOLS_SYSTEM_1_IP}    ${TRANSPORT_ZONE}
58     ${get_nohosted_data} =    BuiltIn.Wait Until Keyword Succeeds    3x    10 sec    Utils.Get Data From URI    session    ${TEP_NOT_HOSTED_ZONE_URL}
59     BuiltIn.Should Contain    ${get_nohosted_data}    ${TRANSPORT_ZONE}
60     BuiltIn.Should Contain    ${get_nohosted_data}    ${DPN1}
61     Utils.Post Elements To URI From File    ${TRANSPORTZONE_POST_URL}    ${TZA_JSON}
62     Change Transport Zone In Compute    ${TOOLS_SYSTEM_2_IP}    ${TRANSPORT_ZONE}
63     : FOR    ${node}    IN    @{COMPUTE-NODE-LIST}
64     \    ${output} =    Utils.Run Command On Remote System    ${node}    ${GET_EXTERNAL_IDS}
65     \    BuiltIn.Should Contain    ${output}    ${TRANSPORT_ZONE}
66     ${get_hosted_data} =    BuiltIn.Wait Until Keyword Succeeds    3x    10 sec    Utils.Get Data From URI    session    ${TRANSPORT_ZONE_ENDPOINT_URL}/${TRANSPORT_ZONE}
67     BuiltIn.Should Contain    ${get_hosted_data}    ${TRANSPORT_ZONE}
68     BuiltIn.Should Contain    ${get_hosted_data}    ${DPN1}
69     BuiltIn.Wait Until Keyword Succeeds    3x    10 sec    Genius.Verify Tunnel Status as UP    ${TRANSPORT_ZONE}
70
71 Verify other-config-key and transport zone value in controller operational datastore
72     [Documentation]    validate local_ip and transport-zone value from controller datastore and Verify value of external-id-key with transport_zone in Controller operational datastore
73     ${controller-data} =    Utils.Get Data From URI    session    ${GET_NETWORK_TOPOLOGY_URL}
74     BuiltIn.Should Contain    ${controller-data}    "other-config-value":"${LOCAL_IP_COMPUTE1}"
75     BuiltIn.Should Contain    ${controller-data}    "other-config-value":"${LOCAL_IP_COMPUTE2}"
76     BuiltIn.Should Contain    ${controller-data}    "external-id-value":"${TRANSPORT_ZONE}"
77
78 Delete transport zone on OVS and check ovsdb update to controller
79     [Documentation]    To verify transport zone moves to default zone after deleting zone name in compute nodes
80     : FOR    ${node}    IN    @{COMPUTE-NODE-LIST}
81     \    Utils.Run Command On Remote System    ${node}    ${DELETE_TRANSPORT_ZONE}
82     ${tep_show_output} =    KarafKeywords.Issue Command On Karaf Console    ${TEP_SHOW}
83     BuiltIn.Should Contain    ${tep_show_output}    ${DEFAULT_TRANSPORT_ZONE}
84     BuiltIn.Wait Until Keyword Succeeds    3x    10 sec    Genius.Verify Tunnel Status as UP    ${DEFAULT_TRANSPORT_ZONE}
85     VpnOperations.ITM Delete Tunnel    ${TRANSPORT_ZONE}
86
87 *** Keywords ***
88 Change Transport Zone In Compute
89     [Arguments]    ${compute_ip}    ${zone_name}
90     [Documentation]    Change transport zone in Compute and verify its configuration
91     Utils.Run Command On Remote System    ${compute_ip}    ${CHANGE_TRANSPORT_ZONE}=${zone_name}
92     ${output} =    Utils.Run Command On Remote System    ${compute_ip}    ${GET_EXTERNAL_IDS}
93     BuiltIn.Should Contain    ${output}    ${zone_name}