Use consistent naming in sfc suite
[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    BuiltIn.Run Keywords    Delete Configurations
6 ...               AND    Close All Connections
7 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
8 Test Teardown     BuiltIn.Run Keywords    OpenStackOperations.Get Test Teardown Debugs
9 ...               AND    OpenStackOperations.Get Test Teardown Debugs For SFC
10 Library           SSHLibrary
11 Library           OperatingSystem
12 Library           RequestsLibrary
13 Resource          ../../../libraries/DevstackUtils.robot
14 Resource          ../../../libraries/OpenStackOperations.robot
15 Resource          ../../../libraries/SetupUtils.robot
16 Resource          ../../../libraries/Utils.robot
17 Resource          ../../../libraries/KarafKeywords.robot
18
19 *** Variables ***
20 ${SECURITY_GROUP}    sg-sfc
21 @{NETWORKS_NAME}    network_1
22 @{SUBNETS_NAME}    l2_subnet_1
23 @{VM_INSTANCES}    sf1    sf2    sf3    source_vm    dest_vm
24 @{SUBNETS_RANGE}    30.0.0.0/24
25 @{PORTS}          p1in    p1out    p2in    p2out    p3in    p3out    source_vm_port
26 ...               dest_vm_port
27
28 *** Test Cases ***
29 Create VXLAN Network (network_1)
30     [Documentation]    Create Network with neutron request.
31     Create Network    @{NETWORKS_NAME}[0]
32
33 Create Subnets For network_1
34     [Documentation]    Create Sub Nets for the Networks with neutron request.
35     Create SubNet    @{NETWORKS_NAME}[0]    @{SUBNETS_NAME}[0]    @{SUBNETS_RANGE}[0]
36
37 Add Allow All Rules
38     [Documentation]    Allow all TCP/UDP/ICMP packets for this suite
39     OpenStackOperations.Create Allow All SecurityGroup    ${SECURITY_GROUP}
40
41 Create Neutron Ports
42     [Documentation]    Precreate neutron ports to be used for SFC VMs
43     : FOR    ${port}    IN    @{PORTS}
44     \    Create Port    @{NETWORKS_NAME}[0]    ${port}    sg=${SECURITY_GROUP}
45
46 Create Vm Instances
47     [Documentation]    Create Four Vm instances using flavor and image names for a network.
48     Create Vm Instance With Ports    p1in    p1out    sf1    sg=${SECURITY_GROUP}
49     Create Vm Instance With Ports    p2in    p2out    sf2    sg=${SECURITY_GROUP}
50     Create Vm Instance With Ports    p3in    p3out    sf3    sg=${SECURITY_GROUP}
51     Create Vm Instance With Port    source_vm_port    source_vm    sg=${SECURITY_GROUP}
52     Create Vm Instance With Port    dest_vm_port    dest_vm    sg=${SECURITY_GROUP}
53
54 Check Vm Instances Have Ip Address
55     @{NET1_VM_IPS}    ${NET1_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{VM_INSTANCES}
56     BuiltIn.Set Suite Variable    @{NET1_VM_IPS}
57     BuiltIn.Should Not Contain    ${NET1_VM_IPS}    None
58     BuiltIn.Should Not Contain    ${NET1_DHCP_IP}    None
59     [Teardown]    BuiltIn.Run Keywords    OpenStackOperations.Show Debugs    @{VM_INSTANCES}
60     ...    AND    OpenStackOperations.Get Test Teardown Debugs
61
62 Create Flow Classifiers
63     [Documentation]    Create SFC Flow Classifier for TCP traffic between source VM and destination VM
64     Create SFC Flow Classifier    FC_http    @{NET1_VM_IPS}[3]    @{NET1_VM_IPS}[4]    tcp    80    source_vm_port
65
66 Create Port Pairs
67     [Documentation]    Create SFC Port Pairs
68     Create SFC Port Pair    PP1    p1in    p1out
69     Create SFC Port Pair    PP2    p2in    p2out
70     Create SFC Port Pair    PP3    p3in    p3out
71
72 Create Port Pair Groups
73     [Documentation]    Create SFC Port Pair Groups
74     Create SFC Port Pair Group With Two Pairs    PG1    PP1    PP2
75     Create SFC Port Pair Group    PG2    PP3
76
77 Create Port Chain
78     [Documentation]    Create SFC Port Chain using two port groups an classifier created previously
79     Create SFC Port Chain    PC1    PG1    PG2    FC_http
80
81 Start Web Server On Destination VM
82     [Documentation]    Start a simple web server on the destination VM
83     OpenStackOperations.Execute Command on VM Instance    @{NETWORKS_NAME}[0]    @{NET1_VM_IPS}[4]    while true; do echo -e "HTTP/1.0 200 OK\r\nContent-Length: 21\r\n\r\nWelcome to web-server" | sudo nc -l -p 80 ; done &
84
85 Add Static Routing On Service Function VMs
86     [Documentation]    Enable eth1 and add static routing between the ports on the SF VMs
87     : FOR    ${INDEX}    IN RANGE    0    2
88     \    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS_NAME}[0]    @{NET1_VM_IPS}[${INDEX}]    sudo sh -c 'echo "auto eth1" >> /etc/network/interfaces'
89     \    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS_NAME}[0]    @{NET1_VM_IPS}[${INDEX}]    sudo sh -c 'echo "iface eth1 inet dhcp" >> /etc/network/interfaces'
90     \    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS_NAME}[0]    @{NET1_VM_IPS}[${INDEX}]    sudo /etc/init.d/S40network restart
91     \    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS_NAME}[0]    @{NET1_VM_IPS}[${INDEX}]    sudo sh -c 'echo 1 > /proc/sys/net/ipv4/ip_forward'
92     \    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS_NAME}[0]    @{NET1_VM_IPS}[${INDEX}]    sudo ip route add @{NET1_VM_IPS}[3] dev eth0
93     \    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS_NAME}[0]    @{NET1_VM_IPS}[${INDEX}]    sudo ip route add @{NET1_VM_IPS}[4] dev eth1
94
95 Connectivity Tests From Vm Instance1 In network_1
96     [Documentation]    Login to the source VM instance, and send a HTTP GET using curl to the destination VM instance
97     # FIXME need to somehow verify it goes through SFs (flows?)
98     ${DEST_VM_LIST}    BuiltIn.Create List    @{NET1_VM_IPS}[4]
99     Test Operations From Vm Instance    network_1    @{NET1_VM_IPS}[3]    ${DEST_VM_LIST}
100     OpenStackOperations.Execute Command on VM Instance    @{NETWORKS_NAME}[0]    @{NET1_VM_IPS}[3]    curl http://@{NET1_VM_IPS}[4]
101
102 *** Keywords ***
103 Delete Configurations
104     [Documentation]    Delete all elements that were created in the test case section. These are done
105     ...    in a local keyword so this can be called as part of the Suite Teardown. When called as part
106     ...    of the Suite Teardown, all steps will be attempted. This prevents robot framework from bailing
107     ...    on the rest of a test case if one step intermittently has trouble and fails. The goal is to attempt
108     ...    to leave the test environment as clean as possible upon completion of this suite.
109     : FOR    ${VmElement}    IN    @{VM_INSTANCES}
110     \    Delete Vm Instance    ${VmElement}
111     Delete SFC Port Chain    PC1
112     Delete SFC Port Pair Group    PG1
113     Delete SFC Port Pair Group    PG2
114     Delete SFC Port Pair    PP1
115     Delete SFC Port Pair    PP2
116     Delete SFC Port Pair    PP3
117     Delete SFC Flow Classifier    FC_http
118     : FOR    ${port}    IN    @{PORTS}
119     \    Delete Port    ${port}
120     Delete SubNet    l2_subnet_1
121     : FOR    ${NetworkElement}    IN    @{NETWORKS_NAME}
122     \    Delete Network    ${NetworkElement}