SFC: Implement boron and carbon scope
[integration/test.git] / csit / suites / sfc / Full_Deploy / 013__sfc_service_functions_logical.robot
1 *** Settings ***
2 Documentation     Test suite for SFC Service Functions using Logical SFF functionality, Operates functions from Restconf APIs.
3 Suite Setup       Init Suite
4 Suite Teardown    Delete All Sessions
5 Test Setup        Remove All Elements If Exist    ${SERVICE_FUNCTIONS_URI}
6 Test Teardown     Remove All Elements If Exist    ${SERVICE_FUNCTIONS_URI}
7 Library           SSHLibrary
8 Library           Collections
9 Library           OperatingSystem
10 Library           RequestsLibrary
11 Resource          ../../../variables/sfc/Variables.robot
12 Resource          ../../../libraries/Utils.robot
13 Resource          ../../../libraries/TemplatedRequests.robot
14
15 *** Variables ***
16 ${VERSION_DIR}    master
17 ${SERVICE_FUNCTIONS_FILE}    ${CURDIR}/../../../variables/sfc/${VERSION_DIR}/service-functions-logicalsff.json
18 ${SF_DPI_URI}     ${SERVICE_FUNCTION_URI}dpi-1/
19 ${SF_DPI_FILE}    ${CURDIR}/../../../variables/sfc/${VERSION_DIR}/sf_dpi.json
20
21 *** Test Cases ***
22 Add Service Functions
23     [Documentation]    Add Service Functions from JSON file. Logical SFF
24     Add Elements To URI From File    ${SERVICE_FUNCTIONS_URI}    ${SERVICE_FUNCTIONS_FILE}
25     ${body}    OperatingSystem.Get File    ${SERVICE_FUNCTIONS_FILE}
26     ${jsonbody}    To Json    ${body}
27     ${functions}    Get From Dictionary    ${jsonbody}    service-functions
28     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FUNCTIONS_URI}
29     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
30     ${result}    To JSON    ${resp.content}
31     ${function}    Get From Dictionary    ${result}    service-functions
32     Lists Should be Equal    ${function}    ${functions}
33
34 Delete All Service Functions
35     [Documentation]    Delete all Service Functions. Logical SFF
36     ${body}    OperatingSystem.Get File    ${SERVICE_FUNCTIONS_FILE}
37     Add Elements To URI From File    ${SERVICE_FUNCTIONS_URI}    ${SERVICE_FUNCTIONS_FILE}
38     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FUNCTIONS_URI}
39     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
40     Remove All Elements At URI    ${SERVICE_FUNCTIONS_URI}
41     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FUNCTIONS_URI}
42     Should Be Equal As Strings    ${resp.status_code}    404
43
44 Get one Service Function
45     [Documentation]    Get one Service Function. Logical SFF
46     Add Elements To URI From File    ${SERVICE_FUNCTIONS_URI}    ${SERVICE_FUNCTIONS_FILE}
47     ${elements}=    Create List    firewall-1    firewall
48     Check For Elements At URI    ${SERVICE_FUNCTION_URI}firewall-1    ${elements}
49
50 Get A Non-existing Service Function
51     [Documentation]    Get A Non-existing Service Function. Logical SFF
52     Add Elements To URI From File    ${SERVICE_FUNCTIONS_URI}    ${SERVICE_FUNCTIONS_FILE}
53     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FUNCTION_URI}non-existing-sf
54     Should Be Equal As Strings    ${resp.status_code}    404
55
56 Delete A Service Function
57     [Documentation]    Delete A Service Function. Logical SFF
58     Add Elements To URI From File    ${SERVICE_FUNCTIONS_URI}    ${SERVICE_FUNCTIONS_FILE}
59     Remove All Elements At URI    ${SERVICE_FUNCTION_URI}dpi-1
60     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FUNCTIONS_URI}
61     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
62     Should Not Contain    ${resp.content}    dpi-1
63
64 Delete A Non-existing Empty Service Function
65     [Documentation]    Delete A Non existing Service Function. Logical SFF
66     Add Elements To URI From File    ${SERVICE_FUNCTIONS_URI}    ${SERVICE_FUNCTIONS_FILE}
67     ${body}    OperatingSystem.Get File    ${SERVICE_FUNCTIONS_FILE}
68     ${jsonbody}    To Json    ${body}
69     ${functions}    Get From Dictionary    ${jsonbody}    service-functions
70     ${resp}    RequestsLibrary.Delete Request    session    ${SERVICE_FUNCTION_URI}non-existing-sf
71     Should Be Equal As Strings    ${resp.status_code}    404
72     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FUNCTIONS_URI}
73     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
74     ${result}    To JSON    ${resp.content}
75     ${function}    Get From Dictionary    ${result}    service-functions
76     Lists Should be Equal    ${function}    ${functions}
77
78 Put one Service Function
79     [Documentation]    Put one Service Function. Logical SFF
80     [Tags]    include
81     Add Elements To URI From File    ${SF_DPI_URI}    ${SF_DPI_FILE}
82     ${elements}=    Create List    dpi-1    dpi
83     Check For Elements At URI    ${SF_DPI_URI}    ${elements}
84     Check For Elements At URI    ${SERVICE_FUNCTIONS_URI}    ${elements}
85
86 *** Keywords ***
87 Init Suite
88     [Documentation]    Initialize session and ODL version specific variables .Logical SFF
89     Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
90     log    ${ODL_STREAM}