3 Library RequestsLibrary
4 Library OperatingSystem
6 Documentation Test cases for onboarding and distributing a VNF package
7 ... Note: onboarded VNF package is used in later VNF tests including:
8 ... -etsi_vnf_lcm_tests.robot
9 ... -etsi_vnf_package_management_tests.robot
10 ... -etsi_vnf_notification_tests.robot
13 ${SLEEP_INTERVAL_SEC}= 5
14 ${MAXIMUM_ATTEMPTS_BEFORE_TIMEOUT}= 48 # Represents the maximum number of attempts that will be made before a timeout. It sleeps for SLEEP_INTERVAL_SEC seconds before retry.
17 OnBoard VNF Package In Etsi Catalog
18 Create Session etsi_catalog_session http://${REPO_IP}:8806
19 ${data}= Get Binary File ${CURDIR}${/}data${/}vnfPackageOnboardRequest.json
20 &{headers}= Create Dictionary Content-Type=application/json Accept=application/json
21 ${resp}= Post On Session etsi_catalog_session /api/catalog/v1/vnfpackages data=${data} headers=${headers}
22 Run Keyword If '${resp.status_code}' == '202' log to console \nexecuted with expected result
23 Should Be Equal As Strings '${resp.status_code}' '202'
24 log to console ${resp.content}
25 ${onboarding_job_json_response}= Evaluate json.loads(r"""${resp.content}""", strict=False) json
26 ${job_ID}= Set Variable ${onboarding_job_json_response}[jobId]
27 Should Not Be Empty ${job_ID}
28 ${actual_job_status}= Set Variable ""
30 FOR ${INDEX} IN RANGE ${MAXIMUM_ATTEMPTS_BEFORE_TIMEOUT}
31 ${onboarding_job_status_request}= Get On Session etsi_catalog_session /api/catalog/v1/jobs/${job_ID}
32 Run Keyword If '${onboarding_job_status_request.status_code}' == '200' log to console \nexecuted with expected result
33 log to console ${onboarding_job_status_request.content}
35 ${onboarding_job_status_json_response}= Evaluate json.loads(r"""${onboarding_job_status_request.content}""", strict=False) json
37 ${actual_job_status}= Set Variable ""
39 ${response_descriptor_exists}= Run Keyword And Return Status Get From Dictionary ${onboarding_job_status_json_response} responseDescriptor
40 ${status_exists}= Run Keyword And Return Status Get From Dictionary ${onboarding_job_status_json_response}[responseDescriptor] status
42 ${actual_job_status}= Set Variable If ${response_descriptor_exists} == True and ${status_exists} == True
43 ... ${onboarding_job_status_json_response}[responseDescriptor][status]
45 Log To Console Received actual repsonse status:${actual_job_status}
46 Run Keyword If '${actual_job_status}' == 'finished' or '${actual_job_status}' == 'error' or '${actual_job_status}' == 'timeout' Exit For Loop
47 log to console Will try again after ${SLEEP_INTERVAL_SEC} seconds
48 SLEEP ${SLEEP_INTERVAL_SEC}
50 Log To Console final repsonse status received: ${actual_job_status}
51 Run Keyword If '${actual_job_status}' == 'finished' log to console \nexecuted with expected result
52 Should Be Equal As Strings '${actual_job_status}' 'finished'
54 Onboard Network Service Package In Etsi Catalog
55 Create Session etsi_catalog_session http://${REPO_IP}:8806
56 ${data}= Get Binary File ${CURDIR}${/}data${/}networkServicePackageOnboardRequest.json
57 &{headers}= Create Dictionary Content-Type=application/json Accept=application/json
58 ${resp}= POST On Session etsi_catalog_session /api/catalog/v1/nspackages data=${data} headers=${headers}
59 log to console ${resp.content}
61 Run Keyword If '${resp.status_code}' == '202' log to console \nexecuted with expected result
62 Should Be Equal As Strings '${resp.status_code}' '202'
65 Distribute Service Template
66 Create Session sdc_controller_session http://${REPO_IP}:8085
67 ${data}= Get Binary File ${CURDIR}${/}data${/}distributeServiceTemplate.json
68 &{headers}= Create Dictionary Authorization=Basic bXNvX2FkbWluOnBhc3N3b3JkMSQ= resource-location=/distribution-test-zip/unzipped/ Content-Type=application/json Accept=application/json
69 ${resp}= Post On Session sdc_controller_session /test/treatNotification/v1 data=${data} headers=${headers}
70 Run Keyword If '${resp.status_code}' == '200' log to console \nexecuted with expected result
71 Should Be Equal As Strings '${resp.status_code}' '200'