e7a07cf38fd05277b995248f2839dacc60c23a6b
[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
16 *** Variables ***
17 @{NETWORKS_NAME}    l2_network_1    l2_network_2
18 @{SUBNETS_NAME}    l2_subnet_1    l2_subnet_2
19 @{NET_1_VM_INSTANCES}    MyFirstInstance_1    MySecondInstance_1    MyThirdInstance_1
20 @{NET_2_VM_INSTANCES}    MyFirstInstance_2    MySecondInstance_2    MyThirdInstance_2
21 @{SUBNETS_RANGE}    30.0.0.0/24    40.0.0.0/24
22
23 *** Test Cases ***
24 Create Networks
25     [Documentation]    Create Network with neutron request.
26     : FOR    ${NetworkElement}    IN    @{NETWORKS_NAME}
27     \    Create Network    ${NetworkElement}
28
29 Create Subnets For l2_network_1
30     [Documentation]    Create Sub Nets for the Networks with neutron request.
31     Create SubNet    l2_network_1    l2_subnet_1    @{SUBNETS_RANGE}[0]
32
33 Create Subnets For l2_network_2
34     [Documentation]    Create Sub Nets for the Networks with neutron request.
35     Create SubNet    l2_network_2    l2_subnet_2    @{SUBNETS_RANGE}[1]
36
37 Add Ssh Allow Rule
38     [Documentation]    Allow all TCP/UDP/ICMP packets for this suite
39     Neutron Security Group Create    csit
40     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
41     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
42     Neutron Security Group Rule Create    csit    direction=ingress    protocol=icmp    remote_ip_prefix=0.0.0.0/0
43     Neutron Security Group Rule Create    csit    direction=egress    protocol=icmp    remote_ip_prefix=0.0.0.0/0
44     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
45     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
46
47 Create Vm Instances For l2_network_1
48     [Documentation]    Create Four Vm instances using flavor and image names for a network.
49     Create Vm Instances    l2_network_1    ${NET_1_VM_INSTANCES}    sg=csit
50
51 Create Vm Instances For l2_network_2
52     [Documentation]    Create Four Vm instances using flavor and image names for a network.
53     Create Vm Instances    l2_network_2    ${NET_2_VM_INSTANCES}    sg=csit
54
55 Check Vm Instances Have Ip Address
56     [Documentation]    Test case to verify that all created VMs are ready and have received their ip addresses.
57     ...    We are polling first and longest on the last VM created assuming that if it's received it's address
58     ...    already the other instances should have theirs already or at least shortly thereafter.
59     # first, ensure all VMs are in ACTIVE state.    if not, we can just fail the test case and not waste time polling
60     # for dhcp addresses
61     : FOR    ${vm}    IN    @{NET_1_VM_INSTANCES}    @{NET_2_VM_INSTANCES}
62     \    Wait Until Keyword Succeeds    15s    5s    Verify VM Is ACTIVE    ${vm}
63     : FOR    ${index}    IN RANGE    1    5
64     \    # creating 50s pool at 5s interval
65     \    ${NET1_VM_IPS}    @{NET1_DHCP_IP}    Verify VMs Received DHCP Lease    @{NET_1_VM_INSTANCES}
66     \    ${NET2_VM_IPS}    @{NET2_DHCP_IP}    Verify VMs Received DHCP Lease    @{NET_2_VM_INSTANCES}
67     \    ${VM_IPS}=    Collections.Combine Lists    ${NET1_VM_IPS}    ${NET2_VM_IPS}    ${NET1_DHCP_IP}    ${NET2_DHCP_IP}
68     \    ${status}    ${message}    Run Keyword And Ignore Error    List Should Not Contain Value    ${VM_IPS}    None
69     \    Exit For Loop If    '${status}' == 'PASS'
70     \    BuiltIn.Sleep    5s
71     : FOR    ${vm}    IN    @{NET_1_VM_INSTANCES}    @{NET_2_VM_INSTANCES}
72     \    Write Commands Until Prompt    nova console-log ${vm}    30s
73     Append To List    ${NET1_VM_IPS}    @{NET1_DHCP_IP}[0]
74     Set Suite Variable    ${NET1_VM_IPS}
75     Append To List    ${NET2_VM_IPS}    @{NET2_DHCP_IP}[0]
76     Set Suite Variable    ${NET2_VM_IPS}
77     Should Not Contain    ${NET1_VM_IPS}    None
78     Should Not Contain    ${NET2_VM_IPS}    None
79     [Teardown]    Run Keywords    Show Debugs    @{NET_1_VM_INSTANCES}    @{NET_2_VM_INSTANCES}
80     ...    AND    Get Test Teardown Debugs
81
82 Ping Vm Instance1 In l2_network_1
83     [Documentation]    Check reachability of vm instances by pinging to them.
84     Ping Vm From DHCP Namespace    l2_network_1    @{NET1_VM_IPS}[0]
85
86 Ping Vm Instance2 In l2_network_1
87     [Documentation]    Check reachability of vm instances by pinging to them.
88     Ping Vm From DHCP Namespace    l2_network_1    @{NET1_VM_IPS}[1]
89
90 Ping Vm Instance3 In l2_network_1
91     [Documentation]    Check reachability of vm instances by pinging to them.
92     Ping Vm From DHCP Namespace    l2_network_1    @{NET1_VM_IPS}[2]
93
94 Ping Vm Instance1 In l2_network_2
95     [Documentation]    Check reachability of vm instances by pinging to them.
96     Ping Vm From DHCP Namespace    l2_network_2    @{NET2_VM_IPS}[0]
97
98 Ping Vm Instance2 In l2_network_2
99     [Documentation]    Check reachability of vm instances by pinging to them.
100     Ping Vm From DHCP Namespace    l2_network_2    @{NET2_VM_IPS}[1]
101
102 Ping Vm Instance3 In l2_network_2
103     [Documentation]    Check reachability of vm instances by pinging to them.
104     Ping Vm From DHCP Namespace    l2_network_2    @{NET2_VM_IPS}[2]
105
106 Connectivity Tests From Vm Instance1 In l2_network_1
107     [Documentation]    Login to the vm instance and test some operations
108     Test Operations From Vm Instance    l2_network_1    @{NET1_VM_IPS}[0]    ${NET1_VM_IPS}
109
110 Connectivity Tests From Vm Instance2 In l2_network_1
111     [Documentation]    Login to the vm instance and test operations
112     Test Operations From Vm Instance    l2_network_1    @{NET1_VM_IPS}[1]    ${NET1_VM_IPS}
113
114 Connectivity Tests From Vm Instance3 In l2_network_1
115     [Documentation]    Login to the vm instance and test operations
116     Test Operations From Vm Instance    l2_network_1    @{NET1_VM_IPS}[2]    ${NET1_VM_IPS}
117
118 Connectivity Tests From Vm Instance1 In l2_network_2
119     [Documentation]    Login to the vm instance and test operations
120     Test Operations From Vm Instance    l2_network_2    @{NET2_VM_IPS}[0]    ${NET2_VM_IPS}
121
122 Connectivity Tests From Vm Instance2 In l2_network_2
123     [Documentation]    Logging to the vm instance using generated key pair.
124     Test Operations From Vm Instance    l2_network_2    @{NET2_VM_IPS}[1]    ${NET2_VM_IPS}
125
126 Connectivity Tests From Vm Instance3 In l2_network_2
127     [Documentation]    Login to the vm instance using generated key pair.
128     Test Operations From Vm Instance    l2_network_2    @{NET2_VM_IPS}[2]    ${NET2_VM_IPS}
129
130 Delete A Vm Instance
131     [Documentation]    Delete Vm instances using instance names.
132     Delete Vm Instance    MyFirstInstance_1
133
134 No Ping For Deleted Vm
135     [Documentation]    Check non reachability of deleted vm instances by pinging to them.
136     ${output}=    Ping From DHCP Should Not Succeed    l2_network_1    @{NET_1_VM_IPS}[0]
137
138 Delete Vm Instances In l2_network_1
139     [Documentation]    Delete Vm instances using instance names in l2_network_1.
140     : FOR    ${VmElement}    IN    @{NET_1_VM_INSTANCES}
141     \    Delete Vm Instance    ${VmElement}
142
143 Delete Vm Instances In l2_network_2
144     [Documentation]    Delete Vm instances using instance names in l2_network_2.
145     : FOR    ${VmElement}    IN    @{NET_2_VM_INSTANCES}
146     \    Delete Vm Instance    ${VmElement}
147     [Teardown]    Run Keywords    Show Debugs    @{NET_1_VM_INSTANCES}    @{NET_2_VM_INSTANCES}
148     ...    AND    Get Test Teardown Debugs
149
150 Delete Sub Networks In l2_network_1
151     [Documentation]    Delete Sub Nets for the Networks with neutron request.
152     Delete SubNet    l2_subnet_1
153
154 Delete Sub Networks In l2_network_2
155     [Documentation]    Delete Sub Nets for the Networks with neutron request.
156     Delete SubNet    l2_subnet_2
157
158 Delete Networks
159     [Documentation]    Delete Networks with neutron request.
160     : FOR    ${NetworkElement}    IN    @{NETWORKS_NAME}
161     \    Delete Network    ${NetworkElement}