Building and running CLAMP
This page is Work in Progress
This page is not updated for Istanbul, the information below this point may or may not be correct for Istanbul.
This page documents how to get CLAMP up and running on a local machine and also how to get CLAMP loaded and set up in an IDE. We may use the information on this page as input for a page in the CLAMP documentation.
Checking out and building CLAMP
Check CLAMP out of its repo
git clone "https://gerrit.onap.org/r/clamp"
Change into the "clamp" directory
Build CLAMP
mvn clean install
You may get the following error (See CLAMP-944: CLAMP build fails with python timeout in dockerOpen)
[ERROR] DOCKER> I/O Error [[docker.io/python:2-slim] "python": Timeout after 120088 ms while waiting on tcp port '[/172.17.0.3:8080]']
If so, then run the following command to skip integration tests
mvn clean install -DskipITs
Getting CLAMP set up locally in your IDE
Import the CLAMP project into your IDE
Eclipse only: Add the following Eclipse profile to pom.xml for Eclipse m2e support, then run Maven->Update
<profile> <!--This profile is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. --> <id>only-eclipse</id> <activation> <property> <name>m2e.version</name> </property> </activation> <build> <pluginManagement> <plugins> <plugin> <groupId>org.eclipse.m2e</groupId> <artifactId>lifecycle-mapping</artifactId> <version>1.0.0</version> <configuration> <lifecycleMappingMetadata> <pluginExecutions> <pluginExecution> <pluginExecutionFilter> <groupId>de.jpdigital</groupId> <artifactId>hibernate52-ddl-maven-plugin</artifactId> <versionRange>[2.2.0,)</versionRange> <goals> <goal>gen-ddl</goal> </goals> </pluginExecutionFilter> <action> <execute /> </action> </pluginExecution> <pluginExecution> <pluginExecutionFilter> <groupId>org.codehaus.groovy.maven</groupId> <artifactId>gmaven-plugin</artifactId> <versionRange>[1.0,)</versionRange> <goals> <goal>execute</goal> </goals> </pluginExecutionFilter> <action> <execute /> </action> </pluginExecution> <pluginExecution> <pluginExecutionFilter> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <versionRange>[1.3.2,)</versionRange> <goals> <goal>exec</goal> </goals> </pluginExecutionFilter> <action> <execute /> </action> </pluginExecution> <pluginExecution> <pluginExecutionFilter> <groupId>com.github.eirslett</groupId> <artifactId>frontend-maven-plugin</artifactId> <versionRange>[1.8.0,)</versionRange> <goals> <goal>npm</goal> </goals> </pluginExecutionFilter> <action> <execute /> </action> </pluginExecution> </pluginExecutions> </lifecycleMappingMetadata> </configuration> </plugin> </plugins> </pluginManagement> </build> </profile>
Running unit tests locally
In order to run the unit tests locally, you need to run an instance of MariaDB and an instance of the emulator for the REST endpoints CLAMP uses. You also need to set the values some variables in a number of configuration files. These values are automatically generated in the maven build but need to be set manually when running tests locally.
If you follow the steps here, all the tests will pass in a Linux environment. In Windows and Mac environments, the Robot test case will not pass because Host Networking is not supported in Docker on WIndows and Mac. The robot test framework cannot reach "localhost" endpoints on the host machine.
Open a console and go into the directory extra/bin-for-dev
cd extra/bin-for-dev
Start an instance of the CLAMP MaraDB database in Docker using the helper script. This script uses docker-compose to bring up an instance of the CLAMP MariaDB.
./start-db.sh
Start an instance of the CLAMP endpoint emulator in Docker using the helper script. This script uses docker-compose to bring up an instance of the CLAMP endpoint emulator.
./start-emulator.sh
Check that the database and emulator are running
docker ps
You should see the two images running
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 93cffd7e7d2e python:2-slim "/bin/sh -c 'pip ins…" 7 seconds ago Up 7 seconds 0.0.0.0:8085->8085/tcp clamp_third-party-proxy_1 0b26d68f4048 mariadb:10.5.4 "docker-entrypoint.s…" About a minute ago Up About a minute 0.0.0.0:3306->3306/tcp clamp_db_1
In the file src/test/resources/application.properties, run this sed command or make the changes below in a text editor:
sed -e 's/${clamp\.it\.tests\.http}/8080/g' -e 's/${docker\.http-cache\.port\.host}/8085/g' -e 's/${docker\.mariadb\.port\.host}/3306/g' -i src/test/resources/application.properties
Change all occurrences of the string "${clamp.it.tests.http}" to "8080"
Change all occurrences of the string "${docker.http-cache.port.host}" to "8085"
Change all occurrences of the string "${docker.mariadb.port.host}" to "3306"
In the file src/test/resources/https/https-test.properties, run this sed command or make the changes below in a text editor:
sed -e 's/${clamp\.it\.tests\.https}/8090/g' -e 's/${clamp\.it\.tests\.http-redirected}/8080/g' -e 's/${docker\.mariadb\.port\.host}/3306/g' -i src/test/resources/https/https-test.properties
In the file src/test/resources/robotframework/robotframework-test.properties, run this sed command or make the changes below in a text editor:
sed -e 's/${clamp\.it\.tests\.robotframework\.http}/8080/g' -e 's/${docker\.http-cache\.port\.host}/8085/g' -e 's/${docker\.mariadb\.port\.host}/3306/g' -i src/test/resources/robotframework/robotframework-test.properties
Change all occurrences of the string "${clamp.it.tests.robotframework.http}" to "8080" (Any free port value)
Change all occurrences of the string "${docker.http-cache.port.host}" to "8085"
Change all occurrences of the string "${docker.mariadb.port.host}" to "3306"
Building ControlLoop docker images in CLAMP
Control loop docker images are built in clamp/packages and pushed to ONAP nexus docker registry nexus3.onap.org:10003
using maven command.
Steps are depicted as below:
Open a console and go into the directory clamp/packages
$cd clamp/packages
Run below command
$mvn clean install -P docker
Note: This command when run from clamp main directory will build all docker images of Clamp. When run in clamp/packages folder will build
ControlLoop docker images alone.There is a fabric8, docker-maven-plugin in clamp/packages/policy-clamp-docker/pom.xml which builds 3 docker images and pushes to ONAP nexus docker registry nexus3.onap.org:10003
onap/policy-clamp-cl-runtime onap/policy-clamp-cl-k8s-ppnt onap/policy-clamp-cl-http-ppnt onap/policy-clamp-cl-pf-ppnt
Configuration to build docker images is present in following files
$cd clamp/packages/policy-clamp-docker/src/main/docker
Docker images once built can be brought up manually on localhost using docker commands, or through docker-compose in CSIT
Clone policy docker repo$cd docker/csit/ $./run-project-csit.sh clamp
Note: More detailed information on CSIT is in Testing CLAMP
Docker images from docker-compose file in /policy/docker/csit for clamp
$docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES b2266ab66cbc onap/policy-clamp-cl-runtime:latest "/opt/app/policy/bin…" 28 seconds ago Up 27 seconds 6970/tcp policy-controlloop-runtime c6475277e750 policy-clamp-cl-pf-ppnt:latest "/opt/app/policy/bin…" 29 seconds ago Up 28 seconds 6972/tcp policy-participant 5a83596fd963 nexus3.onap.org:10001/onap/policy-api:2.5-SNAPSHOT-latest "./wait_for_port.sh …" 30 seconds ago Up 29 seconds 6969/tcp policy-api 77746467d139 onap/policy-clamp-cl-k8s-ppnt:latest "/opt/app/policy/bin…" 30 seconds ago Up 29 seconds 6971/tcp kubernetes-participant 6053cdad35fd nexus3.onap.org:10001/onap/policy-models-simulator:2.5-SNAPSHOT-latest "bash simulators.sh" 31 seconds ago Up 30 seconds 3905/tcp, 6666/tcp, 6668-6670/tcp simulator 17cf42071531 nexus3.onap.org:10001/mariadb:10.5.8 "docker-entrypoint.s…" 32 seconds ago Up 30 seconds 3306/tcp mariadb