blob: 5838c0340de2f1228d73e80e05810e2cb1249655 [file] [log] [blame]
waynedunican7fabab12021-10-22 09:47:05 +01001.. This work is licensed under a
2.. Creative Commons Attribution 4.0 International License.
3.. http://creativecommons.org/licenses/by/4.0
4
5CLAMP Policy Participant Smoke Tests
6------------------------------------
liamfallon516e6722021-10-29 12:00:21 +01007
waynedunican7fabab12021-10-22 09:47:05 +010081. Introduction
9***************
liamfallon516e6722021-10-29 12:00:21 +010010
waynedunican7fabab12021-10-22 09:47:05 +010011The Smoke testing of the policy participant is executed in a local CLAMP/Policy environment. The CLAMP-Controlloop interfaces interact with the Policy Framework to perform actions based on the state of the policy participant. The goal of the Smoke tests is the ensure that CLAMP Policy Participant and Policy Framework work together as expected.
12
132. Setup Guide
14**************
liamfallon516e6722021-10-29 12:00:21 +010015
waynedunican7fabab12021-10-22 09:47:05 +010016This section will show the developer how to set up their environment to start testing in GUI with some instruction on how to carry out the tests. There are a number of prerequisites. Note that this guide is written by a Linux user - although the majority of the steps show will be exactly the same in Windows or other systems.
17
182.1 Prerequisites
19=================
liamfallon516e6722021-10-29 12:00:21 +010020
waynedunican7fabab12021-10-22 09:47:05 +010021- Java 11
22- Maven 3
23- Git
24- Refer to this guide for basic environment setup `Setting up dev environment <https://wiki.onap.org/display/DW/Setting+Up+Your+Development+Environment>`_
25
262.2 Assumptions
27===============
waynedunicancaa4da52021-10-28 10:34:34 +010028
waynedunican7fabab12021-10-22 09:47:05 +010029- You are accessing the policy repositories through gerrit
30- You are using "git review".
waynedunicancaa4da52021-10-28 10:34:34 +010031
waynedunican7fabab12021-10-22 09:47:05 +010032The following repositories are required for development in this project. These repositories should be present on your machine and you should run "mvn clean install" on all of them so that the packages are present in your .m2 repository.
waynedunicancaa4da52021-10-28 10:34:34 +010033
waynedunican7fabab12021-10-22 09:47:05 +010034- policy/parent
35- policy/common
36- policy/models
37- policy/clamp
38- policy/docker
39- policy/gui
40- policy/api
liamfallon516e6722021-10-29 12:00:21 +010041
waynedunican7fabab12021-10-22 09:47:05 +010042In this setup guide, we will be setting up all the components technically required for a working convenient dev environment.
43
442.3 Setting up the components
45=============================
waynedunicancaa4da52021-10-28 10:34:34 +010046
waynedunican7fabab12021-10-22 09:47:05 +0100472.3.1 MariaDB Setup
48^^^^^^^^^^^^^^^^^^^
waynedunicancaa4da52021-10-28 10:34:34 +010049
waynedunican7fabab12021-10-22 09:47:05 +010050We will be using Docker to run our mariadb instance. It will have a total of two databases running in it.
waynedunicancaa4da52021-10-28 10:34:34 +010051
waynedunican7fabab12021-10-22 09:47:05 +010052- controlloop: the runtime-controlloop db
53- policyadmin: the policy-api db
waynedunicancaa4da52021-10-28 10:34:34 +010054
waynedunican7fabab12021-10-22 09:47:05 +010055The easiest way to do this is to perform a small alteration on an SQL script provided by the clamp backend in the file "runtime/extra/sql/bulkload/create-db.sql"
waynedunicancaa4da52021-10-28 10:34:34 +010056
waynedunican7fabab12021-10-22 09:47:05 +010057.. code-block:: mysql
waynedunicancaa4da52021-10-28 10:34:34 +010058
waynedunican7fabab12021-10-22 09:47:05 +010059 CREATE DATABASE `controlloop`;
60 USE `controlloop`;
61 DROP USER 'policy';
62 CREATE USER 'policy';
63 GRANT ALL on controlloop.* to 'policy' identified by 'P01icY' with GRANT OPTION;
64 CREATE DATABASE `policyadmin`;
65 USE `policyadmin`;
66 DROP USER 'policy_user';
67 CREATE USER 'policy_user';
68 GRANT ALL on controlloop.* to 'policy_user' identified by 'policy_user' with GRANT OPTION;
69 FLUSH PRIVILEGES;
waynedunicancaa4da52021-10-28 10:34:34 +010070
waynedunican7fabab12021-10-22 09:47:05 +010071Once this has been done, we can run the bash script provided here: "runtime/extra/bin-for-dev/start-db.sh"
waynedunicancaa4da52021-10-28 10:34:34 +010072
waynedunican7fabab12021-10-22 09:47:05 +010073.. code-block:: bash
waynedunicancaa4da52021-10-28 10:34:34 +010074
waynedunican7fabab12021-10-22 09:47:05 +010075 ./start-db.sh
waynedunicancaa4da52021-10-28 10:34:34 +010076
waynedunican7fabab12021-10-22 09:47:05 +010077This will setup the two databases needed. The database will be exposed locally on port 3306 and will be backed by an anonymous docker volume.
78
792.3.2 DMAAP Simulator
80^^^^^^^^^^^^^^^^^^^^^
liamfallon516e6722021-10-29 12:00:21 +010081
waynedunican7fabab12021-10-22 09:47:05 +010082For convenience, a dmaap simulator has been provided in the policy/models repository. To start the simulator, you can do the following:
831. Navigate to /models-sim/policy-models-simulators in the policy/models repository.
842. Add a configuration file to src/test/resources with the following contents:
waynedunicancaa4da52021-10-28 10:34:34 +010085
waynedunican7fabab12021-10-22 09:47:05 +010086.. code-block:: json
waynedunicancaa4da52021-10-28 10:34:34 +010087
waynedunican7fabab12021-10-22 09:47:05 +010088 {
89 "dmaapProvider":{
90 "name":"DMaaP simulator",
91 "topicSweepSec":900
92 },
93 "restServers":[
94 {
95 "name":"DMaaP simulator",
96 "providerClass":"org.onap.policy.models.sim.dmaap.rest.DmaapSimRestControllerV1",
97 "host":"localhost",
98 "port":3904,
99 "https":false
100 }
101 ]
102 }
waynedunicancaa4da52021-10-28 10:34:34 +0100103
waynedunican7fabab12021-10-22 09:47:05 +01001043. You can then start dmaap with:
waynedunicancaa4da52021-10-28 10:34:34 +0100105
waynedunican7fabab12021-10-22 09:47:05 +0100106.. code-block:: bash
waynedunicancaa4da52021-10-28 10:34:34 +0100107
waynedunican7fabab12021-10-22 09:47:05 +0100108 mvn exec:java -Dexec.mainClass=org.onap.policy.models.simulators.Main -Dexec.args="src/test/resources/YOUR_CONF_FILE.json"
waynedunicancaa4da52021-10-28 10:34:34 +0100109
waynedunican7fabab12021-10-22 09:47:05 +0100110At this stage the dmaap simulator should be running on your local machine on port 3904.
111
1122.3.3 Policy API
113^^^^^^^^^^^^^^^^
liamfallon516e6722021-10-29 12:00:21 +0100114
waynedunican7fabab12021-10-22 09:47:05 +0100115In the policy-api repo, you should find the file "src/main/resources/etc/defaultConfig.json". This file must be altered slightly - as below with the restServerParameters and databaseProviderParameters shown. Note how the database parameters match-up with what you setup in Mariadb:
waynedunicancaa4da52021-10-28 10:34:34 +0100116
waynedunican7fabab12021-10-22 09:47:05 +0100117.. code-block:: json
waynedunicancaa4da52021-10-28 10:34:34 +0100118
waynedunican7fabab12021-10-22 09:47:05 +0100119 {
120 "restServerParameters": {
121 "host": "0.0.0.0",
122 "port": 6970,
123 "userName": "healthcheck",
124 "password": "zb!XztG34",
125 "prometheus": true,
126 "https": false,
127 "aaf": false
128 },
129 "databaseProviderParameters": {
130 "name": "PolicyProviderParameterGroup",
131 "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
132 "databaseDriver": "org.mariadb.jdbc.Driver",
133 "databaseUrl": "jdbc:mariadb://mariadb:3306/policyadmin",
134 "databaseUser": "policy_user",
135 "databasePassword": "policy_user",
136 "persistenceUnit": "PolicyMariaDb"
137 },
138 }
waynedunicancaa4da52021-10-28 10:34:34 +0100139
waynedunican7fabab12021-10-22 09:47:05 +0100140Next, navigate to the "/main" directory. You can then run the following command to start the policy api:
waynedunicancaa4da52021-10-28 10:34:34 +0100141
waynedunican7fabab12021-10-22 09:47:05 +0100142.. code-block:: bash
waynedunicancaa4da52021-10-28 10:34:34 +0100143
waynedunican7fabab12021-10-22 09:47:05 +0100144 mvn exec:java -Dexec.mainClass=org.onap.policy.api.main.startstop.Main -Dexec.args=" -c ../packages/policy-api-tarball/src/main/resources/etc/defaultConfig.json"
145
1462.3.4 Policy PAP
147^^^^^^^^^^^^^^^^
liamfallon516e6722021-10-29 12:00:21 +0100148
waynedunican7fabab12021-10-22 09:47:05 +0100149In the policy-pap repo, you should find the file 'main/src/test/resources/parameters/PapConfigParameters.json'. This file may need to be altered slightly as below:
waynedunicancaa4da52021-10-28 10:34:34 +0100150
waynedunican7fabab12021-10-22 09:47:05 +0100151.. code-block:: json
waynedunicancaa4da52021-10-28 10:34:34 +0100152
waynedunican7fabab12021-10-22 09:47:05 +0100153 {
154 "name": "PapGroup",
155 "restServerParameters": {
156 "host": "0.0.0.0",
157 "port": 6968,
158 "userName": "healthcheck",
159 "password": "zb!XztG34",
160 "https": false
161 },
162 "pdpParameters": {
163 "heartBeatMs": 60000,
164 "updateParameters": {
165 "maxRetryCount": 1,
166 "maxWaitMs": 30000
167 },
168 "stateChangeParameters": {
169 "maxRetryCount": 1,
170 "maxWaitMs": 30000
171 }
172 },
173 "databaseProviderParameters": {
174 "name": "PolicyProviderParameterGroup",
175 "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
176 "databaseDriver": "org.mariadb.jdbc.Driver",
177 "databaseUrl": "jdbc:mariadb://localhost:3306/policyadmin",
178 "databaseUser": "policy_user",
179 "databasePassword": "policy_user",
180 "persistenceUnit": "PolicyMariaDb"
181 },
182 "topicParameterGroup": {
183 "topicSources" : [{
184 "topic" : "POLICY-PDP-PAP",
185 "servers" : [ "localhost:3904" ],
186 "topicCommInfrastructure" : "dmaap"
187 }],
188 "topicSinks" : [{
189 "topic" : "POLICY-PDP-PAP",
190 "servers" : [ "localhost:3904" ],
191 "topicCommInfrastructure" : "dmaap"
192 },{
193 "topic" : "POLICY-NOTIFICATION",
194 "servers" : [ "localhost:3904" ],
195 "topicCommInfrastructure" : "dmaap"
196 }]
197 },
198 "healthCheckRestClientParameters":[{
199 "clientName": "api",
200 "hostname": "policy-api",
201 "port": 6968,
202 "userName": "healthcheck",
203 "password": "zb!XztG34",
204 "useHttps": false,
205 "basePath": "policy/api/v1/healthcheck"
206 },
207 {
208 "clientName": "distribution",
209 "hostname": "policy-distribution",
210 "port": 6970,
211 "userName": "healthcheck",
212 "password": "zb!XztG34",
213 "useHttps": false,
214 "basePath": "healthcheck"
215 }]
216 }
waynedunicancaa4da52021-10-28 10:34:34 +0100217
waynedunican7fabab12021-10-22 09:47:05 +0100218Next, navigate to the "/main" directory. You can then run the following command to start the policy pap
waynedunicancaa4da52021-10-28 10:34:34 +0100219
waynedunican7fabab12021-10-22 09:47:05 +0100220.. code-block:: bash
waynedunicancaa4da52021-10-28 10:34:34 +0100221
waynedunican7fabab12021-10-22 09:47:05 +0100222 mvn -q -e clean compile exec:java -Dexec.mainClass="org.onap.policy.pap.main.startstop.Main" -Dexec.args="-c /src/test/resources/parameters/PapConfigParameters.json"
223
2242.3.5 Controlloop Runtime
225^^^^^^^^^^^^^^^^^^^^^^^^^
liamfallon516e6722021-10-29 12:00:21 +0100226
waynedunican7fabab12021-10-22 09:47:05 +0100227To start the controlloop runtime we need to go the "runtime-controlloop" directory in the clamp repo. There is a config file that is used, by default, for the controlloop runtime. That config file is here: "src/main/resources/application.yaml". For development in your local environment, it shouldn't need any adjustment and we can just run the controlloop runtime with:
waynedunicancaa4da52021-10-28 10:34:34 +0100228
waynedunican7fabab12021-10-22 09:47:05 +0100229.. code-block:: bash
waynedunicancaa4da52021-10-28 10:34:34 +0100230
waynedunican7fabab12021-10-22 09:47:05 +0100231 mvn spring-boot:run
232
2332.3.6 Controlloop Policy Participant
234^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
liamfallon516e6722021-10-29 12:00:21 +0100235
waynedunican7fabab12021-10-22 09:47:05 +0100236To start the policy participant we need to go to the "participant-impl/participant-impl-policy" directory in the clamp repo. There is a config file under "src/main/resources/config/application.yaml". For development in your local environment, we will need to adjust this file slightly:
waynedunicancaa4da52021-10-28 10:34:34 +0100237
waynedunican7fabab12021-10-22 09:47:05 +0100238.. code-block:: yaml
waynedunicancaa4da52021-10-28 10:34:34 +0100239
waynedunican7fabab12021-10-22 09:47:05 +0100240 server:
241 port: 8082
242
243 participant:
244 pdpGroup: defaultGroup
245 pdpType: apex
246 policyApiParameters:
247 clientName: api
248 hostname: localhost
249 port: 6970
250 userName: healthcheck
251 password: zb!XztG34
252 https: true
253 allowSelfSignedCerts: true
254 policyPapParameters:
255 clientName: pap
256 hostname: localhost
257 port: 6968
258 userName: healthcheck
259 password: zb!XztG34
260 https: true
261 allowSelfSignedCerts: true
262 intermediaryParameters:
263 reportingTimeIntervalMs: 120000
264 description: Participant Description
265 participantId:
266 name: org.onap.PM_Policy
267 version: 1.0.0
268 participantType:
269 name: org.onap.policy.controlloop.PolicyControlLoopParticipant
270 version: 2.3.1
271 clampControlLoopTopics:
272 topicSources:
273 -
274 topic: POLICY-CLRUNTIME-PARTICIPANT
275 servers:
276 - ${topicServer:localhost}
277 topicCommInfrastructure: dmaap
278 fetchTimeout: 15000
279 topicSinks:
280 -
281 topic: POLICY-CLRUNTIME-PARTICIPANT
282 servers:
283 - ${topicServer:localhost}
284 topicCommInfrastructure: dmaap
waynedunicancaa4da52021-10-28 10:34:34 +0100285
waynedunican7fabab12021-10-22 09:47:05 +0100286Navigate to the participant-impl/particpant-impl-policy/main directory. We can then run the policy-participant with the following command:
waynedunicancaa4da52021-10-28 10:34:34 +0100287
waynedunican7fabab12021-10-22 09:47:05 +0100288.. code-block:: bash
waynedunicancaa4da52021-10-28 10:34:34 +0100289
waynedunican7fabab12021-10-22 09:47:05 +0100290 mvn spring-boot:run -Dspring-boot.run.arguments="--server.port=8082 --topicServer=localhost"
291
2923. Testing Procedure
293====================
waynedunicancaa4da52021-10-28 10:34:34 +0100294
waynedunican7fabab12021-10-22 09:47:05 +01002953.1 Testing Outline
296^^^^^^^^^^^^^^^^^^^
liamfallon516e6722021-10-29 12:00:21 +0100297
waynedunican7fabab12021-10-22 09:47:05 +0100298To perform the Smoke testing of the policy-participant we will be verifying the behaviours of the participant when the control loop changes state. The scenarios are:
waynedunicancaa4da52021-10-28 10:34:34 +0100299
waynedunican7fabab12021-10-22 09:47:05 +0100300- UNINITIALISED to PASSIVE: participant creates policies and policyTypes specified in the ToscaServiceTemplate using policy-api
301- PASSIVE to RUNNING: participant deploys created policies specified in the ToscaServiceTemplate
302- RUNNING to PASSIVE: participant undeploys policies which have been deployed
303- PASSIVE to UNINITIALISED: participant deletes policies and policyTypes which has been created
304
3053.2 Testing Steps
306^^^^^^^^^^^^^^^^^
307
308Creation of Controlloop:
309************************
liamfallon516e6722021-10-29 12:00:21 +0100310
waynedunican7fabab12021-10-22 09:47:05 +0100311A Control Loop is created by commissioning a Tosca template with Control loop definitions and instantiating the Control Loop with the state "UNINITIALISED".
312Using postman, commision a TOSCA template and instantiate using the following template:
waynedunicancaa4da52021-10-28 10:34:34 +0100313
314:download:`Tosca Service Template <tosca/tosca_service_template_pptnt_smoke.yaml>`
315
316:download:`Instantiate Controlloop <tosca/instantiation_pptnt_smoke.json>`
317
waynedunican7fabab12021-10-22 09:47:05 +0100318To verify this, we check that the Controlloop has been created and is in state UNINITIALISED.
waynedunicancaa4da52021-10-28 10:34:34 +0100319
waynedunican7fabab12021-10-22 09:47:05 +0100320 .. image:: images/pol-part-controlloop-creation-ver.png
321
322Creation of policies and policyTypes:
323*************************************
liamfallon516e6722021-10-29 12:00:21 +0100324
waynedunican7fabab12021-10-22 09:47:05 +0100325The Controlloop STATE is changed from UNINITIALISED to PASSIVE using postman:
waynedunicancaa4da52021-10-28 10:34:34 +0100326
327.. code-block:: json
328
waynedunican7fabab12021-10-22 09:47:05 +0100329 {
330 "orderedState": "PASSIVE",
331 "controlLoopIdentifierList": [
332 {
333 "name": "PMSHInstance0",
334 "version": "1.0.1"
335 }
336 ]
337 }
waynedunicancaa4da52021-10-28 10:34:34 +0100338
waynedunican7fabab12021-10-22 09:47:05 +0100339This state change will trigger the creation of policies and policyTypes using the policy-api. To verify this we will check, using policy-api endpoints, that the "Sirisha" policyType, which is specified in the service template, has been created.
waynedunicancaa4da52021-10-28 10:34:34 +0100340
waynedunican7fabab12021-10-22 09:47:05 +0100341 .. image:: images/pol-part-controlloop-sirisha-ver.png
waynedunicancaa4da52021-10-28 10:34:34 +0100342
waynedunican7fabab12021-10-22 09:47:05 +0100343We can also check that the pm-control policy has been created.
waynedunicancaa4da52021-10-28 10:34:34 +0100344
waynedunican7fabab12021-10-22 09:47:05 +0100345 .. image:: images/pol-part-controlloop-pmcontrol-ver.png
346
347Deployment of policies:
348***********************
liamfallon516e6722021-10-29 12:00:21 +0100349
waynedunican7fabab12021-10-22 09:47:05 +0100350The Controlloop STATE is changed from PASSIVE to RUNNING using postman:
waynedunicancaa4da52021-10-28 10:34:34 +0100351
352.. code-block:: json
353
waynedunican7fabab12021-10-22 09:47:05 +0100354 {
355 "orderedState": "RUNNING",
356 "controlLoopIdentifierList": [
357 {
358 "name": "PMSHInstance0",
359 "version": "1.0.1"
360 }
361 ]
362 }
waynedunicancaa4da52021-10-28 10:34:34 +0100363
waynedunican7fabab12021-10-22 09:47:05 +0100364This state change will trigger the deployment of the policies specified in the ToscaServiceTemplate. To verify this, we will check that the apex pmcontrol policy has been deployed to the defaultGroup. We check this using pap:
waynedunicancaa4da52021-10-28 10:34:34 +0100365
waynedunican7fabab12021-10-22 09:47:05 +0100366 .. image:: images/pol-part-controlloop-pmcontrol-deploy-ver.png
367
368Undeployment of policies:
369*************************
liamfallon516e6722021-10-29 12:00:21 +0100370
waynedunican7fabab12021-10-22 09:47:05 +0100371The Controlloop STATE is changed from RUNNING to PASSIVE using postman:
waynedunicancaa4da52021-10-28 10:34:34 +0100372
373.. code-block:: json
374
waynedunican7fabab12021-10-22 09:47:05 +0100375 {
376 "orderedState": "PASSIVE",
377 "controlLoopIdentifierList": [
378 {
379 "name": "PMSHInstance0",
380 "version": "1.0.1"
381 }
382 ]
383 }
waynedunicancaa4da52021-10-28 10:34:34 +0100384
waynedunican7fabab12021-10-22 09:47:05 +0100385This state change will trigger the undeployment of the pmcontrol policy which was deployed previously. To verifiy this we do a PdpGroup Query as before and check that the pmcontrol policy has been undeployed and removed from the defaultGroup:
waynedunicancaa4da52021-10-28 10:34:34 +0100386
waynedunican7fabab12021-10-22 09:47:05 +0100387 .. image:: images/pol-part-controlloop-pmcontrol-undep-ver.png
388
389Deletion of policies and policyTypes:
390*************************************
liamfallon516e6722021-10-29 12:00:21 +0100391
waynedunican7fabab12021-10-22 09:47:05 +0100392The Controlloop STATE is changed from PASSIVE to UNINITIALISED using postman:
waynedunicancaa4da52021-10-28 10:34:34 +0100393
394.. code-block:: json
395
waynedunican7fabab12021-10-22 09:47:05 +0100396 {
397 "orderedState": "UNINITIALISED",
398 "controlLoopIdentifierList": [
399 {
400 "name": "PMSHInstance0",
401 "version": "1.0.1"
402 }
403 ]
404 }
waynedunicancaa4da52021-10-28 10:34:34 +0100405
waynedunican7fabab12021-10-22 09:47:05 +0100406This state change will trigger the deletion of the previously created policies and policyTypes. To verify this, as before, we can check that the Sirisha policyType is not found this time and likewise for the pmcontrol policy:
waynedunicancaa4da52021-10-28 10:34:34 +0100407
waynedunican7fabab12021-10-22 09:47:05 +0100408 .. image:: images/pol-part-controlloop-sirisha-nf.png
waynedunicancaa4da52021-10-28 10:34:34 +0100409
waynedunican7fabab12021-10-22 09:47:05 +0100410 .. image:: images/pol-part-controlloop-pmcontrol-nf.png