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