Add csit runs with vlan provider
[integration/test.git] / csit / suites / openstack / connectivity / 03_external_network_tests.robot
1 *** Settings ***
2 Documentation     Test suite to check North-South connectivity in L3 using a router and an external network
3 Suite Setup       BuiltIn.Run Keywords    SetupUtils.Setup_Utils_For_Setup_And_Teardown
4 ...               AND    DevstackUtils.Devstack Suite Setup
5 Suite Teardown    Close All Connections
6 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
7 Test Teardown     Get Test Teardown Debugs
8 Library           SSHLibrary
9 Library           OperatingSystem
10 Library           RequestsLibrary
11 Resource          ../../../libraries/DevstackUtils.robot
12 Resource          ../../../libraries/OpenStackOperations.robot
13 Resource          ../../../libraries/SetupUtils.robot
14 Resource          ../../../libraries/Utils.robot
15
16 *** Variables ***
17 @{NETWORKS_NAME}    l3_net
18 @{SUBNETS_NAME}    l3_subnet
19 @{VM_INSTANCES_FLOATING}    VmInstanceFloating1    VmInstanceFloating2
20 @{VM_INSTANCES_SNAT}    VmInstanceSnat3    VmInstanceSnat4
21 @{SUBNETS_RANGE}    90.0.0.0/24
22 ${external_gateway}    10.10.10.250
23 ${external_subnet}    10.10.10.0/24
24 ${external_net_name}    external-net
25 ${external_subnet_name}    external-subnet
26 ${network1_vlan_id}    167
27
28 *** Test Cases ***
29 Create All Controller Sessions
30     [Documentation]    Create sessions for all three controllers
31     ClusterManagement.ClusterManagement Setup
32
33 Create Private Network
34     [Documentation]    Create Network with neutron request.
35     : FOR    ${NetworkElement}    IN    @{NETWORKS_NAME}
36     \    OpenStackOperations.Create Network    ${NetworkElement}
37
38 Create Subnet For Private Network
39     [Documentation]    Create Sub Nets for the Networks with neutron request.
40     OpenStackOperations.Create SubNet    @{NETWORKS_NAME}[0]    @{SUBNETS_NAME}[0]    @{SUBNETS_RANGE}[0]
41
42 Create Vm Instances
43     [Documentation]    Create VM instances using flavor and image names for a network.
44     OpenStackOperations.Create Vm Instances    @{NETWORKS_NAME}[0]    ${VM_INSTANCES_FLOATING}    sg=csit
45     OpenStackOperations.Create Vm Instances    @{NETWORKS_NAME}[0]    ${VM_INSTANCES_SNAT}    sg=csit
46
47 Check Vm Instances Have Ip Address
48     [Documentation]    Test case to verify that all created VMs are ready and have received their ip addresses.
49     ...    We are polling first and longest on the last VM created assuming that if it's received it's address
50     ...    already the other instances should have theirs already or at least shortly thereafter.
51     # first, ensure all VMs are in ACTIVE state.    if not, we can just fail the test case and not waste time polling
52     # for dhcp addresses
53     : FOR    ${vm}    IN    @{VM_INSTANCES_FLOATING}    @{VM_INSTANCES_SNAT}
54     \    Wait Until Keyword Succeeds    15s    5s    Verify VM Is ACTIVE    ${vm}
55     ${FLOATING_VM_COUNT}    Get Length    ${VM_INSTANCES_FLOATING}
56     ${SNAT_VM_COUNT}    Get Length    ${VM_INSTANCES_SNAT}
57     ${LOOP_COUNT}    Evaluate    ${FLOATING_VM_COUNT}+${SNAT_VM_COUNT}
58     : FOR    ${index}    IN RANGE    1    ${LOOP_COUNT}
59     \    ${FLOATING_VM_IPS}    @{FLOATING_DHCP_IP}    Wait Until Keyword Succeeds    180s    10s    Verify VMs Received DHCP Lease
60     \    ...    @{VM_INSTANCES_FLOATING}
61     \    ${SNAT_VM_IPS}    @{SNAT_DHCP_IP}    Wait Until Keyword Succeeds    180s    10s    Verify VMs Received DHCP Lease
62     \    ...    @{VM_INSTANCES_SNAT}
63     \    ${FLOATING_VM_LIST_LENGTH}=    Get Length    ${FLOATING_VM_IPS}
64     \    ${SNAT_VM_LIST_LENGTH}=    Get Length    ${SNAT_VM_IPS}
65     \    Exit For Loop If    ${FLOATING_VM_LIST_LENGTH}==${FLOATING_VM_COUNT} and ${SNAT_VM_LIST_LENGTH}==${SNAT_VM_COUNT}
66     Append To List    ${FLOATING_VM_IPS}    @{FLOATING_DHCP_IP}[0]
67     Set Suite Variable    ${FLOATING_VM_IPS}
68     Append To List    ${SNAT_VM_IPS}    @{SNAT_DHCP_IP}[0]
69     Set Suite Variable    ${SNAT_VM_IPS}
70     Should Not Contain    ${FLOATING_VM_IPS}    None
71     Should Not Contain    ${SNAT_VM_IPS}    None
72     [Teardown]    Run Keywords    Show Debugs    ${VM_INSTANCES_FLOATING}    ${VM_INSTANCES_SNAT}
73     ...    AND    Get Test Teardown Debugs
74
75 Create External Network And Subnet
76     Create Network    ${external_net_name} --router:external --provider:network_type=vlan --provider:physical_network=${PUBLIC_PHYSICAL_NETWORK} --provider:segmentation_id=${network1_vlan_id}
77     Create Subnet    ${external_net_name}    ${external_subnet_name}    ${external_subnet}    --gateway ${external_gateway}
78
79 Create Router
80     [Documentation]    Create Router and Add Interface to the subnets.
81     OpenStackOperations.Create Router    router1
82
83 Add Interfaces To Router
84     [Documentation]    Add Interfaces
85     : FOR    ${interface}    IN    @{SUBNETS_NAME}
86     \    OpenStackOperations.Add Router Interface    router1    ${interface}
87
88 Add Router Gateway To Router
89     [Documentation]    Add Router Gateway
90     OpenStackOperations.Add Router Gateway    router1    ${external_net_name}
91
92 Verify Created Routers
93     [Documentation]    Check created routers using northbound rest calls
94     ${data}    Utils.Get Data From URI    1    ${NEUTRON_ROUTERS_API}
95     Log    ${data}
96     Should Contain    ${data}    router1
97
98 Create And Associate Floating IPs for VMs
99     [Documentation]    Create and associate a floating IP for the VM
100     ${VM_FLOATING_IPS}    OpenStackOperations.Create And Associate Floating IPs    ${external_net_name}    @{VM_INSTANCES_FLOATING}
101     Set Suite Variable    ${VM_FLOATING_IPS}
102     [Teardown]    Run Keywords    Show Debugs    ${VM_INSTANCES_FLOATING}
103     ...    AND    Get Test Teardown Debugs
104
105 Ping External Gateway From Control Node
106     [Documentation]    Check reachability of external gateway by pinging it from the control node.
107     OpenStackOperations.Ping Vm From Control Node    ${external_gateway}
108
109 Ping Vm Instance1 Floating IP From Control Node
110     [Documentation]    Check reachability of VM instance through floating IP by pinging them.
111     OpenStackOperations.Ping Vm From Control Node    @{VM_FLOATING_IPS}[0]
112
113 Ping Vm Instance2 Floating IP From Control Node
114     [Documentation]    Check reachability of VM instance through floating IP by pinging them.
115     OpenStackOperations.Ping Vm From Control Node    @{VM_FLOATING_IPS}[1]
116
117 Prepare SNAT - Install Netcat On Controller
118     Install Netcat On Controller
119
120 SNAT - TCP connection to External Gateway From SNAT VM Instance1
121     [Documentation]    Login to the VM instance and test TCP connection to the controller via SNAT
122     Test Netcat Operations From Vm Instance    @{NETWORKS_NAME}[0]    @{SNAT_VM_IPS}[0]    ${external_gateway}
123
124 SNAT - UDP connection to External Gateway From SNAT VM Instance1
125     [Documentation]    Login to the VM instance and test UDP connection to the controller via SNAT
126     Test Netcat Operations From Vm Instance    @{NETWORKS_NAME}[0]    @{SNAT_VM_IPS}[0]    ${external_gateway}    -u
127
128 SNAT - TCP connection to External Gateway From SNAT VM Instance2
129     [Documentation]    Login to the VM instance and test TCP connection to the controller via SNAT
130     Test Netcat Operations From Vm Instance    @{NETWORKS_NAME}[0]    @{SNAT_VM_IPS}[1]    ${external_gateway}
131
132 SNAT - UDP connection to External Gateway From SNAT VM Instance2
133     [Documentation]    Login to the VM instance and test UDP connection to the controller via SNAT
134     Test Netcat Operations From Vm Instance    @{NETWORKS_NAME}[0]    @{SNAT_VM_IPS}[1]    ${external_gateway}    -u
135
136 Delete Vm Instances
137     [Documentation]    Delete Vm instances using instance names.
138     : FOR    ${VmElement}    IN    @{VM_INSTANCES_FLOATING}
139     \    OpenStackOperations.Delete Vm Instance    ${VmElement}
140     : FOR    ${VmElement}    IN    @{VM_INSTANCES_SNAT}
141     \    OpenStackOperations.Delete Vm Instance    ${VmElement}
142
143 Delete Router Interfaces
144     [Documentation]    Remove Interface to the subnets.
145     : FOR    ${interface}    IN    @{SUBNETS_NAME}
146     \    OpenStackOperations.Remove Interface    router1    ${interface}
147
148 Delete Routers
149     [Documentation]    Delete Router and Interface to the subnets.
150     OpenStackOperations.Delete Router    router1
151
152 Verify Deleted Routers
153     [Documentation]    Check deleted routers using northbound rest calls
154     ${data}    Utils.Get Data From URI    1    ${NEUTRON_ROUTERS_API}
155     Log    ${data}
156     Should Not Contain    ${data}    router1
157
158 Delete Sub Networks
159     [Documentation]    Delete Sub Nets for the Networks with neutron request.
160     OpenStackOperations.Delete SubNet    @{SUBNETS_NAME}[0]
161
162 Delete Networks
163     [Documentation]    Delete Networks with neutron request.
164     : FOR    ${NetworkElement}    IN    @{NETWORKS_NAME}
165     \    OpenStackOperations.Delete Network    ${NetworkElement}
166     OpenStackOperations.Delete Network    ${external_net_name}