3 Library RequestsLibrary
4 Library OperatingSystem
7 Documentation Test cases for CNF lifecycle management operations
9 ... -package being onboarded in cnf_package_onboarding_tests
12 ${SLEEP_INTERVAL_SEC}= 10
13 ${MAXIMUM_ATTEMPTS_BEFORE_TIMEOUT}= 60 # Represents the maximum number of attempts that will be made before a timeout. It sleeps for SLEEP_INTERVAL_SEC seconds before retry.
14 ${BASIC_AUTH}= Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==
15 ${SERVICE_INSTANTIATION_TEMPLATE}= ${CURDIR}${/}data${/}serviceInstantiationRequest.json
16 ${CNF_RESOURCE_INSTANTIATION_TEMPLATE}= ${CURDIR}${/}data${/}cnfResourceInstantiationRequest.json
17 ${CNF_RESOURCE_DELETE_TEMPLATE}= ${CURDIR}${/}data${/}cnfResourceDeleteRequest.json
18 ${SERVICE_DELETE_TEMPLATE}= ${CURDIR}${/}data${/}serviceDeleteRequest.json
21 Invoke Service Instantiation
22 Create Session api_handler_session http://${REPO_IP}:8080
23 ${data}= Get Binary File ${SERVICE_INSTANTIATION_TEMPLATE}
24 &{headers}= Create Dictionary Authorization=${BASIC_AUTH} Content-Type=application/json Accept=application/json
25 ${service_instantiation_request}= Post On Session api_handler_session /onap/so/infra/serviceInstantiation/v7/serviceInstances data=${data} headers=${headers}
26 Log to Console \nStatus code received: ${service_instantiation_request.status_code}
27 Log to Console Content received: ${service_instantiation_request.content}
28 Should Be Equal As Strings '${service_instantiation_request.status_code}' '202'
30 ${service_instantiation_json_response}= Evaluate json.loads(r"""${service_instantiation_request.content}""", strict=False) json
31 ${request_ID}= Set Variable ${service_instantiation_json_response}[requestReferences][requestId]
32 ${service_instance_Id}= Set Variable ${service_instantiation_json_response}[requestReferences][instanceId]
33 Set Global Variable ${service_instance_Id}
34 ${actual_request_state}= Set Variable ""
36 FOR ${INDEX} IN RANGE ${MAXIMUM_ATTEMPTS_BEFORE_TIMEOUT}
37 ${orchestration_status_request}= Get On Session api_handler_session /onap/so/infra/orchestrationRequests/v7/${request_ID}
38 Log to Console Orchestration status code received: ${orchestration_status_request.status_code}
39 Log to Console Orchestration Content received: ${orchestration_status_request.content}
40 ${orchestration_json_response}= Evaluate json.loads(r"""${orchestration_status_request.content}""", strict=False) json
41 ${actual_request_state}= Set Variable ${orchestration_json_response}[request][requestStatus][requestState]
42 Log To Console Received actual repsonse status:${actual_request_state}
43 Run Keyword If '${actual_request_state}' == 'COMPLETE' or '${actual_request_state}' == 'FAILED' Exit For Loop
44 Log to Console Will try again after ${SLEEP_INTERVAL_SEC} seconds
45 Sleep ${SLEEP_INTERVAL_SEC}s
48 Log To Console Final repsonse status received: ${actual_request_state}
49 Should Be Equal As Strings '${actual_request_state}' 'COMPLETE'
51 Invoke CNF Instantiation
52 Run Keyword If "${service_instance_Id}"!="${EMPTY}" Log to Console Service Instance ID :${service_instance_Id} received
53 ... ELSE Fail Log to Console Invalid Service Instance ID :${service_instance_Id} recieved
55 ${data}= Get Binary File ${CNF_RESOURCE_INSTANTIATION_TEMPLATE}
56 ${cnf_instantiate_request_json}= Evaluate json.loads(r'''${data}''', strict=False) json
57 Set To Dictionary ${cnf_instantiate_request_json}[requestDetails][relatedInstanceList][0][relatedInstance] instanceId=${service_instance_Id}
58 ${cnf_instantiate_request_string}= Evaluate json.dumps(${cnf_instantiate_request_json}) json
60 Create Session api_handler_session http://${REPO_IP}:8080
61 &{headers}= Create Dictionary Authorization=${BASIC_AUTH} Content-Type=application/json Accept=application/json
62 ${cnf_instantiate_request}= Post On Session api_handler_session /onap/so/infra/serviceInstantiation/v7/serviceInstances/${service_instance_Id}/cnfs data=${cnf_instantiate_request_string} headers=${headers}
63 Log to Console \nStatus code received: ${cnf_instantiate_request.status_code}
64 Log to Console Content received: ${cnf_instantiate_request.content}
65 Should Be Equal As Strings '${cnf_instantiate_request.status_code}' '202'
67 ${cnf_instantiate_json_response}= Evaluate json.loads(r"""${cnf_instantiate_request.content}""") json
68 ${request_ID}= Set Variable ${cnf_instantiate_json_response}[requestReferences][requestId]
69 ${actual_request_state}= Set Variable ""
70 ${cnf_instance_Id}= Set Variable ${cnf_instantiate_json_response}[requestReferences][instanceId]
71 SET GLOBAL VARIABLE ${cnf_instance_Id}
73 FOR ${INDEX} IN RANGE ${MAXIMUM_ATTEMPTS_BEFORE_TIMEOUT}
74 ${orchestration_status_request}= Get On Session api_handler_session /onap/so/infra/orchestrationRequests/v7/${request_ID}
75 Run Keyword If '${orchestration_status_request.status_code}' == '200' log to console \nexecuted with expected result
76 Log To Console ${orchestration_status_request.content}
77 ${orchestration_json_response}= Evaluate json.loads(r"""${orchestration_status_request.content}""", strict=False) json
78 ${actual_request_state}= Set Variable ${orchestration_json_response}[request][requestStatus][requestState]
79 Run Keyword If '${actual_request_state}' == 'COMPLETE' or '${actual_request_state}' == 'FAILED' Exit For Loop
80 Log To Console Will try again after ${SLEEP_INTERVAL_SEC} seconds
81 SLEEP ${SLEEP_INTERVAL_SEC}s
84 ${service_instance_Id}= Set Variable ${orchestration_json_response}[request][instanceReferences][serviceInstanceId]
85 Log To Console Final repsonse status received: ${actual_request_state}
86 Should Be Equal As Strings '${actual_request_state}' 'COMPLETE'
89 Run Keyword If "${cnf_instance_Id}" != "${EMPTY}" Log to Console CNF Instance ID :${cnf_instance_Id} received
90 ... ELSE Fail Log to Console Invalid CNF Instance ID :${cnf_instance_Id} recieved
91 Run Keyword If "${service_instance_Id}" != "${EMPTY}" Log to Console CNF Instance ID :${service_instance_Id} received
92 ... ELSE Fail Log to Console Invalid CNF Instance ID :${service_instance_Id} recieved
94 Create Session api_handler_session http://${REPO_IP}:8080
95 ${data}= Get Binary File ${CNF_RESOURCE_DELETE_TEMPLATE}
96 &{headers}= Create Dictionary Authorization=${BASIC_AUTH} Content-Type=application/json Accept=application/json
97 ${cnf_delete_request}= Delete On Session api_handler_session /onap/so/infra/serviceInstantiation/v7/serviceInstances/${service_instance_Id}/cnfs/${cnf_instance_Id} data=${data} headers=${headers}
98 Log to Console \nStatus code received: ${cnf_delete_request.status_code}
99 Log to Console Content received: ${cnf_delete_request.content}
100 Should Be Equal As Strings '${cnf_delete_request.status_code}' '202'
102 ${cnf_delete_json_response}= Evaluate json.loads(r"""${cnf_delete_request.content}""") json
103 ${request_ID}= Set Variable ${cnf_delete_json_response}[requestReferences][requestId]
104 ${actual_request_state}= Set Variable ""
106 FOR ${INDEX} IN RANGE ${MAXIMUM_ATTEMPTS_BEFORE_TIMEOUT}
107 ${orchestration_status_request}= Get On Session api_handler_session /onap/so/infra/orchestrationRequests/v7/${request_ID}
108 Run Keyword If '${orchestration_status_request.status_code}' == '200' log to console \nexecuted with expected result
109 Log To Console ${orchestration_status_request.content}
110 ${orchestration_json_response}= Evaluate json.loads(r"""${orchestration_status_request.content}""") json
111 ${actual_request_state}= Set Variable ${orchestration_json_response}[request][requestStatus][requestState]
112 RUN KEYWORD IF '${actual_request_state}' == 'COMPLETE' or '${actual_request_state}' == 'FAILED' Exit For Loop
113 Log To Console Will try again after ${SLEEP_INTERVAL_SEC} seconds
114 SLEEP ${SLEEP_INTERVAL_SEC}s
117 Log To Console Final repsonse status received: ${actual_request_state}
118 Should Be Equal As Strings '${actual_request_state}' 'COMPLETE'
120 Delete Service Instance
121 Run Keyword If "${service_instance_Id}" != "${EMPTY}" Log to Console CNF Instance ID :${service_instance_Id} received
122 ... ELSE Fail Log to Console Invalid Service Instance ID :${service_instance_Id} recieved
124 Create Session api_handler_session http://${REPO_IP}:8080
125 ${data}= Get Binary File ${SERVICE_DELETE_TEMPLATE}
126 &{headers}= Create Dictionary Authorization=${BASIC_AUTH} Content-Type=application/json Accept=application/json
127 ${service_delete_request}= Delete On Session api_handler_session /onap/so/infra/serviceInstantiation/v7/serviceInstances/${service_instance_Id} data=${data} headers=${headers}
128 ${service_delete_json_response}= Evaluate json.loads(r"""${service_delete_request.content}""") json
129 Log to Console \nStatus code received: ${service_delete_request.status_code}
130 Log to Console Content received: ${service_delete_request.content}
131 Should Be Equal As Strings '${service_delete_request.status_code}' '202'
133 ${request_ID}= Set Variable ${service_delete_json_response}[requestReferences][requestId]
134 ${actual_request_state}= Set Variable ""
136 FOR ${INDEX} IN RANGE ${MAXIMUM_ATTEMPTS_BEFORE_TIMEOUT}
137 ${orchestration_status_request}= Get On Session api_handler_session /onap/so/infra/orchestrationRequests/v7/${request_ID}
138 Run Keyword If '${orchestration_status_request.status_code}' == '200' log to console \nexecuted with expected result
139 Log To Console ${orchestration_status_request.content}
140 ${orchestration_json_response}= Evaluate json.loads(r"""${orchestration_status_request.content}""") json
141 ${actual_request_state}= Set Variable ${orchestration_json_response}[request][requestStatus][requestState]
142 RUN KEYWORD IF '${actual_request_state}' == 'COMPLETE' or '${actual_request_state}' == 'FAILED' Exit For Loop
143 Log To Console Will try again after ${SLEEP_INTERVAL_SEC} seconds
144 SLEEP ${SLEEP_INTERVAL_SEC}s
147 Log To Console Final repsonse status received: ${actual_request_state}
148 Should Be Equal As Strings '${actual_request_state}' 'COMPLETE'