[DMAAP] fix the references to the dmaap interface files
[testsuite.git] / robot / testsuites / usecases / 5gson.robot
1 *** Settings ***
2 Documentation     5G SON 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/policy_interface.robot
15 Resource          ../../resources/dmaap/mr_interface.robot
16 Resource          ../../resources/dcae/ves_interface.robot
17 Resource          ../../resources/usecases/5gbulkpm_interface.robot
18 Suite Teardown    SON Usecase Teardown
19
20 *** Variables ***
21
22 ${POLICY_TYPE_PATH}                 /policy/api/v1/policytypes
23 ${CL_DATA_PATH}                     ${POLICY_TYPE_PATH}/onap.policies.controlloop.operational.common.Drools/versions/1.0.0/policies
24 ${MONITORING_DATA_PATH}             ${POLICY_TYPE_PATH}/onap.policies.monitoring.docker.sonhandler.app/versions/1.0.0/policies
25 @{TOPICS}                           PCI-NOTIF-TOPIC-NGHBR-LIST-CHANGE-INFO   unauthenticated.SEC_FAULT_OUTPUT   unauthenticated.VES_MEASUREMENT_OUTPUT   unauthenticated.DCAE_CL_OUTPUT   DCAE_CL_RSP   SDNR-CL
26 ${DMAAP_MR_URL}                     ${GLOBAL_MR_SERVER_PROTOCOL}://${GLOBAL_INJECTED_MR_IP_ADDR}:${GLOBAL_MR_SERVER_PORT}
27 ${INVENTORY_SERVER}                 ${GLOBAL_INVENTORY_SERVER_PROTOCOL}://${GLOBAL_INVENTORY_SERVER_NAME}:${GLOBAL_INVENTORY_SERVER_PORT}
28 ${DEPLOYMENT_SERVER}                ${GLOBAL_DEPLOYMENT_HANDLER_SERVER_PROTOCOL}://${GLOBAL_DEPLOYMENT_HANDLER_SERVER_NAME}:${GLOBAL_DEPLOYMENT_HANDLER_SERVER_PORT}
29 ${INVENTORY_ENDPOINT}               /dcae-service-types
30 ${DEPLOYMENT_ENDPOINT}              dcae-deployments
31 ${DEPLOY_DATA_PATH}                 /policy/pap/v1/pdps/policies
32 ${5GSON_RESOURCES_PATH}             ${EXECDIR}/robot/assets/usecases/5gson
33 ${CONFIGDB_BLUEPRINT_PATH}          ${5GSON_RESOURCES_PATH}/k8s-configdb.yaml
34 ${BLUEPRINT_TEMPLATE_PATH}          ${EXECDIR}/robot/assets/usecases/5gbulkpm/blueprintTemplate.json
35 ${CONFIGDB_INSERT_PATH}             /api/sdnc-config-db/v3/insertData
36 ${CONFIGDB_CREATENBR_PATH}          /api/sdnc-config-db/v3/createNbr
37 @{NEW_NBRS}                         Chn0012   Chn0116   Chn0071
38
39 *** Test Cases ***
40
41 Creating Policy Types
42     [Tags]                              5gson
43     ${monitoring_policy_type}=          Get Binary File                    ${5GSON_RESOURCES_PATH}/monitoring_policy_type.json
44     ${resp}=                            Run Policy Api Post Request        data_path=${POLICY_TYPE_PATH}    data=${monitoring_policy_type}
45     Should Be Equal As Strings          ${resp.status_code}                200
46
47 Creating SON Policies
48     [Tags]                              5gson
49     ${pci_policy}=                      Get Binary File                    ${5GSON_RESOURCES_PATH}/pci.json
50     ${resp}=                            Run Policy Api Post Request        data_path=${CL_DATA_PATH}        data=${pci_policy}
51     Should Be Equal As Strings          ${resp.status_code}                200
52     ${anr_policy}=                      Get Binary File                    ${5GSON_RESOURCES_PATH}/anr.json
53     ${resp}=                            Run Policy Api Post Request        data_path=${CL_DATA_PATH}        data=${anr_policy}
54     Should Be Equal As Strings          ${resp.status_code}                200
55     ${son_policy}=                      Get Binary File                    ${5GSON_RESOURCES_PATH}/son_monitoring.json
56     ${resp}=                            Run Policy Api Post Request        data_path=${MONITORING_DATA_PATH}    data=${son_policy}
57     Should Be Equal As Strings          ${resp.status_code}                200
58
59 Deploying SON Polciies
60     [Tags]                              5gson
61     ${pci_deploy}=                      Get Binary File                    ${5GSON_RESOURCES_PATH}/pci_deploy.json
62     ${resp}=                            Run Policy Pap Post Request        data_path=${DEPLOY_DATA_PATH}    data=${pci_deploy}
63     Should Be Equal As Strings          ${resp.status_code}                200
64     ${anr_deploy}=                      Get Binary File                    ${5GSON_RESOURCES_PATH}/anr_deploy.json
65     ${resp}=                            Run Policy Pap Post Request        data_path=${DEPLOY_DATA_PATH}    data=${anr_deploy}
66     Should Be Equal As Strings          ${resp.status_code}                200
67     ${son_deploy}=                      Get Binary File                    ${5GSON_RESOURCES_PATH}/son_deploy.json
68     ${resp}=                            Run Policy Pap Post Request        data_path=${DEPLOY_DATA_PATH}    data=${son_deploy}
69     Should Be Equal As Strings          ${resp.status_code}                200
70
71 Create dmaap topics
72     [Tags]                              5gson
73     :FOR   ${topic}   IN   @{TOPICS}
74     \   ${data_path}=                   Set Variable                       /events/${topic}
75     \   ${resp}=                        Run MR Post Request                data_path=${data_path}
76     \   Should Be Equal As Strings      ${resp.status_code}                200
77
78 Deploy SON Handler
79     [Tags]                              5gson
80     ${headers}=                         Create Dictionary                  content-type=application/json
81     ${session}=                         Create Session                     inv                              ${INVENTORY_SERVER}
82     ${resp}=                            Get Request                        inv                              ${INVENTORY_ENDPOINT}?typeName=k8s-sonhms
83     ${json}=                            Set Variable                       ${resp.json()}
84     ${serviceTypeId-sonhms}             Set Variable                       ${json['items'][0]['typeId']}
85     ${sonhms_inputs}=                   Get Binary File                    ${5GSON_RESOURCES_PATH}/sonhms_inputs.json
86     ${deployment_data}=                 Set Variable                       {"serviceTypeId": "${serviceTypeId-sonhms}", "inputs": ${sonhms_inputs}}
87     ${session}=                         Create Session                     deployment-son                   ${DEPLOYMENT_SERVER}
88     ${resp}=                            Put Request                        deployment-son                   /${DEPLOYMENT_ENDPOINT}/sonhms         data=${deployment_data}     headers=${headers}
89     ${operationLink}                    Set Variable                       ${resp.json().get('links').get('status')}
90     ${operationId}                      Fetch From Right                   ${operationLink}                 /
91     Wait Until Keyword Succeeds         5 minute                           20 sec                           Deployment Status       ${DEPLOYMENT_SERVER}     ${DEPLOYMENT_ENDPOINT}     sonhms     ${operationId}
92
93 Deploy Config DB
94     [Tags]                              5gson
95     ${configdb_blueprint_path}          Set Variable                       ${5GSON_RESOURCES_PATH}/k8s-configdb.yaml
96     ${blueprint}=                       OperatingSystem.Get File           ${configdb_blueprint_path}
97     ${templatejson}=                    Load JSON From File                ${BLUEPRINT_TEMPLATE_PATH}
98     ${templatejson}=                    Update Value To Json               ${templatejson}                  blueprintTemplate             ${blueprint}
99     ${templatejson}=                    Update Value To Json               ${templatejson}                  typeName                      configdb
100     ${json_data}                        Convert JSON To String             ${templatejson}
101     ${headers}=                         Create Dictionary                  content-type=application/json
102     ${session}=                         Create Session                     sftp                             ${INVENTORY_SERVER}
103     ${resp}=                            Post Request                       sftp                             ${INVENTORY_ENDPOINT}          data=${json_data}             headers=${headers}
104     ${serviceTypeId-configdb}=          Set Variable                       ${resp.json().get('typeId')}
105     Set Global Variable                 ${serviceTypeId-configdb}
106     ${deployment_data}=                 Set Variable                       {"serviceTypeId": "${serviceTypeId-configdb}" }
107     ${session}=                         Create Session                     deployment-configdb              ${DEPLOYMENT_SERVER}
108     ${resp}=                            Put Request                        deployment-configdb              /${DEPLOYMENT_ENDPOINT}/configdb         data=${deployment_data}     headers=${headers}
109     ${operationLink}=                   Set Variable                       ${resp.json().get('links').get('status')}
110     ${operationId}                      Fetch From Right                   ${operationLink}                 /
111     Wait Until Keyword Succeeds         2 minute                           5 sec                            Deployment Status       ${DEPLOYMENT_SERVER}     ${DEPLOYMENT_ENDPOINT}     configdb     ${operationId}
112
113 Load Data to Config DB
114     [Tags]                              5gson
115     Sleep                               30 seconds
116     ${initial_dump}                     Get Binary File                    ${5GSON_RESOURCES_PATH}/dump_file.json
117     ${headers}=                         Create Dictionary                  content-type=application/json
118     ${session}=                         Create Session                     configdb                         http://configdb.onap:8080
119     ${resp}=                            Put Request                        configdb                         ${CONFIGDB_INSERT_PATH}    data=${initial_dump}    headers=${headers}
120     Should Be Equal As Strings          ${resp.status_code}                201
121
122 Post Fault Message to VES Collector
123     [Tags]                              5gson
124     ${session}=                         Create Session                     configdb                         http://configdb.onap:8080
125     ${headers}=                         Create Dictionary                  content-type=application/json
126     :FOR   ${NBR}   IN   @{NEW_NBRS}
127     \   ${nbr_obj}                      Set Variable                       {"targetCellId": "${NBR}", "ho": true}
128     \   ${resp}                         Put Request                        configdb                         ${CONFIGDB_CREATENBR_PATH}/Chn0005    headers=${headers}    data=${nbr_obj}
129     \   Should Be Equal As Strings      ${resp.status_code}                201
130     ${fault_event}=                     Set Variable                       ${5GSON_RESOURCES_PATH}/son_fault.json
131     Send Event to VES Collector         event=${fault_event}
132
133 Verifying Modify Config message from SDNR-CL
134     [Tags]                              5gson
135     ${no_of_msgs}                       Set Variable                       ${0}
136     Set Global Variable                 ${no_of_msgs}
137     Wait Until Keyword Succeeds         4 minutes                          30 seconds                       Verify SDNC Dmaap Message
138
139 *** Keywords ***
140
141 SON Usecase Teardown
142     Undeploy Service                    ${DEPLOYMENT_SERVER}               /${DEPLOYMENT_ENDPOINT}/sonhms
143     Undeploy Service                    ${DEPLOYMENT_SERVER}               /${DEPLOYMENT_ENDPOINT}/configdb
144     Undeploy Service                    ${INVENTORY_SERVER}                ${INVENTORY_ENDPOINT}/${serviceTypeId-configdb}
145
146 Verify SDNC Dmaap Message
147     ${resp}=                            Run MR Get Request                 /events/SDNR-CL/robot-cg/robot-cid
148     @{messages}=                        Set Variable                       ${resp.json()}
149     Should Not Be Empty                 ${messages}
150     :FOR   ${msg}   IN   @{messages}
151     \   ${msg_json}=                    Convert String to JSON             ${msg}
152     \   ${rpc_name}=                    Set Variable                       ${msg_json.get("rpc-name")}
153     \   ${no_of_msgs}=                  Set Variable If                    "${rpc_name}" == "modifyconfig"    ${no_of_msgs + 1}
154     Should Be Equal As Numbers          ${no_of_msgs}                      4