blob: 58e3449441d0af212a2e137ebe8433b31c9a1f4e [file] [log] [blame]
FrancescoFioraEstad9a1e82023-04-14 14:05:31 +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------------------------------------
7
81. Introduction
9***************
10
11The 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.
12All applications will be running by console, so they need to run with different ports. Configuration files should be changed accordingly.
13
14+------------------------------+------+
15| Application | port |
16+==============================+======+
17| MariDB | 3306 |
18+------------------------------+------+
19| DMaaP simulator | 3904 |
20+------------------------------+------+
21| policy-api | 6968 |
22+------------------------------+------+
23| policy-pap | 6970 |
24+------------------------------+------+
25| policy-clamp-runtime-acm | 6969 |
26+------------------------------+------+
27| onap/policy-clamp-ac-pf-ppnt | 8085 |
28+------------------------------+------+
29
30
312. Setup Guide
32**************
33
34This 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.
35
362.1 Prerequisites
37=================
38
39- Java 11
40- Maven 3
41- Git
42- Refer to this guide for basic environment setup `Setting up dev environment <https://wiki.onap.org/display/DW/Setting+Up+Your+Development+Environment>`_
43
442.2 Assumptions
45===============
46
47- You are accessing the policy repositories through gerrit
48- You are using "git review".
49
50The 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.
51
52- policy/parent
53- policy/common
54- policy/models
55- policy/clamp
56- policy/api
57- policy/pap
58
59In this setup guide, we will be setting up all the components technically required for a working convenient dev environment.
60
612.3 Setting up the components
62=============================
63
642.3.1 MariaDB Setup
65^^^^^^^^^^^^^^^^^^^
66
67We will be using Docker to run our mariadb instance. It will have a total of two databases running in it.
68
69- clampacm: the policy-clamp-runtime-acm db
70- policyadmin: the policy-api db
71
72A sql such as the one below can be used to build the SQL initialization. Create the *mariadb.sql* file in a directory *PATH_DIRECTORY*.
73
74 .. code-block:: SQL
75
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'@'%';
82 FLUSH PRIVILEGES;
83
84
85Execution of the command above results in the creation and start of the *mariadb-smoke-test* container.
86
87 .. code-block:: bash
88
89 docker run --name mariadb-smoke-test \
90 -p 3306:3306 \
91 -e MYSQL_ROOT_PASSWORD=my-secret-pw \
92 --mount type=bind,source=PATH_DIRECTORY/mariadb.sql,target=/docker-entrypoint-initdb.d/data.sql \
93 -d mariadb:10.10.2 \
94 --lower-case-table-names=1
95
96This will setup the two databases needed. The database will be exposed locally on port 3306.
97
982.3.2 DMAAP Simulator
99^^^^^^^^^^^^^^^^^^^^^
100
101For convenience, a dmaap simulator has been provided in the policy/models repository. To start the simulator, you can do the following:
102
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:
105
106.. code-block:: json
107
108 {
109 "dmaapProvider":{
110 "name":"DMaaP simulator",
111 "topicSweepSec":900
112 },
113 "restServers":[
114 {
115 "name":"DMaaP simulator",
116 "providerClass":"org.onap.policy.models.sim.dmaap.rest.DmaapSimRestControllerV1",
117 "host":"localhost",
118 "port":3904,
119 "https":false
120 }
121 ]
122 }
123
1243. You can then start dmaap with:
125
126.. code-block:: bash
127
128 mvn exec:java -Dexec.mainClass=org.onap.policy.models.simulators.Main -Dexec.args="src/test/resources/YOUR_CONF_FILE.json"
129
130At this stage the dmaap simulator should be running on your local machine on port 3904.
131
1322.3.3 Policy API
133^^^^^^^^^^^^^^^^
134
135Navigate to the "/main" directory. You can then run the following command to start the policy api:
136
137.. code-block:: bash
138
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
140
141
1422.3.4 Policy PAP
143^^^^^^^^^^^^^^^^
144
145In 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:
146
147.. code-block:: yaml
148
149 spring:
150 security:
151 user:
152 name: policyadmin
153 password: zb!XztG34
154 http:
155 converters:
156 preferred-json-mapper: gson
157 datasource:
158 url: jdbc:mariadb://localhost:3306/policyadmin
159 driverClassName: org.mariadb.jdbc.Driver
160 username: policy_user
161 password: policy_user
162 jpa:
163 properties:
164 hibernate:
165 dialect: org.hibernate.dialect.MariaDB103Dialect
166 hibernate:
167 ddl-auto: update
168 naming:
169 physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
170 implicit-strategy: org.onap.policy.common.spring.utils.CustomImplicitNamingStrategy
171
172 server:
173 port: 6970
174 servlet:
175 context-path: /policy/pap/v1
176 pap:
177 name: PapGroup
178 aaf: false
179 topic:
180 pdp-pap.name: POLICY-PDP-PAP
181 notification.name: POLICY-NOTIFICATION
182 heartbeat.name: POLICY-HEARTBEAT
183 pdpParameters:
184 heartBeatMs: 120000
185 updateParameters:
186 maxRetryCount: 1
187 maxWaitMs: 30000
188 stateChangeParameters:
189 maxRetryCount: 1
190 maxWaitMs: 30000
191 savePdpStatisticsInDb: true
192 topicParameterGroup:
193 topicSources:
194 - topic: ${pap.topic.pdp-pap.name}
195 servers:
196 - localhost
197 topicCommInfrastructure: dmaap
198 fetchTimeout: 15000
199 - topic: ${pap.topic.heartbeat.name}
200 effectiveTopic: ${pap.topic.pdp-pap.name}
201 consumerGroup: policy-pap
202 servers:
203 - localhost
204 topicCommInfrastructure: dmaap
205 fetchTimeout: 15000
206 topicSinks:
207 - topic: ${pap.topic.pdp-pap.name}
208 servers:
209 - localhost
210 topicCommInfrastructure: dmaap
211 - topic: ${pap.topic.notification.name}
212 servers:
213 - localhost
214 topicCommInfrastructure: dmaap
215 healthCheckRestClientParameters:
216 - clientName: api
217 hostname: localhost
218 port: 6968
219 userName: policyadmin
220 password: zb!XztG34
221 useHttps: false
222 basePath: policy/api/v1/healthcheck
223 - clientName: distribution
224 hostname: policy-distribution
225 port: 6969
226 userName: healthcheck
227 password: zb!XztG34
228 useHttps: false
229 basePath: healthcheck
230 - clientName: dmaap
231 hostname: localhost
232 port: 3904
233 useHttps: false
234 basePath: topics
235
236 management:
237 endpoints:
238 web:
239 base-path: /
240 exposure:
241 include: health, metrics, prometheus
242 path-mapping.metrics: plain-metrics
243 path-mapping.prometheus: metrics
244
245Next, navigate to the "/main" directory. You can then run the following command to start the policy pap
246
247.. code-block:: bash
248
249 mvn spring-boot:run
250
2512.3.5 ACM Runtime
252^^^^^^^^^^^^^^^^^
253
254To 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:
255
256.. code-block:: bash
257
258 mvn spring-boot:run
259
2602.3.6 ACM Policy Participant
261^^^^^^^^^^^^^^^^^^^^^^^^^^^^
262
263To 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:
264
265.. code-block:: yaml
266
267 spring:
268 security:
269 user:
270 name: participantUser
271 password: zb!XztG34
272 autoconfigure:
273 exclude:
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
278
279 participant:
280 pdpGroup: defaultGroup
281 pdpType: apex
282 policyApiParameters:
283 clientName: api
284 hostname: localhost
285 port: 6968
286 userName: policyadmin
287 password: zb!XztG34
288 useHttps: false
289 allowSelfSignedCerts: true
290 policyPapParameters:
291 clientName: pap
292 hostname: localhost
293 port: 6970
294 userName: policyadmin
295 password: zb!XztG34
296 useHttps: false
297 allowSelfSignedCerts: true
298 intermediaryParameters:
299 reportingTimeIntervalMs: 120000
300 description: Participant Description
301 participantId: 101c62b3-8918-41b9-a747-d21eb79c6c03
302 clampAutomationCompositionTopics:
303 topicSources:
304 -
305 topic: POLICY-ACRUNTIME-PARTICIPANT
306 servers:
307 - ${topicServer:localhost}
308 topicCommInfrastructure: dmaap
309 fetchTimeout: 15000
310 topicSinks:
311 -
312 topic: POLICY-ACRUNTIME-PARTICIPANT
313 servers:
314 - ${topicServer:localhost}
315 topicCommInfrastructure: dmaap
316 participantSupportedElementTypes:
317 -
318 typeName: org.onap.policy.clamp.acm.PolicyAutomationCompositionElement
319 typeVersion: 1.0.0
320
321 management:
322 endpoints:
323 web:
324 base-path: /
325 exposure:
326 include: health, metrics, prometheus
327 server:
328 port: 8085
329 servlet:
330 context-path: /onap/policy/clamp/acm/policyparticipant
331
332
333Navigate to the "participant/participant-impl/participant-impl-policy" directory. We can then run the policy-participant with the following command:
334
335.. code-block:: bash
336
337 mvn spring-boot:run
338
3393. Testing Procedure
340====================
341
3423.1 Testing Outline
343^^^^^^^^^^^^^^^^^^^
344
345To 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:
346
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.
351
3523.2 Testing Steps
353^^^^^^^^^^^^^^^^^
354
355Creation of AC Definition:
356**************************
357An AC Definition is created by commissioning a Tosca template.
358Using postman, commission a TOSCA template using the following template:
359
360:download:`Tosca Service Template <tosca/tosca_service_template_pptnt_smoke.yaml>`
361
362To verify this, we check that the AC Definition has been created and is in state COMMISSIONED.
363
364 .. image:: images/pol-part-clampacm-get-composition.png
365
366Priming AC Definition:
367**********************
368The AC Definition state is changed from COMMISSIONED to PRIMED using postman:
369
370.. code-block:: json
371
372 {
373 "primeOrder": "PRIME"
374 }
375
376
377To verify this, we check that the AC Definition has been primed.
378
379 .. image:: images/pol-part-clampacm-get-primed-composition.png
380
381
382Creation of AC Instance:
383************************
384Using postman, instance the AC definition using the following template:
385
386:download:`Instantiate ACM <json/instantiation_pptnt_smoke.json>`
387
388To verify this, we check that the AC Instance has been created and is in state UNDEPLOYED.
389
390 .. image:: images/pol-part-clampacm-creation-ver.png
391
392Creation and deploy of policies and policyTypes:
393************************************************
394The AC Instance deploy state is changed from UNDEPLOYED to DEPLOYED using postman:
395
396.. code-block:: json
397
398 {
399 "deployOrder": "DEPLOY"
400 }
401
402This state change will trigger the creation of policies and policyTypes using the policy-api and the deployment of the policies specified in the ToscaServiceTemplate.
403To 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.
404
405 .. image:: images/pol-part-clampacm-ac-policy-ver.png
406
407And we will check that the apex onap.policies.native.apex.ac.element policy has been deployed to the defaultGroup. We check this using pap:
408
409 .. image:: images/pol-part-clampacm-ac-deploy-ver.png
410
411Undeployment and deletion of policies and policyTypes:
412******************************************************
413The ACM STATE is changed from DEPLOYED to UNDEPLOYED using postman:
414
415.. code-block:: json
416
417 {
418 "deployOrder": "UNDEPLOY"
419 }
420
421This 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.
422To 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:
423
424 .. image:: images/pol-part-clampacm-ac-undep-ver.png
425
426
427As 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:
428
429 .. image:: images/pol-part-clampacm-test-policy-nf.png