Upgrade RF syntax for v3.2 compatibility
[integration/test.git] / csit / suites / vpnservice / 020__configure_vpn.robot
1 *** Settings ***
2 Documentation     Test Suite for vpn instance
3 Suite Setup       Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
4 Suite Teardown    Delete All Sessions
5 Library           OperatingSystem
6 Library           String
7 Library           RequestsLibrary
8 Variables         ../../variables/Variables.py
9 Library           Collections
10
11 *** Variables ***
12 ${REST_CON}       /restconf/config/
13 @{vpn_inst_values}    testVpn1    1000:1    1000:1,2000:1    3000:1,4000:1
14 @{vm_int_values}    s1-eth1    l2vlan    openflow:1:1
15 @{vm_vpnint_values}    s1-eth1    testVpn1    10.0.0.1    12:f8:57:a8:b9:a1
16 ${VPN_CONFIG_DIR}    ${CURDIR}/../../variables/vpnservice
17
18 *** Test Cases ***
19 Create VPN Instance
20     [Documentation]    Creates VPN Instance through restconf
21     [Tags]    Post
22     ${body}    OperatingSystem.Get File    ${VPN_CONFIG_DIR}/vpn_instance.json
23     ${resp}    RequestsLibrary.Post Request    session    ${REST_CON}l3vpn:vpn-instances/    data=${body}
24     Log    ${resp.content}
25     Should Be Equal As Strings    ${resp.status_code}    204
26
27 Verify VPN instance
28     [Documentation]    Verifies the vpn instance is created
29     [Tags]    Get
30     ${resp}    RequestsLibrary.Get Request    session    ${REST_CON}l3vpn:vpn-instances/vpn-instance/${vpn_inst_values[0]}/    headers=${ACCEPT_XML}
31     Should Be Equal As Strings    ${resp.status_code}    200
32     Log    ${resp.content}
33     FOR    ${value}    IN    @{vpn_inst_values}
34         Should Contain    ${resp.content}    ${value}
35     END
36
37 Create ietf vm interface
38     [Documentation]    Creates ietf interface through the restconf
39     [Tags]    Post
40     ${body}    OperatingSystem.Get File    ${VPN_CONFIG_DIR}/vm_interface.json
41     ${resp}    RequestsLibrary.Post Request    session    ${REST_CON}ietf-interfaces:interfaces/    data=${body}
42     Should Be Equal As Strings    ${resp.status_code}    204
43
44 Verify ietf vm interface
45     [Documentation]    Verifies ietf interface created
46     [Tags]    Get
47     ${resp}    RequestsLibrary.Get Request    session    ${REST_CON}ietf-interfaces:interfaces/interface/${vm_int_values[0]}/    headers=${ACCEPT_XML}
48     Should Be Equal As Strings    ${resp.status_code}    200
49     Log    ${resp.content}
50     FOR    ${value}    IN    @{vm_int_values}
51         Should Contain    ${resp.content}    ${value}
52     END
53
54 Create VPN interface
55     [Documentation]    Creates vpn interface for the corresponding ietf interface
56     [Tags]    Post
57     ${body}    OperatingSystem.Get File    ${VPN_CONFIG_DIR}/vm_vpninterface.json
58     ${resp}    RequestsLibrary.Post Request    session    ${REST_CON}l3vpn:vpn-interfaces/    data=${body}
59     Should Be Equal As Strings    ${resp.status_code}    204
60
61 Verify VPN interface
62     [Documentation]    Verifies the vpn interface created
63     [Tags]    Get
64     ${resp}    RequestsLibrary.Get Request    session    ${REST_CON}l3vpn:vpn-interfaces/    headers=${ACCEPT_XML}
65     Should Be Equal As Strings    ${resp.status_code}    200
66     Log    ${resp.content}
67     FOR    ${value}    IN    @{vm_vpnint_values}
68         Should Contain    ${resp.content}    ${value}
69     END
70
71 Verify FIB entry after create
72     [Documentation]    Verifies the fib entry for the corresponding vpn interface
73     [Tags]    Get
74     Wait Until Keyword Succeeds    5s    1s    Ensure The Fib Entry Is Present    ${vm_vpnint_values[2]}
75
76 Delete vm vpn interface
77     [Documentation]    Deletes the vpn interface
78     [Tags]    Delete
79     ${resp}    RequestsLibrary.Delete Request    session    ${REST_CON}l3vpn:vpn-interfaces/
80     Should Be Equal As Strings    ${resp.status_code}    200
81
82 Verify after deleteing vm vpn interface
83     [Documentation]    Verifies vpn interface after delete
84     [Tags]    Verify after delete
85     ${resp}    RequestsLibrary.Get Request    session    ${REST_CON}l3vpn:vpn-interfaces/    headers=${ACCEPT_XML}
86     Should Be Equal As Strings    ${resp.status_code}    404
87
88 Delete VPN Instance
89     [Documentation]    Deletes the VPN Instance
90     [Tags]    Delete
91     ${resp}    RequestsLibrary.Delete Request    session    ${REST_CON}l3vpn:vpn-instances/vpn-instance/${vpn_inst_values[0]}/
92     Should Be Equal As Strings    ${resp.status_code}    200
93
94 Verify after deleting the vpn instance
95     [Documentation]    Verifies after deleting the vpn instance
96     [Tags]    Verfiy after delete
97     ${resp}    RequestsLibrary.Get Request    session    ${REST_CON}l3vpn:vpn-instances/vpn-instance/${vpn_inst_values[0]}/    headers=${ACCEPT_XML}
98     Should Be Equal As Strings    ${resp.status_code}    404
99
100 Delete vm ietf interface
101     [Documentation]    Deletes the ietf interface
102     [Tags]    Delete
103     ${resp}    RequestsLibrary.Delete Request    session    ${REST_CON}ietf-interfaces:interfaces/interface/${vm_int_values[0]}
104     Should Be Equal As Strings    ${resp.status_code}    200
105
106 Verify after deleting vm ietf interface
107     [Documentation]    Verifies ietf interface after delete
108     [Tags]    Verify after delete
109     ${resp}    RequestsLibrary.Get Request    session    ${REST_CON}ietf-interfaces:interfaces/interface/${vm_int_values[0]}    headers=${ACCEPT_XML}
110     Should Be Equal As Strings    ${resp.status_code}    404
111
112 Verify FIB entry after delete
113     [Documentation]    Verifies the fib entry is deleted for the corresponding vpn interface
114     [Tags]    Get
115     Wait Until Keyword Succeeds    5s    1s    Ensure The Fib Entry Is Removed    ${vm_vpnint_values[2]}
116
117 *** Keywords ***
118 Ensure The Fib Entry Is Present
119     [Arguments]    ${prefix}
120     [Documentation]    Will succeed if the fib entry is present for the vpn
121     ${resp}    RequestsLibrary.Get Request    session    /restconf/operational/odl-fib:fibEntries/    headers=${ACCEPT_XML}
122     Should Be Equal As Strings    ${resp.status_code}    200
123     Log    ${resp.content}
124     Should Contain    ${resp.content}    ${prefix}
125     Should Contain    ${resp.content}    label
126
127 Ensure the Fib Entry Is Removed
128     [Arguments]    ${prefix}
129     [Documentation]    Will succeed if the fib entry is removed for the vpn
130     ${resp}    RequestsLibrary.Get Request    session    /restconf/operational/odl-fib:fibEntries/    headers=${ACCEPT_XML}
131     Should Be Equal As Strings    ${resp.status_code}    200
132     Should Not Contain    ${resp.content}    ${prefix}