3 Library RequestsLibrary
4 Library OperatingSystem
7 Documentation Test cases for VNF package management operations including get packages, package, content and artifacts
9 ... -package being onboarded in etsi_package_onboarding_tests
12 ${VNF_PACKAGE_ID}= 73522444-e8e9-49c1-be29-d355800aa349
13 ${PACKAGE_MANAGEMENT_BASE_URL}= /so/vnfm-adapter/v1/vnfpkgm/v1
14 ${BASIC_AUTH}= Basic dm5mbTpwYXNzd29yZDEk
15 ${TEST_DIR}= CSIT_ETSI_TEMP
19 Create Session so_vnfm_adapter_session http://${REPO_IP}:9092
20 &{headers}= Create Dictionary Authorization=${BASIC_AUTH} Content-Type=application/json Accept=application/json
21 Log To Console \nGetting VNF Packages from so-vnfm-adapter
22 ${response}= Get On Session so_vnfm_adapter_session ${PACKAGE_MANAGEMENT_BASE_URL}/vnf_packages headers=${headers}
23 Log To Console \nResponse:${response}
24 Run Keyword If '${response.status_code}' == '200' Log To Console \nexecuted with expected result
25 Should Be Equal As Strings '${response.status_code}' '200'
26 Log To Console \nResponse Content:\n${response.content}
27 ${json_response} Evaluate json.loads(r"""${response.content}""", strict=False) json
28 ${vnf_package_id}= Set Variable ${json_response}[0][id]
29 Should Be Equal As Strings '${vnf_package_id}' '${VNF_PACKAGE_ID}'
30 ${expected}= Get File ${CURDIR}${/}data${/}responses${/}expectedVnfPackage.json
31 ${expected}= Evaluate json.loads(r"""${expected}""", strict=False) json
32 Should Be Equal ${json_response[0]} ${expected}
33 Log To Console \nexecuted with expected result
35 Get VNF Package By VNF Package Id
36 Create Session so_vnfm_adapter_session http://${REPO_IP}:9092
37 &{headers}= Create Dictionary Authorization=${BASIC_AUTH} Content-Type=application/json Accept=application/json
38 Log To Console \nGetting VNF Package with id ${VNF_PACKAGE_ID} from so-vnfm-adapter
39 ${response}= Get On Session so_vnfm_adapter_session ${PACKAGE_MANAGEMENT_BASE_URL}/vnf_packages/${VNF_PACKAGE_ID} headers=${headers}
40 Log To Console \nResponse:${response}
41 Run Keyword If '${response.status_code}' == '200' Log To Console \nexecuted with expected result
42 Should Be Equal As Strings '${response.status_code}' '200'
43 Log To Console \nResponse:\n${response.content}
44 ${json_response} Evaluate json.loads(r"""${response.content}""", strict=False) json
45 ${vnf_package_id}= Set Variable ${json_response}[id]
46 Should Be Equal As Strings '${vnf_package_id}' '${VNF_PACKAGE_ID}'
47 ${expected}= Get File ${CURDIR}${/}data${/}responses${/}expectedVnfPackage.json
48 ${expected}= Evaluate json.loads(r"""${expected}""", strict=False) json
49 Should Be Equal ${json_response} ${expected}
50 Log To Console \nexecuted with expected result
52 Get VNF Package Content
53 Create Session so_vnfm_adapter_session http://${REPO_IP}:9092
54 &{headers}= Create Dictionary Authorization=${BASIC_AUTH} Content-Type=application/json Accept=application/zip
55 Log to Console \nGetting Vnf Package Content from Vnf Package with id ${vnf_package_id} from so-vnfm-adapter
56 ${response}= Get On Session so_vnfm_adapter_session ${PACKAGE_MANAGEMENT_BASE_URL}/vnf_packages/${vnf_package_id}/package_content headers=${headers}
57 Log To Console Response:${response}
58 Run Keyword If '${response.status_code}' == '200' Log To Console \nexecuted with expected result
59 Should Be Equal As Strings '${response.status_code}' '200'
60 Create Directory ${TEMPDIR}${/}${TEST_DIR}
61 Empty Directory ${TEMPDIR}${/}${TEST_DIR}
62 Create Binary File ${TEMPDIR}${/}${TEST_DIR}${/}actualVnfPackageContent.csar ${response.content}
63 Should Be Equal File Size ${TEMPDIR}${/}${TEST_DIR}${/}actualVnfPackageContent.csar ${CURDIR}${/}data${/}responses${/}expectedVnfPackageContent.csar
64 Extract Zip File ${TEMPDIR}${/}${TEST_DIR}${/}actualVnfPackageContent.csar ${TEMPDIR}${/}${TEST_DIR}/actualContent
65 Extract Zip File ${CURDIR}${/}data${/}responses${/}expectedVnfPackageContent.csar ${TEMPDIR}${/}${TEST_DIR}${/}expectedContent
66 Should Contain Same Content ${TEMPDIR}${/}${TEST_DIR}${/}actualContent ${TEMPDIR}${/}${TEST_DIR}${/}expectedContent
67 File Should Exist ${TEMPDIR}${/}${TEST_DIR}${/}actualContent${/}Definitions${/}MainServiceTemplate.yaml
68 File Should Exist ${TEMPDIR}${/}${TEST_DIR}${/}actualContent${/}Definitions${/}onap_dm.yaml
69 File Should Exist ${TEMPDIR}${/}${TEST_DIR}${/}actualContent${/}TOSCA-Metadata${/}TOSCA.meta
70 ${expectedMainServiceTemplate}= Get Binary File ${TEMPDIR}${/}${TEST_DIR}${/}expectedContent${/}Definitions${/}MainServiceTemplate.yaml
71 ${actualMainServiceTemplate}= Get Binary File ${TEMPDIR}${/}${TEST_DIR}${/}actualContent${/}Definitions${/}MainServiceTemplate.yaml
72 Should Be Equal As Strings ${expectedMainServiceTemplate} ${actualMainServiceTemplate}
73 ${expectedOnapDm}= Get Binary File ${TEMPDIR}${/}${TEST_DIR}${/}expectedContent${/}Definitions${/}onap_dm.yaml
74 ${actualOnapDm}= Get Binary File ${TEMPDIR}${/}${TEST_DIR}${/}actualContent${/}Definitions${/}onap_dm.yaml
75 Should Be Equal As Strings ${expectedOnapDm} ${actualOnapDm}
76 ${expectedToscaMeta}= Get Binary File ${TEMPDIR}${/}${TEST_DIR}${/}expectedContent${/}TOSCA-Metadata${/}TOSCA.meta
77 ${actualToscaMeta}= Get Binary File ${TEMPDIR}${/}${TEST_DIR}${/}actualContent${/}TOSCA-Metadata${/}TOSCA.meta
78 Should Be Equal As Strings ${expectedOnapDm} ${actualOnapDm}
79 Remove Directory ${TEMPDIR}${/}${TEST_DIR} recursive=True
80 Log To Console \nexecuted with expected result
83 Create Session so_vnfm_adapter_session http://${REPO_IP}:9092
84 &{headers}= Create Dictionary Authorization=${BASIC_AUTH} Content-Type=application/json Accept=application/zip
85 Log to Console \nGetting Vnfd from Vnf Package with id ${vnf_package_id} from so-vnfm-adapter
86 ${response}= Get On Session so_vnfm_adapter_session ${PACKAGE_MANAGEMENT_BASE_URL}/vnf_packages/${vnf_package_id}/vnfd headers=${headers}
87 Log To Console Response:${response}
88 Run Keyword If '${response.status_code}' == '200' Log To Console \nexecuted with expected result
89 Should Be Equal As Strings '${response.status_code}' '200'
90 Create Directory ${TEMPDIR}${/}${TEST_DIR}
91 Empty Directory ${TEMPDIR}${/}${TEST_DIR}
92 Create Binary File ${TEMPDIR}${/}${TEST_DIR}${/}actualVnfd.zip ${response.content}
93 Extract Zip File ${TEMPDIR}${/}${TEST_DIR}${/}actualVnfd.zip ${TEMPDIR}${/}${TEST_DIR}
94 File Should Exist ${TEMPDIR}${/}${TEST_DIR}${/}MainServiceTemplate.yaml
95 File Should Exist ${TEMPDIR}${/}${TEST_DIR}${/}onap_dm.yaml
96 ${expectedMainServiceTemplate}= Get Binary File ${CURDIR}${/}data${/}responses${/}expectedVnfd${/}MainServiceTemplate.yaml
97 ${actualMainServiceTemplate}= Get Binary File ${TEMPDIR}${/}${TEST_DIR}${/}MainServiceTemplate.yaml
98 Should Be Equal As Strings ${expectedMainServiceTemplate} ${actualMainServiceTemplate}
99 ${expectedOnapDm}= Get Binary File ${CURDIR}${/}data${/}responses${/}expectedVnfd${/}onap_dm.yaml
100 ${actualOnapDm}= Get Binary File ${TEMPDIR}${/}${TEST_DIR}${/}onap_dm.yaml
101 Should Be Equal As Strings ${expectedOnapDm} ${actualOnapDm}
102 Remove Directory ${TEMPDIR}${/}${TEST_DIR} recursive=True
103 Log To Console \nexecuted with expected result
105 Get A VNF Package Artifact
106 ${artifactPath}= Convert To String image
107 Create Session so_vnfm_adapter_session http://${REPO_IP}:9092
108 &{headers}= Create Dictionary Authorization=${BASIC_AUTH} Content-Type=application/json Accept=application/octet-stream
109 Log to Console \nGetting ${artifactPath} artifact from Vnf Package with id ${vnf_package_id} from so-vnfm-adapter
110 ${response}= Get On Session so_vnfm_adapter_session ${PACKAGE_MANAGEMENT_BASE_URL}/vnf_packages/${vnf_package_id}/artifacts/${artifactPath} headers=${headers}
111 Log To Console Response:${response}
112 Run Keyword If '${response.status_code}' == '200' Log To Console \nexecuted with expected result
113 Should Be Equal As Strings '${response.status_code}' '200'
114 Create Directory ${TEMPDIR}${/}${TEST_DIR}
115 Empty Directory ${TEMPDIR}${/}${TEST_DIR}
116 Create Binary File ${TEMPDIR}${/}${TEST_DIR}${/}${artifactPath} ${response.content}
117 ${expectedArtifact}= Get Binary File ${CURDIR}${/}data${/}responses${/}expectedArtifacts${/}${artifactPath}
118 ${actualArtifact}= Get Binary File ${TEMPDIR}${/}${TEST_DIR}${/}${artifactPath}
119 Should Be Equal As Strings ${expectedArtifact} ${actualArtifact}
120 Remove Directory ${TEMPDIR}${/}${TEST_DIR} recursive=True
121 Log To Console \nexecuted with expected result
124 Should Be Equal File Size
125 [Arguments] ${file1} ${file2}
126 Log To Console \nComparing file sizes between ${file1} and ${file2}
127 ${file1size}= Get File Size ${file1}
128 ${file2size}= Get File Size ${file2}
129 Should Be Equal ${file1size} ${file2size}
130 Log To Console Files are the same size
132 Should Contain Same Content
133 [Arguments] ${dir1} ${dir2}
134 Log To Console \nComparing directory contents between:
135 Log To Console Directory 1: ${dir1}
136 Log To Console Directory 2: ${dir2}
137 @{dir1files}= List Files In Directory ${dir1}
138 Log To Console Files in directory 1: @{dir1files}
139 @{dir2files}= List Files In Directory ${dir2}
140 Log To Console Files in directory 2: @{dir2files}
141 Lists Should Be Equal ${dir1files} ${dir2files}
142 FOR ${file} IN @{dir1files}
143 Should Be Equal File Size ${dir1}${/}${file} ${dir2}${/}${file}
145 @{dir1directories}= List Directories In Directory ${dir1}
146 Log To Console Directories in directory 1: ${dir1directories}
147 @{dir2directories}= List Directories In Directory ${dir2}
148 Log To Console Directories in directory 2: ${dir2directories}
149 Lists Should Be Equal ${dir1directories} ${dir2directories}
150 FOR ${directory} IN @{dir1directories}
151 Should Contain Same Content ${dir1}${/}${directory} ${dir2}${/}${directory}
153 Log To Console executed with expected result