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/repos/q/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
55 ## Help screen and exit condition (i.e. too few arguments)
60 echo "$MOD_SCRIPT_NAME - clones all required ONAP git repositories"
62 echo " Usage: $MOD_SCRIPT_NAME [-options]"
65 echo " -d - the ONAP clone directory, defaults to '.'"
66 echo " -h - this help screen"
77 #-d ONAP clone directory
81 echo "$MOD_SCRIPT_NAME: no clone directory"
88 #-h prints help and exists
92 *) echo "$MOD_SCRIPT_NAME: undefined CLI option - $1"; exit 255;;
96 if [ -f "$clone_dir" ]; then
97 echo "$MOD_SCRIPT_NAME: requested clone directory '$clone_dir' exists as file"
100 if [ -d "$clone_dir" ]; then
101 echo "$MOD_SCRIPT_NAME: requested clone directory '$clone_dir' exists as directory"
108 echo cannot clone ONAP repositories, could not create directory '"'$clone_dir'"'
112 for repo in $onap_repos
114 repoDir=`dirname "$repo"`
115 repoName=`basename "$repo"`
119 mkdir "$clone_dir/$repoDir"
122 echo cannot clone ONAP repositories, could not create directory '"'$clone_dir/repoDir'"'
127 git clone https://gerrit.onap.org/r/${repo} $clone_dir/$repo
130 echo ONAP has been cloned into '"'$clone_dir'"'
133 Execution of the script above results in the following directory hierarchy in your *~/git* directory:
137 * ~/git/onap/policy/parent
138 * ~/git/onap/policy/common
139 * ~/git/onap/policy/models
140 * ~/git/onap/policy/clamp
143 Building CLAMP automation composition and all dependency
144 ********************************************************
146 **Step 1:** Optionally, for a completely clean build, remove the ONAP built modules from your local repository.
150 rm -fr ~/.m2/repository/org/onap
153 **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*.
156 :caption: Typical pom.xml to build the ONAP Policy Framework
159 <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">
160 <modelVersion>4.0.0</modelVersion>
161 <groupId>org.onap</groupId>
162 <artifactId>onap-policy</artifactId>
163 <version>1.0.0-SNAPSHOT</version>
164 <packaging>pom</packaging>
165 <name>${project.artifactId}</name>
166 <inceptionYear>2023</inceptionYear>
172 <module>parent</module>
173 <module>common</module>
174 <module>models</module>
175 <module>clamp</module>
180 **Step 3:** You can now build the Policy framework.
182 Build java artifacts only:
189 Build with docker images:
193 cd ~/git/onap/policy/clamp/packages/
194 mvn clean install -P docker
196 cd ~/git/onap/policy/models/models-sim/packages
197 mvn clean install -P docker
199 Running MariaDb and DMaaP Simulator
200 ***********************************
202 Running a MariaDb Instance
203 ++++++++++++++++++++++++++
205 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
206 running MariaDb database instance. The easiest way to do this is to run the docker image locally.
208 A sql such as the one below can be used to build the SQL initialization. Create the *mariadb.sql* file in the directory *~/git*.
212 create database clampacm;
213 CREATE USER 'policy'@'%' IDENTIFIED BY 'P01icY';
214 GRANT ALL PRIVILEGES ON clampacm.* TO 'policy'@'%';
217 Execution of the command above results in the creation and start of the *mariadb-smoke-test* container.
222 docker run --name mariadb-smoke-test \
224 -e MYSQL_ROOT_PASSWORD=my-secret-pw \
225 --mount type=bind,source=$HOME/git/mariadb.sql,target=/docker-entrypoint-initdb.d/data.sql \
227 --lower-case-table-names=1
230 Running the DMaaP Simulator during Development
231 ++++++++++++++++++++++++++++++++++++++++++++++
232 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.
235 Create a new configuration file *~/git/onap/policy/models/models-sim/policy-models-simulators/src/test/resources/newParameters.json* using the below code:
241 "name": "DMaaP simulator",
246 "name": "DMaaP simulator",
247 "providerClass": "org.onap.policy.models.sim.dmaap.rest.DmaapSimRestControllerV1",
255 Run the following commands:
259 cd ~/git/onap/policy/models/models-sim/policy-models-simulators
260 mvn exec:java -Dexec.mainClass=org.onap.policy.models.simulators.Main -Dexec.args="src/test/resources/newParameters.json"
263 Developing and Debugging CLAMP automation composition
264 *****************************************************
266 Running on the Command Line using Maven
267 +++++++++++++++++++++++++++++++++++++++
269 Once the mariadb and DMaap simulator are up and running, run the following commands:
273 cd ~/git/onap/policy/clamp/runtime-acm
277 Running on the Command Line
278 +++++++++++++++++++++++++++
282 cd ~/git/onap/policy/clamp/runtime-acm
283 java -jar target/policy-clamp-runtime-acm-6.4.2-SNAPSHOT.jar
289 1. Check out the policy models repository
290 2. Go to the *policy-clamp-runtime-acm* module in the clamp repo
291 3. Where necessary Add as Source Folder 'target/generated-sources/swagger'
292 4. Specify a run configuration using the class *org.onap.policy.clamp.acm.runtime.Application* as the main class
293 5. Run the configuration
295 Swagger UI of Automation composition is available at *http://localhost:6969/onap/policy/clamp/acm/swagger-ui/index.html*
298 Running one or more participants
299 ++++++++++++++++++++++++++++++++
301 Into :ref:`HTTP Participant <clamp-acm-http-participant>` you can find a test case with http-participant.
303 Run the following commands:
307 cd ~/git/onap/policy/clamp/participant/participant-impl/participant-impl-http
308 java -jar target/policy-clamp-participant-impl-http-6.4.2-SNAPSHOT.jar
311 Running the CLAMP automation composition docker image
312 +++++++++++++++++++++++++++++++++++++++++++++++++++++
314 Create the '*docker-composition.yaml*' using following code:
322 image: mariadb:10.10.2
325 source: ./mariadb.sql
326 target: /docker-entrypoint-initdb.d/data.sql
328 - MYSQL_ROOT_PASSWORD=my-secret-pw
329 - lower-case-table-names=1
334 image: onap/policy-clamp-runtime-acm
336 - mariadb.host=mariadb
337 - topicServer=message-router
340 source: ./onap/policy/clamp/runtime-acm/src/main/resources/application.yaml
341 target: /opt/app/policy/clamp/etc/AcRuntimeParameters.yaml
346 image: onap/policy-models-simulator
349 source: ./onap/policy/models/models-sim/policy-models-simulators/src/test/resources/newParameters.json
350 target: /opt/app/policy/simulators/etc/mounted/simParameters.json
354 Run the docker composition:
362 Swagger UI of automation composition is available at *http://localhost:6969/onap/policy/clamp/acm/swagger-ui/index.html*