Skip vlan network in tempest if legacy-netvirt
[integration/test.git] / csit / suites / openstack / connectivity / 01_l2_tests.robot
1 *** Settings ***
2 Documentation     Test suite to verify packet flows between vm instances.
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 Resource          ../../../libraries/KarafKeywords.robot
16 Resource          ../../../variables/netvirt/Variables.robot
17
18 *** Variables ***
19 @{NETWORKS_NAME}    l2_network_1    l2_network_2
20 @{SUBNETS_NAME}    l2_subnet_1    l2_subnet_2
21 @{NET_1_VM_INSTANCES}    MyFirstInstance_1    MySecondInstance_1    MyThirdInstance_1
22 @{NET_2_VM_INSTANCES}    MyFirstInstance_2    MySecondInstance_2    MyThirdInstance_2
23 @{SUBNETS_RANGE}    30.0.0.0/24    40.0.0.0/24
24 ${network1_vlan_id}    1235
25
26 *** Test Cases ***
27 Create VLAN Network (l2_network_1)
28     [Documentation]    Create Network with neutron request.
29     # in the case that the controller under test is using legacy netvirt features, vlan segmentation is not supported,
30     # and we cannot create a vlan network. If those features are installed we will instead stick with vxlan.
31     : FOR    ${feature_name}    IN    @{legacy_feature_list}
32     \    ${feature_check_status}=    Run Keyword And Return Status    Verify Feature Is Installed    ${feature_name}
33     \    Exit For Loop If    '${feature_check_status}' == 'True'
34     Run Keyword If    '${feature_check_status}' == 'True'    Create Network    @{NETWORKS_NAME}[0]
35     ...    ELSE    Create Network    @{NETWORKS_NAME}[0]    --provider:network_type=vlan --provider:physical_network=${PUBLIC_PHYSICAL_NETWORK} --provider:segmentation_id=${network1_vlan_id}
36
37 Create VXLAN Network (l2_network_2)
38     [Documentation]    Create Network with neutron request.
39     Create Network    @{NETWORKS_NAME}[1]
40
41 Create Subnets For l2_network_1
42     [Documentation]    Create Sub Nets for the Networks with neutron request.
43     Create SubNet    @{NETWORKS_NAME}[0]    @{SUBNETS_NAME}[0]    @{SUBNETS_RANGE}[0]
44
45 Create Subnets For l2_network_2
46     [Documentation]    Create Sub Nets for the Networks with neutron request.
47     Create SubNet    @{NETWORKS_NAME}[1]    @{SUBNETS_NAME}[1]    @{SUBNETS_RANGE}[1]
48
49 Add Ssh Allow Rule
50     [Documentation]    Allow all TCP/UDP/ICMP packets for this suite
51     Neutron Security Group Create    csit
52     Neutron Security Group Rule Create    csit    direction=ingress    port_range_max=65535    port_range_min=1    protocol=tcp    remote_ip_prefix=0.0.0.0/0
53     Neutron Security Group Rule Create    csit    direction=egress    port_range_max=65535    port_range_min=1    protocol=tcp    remote_ip_prefix=0.0.0.0/0
54     Neutron Security Group Rule Create    csit    direction=ingress    protocol=icmp    remote_ip_prefix=0.0.0.0/0
55     Neutron Security Group Rule Create    csit    direction=egress    protocol=icmp    remote_ip_prefix=0.0.0.0/0
56     Neutron Security Group Rule Create    csit    direction=ingress    port_range_max=65535    port_range_min=1    protocol=udp    remote_ip_prefix=0.0.0.0/0
57     Neutron Security Group Rule Create    csit    direction=egress    port_range_max=65535    port_range_min=1    protocol=udp    remote_ip_prefix=0.0.0.0/0
58
59 Create Vm Instances For l2_network_1
60     [Documentation]    Create Four Vm instances using flavor and image names for a network.
61     Create Vm Instances    l2_network_1    ${NET_1_VM_INSTANCES}    sg=csit
62
63 Create Vm Instances For l2_network_2
64     [Documentation]    Create Four Vm instances using flavor and image names for a network.
65     Create Vm Instances    l2_network_2    ${NET_2_VM_INSTANCES}    sg=csit
66
67 Check Vm Instances Have Ip Address
68     [Documentation]    Test case to verify that all created VMs are ready and have received their ip addresses.
69     ...    We are polling first and longest on the last VM created assuming that if it's received it's address
70     ...    already the other instances should have theirs already or at least shortly thereafter.
71     # first, ensure all VMs are in ACTIVE state.    if not, we can just fail the test case and not waste time polling
72     # for dhcp addresses
73     : FOR    ${vm}    IN    @{NET_1_VM_INSTANCES}    @{NET_2_VM_INSTANCES}
74     \    Wait Until Keyword Succeeds    15s    5s    Verify VM Is ACTIVE    ${vm}
75     ${status}    ${message}    Run Keyword And Ignore Error    Wait Until Keyword Succeeds    60s    5s    Collect VM IP Addresses
76     ...    true    @{NET_1_VM_INSTANCES}
77     ${status}    ${message}    Run Keyword And Ignore Error    Wait Until Keyword Succeeds    60s    5s    Collect VM IP Addresses
78     ...    true    @{NET_2_VM_INSTANCES}
79     ${NET1_VM_IPS}    ${NET1_DHCP_IP}    Collect VM IP Addresses    false    @{NET_1_VM_INSTANCES}
80     ${NET2_VM_IPS}    ${NET2_DHCP_IP}    Collect VM IP Addresses    false    @{NET_2_VM_INSTANCES}
81     ${VM_INSTANCES}=    Collections.Combine Lists    ${NET_1_VM_INSTANCES}    ${NET_2_VM_INSTANCES}
82     ${VM_IPS}=    Collections.Combine Lists    ${NET1_VM_IPS}    ${NET2_VM_IPS}
83     ${LOOP_COUNT}    Get Length    ${VM_INSTANCES}
84     : FOR    ${index}    IN RANGE    0    ${LOOP_COUNT}
85     \    ${status}    ${message}    Run Keyword And Ignore Error    Should Not Contain    @{VM_IPS}[${index}]    None
86     \    Run Keyword If    '${status}' == 'FAIL'    Write Commands Until Prompt    nova console-log @{VM_INSTANCES}[${index}]    30s
87     Set Suite Variable    ${NET1_VM_IPS}
88     Set Suite Variable    ${NET2_VM_IPS}
89     Should Not Contain    ${NET1_VM_IPS}    None
90     Should Not Contain    ${NET2_VM_IPS}    None
91     Should Not Contain    ${NET1_DHCP_IP}    None
92     Should Not Contain    ${NET2_DHCP_IP}    None
93     [Teardown]    Run Keywords    Show Debugs    @{NET_1_VM_INSTANCES}    @{NET_2_VM_INSTANCES}
94     ...    AND    Get Test Teardown Debugs
95
96 Ping Vm Instance1 In l2_network_1
97     [Documentation]    Check reachability of vm instances by pinging to them.
98     Ping Vm From DHCP Namespace    l2_network_1    @{NET1_VM_IPS}[0]
99
100 Ping Vm Instance2 In l2_network_1
101     [Documentation]    Check reachability of vm instances by pinging to them.
102     Ping Vm From DHCP Namespace    l2_network_1    @{NET1_VM_IPS}[1]
103
104 Ping Vm Instance3 In l2_network_1
105     [Documentation]    Check reachability of vm instances by pinging to them.
106     Ping Vm From DHCP Namespace    l2_network_1    @{NET1_VM_IPS}[2]
107
108 Ping Vm Instance1 In l2_network_2
109     [Documentation]    Check reachability of vm instances by pinging to them.
110     Ping Vm From DHCP Namespace    l2_network_2    @{NET2_VM_IPS}[0]
111
112 Ping Vm Instance2 In l2_network_2
113     [Documentation]    Check reachability of vm instances by pinging to them.
114     Ping Vm From DHCP Namespace    l2_network_2    @{NET2_VM_IPS}[1]
115
116 Ping Vm Instance3 In l2_network_2
117     [Documentation]    Check reachability of vm instances by pinging to them.
118     Ping Vm From DHCP Namespace    l2_network_2    @{NET2_VM_IPS}[2]
119
120 Connectivity Tests From Vm Instance1 In l2_network_1
121     [Documentation]    Login to the vm instance and test some operations
122     Test Operations From Vm Instance    l2_network_1    @{NET1_VM_IPS}[0]    ${NET1_VM_IPS}
123
124 Connectivity Tests From Vm Instance2 In l2_network_1
125     [Documentation]    Login to the vm instance and test operations
126     Test Operations From Vm Instance    l2_network_1    @{NET1_VM_IPS}[1]    ${NET1_VM_IPS}
127
128 Connectivity Tests From Vm Instance3 In l2_network_1
129     [Documentation]    Login to the vm instance and test operations
130     Test Operations From Vm Instance    l2_network_1    @{NET1_VM_IPS}[2]    ${NET1_VM_IPS}
131
132 Connectivity Tests From Vm Instance1 In l2_network_2
133     [Documentation]    Login to the vm instance and test operations
134     Test Operations From Vm Instance    l2_network_2    @{NET2_VM_IPS}[0]    ${NET2_VM_IPS}
135
136 Connectivity Tests From Vm Instance2 In l2_network_2
137     [Documentation]    Logging to the vm instance using generated key pair.
138     Test Operations From Vm Instance    l2_network_2    @{NET2_VM_IPS}[1]    ${NET2_VM_IPS}
139
140 Connectivity Tests From Vm Instance3 In l2_network_2
141     [Documentation]    Login to the vm instance using generated key pair.
142     Test Operations From Vm Instance    l2_network_2    @{NET2_VM_IPS}[2]    ${NET2_VM_IPS}
143
144 Delete A Vm Instance
145     [Documentation]    Delete Vm instances using instance names.
146     Delete Vm Instance    MyFirstInstance_1
147
148 No Ping For Deleted Vm
149     [Documentation]    Check non reachability of deleted vm instances by pinging to them.
150     ${output}=    Ping From DHCP Should Not Succeed    l2_network_1    @{NET_1_VM_IPS}[0]
151
152 Delete Vm Instances In l2_network_1
153     [Documentation]    Delete Vm instances using instance names in l2_network_1.
154     : FOR    ${VmElement}    IN    @{NET_1_VM_INSTANCES}
155     \    Delete Vm Instance    ${VmElement}
156
157 Delete Vm Instances In l2_network_2
158     [Documentation]    Delete Vm instances using instance names in l2_network_2.
159     : FOR    ${VmElement}    IN    @{NET_2_VM_INSTANCES}
160     \    Delete Vm Instance    ${VmElement}
161     [Teardown]    Run Keywords    Show Debugs    @{NET_1_VM_INSTANCES}    @{NET_2_VM_INSTANCES}
162     ...    AND    Get Test Teardown Debugs
163
164 Delete Sub Networks In l2_network_1
165     [Documentation]    Delete Sub Nets for the Networks with neutron request.
166     Delete SubNet    l2_subnet_1
167
168 Delete Sub Networks In l2_network_2
169     [Documentation]    Delete Sub Nets for the Networks with neutron request.
170     Delete SubNet    l2_subnet_2
171
172 Delete Networks
173     [Documentation]    Delete Networks with neutron request.
174     : FOR    ${NetworkElement}    IN    @{NETWORKS_NAME}
175     \    Delete Network    ${NetworkElement}