87bae3c43a79e17c777a1cc20cb76bfe3b54a5e2
[integration/test.git] / csit / suites / netvirt / Netvirt_Vpnservice / 02_bgp_vpnservice.robot
1 *** Settings ***
2 Documentation     Test suite to validate BGP vpnservice functionality in an openstack integrated environment.
3 ...               The assumption of this suite is that the environment is already configured with the proper
4 ...               integration bridges and vxlan tunnels.
5 Suite Setup       BGP Vpnservice Suite Setup
6 Suite Teardown    BGP Vpnservice Suite Teardown
7 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
8 Test Teardown     Get Test Teardown Debugs
9 Library           OperatingSystem
10 Library           RequestsLibrary
11 Resource          ../../../libraries/Utils.robot
12 Resource          ../../../libraries/OpenStackOperations.robot
13 Resource          ../../../libraries/DevstackUtils.robot
14 Resource          ../../../libraries/VpnOperations.robot
15 Resource          ../../../libraries/OVSDB.robot
16 Resource          ../../../libraries/SetupUtils.robot
17 Resource          ../../../libraries/BgpOperations.robot
18 Resource          ../../../variables/Variables.robot
19 Resource          ../../../variables/netvirt/Variables.robot
20
21 *** Variables ***
22 @{NETWORKS}       NET101    NET102    NET103    NET104
23 @{SUBNETS}        SUBNET101    SUBNET102    SUBNET103    SUBNET104
24 @{SUBNET_CIDR}    101.1.1.0/8    102.1.1.0/16    103.1.1.0/24    104.1.1.0/24
25 @{PORTS}          PORT101    PORT102    PORT103    PORT104
26 @{VM_NAMES}       VM101    VM102    VM103    VM104
27 @{VPN_INSTANCE_IDS}    4ae8cd92-48ca-49b5-94e1-b2921a261111    4ae8cd92-48ca-49b5-94e1-b2921a261112
28 @{RD_LIST}        ["2200:2"]    ["2300:2"]
29 @{VPN_NAMES}      vpn101    vpn102
30 ${LOOPBACK_IP}    5.5.5.2
31 ${DCGW_SYSTEM_IP}    ${TOOLS_SYSTEM_1_IP}
32 ${AS_ID}          500
33 ${DCGW_RD}        2200:2
34 ${SECURITY_GROUP}    sg-vpnservice-bgp
35
36 *** Test Cases ***
37 Create BGP Config On ODL
38     [Documentation]    Create BGP Config on ODL
39     Create BGP Configuration On ODL    localas=${AS_ID}    routerid=${ODL_SYSTEM_IP}
40     AddNeighbor To BGP Configuration On ODL    remoteas=${AS_ID}    neighborAddr=${DCGW_SYSTEM_IP}
41     ${output} =    Get BGP Configuration On ODL    session
42     Log    ${output}
43     Should Contain    ${output}    ${DCGW_SYSTEM_IP}
44
45 Create BGP Config On DCGW
46     [Documentation]    Configure BGP Config on DCGW
47     Configure BGP And Add Neighbor On DCGW    ${DCGW_SYSTEM_IP}    ${AS_ID}    ${DCGW_SYSTEM_IP}    ${ODL_SYSTEM_IP}    ${VPN_NAMES[0]}    ${DCGW_RD}
48     ...    ${LOOPBACK_IP}
49     Add Loopback Interface On DCGW    ${DCGW_SYSTEM_IP}    lo    ${LOOPBACK_IP}
50     ${output} =    Execute Show Command On Quagga    ${DCGW_SYSTEM_IP}    show running-config
51     Log    ${output}
52     Should Contain    ${output}    ${ODL_SYSTEM_IP}
53
54 Verify BGP Neighbor Status
55     [Documentation]    Verify BGP status established
56     ${output} =    Wait Until Keyword Succeeds    60s    10s    Verify BGP Neighbor Status On Quagga    ${DCGW_SYSTEM_IP}    ${ODL_SYSTEM_IP}
57     Log    ${output}
58     ${output1} =    Execute Show Command On Quagga    ${DCGW_SYSTEM_IP}    show ip bgp vrf ${DCGW_RD}
59     Log    ${output1}
60     Should Contain    ${output1}    ${LOOPBACK_IP}
61
62 Create External Tunnel Endpoint
63     [Documentation]    Create and verify external tunnel endpoint between ODL and GWIP
64     Create External Tunnel Endpoint Configuration    destIp=${DCGW_SYSTEM_IP}
65     ${output} =    Get External Tunnel Endpoint Configuration    ${DCGW_SYSTEM_IP}
66     Should Contain    ${output}    ${DCGW_SYSTEM_IP}
67
68 Verify Routes Exchange Between ODL And DCGW
69     [Documentation]    Verify routes exchange between ODL and DCGW
70     ${fib_values} =    Create List    ${LOOPBACK_IP}    @{VM_IPS}
71     Wait Until Keyword Succeeds    60s    5s    Check For Elements At URI    ${CONFIG_API}/odl-fib:fibEntries/vrfTables/${DCGW_RD}/    ${fib_values}
72     Wait Until Keyword Succeeds    60s    5s    Verify Routes On Quagga    ${DCGW_SYSTEM_IP}    ${DCGW_RD}    ${fib_values}
73     [Teardown]    Run Keywords    Report_Failure_Due_To_Bug    7607
74     ...    AND    Get Test Teardown Debugs
75
76 Delete External Tunnel Endpoint
77     [Documentation]    Delete external tunnel endpoint
78     Delete External Tunnel Endpoint Configuration    destIp=${DCGW_SYSTEM_IP}
79     ${output} =    Get External Tunnel Endpoint Configuration    ${DCGW_SYSTEM_IP}
80     Should Not Contain    ${output}    ${DCGW_SYSTEM_IP}
81
82 Delete BGP Config On ODL
83     [Documentation]    Delete BGP Configuration on ODL
84     Delete BGP Configuration On ODL    session
85     ${output} =    Get BGP Configuration On ODL    session
86     Log    ${output}
87     Should Not Contain    ${output}    ${DCGW_SYSTEM_IP}
88     Run Command On Remote System    ${ODL_SYSTEM_IP}    sudo cp /opt/quagga/var/log/quagga/zrpcd.init.log /tmp/
89
90 Delete BGP Config On DCGW
91     [Documentation]    Delete BGP Configuration on DCGW
92     ${output} =    Delete BGP Config On Quagga    ${DCGW_SYSTEM_IP}    ${AS_ID}
93     Log    ${output}
94     Should Not Contain    ${output}    ${ODL_SYSTEM_IP}
95
96 *** Keywords ***
97 BGP Vpnservice Suite Setup
98     SetupUtils.Setup_Utils_For_Setup_And_Teardown
99     DevstackUtils.Devstack Suite Setup
100     Create And Configure Security Group    ${SECURITY_GROUP}
101     Start Quagga Processes On ODL    ${ODL_SYSTEM_IP}
102     Start Quagga Processes On DCGW    ${DCGW_SYSTEM_IP}
103     Create Basic Configuartion for BGP VPNservice Suite
104
105 BGP Vpnservice Suite Teardown
106     Delete Basic Configuartion for BGP VPNservice Suite
107     Delete SecurityGroup    ${SECURITY_GROUP}
108     Close All Connections
109
110 Create Basic Configuartion for BGP VPNservice Suite
111     [Documentation]    Create basic configuration for BGP VPNservice suite
112     Start Quagga Processes On ODL    ${ODL_SYSTEM_IP}
113     : FOR    ${Network}    IN    @{NETWORKS}
114     \    Create Network    ${Network}
115     Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${NETWORK_URL}    ${NETWORKS}
116     ${length}=    Get Length    ${SUBNETS}
117     : FOR    ${idx}    IN RANGE    ${length}
118     \    Create SubNet    ${NETWORKS[${idx}]}    ${SUBNETS[${idx}]}    ${SUBNET_CIDR[${idx}]}
119     Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${SUBNETWORK_URL}    ${SUBNETS}
120     : FOR    ${network}    ${port}    IN ZIP    ${NETWORKS}    ${PORTS}
121     \    Create Port    ${network}    ${port}    sg=${SECURITY_GROUP}
122     Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${PORT_URL}    ${PORTS}
123     Create Vm Instance With Port On Compute Node    ${PORTS[0]}    ${VM_NAMES[0]}    ${OS_COMPUTE_1_IP}    sg=${SECURITY_GROUP}
124     Create Vm Instance With Port On Compute Node    ${PORTS[1]}    ${VM_NAMES[1]}    ${OS_COMPUTE_1_IP}    sg=${SECURITY_GROUP}
125     Create Vm Instance With Port On Compute Node    ${PORTS[2]}    ${VM_NAMES[2]}    ${OS_COMPUTE_2_IP}    sg=${SECURITY_GROUP}
126     Create Vm Instance With Port On Compute Node    ${PORTS[3]}    ${VM_NAMES[3]}    ${OS_COMPUTE_2_IP}    sg=${SECURITY_GROUP}
127     : FOR    ${VM}    IN    @{VM_NAMES}
128     \    Poll VM Is ACTIVE    ${VM}
129     ${VM_IPS}    ${DHCP_IPS}    Wait Until Keyword Succeeds    30s    10s    Collect VM IP Addresses    true
130     ...    @{VM_NAMES}
131     Log    ${VM_IPS}
132     Set Suite Variable    ${VM_IPS}
133     ${net_id} =    Get Net Id    @{NETWORKS}[0]    ${devstack_conn_id}
134     ${tenant_id} =    Get Tenant ID From Network    ${net_id}
135     VPN Create L3VPN    vpnid=${VPN_INSTANCE_IDS[0]}    name=${VPN_NAMES[0]}    rd=${RD_LIST[0]}    exportrt=${RD_LIST[0]}    importrt=${RD_LIST[0]}    tenantid=${tenant_id}
136     : FOR    ${network}    IN    @{NETWORKS}
137     \    ${network_id} =    Get Net Id    ${network}    ${devstack_conn_id}
138     \    Associate L3VPN To Network    networkid=${network_id}    vpnid=${VPN_INSTANCE_IDS[0]}
139     ${resp} =    VPN Get L3VPN    vpnid=${VPN_INSTANCE_IDS[0]}
140     Log    ${resp}
141
142 Delete Basic Configuartion for BGP VPNservice Suite
143     [Documentation]    Delete basic configuration for BGP Vpnservice suite
144     : FOR    ${network}    IN    @{NETWORKS}
145     \    ${network_id} =    Get Net Id    ${network}    ${devstack_conn_id}
146     \    Dissociate L3VPN From Networks    networkid=${network_id}    vpnid=${VPN_INSTANCE_IDS[0]}
147     VPN Delete L3VPN    vpnid=${VPN_INSTANCE_IDS[0]}
148     : FOR    ${vmName}    IN    @{VM_NAMES}
149     \    Delete Vm Instance    ${vmName}
150     : FOR    ${port}    IN    @{PORTS}
151     \    Delete Port    ${port}
152     : FOR    ${Subnet}    IN    @{SUBNETS}
153     \    Delete SubNet    ${Subnet}
154     : FOR    ${Network}    IN    @{NETWORKS}
155     \    Delete Network    ${Network}