ScaleVNFTask.robot 6.56 KB
Newer Older
mengxuan.zhao's avatar
mengxuan.zhao committed
1
*** Settings ***
2
Resource    environment/configuration.txt
3
Resource    environment/variables.txt 
4
Library    REST    ${VNFM_SCHEMA}://${VNFM_HOST}:${VNFM_PORT} 
mengxuan.zhao's avatar
mengxuan.zhao committed
5
Library    OperatingSystem
6
7
Library    JSONLibrary
Library    JSONSchemaLibrary    schemas/
Elian Kraja's avatar
Elian Kraja committed
8
Suite Setup    Check resource existance
mengxuan.zhao's avatar
mengxuan.zhao committed
9
10
11

*** Test Cases ***
Scale a vnfInstance
12
13
    [Documentation]    Instantiate VNF The POST method instantiates a VNF instance.
    Log    Trying to Instantiate a vnf Instance
mengxuan.zhao's avatar
mengxuan.zhao committed
14
15
16
    Set Headers  {"Accept":"${ACCEPT}"}  
    Set Headers  {"Content-Type": "${CONTENT_TYPE}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
Elian Kraja's avatar
Elian Kraja committed
17
    ${body}=    Get File    jsons/scaleVnfRequest.json
mengxuan.zhao's avatar
mengxuan.zhao committed
18
    Post    ${apiRoot}/${apiName}/${apiVersion}/vnf_instances/${vnfInstanceId}/scale    ${body}
mengxuan.zhao's avatar
mengxuan.zhao committed
19
20
    Integer    response status    202
    Log    Status code validated
21
22
23
    ${headers}=    Output    response headers
    Should Contain    ${headers}    Location
    Log    Validation OK
mengxuan.zhao's avatar
mengxuan.zhao committed
24
25

Scale a vnfInstance Conflict (Not-Instantiated)
26
    # TODO: Need to set the pre-condition of the test. VNF instance shall be in INSTANTIATED state
mengxuan.zhao's avatar
mengxuan.zhao committed
27
28
29
    [Documentation]    Conflict. 
    ...    The operation cannot be executed currently, due to a conflict with the state of the VNF instance resource. 
    ...    Typically, this is due to the fact that the VNF instance resource is in NOT-INSTANTIATED state, or that another lifecycle management operation is ongoing. 
Elian Kraja's avatar
Elian Kraja committed
30
    ...    The response body shall contain a ProblemDetails structure, in which the �detail� attribute should convey more information about the error.
mengxuan.zhao's avatar
mengxuan.zhao committed
31
32
33
34
35
    [Setup]    Check resource not instantiated
    Log    Trying to Scale a vnf Instance
    Set Headers  {"Accept":"${ACCEPT}"}  
    Set Headers  {"Content-Type": "${CONTENT_TYPE}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
Elian Kraja's avatar
Elian Kraja committed
36
    ${body}=    Get File    jsons/scaleVnfRequest.json
37
    Post    ${apiRoot}/${apiName}/${apiVersion}/vnf_instances/${notInstantiatedVnfInstanceId}/scale    ${body}
mengxuan.zhao's avatar
mengxuan.zhao committed
38
39
    Integer    response status    409
    Log    Status code validated
40
    ${problemDetails}=    Output    response body
Elian Kraja's avatar
Elian Kraja committed
41
    Validate Json    ProblemDetails.schema.json    ${problemDetails}
42
    Log    Validation OK
mengxuan.zhao's avatar
mengxuan.zhao committed
43
44
45
46
47
48
49

    
Scale a vnfInstance Not Found
    # TODO: Need to create a vnfInstance which's instantiatedVnfInfo.scaleStatus is absent
    [Documentation]    Not Found
    ...    Error: The API producer did not find a current representation for the target resource or is not willing to disclose that one exists. 
    ...    Specifically in case of this task resource, the response code 404 shall also returned if the task is not supported for the VNF instance represented by the parent resource, which means that the task resource consequently does not exist. 
Elian Kraja's avatar
Elian Kraja committed
50
    ...    In this case, the response body shall be present, and shall contain a ProblemDetails structure, in which the �detail� attribute shall convey more information about the error.
mengxuan.zhao's avatar
mengxuan.zhao committed
51
52
53
54
55
    [Setup]    Check scale not supported
    Log    Trying to scale a vnf Instance, not exist
    Set Headers  {"Accept":"${ACCEPT}"}  
    Set Headers  {"Content-Type": "${CONTENT_TYPE}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
Elian Kraja's avatar
Elian Kraja committed
56
    ${body}=    Get File    jsons/scaleVnfRequest.json
mengxuan.zhao's avatar
mengxuan.zhao committed
57
    Post    ${apiRoot}/${apiName}/${apiVersion}/vnf_instances/${vnfInstanceId}/scale    ${body}
mengxuan.zhao's avatar
mengxuan.zhao committed
58
59
    Integer    response status    404
    Log    Status code validated
60
    ${problemDetails}=    Output    response body
Elian Kraja's avatar
Elian Kraja committed
61
    Validate Json    ProblemDetails.schema.json    ${problemDetails}
62
    Log    Validation OK
mengxuan.zhao's avatar
mengxuan.zhao committed
63
   
mengxuan.zhao's avatar
mengxuan.zhao committed
64
GET Scale VNFInstance - Method not implemented
mengxuan.zhao's avatar
mengxuan.zhao committed
65
66
67
68
69
70
    log    Trying to perform a GET. This method should not be implemented
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
    Get    ${apiRoot}/${apiName}/${apiVersion}/vnf_instances/${vnfInstanceId}/scale    
    Log    Validate Status code
    Integer    response status    405

mengxuan.zhao's avatar
mengxuan.zhao committed
71
PUT Scale VNFInstance - Method not implemented
mengxuan.zhao's avatar
mengxuan.zhao committed
72
73
74
75
76
77
    log    Trying to perform a PUT. This method should not be implemented
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
    Put    ${apiRoot}/${apiName}/${apiVersion}/vnf_instances/${vnfInstanceId}/scale    
    Log    Validate Status code
    Integer    response status    405

mengxuan.zhao's avatar
mengxuan.zhao committed
78
PATCH Scale VNFInstance - Method not implemented
mengxuan.zhao's avatar
mengxuan.zhao committed
79
80
81
82
83
84
    log    Trying to perform a PATCH. This method should not be implemented
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
    Patch    ${apiRoot}/${apiName}/${apiVersion}/vnf_instances/${vnfInstanceId}/scale    
    Log    Validate Status code
    Integer    response status    405
    
mengxuan.zhao's avatar
mengxuan.zhao committed
85
DELETE Scale VNFInstance - Method not implemented
mengxuan.zhao's avatar
mengxuan.zhao committed
86
87
88
89
90
91
    log    Trying to perform a DELETE. This method should not be implemented
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
    Delete    ${apiRoot}/${apiName}/${apiVersion}/vnf_instances/${vnfInstanceId}/scale    
    Log    Validate Status code
    Integer    response status    405

92
*** Keywords ***
mengxuan.zhao's avatar
mengxuan.zhao committed
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
Check resource existance
    Set Headers    {"Accept":"${ACCEPT}"}  
    Set Headers    {"Content-Type": "${CONTENT_TYPE}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
    Get    ${apiRoot}/${apiName}/${apiVersion}/vnf_instances/${vnfInstanceId} 
    Integer    response status    200

Check resource not instantiated
    Set Headers    {"Accept":"${ACCEPT}"}  
    Set Headers    {"Content-Type": "${CONTENT_TYPE}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
    Get    ${apiRoot}/${apiName}/${apiVersion}/vnf_instances/${vnfInstanceId} 
    String    response body instantiationState    NOT_INSTANTIATED

Check scale not supported
    Set Headers    {"Accept":"${ACCEPT}"}  
    Set Headers    {"Content-Type": "${CONTENT_TYPE}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
    Get    ${apiRoot}/${apiName}/${apiVersion}/vnf_instances/${vnfInstanceId} 
    Missing    response body instantiatedVnfInfo scaleStatus

Launch another LCM operation
    Set Headers  {"Accept":"${ACCEPT}"}  
    Set Headers  {"Content-Type": "${CONTENT_TYPE}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
Elian Kraja's avatar
Elian Kraja committed
118
    ${body}=    Get File    jsons/scaleVnfToLevelRequest.json
mengxuan.zhao's avatar
mengxuan.zhao committed
119
    Post    ${apiRoot}/${apiName}/${apiVersion}/vnf_instances/${vnfInstanceId}/scale_to_level    ${body}
mengxuan.zhao's avatar
mengxuan.zhao committed
120
    Integer    response status    202