PMJobs.robot 29 KB
Newer Older
1
2
*** Settings ***
Library           JSONSchemaLibrary    schemas/
3
Resource          environment/variables.txt    # Generic Parameters
4
5
Library           JSONLibrary
Library           OperatingSystem
6
Library           String
Elian Kraja's avatar
Elian Kraja committed
7
Library           REST    ${VNFM_SCHEMA}://${VNFM_HOST}:${VNFM_PORT}    ssl_verify=false
Elian Kraja's avatar
Elian Kraja committed
8
Library           MockServerLibrary
9
10
11
Library           Process
Suite Setup       Create Sessions
Suite Teardown    Terminate All Processes    kill=true
12
13

*** Test Cases ***
14
15
16
17
18
GET all VNF Performance Monitoring Jobs
    [Documentation]    Test ID: 7.3.4.1.1
    ...    Test title: GET all VNF Performance Monitoring Jobs
    ...    Test objective: The objective is to test the retrieval of all the available VNF performance monitoring jobs and perform a JSON schema and content validation of the collected jobs data structure
    ...    Pre-conditions: A VNF instance is instantiated. One or more VNF performance jobs are set in the VNF.
19
    ...    Reference: Clause 6.4.2.3.2 - ETSI GS NFV-SOL 003 [1] v2.8.1
20
21
22
23
24
25
26
27
28
29
30
31
32
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: none
    GET all VNF Performance Monitoring Jobs
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is   PmJobs
    Check HTTP Response Body Does Not Contain reports

GET VNF Performance Monitoring Jobs with attribute-based filter
    [Documentation]    Test ID: 7.3.4.1.2
    ...    Test title: GET all VNF Performance Monitoring Jobs with attribute-based filter
    ...    Test objective: The objective is to test the retrieval of VNF performance monitoring jobs using attribute-based filter, perform a JSON schema validation of the collected jobs data structure, and verify that the retrieved information matches the issued attribute-based filter
    ...    Pre-conditions: A VNF instance is instantiated. One or more VNF performance jobs are set in the VNF.
33
    ...    Reference: Clause 6.4.2.3.2 - ETSI GS NFV-SOL 003 [1] v2.8.1
34
35
36
37
38
39
40
41
42
43
44
45
46
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: none
    GET VNF Performance Monitoring Jobs with attribute-based filter
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is   PmJobs
    Check HTTP Response Body PmJobs Matches the requested attribute-based filter

GET all VNF Performance Monitoring Jobs with all_fields attribute selector
    [Documentation]    Test ID: 7.3.4.1.3
    ...    Test title: GET all VNF Performance Monitoring Jobs with all_fields attribute selector
    ...    Test objective: The objective is to test the retrieval of all VNF performance monitoring jobs all_fields attribute selector, perform a JSON schema validation of the collected jobs data structure, and verify that the retrieved information matches the issued all_fileds selector
    ...    Pre-conditions: A VNF instance is instantiated. One or more VNF performance jobs are set in the VNF.
47
    ...    Reference: Clause 6.4.2.3.2 - ETSI GS NFV-SOL 003 [1] v2.8.1
48
49
50
51
52
53
54
55
56
57
58
59
60
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: none
    GET VNF Performance Monitoring Jobs with all_fields attribute selector
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is   PmJobs
    Check HTTP Response Body PmJobs Matches the requested all_fields selector

GET all VNF Performance Monitoring Jobs with exclude_default attribute selector
    [Documentation]    Test ID: 7.3.4.1.4
    ...    Test title: GET all VNF Performance Monitoring Jobs with exclude_default attribute selector
    ...    Test objective: The objective is to test the retrieval of all VNF performance monitoring jobs exclude_default attribute selector, perform a JSON schema validation of the collected jobs data structure, and verify that the retrieved information matches the issued exclude_default selector
    ...    Pre-conditions: A VNF instance is instantiated. One or more VNF performance jobs are set in the VNF.
61
    ...    Reference: Clause 6.4.2.3.2 - ETSI GS NFV-SOL 003 [1] v2.8.1
62
63
64
65
66
67
68
69
70
71
72
73
74
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: none
    GET VNF Performance Monitoring Jobs with exclude_default attribute selector
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is   PmJobs
    Check HTTP Response Body PmJobs Matches the requested exclude_default selector

GET all VNF Performance Monitoring Jobs with fields attribute selector
    [Documentation]    Test ID: 7.3.4.1.5
    ...    Test title: GET all VNF Performance Monitoring Jobs with fields attribute selector
    ...    Test objective: The objective is to test the retrieval of all VNF performance monitoring jobs fields attribute selector, perform a JSON schema validation of the collected jobs data structure, and verify that the retrieved information matches the issued fields selector
    ...    Pre-conditions: A VNF instance is instantiated. One or more VNF performance jobs are set in the VNF.
75
    ...    Reference: Clause 6.4.2.3.2 - ETSI GS NFV-SOL 003 [1] v2.8.1
76
77
78
79
80
81
82
83
84
85
86
87
88
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: The VNFM supports the use of exclude_fields attribute selector
    ...    Post-Conditions: none
    GET VNF Performance Monitoring Jobs with fields attribute selector
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is   PmJobs
    Check HTTP Response Body PmJobs Matches the requested fields selector

GET all VNF Performance Monitoring Jobs with exclude_fields attribute selector
    [Documentation]    Test ID: 7.3.4.1.6
    ...    Test title: GET all VNF Performance Monitoring Jobs with exclude_fields attribute selector
    ...    Test objective: The objective is to test the retrieval of all VNF performance monitoring jobs exclude_fields attribute selector, perform a JSON schema validation of the collected jobs data structure, and verify that the retrieved information matches the issued exclude_fields selector
    ...    Pre-conditions: A VNF instance is instantiated. One or more VNF performance jobs are set in the VNF.
89
    ...    Reference: Clause 6.4.2.3.2 - ETSI GS NFV-SOL 003 [1] v2.8.1
90
91
92
93
94
95
96
97
98
99
100
101
102
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: The VNFM supports the use of exclude_fields attribute selector
    ...    Post-Conditions: none
    GET VNF Performance Monitoring Jobs with exclude_fields attribute selector
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is   PmJobs
    Check HTTP Response Body PmJobs Matches the requested exclude_fields selector

GET VNF Performance Monitoring Jobs with invalid attribute-based filter
    [Documentation]    Test ID: 7.3.4.1.7
    ...    Test title: GET VNF Performance Monitoring Jobs with invalid attribute-based filter
    ...    Test objective: The objective is to test that the retrieval of VNF performance monitoring jobs fails when using invalid attribute-based filter, and perform the JSON schema validation of the failed operation HTTP response
    ...    Pre-conditions: A VNF instance is instantiated. One or more VNF performance jobs are set in the VNF.
103
    ...    Reference: Clause 6.4.2.3.2 - ETSI GS NFV-SOL 003 [1] v2.8.1
104
105
106
107
108
109
110
111
112
113
114
115
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: none
    GET VNF Performance Monitoring Jobs with invalid attribute-based filter
    Check HTTP Response Status Code Is    400
    Check HTTP Response Body Json Schema Is   ProblemDetails

GET VNF Performance Monitoring Jobs with invalid resource endpoint
    [Documentation]    Test ID: 7.3.4.1.8
    ...    Test title: GET VNF Performance Monitoring Jobs with invalid resource endpoint
    ...    Test objective: The objective is to test that the retrieval of VNF performance monitoring jobs fails when using invalid resource endpoint
    ...    Pre-conditions: A VNF instance is instantiated. One or more VNF performance jobs are set in the VNF.
116
    ...    Reference: Clause 6.4.2.3.2 - ETSI GS NFV-SOL 003 [1] v2.8.1
117
118
119
120
121
122
123
124
125
126
127
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: none
    GET VNF Performance Monitoring Jobs with invalid resource endpoint
    Check HTTP Response Status Code Is    404

Create new VNF Performance Monitoring Job
    [Documentation]    Test ID: 7.3.4.1.9
    ...    Test title:  Create a new VNF Performance Monitoring Job
    ...    Test objective: The objective is to test the creation of a new VNF performance monitoring job and perform the JSON schema validation of the returned job data structure
    ...    Pre-conditions: A VNF instance is instantiated. One or more VNF performance jobs are set in the VNF.
128
    ...    Reference: Clause 6.4.2.3.1 - ETSI GS NFV-SOL 003 [1] v2.8.1
129
130
131
132
133
134
135
136
137
138
139
140
141
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: The VNF Performance Job is successfully created on the VNFM
    Send Post Request Create new VNF Performance Monitoring Job
    Check HTTP Response Status Code Is    201
    Check HTTP Response Body Json Schema Is   PmJob
    Check Postcondition PmJob Exists

PUT all VNF Performance Monitoring Jobs - Method not implemented
    [Documentation]    Test ID: 7.3.4.1.10
    ...    Test title: PUT all VNF Performance Monitoring Jobs - Method not implemented
    ...    Test objective: The objective is to test that PUT method is not allowed to modify VNF Performance Monitoring Jobs
    ...    Pre-conditions: A VNF instance is instantiated. One or more VNF performance jobs are set in the VNF.
142
    ...    Reference: Clause 6.4.2.3.3 - ETSI GS NFV-SOL 003 [1] v2.8.1
143
144
145
146
147
148
149
150
151
152
153
    ...    Config ID: Config_prod_VE
    ...    Applicability: none
    ...    Post-Conditions: none
    Send PUT Request for all VNF Performance Monitoring Jobs
    Check HTTP Response Status Code Is    405
    
PATCH all VNF Performance Monitoring Jobs - (Method not implemented)
    [Documentation]    Test ID: 7.3.4.1.11
    ...    Test title: PATCH all VNF Performance Monitoring Jobs - Method not implemented
    ...    Test objective: The objective is to test that PATCH method is not allowed to update VNF Performance Monitoring Jobs
    ...    Pre-conditions: A VNF instance is instantiated. One or more VNF performance jobs are set in the VNF.
154
    ...    Reference: Clause 6.4.2.3.3 - ETSI GS NFV-SOL 003 [1] v2.8.1
155
156
157
158
159
160
161
162
163
164
165
    ...    Config ID: Config_prod_VE
    ...    Applicability: none
    ...    Post-Conditions: none
    Send PATCH Request for all VNF Performance Monitoring Jobs
    Check HTTP Response Status Code Is    405
    
DELETE all VNF Performance Monitoring Jobs - Method not implemented
    [Documentation]    Test ID: 7.3.4.1.12
    ...    Test title: DELETE all VNF Performance Monitoring Jobs - Method not implemented
    ...    Test objective: The objective is to test that DELETE method is not allowed to update VNF Performance Monitoring Jobs
    ...    Pre-conditions: A VNF instance is instantiated. One or more VNF performance jobs are set in the VNF.
166
    ...    Reference: Clause 6.4.2.3.3 - ETSI GS NFV-SOL 003 [1] v2.8.1
167
168
169
170
171
172
173
    ...    Config ID: Config_prod_VE
    ...    Applicability: none
    ...    Post-Conditions: none
    Send PATCH Request for all VNF Performance Monitoring Jobs
    Check HTTP Response Status Code Is    405
    Check Postcondition VNF Performance Monitoring Jobs Exist
    
174
175
176
177
178
GET all VNF Performance Monitoring Jobs as Paged Response
    [Documentation]    Test ID: 7.3.4.1.13
    ...    Test title: GET all VNF Performance Monitoring Jobs as Paged Response
    ...    Test objective: The objective is to test the retrieval of all the available VNF performance monitoring jobs as Paged Response.
    ...    Pre-conditions: A VNF instance is instantiated. One or more VNF performance jobs are set in the VNF.
179
    ...    Reference: Clause 6.4.2.3.2 - ETSI GS NFV-SOL 003 [1] v2.8.1
180
    ...    Config ID: Config_prod_VNFM
181
    ...    Applicability: The VNFM supports response paging for the VNF performance jobs resources
182
183
184
    ...    Post-Conditions: none
    GET all VNF Performance Monitoring Jobs
    Check HTTP Response Status Code Is    200
185
186
187
188
189
190
191
192
193
194
195
196
197
    Check HTTP Response Header Contain Link

GET all VNF Performance Monitoring Jobs as Paged Response with nextpage_opauque_marker parameter 
     [Documentation]    Test ID: 7.3.4.1.13a
    ...    Test title: GET all VNF Performance Monitoring Jobs as Paged Response with nextpage_opauque_marker parameter 
    ...    Test objective: The objective is to query information about all the available VNF performance monitoring jobs as a Paged Response and retrieve the next page using the nextpage_opaque_marker parameter
    ...    Pre-conditions: A request for retrieving the available VNF performance monitoring jobs as a paged response has been successfully issued (Test ID: 7.3.4.1.13)
    ...    Reference: Clause 6.4.2.3.2 - ETSI GS NFV-SOL 003 [1] v2.8.1
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: The VNFM supports response paging for the VNF performance jobs resources
    ...    Post-Conditions: none 
    GET all VNF Performance Monitoring Jobs with nextpage_opaque_marker parameter 
    Check HTTP Response Status Code Is    200
198
199
200
201
202
203
    
GET VNF Performance Monitoring Jobs - Bad Request Response too Big
    [Documentation]    Test ID: 7.3.4.1.14
    ...    Test title: GET VNF Performance Monitoring Jobs - Bad Request Response too Big
    ...    Test objective: The objective is to test that the retrieval of VNF performance monitoring jobs fails because response is too big, and perform the JSON schema validation of the failed operation HTTP response.
    ...    Pre-conditions: A VNF instance is instantiated. One or more VNF performance jobs are set in the VNF.
204
    ...    Reference: Clause 6.4.2.3.2 - ETSI GS NFV-SOL 003 [1] v2.8.1
205
206
207
208
209
210
211
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: none
    GET all VNF Performance Monitoring Jobs
    Check HTTP Response Status Code Is    400
    Check HTTP Response Body Json Schema Is   ProblemDetails
    
212
213
214
215
216
GET all VNF Performance Monitoring Jobs with fields and exclude_default attribute selector
    [Documentation]    Test ID: 7.3.4.1.15
    ...    Test title: GET all VNF Performance Monitoring Jobs with fields and exclude_default attribute selector
    ...    Test objective: The objective is to test the retrieval of all VNF performance monitoring jobs fields and exclude_default attribute selector, perform a JSON schema validation of the collected jobs data structure, and verify that the retrieved information matches the issued fields selector
    ...    Pre-conditions: A VNF instance is instantiated. One or more VNF performance jobs are set in the VNF.
217
    ...    Reference: Clause 6.4.2.3.2 - ETSI GS NFV-SOL 003 [1] v2.8.1
218
219
220
221
222
223
224
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: The VNFM supports the use of fields and exclude_fields attribute selector
    ...    Post-Conditions: none
    GET VNF Performance Monitoring Jobs with fields and exclude_default attribute selector
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is   PmJobs
    Check HTTP Response Body PmJobs Matches the requested fields selector
225
226
227
228
229
230
231
232
233
234
235
236
237

Create new VNF Performance Monitoring Job with Unprocessable Entity
    [Documentation]    Test ID: 7.3.4.1.16
    ...    Test title:  Create a new VNF Performance Monitoring Job with Unprocessable Entity
    ...    Test objective: The objective is to test that the creation of a new VNF performance monitoring job fails when the request data is syntactically correct but cannot be processed, and perform the JSON schema validation of the failed operation HTTP response
    ...    Pre-conditions: A VNF instance is instantiated.
    ...    Reference: Clause 6.4.2.3.1 - ETSI GS NFV-SOL 003 [1] v2.8.1
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: none
    Send Post Request Create new VNF Performance Monitoring Job with Unprocessable Entity
    Check HTTP Response Status Code Is    422
    Check HTTP Response Body Json Schema Is   ProblemDetails
238
    
239
*** Keywords ***
240
241
242
243
Create Sessions
    Start Process  java  -jar  ${MOCK_SERVER_JAR}    -serverPort  ${callback_port}  alias=mockInstance
    Wait For Process  handle=mockInstance  timeout=5s  on_timeout=continue
    Create Mock Session  ${callback_uri}:${callback_port}
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264

Check HTTP Response Header Contain Link
    ${linkURL}=    Get Value From Json    ${response['headers']}    $..Link
    Should Not Be Empty    ${linkURL}
    Log    Check that Link header contains rel set to next
    Should Contain    ${linkURL}    rel="next"
    Log    Check that Link header contains URI to next page between <>
    ${linkHeaderUri}=    Get Regexp Matches    ${linkURL}    (?<=\<)(.*?)(?=\>)
    ${length}=    Get Length    ${linkHeaderUri}	
    Should Be Equal As Integers	${length}	0
    Set Global Variable    ${nextPageUri}    ${linkHeaderUri[0]} 

Get all VNF Performance Monitoring Jobs with nextpage_opaque_marker parameter
    Log    Get next page of subscriptions
    Set Headers  {"Accept":"${ACCEPT_JSON}"}  
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
    Log    Execute Query using the URI provided in the previous GET request and validate response
    Get    ${nextPageUri}
    ${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}
 
265
GET all VNF Performance Monitoring Jobs
266
    Log    Trying to get all PM Jobs present in the VNFM
267
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
268
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
269
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/pm_jobs
270
271
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
272

273
GET VNF Performance Monitoring Jobs with attribute-based filter
274
    Log    Trying to get all PM Jobs present in the VNFM, using filter params
275
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
276
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
277
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/pm_jobs?${POS_FILTER}
278
279
280
281
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}

GET VNF Performance Monitoring Jobs with all_fields attribute selector
282
    Log    Trying to get all PM Jobs present in the VNFM, using 'all_fields' filter
283
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
284
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
285
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/pm_jobs?all_fields
286
287
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
288

289
GET VNF Performance Monitoring Jobs with exclude_default attribute selector
290
291
    Log    Trying to get all VNF Packages present in the VNFM, using filter params
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
292
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
293
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/pm_jobs?exclude_default
294
295
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
296

297
GET VNF Performance Monitoring Jobs with fields attribute selector
298
    Log    Trying to get all VNF Packages present in the VNFM, using filter params
Giacomo Bernini's avatar
fixes  
Giacomo Bernini committed
299
    Pass Execution If    ${FIELD_USAGE} == 0    Skipping test as VNFM is not supporting 'fields'
300
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
301
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
302
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/pm_jobs?fields=${fields}
303
304
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
305

306
307
308
309
GET VNF Performance Monitoring Jobs with fields and exclude_default attribute selector
    Log    Trying to get all VNF Packages present in the VNFM, using filter params
    Pass Execution If    ${FIELD_USAGE} == 0    Skipping test as VNFM is not supporting 'fields'
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
310
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
311
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/pm_jobs?fields=${fields}&exclude_default
312
313
314
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
    
315
GET VNF Performance Monitoring Jobs with exclude_fields attribute selector
316
    Log    Trying to get all VNF Packages present in the VNFM, using filter params
Giacomo Bernini's avatar
fixes  
Giacomo Bernini committed
317
    Pass Execution If    ${FIELD_USAGE} == 0    Skipping test as VNFM is not supporting 'fields'
318
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
319
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
320
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/pm_jobs?fields=${fields}
321
322
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
323

324
GET VNF Performance Monitoring Jobs with invalid attribute-based filter
325
326
    Log    Trying to get all PM Jobs present in the VNFM, using an erroneous filter param
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
327
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
328
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/pm_jobs?${NEG_FILTER}
329
330
331
332
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}

GET VNF Performance Monitoring Jobs with invalid resource endpoint    
333
    Log    Trying to perform a GET on a erroneous URI
334
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
335
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
336
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/pm_job    # wrong URI /pm_job instead of /pm_jobs
337
338
339
340
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}

Send Post Request Create new VNF Performance Monitoring Job
341
    Log    Creating a new PM Job
342
343
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Set Headers    {"Content-Type": "${CONTENT_TYPE_JSON}"}
344
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
345
    ${template}=    Get File    jsons/CreatePmJobRequest.json
346
347
348
349
350
351
    ${body}=        Format String   ${template}     objectInstanceIds=${objectInstanceIds}    callback_uri=${callback_uri}    callback_port=${callback_port}    callback_uri=${callback_endpoint} 
    Log  Creating mock request and response to handle GET operation on notification endpoint
    &{notification_request}=  Create Mock Request Matcher	GET  ${callback_endpoint}
    &{notification_response}=  Create Mock Response	status_code=204
    Log    Issue the request
    Create Mock Expectation  ${notification_request}  ${notification_response}
Najam UI Hassan's avatar
Najam UI Hassan committed
352
    POST    ${apiRoot}/${apiName}/${apiMajorVersion}/pm_jobs    ${body}
353
354
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
355
356
    Verify Mock Expectation    ${notification_request}
	Clear Requests    ${callback_endpoint}
357

358
359
360
361
362
363
364
365
366
367
368
369
Send Post Request Create new VNF Performance Monitoring Job with Unprocessable Entity
    Log    Creating a new PM Job
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Set Headers    {"Content-Type": "${CONTENT_TYPE_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
    ${template}=    Get File    jsons/CreatePmJobRequest.json
    ${body}=        Format String   ${template}     objectInstanceIds=${objectInstanceIds}    callback_uri=${callback_uri}    callback_port=${callback_port}    callback_uri=${callback_endpoint} 
    Log  Do not create mock for notification endpoint
    POST    ${apiRoot}/${apiName}/${apiMajorVersion}/pm_jobs    ${body}
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
    
370
Send PUT Request for all VNF Performance Monitoring Jobs 
371
    Log    Trying to perform a PUT. This method should not be implemented
372
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
373
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
374
    PUT    ${apiRoot}/${apiName}/${apiMajorVersion}/pm_jobs
375
376
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
377

378
379
380
Send PATCH Request for all VNF Performance Monitoring Jobs 
    Log    Trying to perform a PUT. This method should not be implemented
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
381
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
382
    PATCH    ${apiRoot}/${apiName}/${apiMajorVersion}/pm_jobs
383
384
385
386
387
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
    
Send DELETE Request for all VNF Performance Monitoring Jobs 
    Log    Trying to perform a PUT. This method should not be implemented
388
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
389
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
390
    PATCH    ${apiRoot}/${apiName}/${apiMajorVersion}/pm_jobs
391
392
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
393

394
395
396
397
398
399
Check Postcondition VNF Performance Monitoring Jobs Exist
    Log    Checking that Pm Job still exists
    GET all VNF Performance Monitoring Jobs
    
Check Postcondition PmJob Exists
    Log    Checking that Pm Job exists
400
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
401
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
402
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/pm_jobs/${response['body']['id']}
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is    PmJob
    
Check HTTP Response Body PmJobs Matches the requested exclude_fields selector
    Log    Checking that reports element is missing
    ${reports}=    Get Value From Json    ${response['body']}    $..reports
    Should Be Empty    ${reports}
    Log    Checking that reports element is missing
    ${criteria}=    Get Value From Json    ${response['body']}    $..criteria
    Should Be Empty    ${criteria}
    Log    Reports element is empty as expected

Check HTTP Response Body PmJobs Matches the requested fields selector
    Log    Trying to validate criteria schema
    ${criteria}=    Get Value From Json    ${response['body']}    $..criteria
420
    Validate Json    criteria.schema.json    ${criteria}
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
    Log    Validation for criteria schema OK
    Log    Trying to validate criteria schema
    ${reports}=    Get Value From Json    ${response['body']}    $..reports
    Validate Json    reports.schema.json    ${reports[0]}
    Log    Validation for reports schema OK
    
Check HTTP Response Body PmJobs Matches the requested exclude_default selector
    Log    Checking that reports element is missing
    ${reports}=    Get Value From Json    ${response['body']}    $..reports
    Should Be Empty    ${reports}
    Log    Reports element is empty as expected

Check HTTP Response Body PmJobs Matches the requested all_fields selector
    Log    Trying to validate criteria schema
    ${criteria}=    Get Value From Json    ${response['body']}    $..criteria
436
    Validate Json    criteria.schema.json    ${criteria}
437
438
439
440
441
442
443
444
445
446
447
448
    Log    Validation for criteria schema OK
    Log    Trying to validate criteria schema
    ${reports}=    Get Value From Json    ${response['body']}    $..reports
    Validate Json    reports.schema.json    ${reports[0]}
    Log    Validation for reports schema OK
    Log    Validating _links schema
    ${links}=    Get Value From Json    ${response['body']}    $.._links
    Validate Json    links.schema.json    ${links[0]}
    Log    Validation for _links schema OK
    
Check HTTP Response Body PmJobs Matches the requested Attribute-Based Filter 
    Log    Checking that attribute-based filter is matched
Elian Kraja's avatar
Elian Kraja committed
449
    @{words} =  Split String    ${POS_FILTER}       ${SEPARATOR} 
Najam UI Hassan's avatar
Najam UI Hassan committed
450
    Should Be Equal As Strings    ${response['body'][0]['objectInstanceIds']}    @{words}[1]
451
452
453
454
455
456
457
458
459
460

Check HTTP Response Body Does Not Contain reports
    Log    Checking that field element is missing
    ${reports}=    Get Value From Json    ${response['body']}    $..reports
    Should Be Empty    ${reports}
    Log    Reports element is empty as expected
    
Check HTTP Response Status Code Is
    [Arguments]    ${expected_status}
    ${status}=    Convert To Integer    ${expected_status}    
461
    Should Be Equal As Strings    ${response['status']}    ${status} 
462
463
464
465
466
    Log    Status code validated
    
Check HTTP Response Status Code Is 40x  
    Should Contain Any    ${response['status']}    401    403
    Log    Status code validated
467

468
469
470
471
472
473
474
475
Check HTTP Response Header Contains
    [Arguments]    ${CONTENT_TYPE}
    Should Contain    ${response['headers']}    ${CONTENT_TYPE}
    Log    Header is present
    
Check HTTP Response Body Json Schema Is
    [Arguments]    ${input}
    Should Contain    ${response['headers']['Content-Type']}    application/json
476
    ${schema} =    Catenate    SEPARATOR=    ${input}    .schema.json
477
478
    Validate Json    ${schema}    ${response['body']}
    Log    Json Schema Validation OK
479
480
    
Check LINK in Header
481
    ${linkURL}=    Get Value From Json    ${response['headers']}    $..Link
482
    Should Not Be Empty    ${linkURL}