[VFc] - fix CSIT failure for lcm component
[integration/csit.git] / tests / vfc / nfvo-lcm / test.robot
1 *** settings ***
2 Resource    ../../common.robot
3 Library     Collections
4 Library     RequestsLibrary
5 Library     OperatingSystem
6 Library     json
7 Library     HttpLibrary.HTTP
8 Library     ONAPLibrary.Utilities
9
10 *** Variables ***
11 @{return_ok_list}=   200  201  202  204
12 ${queryswagger_url}    /api/nslcm/v1/swagger.json
13 ${ns_url}          /api/nslcm/v1/ns
14 ${get_subscriptions_url}          /api/nslcm/v1/subscriptions
15 ${healthcheck_url}     /api/nslcm/v1/health_check
16 ${get_job_url}     /api/nslcm/v1/jobs
17 ${vnfs_url}     /api/nslcm/v1/ns/vnfs
18 ${terminate_vnfs_url}     /api/nslcm/v1/ns/terminatevnf
19 ${vls_url}     /api/nslcm/v1/ns/vls
20 ${sfcs_url}     /api/nslcm/v1/ns/sfcs
21 ${pnfs_url}     /api/nslcm/v1/pnfs
22
23 ${ns_instances_url}    /api/nslcm/v1/ns_instances
24
25 #json files
26 ${create_ns_json}    ${SCRIPTS}/../tests/vfc/nfvo-lcm/jsoninput/create_ns.json
27 ${heal_ns_json}    ${SCRIPTS}/../tests/vfc/nfvo-lcm/jsoninput/heal_ns.json
28 ${scale_ns_json}    ${SCRIPTS}/../tests/vfc/nfvo-lcm/jsoninput/scale_ns.json
29 ${update_ns_json}    ${SCRIPTS}/../tests/vfc/nfvo-lcm/jsoninput/update_ns.json
30 ${terminate_ns_json}    ${SCRIPTS}/../tests/vfc/nfvo-lcm/jsoninput/terminate_ns.json
31 ${create_vnf_json}    ${SCRIPTS}/../tests/vfc/nfvo-lcm/jsoninput/create_vnf.json
32 ${terminate_vnf_json}    ${SCRIPTS}/../tests/vfc/nfvo-lcm/jsoninput/terminate_vnf.json
33 ${create_vl_json}    ${SCRIPTS}/../tests/vfc/nfvo-lcm/jsoninput/create_vl.json
34 ${create_subscriptions_json}    ${SCRIPTS}/../tests/vfc/nfvo-lcm/jsoninput/create_subscription.json
35
36 ${create_ns_instance_json}    ${SCRIPTS}/../tests/vfc/nfvo-lcm/jsoninput/create_ns_instance.json
37 ${terminate_ns_instance_json}    ${SCRIPTS}/../tests/vfc/nfvo-lcm/jsoninput/terminate_ns_instance.json
38 ${update_ns_instance_json}    ${SCRIPTS}/../tests/vfc/nfvo-lcm/jsoninput/update_ns_instance.json
39
40 #global variables
41 ${nsInstId}
42 ${jobInstId}
43 ${vnfInstId}
44 ${vlInstId}
45 ${nsInstanceId}
46
47 *** Test Cases ***
48 NslcmSwaggerTest
49     [Documentation]    query swagger info of nslcm
50     ${headers}    Create Dictionary    Content-Type=application/json    Accept=application/json
51     Create Session    web_session    http://${NSLCM_IP}:8403    headers=${headers}
52     ${resp}=   GET On Session    web_session    ${queryswagger_url}
53     ${responese_code}=     Convert To String      ${resp.status_code}
54     List Should Contain Value    ${return_ok_list}   ${responese_code}
55     ${response_json}    json.loads    ${resp.content}
56     ${swagger_version}=    Convert To String      ${response_json['swagger']}
57     Should Be Equal    ${swagger_version}    2.0
58
59 NslcmSwaggerByMSBTest
60     [Documentation]    query swagger info of nslcm by MSB
61     ${headers}    Create Dictionary    Content-Type=application/json    Accept=application/json
62     Create Session    web_session    http://${NSLCM_IP}:8403    headers=${headers}
63     ${resp}=   GET On Session    web_session    ${queryswagger_url}
64     ${responese_code}=     Convert To String      ${resp.status_code}
65     List Should Contain Value    ${return_ok_list}   ${responese_code}
66     ${response_json}    json.loads    ${resp.content}
67     ${swagger_version}=    Convert To String      ${response_json['swagger']}
68     Should Be Equal    ${swagger_version}    2.0
69
70 CreateNSTest
71     [Documentation]    Create NS function test
72     ${json_value}=     json_from_file      ${create_ns_json}
73     ${json_string}=     string_from_json   ${json_value}
74     ${headers}    Create Dictionary    Content-Type=application/json    Accept=application/json
75     Create Session    web_session    http://${NSLCM_IP}:8403    headers=${headers}
76     Set Request Body    ${json_string}
77     ${resp}=    Post Request    web_session     ${ns_url}    ${json_string}
78     ${responese_code}=     Convert To String      ${resp.status_code}
79     List Should Contain Value    ${return_ok_list}   ${responese_code}
80     ${response_json}    json.loads    ${resp.content}
81     ${nsInstId}=    Convert To String      ${response_json['nsInstanceId']}
82     Set Global Variable     ${nsInstId}
83
84 CreateVnfTest
85     [Documentation]    Create vnf function test
86     ${json_value}=     json_from_file      ${create_vnf_json}
87     Set To Dictionary    ${json_value}    nsInstanceId=${nsInstId}
88     ${json_string}=     string_from_json   ${json_value}
89     ${headers}    Create Dictionary    Content-Type=application/json    Accept=application/json
90     Create Session    web_session    http://${NSLCM_IP}:8403    headers=${headers}
91     Set Request Body    ${json_string}
92     ${resp}=    Post Request    web_session     ${vnfs_url}    ${json_string}
93     ${responese_code}=     Convert To String      ${resp.status_code}
94     List Should Contain Value    ${return_ok_list}   ${responese_code}
95     ${response_json}    json.loads    ${resp.content}
96     ${vnfInstId}=    Convert To String      ${response_json['vnfInstId']}
97     Set Global Variable     ${vnfInstId}
98
99 QueryVnfTest
100     [Documentation]    Query vnf function test
101     ${headers}    Create Dictionary    Content-Type=application/json    Accept=application/json
102     Create Session    web_session    http://${NSLCM_IP}:8403    headers=${headers}
103     ${resp}=   GET On Session    web_session    ${vnfs_url}/${vnfInstId}
104     ${responese_code}=     Convert To String      ${resp.status_code}
105     List Should Contain Value    ${return_ok_list}   ${responese_code}
106
107 TerminateVnfTest
108     [Documentation]    Terminate vnf function test
109     ${json_value}=     json_from_file      ${terminate_vnf_json}
110     ${json_string}=     string_from_json   ${json_value}
111     ${headers}    Create Dictionary    Content-Type=application/json    Accept=application/json
112     Create Session    web_session    http://${NSLCM_IP}:8403    headers=${headers}
113     Set Request Body    ${json_string}
114     ${resp}=    Post Request    web_session     ${terminate_vnfs_url}/${vnfInstId}    ${json_string}
115     ${responese_code}=     Convert To String      ${resp.status_code}
116     List Should Contain Value    ${return_ok_list}   ${responese_code}
117
118 CreateVlTest
119     [Documentation]    Create vl function test
120     ${json_value}=     json_from_file      ${create_vl_json}
121     Set To Dictionary    ${json_value}    nsInstanceId=${nsInstId}
122     ${json_string}=     string_from_json   ${json_value}
123     ${headers}    Create Dictionary    Content-Type=application/json    Accept=application/json
124     Create Session    web_session    http://${NSLCM_IP}:8403    headers=${headers}
125     Set Request Body    ${json_string}
126     ${resp}=    Post Request    web_session     ${vls_url}    ${json_string}
127     ${responese_code}=     Convert To String      ${resp.status_code}
128     List Should Contain Value    ${return_ok_list}   ${responese_code}
129     ${response_json}    json.loads    ${resp.content}
130     ${vlInstId}=    Convert To String      ${response_json['vlId']}
131     Set Global Variable     ${vlInstId}
132
133 DeleteVlTest
134     [Documentation]    Delete vl function test
135     ${headers}    Create Dictionary    Content-Type=application/json    Accept=application/json
136     Create Session    web_session    http://${NSLCM_IP}:8403    headers=${headers}
137     ${resp}=    Delete Request    web_session     ${vls_url}/${vlInstId}
138     ${responese_code}=     Convert To String      ${resp.status_code}
139     List Should Contain Value    ${return_ok_list}   ${responese_code}
140
141 ScaleNSTest
142     [Documentation]    Scale Ns function test
143     ${json_value}=     json_from_file      ${scale_ns_json}
144     ${json_string}=     string_from_json   ${json_value}
145     ${headers}    Create Dictionary    Content-Type=application/json    Accept=application/json
146     Create Session    web_session    http://${NSLCM_IP}:8403    headers=${headers}
147     Set Request Body    ${json_string}
148     ${resp}=    Post Request    web_session     ${ns_url}/${nsInstId}/scale    ${json_string}
149     ${responese_code}=     Convert To String      ${resp.status_code}
150     List Should Contain Value    ${return_ok_list}   ${responese_code}
151
152 HealNSTest
153     [Documentation]    Heal Ns function test
154     ${json_value}=     json_from_file      ${heal_ns_json}
155     ${json_string}=     string_from_json   ${json_value}
156     ${headers}    Create Dictionary    Content-Type=application/json    Accept=application/json
157     Create Session    web_session    http://${NSLCM_IP}:8403    headers=${headers}
158     Set Request Body    ${json_string}
159     ${resp}=    Post Request    web_session     ${ns_url}/${nsInstId}/heal    ${json_string}
160     ${responese_code}=     Convert To String      ${resp.status_code}
161     List Should Contain Value    ${return_ok_list}   ${responese_code}
162     ${response_json}    json.loads    ${resp.content}
163     ${jobInstId}=    Convert To String      ${response_json['jobId']}
164     Set Global Variable     ${jobInstId}
165
166 GetJobTest
167     [Documentation]    Query Ns Job function test
168     ${headers}    Create Dictionary    Content-Type=application/json    Accept=application/json
169     Create Session    web_session    http://${NSLCM_IP}:8403    headers=${headers}
170     ${resp}=   GET On Session    web_session    ${get_job_url}/${jobInstId}
171     ${responese_code}=     Convert To String      ${resp.status_code}
172     List Should Contain Value    ${return_ok_list}   ${responese_code}
173
174 UpdateNSTest
175     [Documentation]    Scale Ns function test
176     ${json_value}=     json_from_file      ${update_ns_json}
177     ${json_string}=     string_from_json   ${json_value}
178     ${headers}    Create Dictionary    Content-Type=application/json    Accept=application/json
179     Create Session    web_session    http://${NSLCM_IP}:8403    headers=${headers}
180     Set Request Body    ${json_string}
181     ${resp}=    Post Request    web_session     ${ns_url}/${nsInstId}/update    ${json_string}
182     ${responese_code}=     Convert To String      ${resp.status_code}
183     List Should Contain Value    ${return_ok_list}   ${responese_code}
184
185 TerminateNSTest
186     [Documentation]    Terminate Ns function test
187     ${json_value}=     json_from_file      ${terminate_ns_json}
188     ${json_string}=     string_from_json   ${json_value}
189     ${headers}    Create Dictionary    Content-Type=application/json    Accept=application/json
190     Create Session    web_session    http://${NSLCM_IP}:8403    headers=${headers}
191     Set Request Body    ${json_string}
192     ${resp}=    Post Request    web_session     ${ns_url}/${nsInstId}/terminate    ${json_string}
193     ${responese_code}=     Convert To String      ${resp.status_code}
194     List Should Contain Value    ${return_ok_list}   ${responese_code}
195
196 DeleteNSTest
197     [Documentation]    Delete NS function test
198     ${headers}    Create Dictionary    Content-Type=application/json    Accept=application/json
199     Create Session    web_session    http://${NSLCM_IP}:8403    headers=${headers}
200     ${resp}=    Delete Request    web_session     ${ns_url}/${nsInstId}
201     ${responese_code}=     Convert To String      ${resp.status_code}
202     List Should Contain Value    ${return_ok_list}   ${responese_code}
203
204 LcmHealthCheckTest
205     [Documentation]    check health for nslcm by MSB
206     ${headers}    Create Dictionary    Content-Type=application/json    Accept=application/json
207     Create Session    web_session    http://${NSLCM_IP}:8403    headers=${headers}
208     ${resp}=   GET On Session    web_session    ${healthcheck_url}
209     ${responese_code}=     Convert To String      ${resp.status_code}
210     List Should Contain Value    ${return_ok_list}   ${responese_code}
211     ${response_json}    json.loads    ${resp.content}
212     ${health_status}=    Convert To String      ${response_json['status']}
213     Should Be Equal    ${health_status}    active
214
215 LcmGetNsTest
216     [Documentation]    get ns instances for nslcm by MSB
217     ${headers}    Create Dictionary    Content-Type=application/json    Accept=application/json
218     Create Session    web_session    http://${NSLCM_IP}:8403    headers=${headers}
219     ${resp}=   GET On Session    web_session    ${ns_url}
220     ${responese_code}=     Convert To String      ${resp.status_code}
221     List Should Contain Value    ${return_ok_list}   ${responese_code}
222
223 QueryAllPnfsTest
224     [Documentation]    Query all pnfs function test
225     ${headers}    Create Dictionary    Content-Type=application/json    Accept=application/json
226     Create Session    web_session    http://${NSLCM_IP}:8403    headers=${headers}
227     ${resp}=   GET On Session    web_session    ${pnfs_url}
228     ${responese_code}=     Convert To String      ${resp.status_code}
229     List Should Contain Value    ${return_ok_list}   ${responese_code}
230
231 CreateNSInstanceTest
232     [Documentation]    Create NS Instance function test
233     ${json_value}=     json_from_file      ${create_ns_instance_json}
234     ${json_string}=     string_from_json   ${json_value}
235     ${headers}    Create Dictionary    Content-Type=application/json    Accept=application/json    globalcustomerid=global-customer-id-test1    servicetype=service-type-test1
236     Create Session    web_session    http://${NSLCM_IP}:8403    headers=${headers}
237     Set Request Body    ${json_string}
238     ${resp}=    Post Request    web_session     ${ns_instances_url}    ${json_string}
239     ${responese_code}=     Convert To String      ${resp.status_code}
240     List Should Contain Value    ${return_ok_list}   ${responese_code}
241     ${response_json}    json.loads    ${resp.content}
242     ${nsInstanceId}=    Convert To String      ${response_json['nsInstanceId']}
243     Set Global Variable     ${nsInstanceId}
244
245 QueryNSInstancesTest
246     [Documentation]    Query Ns Instances function test
247     ${headers}    Create Dictionary    Content-Type=application/json    Accept=application/json
248     Create Session    web_session    http://${NSLCM_IP}:8403    headers=${headers}
249     ${resp}=   GET On Session    web_session    ${ns_instances_url}
250     ${responese_code}=     Convert To String      ${resp.status_code}
251     List Should Contain Value    ${return_ok_list}   ${responese_code}
252
253 UpdateNSInstanceTest
254     [Documentation]    Scale Ns Instance function test
255     ${json_value}=     json_from_file      ${update_ns_instance_json}
256     ${json_string}=     string_from_json   ${json_value}
257     Log    ${json_string}
258     ${headers}    Create Dictionary    Content-Type=application/json    Accept=application/json
259     Create Session    web_session    http://${NSLCM_IP}:8403    headers=${headers}
260     Set Request Body    ${json_string}
261     ${resp}=    Post Request    web_session     ${ns_instances_url}/${nsInstId}/update    ${json_string}
262     ${responese_code}=     Convert To String      ${resp.status_code}
263     List Should Contain Value    ${return_ok_list}   ${responese_code}
264
265 TerminateNSInstanceTest
266     [Documentation]    Terminate Ns Instance function test
267     ${json_value}=     json_from_file      ${terminate_ns_instance_json}
268     ${json_string}=     string_from_json   ${json_value}
269     ${headers}    Create Dictionary    Content-Type=application/json    Accept=application/json
270     Create Session    web_session    http://${NSLCM_IP}:8403    headers=${headers}
271     Set Request Body    ${json_string}
272     ${resp}=    Post Request    web_session     ${ns_instances_url}/${nsInstanceId}/terminate    ${json_string}
273     ${responese_code}=     Convert To String      ${resp.status_code}
274     List Should Contain Value    ${return_ok_list}   ${responese_code}
275
276 LcmCreateSubscriptionsTest
277     [Documentation]    Postdeal Ns function test
278     ${json_value}=     json_from_file      ${create_subscriptions_json}
279     ${json_string}=     string_from_json   ${json_value}
280     ${headers}    Create Dictionary    Content-Type=application/json    Accept=application/json
281     Create Session    web_session    http://${NSLCM_IP}:8403    headers=${headers}
282     Set Request Body    ${json_string}
283     ${resp}=    Post Request    web_session     ${get_subscriptions_url}    ${json_string}
284     ${responese_code}=     Convert To String      ${resp.status_code}
285     List Should Contain Value    ${return_ok_list}   ${responese_code}
286
287 LcmGetSubscriptionsTest
288     [Documentation]    get subscriptions for nslcm by MSB
289     ${headers}    Create Dictionary    Content-Type=application/json    Accept=application/json
290     Create Session    web_session    http://${NSLCM_IP}:8403    headers=${headers}
291     ${resp}=   GET On Session    web_session    ${get_subscriptions_url}
292     ${responese_code}=     Convert To String      ${resp.status_code}
293     List Should Contain Value    ${return_ok_list}   ${responese_code}