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