1 .. This work is licensed under a
2 .. Creative Commons Attribution 4.0 International License.
3 .. http://creativecommons.org/licenses/by/4.0
5 .. _policy-clamp-runtime-smoke-label:
7 CLAMP Automation Composition Smoke Tests
8 ########################################
14 This article explains how to build the CLAMP automation composition for development purposes and how to run smoke tests for automation composition. To start, the developer should consult the latest ONAP Wiki to familiarize themselves with developer best practices and how-tos to setup their environment, see `https://wiki.onap.org/display/DW/Developer+Best+Practices`.
17 This article assumes that:
19 * You are using a *\*nix* operating system such as linux or macOS.
20 * You are using a directory called *git* off your home directory *(~/git)* for your git repositories
21 * Your local maven repository is in the location *~/.m2/repository*
22 * You have copied the settings.xml from oparent to *~/.m2/* directory
23 * You have added settings to access the ONAP Nexus to your M2 configuration, see `Maven Settings Example <https://wiki.onap.org/display/DW/Setting+Up+Your+Development+Environment>`_ (bottom of the linked page)
25 The procedure documented in this article has been verified using Ubuntu 20.04 LTS VM.
27 Cloning CLAMP automation composition and all dependency
28 *******************************************************
30 Run a script such as the script below to clone the required modules from the `ONAP git repository <https://gerrit.onap.org/r/#/admin/projects/?filter=policy>`_. This script clones CLAMP automation composition and all dependency.
32 ONAP Policy Framework has dependencies to the ONAP Parent *oparent* module, the ONAP ECOMP SDK *ecompsdkos* module, and the A&AI Schema module.
36 :caption: Typical ONAP Policy Framework Clone Script
41 ## script name for output
42 MOD_SCRIPT_NAME='basename $0'
44 ## the ONAP clone directory, defaults to "onap"
47 ## the ONAP repos to clone
56 ## Help screen and exit condition (i.e. too few arguments)
61 echo "$MOD_SCRIPT_NAME - clones all required ONAP git repositories"
63 echo " Usage: $MOD_SCRIPT_NAME [-options]"
66 echo " -d - the ONAP clone directory, defaults to '.'"
67 echo " -h - this help screen"
78 #-d ONAP clone directory
82 echo "$MOD_SCRIPT_NAME: no clone directory"
89 #-h prints help and exists
93 *) echo "$MOD_SCRIPT_NAME: undefined CLI option - $1"; exit 255;;
97 if [ -f "$clone_dir" ]; then
98 echo "$MOD_SCRIPT_NAME: requested clone directory '$clone_dir' exists as file"
101 if [ -d "$clone_dir" ]; then
102 echo "$MOD_SCRIPT_NAME: requested clone directory '$clone_dir' exists as directory"
109 echo cannot clone ONAP repositories, could not create directory '"'$clone_dir'"'
113 for repo in $onap_repos
115 repoDir=`dirname "$repo"`
116 repoName=`basename "$repo"`
120 mkdir "$clone_dir/$repoDir"
123 echo cannot clone ONAP repositories, could not create directory '"'$clone_dir/repoDir'"'
128 git clone https://gerrit.onap.org/r/${repo} $clone_dir/$repo
131 echo ONAP has been cloned into '"'$clone_dir'"'
134 Execution of the script above results in the following directory hierarchy in your *~/git* directory:
138 * ~/git/onap/policy/parent
139 * ~/git/onap/policy/common
140 * ~/git/onap/policy/models
141 * ~/git/onap/policy/clamp
142 * ~/git/onap/policy/docker
145 Building CLAMP automation composition and all dependency
146 ********************************************************
148 **Step 1:** Optionally, for a completely clean build, remove the ONAP built modules from your local repository.
152 rm -fr ~/.m2/repository/org/onap
155 **Step 2:** A pom such as the one below can be used to build the ONAP Policy Framework modules. Create the *pom.xml* file in the directory *~/git/onap/policy*.
158 :caption: Typical pom.xml to build the ONAP Policy Framework
161 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
162 <modelVersion>4.0.0</modelVersion>
163 <groupId>org.onap</groupId>
164 <artifactId>onap-policy</artifactId>
165 <version>1.0.0-SNAPSHOT</version>
166 <packaging>pom</packaging>
167 <name>${project.artifactId}</name>
168 <inceptionYear>2017</inceptionYear>
174 <module>parent</module>
175 <module>common</module>
176 <module>models</module>
177 <module>clamp</module>
182 **Step 3:** You can now build the Policy framework.
184 Build java artifacts only:
189 mvn -pl '!org.onap.policy.clamp:policy-clamp-runtime' install
191 Build with docker images:
195 cd ~/git/onap/policy/clamp/packages/
196 mvn clean install -P docker
198 Running MariaDb and DMaaP Simulator
199 ***********************************
201 Running a MariaDb Instance
202 ++++++++++++++++++++++++++
204 Assuming you have successfully built the codebase using the instructions above. There are two requirements for the Clamp automation composition component to run, one of them is a
205 running MariaDb database instance. The easiest way to do this is to run the docker image locally.
207 A sql such as the one below can be used to build the SQL initialization. Create the *mariadb.sql* file in the directory *~/git*.
211 create database clampacm;
212 CREATE USER 'policy'@'%' IDENTIFIED BY 'P01icY';
213 GRANT ALL PRIVILEGES ON clampacm.* TO 'policy'@'%';
216 Execution of the command above results in the creation and start of the *mariadb-smoke-test* container.
221 docker run --name mariadb-smoke-test \
223 -e MYSQL_ROOT_PASSWORD=my-secret-pw \
224 --mount type=bind,source=~/git/mariadb.sql,target=/docker-entrypoint-initdb.d/data.sql \
228 Running the DMaaP Simulator during Development
229 ++++++++++++++++++++++++++++++++++++++++++++++
230 The second requirement for the Clamp automation composition component to run is to run the DMaaP simulator. You can run it from the command line using Maven.
233 Change the local configuration file *src/test/resources/simParameters.json* using the below code:
239 "name": "DMaaP simulator",
244 "name": "DMaaP simulator",
245 "providerClass": "org.onap.policy.models.sim.dmaap.rest.DmaapSimRestControllerV1",
253 Run the following commands:
257 cd ~/git/onap/policy/models/models-sim/policy-models-simulators
258 mvn exec:java -Dexec.mainClass=org.onap.policy.models.simulators.Main -Dexec.args="src/test/resources/simParameters.json"
261 Developing and Debugging CLAMP automation composition
262 *****************************************************
264 Running on the Command Line using Maven
265 +++++++++++++++++++++++++++++++++++++++
267 Once the mariadb and DMaap simulator are up and running, run the following commands:
271 cd ~/git/onap/policy/clamp/runtime-acm
275 Running on the Command Line
276 +++++++++++++++++++++++++++
280 cd ~/git/onap/policy/clamp/runtime-acm
281 java -jar target/policy-clamp-runtime-acm-6.2.2-SNAPSHOT.jar
287 1. Check out the policy models repository
288 2. Go to the *policy-clamp-runtime-acm* module in the clamp repo
289 3. Specify a run configuration using the class *org.onap.policy.clamp.acm.runtime.Application* as the main class
290 4. Run the configuration
292 Swagger UI of Automation composition is available at *http://localhost:6969/onap/policy/clamp/acm/swagger-ui/*, and swagger JSON at *http://localhost:6969/onap/policy/clamp/acm/v2/api-docs/*
295 Running one or more participant simulators
296 ++++++++++++++++++++++++++++++++++++++++++
298 Into *docker\csit\clamp\tests\data* you can find a test case with policy-participant. In order to use that test you can use particpant-simulator.
299 Copy the file *src/main/resources/config/application.yaml* and paste into *src/test/resources/*, after that change *participantId* and *participantType* as showed below:
304 name: org.onap.PM_Policy
307 name: org.onap.policy.clamp.acm.PolicyParticipant
310 Run the following commands:
314 cd ~/git/onap/policy/clamp/participant/participant-impl/participant-impl-simulator
315 java -jar target/policy-clamp-participant-impl-simulator-6.2.2-SNAPSHOT.jar --spring.config.location=src/main/resources/config/application.yaml
318 Creating self-signed certificate
319 ++++++++++++++++++++++++++++++++
321 There is an additional requirement for the Clamp automation composition docker image to run, is creating the SSL self-signed certificate.
323 Run the following commands:
327 cd ~/git/onap/policy/docker/csit/
331 Execution of the commands above results additional files into the following directory *~/git/onap/policy/docker/csit/config*:
333 * ~/git/onap/policy/docker/csit/config/cakey.pem
334 * ~/git/onap/policy/docker/csit/config/careq.pem
335 * ~/git/onap/policy/docker/csit/config/caroot.cer
336 * ~/git/onap/policy/docker/csit/config/ks.cer
337 * ~/git/onap/policy/docker/csit/config/ks.csr
338 * ~/git/onap/policy/docker/csit/config/ks.jks
341 Running the CLAMP automation composition docker image
342 +++++++++++++++++++++++++++++++++++++++++++++++++++++
344 Run the following command:
348 docker run --name runtime-smoke-test \
350 -e mariadb.host=host.docker.internal \
351 -e topicServer=host.docker.internal \
352 --mount type=bind,source=~/git/onap/policy/docker/csit/config/ks.jks,target=/opt/app/policy/clamp/etc/ssl/policy-keystore \
353 --mount type=bind,source=~/git/onap/policy/clamp/runtime-acm/src/main/resources/application.yaml,target=/opt/app/policy/clamp/etc/AcRuntimeParameters.yaml \
354 onap/policy-clamp-runtime-acm
357 Swagger UI of automation composition is available at *https://localhost:6969/onap/policy/clamp/acm/swagger-ui/*, and swagger JSON at *https://localhost:6969/onap/policy/clamp/acm/v2/api-docs/*
360 Using CLAMP runtime to connect to CLAMP automation composition
361 **************************************************************
363 Build CLAMP runtime image:
367 cd ~/git/onap/policy/clamp/runtime
368 mvn clean install -P docker -DskipTests
371 Run the following docker composition:
379 image: mariadb:10.5.8
381 - "~/git/onap/policy/clamp/runtime/extra/sql/:/docker-entrypoint-initdb.d:rw"
383 - MYSQL_ROOT_PASSWORD=strong_pitchou
387 policy-clamp-backend:
388 image: onap/policy-clamp-backend
393 - SPRING_DATASOURCE_URL=jdbc:mariadb:sequential://db:3306/cldsdb4?autoReconnect=true&connectTimeout=10000&socketTimeout=10000&retriesAllDown=3
394 - SPRING_PROFILES_ACTIVE=clamp-default,clamp-default-user,clamp-sdc-controller,clamp-ssl-config,clamp-policy-controller,default-dictionary-elements
395 - CLAMP_CONFIG_POLICY_API_URL=http://third-party-proxy:8085
396 - CLAMP_CONFIG_ACM_RUNTIME_URL=http://host.docker.internal:6969
397 - CLAMP_CONFIG_POLICY_PAP_URL=http://third-party-proxy:8085
398 - CLAMP_CONFIG_DCAE_INVENTORY_URL=http://third-party-proxy:8085
399 - CLAMP_CONFIG_DCAE_DEPLOYMENT_URL=http://third-party-proxy:8085
400 - SPRING_CONFIG_LOCATION=classpath:/application.properties
407 - "~/git/onap/policy/clamp/runtime/src/test/resources/http-cache/example/:/thirdparty:rw"
408 - "~/git/onap/policy/clamp/runtime/src/test/resources/http-cache/:/script/:ro"
411 command: /bin/sh -c "pip install --no-cache-dir requests && pip install --no-cache-dir simplejson && python -u /script/third_party_proxy.py -v true --port 8085 --root /thirdparty --proxyaddress third-party-proxy:8085"
414 Run DMaaP simulator, and then run CLAMP Acm using java.