Fix 5g_bulk_PM and pnf_registrate test case errors
[testsuite.git] / robot / testsuites / usecases / 5gbulkpm.robot
1 *** Settings ***
2 Documentation     5G Bulk PM Usecase functionality
3
4 Library           RequestsLibrary
5 Library           OperatingSystem
6 Library           Collections
7 Library           String
8 Library           DateTime
9 Library           SSHLibrary
10 Library           JSONLibrary
11 Library           Process
12 Library           ONAPLibrary.JSON
13 Library           ONAPLibrary.Utilities
14 Resource          ../../resources/usecases/5gbulkpm_interface.robot
15 Resource          ../../resources/mr_interface.robot
16 Resource          ../../resources/dr_interface.robot
17 Suite Setup       Send File Ready Event to VES Collector   test
18 Suite Teardown    Usecase Teardown
19
20 *** Variables ***
21 ${INVENTORY_ENDPOINT}               /dcae-service-types
22 ${XNF_SFTP_BLUEPRINT_PATH}          ${EXECDIR}/robot/assets/usecases/5gbulkpm/k8s-sftp.yaml
23 ${BLUEPRINT_TEMPLATE_PATH}          ${EXECDIR}/robot/assets/usecases/5gbulkpm/blueprintTemplate.json
24 ${FTP_FILE_PATH}                    ${EXECDIR}/robot/assets/usecases/5gbulkpm/pmfiles/A20181002.0000-1000-0015-1000_5G.xml.gz
25 ${DEPLOYMENT_ENDPOINT}              dcae-deployments
26 ${MR_TOPIC_CHECK_PATH}              /topics
27 ${DR_SUB_CHECK_PATH}                /internal/prov
28 ${MR_TOPIC_URL_PATH}                /events/org.onap.dmaap.mr.PERFORMANCE_MEASUREMENTS/CG1/C1
29 ${MR_TOPIC_URL_PATH_FOR_POST}       /events/org.onap.dmaap.mr.PERFORMANCE_MEASUREMENTS
30 ${DMAAP_BC_MR_CLIENT_PATH}          /webapi/mr_clients
31 ${DMAAP_BC_MR_CLUSTER_PATH}         /webapi/mr_clusters
32 ${PMMAPPER_HEALTH_CHECK_PATH}       /healthcheck
33 ${JSON_DATA_FILE}                   ${EXECDIR}/robot/assets/usecases/5gbulkpm/Notification.json
34 ${VES_LISTENER_PATH}                /eventListener/v7
35 ${PMMAPPER_SUB_ROLE_DATA}           ${EXECDIR}/robot/assets/usecases/5gbulkpm/sub.json
36 ${PMMAPPER_MR_CLUSTER_DATA}         ${EXECDIR}/robot/assets/usecases/5gbulkpm/mr_clusters.json
37 ${NEXUS3}                           ${GLOBAL_INJECTED_NEXUS_DOCKER_REPO}
38
39
40
41 *** Test Cases ***
42
43 Deploying Data File Collector
44     [Tags]                              5gbulkpm
45     ${headers}=                         Create Dictionary                  content-type=application/json
46     ${session}=                         Create Session                     dfc                 ${INVENTORY_SERVER}
47     ${resp}=                            Get Request                       dfc                 ${INVENTORY_ENDPOINT}?typeName=k8s-datafile                      headers=${headers}
48     ${json}=                            Set Variable                       ${resp.json()}
49     ${serviceTypeId-Dfc}                Set Variable                       ${json['items'][0]['typeId']}
50     ${image}                            Get Regexp Matches                 ${json['items'][0]['blueprintTemplate']}            nexus3(.)*?(?=\\")
51     ${image}                            Replace String                     ${image}[0]      nexus3.onap.org:10001                 ${NEXUS3}
52     Set Global Variable                 ${serviceTypeId-Dfc}
53     ${deployment_data}=                 Set Variable                       {"serviceTypeId": "${serviceTypeId-Dfc}", "inputs": {"tag_version": "${image}"}}
54     ${session}=                         Create Session                     deployment-dfc                 ${DEPLOYMENT_SERVER}
55     ${resp}=                            Put Request                        deployment-dfc                 /${DEPLOYMENT_ENDPOINT}/datafile         data=${deployment_data}     headers=${headers}
56     ${operationLink}                    Set Variable                       ${resp.json().get('links').get('status')}
57     ${operationId}                      Fetch From Right                   ${operationLink}                /
58     Wait Until Keyword Succeeds         5 minute                           20 sec            Deployment Status       ${DEPLOYMENT_SERVER}     ${DEPLOYMENT_ENDPOINT}     datafile     ${operationId}
59
60 Deploying 3GPP PM Mapper
61     [Tags]                              5gbulkpm
62     ${clusterdata}=                     OperatingSystem.Get File           ${PMMAPPER_MR_CLUSTER_DATA}
63     ${headers}=                         Create Dictionary                  content-type=application/json
64     ${session}=                         Create Session                     dmaapbc                          ${DMAAP_BC_SERVER}
65     ${resp}=                            Post Request                       dmaapbc                          ${DMAAP_BC_MR_CLUSTER_PATH}          data=${clusterdata}   headers=${headers}
66     ${session}=                         Create Session                     pmmapper                 ${INVENTORY_SERVER}
67     ${resp}=                            Get Request                        pmmapper                 ${INVENTORY_ENDPOINT}?typeName=k8s-pm-mapper                     headers=${headers}
68     ${json}=                            Set Variable                       ${resp.json()}
69     ${serviceTypeId-Pmmapper}           Set Variable                       ${json['items'][0]['typeId']}
70     ${image}                            Get Regexp Matches                 ${json['items'][0]['blueprintTemplate']}            nexus3(.)*?(?=\')
71     ${image}                            Replace String                     ${image}[0]      nexus3.onap.org:10001                 ${NEXUS3}
72     Set Global Variable                 ${serviceTypeId-Pmmapper}
73     ${deployment_data}=                 Set Variable                       {"inputs":{"client_password": "${GLOBAL_DCAE_PASSWORD}", "tag_version": "${image}"},"serviceTypeId": "${serviceTypeId-Pmmapper}"}
74     ${session}=                         Create Session                     deployment-pmmapper                 ${DEPLOYMENT_SERVER}
75     ${resp}=                            Put Request                        deployment-pmmapper                 /${DEPLOYMENT_ENDPOINT}/pmmapper         data=${deployment_data}     headers=${headers}
76     ${operationLink}                    Set Variable                       ${resp.json().get('links').get('status')}
77     ${operationId}                      Fetch From Right                   ${operationLink}                /
78     Wait Until Keyword Succeeds         6 minute                           10 sec            Deployment Status       ${DEPLOYMENT_SERVER}     ${DEPLOYMENT_ENDPOINT}     pmmapper     ${operationId}
79
80 Deploying SFTP Server As xNF
81     [Tags]                              5gbulkpm
82     ${blueprint}=                       OperatingSystem.Get File           ${XNF_SFTP_BLUEPRINT_PATH}
83     ${templatejson}=                    Load JSON From File                ${BLUEPRINT_TEMPLATE_PATH}
84     ${templatejson}=                    Update Value To Json               ${templatejson}                            blueprintTemplate             ${blueprint}
85     ${templatejson}=                    Update Value To Json               ${templatejson}                            typeName                      sftpserver
86     ${json_data}                        Convert JSON To String             ${templatejson}
87     ${headers}=                         Create Dictionary                  content-type=application/json
88     ${session}=                         Create Session                     sftp                 ${INVENTORY_SERVER}
89     ${resp}=                            Post Request                       sftp                 ${INVENTORY_ENDPOINT}          data=${json_data}             headers=${headers}
90     ${serviceTypeId-Sftp}=              Set Variable                       ${resp.json().get('typeId')}
91     Set Global Variable                 ${serviceTypeId-Sftp}
92     ${deployment_data}=                 Set Variable                       {"serviceTypeId": "${serviceTypeId-Sftp}" }
93     ${session}=                         Create Session                     deployment-sftpserver                 ${DEPLOYMENT_SERVER}
94     ${resp}=                            Put Request                        deployment-sftpserver                 /${DEPLOYMENT_ENDPOINT}/sftpserver         data=${deployment_data}     headers=${headers}
95     ${operationLink}=                   Set Variable                       ${resp.json().get('links').get('status')}
96     ${operationId}                      Fetch From Right                   ${operationLink}                /
97     Wait Until Keyword Succeeds         2 minute                           5 sec            Deployment Status       ${DEPLOYMENT_SERVER}     ${DEPLOYMENT_ENDPOINT}     sftpserver     ${operationId}
98
99
100 Checking PERFORMANCE_MEASUREMENTS Topic In Message Router
101     [Tags]                              5gbulkpm
102     ${headers}=                         Create Dictionary                  content-type=application/json
103     ${subdata}=                         OperatingSystem.Get File           ${PMMAPPER_SUB_ROLE_DATA}
104     ${session}=                         Create Session                     dmaapbc                          ${DMAAP_BC_SERVER}
105     ${resp}=                            Post Request                       dmaapbc                          ${DMAAP_BC_MR_CLIENT_PATH}      data=${subdata}        headers=${headers}
106     Wait Until Keyword Succeeds         5 minute                           5 sec                            Topic Validate                  success
107     ${resp}=                            Run MR Get Request                 ${MR_TOPIC_CHECK_PATH}
108     Should Be Equal As Strings          ${resp.status_code}                200
109     ${topics}=                          Set Variable                       ${resp.json().get('topics')}
110     List Should Contain Value           ${topics}                          org.onap.dmaap.mr.PERFORMANCE_MEASUREMENTS
111     ${resp}=                            Run MR Auth Get Request            ${MR_TOPIC_URL_PATH}            ${GLOBAL_DCAE_USERNAME}         ${GLOBAL_DCAE_PASSWORD}
112     Should Be Equal As Strings          ${resp.status_code}                200
113
114 Upload PM Files to xNF SFTP Server
115     [Tags]                              5gbulkpm
116     Open Connection                     sftpserver
117     Login                               bulkpm                             bulkpm
118     ${epoch}=                           Get Current Date                   result_format=epoch
119     Set Global Variable                 ${epoch}
120     Put File                            ${FTP_FILE_PATH}                   upload/A${epoch}.xml.gz
121
122 DR Bulk PM Feed Check
123     [Tags]                              5gbulkpm
124     ${resp}=                            Run DR Get Request                  ${DR_SUB_CHECK_PATH}
125     Should Contain                      ${resp.text}                        bulk_pm_feed
126
127 DR PM Mapper Subscriber Check
128     [Tags]                              5gbulkpm
129     ${resp}=                            Run DR Get Request                  ${DR_SUB_CHECK_PATH}
130     Should Contain                      ${resp.text}                        https://dcae-pm-mapper:8443/delivery
131
132 Sending File Ready Event to VES Collector
133     [Tags]                              5gbulkpm
134     Send File Ready Event to VES Collector                       ${epoch}
135
136 Verifying 3GPP Perf VES Content On PERFORMANCE_MEASUREMENTS Topic
137     [Tags]                              5gbulkpm
138     Wait Until Keyword Succeeds         5 minute                            5 sec            xNF PM File Validate      perf3gpp_RnNode-Ericsson_pmMeasResult