IndividualThreshold.robot 13.8 KB
Newer Older
1
2
*** Settings ***
Library           JSONSchemaLibrary    schemas/
3
Resource          environment/variables.txt    # Generic Parameters
4
Library           JSONLibrary
Elian Kraja's avatar
Elian Kraja committed
5
Library           REST    ${VNFM_SCHEMA}://${VNFM_HOST}:${VNFM_PORT}    ssl_verify=false
6
Library           OperatingSystem
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
14

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

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

DELETE Individual Threshold
    [Documentation]    Test ID: 7.3.4.5.3
    ...    Test title: DELETE Individual Threshold
    ...    Test objective: The objective is to test the deletion of an individual VNF performance threshold
    ...    Pre-conditions: A VNF instance is instantiated. One or more VNF performance thresholds are set in the VNFM.
46
    ...    Reference: Clause 6.4.6.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 Threshold is not available anymore in the VNFM    
    Send Delete request for individual VNF Performance Threshold
    Check HTTP Response Status Code Is    204
    Check Postcondition VNF Performance Threshold is Deleted

DELETE Individual Threshold with invalid resource identifier
    [Documentation]    Test ID: 7.3.4.5.4
    ...    Test title: DELETE Individual Threshold with invalid resource identifier
    ...    Test objective: The objective is to test the deletion of an individual VNF performance threshold
    ...    Pre-conditions: A VNF instance is instantiated. One or more VNF performance thresholds are set in the VNFM.
59
    ...    Reference: Clause 6.4.6.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 Threshold 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 Threshold - Method not implemented
    [Documentation]    Test ID: 7.3.4.5.5
    ...    Test title: POST Individual Threshold - Method not implemented
    ...    Test objective: The objective is to test that POST method is not allowed to create a new VNF Performance Threshold
    ...    Pre-conditions: A VNF instance is instantiated
72
    ...    Reference: Clause 6.4.6.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 Threshold
    Check HTTP Response Status Code Is    405

PUT Individual Threshold - Method not implemented
    [Documentation]    Test ID: 7.3.4.5.6
    ...    Test title: PUT Individual Threshold - Method not implemented
    ...    Test objective: The objective is to test that PUT method is not allowed to update an existing VNF Performance threshold
    ...    Pre-conditions: A VNF instance is instantiated. One or more VNF performance thresholds are set in the VNFM.
84
    ...    Reference: Clause 6.4.6.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 Threshold
    Check HTTP Response Status Code Is    405

91
PATCH Individual Threshold
92
    [Documentation]    Test ID: 7.3.4.5.7
93
94
    ...    Test title: PATCH Individual Threshold
    ...    Test objective: The objective is to test that PATCH method allows to modify an Individual threshold resource.
95
    ...    Pre-conditions: A VNF instance is instantiated. One or more VNF performance thresholds are set in the VNFM.
96
    ...    Reference: Clause 6.4.6.3.4 - ETSI GS NFV-SOL 003 [1] v2.8.1
97
98
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
99
    ...    Post-Conditions: none
100
    Send Patch request for individual VNF Performance Threshold
101
102
103
104
105
106
107
108
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is    ThresholdModifications
    
PATCH Individual Threshold - Precondition failed
    [Documentation]    Test ID: 7.3.4.5.8
    ...    Test title: PATCH Individual Threshold - Preconition failed
    ...    Test objective: The objective is to attempt to modify an individual threshold 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.6.3.4 - ETSI GS NFV-SOL 003 [1] v2.8.1
110
111
112
113
114
115
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions:  The VNF Performance Job is not modified by the operation
    Send Patch request for individual VNF Performance Threshold
    Check HTTP Response Status Code Is    412
    Check HTTP Response Body Json Schema Is   ProblemDetails
116
    Check Postcondition VNF Performance Threshold is Unmodified (Implicit)
117
118
119
120
121
122
123
124
125
126
127
128
129
130

PATCH Individual Threshold with Unprocessable Entity
    [Documentation]    Test ID: 7.3.4.5.9
    ...    Test title: PATCH Individual Threshold with Unprocessable Entity
    ...    Test objective: The objective is to test that PATCH method to modify an Individual threshold resource 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 thresholds are set in the VNFM.
    ...    Reference: Clause 6.4.6.3.4 - ETSI GS NFV-SOL 003 [1] v2.8.1
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: none
    Send Patch request for individual VNF Performance Threshold 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
138
GET Individual VNF Performance Threshold
    Log    Trying to get a Threhsold present in the VNFM
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}/thresholds/${thresholdId}
142
    ${output}=    Output    response
143
    Set Suite Variable    ${response}    ${output}
144
145
146

GET individual VNF Performance Threshold with invalid resource identifier
    Log    Trying to get a Threhsold with invalid resource endpoint
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}/thresholds/${erroneousThresholdId}
150
    ${output}=    Output    response
151
    Set Suite Variable    ${response}    ${output}
152

153
154
Send Delete request for individual VNF Performance Threshold
    Log    Trying to delete a Threhsold in the VNFM
155
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
156
    DELETE    ${apiRoot}/${apiName}/${apiMajorVersion}/thresholds/${thresholdId}
157
    ${output}=    Output    response
158
    Set Suite Variable    ${response}    ${output}
159
160
161

Send Delete request for individual VNF Performance Threshold with invalid resource identifier
    Log    Trying to delete a Threhsold in the VNFM with invalid id
162
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
163
    DELETE    ${apiRoot}/${apiName}/${apiMajorVersion}/thresholds/${erroneousThresholdId}
164
    ${output}=    Output    response
165
    Set Suite Variable    ${response}    ${output}
166
167
168

Send Post request for individual VNF Performance Threshold
    Log    Trying to create new threshold
169
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
170
    POST    ${apiRoot}/${apiName}/${apiMajorVersion}/thresholds/${newThresholdId}
171
    ${output}=    Output    response
172
    Set Suite Variable    ${response}    ${output}
173

174
175
176
Send Put request for individual VNF Performance Threshold
    Log    Trying to PUT threshold
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
177
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
178
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/thresholds/${thresholdId}
179
180
    ${origOutput}=    Output    response
    Set Suite Variable    ${origResponse}    ${origOutput}
Najam UI Hassan's avatar
Najam UI Hassan committed
181
    PUT    ${apiRoot}/${apiName}/${apiMajorVersion}/thresholds/${thresholdId}
182
    ${output}=    Output    response
183
    Set Suite Variable    ${response}    ${output}
184

185
186
Send Patch request for individual VNF Performance Threshold
    Log    Trying to PUT threshold
187
188
    Set Headers  {"Accept":"${ACCEPT_JSON}"} 
    Set Headers  {"Content-Type": "${CONTENT_TYPE_JSON}"} 
189
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
    ${template}=    Get File    jsons/ThresholdModifications.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}    
    PATCH    ${apiRoot}/${apiName}/${apiMajorVersion}/thresholds/${thresholdId}
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
    Verify Mock Expectation    ${notification_request}
	Clear Requests    ${callback_endpoint}

Send Patch request for individual VNF Performance Threshold with Unprocessable Entity
    Log    Trying to PUT threshold
    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/ThresholdModifications.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    
Najam UI Hassan's avatar
Najam UI Hassan committed
211
    PATCH    ${apiRoot}/${apiName}/${apiMajorVersion}/thresholds/${thresholdId}
212
    ${output}=    Output    response
213
    Set Suite Variable    ${response}    ${output}
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237

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

Check Postcondition VNF Performance Threshold is Deleted
    Log    Check Postcondition Threshold is deleted
    GET individual VNF Performance Threshold
    Check HTTP Response Status Code Is    404
    
Check HTTP Response Body Threshold Identifier matches the requested Threshold
    Log    Trying to check response ID
    Should Be Equal    ${response['body']['id']}    ${thresholdId} 
    Log    Pm Job identifier as expected
    
Check HTTP Response Status Code Is
    [Arguments]    ${expected_status}
    ${status}=    Convert To Integer    ${expected_status}    
    Should Be Equal    ${response['status']}    ${status} 
    Log    Status code validated
238

239
240
241
242
243
244
245
246
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
247
    ${schema} =    Catenate    SEPARATOR=    ${input}    .schema.json
248
249
    Validate Json    ${schema}    ${response['body']}
    Log    Json Schema Validation OK