SFC: Implement boron and carbon scope
[integration/test.git] / csit / suites / sfc / Full_Deploy / 015__sfc_rendered_service_paths_logical.robot
1 *** Settings ***
2 Documentation     Test suite for SFC Service Functions, Operates functions from Restconf APIs. Logical SFF
3 Suite Setup       Init Suite
4 Suite Teardown    Delete All Sessions
5 Test Setup        Create All Elements
6 Test Teardown     Delete All Elements
7 Library           SSHLibrary
8 Library           Collections
9 Library           OperatingSystem
10 Library           RequestsLibrary
11 Library           HttpLibrary.HTTP
12 Resource          ../../../variables/sfc/Variables.robot
13 Resource          ../../../libraries/Utils.robot
14 Resource          ../../../libraries/TemplatedRequests.robot
15
16 *** Variables ***
17 ${VERSION_DIR}    master
18 ${SERVICE_FUNCTIONS_FILE}    ${CURDIR}/../../../variables/sfc/${VERSION_DIR}/service-functions-logicalsff.json
19 ${SERVICE_FORWARDERS_FILE}    ${CURDIR}/../../../variables/sfc/${VERSION_DIR}/service-function-forwarders-logicallsff.json
20 ${SERVICE_CHAINS_FILE}    ${CURDIR}/../../../variables/sfc/${VERSION_DIR}/service-function-chains-logicalsff.json
21 ${SERVICE_FUNCTION_PATHS_FILE}    ${CURDIR}/../../../variables/sfc/${VERSION_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
29 *** Test Cases ***
30 Basic Environment Setup Tests
31     [Documentation]    Prepare Basic Test Environment. Logical SFF
32     Add Elements To URI From File    ${SERVICE_FORWARDERS_URI}    ${SERVICE_FORWARDERS_FILE}
33     Add Elements To URI From File    ${SERVICE_FUNCTIONS_URI}    ${SERVICE_FUNCTIONS_FILE}
34     Add Elements To URI From File    ${SERVICE_CHAINS_URI}    ${SERVICE_CHAINS_FILE}
35     Add Elements To URI From File    ${SERVICE_FUNCTION_PATHS_URI}    ${SERVICE_FUNCTION_PATHS_FILE}
36
37 Create and Get Rendered Service Path
38     [Documentation]    Create and Get Rendered Service Path Through RESTConf APIs. Logical SFF
39     [Tags]    include
40     Post Elements To URI    ${OPERATIONS_CREATE_RSP_URI}    ${CREATE_RSP1_INPUT}
41     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSPS_URI}
42     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
43     ${elements1}=    Create List    RSP1    "parent-service-function-path":"SFP1"    "service-chain-name":"SFC1"    "hop-number":0    "service-index":255
44     ...    "hop-number":1    "service-index":254    "service-function-forwarder":"sfflogical1"    "sfc-encapsulation":"service-locator:nsh"
45     ${elements2}=    Create List    RSP1-Reverse    "parent-service-function-path":"SFP1"    "service-chain-name":"SFC1"    "hop-number":0    "service-index":255
46     ...    "hop-number":1    "service-index":254    "service-function-forwarder":"sfflogical1"    "sfc-encapsulation":"service-locator:nsh"
47     ${elements}=    Combine Lists    ${elements1}    ${elements2}
48     Check For Elements At URI    ${OPERATIONAL_RSPS_URI}    ${elements}
49
50 Create Get Rendered Service Path Failure
51     [Documentation]    Create Rendered Service Path Failure Cases. Logical SFF
52     ${resp}    RequestsLibrary.Post Request    session    ${OPERATIONS_CREATE_RSP_URI}    data=${CREATE_RSP_FAILURE_INPUT}    headers=${headers}
53     Should Be Equal As Strings    ${resp.status_code}    500
54
55 Get Rendered Service Path By Name
56     [Documentation]    Get Rendered Service Path By Name Through RESTConf APIs. Logical SFF
57     Post Elements To URI    ${OPERATIONS_CREATE_RSP_URI}    ${CREATE_RSP1_INPUT}
58     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSPS_URI}rendered-service-path/RSP1
59     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
60     ${elements}=    Create List    RSP1    "parent-service-function-path":"SFP1"    "hop-number":0    "service-index":255    "hop-number":1
61     ...    "service-index":254
62     Check For Elements At URI    ${OPERATIONAL_RSPS_URI}    ${elements}
63
64 Get Non Existing Rendered Service Path
65     [Documentation]    Get Non Existing Rendered Service Path Through RESTConf APIs. Logical SFF
66     Post Elements To URI    ${OPERATIONS_CREATE_RSP_URI}    ${CREATE_RSP1_INPUT}
67     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSPS_URI}rendered-service-path/non-existing-rsp
68     Should Be Equal As Strings    ${resp.status_code}    404
69     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSPS_URI}
70     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
71     Should Not Contain    ${resp.content}    non-existing-rsp
72
73 Delete one Rendered Service Path By Name
74     [Documentation]    Delete One Rendered Service Path By Name Through RESTConf APIs. Logical SFF
75     Post Elements To URI    ${OPERATIONS_CREATE_RSP_URI}    ${CREATE_RSP1_INPUT}
76     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSPS_URI}rendered-service-path/RSP1-Reverse
77     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
78     Should Contain    ${resp.content}    RSP1-Reverse
79     Post Elements To URI    ${OPERATIONS_DELETE_RSP_URI}    ${DELETE_RSP1_REVERSE_INPUT}
80     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSPS_URI}rendered-service-path/RSP1-Reverse
81     Should Be Equal As Strings    ${resp.status_code}    404
82     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSPS_URI}
83     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
84     Should Not Contain    ${resp.content}    RSP1-Reverse
85
86 Delete Non Existing Rendered Service Path By Name
87     [Documentation]    Delete One Rendered Service Path By Name Through RESTConf APIs. Logical SFF
88     Post Elements To URI    ${OPERATIONS_CREATE_RSP_URI}    ${CREATE_RSP1_INPUT}
89     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSPS_URI}rendered-service-path/RSP1
90     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
91     Should Contain    ${resp.content}    RSP1
92     Post Elements To URI    ${OPERATIONS_DELETE_RSP_URI}    ${DELETE_RSP2_INPUT}
93     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSPS_URI}
94     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
95     Should Not Contain    ${resp.content}    {"rendered-service-paths":{}}
96
97 Get Rendered Service Path Hop
98     [Documentation]    Get Rendered Service Path By Name Through RESTConf APIs. Logical SFF
99     Post Elements To URI    ${OPERATIONS_CREATE_RSP_URI}    ${CREATE_RSP1_INPUT}
100     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSPS_URI}rendered-service-path/RSP1/rendered-service-path-hop/0/
101     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
102     ${elements}=    Create List    "hop-number":0    "service-index":255    "service-function-name":"dpi-1
103     Check For Elements At URI    ${OPERATIONAL_RSPS_URI}rendered-service-path/RSP1/rendered-service-path-hop/0/    ${elements}
104     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSPS_URI}rendered-service-path/RSP1/rendered-service-path-hop/1/
105     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
106     ${elements}=    Create List    "hop-number":1    "service-index":254    "service-function-name":"firewall-1
107     Check For Elements At URI    ${OPERATIONAL_RSPS_URI}rendered-service-path/RSP1/rendered-service-path-hop/1/    ${elements}
108     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSPS_URI}rendered-service-path/RSP1/rendered-service-path-hop/2/
109     Should Be Equal As Strings    ${resp.status_code}    404
110     Post Elements To URI    ${OPERATIONS_DELETE_RSP_URI}    ${DELETE_RSP1_INPUT}
111
112 *** Keywords ***
113 Init Suite
114     [Documentation]    Create session and initialize ODL version specific variables
115     Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
116     log    ${ODL_STREAM}
117
118 Delete All Elements
119     [Documentation]    Delete all provisioned elements
120     Remove All Elements If Exist    ${RENDERED_SERVICE_PATHS_URI}
121     Remove All Elements If Exist    ${SERVICE_FUNCTION_PATHS_URI}
122     Remove All Elements If Exist    ${SERVICE_CHAINS_URI}
123     Remove All Elements If Exist    ${SERVICE_FORWARDERS_URI}
124     Remove All Elements If Exist    ${SERVICE_FUNCTIONS_URI}
125
126 Create All Elements
127     [Documentation]    Delete all provisioned elements
128     Add Elements To URI From File    ${SERVICE_FUNCTIONS_URI}    ${SERVICE_FUNCTIONS_FILE}
129     Add Elements To URI From File    ${SERVICE_FORWARDERS_URI}    ${SERVICE_FORWARDERS_FILE}
130     Add Elements To URI From File    ${SERVICE_CHAINS_URI}    ${SERVICE_CHAINS_FILE}
131     Add Elements To URI From File    ${SERVICE_FUNCTION_PATHS_URI}    ${SERVICE_FUNCTION_PATHS_FILE}