aboutsummaryrefslogtreecommitdiffstats
path: root/tests/so/etsi/etsi_vnf_package_management_tests.robot
blob: 000148f8b749e0da19af9add15db1a047d57d599 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
*** Settings ***
Library     Collections
Library     RequestsLibrary
Library     OperatingSystem
Library     json
Library     ArchiveLibrary
Documentation    Test cases for VNF package management operations including get packages, package, content and artifacts
...              Note, relies on:
...                -package being onboarded in etsi_package_onboarding_tests

*** Variables ***
${VNF_PACKAGE_ID}=    73522444-e8e9-49c1-be29-d355800aa349
${PACKAGE_MANAGEMENT_BASE_URL}=    /so/vnfm-adapter/v1/vnfpkgm/v1
${BASIC_AUTH}=    Basic dm5mbTpwYXNzd29yZDEk
${TEST_DIR}=    CSIT_ETSI_TEMP

*** Test Cases ***
Get VNF Packages
    Create Session    so_vnfm_adapter_session    http://${REPO_IP}:9092
    &{headers}=    Create Dictionary    Authorization=${BASIC_AUTH}    Content-Type=application/json    Accept=application/json
    Log To Console    \nGetting VNF Packages from so-vnfm-adapter
    ${response}=    Get On Session    so_vnfm_adapter_session    ${PACKAGE_MANAGEMENT_BASE_URL}/vnf_packages    headers=${headers}
    Log To Console    \nResponse:${response}
    Run Keyword If    '${response.status_code}' == '200'    Log To Console    \nexecuted with expected result
    Should Be Equal As Strings    '${response.status_code}'    '200'
    Log To Console    \nResponse Content:\n${response.content}
    ${json_response}    Evaluate    json.loads(r"""${response.content}""", strict=False)    json
    ${vnf_package_id}=    Set Variable    ${json_response}[0][id]
    Should Be Equal As Strings    '${vnf_package_id}'    '${VNF_PACKAGE_ID}'
    ${expected}=    Get File    ${CURDIR}${/}data${/}responses${/}expectedVnfPackage.json
    ${expected}=    Evaluate    json.loads(r"""${expected}""", strict=False)    json
    Should Be Equal    ${json_response[0]}    ${expected}
    Log To Console    \nexecuted with expected result

Get VNF Package By VNF Package Id
    Create Session    so_vnfm_adapter_session    http://${REPO_IP}:9092
    &{headers}=    Create Dictionary    Authorization=${BASIC_AUTH}    Content-Type=application/json    Accept=application/json
    Log To Console    \nGetting VNF Package with id ${VNF_PACKAGE_ID} from so-vnfm-adapter
    ${response}=    Get On Session    so_vnfm_adapter_session    ${PACKAGE_MANAGEMENT_BASE_URL}/vnf_packages/${VNF_PACKAGE_ID}    headers=${headers}
    Log To Console    \nResponse:${response}
    Run Keyword If    '${response.status_code}' == '200'    Log To Console    \nexecuted with expected result
    Should Be Equal As Strings    '${response.status_code}'    '200'
    Log To Console    \nResponse:\n${response.content}
    ${json_response}    Evaluate    json.loads(r"""${response.content}""", strict=False)    json
    ${vnf_package_id}=    Set Variable    ${json_response}[id]
    Should Be Equal As Strings    '${vnf_package_id}'    '${VNF_PACKAGE_ID}'
    ${expected}=    Get File    ${CURDIR}${/}data${/}responses${/}expectedVnfPackage.json
    ${expected}=    Evaluate    json.loads(r"""${expected}""", strict=False)    json
    Should Be Equal    ${json_response}    ${expected}
    Log To Console    \nexecuted with expected result

Get VNF Package Content
    Create Session    so_vnfm_adapter_session    http://${REPO_IP}:9092
    &{headers}=    Create Dictionary    Authorization=${BASIC_AUTH}    Content-Type=application/json    Accept=application/zip
    Log to Console    \nGetting Vnf Package Content from Vnf Package with id ${vnf_package_id} from so-vnfm-adapter
    ${response}=    Get On Session    so_vnfm_adapter_session    ${PACKAGE_MANAGEMENT_BASE_URL}/vnf_packages/${vnf_package_id}/package_content    headers=${headers}
    Log To Console    Response:${response}
    Run Keyword If    '${response.status_code}' == '200'    Log To Console    \nexecuted with expected result
    Should Be Equal As Strings    '${response.status_code}'    '200'
    Create Directory    ${TEMPDIR}${/}${TEST_DIR}
    Empty Directory    ${TEMPDIR}${/}${TEST_DIR}
    Create Binary File    ${TEMPDIR}${/}${TEST_DIR}${/}actualVnfPackageContent.csar    ${response.content}
    Should Be Equal File Size    ${TEMPDIR}${/}${TEST_DIR}${/}actualVnfPackageContent.csar    ${CURDIR}${/}data${/}responses${/}expectedVnfPackageContent.csar
    Extract Zip File    ${TEMPDIR}${/}${TEST_DIR}${/}actualVnfPackageContent.csar    ${TEMPDIR}${/}${TEST_DIR}/actualContent
    Extract Zip File    ${CURDIR}${/}data${/}responses${/}expectedVnfPackageContent.csar    ${TEMPDIR}${/}${TEST_DIR}${/}expectedContent
    Should Contain Same Content    ${TEMPDIR}${/}${TEST_DIR}${/}actualContent    ${TEMPDIR}${/}${TEST_DIR}${/}expectedContent
    File Should Exist    ${TEMPDIR}${/}${TEST_DIR}${/}actualContent${/}Definitions${/}MainServiceTemplate.yaml
    File Should Exist    ${TEMPDIR}${/}${TEST_DIR}${/}actualContent${/}Definitions${/}onap_dm.yaml
    File Should Exist    ${TEMPDIR}${/}${TEST_DIR}${/}actualContent${/}TOSCA-Metadata${/}TOSCA.meta
    ${expectedMainServiceTemplate}=    Get Binary File    ${TEMPDIR}${/}${TEST_DIR}${/}expectedContent${/}Definitions${/}MainServiceTemplate.yaml
    ${actualMainServiceTemplate}=    Get Binary File    ${TEMPDIR}${/}${TEST_DIR}${/}actualContent${/}Definitions${/}MainServiceTemplate.yaml
    Should Be Equal As Strings    ${expectedMainServiceTemplate}    ${actualMainServiceTemplate}
    ${expectedOnapDm}=    Get Binary File    ${TEMPDIR}${/}${TEST_DIR}${/}expectedContent${/}Definitions${/}onap_dm.yaml
    ${actualOnapDm}=    Get Binary File    ${TEMPDIR}${/}${TEST_DIR}${/}actualContent${/}Definitions${/}onap_dm.yaml
    Should Be Equal As Strings    ${expectedOnapDm}    ${actualOnapDm}
    ${expectedToscaMeta}=    Get Binary File    ${TEMPDIR}${/}${TEST_DIR}${/}expectedContent${/}TOSCA-Metadata${/}TOSCA.meta
    ${actualToscaMeta}=    Get Binary File    ${TEMPDIR}${/}${TEST_DIR}${/}actualContent${/}TOSCA-Metadata${/}TOSCA.meta
    Should Be Equal As Strings    ${expectedOnapDm}    ${actualOnapDm}
    Remove Directory    ${TEMPDIR}${/}${TEST_DIR}    recursive=True
    Log To Console    \nexecuted with expected result

Get VNF Package VNFD
    Create Session    so_vnfm_adapter_session    http://${REPO_IP}:9092
    &{headers}=    Create Dictionary    Authorization=${BASIC_AUTH}    Content-Type=application/json    Accept=application/zip
    Log to Console    \nGetting Vnfd from Vnf Package with id ${vnf_package_id} from so-vnfm-adapter
    ${response}=    Get On Session    so_vnfm_adapter_session    ${PACKAGE_MANAGEMENT_BASE_URL}/vnf_packages/${vnf_package_id}/vnfd    headers=${headers}
    Log To Console    Response:${response}
    Run Keyword If    '${response.status_code}' == '200'    Log To Console    \nexecuted with expected result
    Should Be Equal As Strings    '${response.status_code}'    '200'
    Create Directory    ${TEMPDIR}${/}${TEST_DIR}
    Empty Directory    ${TEMPDIR}${/}${TEST_DIR}
    Create Binary File    ${TEMPDIR}${/}${TEST_DIR}${/}actualVnfd.zip    ${response.content}
    Extract Zip File    ${TEMPDIR}${/}${TEST_DIR}${/}actualVnfd.zip    ${TEMPDIR}${/}${TEST_DIR}
    File Should Exist    ${TEMPDIR}${/}${TEST_DIR}${/}MainServiceTemplate.yaml
    File Should Exist    ${TEMPDIR}${/}${TEST_DIR}${/}onap_dm.yaml
    ${expectedMainServiceTemplate}=    Get Binary File    ${CURDIR}${/}data${/}responses${/}expectedVnfd${/}MainServiceTemplate.yaml
    ${actualMainServiceTemplate}=    Get Binary File    ${TEMPDIR}${/}${TEST_DIR}${/}MainServiceTemplate.yaml
    Should Be Equal As Strings    ${expectedMainServiceTemplate}    ${actualMainServiceTemplate}
    ${expectedOnapDm}=    Get Binary File    ${CURDIR}${/}data${/}responses${/}expectedVnfd${/}onap_dm.yaml
    ${actualOnapDm}=    Get Binary File    ${TEMPDIR}${/}${TEST_DIR}${/}onap_dm.yaml
    Should Be Equal As Strings    ${expectedOnapDm}    ${actualOnapDm}
    Remove Directory    ${TEMPDIR}${/}${TEST_DIR}    recursive=True
    Log To Console    \nexecuted with expected result

Get A VNF Package Artifact
    ${artifactPath}=    Convert To String    image
    Create Session    so_vnfm_adapter_session    http://${REPO_IP}:9092
    &{headers}=    Create Dictionary    Authorization=${BASIC_AUTH}    Content-Type=application/json    Accept=application/octet-stream
    Log to Console    \nGetting ${artifactPath} artifact from Vnf Package with id ${vnf_package_id} from so-vnfm-adapter
    ${response}=    Get On Session    so_vnfm_adapter_session    ${PACKAGE_MANAGEMENT_BASE_URL}/vnf_packages/${vnf_package_id}/artifacts/${artifactPath}    headers=${headers}
    Log To Console    Response:${response}
    Run Keyword If    '${response.status_code}' == '200'    Log To Console    \nexecuted with expected result
    Should Be Equal As Strings    '${response.status_code}'    '200'
    Create Directory    ${TEMPDIR}${/}${TEST_DIR}
    Empty Directory    ${TEMPDIR}${/}${TEST_DIR}
    Create Binary File    ${TEMPDIR}${/}${TEST_DIR}${/}${artifactPath}    ${response.content}
    ${expectedArtifact}=    Get Binary File    ${CURDIR}${/}data${/}responses${/}expectedArtifacts${/}${artifactPath}
    ${actualArtifact}=    Get Binary File    ${TEMPDIR}${/}${TEST_DIR}${/}${artifactPath}
    Should Be Equal As Strings    ${expectedArtifact}    ${actualArtifact}
    Remove Directory    ${TEMPDIR}${/}${TEST_DIR}    recursive=True
    Log To Console    \nexecuted with expected result

*** Keywords ***
Should Be Equal File Size
    [Arguments]    ${file1}    ${file2}
    Log To Console    \nComparing file sizes between ${file1} and ${file2}
    ${file1size}=    Get File Size    ${file1}
    ${file2size}=    Get File Size    ${file2}
    Should Be Equal    ${file1size}    ${file2size}
    Log To Console    Files are the same size

Should Contain Same Content
    [Arguments]    ${dir1}    ${dir2}
    Log To Console    \nComparing directory contents between:
    Log To Console    Directory 1: ${dir1}
    Log To Console    Directory 2: ${dir2}
    @{dir1files}=    List Files In Directory    ${dir1}
    Log To Console    Files in directory 1: @{dir1files}
    @{dir2files}=    List Files In Directory    ${dir2}
    Log To Console    Files in directory 2: @{dir2files}
    Lists Should Be Equal    ${dir1files}    ${dir2files}
    FOR    ${file}    IN    @{dir1files}
        Should Be Equal File Size    ${dir1}${/}${file}    ${dir2}${/}${file}
    END
    @{dir1directories}=    List Directories In Directory    ${dir1}
    Log To Console    Directories in directory 1: ${dir1directories}
    @{dir2directories}=    List Directories In Directory    ${dir2}
    Log To Console    Directories in directory 2: ${dir2directories}
    Lists Should Be Equal     ${dir1directories}    ${dir2directories}
    FOR    ${directory}    IN    @{dir1directories}
        Should Contain Same Content    ${dir1}${/}${directory}    ${dir2}${/}${directory}
    END
    Log To Console    executed with expected result