Upgrade RF syntax for v3.2 compatibility
[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          ../../../libraries/CompareStream.robot
12 Resource          ../../../libraries/TemplatedRequests.robot
13 Resource          ../../../libraries/Utils.robot
14 Resource          ../../../variables/Variables.robot
15 Resource          ../../../variables/sfc/Variables.robot
16
17 *** Test Cases ***
18 Add Service Function Path referencing a non-existing SF
19     [Documentation]    Add Service Function Paths from JSON file
20     CompareStream.Run_Keyword_If_Equals_Else    neon    Add Elements To URI From File And Check Validation Error    ${SERVICE_FUNCTION_PATHS_URI}    ${SERVICE_FUNCTION_PATHS_WITH_HOP_FILE}
21     ...    ELSE    Add Elements To URI From File And Check Server Error    ${SERVICE_FUNCTION_PATHS_URI}    ${SERVICE_FUNCTION_PATHS_WITH_HOP_FILE}
22     ${body}    OperatingSystem.Get File    ${SERVICE_FUNCTION_PATHS_WITH_HOP_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 Be Equal As Strings    ${resp.status_code}    404
27
28 Add Service Function Path referencing a non-existing SFC
29     [Documentation]    Add Service Function Paths from JSON file
30     Add Elements To URI From File    ${SERVICE_FUNCTIONS_URI}    ${SERVICE_FUNCTIONS_FILE}
31     CompareStream.Run_Keyword_If_Equals_Else    neon    Add Elements To URI From File And Check Validation Error    ${SERVICE_FUNCTION_PATHS_URI}    ${SERVICE_FUNCTION_PATHS_WITH_HOP_FILE}
32     ...    ELSE    Add Elements To URI From File And Check Server Error    ${SERVICE_FUNCTION_PATHS_URI}    ${SERVICE_FUNCTION_PATHS_WITH_HOP_FILE}
33     ${body}    OperatingSystem.Get File    ${SERVICE_FUNCTION_PATHS_WITH_HOP_FILE}
34     ${jsonbody}    To Json    ${body}
35     ${paths}    Get From Dictionary    ${jsonbody}    service-function-paths
36     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FUNCTION_PATHS_URI}
37     Should Be Equal As Strings    ${resp.status_code}    404
38     Remove All Elements At URI    ${SERVICE_FUNCTIONS_URI}
39
40 Add Service Function Path where SFC types size and hop sizes differ
41     [Documentation]    Add Service Function Paths from JSON file
42     Add Elements To URI From File    ${SERVICE_FUNCTIONS_URI}    ${SERVICE_FUNCTIONS_FILE}
43     Add Elements To URI From File    ${SERVICE_CHAINS_URI}    ${SERVICE_CHAINS_FILE}
44     CompareStream.Run_Keyword_If_At_Least_Else    neon    Add Elements To URI From File And Check Validation Error    ${SERVICE_FUNCTION_PATHS_URI}    ${SERVICE_FUNCTION_PATHS_WITH_HOP_FILE}
45     ...    ELSE    Add Elements To URI From File And Check Server Error    ${SERVICE_FUNCTION_PATHS_URI}    ${SERVICE_FUNCTION_PATHS_WITH_HOP_FILE}
46     ${body}    OperatingSystem.Get File    ${SERVICE_FUNCTION_PATHS_WITH_HOP_FILE}
47     ${jsonbody}    To Json    ${body}
48     ${paths}    Get From Dictionary    ${jsonbody}    service-function-paths
49     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FUNCTION_PATHS_URI}
50     Should Be Equal As Strings    ${resp.status_code}    404
51     Remove All Elements At URI    ${SERVICE_CHAINS_URI}
52     Remove All Elements At URI    ${SERVICE_FUNCTIONS_URI}
53
54 Add Service Function Path where SFC types size and types for SFs in hops differ
55     [Documentation]    Add Service Function Paths from JSON file
56     Add Elements To URI From File    ${SERVICE_FUNCTIONS_URI}    ${SERVICE_FUNCTIONS_FILE}
57     Add Elements To URI From File    ${SERVICE_CHAINS_URI}    ${SERVICE_CHAINS_FILE}
58     CompareStream.Run_Keyword_If_At_Least_Else    neon    Add Elements To URI From File And Check Validation Error    ${SERVICE_FUNCTION_PATHS_URI}    ${SERVICE_FUNCTION_PATHS_WITH_THREE_HOPS_FILE}
59     ...    ELSE    Add Elements To URI From File And Check Server Error    ${SERVICE_FUNCTION_PATHS_URI}    ${SERVICE_FUNCTION_PATHS_WITH_THREE_HOPS_FILE}
60     ${body}    OperatingSystem.Get File    ${SERVICE_FUNCTION_PATHS_WITH_HOP_FILE}
61     ${jsonbody}    To Json    ${body}
62     ${paths}    Get From Dictionary    ${jsonbody}    service-function-paths
63     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FUNCTION_PATHS_URI}
64     Should Be Equal As Strings    ${resp.status_code}    404
65     Remove All Elements At URI    ${SERVICE_FUNCTIONS_URI}
66     Remove All Elements At URI    ${SERVICE_CHAINS_URI}
67
68 Add Service Function Path where SFC types size and types for SFs in hops match
69     [Documentation]    Add Service Function Paths from JSON file
70     Add Elements To URI From File    ${SERVICE_FUNCTIONS_URI}    ${SERVICE_FUNCTIONS_FILE}
71     Add Elements To URI From File    ${SERVICE_CHAINS_URI}    ${SERVICE_CHAINS_FILE_FW_NAPT44_DPI}
72     Add Elements To URI From File And Verify    ${SERVICE_FUNCTION_PATHS_URI}    ${SERVICE_FUNCTION_PATHS_WITH_THREE_HOPS_FILE}
73     ${body}    OperatingSystem.Get File    ${SERVICE_FUNCTION_PATHS_FILE}
74     ${jsonbody}    To Json    ${body}
75     ${paths}    Get From Dictionary    ${jsonbody}    service-function-paths
76     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FUNCTION_PATHS_URI}
77     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
78     ${result}    To JSON    ${resp.content}
79     ${path}    Get From Dictionary    ${result}    service-function-paths
80     Lists Should be Equal    ${path}    ${paths}
81
82 *** Keywords ***
83 Init Suite
84     [Documentation]    Initialize session and ODL version specific variables
85     Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
86     log    ${ODL_STREAM}
87     Set Suite Variable    ${VERSION_DIR}    master
88     Set Suite Variable    ${SFC_JSON_TEST_FILES_DIR}    ${CURDIR}/../../../variables/sfc/${VERSION_DIR}
89     Set Suite Variable    ${SERVICE_FUNCTION_PATHS_FILE}    ${SFC_JSON_TEST_FILES_DIR}/service-function-paths.json
90     Set Suite Variable    ${SERVICE_FUNCTION_PATHS_WITH_HOP_FILE}    ${SFC_JSON_TEST_FILES_DIR}/service-function-paths-with-one-hop.json
91     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
92     Set Suite Variable    ${SERVICE_FUNCTIONS_FILE}    ${SFC_JSON_TEST_FILES_DIR}/service-functions.json
93     Set Suite Variable    ${SERVICE_CHAINS_FILE}    ${SFC_JSON_TEST_FILES_DIR}/service-function-chains.json
94     Set Suite Variable    ${SERVICE_CHAINS_FILE_FW_NAPT44_DPI}    ${SFC_JSON_TEST_FILES_DIR}/service-function-chain-firewall-napt44-dpi.json
95
96 Clean_All_URIs
97     [Documentation]    Deletes all the elements which might have been created during SFP validation tests
98     Utils.Remove All Elements If Exist    ${SERVICE_FUNCTIONS_URI}
99     Utils.Remove All Elements If Exist    ${SERVICE_CHAINS_URI}
100     Utils.Remove All Elements If Exist    ${SERVICE_FUNCTION_PATHS_URI}