Beta version of a longevity test
[integration/test.git] / test / 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           ../../libraries/RequestsLibrary.py
6 Variables         ../../variables/Variables.py
7 Variables         ../../variables/vpnservice/Variables.py
8 Library           Collections
9
10 *** Variables ***
11 ${REST_CON}       /restconf/config/
12 @{vpn_inst_values}    testVpn1    1000:1    1000:1,2000:1    3000:1,4000:1
13 @{vm_int_values}    s1-eth1    l2vlan    openflow:1:1
14 @{vm_vpnint_values}    s1-eth1    testVpn1    10.0.0.1    12:f8:57:a8:b9:a1
15
16 *** Test Cases ***
17 Create VPN Instance
18     [Documentation]    Creates VPN Instance through restconf
19     [Tags]    Post
20     ${resp}    Post Json    session    ${REST_CON}l3vpn:vpn-instances/    data=${vpn_instance}
21     Log    ${resp.content}
22     Should Be Equal As Strings    ${resp.status_code}    204
23
24 Verify VPN instance
25     [Documentation]    Verifies the vpn instance is created
26     [Tags]    Get
27     ${resp}    RequestsLibrary.get    session    ${REST_CON}l3vpn:vpn-instances/vpn-instance/${vpn_inst_values[0]}/    headers=${ACCEPT_XML}
28     Should Be Equal As Strings    ${resp.status_code}    200
29     Log    ${resp.content}
30     : FOR    ${value}    IN    @{vpn_inst_values}
31     \    Should Contain    ${resp.content}    ${value}
32
33 Create ietf vm interface
34     [Documentation]    Creates ietf interface through the restconf
35     [Tags]    Post
36     ${resp}    Post Json    session    ${REST_CON}ietf-interfaces:interfaces/    data=${vm_interface}
37     Should Be Equal As Strings    ${resp.status_code}    204
38
39 Verify ietf vm interface
40     [Documentation]    Verifies ietf interface created
41     [Tags]    Get
42     ${resp}    RequestsLibrary.get    session    ${REST_CON}ietf-interfaces:interfaces/interface/${vm_int_values[0]}/    headers=${ACCEPT_XML}
43     Should Be Equal As Strings    ${resp.status_code}    200
44     Log    ${resp.content}
45     : FOR    ${value}    IN    @{vm_int_values}
46     \    Should Contain    ${resp.content}    ${value}
47
48 Create VPN interface
49     [Documentation]    Creates vpn interface for the corresponding ietf interface
50     [Tags]    Post
51     ${resp}    Post Json    session    ${REST_CON}l3vpn:vpn-interfaces/    data=${vm_vpninterface}
52     Should Be Equal As Strings    ${resp.status_code}    204
53
54 Verify VPN interface
55     [Documentation]    Verifies the vpn interface created
56     [Tags]    Get
57     ${resp}    RequestsLibrary.get    session    ${REST_CON}l3vpn:vpn-interfaces/    headers=${ACCEPT_XML}
58     Should Be Equal As Strings    ${resp.status_code}    200
59     Log    ${resp.content}
60     : FOR    ${value}    IN    @{vm_vpnint_values}
61     \    Should Contain    ${resp.content}    ${value}
62
63 Verify FIB entry after create
64     [Documentation]    Verifies the fib entry for the corresponding vpn interface
65     [Tags]    Get
66     Wait Until Keyword Succeeds    10s    2s    Ensure The Fib Entry Is Present    vrfTables/${vpn_inst_values[1]}/vrfEntry/${vm_vpnint_values[2]}/    ${vm_vpnint_values[2]}
67
68 Delete vm vpn interface
69     [Documentation]    Deletes the vpn interface
70     [Tags]    Delete
71     ${resp}    RequestsLibrary.Delete    session    ${REST_CON}l3vpn:vpn-interfaces/
72     Should Be Equal As Strings    ${resp.status_code}    200
73
74 Verify after deleteing vm vpn interface
75     [Documentation]    Verifies vpn interface after delete
76     [Tags]    Verify after delete
77     ${resp}    RequestsLibrary.get    session    ${REST_CON}l3vpn:vpn-interfaces/    headers=${ACCEPT_XML}
78     Should Be Equal As Strings    ${resp.status_code}    404
79
80 Delete VPN Instance
81     [Documentation]    Deletes the VPN Instance
82     [Tags]    Delete
83     ${resp}    RequestsLibrary.Delete    session    ${REST_CON}l3vpn:vpn-instances/vpn-instance/${vpn_inst_values[0]}/
84     Should Be Equal As Strings    ${resp.status_code}    200
85
86 Verify after deleting the vpn instance
87     [Documentation]    Verifies after deleting the vpn instance
88     [Tags]    Verfiy after delete
89     ${resp}    RequestsLibrary.get    session    ${REST_CON}l3vpn:vpn-instances/vpn-instance/${vpn_inst_values[0]}/    headers=${ACCEPT_XML}
90     Should Be Equal As Strings    ${resp.status_code}    404
91
92 Delete vm ietf interface
93     [Documentation]    Deletes the ietf interface
94     [Tags]    Delete
95     ${resp}    RequestsLibrary.Delete    session    ${REST_CON}ietf-interfaces:interfaces/interface/${vm_int_values[0]}
96     Should Be Equal As Strings    ${resp.status_code}    200
97
98 Verify after deleting vm ietf interface
99     [Documentation]    Verifies ietf interface after delete
100     [Tags]    Verify after delete
101     ${resp}    RequestsLibrary.get    session    ${REST_CON}ietf-interfaces:interfaces/interface/${vm_int_values[0]}    headers=${ACCEPT_XML}
102     Should Be Equal As Strings    ${resp.status_code}    404
103
104 Verify FIB entry after delete
105     [Documentation]    Verifies the fib entry is deleted for the corresponding vpn interface
106     [Tags]    Get
107     Wait Until Keyword Succeeds    10s    2s    Ensure The Fib Entry Is Removed    vrfTables/${vpn_inst_values[1]}/vrfEntry/${vm_vpnint_values[2]}/
108
109 *** Keywords ***
110 Ensure The Fib Entry Is Present
111     [Arguments]    ${uri_part}    ${prefix}
112     [Documentation]    Will succeed if the fib entry is present for the vpn
113     ${resp}    RequestsLibrary.get    session    ${REST_CON}odl-fib:fibEntries/${uri_part}    headers=${ACCEPT_XML}
114     Should Be Equal As Strings    ${resp.status_code}    200
115     Log    ${resp.content}
116     Should Contain    ${resp.content}    ${prefix}
117     Should Contain    ${resp.content}    label
118
119 Ensure the Fib Entry Is Removed
120     [Arguments]    ${uri_part}
121     [Documentation]    Will succeed if the fib entry is removed for the vpn
122     ${resp}    RequestsLibrary.get    session    ${REST_CON}odl-fib:fibEntries/${uri_part}    headers=${ACCEPT_XML}
123     Should Be Equal As Strings    ${resp.status_code}    404