Step 2: Move test folder to root
[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://${CONTROLLER}:${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    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    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
36 Create ietf vm interface
37     [Documentation]    Creates ietf interface through the restconf
38     [Tags]    Post
39     ${body}    OperatingSystem.Get File    ${VPN_CONFIG_DIR}/vm_interface.json
40     ${resp}    RequestsLibrary.Post    session    ${REST_CON}ietf-interfaces:interfaces/    data=${body}
41     Should Be Equal As Strings    ${resp.status_code}    204
42
43 Verify ietf vm interface
44     [Documentation]    Verifies ietf interface created
45     [Tags]    Get
46     ${resp}    RequestsLibrary.Get    session    ${REST_CON}ietf-interfaces:interfaces/interface/${vm_int_values[0]}/    headers=${ACCEPT_XML}
47     Should Be Equal As Strings    ${resp.status_code}    200
48     Log    ${resp.content}
49     : FOR    ${value}    IN    @{vm_int_values}
50     \    Should Contain    ${resp.content}    ${value}
51
52 Create VPN interface
53     [Documentation]    Creates vpn interface for the corresponding ietf interface
54     [Tags]    Post
55     ${body}    OperatingSystem.Get File    ${VPN_CONFIG_DIR}/vm_vpninterface.json
56     ${resp}    RequestsLibrary.Post    session    ${REST_CON}l3vpn:vpn-interfaces/    data=${body}
57     Should Be Equal As Strings    ${resp.status_code}    204
58
59 Verify VPN interface
60     [Documentation]    Verifies the vpn interface created
61     [Tags]    Get
62     ${resp}    RequestsLibrary.Get    session    ${REST_CON}l3vpn:vpn-interfaces/    headers=${ACCEPT_XML}
63     Should Be Equal As Strings    ${resp.status_code}    200
64     Log    ${resp.content}
65     : FOR    ${value}    IN    @{vm_vpnint_values}
66     \    Should Contain    ${resp.content}    ${value}
67
68 Verify FIB entry after create
69     [Documentation]    Verifies the fib entry for the corresponding vpn interface
70     [Tags]    Get
71     Wait Until Keyword Succeeds    5s    1s    Ensure The Fib Entry Is Present    ${vm_vpnint_values[2]}
72
73 Delete vm vpn interface
74     [Documentation]    Deletes the vpn interface
75     [Tags]    Delete
76     ${resp}    RequestsLibrary.Delete    session    ${REST_CON}l3vpn:vpn-interfaces/
77     Should Be Equal As Strings    ${resp.status_code}    200
78
79 Verify after deleteing vm vpn interface
80     [Documentation]    Verifies vpn interface after delete
81     [Tags]    Verify after delete
82     ${resp}    RequestsLibrary.Get    session    ${REST_CON}l3vpn:vpn-interfaces/    headers=${ACCEPT_XML}
83     Should Be Equal As Strings    ${resp.status_code}    404
84
85 Delete VPN Instance
86     [Documentation]    Deletes the VPN Instance
87     [Tags]    Delete
88     ${resp}    RequestsLibrary.Delete    session    ${REST_CON}l3vpn:vpn-instances/vpn-instance/${vpn_inst_values[0]}/
89     Should Be Equal As Strings    ${resp.status_code}    200
90
91 Verify after deleting the vpn instance
92     [Documentation]    Verifies after deleting the vpn instance
93     [Tags]    Verfiy after delete
94     ${resp}    RequestsLibrary.Get    session    ${REST_CON}l3vpn:vpn-instances/vpn-instance/${vpn_inst_values[0]}/    headers=${ACCEPT_XML}
95     Should Be Equal As Strings    ${resp.status_code}    404
96
97 Delete vm ietf interface
98     [Documentation]    Deletes the ietf interface
99     [Tags]    Delete
100     ${resp}    RequestsLibrary.Delete    session    ${REST_CON}ietf-interfaces:interfaces/interface/${vm_int_values[0]}
101     Should Be Equal As Strings    ${resp.status_code}    200
102
103 Verify after deleting vm ietf interface
104     [Documentation]    Verifies ietf interface after delete
105     [Tags]    Verify after delete
106     ${resp}    RequestsLibrary.Get    session    ${REST_CON}ietf-interfaces:interfaces/interface/${vm_int_values[0]}    headers=${ACCEPT_XML}
107     Should Be Equal As Strings    ${resp.status_code}    404
108
109 Verify FIB entry after delete
110     [Documentation]    Verifies the fib entry is deleted for the corresponding vpn interface
111     [Tags]    Get
112     Wait Until Keyword Succeeds    5s    1s    Ensure The Fib Entry Is Removed    ${vm_vpnint_values[2]}
113
114 *** Keywords ***
115 Ensure The Fib Entry Is Present
116     [Arguments]    ${prefix}
117     [Documentation]    Will succeed if the fib entry is present for the vpn
118     ${resp}    RequestsLibrary.Get    session    /restconf/operational/odl-fib:fibEntries/    headers=${ACCEPT_XML}
119     Should Be Equal As Strings    ${resp.status_code}    200
120     Log    ${resp.content}
121     Should Contain    ${resp.content}    ${prefix}
122     Should Contain    ${resp.content}    label
123
124 Ensure the Fib Entry Is Removed
125     [Arguments]    ${prefix}
126     [Documentation]    Will succeed if the fib entry is removed for the vpn
127     ${resp}    RequestsLibrary.Get    session    /restconf/operational/odl-fib:fibEntries/    headers=${ACCEPT_XML}
128     Should Be Equal As Strings    ${resp.status_code}    200
129     Should Not Contain    ${resp.content}    ${prefix}