1b707370d923b8123e91e76e519935d66ef14c3c
[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    OpenStackOperations.OpenStack Suite Setup
4 ...               AND    OvsManager.Check Ovs Version Is Higher Than    ${OVS_VERSION}    @{COMPUTE-NODE-LIST}
5 Suite Teardown    SSHLibrary.Close All Connections
6 Library           OperatingSystem
7 Library           RequestsLibrary
8 Library           String
9 Library           SSHLibrary
10 Resource          ../../libraries/KarafKeywords.robot
11 Resource          ../../libraries/OpenStackOperations.robot
12 Resource          ../../libraries/OVSDB.robot
13 Resource          ../../libraries/OvsManager.robot
14 Resource          ../../libraries/Utils.robot
15 Resource          ../../libraries/VpnOperations.robot
16 Resource          ../../variables/netvirt/Variables.robot
17 Resource          ../../variables/Variables.robot
18
19 *** Variables ***
20 ${CHANGE_TRANSPORT_ZONE}    sudo ovs-vsctl set O . external_ids:transport-zone
21 ${CHANGE_LOCAL_IP}    sudo ovs-vsctl set O . other_config:local_ip
22 ${DATA_FILE}      ${GENIUS_VAR_DIR}/Itm_Auto_Tunnel_Create.json
23 ${DEFAULT_TRANSPORT_ZONE}    default-transport-zone
24 ${DELETE_TRANSPORT_ZONE}    sudo ovs-vsctl remove O . external_ids transport-zone
25 ${GET_EXTERNAL_IDS}    sudo ovsdb-client dump -f list Open_vSwitch | grep external_ids
26 ${GET_NETWORK_TOPOLOGY_URL}    ${OPERATIONAL_API}/network-topology:network-topology/topology/ovsdb:1/
27 ${OVS_VERSION}    2.6
28 ${REMOVE_LOCAL_IP}    sudo ovs-vsctl remove O . other_config local_ip
29 ${SECURITY_GROUP}    itm_vtep_sg
30 ${SHOW_OTHER_CONFIG}    sudo ovsdb-client dump -f list Open_vSwitch | grep other_config
31 ${STATUS_CHECK}    DOWN
32 ${TRANSPORT_ZONE}    TZA
33 ${TRANSPORTZONE_POST_URL}    ${CONFIG_API}/itm:transport-zones
34 @{COMPUTE-NODE-LIST}    ${OS_COMPUTE_1_IP}    ${OS_COMPUTE_2_IP}
35 @{NET_1_VMS}      itm_vm1_1    itm_vm2_2
36 @{NETWORKS}       itm_net1_1    itm_net2_2
37 @{PORTS}          itm_port1_1    itm_port2_2
38 @{SUBNETS}        itm_subnet1_1    itm_subnet2_2
39 @{SUBNET_CIDRS}    10.1.1.0/24    20.1.1.0/24
40
41 *** Test Cases ***
42 Verify TEP in controller and transport zone in OVSDB table of compute nodes
43     [Documentation]    Dump OVSDB table in all compute nodes and Verify ovs version, zone name, tunnel and perform ping across DPN VM’s
44     : FOR    ${ip}    IN    @{COMPUTE-NODE-LIST}
45     \    ${localip} =    OvsManager.Get OVS Local Ip    ${ip}
46     \    ${output} =    Utils.Run Command On Remote System    ${ip}    ${SHOW_OTHER_CONFIG}
47     \    BuiltIn.Should Contain    ${output}    ${localip}
48     ${dpn} =    OVSDB.Get DPID    @{COMPUTE-NODE-LIST}[0]
49     ${dpn} =    BuiltIn.Convert To String    ${dpn}
50     Set Suite Variable    ${DPN1}    ${dpn}
51     ${dpn} =    OVSDB.Get DPID    @{COMPUTE-NODE-LIST}[1]
52     ${dpn} =    BuiltIn.Convert To String    ${dpn}
53     Set Suite Variable    ${DPN2}    ${dpn}
54     @{tep_data} =    BuiltIn.Create List    ${DPN1}    ${DPN2}    ${DEFAULT_TRANSPORT_ZONE}
55     ${itm_data} =    Utils.Get Data From URI    session    ${TRANSPORTZONE_POST_URL}
56     : FOR    ${data}    IN    @{tep_data}
57     \    BuiltIn.Should Contain    ${itm_data}    ${data}
58     ${tep_show_output} =    KarafKeywords.Issue Command On Karaf Console    ${TEP_SHOW_STATE}
59     BuiltIn.Should Not Contain    ${tep_show_output}    ${STATUS_CHECK}
60     BuiltIn.Should Contain    ${tep_show_output}    ${DPN1}
61     BuiltIn.Should Contain    ${tep_show_output}    ${DPN2}
62     OpenStackOperations.Create Allow All SecurityGroup    ${SECURITY_GROUP}
63     OpenStackOperations.Create Network    @{NETWORKS}[0]
64     OpenStackOperations.Create SubNet    @{NETWORKS}[0]    @{SUBNETS}[0]    @{SUBNET_CIDRS}[0]
65     OpenStackOperations.Create Port    @{NETWORKS}[0]    @{PORTS}[0]    sg=${SECURITY_GROUP}
66     OpenStackOperations.Create Port    @{NETWORKS}[0]    @{PORTS}[1]    sg=${SECURITY_GROUP}
67     OpenStackOperations.Create Vm Instance With Port On Compute Node    @{PORTS}[0]    @{NET_1_VMS}[0]    ${OS_CMP1_HOSTNAME}    sg=${SECURITY_GROUP}
68     OpenStackOperations.Create Vm Instance With Port On Compute Node    @{PORTS}[1]    @{NET_1_VMS}[1]    ${OS_CMP2_HOSTNAME}    sg=${SECURITY_GROUP}
69     ${VM1_IP}    ${dhcp1}    ${console} =    BuiltIn.Wait Until Keyword Succeeds    240s    10s    OpenStackOperations.Get VM IP
70     ...    true    @{NET_1_VMS}[0]
71     BuiltIn.Set Suite Variable    ${VM1_IP}
72     ${VM2_IP}    ${dhcp2}    ${console1} =    BuiltIn.Wait Until Keyword Succeeds    240s    10s    OpenStackOperations.Get VM IP
73     ...    true    @{NET_1_VMS}[1]
74     BuiltIn.Set Suite Variable    ${VM2_IP}
75     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    ${VM1_IP}    ping -c ${DEFAULT_PING_COUNT} ${VM2_IP}
76     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
77
78 Verify TEPs with transport zone configured from OVS will be added to corresponding transport zone
79     [Documentation]    To Verify transport zone teps configured from ovs will be added to respective zone with zone name, tunnel type and TEPs part of teps-not-hosted-in-transport-zone
80     Utils.Get Data From URI    session    ${TRANSPORT_ZONE_ENDPOINT_URL}/${DEFAULT_TRANSPORT_ZONE}
81     Change Transport Zone In Compute    @{COMPUTE-NODE-LIST}[0]    ${TRANSPORT_ZONE}
82     ${get_nohosted_data} =    BuiltIn.Wait Until Keyword Succeeds    1 min    5 sec    Utils.Get Data From URI    session    ${TEP_NOT_HOSTED_ZONE_URL}
83     BuiltIn.Should Contain    ${get_nohosted_data}    ${TRANSPORT_ZONE}
84     BuiltIn.Should Contain    ${get_nohosted_data}    ${DPN1}
85     Utils.Post Elements To URI From File    ${TRANSPORTZONE_POST_URL}    ${DATA_FILE}
86     ${get_hosted_data} =    Utils.Get Data From URI    session    ${TRANSPORT_ZONE_ENDPOINT_URL}/${TRANSPORT_ZONE}
87     BuiltIn.Should Contain    ${get_hosted_data}    ${TRANSPORT_ZONE}
88     BuiltIn.Should Contain    ${get_hosted_data}    ${DPN1}
89     Change Transport Zone In Compute    @{COMPUTE-NODE-LIST}[1]    ${TRANSPORT_ZONE}
90     : FOR    ${node}    IN    @{COMPUTE-NODE-LIST}
91     \    ${localip} =    OvsManager.Get OVS Local Ip    ${node}
92     \    ${output} =    Utils.Run Command On Remote System    ${node}    ${SHOW_OTHER_CONFIG}
93     \    BuiltIn.Should Contain    ${output}    ${localip}
94     \    ${output} =    Utils.Run Command On Remote System    ${node}    ${GET_EXTERNAL_IDS}
95     \    BuiltIn.Should Contain    ${output}    ${TRANSPORT_ZONE}
96     ${ip} =    OvsManager.Get OVS Local Ip    @{COMPUTE-NODE-LIST}[0]
97     Set Suite Variable    ${IP1}    ${ip}
98     ${ip} =    OvsManager.Get OVS Local Ip    @{COMPUTE-NODE-LIST}[1]
99     Set Suite Variable    ${IP2}    ${ip}
100     @{tep_data} =    BuiltIn.Create List    ${DPN1}    ${DPN2}    ${TRANSPORT_ZONE}    ${IP1}    ${IP2}
101     ${config_data} =    Utils.Get Data From URI    session    ${TRANSPORT_ZONE_ENDPOINT_URL}/${TRANSPORT_ZONE}
102     : FOR    ${data}    IN    @{tep_data}
103     \    BuiltIn.Should Contain    ${config_data}    ${data}
104
105 Verify other-config-key and transport zone value in controller operational datastore
106     [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
107     ${controller-data} =    Utils.Get Data From URI    session    ${GET_NETWORK_TOPOLOGY_URL}
108     BuiltIn.Should Contain    ${controller-data}    "other-config-value":"${IP1}"
109     BuiltIn.Should Contain    ${controller-data}    "other-config-value":"${IP2}"
110     BuiltIn.Should Contain    ${controller-data}    "external-id-value":"${TRANSPORT_ZONE}"
111
112 Delete transport zone on OVS and check ovsdb update to controller
113     [Documentation]    To verify transport zone moves to tepsNotHostedInTransportZone after deleting in compute and transport zone configuration from Compute added to default-transport-zone
114     : FOR    ${node}    IN    @{COMPUTE-NODE-LIST}
115     \    Utils.Run Command On Remote System    ${node}    ${DELETE_TRANSPORT_ZONE}
116     ${tep_show_output} =    KarafKeywords.Issue Command On Karaf Console    ${TEP_SHOW}
117     BuiltIn.Should Contain    ${tep_show_output}    ${DEFAULT_TRANSPORT_ZONE}
118     VpnOperations.ITM Delete Tunnel    ${TRANSPORT_ZONE}
119     @{tep_data} =    BuiltIn.Create List    ${DPN1}    ${DPN2}    ${IP1}    ${IP2}
120     ${default_zone_data} =    Utils.Get Data From URI    session    ${TRANSPORT_ZONE_ENDPOINT_URL}/${DEFAULT_TRANSPORT_ZONE}
121     BuiltIn.Should Not Contain    ${default_zone_data}    ${TRANSPORT_ZONE}
122     : FOR    ${data}    IN    @{tep_data}
123     \    BuiltIn.Should Contain    ${default_zone_data}    ${data}
124     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    ${VM1_IP}    ping -c ${DEFAULT_PING_COUNT} ${VM2_IP}
125     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
126
127 *** Keywords ***
128 Change Transport Zone In Compute
129     [Arguments]    ${compute_ip}    ${zone_name}
130     [Documentation]    Change transport zone in Compute and verify its configuration
131     Utils.Run Command On Remote System    ${compute_ip}    ${CHANGE_TRANSPORT_ZONE}=${zone_name}
132     ${output} =    Utils.Run Command On Remote System    ${compute_ip}    ${GET_EXTERNAL_IDS}
133     BuiltIn.Should Contain    ${output}    ${zone_name}