Add External Network PNF Tests
[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 # Parameter values below are based on releng/builder - changing them requires updates in releng/builder as well
23 ${external_gateway}    10.10.10.250
24 ${external_pnf}    10.10.10.253
25 ${external_subnet}    10.10.10.0/24
26 ${external_subnet_allocation_pool}    start=10.10.10.2,end=10.10.10.249
27 ${external_internet_addr}    10.9.9.9
28 ${external_net_name}    external-net
29 ${external_subnet_name}    external-subnet
30 ${network1_vlan_id}    167
31
32 *** Test Cases ***
33 Create All Controller Sessions
34     [Documentation]    Create sessions for all three controllers
35     ClusterManagement.ClusterManagement Setup
36
37 Create Private Network
38     [Documentation]    Create Network with neutron request.
39     : FOR    ${NetworkElement}    IN    @{NETWORKS_NAME}
40     \    OpenStackOperations.Create Network    ${NetworkElement}
41
42 Create Subnet For Private Network
43     [Documentation]    Create Sub Nets for the Networks with neutron request.
44     OpenStackOperations.Create SubNet    @{NETWORKS_NAME}[0]    @{SUBNETS_NAME}[0]    @{SUBNETS_RANGE}[0]
45
46 Create Vm Instances
47     [Documentation]    Create VM instances using flavor and image names for a network.
48     OpenStackOperations.Create Vm Instances    @{NETWORKS_NAME}[0]    ${VM_INSTANCES_FLOATING}    sg=csit
49     OpenStackOperations.Create Vm Instances    @{NETWORKS_NAME}[0]    ${VM_INSTANCES_SNAT}    sg=csit
50
51 Check Vm Instances Have Ip Address
52     [Documentation]    Test case to verify that all created VMs are ready and have received their ip addresses.
53     ...    We are polling first and longest on the last VM created assuming that if it's received it's address
54     ...    already the other instances should have theirs already or at least shortly thereafter.
55     # first, ensure all VMs are in ACTIVE state.    if not, we can just fail the test case and not waste time polling
56     # for dhcp addresses
57     : FOR    ${vm}    IN    @{VM_INSTANCES_FLOATING}    @{VM_INSTANCES_SNAT}
58     \    Wait Until Keyword Succeeds    15s    5s    Verify VM Is ACTIVE    ${vm}
59     ${status}    ${message}    Run Keyword And Ignore Error    Wait Until Keyword Succeeds    60s    5s    Collect VM IP Addresses
60     ...    true    @{VM_INSTANCES_FLOATING}
61     ${status}    ${message}    Run Keyword And Ignore Error    Wait Until Keyword Succeeds    60s    5s    Collect VM IP Addresses
62     ...    true    @{VM_INSTANCES_SNAT}
63     ${FLOATING_VM_IPS}    ${FLOATING_DHCP_IP}    Collect VM IP Addresses    false    @{VM_INSTANCES_FLOATING}
64     ${SNAT_VM_IPS}    ${SNAT_DHCP_IP}    Collect VM IP Addresses    false    @{VM_INSTANCES_SNAT}
65     ${VM_INSTANCES}=    Collections.Combine Lists    ${VM_INSTANCES_FLOATING}    ${VM_INSTANCES_SNAT}
66     ${VM_IPS}=    Collections.Combine Lists    ${FLOATING_VM_IPS}    ${SNAT_VM_IPS}
67     ${LOOP_COUNT}    Get Length    ${VM_INSTANCES}
68     : FOR    ${index}    IN RANGE    0    ${LOOP_COUNT}
69     \    ${status}    ${message}    Run Keyword And Ignore Error    Should Not Contain    @{VM_IPS}[${index}]    None
70     \    Run Keyword If    '${status}' == 'FAIL'    Write Commands Until Prompt    nova console-log @{VM_INSTANCES}[${index}]    30s
71     Set Suite Variable    ${FLOATING_VM_IPS}
72     Set Suite Variable    ${SNAT_VM_IPS}
73     Should Not Contain    ${FLOATING_VM_IPS}    None
74     Should Not Contain    ${SNAT_VM_IPS}    None
75     Should Not Contain    @{FLOATING_DHCP_IP}[0]    None
76     Should Not Contain    @{SNAT_DHCP_IP}[0]    None
77     [Teardown]    Run Keywords    Show Debugs    @{VM_INSTANCES_FLOATING}    @{VM_INSTANCES_SNAT}
78     ...    AND    Get Test Teardown Debugs
79
80 Create External Network And Subnet
81     Create Network    ${external_net_name} --router:external --provider:network_type=vlan --provider:physical_network=${PUBLIC_PHYSICAL_NETWORK} --provider:segmentation_id=${network1_vlan_id}
82     Create Subnet    ${external_net_name}    ${external_subnet_name}    ${external_subnet}    --gateway ${external_gateway} --allocation-pool ${external_subnet_allocation_pool}
83
84 Create Router
85     [Documentation]    Create Router and Add Interface to the subnets.
86     OpenStackOperations.Create Router    router1
87
88 Add Interfaces To Router
89     [Documentation]    Add Interfaces
90     : FOR    ${interface}    IN    @{SUBNETS_NAME}
91     \    OpenStackOperations.Add Router Interface    router1    ${interface}
92
93 Add Router Gateway To Router
94     [Documentation]    Add Router Gateway
95     OpenStackOperations.Add Router Gateway    router1    ${external_net_name}
96
97 Verify Created Routers
98     [Documentation]    Check created routers using northbound rest calls
99     ${data}    Utils.Get Data From URI    1    ${NEUTRON_ROUTERS_API}
100     Log    ${data}
101     Should Contain    ${data}    router1
102
103 Create And Associate Floating IPs for VMs
104     [Documentation]    Create and associate a floating IP for the VM
105     ${VM_FLOATING_IPS}    OpenStackOperations.Create And Associate Floating IPs    ${external_net_name}    @{VM_INSTANCES_FLOATING}
106     Set Suite Variable    ${VM_FLOATING_IPS}
107     [Teardown]    Run Keywords    Show Debugs    @{VM_INSTANCES_FLOATING}
108     ...    AND    Get Test Teardown Debugs
109
110 Ping External Gateway From Control Node
111     [Documentation]    Check reachability of external gateway by pinging it from the control node.
112     OpenStackOperations.Ping Vm From Control Node    ${external_gateway}    additional_args=-I ${external_internet_addr}
113
114 Ping Vm Instance1 Floating IP From Control Node
115     [Documentation]    Check reachability of VM instance through floating IP by pinging them.
116     OpenStackOperations.Ping Vm From Control Node    @{VM_FLOATING_IPS}[0]    additional_args=-I ${external_internet_addr}
117
118 Ping Vm Instance2 Floating IP From Control Node
119     [Documentation]    Check reachability of VM instance through floating IP by pinging them.
120     OpenStackOperations.Ping Vm From Control Node    @{VM_FLOATING_IPS}[1]    additional_args=-I ${external_internet_addr}
121
122 Ping External Network PNF from Vm Instance 1
123     [Documentation]    Check reachability of External Network PNF from VM instance (with ttl=1 to make sure no router hops)
124     Pass Execution If    "${ODL_STREAM}" == "boron"    PNF subnet route support is not available in boron or earlier
125     ${dst_ip}=    Create List    ${external_pnf}
126     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS_NAME}[0]    @{FLOATING_VM_IPS}[0]    ${dst_ip}    ttl=1
127
128 Prepare SNAT - Install Netcat On Controller
129     Install Netcat On Controller
130
131 SNAT - TCP connection to External Gateway From SNAT VM Instance1
132     [Documentation]    Login to the VM instance and test TCP connection to the controller via SNAT
133     Test Netcat Operations From Vm Instance    @{NETWORKS_NAME}[0]    @{SNAT_VM_IPS}[0]    ${external_gateway}
134
135 SNAT - UDP connection to External Gateway From SNAT VM Instance1
136     [Documentation]    Login to the VM instance and test UDP connection to the controller via SNAT
137     Test Netcat Operations From Vm Instance    @{NETWORKS_NAME}[0]    @{SNAT_VM_IPS}[0]    ${external_gateway}    -u
138
139 SNAT - TCP connection to External Gateway From SNAT VM Instance2
140     [Documentation]    Login to the VM instance and test TCP connection to the controller via SNAT
141     Test Netcat Operations From Vm Instance    @{NETWORKS_NAME}[0]    @{SNAT_VM_IPS}[1]    ${external_gateway}
142
143 SNAT - UDP connection to External Gateway From SNAT VM Instance2
144     [Documentation]    Login to the VM instance and test UDP connection to the controller via SNAT
145     Test Netcat Operations From Vm Instance    @{NETWORKS_NAME}[0]    @{SNAT_VM_IPS}[1]    ${external_gateway}    -u
146
147 Delete Vm Instances
148     [Documentation]    Delete Vm instances using instance names.
149     : FOR    ${VmElement}    IN    @{VM_INSTANCES_FLOATING}
150     \    OpenStackOperations.Delete Vm Instance    ${VmElement}
151     : FOR    ${VmElement}    IN    @{VM_INSTANCES_SNAT}
152     \    OpenStackOperations.Delete Vm Instance    ${VmElement}
153
154 Delete Router Interfaces
155     [Documentation]    Remove Interface to the subnets.
156     : FOR    ${interface}    IN    @{SUBNETS_NAME}
157     \    OpenStackOperations.Remove Interface    router1    ${interface}
158
159 Delete Routers
160     [Documentation]    Delete Router and Interface to the subnets.
161     OpenStackOperations.Delete Router    router1
162
163 Verify Deleted Routers
164     [Documentation]    Check deleted routers using northbound rest calls
165     ${data}    Utils.Get Data From URI    1    ${NEUTRON_ROUTERS_API}
166     Log    ${data}
167     Should Not Contain    ${data}    router1
168
169 Delete Sub Networks
170     [Documentation]    Delete Sub Nets for the Networks with neutron request.
171     OpenStackOperations.Delete SubNet    @{SUBNETS_NAME}[0]
172
173 Delete Networks
174     [Documentation]    Delete Networks with neutron request.
175     : FOR    ${NetworkElement}    IN    @{NETWORKS_NAME}
176     \    OpenStackOperations.Delete Network    ${NetworkElement}
177     OpenStackOperations.Delete Network    ${external_net_name}