Upgrade RF syntax for v3.2 compatibility
[integration/test.git] / csit / suites / sfc / SFC_Basic / 020__sfc_service_forwarders.robot
1 *** Settings ***
2 Documentation     Test suite for SFC Service Function Forwarders, Operates SFFs from Restconf APIs.
3 Suite Setup       Init Suite
4 Suite Teardown    Delete All Sessions
5 Test Setup        Remove All Elements If Exist    ${SERVICE_FORWARDERS_URI}
6 Library           SSHLibrary
7 Library           Collections
8 Library           OperatingSystem
9 Library           RequestsLibrary
10 Resource          ../../../variables/sfc/Variables.robot
11 Resource          ../../../libraries/Utils.robot
12 Resource          ../../../libraries/TemplatedRequests.robot
13
14 *** Test Cases ***
15 Put Service Function Forwarders
16     [Documentation]    Add Service Function Forwarders from JSON file
17     Add Elements To URI From File    ${SERVICE_FORWARDERS_URI}    ${SERVICE_FORWARDERS_FILE}
18     ${body}    OperatingSystem.Get File    ${SERVICE_FORWARDERS_FILE}
19     ${jsonbody}    To Json    ${body}
20     ${forwarders}    Get From Dictionary    ${jsonbody}    service-function-forwarders
21     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FORWARDERS_URI}
22     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
23     ${result}    To JSON    ${resp.content}
24     ${forwarder}    Get From Dictionary    ${result}    service-function-forwarders
25     Lists Should be Equal    ${forwarder}    ${forwarders}
26
27 Delete All Service Function Forwarders
28     [Documentation]    Delete all Service Function Forwarders
29     Add Elements To URI From File    ${SERVICE_FORWARDERS_URI}    ${SERVICE_FORWARDERS_FILE}
30     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FORWARDERS_URI}
31     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
32     Remove All Elements At URI    ${SERVICE_FORWARDERS_URI}
33     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FORWARDERS_URI}
34     Should Be Equal As Strings    ${resp.status_code}    404
35
36 Get one Service Function Forwarder
37     [Documentation]    Get one Service Function Forwarder
38     Add Elements To URI From File    ${SERVICE_FORWARDERS_URI}    ${SERVICE_FORWARDERS_FILE}
39     ${elements}=    Create List    SFF-bootstrap    service-locator:vxlan-gpe    SF1
40     Check For Elements At URI    ${SFF_BOOTSTRAP_URI}    ${elements}
41
42 Get A Non-existing Service Function Forwarder
43     [Documentation]    Get A Non-existing Service Function Forwarder
44     Add Elements To URI From File    ${SERVICE_FORWARDERS_URI}    ${SERVICE_FORWARDERS_FILE}
45     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FORWARDER_URI}/non-existing-sff
46     Should Be Equal As Strings    ${resp.status_code}    404
47
48 Delete A Service Function Forwarder
49     [Documentation]    Delete A Service Function Forwarder
50     Add Elements To URI From File    ${SERVICE_FORWARDERS_URI}    ${SERVICE_FORWARDERS_FILE}
51     ${resp}    RequestsLibrary.Get Request    session    ${SFF_BOOTSTRAP_URI}
52     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
53     Remove All Elements At URI    ${SFF_BOOTSTRAP_URI}
54     ${resp}    RequestsLibrary.Get Request    session    ${SFF_BOOTSTRAP_URI}
55     Should Be Equal As Strings    ${resp.status_code}    404
56     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FORWARDERS_URI}
57     Should Be Equal As Strings    ${resp.status_code}    200
58     Should Not Contain    ${resp.content}    SF1
59
60 Delete A Non-existing Service Function Forwarder
61     [Documentation]    Delete A Non existing Service Function
62     Add Elements To URI From File    ${SERVICE_FORWARDERS_URI}    ${SERVICE_FORWARDERS_FILE}
63     ${body}    OperatingSystem.Get File    ${SERVICE_FORWARDERS_FILE}
64     ${jsonbody}    To Json    ${body}
65     ${forwarders}    Get From Dictionary    ${jsonbody}    service-function-forwarders
66     ${resp}    RequestsLibrary.Delete Request    session    ${SERVICE_FORWARDER_URI}/non-existing-sff
67     Should Be Equal As Strings    ${resp.status_code}    404
68     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FORWARDERS_URI}
69     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
70     ${result}    To JSON    ${resp.content}
71     ${forwarder}    Get From Dictionary    ${result}    service-function-forwarders
72     Lists Should be Equal    ${forwarder}    ${forwarders}
73
74 Put one Service Function Forwarder
75     [Documentation]    Put one Service Function Forwarder
76     Add Elements To URI From File    ${SFF_OVS100_URI}    ${SFF_OVS100_FILE}
77     ${resp}    RequestsLibrary.Get Request    session    ${SFF_OVS100_URI}
78     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
79     ${elements}=    Create List    ovs-100    SF7
80     Check For Elements At URI    ${SFF_OVS100_URI}    ${elements}
81     Check For Elements At URI    ${SERVICE_FORWARDERS_URI}    ${elements}
82
83 Get Service Function Forwarder DPL
84     [Documentation]    Get Service Function Data Plane Locator
85     Add Elements To URI From File    ${SFF_OVS100_URI}    ${SFF_OVS100_FILE}
86     ${elements}=    Create List    eth0    service-locator:vxlan-gpe
87     Check For Elements At URI    ${SFF_OVS100_URI}/sff-data-plane-locator/eth0    ${elements}
88
89 Put Service Function Forwarder DPL
90     [Documentation]    Put Service Function Forwarder Data Plane Locator
91     Add Elements To URI From File    ${SFF_OVS100_URI}    ${SFF_OVS100_FILE}
92     Add Elements To URI From File    ${SFF_OVS100_URI}/sff-data-plane-locator/dpl-101    ${SFF_DPL101_FILE}
93     ${elements}=    Create List    dpl-101    6101
94     Check For Elements At URI    ${SFF_OVS100_URI}/sff-data-plane-locator/dpl-101    ${elements}
95     Check For Elements At URI    ${SFF_OVS100_URI}    ${elements}
96
97 Put DPL to a Non-existing Service Function Forwarder
98     [Documentation]    Put Service Function DPL to a Non-existing Service Function
99     Add Elements To URI From File    ${SFF_OVS100_URI}/sff-data-plane-locator/dpl-101    ${SFF_DPL101_FILE}
100     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FORWARDERS_URI}
101     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
102     Should Contain    ${resp.content}    ovs-100
103     ${elements}=    Create List    dpl-101    6101
104     Check For Elements At URI    ${SFF_OVS100_URI}/sff-data-plane-locator/dpl-101    ${elements}
105     Check For Elements At URI    ${SFF_OVS100_URI}    ${elements}
106
107 Delete Service Function Forwarder DPL
108     [Documentation]    Delete Service Function Forwarder Data Plane Locator
109     Add Elements To URI From File    ${SFF_OVS100_URI}    ${SFF_OVS100_FILE}
110     Remove All Elements At URI    ${SFF_OVS100_URI}/sff-data-plane-locator/eth0
111     ${resp}    RequestsLibrary.Get Request    session    ${SFF_OVS100_URI}
112     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
113     Should Not Contain    ${resp.content}    "name":"eth0"
114
115 Get Service Function Forwarder DPL's Locator
116     [Documentation]    Get Service Function Data Plane Locator
117     Add Elements To URI From File    ${SFF_OVS100_URI}    ${SFF_OVS100_FILE}
118     ${elements}=    Create List    6000    service-locator:vxlan-gpe
119     Check For Elements At URI    ${SFF_OVS100_URI}/sff-data-plane-locator/eth0/data-plane-locator/    ${elements}
120
121 Put Service Function Forwarder DPL's Locator
122     [Documentation]    Put Service Function Forwarder Data Plane Locator
123     Add Elements To URI From File    ${SFF_OVS100_URI}    ${SFF_OVS100_FILE}
124     Add Elements To URI From File    ${SFF_OVS100_URI}/sff-data-plane-locator/dpl-101    ${SFF_DPL101_FILE}
125     Add Elements To URI From File    ${SFF_OVS100_URI}/sff-data-plane-locator/dpl-101/data-plane-locator/    ${SFF_DPL_LOCATOR_FILE}
126     ${elements}=    Create List    5000    service-locator:vxlan-gpe
127     Check For Elements At URI    ${SFF_OVS100_URI}/sff-data-plane-locator/dpl-101/data-plane-locator    ${elements}
128     ${elements}=    Create List    dpl-101    5000    service-locator:vxlan-gpe
129     Check For Elements At URI    ${SFF_OVS100_URI}/sff-data-plane-locator/dpl-101    ${elements}
130     Check For Elements At URI    ${SFF_OVS100_URI}    ${elements}
131
132 Delete Service Function Forwarder DPL's Locator
133     [Documentation]    Delete Service Function Forwarder Data Plane Locator
134     [Tags]    exclude
135     Add Elements To URI From File    ${SFF_OVS100_URI}    ${SFF_OVS100_FILE}
136     Add Elements To URI From File    ${SFF_OVS100_URI}/sff-data-plane-locator/dpl-101    ${SFF_DPL101_FILE}
137     Add Elements To URI From File    ${SFF_OVS100_URI}/sff-data-plane-locator/dpl-101/data-plane-locator    ${SFF_DPL_LOCATOR_FILE}
138     Remove All Elements At URI    ${SFF_OVS100_URI}/sff-data-plane-locator/dpl-101/data-plane-locator
139     ${resp}    RequestsLibrary.Get Request    session    ${SFF_OVS100_URI}/sff-data-plane-locator/dpl-101
140     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
141     Should Contain    ${resp.content}    dpl-101
142     Should Not Contain    ${resp.content}    6101
143     Should Not Contain    ${resp.content}    service-locator:vxlan-gpe
144     ${resp}    RequestsLibrary.Get Request    session    ${SFF_OVS100_URI}
145     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
146     Should Contain    ${resp.content}    dpl-101
147     Should Not Contain    ${resp.content}    6101
148
149 Get Service Function Dictionary From SFF
150     [Documentation]    Get Service Function Dictionary From SFF
151     Add Elements To URI From File    ${SERVICE_FORWARDERS_URI}    ${SERVICE_FORWARDERS_FILE}
152     ${elements}=    Create List    service-function-dictionary    SF1    SF1-DPL    eth0
153     Check For Elements At URI    ${SFF_BOOTSTRAP_URI}/${SF_DICT_SF1_URI}    ${elements}
154
155 Delete Service Function Dictionary From SFF
156     [Documentation]    Delete Service Function Dictionary From SFF
157     Add Elements To URI From File    ${SERVICE_FORWARDERS_URI}    ${SERVICE_FORWARDERS_FILE}
158     ${resp}    RequestsLibrary.Get Request    session    ${SFF_BOOTSTRAP_URI}/${SF_DICT_SF1_URI}
159     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
160     Remove All Elements At URI    ${SFF_BOOTSTRAP_URI}/${SF_DICT_SF1_URI}
161     ${resp}    RequestsLibrary.Get Request    session    ${SFF_BOOTSTRAP_URI}/${SF_DICT_SF1_URI}
162     Should Be Equal As Strings    ${resp.status_code}    404
163     ${resp}    RequestsLibrary.Get Request    session    ${SFF_BOOTSTRAP_URI}
164     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
165     Should Contain    ${resp.content}    service-function-dictionary
166     Should Not Contain    ${resp.content}    SF1
167
168 Put Service Function Dictionary to SFF
169     [Documentation]    Put Service Function Dictionary to SFF
170     Add Elements To URI From File    ${SERVICE_FORWARDERS_URI}    ${SERVICE_FORWARDERS_FILE}
171     Add Elements To URI From File    ${SFF_BOOTSTRAP_URI}/service-function-dictionary/SF100    ${SFF_SFD_SF100_FILE}
172     ${elements}=    Create List    SF100    SF2-DPL    eth0
173     Check For Elements At URI    ${SFF_BOOTSTRAP_URI}/service-function-dictionary/SF100    ${elements}
174     ${elements}=    create list    service-function-dictionary    SF100    SF2-DPL    eth0
175     Check For Elements At URI    ${SFF_BOOTSTRAP_URI}    ${elements}
176
177 Get Service Function Dictionary's DPL From SFF
178     [Documentation]    Get Service Function Dictionary From SFF
179     Add Elements To URI From File    ${SERVICE_FORWARDERS_URI}    ${SERVICE_FORWARDERS_FILE}
180     ${elements}=    create list    sff-sf-data-plane-locator    SF1-DPL    eth0
181     Check For Elements At URI    ${SFF_BOOTSTRAP_URI}/${SF_DICT_SF1_URI}/sff-sf-data-plane-locator/    ${elements}
182
183 Delete Service Function Dictionary's DPL From SFF
184     [Documentation]    Delete Service Function Dictionary From SFF
185     Add Elements To URI From File    ${SERVICE_FORWARDERS_URI}    ${SERVICE_FORWARDERS_FILE}
186     ${resp}    RequestsLibrary.Get Request    session    ${SFF_BOOTSTRAP_URI}/${SF_DICT_SF1_URI}/sff-sf-data-plane-locator
187     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
188     Remove All Elements At URI    ${SFF_BOOTSTRAP_URI}/${SF_DICT_SF1_URI}/sff-sf-data-plane-locator
189     ${resp}    RequestsLibrary.Get Request    session    ${SFF_BOOTSTRAP_URI}/${SF_DICT_SF1_URI}/sff-sf-data-plane-locator
190     Should Be Equal As Strings    ${resp.status_code}    404
191
192 Put DPL of Service Function Dictionary to SFF
193     [Documentation]    Put DPL of Service Function Dictionary to SFF
194     Add Elements To URI From File    ${SERVICE_FORWARDERS_URI}    ${SERVICE_FORWARDERS_FILE}
195     Add Elements To URI From File    ${SFF_BOOTSTRAP_URI}/${SF_DICT_SF1_URI}/sff-sf-data-plane-locator    ${SFF_SFD_LOCATOR_FILE}
196     ${elements}=    create list    sff-sf-data-plane-locator    SF2-DPL    eth0
197     Check For Elements At URI    ${SFF_BOOTSTRAP_URI}/${SF_DICT_SF1_URI}/sff-sf-data-plane-locator    ${elements}
198     Check For Elements At URI    ${SFF_BOOTSTRAP_URI}/${SF_DICT_SF1_URI}    ${elements}
199
200 Get Connected SFF Dictionary From SFF
201     [Documentation]    Get Connected SFF Dictionary Dictionary From SFF
202     Add Elements To URI From File    ${SERVICE_FORWARDERS_URI}    ${SERVICE_FORWARDERS_FILE}
203     ${elements}=    create list    connected-sff-dictionary    br-int-ovs-2    sff-sff-data-plane-locator
204     Check For Elements At URI    ${SFF_BOOTSTRAP_URI}/connected-sff-dictionary/br-int-ovs-2    ${elements}
205     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FORWARDER_URI}/br-int-ovs-2/connected-sff-dictionary/SFF-bootstrap
206     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
207     Should Contain    ${resp.content}    SFF-bootstrap
208
209 Delete Connected SFF Dictionary From SFF
210     [Documentation]    Delete Connected SFF Dictionary From SFF
211     Add Elements To URI From File    ${SERVICE_FORWARDERS_URI}    ${SERVICE_FORWARDERS_FILE}
212     ${resp}    RequestsLibrary.Get Request    session    ${SFF_BOOTSTRAP_URI}/connected-sff-dictionary/br-int-ovs-2
213     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
214     Remove All Elements At URI    ${SFF_BOOTSTRAP_URI}/connected-sff-dictionary/br-int-ovs-2
215     ${resp}    RequestsLibrary.Get Request    session    ${SFF_BOOTSTRAP_URI}/connected-sff-dictionary/br-int-ovs-2
216     Should Be Equal As Strings    ${resp.status_code}    404
217     ${resp}    RequestsLibrary.Get Request    session    ${SFF_BOOTSTRAP_URI}
218     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
219     Should Not Contain    ${resp.content}    br-int-ovs-2
220
221 Put Connected SFF Dictionary to SFF
222     [Documentation]    Put Connected SFF Dictionary to SFF
223     Add Elements To URI From File    ${SERVICE_FORWARDERS_URI}    ${SERVICE_FORWARDERS_FILE}
224     Add Elements To URI From File    ${SFF_BOOTSTRAP_URI}/connected-sff-dictionary/SFF100    ${SFF_CSD_SFF100_FILE}
225     ${elements}=    create list    SFF100    service-function-forwarder:open
226     Check For Elements At URI    ${SFF_BOOTSTRAP_URI}/connected-sff-dictionary/SFF100    ${elements}
227     Check For Elements At URI    ${SFF_BOOTSTRAP_URI}    ${elements}
228
229 Get Connected SFF Dictionary's DPL From SFF
230     [Documentation]    Get Connected SFF Dictionary's DPL From SFF
231     Add Elements To URI From File    ${SERVICE_FORWARDERS_URI}    ${SERVICE_FORWARDERS_FILE}
232     ${elements}=    create list    sff-sff-data-plane-locator    5000    192.168.1.2
233     Check For Elements At URI    ${SFF_BOOTSTRAP_URI}/connected-sff-dictionary/br-int-ovs-2/sff-sff-data-plane-locator    ${elements}
234
235 Put DPL of Connected SFF Dictionary to SFF
236     [Documentation]    Put DPL of Connected SFF Dictionary to SFF
237     Add Elements To URI From File    ${SERVICE_FORWARDERS_URI}    ${SERVICE_FORWARDERS_FILE}
238     Add Elements To URI From File    ${SFF_BOOTSTRAP_URI}/connected-sff-dictionary/br-int-ovs-2/sff-sff-data-plane-locator    ${SFF_CSD_LOCATOR_FILE}
239     ${elements}=    create list    sff-sff-data-plane-locator    6000    10.1.1.1
240     Check For Elements At URI    ${SFF_BOOTSTRAP_URI}/connected-sff-dictionary/br-int-ovs-2/sff-sff-data-plane-locator    ${elements}
241     Check For Elements At URI    ${SFF_BOOTSTRAP_URI}/connected-sff-dictionary/br-int-ovs-2    ${elements}
242
243 *** Keywords ***
244 Init Suite
245     [Documentation]    Initialize session and ODL version specific variables
246     Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
247     log    ${ODL_STREAM}
248     Set Suite Variable    ${VERSION_DIR}    master
249     Set Suite Variable    ${TEST_DIR}    ${CURDIR}/../../../variables/sfc/${VERSION_DIR}
250     Set Suite Variable    ${SERVICE_FORWARDERS_FILE}    ${TEST_DIR}/service-function-forwarders.json
251     Set Suite Variable    ${SFF_OVS100_URI}    ${SERVICE_FORWARDER_URI}/ovs-100
252     Set Suite Variable    ${SFF_BOOTSTRAP_URI}    ${SERVICE_FORWARDER_URI}/SFF-bootstrap
253     Set Suite Variable    ${SF_DICT_SF1_URI}    service-function-dictionary/SF1
254     Set Suite Variable    ${SFF_OVS100_FILE}    ${TEST_DIR}/sff_ovs_100.json
255     Set Suite Variable    ${SFF_DPL101_FILE}    ${TEST_DIR}/sff_dpl_101.json
256     Set Suite Variable    ${SFF_DPL_LOCATOR_FILE}    ${TEST_DIR}/sff_dpl_locator.json
257     Set Suite Variable    ${SFF_SFD_SF100_FILE}    ${TEST_DIR}/sff_sfd_sf100.json
258     Set Suite Variable    ${SFF_SFD_LOCATOR_FILE}    ${TEST_DIR}/sff_sfd_locator.json
259     Set Suite Variable    ${SFF_CSD_SFF100_FILE}    ${TEST_DIR}/sff_csd_sff100.json
260     Set Suite Variable    ${SFF_CSD_LOCATOR_FILE}    ${TEST_DIR}/sff_csd_locator.json