Add CSIT for openstack-sfc
[integration/test.git] / csit / suites / openstack / extensions / sfc.robot
1 *** Settings ***
2 Documentation     Test suite to verify SFC configuration and packet flows.
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
17 *** Variables ***
18 @{NETWORKS_NAME}    network_1
19 @{SUBNETS_NAME}    l2_subnet_1
20 @{VM_INSTANCES}    sf1    sf2    sf3    source_vm    dest_vm
21 @{SUBNETS_RANGE}    30.0.0.0/24
22 @{PORTS}          p1in    p1out    p2in    p2out    p3in    p3out    source_vm_port
23 ...               dest_vm_port
24
25 *** Test Cases ***
26 Create VXLAN Network (network_1)
27     [Documentation]    Create Network with neutron request.
28     Create Network    @{NETWORKS_NAME}[0]
29
30 Create Subnets For network_1
31     [Documentation]    Create Sub Nets for the Networks with neutron request.
32     Create SubNet    @{NETWORKS_NAME}[0]    @{SUBNETS_NAME}[0]    @{SUBNETS_RANGE}[0]
33
34 Add Allow All Rules
35     [Documentation]    Allow all packets for this suite
36     Neutron Security Group Create    sg-sfc
37     Neutron Security Group Rule Create    sg-sfc    direction=ingress    port_range_max=65535    port_range_min=1    protocol=tcp    remote_ip_prefix=0.0.0.0/0
38     Neutron Security Group Rule Create    sg-sfc    direction=egress    port_range_max=65535    port_range_min=1    protocol=tcp    remote_ip_prefix=0.0.0.0/0
39     Neutron Security Group Rule Create    sg-sfc    direction=ingress    port_range_max=65535    port_range_min=1    protocol=udp    remote_ip_prefix=0.0.0.0/0
40     Neutron Security Group Rule Create    sg-sfc    direction=egress    port_range_max=65535    port_range_min=1    protocol=udp    remote_ip_prefix=0.0.0.0/0
41     Neutron Security Group Rule Create    sg-sfc    direction=ingress    protocol=icmp    remote_ip_prefix=0.0.0.0/0
42     Neutron Security Group Rule Create    sg-sfc    direction=egress    protocol=icmp    remote_ip_prefix=0.0.0.0/0
43
44 Create Neutron Ports
45     [Documentation]    Precreate neutron ports to be used for SFC VMs
46     : FOR    ${port}    IN    @{PORTS}
47     \    Create Port    @{NETWORKS_NAME}[0]    ${port}    sg=sg-sfc
48
49 Create Vm Instances
50     [Documentation]    Create Four Vm instances using flavor and image names for a network.
51     Create Vm Instance With Ports    p1in    p1out    sf1    sg=sg-sfc
52     Create Vm Instance With Ports    p2in    p2out    sf2    sg=sg-sfc
53     Create Vm Instance With Ports    p3in    p3out    sf3    sg=sg-sfc
54     Create Vm Instance With Port    source_vm_port    source_vm    sg=sg-sfc
55     Create Vm Instance With Port    dest_vm_port    dest_vm    sg=sg-sfc
56
57 Check Vm Instances Have Ip Address
58     [Documentation]    Test case to verify that all created VMs are ready and have received their ip addresses.
59     ...    We are polling first and longest on the last VM created assuming that if it's received it's address
60     ...    already the other instances should have theirs already or at least shortly thereafter.
61     # first, ensure all VMs are in ACTIVE state.    if not, we can just fail the test case and not waste time polling
62     # for dhcp addresses
63     : FOR    ${vm}    IN    @{VM_INSTANCES}
64     \    Wait Until Keyword Succeeds    15s    5s    Verify VM Is ACTIVE    ${vm}
65     ${status}    ${message}    Run Keyword And Ignore Error    Wait Until Keyword Succeeds    60s    5s    Collect VM IP Addresses
66     ...    true    @{VM_INSTANCES}
67     ${NET1_VM_IPS}    ${NET1_DHCP_IP}    Collect VM IP Addresses    false    @{VM_INSTANCES}
68     ${VM_INSTANCES}=    Collections.Combine Lists    ${VM_INSTANCES}
69     ${VM_IPS}=    Collections.Combine Lists    ${NET1_VM_IPS}
70     ${LOOP_COUNT}    Get Length    ${VM_INSTANCES}
71     : FOR    ${index}    IN RANGE    0    ${LOOP_COUNT}
72     \    ${status}    ${message}    Run Keyword And Ignore Error    Should Not Contain    @{VM_IPS}[${index}]    None
73     \    Run Keyword If    '${status}' == 'FAIL'    Write Commands Until Prompt    nova console-log @{VM_INSTANCES}[${index}]    30s
74     Set Suite Variable    ${NET1_VM_IPS}
75     Should Not Contain    ${NET1_VM_IPS}    None
76     Should Not Contain    ${NET1_DHCP_IP}    None
77     [Teardown]    Run Keywords    Show Debugs    @{VM_INSTANCES}
78     ...    AND    Get Test Teardown Debugs
79
80 Create Flow Classifiers
81     [Documentation]    Create SFC Flow Classifier for TCP traffic between source VM and destination VM
82     Create SFC Flow Classifier    FC_http    @{NET1_VM_IPS}[3]    @{NET1_VM_IPS}[4]    tcp    80    source_vm_port
83
84 Create Port Pairs
85     [Documentation]    Create SFC Port Pairs
86     Create SFC Port Pair    PP1    p1in    p1out
87     Create SFC Port Pair    PP2    p2in    p2out
88     Create SFC Port Pair    PP3    p3in    p3out
89
90 Create Port Pair Groups
91     [Documentation]    Create SFC Port Pair Groups
92     Create SFC Port Pair Group With Two Pairs    PG1    PP1    PP2
93     Create SFC Port Pair Group    PG2    PP3
94
95 Create Port Chain
96     [Documentation]    Create SFC Port Chain using two port groups an classifier created previously
97     Create SFC Port Chain    PC1    PG1    PG2    FC_http
98
99 Start Web Server On Destination VM
100     [Documentation]    Start a simple web server on the destination VM
101     Execute Command on VM Instance    @{NETWORKS_NAME}[0]    @{NET1_VM_IPS}[4]    while true; do echo -e "HTTP/1.0 200 OK\r\n\r\nWelcome to $(hostname)" | sudo nc -l -p 80 ; done&
102
103 Add Static Routing On Service Function VMs
104     [Documentation]    Enable eth1 and add static routing between the ports on the SF VMs
105     : FOR    ${INDEX}    IN RANGE    0    2
106     \    Execute Command on VM Instance    @{NETWORKS_NAME}[0]    @{NET1_VM_IPS}[${INDEX}]    sudo sh -c 'echo "auto eth1" >> /etc/network/interfaces'
107     \    Execute Command on VM Instance    @{NETWORKS_NAME}[0]    @{NET1_VM_IPS}[${INDEX}]    sudo sh -c 'echo "iface eth1 inet dhcp" >> /etc/network/interfaces'
108     \    Execute Command on VM Instance    @{NETWORKS_NAME}[0]    @{NET1_VM_IPS}[${INDEX}]    sudo /etc/init.d/S40network restart
109     \    Execute Command on VM Instance    @{NETWORKS_NAME}[0]    @{NET1_VM_IPS}[${INDEX}]    sudo sh -c 'echo 1 > /proc/sys/net/ipv4/ip_forward'
110     \    Execute Command on VM Instance    @{NETWORKS_NAME}[0]    @{NET1_VM_IPS}[${INDEX}]    sudo ip route add @{NET1_VM_IPS}[3] dev eth0
111     \    Execute Command on VM Instance    @{NETWORKS_NAME}[0]    @{NET1_VM_IPS}[${INDEX}]    sudo ip route add @{NET1_VM_IPS}[4] dev eth1
112
113 Connectivity Tests From Vm Instance1 In network_1
114     [Documentation]    Login to the source VM instance, and send a HTTP GET using curl to the destination VM instance
115     # FIXME need to somehow verify it goes through SFs (flows?)
116     ${DEST_VM_LIST}    Create List    @{NET1_VM_IPS}[4]
117     Test Operations From Vm Instance    network_1    @{NET1_VM_IPS}[3]    ${DEST_VM_LIST}
118     Execute Command on VM Instance    @{NETWORKS_NAME}[0]    @{NET1_VM_IPS}[3]    curl http://@{NET1_VM_IPS}[4]
119
120 Delete Vm Instances In network_1
121     [Documentation]    Delete Vm instances using instance names in network_1.
122     : FOR    ${VmElement}    IN    @{VM_INSTANCES}
123     \    Delete Vm Instance    ${VmElement}
124
125 Delete All SFC Objects
126     [Documentation]    Delete all previously created SFC objects
127     Delete SFC Port Chain    PC1
128     Delete SFC Port Pair Group    PG1
129     Delete SFC Port Pair Group    PG2
130     Delete SFC Port Pair    PP1
131     Delete SFC Port Pair    PP2
132     Delete SFC Port Pair    PP3
133     Delete SFC Flow Classifier    FC_http
134
135 Delete Sub Networks In network_1
136     [Documentation]    Delete Sub Nets for the Networks with neutron request.
137     Delete SubNet    l2_subnet_1
138
139 Delete Networks
140     [Documentation]    Delete Networks with neutron request.
141     : FOR    ${NetworkElement}    IN    @{NETWORKS_NAME}
142     \    Delete Network    ${NetworkElement}