Check service function types are present
[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     Wait Until Keyword Succeeds    60s    2s    Check Service Function Types
35     Add Elements To URI From File    ${SERVICE_CHAINS_URI}    ${SERVICE_CHAINS_FILE}
36     Add Elements To URI From File    ${SERVICE_FUNCTION_PATHS_URI}    ${SERVICE_FUNCTION_PATHS_FILE}
37
38 Create and Get Rendered Service Path
39     [Documentation]    Create and Get Rendered Service Path Through RESTConf APIs. Logical SFF
40     [Tags]    include
41     Post Elements To URI    ${OPERATIONS_CREATE_RSP_URI}    ${CREATE_RSP1_INPUT}
42     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSPS_URI}
43     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
44     ${elements1}=    Create List    RSP1    "parent-service-function-path":"SFP1"    "service-chain-name":"SFC1"    "hop-number":0    "service-index":255
45     ...    "hop-number":1    "service-index":254    "service-function-forwarder":"sfflogical1"    "sfc-encapsulation":"service-locator:nsh"
46     ${elements2}=    Create List    RSP1-Reverse    "parent-service-function-path":"SFP1"    "service-chain-name":"SFC1"    "hop-number":0    "service-index":255
47     ...    "hop-number":1    "service-index":254    "service-function-forwarder":"sfflogical1"    "sfc-encapsulation":"service-locator:nsh"
48     ${elements}=    Combine Lists    ${elements1}    ${elements2}
49     Check For Elements At URI    ${OPERATIONAL_RSPS_URI}    ${elements}
50
51 Create Get Rendered Service Path Failure
52     [Documentation]    Create Rendered Service Path Failure Cases. Logical SFF
53     ${resp}    RequestsLibrary.Post Request    session    ${OPERATIONS_CREATE_RSP_URI}    data=${CREATE_RSP_FAILURE_INPUT}    headers=${headers}
54     Should Be Equal As Strings    ${resp.status_code}    500
55
56 Get Rendered Service Path By Name
57     [Documentation]    Get Rendered Service Path By Name Through RESTConf APIs. Logical SFF
58     Post Elements To URI    ${OPERATIONS_CREATE_RSP_URI}    ${CREATE_RSP1_INPUT}
59     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSPS_URI}rendered-service-path/RSP1
60     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
61     ${elements}=    Create List    RSP1    "parent-service-function-path":"SFP1"    "hop-number":0    "service-index":255    "hop-number":1
62     ...    "service-index":254
63     Check For Elements At URI    ${OPERATIONAL_RSPS_URI}    ${elements}
64
65 Get Non Existing Rendered Service Path
66     [Documentation]    Get Non Existing Rendered Service Path Through RESTConf APIs. Logical SFF
67     Post Elements To URI    ${OPERATIONS_CREATE_RSP_URI}    ${CREATE_RSP1_INPUT}
68     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSPS_URI}rendered-service-path/non-existing-rsp
69     Should Be Equal As Strings    ${resp.status_code}    404
70     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSPS_URI}
71     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
72     Should Not Contain    ${resp.content}    non-existing-rsp
73
74 Delete one Rendered Service Path By Name
75     [Documentation]    Delete One Rendered Service Path By Name Through RESTConf APIs. Logical SFF
76     Post Elements To URI    ${OPERATIONS_CREATE_RSP_URI}    ${CREATE_RSP1_INPUT}
77     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSPS_URI}rendered-service-path/RSP1-Reverse
78     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
79     Should Contain    ${resp.content}    RSP1-Reverse
80     Post Elements To URI    ${OPERATIONS_DELETE_RSP_URI}    ${DELETE_RSP1_REVERSE_INPUT}
81     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSPS_URI}rendered-service-path/RSP1-Reverse
82     Should Be Equal As Strings    ${resp.status_code}    404
83     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSPS_URI}
84     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
85     Should Not Contain    ${resp.content}    RSP1-Reverse
86
87 Delete Non Existing Rendered Service Path By Name
88     [Documentation]    Delete One Rendered Service Path By Name Through RESTConf APIs. Logical SFF
89     Post Elements To URI    ${OPERATIONS_CREATE_RSP_URI}    ${CREATE_RSP1_INPUT}
90     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSPS_URI}rendered-service-path/RSP1
91     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
92     Should Contain    ${resp.content}    RSP1
93     Post Elements To URI    ${OPERATIONS_DELETE_RSP_URI}    ${DELETE_RSP2_INPUT}
94     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSPS_URI}
95     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
96     Should Not Contain    ${resp.content}    {"rendered-service-paths":{}}
97
98 Get Rendered Service Path Hop
99     [Documentation]    Get Rendered Service Path By Name Through RESTConf APIs. Logical SFF
100     Post Elements To URI    ${OPERATIONS_CREATE_RSP_URI}    ${CREATE_RSP1_INPUT}
101     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSPS_URI}rendered-service-path/RSP1/rendered-service-path-hop/0/
102     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
103     ${elements}=    Create List    "hop-number":0    "service-index":255    "service-function-name":"dpi-1
104     Check For Elements At URI    ${OPERATIONAL_RSPS_URI}rendered-service-path/RSP1/rendered-service-path-hop/0/    ${elements}
105     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSPS_URI}rendered-service-path/RSP1/rendered-service-path-hop/1/
106     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
107     ${elements}=    Create List    "hop-number":1    "service-index":254    "service-function-name":"firewall-1
108     Check For Elements At URI    ${OPERATIONAL_RSPS_URI}rendered-service-path/RSP1/rendered-service-path-hop/1/    ${elements}
109     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSPS_URI}rendered-service-path/RSP1/rendered-service-path-hop/2/
110     Should Be Equal As Strings    ${resp.status_code}    404
111     Post Elements To URI    ${OPERATIONS_DELETE_RSP_URI}    ${DELETE_RSP1_INPUT}
112
113 *** Keywords ***
114 Init Suite
115     [Documentation]    Create session and initialize ODL version specific variables
116     Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
117     log    ${ODL_STREAM}
118
119 Delete All Elements
120     [Documentation]    Delete all provisioned elements
121     Remove All Elements If Exist    ${RENDERED_SERVICE_PATHS_URI}
122     Remove All Elements If Exist    ${SERVICE_FUNCTION_PATHS_URI}
123     Remove All Elements If Exist    ${SERVICE_CHAINS_URI}
124     Remove All Elements If Exist    ${SERVICE_FORWARDERS_URI}
125     Remove All Elements If Exist    ${SERVICE_FUNCTIONS_URI}
126
127 Create All Elements
128     [Documentation]    Delete all provisioned elements
129     Add Elements To URI From File    ${SERVICE_FUNCTIONS_URI}    ${SERVICE_FUNCTIONS_FILE}
130     Wait Until Keyword Succeeds    60s    2s    Check Service Function Types
131     Add Elements To URI From File    ${SERVICE_FORWARDERS_URI}    ${SERVICE_FORWARDERS_FILE}
132     Add Elements To URI From File    ${SERVICE_CHAINS_URI}    ${SERVICE_CHAINS_FILE}
133     Add Elements To URI From File    ${SERVICE_FUNCTION_PATHS_URI}    ${SERVICE_FUNCTION_PATHS_FILE}
134
135 Check Service Function Types
136     [Documentation]    Check that the service function types are updated with the service functions names
137     ${elements}=    Create List    "name":"firewall-1"    "name":"dpi-1"
138     Check For Elements At URI    ${SERVICE_FUNCTION_TYPES_URI}    ${elements}