063c17fc0b750a3195c8256401b6a4322143e033
[integration/test.git] / csit / suites / sfc / Full_Deploy / 015__sfc_rendered_service_paths_logical.robot
1 *** Settings ***
2 Documentation     Test suite for SFC Rendered Service Paths. Logical SFF
3 Suite Setup       Init Suite
4 Suite Teardown    Delete All Elements
5 Library           SSHLibrary
6 Library           Collections
7 Library           OperatingSystem
8 Library           RequestsLibrary
9 Library           HttpLibrary.HTTP
10 Resource          ../../../libraries/SFC/SfcKeywords.robot
11 Resource          ../../../variables/sfc/Variables.robot
12 Resource          ../../../libraries/Utils.robot
13 Resource          ../../../libraries/TemplatedRequests.robot
14
15 *** Variables ***
16 ${VERSION_DIR}    master
17 ${TEST_DIR}       ${CURDIR}/../../../variables/sfc/${VERSION_DIR}
18 ${SERVICE_FUNCTIONS_FILE}    ${TEST_DIR}/service-functions-logicalsff.json
19 ${SERVICE_FORWARDERS_FILE}    ${TEST_DIR}/service-function-forwarders-logicallsff.json
20 ${SERVICE_CHAINS_FILE}    ${TEST_DIR}/service-function-chains-logicalsff.json
21 ${SERVICE_FUNCTION_PATHS_FILE}    ${TEST_DIR}/service-function-paths-logicalsff.json
22 ${CREATE_RSP1_INPUT}    {"input":{"name": "RSP1","parent-service-function-path": "SFP1","symmetric": "true"}}
23 ${CREATE_RSP2_INPUT}    {"input":{"name": "RSP2","parent-service-function-path": "SFP2","symmetric": "true"}}
24 ${CREATE_RSP_FAILURE_INPUT}    {"input":{"name": "RSP1","parent-service-function-path": "SFP3","symmetric": "true"}}
25 ${DELETE_RSP1_INPUT}    {"input":{"name":"RSP1"}}
26 ${DELETE_RSP1_REVERSE_INPUT}    {"input":{"name":"RSP1-Reverse"}}
27 ${DELETE_RSP2_INPUT}    {"input":{"name":"RSP2"}}
28 @{SF_NAMES}       "name":"firewall-1"    "name":"dpi-1"
29
30 *** Test Cases ***
31 Basic Environment Setup Tests
32     [Documentation]    Prepare Basic Test Environment. Logical SFF
33     Utils.Add Elements To URI From File    ${SERVICE_FORWARDERS_URI}    ${SERVICE_FORWARDERS_FILE}
34     Utils.Add Elements To URI From File    ${SERVICE_FUNCTIONS_URI}    ${SERVICE_FUNCTIONS_FILE}
35     BuiltIn.Wait Until Keyword Succeeds    60s    2s    SfcKeywords.Check Service Function Types Added    ${SF_NAMES}
36     Utils.Add Elements To URI From File    ${SERVICE_CHAINS_URI}    ${SERVICE_CHAINS_FILE}
37     SfcKeywords.Create Sfp And Wait For Rsp Creation    ${SERVICE_FUNCTION_PATHS_FILE}
38
39 Get Rendered Service Path By Name
40     [Documentation]    Get Rendered Service Path By Name Through RESTConf APIs. Logical SFF
41     # The RSP should be symetric, so 2 should be created for the SFP
42     ${rsp_name} =    SfcKeywords.Get Rendered Service Path Name    ${SFP_NAME}
43     Utils.Get URI And Verify    ${OPERATIONAL_RSP_URI}/${rsp_name}
44     ${rsp_name_rev} =    SfcKeywords.Get Rendered Service Path Name    ${SFP_NAME}
45     Utils.Get URI And Verify    ${OPERATIONAL_RSP_URI}/${rsp_name_rev}
46     ${elements} =    Create List    "parent-service-function-path":"${SFP_NAME}"    "hop-number":0    "service-index":255    "hop-number":1    "service-index":254
47     Utils.Check For Elements At URI    ${OPERATIONAL_RSPS_URI}    ${elements}
48
49 Delete one Rendered Service Path By Name
50     [Documentation]    Delete One Rendered Service Path By Name Through RESTConf APIs. Logical SFF
51     # First verify that the RSPs exist
52     ${rsp_name} =    SfcKeywords.Get Rendered Service Path Name    ${SFP_NAME}
53     Utils.Get URI And Verify    ${OPERATIONAL_RSP_URI}/${rsp_name}
54     ${rsp_name_rev} =    SfcKeywords.Get Rendered Service Path Name    ${SFP_NAME}    True
55     Utils.Get URI And Verify    ${OPERATIONAL_RSP_URI}/${rsp_name_rev}
56     # Delete the SFP, which will delete the RSPs
57     SfcKeywords.Delete Sfp And Wait For Rsps Deletion    ${SFP_NAME}
58
59 Get Rendered Service Path Hop
60     [Documentation]    Get Rendered Service Path By Name Through RESTConf APIs. Logical SFF
61     # Create the SFP, which will create the RSPs
62     SfcKeywords.Create Sfp And Wait For Rsp Creation    ${SERVICE_FUNCTION_PATHS_FILE}
63     ${rsp_name} =    SfcKeywords.Get Rendered Service Path Name    ${SFP_NAME}
64     ${elements} =    BuiltIn.Create List    "hop-number":0    "service-index":255    "service-function-name":"dpi-1
65     Utils.Check For Elements At URI    ${OPERATIONAL_RSP_URI}/${rsp_name}/rendered-service-path-hop/0/    ${elements}
66     ${elements} =    BuiltIn.Create List    "hop-number":1    "service-index":254    "service-function-name":"firewall-1
67     Utils.Check For Elements At URI    ${OPERATIONAL_RSP_URI}/${rsp_name}/rendered-service-path-hop/1/    ${elements}
68     ${resp} =    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSP_URI}/${rsp_name}/rendered-service-path-hop/2/
69     BuiltIn.Should Be Equal As Strings    ${resp.status_code}    404
70
71 *** Keywords ***
72 Init Suite
73     [Documentation]    Create session and initialize ODL version specific variables
74     RequestsLibrary.Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
75     BuiltIn.log    ${ODL_STREAM}
76     BuiltIn.Set Suite Variable    ${SFP_NAME}    SFP1
77     BuiltIn.Set Suite Variable    ${VERSION_DIR}    master
78     BuiltIn.Set Suite Variable    ${SERVICE_FUNCTIONS_FILE}    ${CURDIR}/../../../variables/sfc/${VERSION_DIR}/service-functions-logicalsff.json
79     BuiltIn.Set Suite Variable    ${SERVICE_FORWARDERS_FILE}    ${CURDIR}/../../../variables/sfc/${VERSION_DIR}/service-function-forwarders-logicallsff.json
80     BuiltIn.Set Suite Variable    ${SERVICE_CHAINS_FILE}    ${CURDIR}/../../../variables/sfc/${VERSION_DIR}/service-function-chains-logicalsff.json
81     BuiltIn.Set Suite Variable    ${SERVICE_FUNCTION_PATHS_FILE}    ${CURDIR}/../../../variables/sfc/${VERSION_DIR}/service-function-paths-logicalsff.json
82     BuiltIn.Set Suite Variable    @{SF_NAMES}    "name":"firewall-1"    "name":"dpi-1"
83
84 Delete All Elements
85     [Documentation]    Delete all provisioned elements
86     Utils.Remove All Elements If Exist    ${SERVICE_FUNCTION_PATHS_URI}
87     Utils.Remove All Elements If Exist    ${SERVICE_CHAINS_URI}
88     Utils.Remove All Elements If Exist    ${SERVICE_FORWARDERS_URI}
89     Utils.Remove All Elements If Exist    ${SERVICE_FUNCTIONS_URI}
90     BuiltIn.Wait Until Keyword Succeeds    60s    2s    SfcKeywords.Check Service Function Types Removed    ${SF_NAMES}
91     RequestsLibrary.Delete All Sessions