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

*** Test Cases ***
14
15
16
17
18
GET individual VNF Performance Job
    [Documentation]    Test ID: 7.3.4.2.1
    ...    Test title: Get individual VNF Performance Job
    ...    Test objective: The objective is to test the retrieval of an individual VNF performance monitoring job and perform a JSON schema and content validation of the collected job data structure
    ...    Pre-conditions: A VNF instance is instantiated. One or more VNF performance jobs are set in the VNFM.
19
    ...    Reference: Clause 6.4.3.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 individual VNF Performance Job
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is   PmJob
    Check HTTP Response Body Pm Job Identifier matches the requested Pm Job

GET individual VNF Performance Job with invalid resource identifier
    [Documentation]    Test ID: 7.3.4.2.2
    ...    Test title: Get individual VNF Performance Job with invalid resource identifier
    ...    Test objective: The objective is to test that the retrieval of an individual VNF performance monitoring job fails when using an invalid resource identifier, 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 VNFM.
33
    ...    Reference: Clause 6.4.3.3.2 - ETSI GS NFV-SOL 003 [1] v2.8.1
34
35
36
37
38
39
40
41
42
43
44
45
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: none
    GET individual VNF Performance Job with invalid resource identifier
    Check HTTP Response Status Code Is    404
    Check HTTP Response Body Json Schema Is   ProblemDetails

DELETE Individual VNF Performance Job
    [Documentation]    Test ID: 7.3.4.2.3
    ...    Test title: Delete Individual VNF Performance Job
    ...    Test objective: The objective is to test the deletion of an individual VNF performance monitoring job
    ...    Pre-conditions: A VNF instance is instantiated. One or more VNF performance jobs are set in the VNFM.
46
    ...    Reference: Clause 6.4.3.3.5 - ETSI GS NFV-SOL 003 [1] v2.8.1
47
48
49
50
51
52
53
54
55
56
57
58
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: The VNF Performance Job is no more available in the VNFM    
    Send Delete request for individual VNF Performance Job
    Check HTTP Response Status Code Is    204
    Check Postcondition VNF Pm Job is Deleted

DELETE Individual VNF Performance Job with invalid resource identifier
    [Documentation]    Test ID: 7.3.4.2.4
    ...    Test title: Delete individual VNF Performance Job with invalid resource identifier
    ...    Test objective: The objective is to test that the deletion of an individual VNF performance monitoring job fails when using an invalid resource identifier
    ...    Pre-conditions: A VNF instance is instantiated. One or more VNF performance jobs are set in the VNFM.
59
    ...    Reference: Clause 6.4.3.3.5 - ETSI GS NFV-SOL 003 [1] v2.8.1
60
61
62
63
64
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: none
    Send Delete request for individual VNF Performance Job with invalid resource identifier
    Check HTTP Response Status Code Is    404
65
    Check HTTP Response Body Json Schema Is   ProblemDetails
66
67
68
69
70
71

POST Individual VNF Performance Job - Method not implemented
    [Documentation]    Test ID: 7.3.4.2.5
    ...    Test title: POST Individual VNF Performance Job - method not implemented
    ...    Test objective: The objective is to test that POST method is not allowed to create a new VNF Performance Monitoring Job
    ...    Pre-conditions: A VNF instance is instantiated
72
    ...    Reference: Clause 6.4.3.3.1 - ETSI GS NFV-SOL 003 [1] v2.8.1
73
74
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
75
    ...    Post-Conditions: none
76
77
78
79
80
81
82
83
    Send Post request for individual VNF Performance Job
    Check HTTP Response Status Code Is    405

PUT Individual VNF Performance Job - Method not implemented
    [Documentation]    Test ID: 7.3.4.2.6
    ...    Test title: PUT Individual VNF Performance Job - method not implemented
    ...    Test objective: The objective is to test that PUT method is not allowed to update an existing VNF Performance Monitoring Job
    ...    Pre-conditions: A VNF instance is instantiated. One or more VNF performance jobs are set in the VNFM.
84
    ...    Reference: Clause 6.4.3.3.3 - ETSI GS NFV-SOL 003 [1] v2.8.1
85
86
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
87
    ...    Post-Conditions: none
88
89
90
    Send Put request for individual VNF Performance Job
    Check HTTP Response Status Code Is    405

91
PATCH Individual VNF Performance Job
92
    [Documentation]    Test ID: 7.3.4.2.7
93
    ...    Test title: PATCH Individual VNF Performance Job
94
    ...    Test objective: The objective is to test that PATCH method allows to modify individual performace management job
95
    ...    Pre-conditions: A VNF instance is instantiated. One or more VNF performance jobs are set in the VNFM.
96
    ...    Reference: Clause 6.4.3.3.4 - ETSI GS NFV-SOL 003 [1] v2.8.1
97
98
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
99
    ...    Post-Conditions: 
100
    Send Patch request for individual VNF Performance Job
101
102
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is    PMJobModifications
103
    
104
105
106
107
108
PATCH Individual VNF Performance Job - Precondition failed
    [Documentation]    Test ID: 7.3.4.2.8
    ...    Test title: PATCH Individual VNF Performance Job - Precondition failed
    ...    Test objective: The objective is to attempt to Modify an individual alarm resource, where the precondition was not met.
    ...    Pre-conditions:  A VNF instance is instantiated. One or more VNF performance jobs are set in the VNFM.
109
    ...    Reference: Clause 6.4.3.3.4 - ETSI GS NFV-SOL 003 [1] v2.8.1
110
111
112
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions:  The VNF Performance Job is not modified by the operation
113
    Send Patch request for individual VNF Performance Job - Etag mismatch
114
115
    Check HTTP Response Status Code Is    412
    Check HTTP Response Body Json Schema Is   ProblemDetails
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
    Check Postcondition VNF Performance Job is Unmodified (Implicit)
    
PATCH Individual VNF Performance Job with Unprocessable Entity
    [Documentation]    Test ID: 7.3.4.2.9
    ...    Test title: PATCH Individual VNF Performance Job with Unprocessable Entity
    ...    Test objective: The objective is to test that PATCH method to modify individual performace management 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. One or more VNF performance jobs are set in the VNFM.
    ...    Reference: Clause 6.4.3.3.4 - ETSI GS NFV-SOL 003 [1] v2.8.1
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: 
    Send Patch request for individual VNF Performance Job with Unprocessable Entity
    Check HTTP Response Status Code Is    422
    Check HTTP Response Body Json Schema Is   ProblemDetails
  
131
*** Keywords ***
132
133
134
135
136
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}
    
137
GET individual VNF Performance Job
138
    Log    Trying to get a Pm Job present in the NFVO Catalogue
139
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
140
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
141
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/pm_jobs/${pmJobId}
142
143
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
144

145
GET individual VNF Performance Job with invalid resource identifier  
146
    Log    Trying to perform a negative get, using erroneous PM Job identifier
147
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
148
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
149
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/pm_jobs/${erroneousPmJobId}
150
151
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
152

153
Send Delete request for individual VNF Performance Job
154
155
    Log    Trying to delete an existing PM Job
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
156
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
157
    DELETE    ${apiRoot}/${apiName}/${apiMajorVersion}/pm_jobs/${pmJobId}
158
159
160
161
162
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
    
Send Delete request for individual VNF Performance Job with invalid resource identifier
    Log    Trying to perform a negative delete, using erroneous PM Job identifier
163
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
164
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
165
    DELETE    ${apiRoot}/${apiName}/${apiMajorVersion}/pm_jobs/${erroneousPmJobId}
166
167
168
169
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}

Send Post request for individual VNF Performance Job    
170
    Log    Trying to perform a POST (method should not be implemented)
171
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
172
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
173
    POST    ${apiRoot}/${apiName}/${apiMajorVersion}/pm_jobs/${newPmJobId}
174
175
176
177
178
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
    
Send Put request for individual VNF Performance Job    
    Log    Trying to perform a POST (method should not be implemented)
179
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
180
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
181
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/pm_jobs/${pmJobId}
182
183
    ${origOutput}=    Output    response
    Set Suite Variable    ${origResponse}    ${origOutput}
Najam UI Hassan's avatar
Najam UI Hassan committed
184
    PUT    ${apiRoot}/${apiName}/${apiMajorVersion}/pm_jobs/${pmJobId}
185
186
187
188
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
    
Send Patch request for individual VNF Performance Job    
189
190
    Set Headers  {"Accept":"${ACCEPT_JSON}"} 
    Set Headers  {"Content-Type": "${CONTENT_TYPE_JSON}"} 
191
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
192
193
194
195
196
197
198
    ${template}=    Get File    jsons/PMJobModifications.json
    ${body}=        Format String   ${template}     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
199
    PATCH    ${apiRoot}/${apiName}/${apiMajorVersion}/pm_jobs/${pmJobId}     ${body}
200
201
202
203
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
    Verify Mock Expectation    ${notification_request}
	Clear Requests    ${callback_endpoint}
204

205
206
207
208
209
210
211
212
213
214
215
Send Patch request for individual VNF Performance Job - Etag mismatch  
    Set Headers  {"Accept":"${ACCEPT_JSON}"} 
    Set Headers  {"Content-Type": "${CONTENT_TYPE_JSON}"} 
    Set Headers  {"If-Match": "${invalid_etag}"} 
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
    ${template}=    Get File    jsons/PMJobModifications.json
    ${body}=        Format String   ${template}     callback_uri=${callback_uri}    callback_port=${callback_port}    callback_uri=${callback_endpoint} 
    PATCH    ${apiRoot}/${apiName}/${apiMajorVersion}/pm_jobs/${pmJobId}     ${body}
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}

216
217
218
219
220
221
222
223
Send Patch request for individual VNF Performance Job with Unprocessable Entity 
    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/PMJobModifications.json
    ${body}=        Format String   ${template}     callback_uri=${callback_uri}    callback_port=${callback_port}    callback_uri=${callback_endpoint} 
    Log    Do not create any mock for notification endpoint
    PATCH    ${apiRoot}/${apiName}/${apiMajorVersion}/pm_jobs/${pmJobId}     ${body}
224
225
226
227
228
229
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}

Check Postcondition VNF Performance Job is not Created
    Log    Trying to get a new Pm Job
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
230
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
231
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/pm_jobs/${newPmJobId}
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
    Check HTTP Response Status Code Is    404

Check Postcondition VNF Performance Job is Unmodified (Implicit)
    Log    Check Postcondition VNF PM job is not modified
    GET individual VNF Performance Job
    Log    Check Response matches original VNF Pm Job
    ${pmJob}=    evaluate    json.loads('''${response['body']}''')    json
    Should Be Equal    ${origresponse['body']['id']}    ${pmJob.id}
    Should Be Equal    ${origresponse['body']['criteria']}    ${pmJob.criteria}
    Should Be Equal    ${origresponse['body']['_links']}    ${pmJob._links}

Check Postcondition VNF Pm Job is Deleted
    Log    Check Postcondition
    GET individual VNF Performance Job
    Check HTTP Response Status Code Is    404

Check HTTP Response Body Pm Job Identifier matches the requested Pm Job
    Log    Going to validate Pm Job info retrieved
    Should Be Equal    ${response['body']['id']}    ${pmJobId} 
    Log    Pm Job identifier as expected
    
Check HTTP Response Status Code Is
    [Arguments]    ${expected_status}
    ${status}=    Convert To Integer    ${expected_status}    
258
    Should Be Equal As Strings    ${response['status']}    ${status} 
259
    Log    Status code validated
260

261
262
263
264
265
266
267
268
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
269
    ${schema} =    Catenate    SEPARATOR=    ${input}	.schema.json
270
271
    Validate Json    ${schema}    ${response['body']}
    Log    Json Schema Validation OK