1 .. This work is licensed under a
2 .. Creative Commons Attribution 4.0 International License.
3 .. http://creativecommons.org/licenses/by/4.0
5 CLAMP Policy Participant Smoke Tests
6 ------------------------------------
11 The Smoke testing of the policy participant is executed in a local CLAMP/Policy environment. The CLAMP-ACM 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 All applications will be running by console, so they need to run with different ports. Configuration files should be changed accordingly.
14 +------------------------------+------+
15 | Application | port |
16 +==============================+======+
18 +------------------------------+------+
19 | DMaaP simulator | 3904 |
20 +------------------------------+------+
22 +------------------------------+------+
24 +------------------------------+------+
25 | policy-clamp-runtime-acm | 6969 |
26 +------------------------------+------+
27 | onap/policy-clamp-ac-pf-ppnt | 8085 |
28 +------------------------------+------+
34 This 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 several 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.
42 - Refer to this guide for basic environment setup `Setting up dev environment <https://wiki.onap.org/display/DW/Setting+Up+Your+Development+Environment>`_
47 - You are accessing the policy repositories through gerrit
48 - You are using "git review".
50 The 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.
59 In this setup guide, we will be setting up all the components technically required for a working convenient dev environment.
61 2.3 Setting up the components
62 =============================
67 We will be using Docker to run our mariadb instance. It will have a total of two databases running in it.
69 - clampacm: the policy-clamp-runtime-acm db
70 - policyadmin: the policy-api db
72 A sql such as the one below can be used to build the SQL initialization. Create the *mariadb.sql* file in a directory *PATH_DIRECTORY*.
76 create database clampacm;
77 CREATE USER 'policy'@'%' IDENTIFIED BY 'P01icY';
78 GRANT ALL PRIVILEGES ON clampacm.* TO 'policy'@'%';
79 CREATE DATABASE `policyadmin`;
80 CREATE USER 'policy_user'@'%' IDENTIFIED BY 'policy_user';
81 GRANT ALL PRIVILEGES ON policyadmin.* to 'policy_user'@'%';
85 Execution of the command above results in the creation and start of the *mariadb-smoke-test* container.
89 docker run --name mariadb-smoke-test \
91 -e MYSQL_ROOT_PASSWORD=my-secret-pw \
92 --mount type=bind,source=PATH_DIRECTORY/mariadb.sql,target=/docker-entrypoint-initdb.d/data.sql \
94 --lower-case-table-names=1
96 This will setup the two databases needed. The database will be exposed locally on port 3306.
101 For convenience, a dmaap simulator has been provided in the policy/models repository. To start the simulator, you can do the following:
103 #. Navigate to models-sim/policy-models-simulators in the policy/models repository.
104 #. Add a configuration file to src/test/resources with the following contents:
110 "name":"DMaaP simulator",
115 "name":"DMaaP simulator",
116 "providerClass":"org.onap.policy.models.sim.dmaap.rest.DmaapSimRestControllerV1",
124 3. You can then start dmaap with:
128 mvn exec:java -Dexec.mainClass=org.onap.policy.models.simulators.Main -Dexec.args="src/test/resources/YOUR_CONF_FILE.json"
130 At this stage the dmaap simulator should be running on your local machine on port 3904.
135 Navigate to the "/main" directory. You can then run the following command to start the policy api:
139 java -jar target/api-main-2.8.2-SNAPSHOT.jar --spring.datasource.url=jdbc:mariadb://localhost:3306/policyadmin --spring.jpa.hibernate.ddl-auto=update --server.port=6968
145 In the policy-pap repo, you should find the file 'main\src\main\resources\application.yaml'. This file may need to be altered slightly as below:
156 preferred-json-mapper: gson
158 url: jdbc:mariadb://localhost:3306/policyadmin
159 driverClassName: org.mariadb.jdbc.Driver
160 username: policy_user
161 password: policy_user
165 dialect: org.hibernate.dialect.MariaDB103Dialect
169 physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
170 implicit-strategy: org.onap.policy.common.spring.utils.CustomImplicitNamingStrategy
175 context-path: /policy/pap/v1
180 pdp-pap.name: POLICY-PDP-PAP
181 notification.name: POLICY-NOTIFICATION
182 heartbeat.name: POLICY-HEARTBEAT
188 stateChangeParameters:
191 savePdpStatisticsInDb: true
194 - topic: ${pap.topic.pdp-pap.name}
197 topicCommInfrastructure: dmaap
199 - topic: ${pap.topic.heartbeat.name}
200 effectiveTopic: ${pap.topic.pdp-pap.name}
201 consumerGroup: policy-pap
204 topicCommInfrastructure: dmaap
207 - topic: ${pap.topic.pdp-pap.name}
210 topicCommInfrastructure: dmaap
211 - topic: ${pap.topic.notification.name}
214 topicCommInfrastructure: dmaap
215 healthCheckRestClientParameters:
219 userName: policyadmin
222 basePath: policy/api/v1/healthcheck
223 - clientName: distribution
224 hostname: policy-distribution
226 userName: healthcheck
229 basePath: healthcheck
241 include: health, metrics, prometheus
242 path-mapping.metrics: plain-metrics
243 path-mapping.prometheus: metrics
245 Next, navigate to the "/main" directory. You can then run the following command to start the policy pap
254 To start the clampacm runtime we need to go the "runtime-acm" directory in the clamp repo. There is a config file that is used, by default, for the clampacm 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 clampacm runtime with:
260 2.3.6 ACM Policy Participant
261 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
263 To start the policy participant we need to go to the "participant/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:
270 name: participantUser
274 - org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration
275 - org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
276 - org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration
277 - org.springframework.boot.autoconfigure.data.web.SpringDataWebAutoConfiguration
280 pdpGroup: defaultGroup
286 userName: policyadmin
289 allowSelfSignedCerts: true
294 userName: policyadmin
297 allowSelfSignedCerts: true
298 intermediaryParameters:
299 reportingTimeIntervalMs: 120000
300 description: Participant Description
301 participantId: 101c62b3-8918-41b9-a747-d21eb79c6c03
302 clampAutomationCompositionTopics:
305 topic: POLICY-ACRUNTIME-PARTICIPANT
307 - ${topicServer:localhost}
308 topicCommInfrastructure: dmaap
312 topic: POLICY-ACRUNTIME-PARTICIPANT
314 - ${topicServer:localhost}
315 topicCommInfrastructure: dmaap
316 participantSupportedElementTypes:
318 typeName: org.onap.policy.clamp.acm.PolicyAutomationCompositionElement
326 include: health, metrics, prometheus
330 context-path: /onap/policy/clamp/acm/policyparticipant
333 Navigate to the "participant/participant-impl/participant-impl-policy" directory. We can then run the policy-participant with the following command:
345 To perform the Smoke testing of the policy-participant we will be verifying the behaviours of the participant when the ACM changes state. The scenarios are:
347 - UNDEPLOYED to DEPLOYED: participant creates policies and policyTypes specified in the ToscaServiceTemplate using policy-api and deploys the policies using pap.
348 - LOCK to UNLOCK: participant changes lock state to UNLOCK. No operation performed.
349 - UNLOCK to LOCK: participant changes lock state to LOCK. No operation performed.
350 - DEPLOYED to UNDEPLOYED: participant undeploys deployed policies and deletes policies and policyTypes which have been created.
355 Creation of AC Definition:
356 **************************
357 An AC Definition is created by commissioning a Tosca template.
358 Using postman, commission a TOSCA template using the following template:
360 :download:`Tosca Service Template <tosca/tosca_service_template_pptnt_smoke.yaml>`
362 To verify this, we check that the AC Definition has been created and is in state COMMISSIONED.
364 .. image:: images/pol-part-clampacm-get-composition.png
366 Priming AC Definition:
367 **********************
368 The AC Definition state is changed from COMMISSIONED to PRIMED using postman:
373 "primeOrder": "PRIME"
377 To verify this, we check that the AC Definition has been primed.
379 .. image:: images/pol-part-clampacm-get-primed-composition.png
382 Creation of AC Instance:
383 ************************
384 Using postman, instance the AC definition using the following template:
386 :download:`Instantiate ACM <json/instantiation_pptnt_smoke.json>`
388 To verify this, we check that the AC Instance has been created and is in state UNDEPLOYED.
390 .. image:: images/pol-part-clampacm-creation-ver.png
392 Creation and deploy of policies and policyTypes:
393 ************************************************
394 The AC Instance deploy state is changed from UNDEPLOYED to DEPLOYED using postman:
399 "deployOrder": "DEPLOY"
402 This state change will trigger the creation of policies and policyTypes using the policy-api and the deployment of the policies specified in the ToscaServiceTemplate.
403 To verify this we will check, using policy-api endpoints, that the onap.policies.native.apex.ac.element policy, which is specified in the service template, has been created.
405 .. image:: images/pol-part-clampacm-ac-policy-ver.png
407 And we will check that the apex onap.policies.native.apex.ac.element policy has been deployed to the defaultGroup. We check this using pap:
409 .. image:: images/pol-part-clampacm-ac-deploy-ver.png
411 Undeployment and deletion of policies and policyTypes:
412 ******************************************************
413 The ACM STATE is changed from DEPLOYED to UNDEPLOYED using postman:
418 "deployOrder": "UNDEPLOY"
421 This state change will trigger the undeployment of the onap.policies.native.apex.ac.element policy which was deployed previously and the deletion of the previously created policies and policyTypes.
422 To verify this we do a PdpGroup Query as before and check that the onap.policies.native.apex.ac.element policy has been undeployed and removed from the defaultGroup:
424 .. image:: images/pol-part-clampacm-ac-undep-ver.png
427 As before, we can check that the Test Policy policyType is not found this time and likewise for the onap.policies.native.apex.ac.element policy:
429 .. image:: images/pol-part-clampacm-test-policy-nf.png