Refactor SFC_FullDeploy tests to not use RSP RPCs
[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 *** Test Cases ***
16 Basic Environment Setup Tests
17     [Documentation]    Prepare Basic Test Environment. Logical SFF
18     Utils.Add Elements To URI From File    ${SERVICE_FORWARDERS_URI}    ${SERVICE_FORWARDERS_FILE}
19     Utils.Add Elements To URI From File    ${SERVICE_FUNCTIONS_URI}    ${SERVICE_FUNCTIONS_FILE}
20     BuiltIn.Wait Until Keyword Succeeds    60s    2s    SfcKeywords.Check Service Function Types Added    ${SF_NAMES}
21     Utils.Add Elements To URI From File    ${SERVICE_CHAINS_URI}    ${SERVICE_CHAINS_FILE}
22     SfcKeywords.Create Sfp And Wait For Rsp Creation    ${SERVICE_FUNCTION_PATHS_FILE}
23
24 Get Rendered Service Path By Name
25     [Documentation]    Get Rendered Service Path By Name Through RESTConf APIs. Logical SFF
26     # The RSP should be symetric, so 2 should be created for the SFP
27     ${rsp_name} =    SfcKeywords.Get Rendered Service Path Name    ${SFP_NAME}
28     Utils.Get URI And Verify    ${OPERATIONAL_RSP_URI}${rsp_name}
29     ${rsp_name_rev} =    SfcKeywords.Get Rendered Service Path Name    ${SFP_NAME}
30     Utils.Get URI And Verify    ${OPERATIONAL_RSP_URI}${rsp_name_rev}
31     ${elements} =    Create List    "parent-service-function-path":"${SFP_NAME}"    "hop-number":0    "service-index":255    "hop-number":1    "service-index":254
32     Utils.Check For Elements At URI    ${OPERATIONAL_RSPS_URI}    ${elements}
33
34 Delete one Rendered Service Path By Name
35     [Documentation]    Delete One Rendered Service Path By Name Through RESTConf APIs. Logical SFF
36     # First verify that the RSPs exist
37     ${rsp_name} =    SfcKeywords.Get Rendered Service Path Name    ${SFP_NAME}
38     Utils.Get URI And Verify    ${OPERATIONAL_RSP_URI}${rsp_name}
39     ${rsp_name_rev} =    SfcKeywords.Get Rendered Service Path Name    ${SFP_NAME}    True
40     Utils.Get URI And Verify    ${OPERATIONAL_RSP_URI}${rsp_name_rev}
41     # Delete the SFP, which will delete the RSPs
42     SfcKeywords.Delete Sfp And Wait For Rsps Deletion    ${SFP_NAME}
43
44 Get Rendered Service Path Hop
45     [Documentation]    Get Rendered Service Path By Name Through RESTConf APIs. Logical SFF
46     # Create the SFP, which will create the RSPs
47     SfcKeywords.Create Sfp And Wait For Rsp Creation    ${SERVICE_FUNCTION_PATHS_FILE}
48     ${rsp_name} =    SfcKeywords.Get Rendered Service Path Name    ${SFP_NAME}
49     ${elements} =    BuiltIn.Create List    "hop-number":0    "service-index":255    "service-function-name":"dpi-1
50     Utils.Check For Elements At URI    ${OPERATIONAL_RSPS_URI}rendered-service-path/${rsp_name}/rendered-service-path-hop/0/    ${elements}
51     ${elements} =    BuiltIn.Create List    "hop-number":1    "service-index":254    "service-function-name":"firewall-1
52     Utils.Check For Elements At URI    ${OPERATIONAL_RSPS_URI}rendered-service-path/${rsp_name}/rendered-service-path-hop/1/    ${elements}
53     ${resp} =    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSPS_URI}rendered-service-path/RSP1/rendered-service-path-hop/2/
54     BuiltIn.Should Be Equal As Strings    ${resp.status_code}    404
55
56 *** Keywords ***
57 Init Suite
58     [Documentation]    Create session and initialize ODL version specific variables
59     RequestsLibrary.Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
60     BuiltIn.log    ${ODL_STREAM}
61     BuiltIn.Set Suite Variable    ${SFP_NAME}    SFP1
62     BuiltIn.Set Suite Variable    ${VERSION_DIR}    master
63     BuiltIn.Set Suite Variable    ${SERVICE_FUNCTIONS_FILE}    ${CURDIR}/../../../variables/sfc/${VERSION_DIR}/service-functions-logicalsff.json
64     BuiltIn.Set Suite Variable    ${SERVICE_FORWARDERS_FILE}    ${CURDIR}/../../../variables/sfc/${VERSION_DIR}/service-function-forwarders-logicallsff.json
65     BuiltIn.Set Suite Variable    ${SERVICE_CHAINS_FILE}    ${CURDIR}/../../../variables/sfc/${VERSION_DIR}/service-function-chains-logicalsff.json
66     BuiltIn.Set Suite Variable    ${SERVICE_FUNCTION_PATHS_FILE}    ${CURDIR}/../../../variables/sfc/${VERSION_DIR}/service-function-paths-logicalsff.json
67     BuiltIn.Set Suite Variable    @{SF_NAMES}    "name":"firewall-1"    "name":"dpi-1"
68
69 Delete All Elements
70     [Documentation]    Delete all provisioned elements
71     Utils.Remove All Elements If Exist    ${SERVICE_FUNCTION_PATHS_URI}
72     Utils.Remove All Elements If Exist    ${SERVICE_CHAINS_URI}
73     Utils.Remove All Elements If Exist    ${SERVICE_FORWARDERS_URI}
74     Utils.Remove All Elements If Exist    ${SERVICE_FUNCTIONS_URI}
75     BuiltIn.Wait Until Keyword Succeeds    60s    2s    SfcKeywords.Check Service Function Types Removed    ${SF_NAMES}
76     RequestsLibrary.Delete All Sessions