Step 1: Move vm scripts to the right place
[integration/test.git] / test / csit / suites / vpnservice / 030__configure_2_switches.robot
1 *** Settings ***
2 Documentation     Test Suite for vpn instance
3 Suite Setup       Create Session    session    http://${CONTROLLER}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
4 Suite Teardown    Delete All Sessions
5 Variables         ../../variables/vpnservice/configureSwitches.py    ${MININET}    ${MININET1}
6 Library           SSHLibrary
7 Variables         ../../variables/Variables.py
8 Resource          ../../libraries/Utils.robot
9 Library           RequestsLibrary
10
11 *** Variables ***
12 ${REST_CON}       /restconf/config
13 @{vpn_inst_values}    testVpn1    100:1    200:1    300:1    testVpn2    400:1    500:1
14 ...               600:1
15 @{ietf_int_values}    s1-eth1    s1-eth2    s1-gre1    s2-eth1    s2-eth2    s2-gre1
16 @{vpn_int_values}    s1-eth1    testVpn1    10.0.0.1    00:00:00:00:00:01    s1-eth2    10.0.0.2    00:00:00:00:00:02
17 ...               s2-eth1    10.0.0.3    00:00:00:00:00:03    testVpn2    s2-eth2    10.0.0.4    00:00:00:00:00:04
18 ${REST_OPER}      /restconf/operational
19 @{NODE_ELEMENTS}    openflow:1    openflow:1:1    openflow:1:2    openflow:1:3    openflow:2    openflow:2:1    openflow:2:2
20 ...               openflow:2:3
21
22 *** Test Cases ***
23 Veirfy The Switches
24     [Documentation]    Verifies if the switches and node connectors data is available to the controller
25     Check For Elements At URI    ${REST_OPER}/opendaylight-inventory:nodes/    ${NODE_ELEMENTS}
26
27 Create VPN Instances
28     [Documentation]    Creates VPN Instances through restconf
29     [Tags]    Post
30     ${resp}    RequestsLibrary.Post    session    ${REST_CON}/l3vpn:vpn-instances/    data=${vpn_instances}
31     Log    ${resp.content}
32     Should Be Equal As Strings    ${resp.status_code}    204
33
34 Verify VPN instances
35     [Documentation]    Verifies the vpn instances in the datastores
36     [Tags]    Get
37     Wait Until Keyword Succeeds    5s    1s    Check For Elements At URI    ${REST_CON}/l3vpn:vpn-instances/    ${vpn_inst_values}
38     Wait Until Keyword Succeeds    5s    1s    Check For Elements At URI    ${REST_OPER}/l3vpn:vpn-instances/    ${vpn_inst_values}
39
40 Create ietf interfaces
41     [Documentation]    Creates ietf interfaces through the restconf
42     [Tags]    Post
43     ${resp}    RequestsLibrary.Post    session    ${REST_CON}/ietf-interfaces:interfaces/    data=${ietf_interfaces}
44     Should Be Equal As Strings    ${resp.status_code}    204
45
46 Verify ietf interfaces
47     [Documentation]    Verifies ietf interfaces created in datastores
48     [Tags]    Get
49     Wait Until Keyword Succeeds    5s    1s    Check For Elements At URI    ${REST_CON}/ietf-interfaces:interfaces/    ${ietf_int_values}
50     Wait Until Keyword Succeeds    5s    1s    Check For Elements At URI    ${REST_OPER}/ietf-interfaces:interfaces-state/    ${ietf_int_values}
51     @{state}=    Create List    down
52     Wait Until Keyword Succeeds    2s    1s    Check For Elements Not At URI    ${REST_OPER}/ietf-interfaces:interfaces-state/    ${state}
53
54 Create VPN interfaces
55     [Documentation]    Creates vpn interface for the corresponding ietf interface
56     [Tags]    Post
57     ${resp}    RequestsLibrary.Post    session    ${REST_CON}/l3vpn:vpn-interfaces/    data=${vpn_interfaces}
58     Should Be Equal As Strings    ${resp.status_code}    204
59
60 Verify VPN interfaces
61     [Documentation]    Verifies the vpn interfaces created in datastores
62     [Tags]    Get
63     Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${REST_CON}/l3vpn:vpn-interfaces/    ${vpn_int_values}
64     Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${REST_OPER}/l3vpn:vpn-interfaces/    ${vpn_int_values}
65
66 Verify FIB entries after create
67     [Documentation]    Verifies the fib entries in the operational DS for the corresponding vpn interfaces
68     [Tags]    Get
69     @{fib_entries1}=    Create List    ${vpn_int_values[2]}    ${vpn_int_values[8]}
70     @{fib_entries2}=    Create List    ${vpn_int_values[5]}    ${vpn_int_values[12]}
71     Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${REST_OPER}/odl-fib:fibEntries/vrfTables/${vpn_inst_values[1]}    ${fib_entries1}
72     Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${REST_OPER}/odl-fib:fibEntries/vrfTables/${vpn_inst_values[5]}    ${fib_entries2}
73
74 Verify flows
75     [Documentation]    Verify flows in the switches
76     [Tags]    verify in switch
77     @{flow_elements}    Create List    ${vpn_int_values[2]}    ${vpn_int_values[5]}    ${vpn_int_values[8]}    ${vpn_int_values[12]}
78     Wait Until Keyword Succeeds    6s    2s    Ensure Flows Are Present    ${mininet1_conn_id_1}    ${flow_elements}
79     Wait Until Keyword Succeeds    6s    2s    Ensure Flows Are Present    ${mininet2_conn_id_1}    ${flow_elements}
80
81 Verify groups
82     [Documentation]    Verify groups in the switches
83     [Tags]    verify in switch
84     @{group_elements1}    Create List    ${vpn_int_values[3]}    ${vpn_int_values[6]}
85     @{group_elements2}    Create List    ${vpn_int_values[9]}    ${vpn_int_values[13]}
86     Wait Until Keyword Succeeds    5s    1s    Ensure Groups Are Present    ${mininet1_conn_id_1}    ${group_elements1}    3
87     Wait Until Keyword Succeeds    5s    1s    Ensure Groups Are Present    ${mininet2_conn_id_1}    ${group_elements2}    3
88
89 Verify ping
90     [Documentation]    Verifies the ping between the two hosts. Ping should succeed between hosts in same vpn, (h1,h3) and (h2,h4).Ping between hosts in different vpns should fail (h1,h2) & (h3,h4). The commented out section is to be uncommented when ovs supports mpls over gre in datapath
91     [Tags]    verify in switch
92     Switch Connection    ${mininet1_conn_id_1}
93     Write    h1 ping h2 -c 5
94     ${result}    Read Until    mininet>
95     Log    ${result}
96     Should Contain    ${result}    100% packet loss
97
98 Delete vpn interfaces
99     [Documentation]    Deletes the vpn interfaces
100     [Tags]    Delete
101     ${resp}    RequestsLibrary.Delete    session    ${REST_CON}/l3vpn:vpn-interfaces/
102     Should Be Equal As Strings    ${resp.status_code}    200
103
104 Verify after deleting vpn interfaces
105     [Documentation]    Verifies if vpn interfaces are deleted
106     [Tags]    Verify after delete
107     ${resp}    RequestsLibrary.get    session    ${REST_CON}/l3vpn:vpn-interfaces/    headers=${ACCEPT_XML}
108     Should Be Equal As Strings    ${resp.status_code}    404
109
110 Delete ietf interfaces
111     [Documentation]    Deletes the ietf interfaces
112     [Tags]    Delete
113     ${resp}    RequestsLibrary.Delete    session    ${REST_CON}/ietf-interfaces:interfaces/
114     Should Be Equal As Strings    ${resp.status_code}    200
115
116 Verify after deleting ietf interfaces
117     [Documentation]    Verifies if ietf interfaces are deleted
118     [Tags]    Verify after delete
119     ${resp}    RequestsLibrary.get    session    ${REST_CON}/ietf-interfaces:interfaces/    headers=${ACCEPT_XML}
120     Should Be Equal As Strings    ${resp.status_code}    404
121
122 Delete VPN Instances
123     [Documentation]    Deletes the VPN Instances
124     [Tags]    Delete
125     ${resp}    RequestsLibrary.Delete    session    ${REST_CON}/l3vpn:vpn-instances/
126     Should Be Equal As Strings    ${resp.status_code}    200
127
128 Verify after deleting the vpn instances
129     [Documentation]    Verifies after deleting the vpn instances
130     [Tags]    Verfiy after delete
131     ${resp}    RequestsLibrary.get    session    ${REST_CON}/l3vpn:vpn-instances/    headers=${ACCEPT_XML}
132     Should Be Equal As Strings    ${resp.status_code}    404
133
134 Verify FIB entries after delete
135     [Documentation]    Verifies if the fib entries are deleted in the operational DS
136     [Tags]    Get
137     @{fib_entries}=    Create List    ${vpn_int_values[2]}    ${vpn_int_values[5]}    ${vpn_int_values[8]}    ${vpn_int_values[12]}
138     Wait Until Keyword Succeeds    3s    1s    Check For Elements Not At URI    ${REST_OPER}/odl-fib:fibEntries/    ${fib_entries}
139
140 Verify flows after delete
141     [Documentation]    Verify if the flows are deleted from the switch
142     [Tags]    verify in switch
143     [Template]
144     Wait Until Keyword Succeeds    12s    2s    Ensure Flows Are Removed    ${mininet1_conn_id_1}
145     Wait Until Keyword Succeeds    12s    2s    Ensure Flows Are Removed    ${mininet2_conn_id_1}
146
147 *** Keywords ***
148 Ensure Flows Are Present
149     [Arguments]    ${conn_id}    ${flow_elements}
150     [Documentation]    Succeeds if the flows for vpn service are present
151     Switch Connection    ${conn_id}
152     Write    dpctl dump-flows -O OpenFlow13
153     ${output}=    Read Until    mininet>
154     Log    ${output}
155     Should Contain    ${output}    goto_table:20
156     Should Contain X Times    ${output}    goto_table:21    2
157     Should Contain X Times    ${output}    table=20    2
158     Should Contain X Times    ${output}    table=21    4
159     : FOR    ${i}    IN    @{flow_elements}
160     \    Should Contain    ${output}    ${i}
161
162 Ensure Groups Are Present
163     [Arguments]    ${conn_id}    ${group_elements}    ${gre_port_id}
164     [Documentation]    Succeeds if the groups for the vpn service are present
165     Switch Connection    ${conn_id}
166     Write    dpctl dump-groups -O OpenFlow13
167     ${output}=    Read Until    mininet>
168     Log    ${output}
169     Should Contain X Times    ${output}    actions=output:${gre_port_id}    1
170     : FOR    ${i}    IN    @{group_elements}
171     \    Should Contain    ${output}    actions=pop_mpls:0x0800,set_field:${i}
172
173 Ensure Flows Are Removed
174     [Arguments]    ${conn_id}
175     [Documentation]    Succeeds if the flows are removed from the switch
176     Switch Connection    ${conn_id}
177     Write    dpctl dump-flows -O OpenFlow13
178     ${output}=    Read Until    mininet>
179     Log    ${output}
180     Should Not contain    ${output}    goto_table:20
181     Should Not contain    ${output}    goto_table:21
182     Should Not contain    ${output}    table=20
183     Should Not contain    ${output}    table=21
184
185 Ensure Groups Are Removed
186     [Arguments]    ${conn_id}
187     [Documentation]    Succeeds if the group entries are removed from switch
188     Switch Connection    ${conn_id}
189     Write    dpctl dump-groups -O OpenFlow13
190     ${output}=    Read Until    mininet>
191     Log    ${output}
192     Should Not Contain    ${output}    actions=output:
193     Should Not Contain    ${output}    actions=pop_mpls:0x0800