Remove HTTP library
[integration/test.git] / csit / suites / sfc / SFC_Basic / 070__sfc_rendered_service_paths.robot
1 *** Settings ***
2 Documentation     Test suite for SFC Rendered Service Paths, Operates functions from Restconf APIs.
3 Suite Setup       Init Suite
4 Suite Teardown    Delete All Sessions
5 Library           SSHLibrary
6 Library           Collections
7 Library           OperatingSystem
8 Library           RequestsLibrary
9 Resource          ../../../variables/sfc/Variables.robot
10 Resource          ../../../libraries/SFC/SfcKeywords.robot
11 Resource          ../../../libraries/Utils.robot
12 Resource          ../../../libraries/TemplatedRequests.robot
13
14 *** Test Cases ***
15 Basic Environment Setup Tests
16     [Documentation]    Prepare Basic Test Environment
17     Utils.Add Elements To URI From File    ${SERVICE_FORWARDERS_URI}    ${SERVICE_FORWARDERS_FILE}
18     Utils.Add Elements To URI From File    ${SERVICE_NODES_URI}    ${SERVICE_NODES_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    ${SERVICE_FUNCTION_NAMES}
21     Utils.Add Elements To URI From File    ${SERVICE_CHAINS_URI}    ${SERVICE_CHAINS_FILE}
22     # Creates SFPs: SFC1-100, SFC1-200, SFC1-300, SFC2-100, and SFC2-200
23     SfcKeywords.Create Sfp And Wait For Rsp Creation    ${SERVICE_FUNCTION_PATHS_FILE}
24
25 Get Rendered Service Path By Name
26     [Documentation]    Get The Rendered Service Path Created in "Basic Environment Setup Tests" By Name Via RESTConf APIs
27     ${sfp_name} =    BuiltIn.Set Variable    SFC1-100
28     ${rsp_name} =    SfcKeywords.Get Rendered Service Path Name    ${sfp_name}
29     ${resp} =    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSP_URI}/${rsp_name}
30     BuiltIn.Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
31     # The RSP should not be symetric, so only 1 should be created for the SFP
32     Utils.Check For Specific Number Of Elements At URI    ${SERVICE_FUNCTION_PATH_STATE_URI}/${sfp_name}    "sfp-rendered-service-path"    1
33     ${elements} =    BuiltIn.Create List    "parent-service-function-path":"SFC1-100"    "hop-number":0    "service-index":255    "hop-number":1    "service-index":254
34     ...    "hop-number":2    "service-index":253
35     Utils.Check For Elements At URI    ${OPERATIONAL_RSPS_URI}    ${elements}
36
37 Get Rendered Service Path Hop
38     [Documentation]    Check Rendered Service Path Hops Created in "Basic Environment Setup Tests"
39     ${sfp_name} =    BuiltIn.Set Variable    SFC1-100
40     ${rsp_name} =    SfcKeywords.Get Rendered Service Path Name    ${sfp_name}
41     ${resp} =    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSP_URI}/${rsp_name}/rendered-service-path-hop/0/
42     BuiltIn.Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
43     ${elements} =    BuiltIn.Create List    "hop-number":0    "service-index":255    "service-function-name":"dpi
44     Utils.Check For Elements At URI    ${OPERATIONAL_RSP_URI}/${rsp_name}/rendered-service-path-hop/0/    ${elements}
45     ${elements} =    BuiltIn.Create List    "hop-number":1    "service-index":254    "service-function-name":"napt44
46     Utils.Check For Elements At URI    ${OPERATIONAL_RSP_URI}/${rsp_name}/rendered-service-path-hop/1/    ${elements}
47     ${elements} =    BuiltIn.Create List    "hop-number":2    "service-index":253    "service-function-name":"firewall
48     Utils.Check For Elements At URI    ${OPERATIONAL_RSP_URI}/${rsp_name}/rendered-service-path-hop/2/    ${elements}
49     ${resp} =    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSP_URI}/${rsp_name}/rendered-service-path-hop/3/
50     BuiltIn.Should Be Equal As Strings    ${resp.status_code}    404
51
52 Delete one Rendered Service Path By Name
53     [Documentation]    Delete One Rendered Service Path By deleting the parent Service Function Path
54     ...    The RSP to be deleted was created in "Basic Environment Setup Tests"
55     ${sfp_name} =    BuiltIn.Set Variable    SFC2-200
56     ${rsp_name} =    SfcKeywords.Get Rendered Service Path Name    ${sfp_name}
57     # First verify that the RSP exists
58     ${resp} =    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSP_URI}/${rsp_name}
59     BuiltIn.Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
60     SfcKeywords.Delete Sfp And Wait For Rsps Deletion    ${sfp_name}
61
62 Generate RSPs with Random Schedule Algorithm type
63     [Documentation]    Generate RSPs with Random Schedule Algorithm type Through RESTConf APIs
64     Utils.Remove All Elements At URI    ${SERVICE_SCHED_TYPES_URI}
65     Utils.Add Elements To URI From File    ${SERVICE_RANDOM_SCHED_TYPE_URI}    ${SERVICE_RANDOM_SCHED_TYPE_FILE}
66     SfcKeywords.Delete All Sfps And Wait For Rsps Deletion
67     # Create the SFPs which will create the RSPs with the Random scheduler
68     SfcKeywords.Create Sfp And Wait For Rsp Creation    ${SERVICE_FUNCTION_PATHS_FILE}
69     ${sfp_name} =    BuiltIn.Set Variable    SFC1-100
70     ${rsp_name} =    SfcKeywords.Get Rendered Service Path Name    ${sfp_name}
71     ${elements} =    BuiltIn.Create List    "hop-number":0    "service-index":255    "service-function-name":"dpi
72     Utils.Check For Elements At URI    ${OPERATIONAL_RSP_URI}/${rsp_name}/rendered-service-path-hop/0/    ${elements}
73     ${elements} =    BuiltIn.Create List    "hop-number":1    "service-index":254    "service-function-name":"napt44
74     Utils.Check For Elements At URI    ${OPERATIONAL_RSP_URI}/${rsp_name}/rendered-service-path-hop/1/    ${elements}
75     ${elements} =    BuiltIn.Create List    "hop-number":2    "service-index":253    "service-function-name":"firewall
76     Utils.Check For Elements At URI    ${OPERATIONAL_RSP_URI}/${rsp_name}/rendered-service-path-hop/2/    ${elements}
77
78 Generate RSPs with Round Robin Schedule Algorithm type
79     [Documentation]    Generate RSPs with Round Robin Schedule Algorithm type
80     [Tags]    exclude
81     Utils.Remove All Elements At URI    ${SERVICE_SCHED_TYPES_URI}
82     Utils.Add Elements To URI From File    ${SERVICE_ROUNDROBIN_SCHED_TYPE_URI}    ${SERVICE_ROUNDROBIN_SCHED_TYPE_FILE}
83     SfcKeywords.Delete All Sfps And Wait For Rsps Deletion
84     # Create the SFPs which will create the RSPs with the Random scheduler
85     SfcKeywords.Create Sfp And Wait For Rsp Creation    ${SERVICE_FUNCTION_PATHS_FILE}
86     ${rsp1_name} =    SfcKeywords.Get Rendered Service Path Name    SFC1-100
87     ${rsp2_name} =    SfcKeywords.Get Rendered Service Path Name    SFC1-200
88     ${rsp3_name} =    SfcKeywords.Get Rendered Service Path Name    SFC1-300
89     ${rsp4_name} =    SfcKeywords.Get Rendered Service Path Name    SFC2-100
90     ${rsp5_name} =    SfcKeywords.Get Rendered Service Path Name    SFC2-200
91     ${path1_hop0} =    SfcKeywords.Get JSON Elements From URI    ${OPERATIONAL_RSP_URI}/${rsp1_name}/rendered-service-path-hop/0/
92     ${path1_hop1} =    SfcKeywords.Get JSON Elements From URI    ${OPERATIONAL_RSP_URI}/${rsp1_name}/rendered-service-path-hop/1/
93     ${path1_hop2} =    SfcKeywords.Get JSON Elements From URI    ${OPERATIONAL_RSP_URI}/${rsp1_name}/rendered-service-path-hop/2/
94     ${path2_hop0} =    SfcKeywords.Get JSON Elements From URI    ${OPERATIONAL_RSP_URI}/${rsp1_name}/rendered-service-path-hop/0/
95     ${path2_hop1} =    SfcKeywords.Get JSON Elements From URI    ${OPERATIONAL_RSP_URI}/${rsp1_name}/rendered-service-path-hop/1/
96     ${path2_hop2} =    SfcKeywords.Get JSON Elements From URI    ${OPERATIONAL_RSP_URI}/${rsp1_name}/rendered-service-path-hop/2/
97     ${path3_hop0} =    SfcKeywords.Get JSON Elements From URI    ${OPERATIONAL_RSP_URI}/${rsp1_name}/rendered-service-path-hop/0/
98     ${path3_hop1} =    SfcKeywords.Get JSON Elements From URI    ${OPERATIONAL_RSP_URI}/${rsp1_name}/rendered-service-path-hop/1/
99     ${path3_hop2} =    SfcKeywords.Get JSON Elements From URI    ${OPERATIONAL_RSP_URI}/${rsp1_name}/rendered-service-path-hop/2/
100     ${path4_hop0} =    SfcKeywords.Get JSON Elements From URI    ${OPERATIONAL_RSP_URI}/${rsp1_name}/rendered-service-path-hop/0/
101     ${path4_hop1} =    SfcKeywords.Get JSON Elements From URI    ${OPERATIONAL_RSP_URI}/${rsp1_name}/rendered-service-path-hop/1/
102     ${path4_hop2} =    SfcKeywords.Get JSON Elements From URI    ${OPERATIONAL_RSP_URI}/${rsp1_name}/rendered-service-path-hop/2/
103     ${path5_hop0} =    SfcKeywords.Get JSON Elements From URI    ${OPERATIONAL_RSP_URI}/${rsp1_name}/rendered-service-path-hop/0/
104     ${path5_hop1} =    SfcKeywords.Get JSON Elements From URI    ${OPERATIONAL_RSP_URI}/${rsp1_name}/rendered-service-path-hop/1/
105     ${path5_hop2} =    SfcKeywords.Get JSON Elements From URI    ${OPERATIONAL_RSP_URI}/${rsp1_name}/rendered-service-path-hop/2/
106     BuiltIn.Should Be Equal    ${path1_hop0}    ${path4_hop0}
107     BuiltIn.Should Not Be Equal    ${path1_hop0}    ${path2_hop0}
108     BuiltIn.Should Be Equal    ${path1_hop1}    ${path4_hop1}
109     BuiltIn.Should Not Be Equal    ${path1_hop1}    ${path2_hop1}
110     BuiltIn.Should Be Equal    ${path1_hop2}    ${path4_hop2}
111     BuiltIn.Should Not Be Equal    ${path1_hop2}    ${path2_hop2}
112     BuiltIn.Should Be Equal    ${path2_hop0}    ${path5_hop0}
113     BuiltIn.Should Not Be Equal    ${path2_hop0}    ${path3_hop0}
114     BuiltIn.Should Be Equal    ${path2_hop1}    ${path5_hop1}
115     BuiltIn.Should Not Be Equal    ${path2_hop1}    ${path3_hop1}
116     BuiltIn.Should Be Equal    ${path2_hop2}    ${path5_hop2}
117     BuiltIn.Should Not Be Equal    ${path2_hop2}    ${path3_hop2}
118     BuiltIn.Should Be Equal    ${path3_hop0}    ${path1_hop0}
119     BuiltIn.Should Not Be Equal    ${path3_hop0}    ${path1_hop0}
120     BuiltIn.Should Be Equal    ${path3_hop1}    ${path1_hop1}
121     BuiltIn.Should Not Be Equal    ${path3_hop1}    ${path1_hop1}
122     BuiltIn.Should Be Equal    ${path3_hop2}    ${path1_hop2}
123     BuiltIn.Should Not Be Equal    ${path3_hop2}    ${path1_hop2}
124
125 Generate RSPs with Shortest Path Schedule Algorithm type
126     [Documentation]    Generate RSPs with Shortest Path Schedule Algorithm type Through RESTConf APIs
127     Utils.Remove All Elements At URI    ${SERVICE_SCHED_TYPES_URI}
128     Utils.Add Elements To URI From File    ${SERVICE_SHORTESTPATH_SCHED_TYPE_URI}    ${SERVICE_SHORTESTPATH_SCHED_TYPE_FILE}
129     SfcKeywords.Delete All Sfps And Wait For Rsps Deletion
130     # Create the SFPs which will create the RSPs with the Random scheduler
131     SfcKeywords.Create Sfp And Wait For Rsp Creation    ${SERVICE_FUNCTION_PATHS_FILE}
132     ${rsp1_name} =    SfcKeywords.Get Rendered Service Path Name    SFC1-100
133     ${rsp2_name} =    SfcKeywords.Get Rendered Service Path Name    SFC1-200
134     ${rsp3_name} =    SfcKeywords.Get Rendered Service Path Name    SFC1-300
135     ${rsp4_name} =    SfcKeywords.Get Rendered Service Path Name    SFC2-100
136     ${rsp5_name} =    SfcKeywords.Get Rendered Service Path Name    SFC2-200
137     ${elements} =    BuiltIn.Create List    "hop-number":0    "service-index":255    "service-function-name":"dpi-1
138     Utils.Check For Elements At URI    ${OPERATIONAL_RSP_URI}/${rsp1_name}/rendered-service-path-hop/0/    ${elements}
139     ${elements} =    BuiltIn.Create List    "hop-number":1    "service-index":254    "service-function-name":"napt44
140     Utils.Check For Elements At URI    ${OPERATIONAL_RSP_URI}/${rsp1_name}/rendered-service-path-hop/1/    ${elements}
141     ${elements} =    BuiltIn.Create List    "hop-number":2    "service-index":253    "service-function-name":"firewall
142     Utils.Check For Elements At URI    ${OPERATIONAL_RSP_URI}/${rsp1_name}/rendered-service-path-hop/2/    ${elements}
143     ${resp} =    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSP_URI}/${rsp1_name}/rendered-service-path-hop/0/
144     BuiltIn.Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
145     ${fwd_hop1} =    Utils.Extract Value From Content    ${resp.content}    /rendered-service-path-hop/0/service-function-forwarder
146     ${resp} =    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSP_URI}/${rsp1_name}/rendered-service-path-hop/1/
147     BuiltIn.Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
148     ${fwd_hop2} =    Utils.Extract Value From Content    ${resp.content}    /rendered-service-path-hop/0/service-function-forwarder
149     ${resp} =    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSP_URI}/${rsp1_name}/rendered-service-path-hop/2/
150     BuiltIn.Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
151     ${fwd_hop3} =    Utils.Extract Value From Content    ${resp.content}    /rendered-service-path-hop/0/service-function-forwarder
152     BuiltIn.Should Be Equal    ${fwd_hop1}    ${fwd_hop2}
153     BuiltIn.Should Be Equal    ${fwd_hop2}    ${fwd_hop3}
154     ${resp} =    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSP_URI}/${rsp2_name}/rendered-service-path-hop/0/
155     BuiltIn.Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
156     ${fwd_hop1} =    Utils.Extract Value From Content    ${resp.content}    /rendered-service-path-hop/0/service-function-forwarder
157     ${resp} =    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSP_URI}/${rsp2_name}/rendered-service-path-hop/1/
158     BuiltIn.Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
159     ${fwd_hop2} =    Utils.Extract Value From Content    ${resp.content}    /rendered-service-path-hop/0/service-function-forwarder
160     ${resp} =    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSP_URI}/${rsp2_name}/rendered-service-path-hop/2/
161     BuiltIn.Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
162     ${fwd_hop3} =    Utils.Extract Value From Content    ${resp.content}    /rendered-service-path-hop/0/service-function-forwarder
163     BuiltIn.Should Be Equal    ${fwd_hop1}    ${fwd_hop2}
164     BuiltIn.Should Be Equal    ${fwd_hop2}    ${fwd_hop3}
165
166 Clean Datastore After Tests
167     [Documentation]    Clean All Items In Datastore After Tests
168     Utils.Remove All Elements At URI    ${SERVICE_FUNCTIONS_URI}
169     BuiltIn.Wait Until Keyword Succeeds    60s    2s    SfcKeywords.Check Service Function Types Removed    ${SERVICE_FUNCTION_NAMES}
170     Utils.Remove All Elements At URI    ${SERVICE_FORWARDERS_URI}
171     Utils.Remove All Elements At URI    ${SERVICE_NODES_URI}
172     Utils.Remove All Elements At URI    ${SERVICE_CHAINS_URI}
173     Utils.Remove All Elements At URI    ${SERVICE_SCHED_TYPES_URI}
174     Utils.Remove All Elements If Exist    ${SERVICE_FUNCTION_PATHS_URI}
175     BuiltIn.Wait Until Keyword Succeeds    60s    2s    SfcKeywords.Check Empty Service Function Paths State
176
177 *** Keywords ***
178 Init Suite
179     [Documentation]    Create session and initialize ODL version specific variables
180     RequestsLibrary.Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
181     BuiltIn.log    ${ODL_STREAM}
182     BuiltIn.Set Suite Variable    ${VERSION_DIR}    master
183     BuiltIn.Set Suite Variable    ${TEST_DIR}    ${CURDIR}/../../../variables/sfc/${VERSION_DIR}
184     BuiltIn.Set Suite Variable    ${SERVICE_FUNCTIONS_FILE}    ${TEST_DIR}/service-functions.json
185     BuiltIn.Set Suite Variable    @{SERVICE_FUNCTION_NAMES}    "napt44-103-2"    "napt44-103-1"    "dpi-102-2"    "firewall-101-2"    "napt44-104"
186     ...    "dpi-102-1"    "firewall-104"    "dpi-102-3"    "firewall-101-1"
187     BuiltIn.Set Suite Variable    ${SERVICE_FORWARDERS_FILE}    ${TEST_DIR}/service-function-forwarders.json
188     BuiltIn.Set Suite Variable    ${SERVICE_NODES_FILE}    ${TEST_DIR}/service-nodes.json
189     BuiltIn.Set Suite Variable    ${SERVICE_CHAINS_FILE}    ${TEST_DIR}/service-function-chains.json
190     BuiltIn.Set Suite Variable    ${SERVICE_FUNCTION_PATHS_FILE}    ${TEST_DIR}/service-function-paths.json
191     BuiltIn.Set Suite Variable    ${SERVICE_RANDOM_SCHED_TYPE_FILE}    ${TEST_DIR}/service-random-schedule-type.json
192     BuiltIn.Set Suite Variable    ${SERVICE_ROUNDROBIN_SCHED_TYPE_FILE}    ${TEST_DIR}/service-roundrobin-schedule-type.json
193     BuiltIn.Set Suite Variable    ${SERVICE_LOADBALANCE_SCHED_TYPE_FILE}    ${TEST_DIR}/service-loadbalance-schedule-type.json
194     BuiltIn.Set Suite Variable    ${SERVICE_SHORTESTPATH_SCHED_TYPE_FILE}    ${TEST_DIR}/service-shortestpath-schedule-type.json