Upgrade RF syntax for v3.2 compatibility
[integration/test.git] / csit / suites / sfc / SFC_Basic / 060__sfc_service_paths.robot
1 *** Settings ***
2 Documentation     Test suite for SFC Service Function Paths, Operates paths from Restconf APIs.
3 Suite Setup       Init Suite
4 Suite Teardown    Delete All Sessions
5 Test Setup        Remove All Elements If Exist    ${SERVICE_FUNCTION_PATHS_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 Add Service Function Paths
16     [Documentation]    Add Service Function Paths from JSON file
17     Add Elements To URI From File    ${SERVICE_FUNCTION_PATHS_URI}    ${SERVICE_FUNCTION_PATHS_FILE}
18     ${body}    OperatingSystem.Get File    ${SERVICE_FUNCTION_PATHS_FILE}
19     ${jsonbody}    To Json    ${body}
20     ${paths}    Get From Dictionary    ${jsonbody}    service-function-paths
21     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FUNCTION_PATHS_URI}
22     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
23     ${result}    To JSON    ${resp.content}
24     ${path}    Get From Dictionary    ${result}    service-function-paths
25     Lists Should be Equal    ${path}    ${paths}
26
27 Delete All Service Function Paths
28     [Documentation]    Delete all Service Function Paths
29     Add Elements To URI From File    ${SERVICE_FUNCTION_PATHS_URI}    ${SERVICE_FUNCTION_PATHS_FILE}
30     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FUNCTION_PATHS_URI}
31     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
32     Remove All Elements At URI    ${SERVICE_FUNCTION_PATHS_URI}
33     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FUNCTION_PATHS_URI}
34     Should Be Equal As Strings    ${resp.status_code}    404
35
36 Get one Service Function Path
37     [Documentation]    Get one Service Function Path
38     Add Elements To URI From File    ${SERVICE_FUNCTION_PATHS_URI}    ${SERVICE_FUNCTION_PATHS_FILE}
39     ${elements}=    Create List    SFC1-100    "service-chain-name":"SFC1"
40     Check For Elements At URI    ${SERVICE_FUNCTION_PATH_URI}/SFC1-100    ${elements}
41
42 Get A Non-existing Service Function Path
43     [Documentation]    Get A Non-existing Service Function Path
44     Add Elements To URI From File    ${SERVICE_FUNCTION_PATHS_URI}    ${SERVICE_FUNCTION_PATHS_FILE}
45     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FUNCTION_PATH_URI}/non-existing-sfp
46     Should Be Equal As Strings    ${resp.status_code}    404
47
48 Delete A Service Function Path
49     [Documentation]    Delete A Service Function Path
50     Add Elements To URI From File    ${SERVICE_FUNCTION_PATHS_URI}    ${SERVICE_FUNCTION_PATHS_FILE}
51     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FUNCTION_PATH_URI}/SFC1-100
52     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
53     Remove All Elements At URI    ${SERVICE_FUNCTION_PATH_URI}/SFC1-100
54     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FUNCTION_PATH_URI}/SFC1-100
55     Should Be Equal As Strings    ${resp.status_code}    404
56     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FUNCTION_PATHS_URI}
57     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
58     Should Not Contain    ${resp.content}    SFC1-100
59
60 Delete A Non-existing Empty Service Function Path
61     [Documentation]    Delete A Non existing Service Function Path
62     Add Elements To URI From File    ${SERVICE_FUNCTION_PATHS_URI}    ${SERVICE_FUNCTION_PATHS_FILE}
63     ${body}    OperatingSystem.Get File    ${SERVICE_FUNCTION_PATHS_FILE}
64     ${jsonbody}    To Json    ${body}
65     ${paths}    Get From Dictionary    ${jsonbody}    service-function-paths
66     ${resp}    RequestsLibrary.Delete Request    session    ${SERVICE_FUNCTION_PATH_URI}/non-existing-sfp
67     Should Be Equal As Strings    ${resp.status_code}    404
68     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FUNCTION_PATHS_URI}
69     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
70     ${result}    To JSON    ${resp.content}
71     ${path}    Get From Dictionary    ${result}    service-function-paths
72     Lists Should be Equal    ${path}    ${paths}
73
74 Put One Service Function Path
75     [Documentation]    Put one Service Function Path
76     Add Elements To URI From File    ${SERVICE_FUNCTION_PATH400_URI}    ${SERVICE_FUNCTION_PATH400_FILE}
77     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FUNCTION_PATH400_URI}
78     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
79     Should Contain    ${resp.content}    SFC1-400
80     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FUNCTION_PATHS_URI}
81     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
82     Should Contain    ${resp.content}    SFC1-400
83
84 *** Keywords ***
85 Init Suite
86     [Documentation]    Initialize session and ODL version specific variables
87     Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
88     log    ${ODL_STREAM}
89     Set Suite Variable    ${VERSION_DIR}    master
90     Set Suite Variable    ${TEST_DIR}    ${CURDIR}/../../../variables/sfc/${VERSION_DIR}
91     Set Suite Variable    ${SERVICE_FUNCTION_PATHS_FILE}    ${TEST_DIR}/service-function-paths.json
92     Set Suite Variable    ${SERVICE_FUNCTION_PATH400_URI}    ${SERVICE_FUNCTION_PATH_URI}/SFC1-400
93     Set Suite Variable    ${SERVICE_FUNCTION_PATH400_FILE}    ${TEST_DIR}/sfp_sfc1_path400.json