Refactor SFC CSIT Variables
[integration/test.git] / csit / suites / sfc / Full_Deploy / 012__sfc_service_paths_validation.robot
1 *** Settings ***
2 Documentation     Test suite for SFC Service Function Paths validation. This validation is in charge of verifying that the SF types for the SFs defined in newly added SFPs are consistent with SF types defined in the referenced SFC.
3 Suite Setup       Init Suite
4 Suite Teardown    Delete All Sessions
5 Test Setup        Remove All Elements If Exist    ${SERVICE_FUNCTION_PATHS_URI}
6 Test Teardown     Clean_All_URIs
7 Library           SSHLibrary
8 Library           Collections
9 Library           OperatingSystem
10 Library           RequestsLibrary
11 Resource          ../../../variables/Variables.robot
12 Resource          ../../../variables/sfc/Variables.robot
13 Resource          ../../../libraries/Utils.robot
14 Resource          ../../../libraries/TemplatedRequests.robot
15
16 *** Test Cases ***
17 Add Service Function Path referencing a non-existing SF
18     [Documentation]    Add Service Function Paths from JSON file
19     Add Elements To URI From File And Check Server Error    ${SERVICE_FUNCTION_PATHS_URI}    ${SERVICE_FUNCTION_PATHS_WITH_HOP_FILE}
20     ${body}    OperatingSystem.Get File    ${SERVICE_FUNCTION_PATHS_WITH_HOP_FILE}
21     ${jsonbody}    To Json    ${body}
22     ${paths}    Get From Dictionary    ${jsonbody}    service-function-paths
23     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FUNCTION_PATHS_URI}
24     Should Be Equal As Strings    ${resp.status_code}    404
25
26 Add Service Function Path referencing a non-existing SFC
27     [Documentation]    Add Service Function Paths from JSON file
28     Add Elements To URI From File    ${SERVICE_FUNCTIONS_URI}    ${SERVICE_FUNCTIONS_FILE}
29     Add Elements To URI From File And Check Server Error    ${SERVICE_FUNCTION_PATHS_URI}    ${SERVICE_FUNCTION_PATHS_WITH_HOP_FILE}
30     ${body}    OperatingSystem.Get File    ${SERVICE_FUNCTION_PATHS_WITH_HOP_FILE}
31     ${jsonbody}    To Json    ${body}
32     ${paths}    Get From Dictionary    ${jsonbody}    service-function-paths
33     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FUNCTION_PATHS_URI}
34     Should Be Equal As Strings    ${resp.status_code}    404
35     Remove All Elements At URI    ${SERVICE_FUNCTIONS_URI}
36
37 Add Service Function Path where SFC types size and hop sizes differ
38     [Documentation]    Add Service Function Paths from JSON file
39     Add Elements To URI From File    ${SERVICE_FUNCTIONS_URI}    ${SERVICE_FUNCTIONS_FILE}
40     Add Elements To URI From File    ${SERVICE_CHAINS_URI}    ${SERVICE_CHAINS_FILE}
41     Add Elements To URI From File And Check Server Error    ${SERVICE_FUNCTION_PATHS_URI}    ${SERVICE_FUNCTION_PATHS_WITH_HOP_FILE}
42     ${body}    OperatingSystem.Get File    ${SERVICE_FUNCTION_PATHS_WITH_HOP_FILE}
43     ${jsonbody}    To Json    ${body}
44     ${paths}    Get From Dictionary    ${jsonbody}    service-function-paths
45     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FUNCTION_PATHS_URI}
46     Should Be Equal As Strings    ${resp.status_code}    404
47     Remove All Elements At URI    ${SERVICE_CHAINS_URI}
48     Remove All Elements At URI    ${SERVICE_FUNCTIONS_URI}
49
50 Add Service Function Path where SFC types size and types for SFs in hops differ
51     [Documentation]    Add Service Function Paths from JSON file
52     Add Elements To URI From File    ${SERVICE_FUNCTIONS_URI}    ${SERVICE_FUNCTIONS_FILE}
53     Add Elements To URI From File    ${SERVICE_CHAINS_URI}    ${SERVICE_CHAINS_FILE}
54     Add Elements To URI From File And Check Server Error    ${SERVICE_FUNCTION_PATHS_URI}    ${SERVICE_FUNCTION_PATHS_WITH_THREE_HOPS_FILE}
55     ${body}    OperatingSystem.Get File    ${SERVICE_FUNCTION_PATHS_WITH_HOP_FILE}
56     ${jsonbody}    To Json    ${body}
57     ${paths}    Get From Dictionary    ${jsonbody}    service-function-paths
58     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FUNCTION_PATHS_URI}
59     Should Be Equal As Strings    ${resp.status_code}    404
60     Remove All Elements At URI    ${SERVICE_FUNCTIONS_URI}
61     Remove All Elements At URI    ${SERVICE_CHAINS_URI}
62
63 Add Service Function Path where SFC types size and types for SFs in hops match
64     [Documentation]    Add Service Function Paths from JSON file
65     Add Elements To URI From File    ${SERVICE_FUNCTIONS_URI}    ${SERVICE_FUNCTIONS_FILE}
66     Add Elements To URI From File    ${SERVICE_CHAINS_URI}    ${SERVICE_CHAINS_FILE_FW_NAPT44_DPI}
67     Add Elements To URI From File And Verify    ${SERVICE_FUNCTION_PATHS_URI}    ${SERVICE_FUNCTION_PATHS_WITH_THREE_HOPS_FILE}
68     ${body}    OperatingSystem.Get File    ${SERVICE_FUNCTION_PATHS_FILE}
69     ${jsonbody}    To Json    ${body}
70     ${paths}    Get From Dictionary    ${jsonbody}    service-function-paths
71     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FUNCTION_PATHS_URI}
72     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
73     ${result}    To JSON    ${resp.content}
74     ${path}    Get From Dictionary    ${result}    service-function-paths
75     Lists Should be Equal    ${path}    ${paths}
76
77 *** keywords ***
78 Init Suite
79     [Documentation]    Initialize session and ODL version specific variables
80     Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
81     log    ${ODL_STREAM}
82     Set Suite Variable    ${VERSION_DIR}    master
83     Set Suite Variable    ${SFC_JSON_TEST_FILES_DIR}    ${CURDIR}/../../../variables/sfc/${VERSION_DIR}
84     Set Suite Variable    ${SERVICE_FUNCTION_PATHS_FILE}    ${SFC_JSON_TEST_FILES_DIR}/service-function-paths.json
85     Set Suite Variable    ${SERVICE_FUNCTION_PATHS_WITH_HOP_FILE}    ${SFC_JSON_TEST_FILES_DIR}/service-function-paths-with-one-hop.json
86     Set Suite Variable    ${SERVICE_FUNCTION_PATHS_WITH_THREE_HOPS_FILE}    ${SFC_JSON_TEST_FILES_DIR}/service-function-paths-with-three-hops-firewall-napt44-dpi.json
87     Set Suite Variable    ${SERVICE_FUNCTIONS_FILE}    ${SFC_JSON_TEST_FILES_DIR}/service-functions.json
88     Set Suite Variable    ${SERVICE_CHAINS_FILE}    ${SFC_JSON_TEST_FILES_DIR}/service-function-chains.json
89     Set Suite Variable    ${SERVICE_CHAINS_FILE_FW_NAPT44_DPI}    ${SFC_JSON_TEST_FILES_DIR}/service-function-chain-firewall-napt44-dpi.json
90
91 Clean_All_URIs
92     [Documentation]    Deletes all the elements which might have been created during SFP validation tests
93     Utils.Remove All Elements If Exist    ${SERVICE_FUNCTIONS_URI}
94     Utils.Remove All Elements If Exist    ${SERVICE_CHAINS_URI}
95     Utils.Remove All Elements If Exist    ${SERVICE_FUNCTION_PATHS_URI}