CLAMP Automation Composition Smoke Tests

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.

This article assumes that:

  • You are using a *nix operating system such as linux or macOS.

  • You are using a directory called git off your home directory (~/git) for your git repositories

  • Your local maven repository is in the location ~/.m2/repository

  • You have copied the settings.xml from oparent to ~/.m2/ directory

  • You have added settings to access the ONAP Nexus to your M2 configuration, see Maven Settings Example (bottom of the linked page)

The procedure documented in this article has been verified using Ubuntu 20.04 LTS VM.

Cloning CLAMP automation composition

Run the below command to clone the required CLAMP automation composition:

cd ~/git
git clone https://gerrit.onap.org/r/policy/clamp clamp

Execution of the command above results in the following directory hierarchy in your ~/git directory:

  • ~/git/clamp

Building CLAMP automation composition

Step 1: Optionally, for a completely clean build, remove the ONAP built modules from your local repository.

rm -fr ~/.m2/repository/org/onap

Step 2: You can now build the Policy framework.

Build java artifacts and docker images:

cd ~/git/clamp
mvn clean install -P docker -DskipTests

Running Postgres and Kafka

Assuming you have successfully built the codebase using the instructions above. There are two requirements for the Clamp automation composition component to run, Postgres database and Kafka/Zookeeper. The easiest way to do this is to run a docker compose locally.

Create the db-pg.conf and db-pg.sh files in the directory ~/git.

# Copyright (C) 2022, 2024,2026 OpenInfra Foundation Europe. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

PGSQL_ROOT_PASSWORD=secret
PGSQL_USER=policy_user
PGSQL_PASSWORD=policy_user
PGPASSWORD=policy_user
POSTGRES_PASSWORD=policy_user
# Copyright (C) 2022, 2024,2026 OpenInfra Foundation Europe. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

psql -U postgres -d postgres --command "CREATE USER ${PGSQL_USER} WITH PASSWORD '${PGSQL_PASSWORD}';"

for db in migration policyadmin operationshistory clampacm
do
    psql -U postgres -d postgres --command "CREATE DATABASE ${db};"
    psql -U postgres -d postgres --command "ALTER DATABASE ${db} OWNER TO ${PGSQL_USER} ;"
    psql -U postgres -d postgres --command "GRANT ALL PRIVILEGES ON DATABASE ${db} TO ${PGSQL_USER} ;"
done

Create the ‘docker-compose.yaml’ using following code:

services:
  postgres:
    image: nexus3.onap.org:10001/library/postgres:latest
    container_name: postgres
    hostname: postgres
    command: [ '--idle_in_transaction_session_timeout=28800' ]
    env_file: ./db-pg.conf
    volumes:
      - ./db-pg.sh:/docker-entrypoint-initdb.d/db-pg.sh:ro
    expose:
      - 5432
    ports:
      - "5432:5432"

  zookeeper:
    image: nexus3.onap.org:10001/confluentinc/cp-zookeeper:latest
    environment:
      ZOOKEEPER_CLIENT_PORT: 2181
      ZOOKEEPER_TICK_TIME: 2000
    ports:
      - 2181:2181

  kafka:
    image: nexus3.onap.org:10001/confluentinc/cp-kafka:7.4.9
    container_name: kafka
    depends_on:
      - zookeeper
    ports:
      - 29092:29092
      - 9092:9092
    environment:
      KAFKA_BROKER_ID: 1
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,PLAINTEXT_HOST://localhost:29092
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
      KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1

Run the docker composition:

cd ~/git/
docker compose up

Developing and Debugging CLAMP automation composition

Running ACM-R on the Command Line

cd ~/git/clamp/runtime-acm
java -DRUNTIME_USER=runtimeUser -DRUNTIME_PASSWORD=zb\!XztG34 \
     -DSQL_HOST=localhost -DSQL_PORT=5432 -DSQL_USER=policy_user -DSQL_PASSWORD=policy_user \
     -DKAFKA_SERVER=localhost:29092 -DTOPIC_COMM_INFRASTRUCTURE=kafka \
     -jar target/policy-clamp-runtime-acm-9.0.1-SNAPSHOT.jar

Running participant simulator

Run the following commands:

cd ~/git/clamp/participant/participant-impl/participant-impl-simulator
java -Dserver.port=8085 -DHTTP_USER=participantUser -DHTTP_PASSWORD=zb\!XztG34 \
     -DkafkaServer=localhost:29092 -DtopicCommInfrastructure=kafka \
     -DparticipantId=101c62b3-8918-41b9-a747-d21eb79c6c90 \
     -DapplicationName=sim-ppnt -DgroupId=policy-clamp-ac-sim-ppnt \
     -jar target/policy-clamp-participant-impl-simulator-9.0.1-SNAPSHOT.jar

Running the CLAMP automation composition docker image

Create the ‘docker-compose.yaml’ using following code:

services:
  postgres:
    image: nexus3.onap.org:10001/library/postgres:latest
    container_name: postgres
    hostname: postgres
    command: [ '--idle_in_transaction_session_timeout=28800' ]
    env_file: ./db-pg.conf
    volumes:
      - ./db-pg.sh:/docker-entrypoint-initdb.d/db-pg.sh:ro
    expose:
      - 5432
    ports:
      - "5432:5432"

  zookeeper:
    image: nexus3.onap.org:10001/confluentinc/cp-zookeeper:latest
    environment:
      ZOOKEEPER_CLIENT_PORT: 2181
      ZOOKEEPER_TICK_TIME: 2000
    ports:
      - 2181:2181

  kafka:
    image: nexus3.onap.org:10001/confluentinc/cp-kafka:7.4.9
    container_name: kafka
    depends_on:
      - zookeeper
    ports:
      - 29092:29092
      - 9092:9092
    environment:
      KAFKA_BROKER_ID: 1
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,PLAINTEXT_HOST://localhost:29092
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
      KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1

  runtime-acm:
    image: onap/policy-clamp-runtime-acm
    depends_on:
      - zookeeper
      - kafka
      - postgres
    environment:
      RUNTIME_USER: runtimeUser
      RUNTIME_PASSWORD: zb!XztG34
      SQL_HOST: postgres
      SQL_PORT: 5432
      SQL_USER: policy_user
      SQL_PASSWORD: policy_user
      TOPIC_COMM_INFRASTRUCTURE: kafka
    ports:
      - "6969:6969"

  participant-simulator:
    image: onap/policy-clamp-ac-sim-ppnt
    depends_on:
      - zookeeper
      - kafka
    environment:
      HTTP_USER: participantUser
      HTTP_PASSWORD: zb!XztG34
      SERVER_PORT: 8085
      topicCommInfrastructure: kafka
      participantId: 101c62b3-8918-41b9-a747-d21eb79c6c90
      applicationName: sim-ppnt
      groupId: policy-clamp-ac-sim-ppnt
      supportedElementTypeName: org.onap.policy.clamp.acm.SimAutomationCompositionElement
    ports:
      - "8085:8085"

Run the docker composition:

cd ~/git/
docker compose up

Swagger UI of automation composition is available at http://localhost:6969/onap/policy/clamp/acm/swagger-ui/index.html