How to set up a local DMaaP installation in Docker for testing
It is sometimes convenient to have a local installation of DMaaP on your machine for testing purposes. For example, for testing policies, you can connect the Policy Framework to a local installation of DMaaP and use curl to issue the policy REST calls to the local DMaaP. For this howto, in order to avoid a dependency on A&AI, checks towards A&AI are commented out. This howto was written on the Amsterdam versions of DMaaP. It was executed on a Macbook Pro running macOS 10.13.3.
Step-by-step guide
Create a new directory, let's call it "local-dmaap", and go into the directory
mkdir <path-to>/local-dmaap cd <path-to>/local-dmaap
Clone the DMaaP msgrtr and messageservice repositories
git clone https://gerrit.onap.org/r/dmaap/messagerouter/msgrtr git clone https://gerrit.onap.org/r/dmaap/messagerouter/messageservice
Check out the Amsterdam branches of the DMaaP repos
cd msgrtr git co amsterdam cd ../messageservice git co amsterdam cd ..
In order to remove the need to install A&AI, comment out as follows in msgrtr src/main/java/com/att/nsa/cambria/service/impl/TopicServiceImpl.java:
Build the msgrtr, skipping tests if you wish. Once the build completes, we're finished in msgrtr.
In messageservice, the start-kafka.sh script breaks with the latest version of Scala and Kafka unless a new line is added to the end of the server.properties file. Edit the messageservice src/main/resources/docker-compose/start-kafka.sh as follows:
Ensure that the version of msgrtr dependency used in messageservice pom.xml is the local one created above, check your pom.xml in messageservice, specifically you must specify if msgrtr is a SNAPSHOT version. for example, see below:
Build the message service, skipping tests if you wish.
Ensure Docker is running on your machine. Clear down all relevant containers and images in your docker that might interfere with DMaaP. Use the commands below WITH CARE!
In messageservice, copy the "appl" directory to target/classes/docker. This copies the configuration for DMaaP into the location in which we will build the docker images and the docker-compose setup.
In messageservice, copy the "startup.sh" script target/classes/docker. This is the startup shell script for the DMaaP message service in Docker.
If /var/tmp/MsgRtr.properties file or directory exists on /var/tmp,delete it. This is the file where we will specify the local properties for Kafka/Zookeeper for DMaaP.
Copy the template MsgRtr properties to /var/tmp
Edit /var/tmp/MsgRtrApi.properties as follows to put in the host names and ports for Kafka and Zookeeper in our docker-compose setup:
Build the adapted DMaaP docker image, it will be tagged as dmaap:localadapt
Now we prepare the docker-compose setup for DMaaP. Go to messageservice/target/classes/docker-compose and edit Dockerfile, changing the KAFKA_VERSION to 1.0.0 and the SCALA_VERSION to 2.12
Edit docker-compose.yml to change the name of th DMaaP docker image to use our locally adapted DMaaP image:
On macOS only, edit docker-compose.yml to change var/tmp to /private/var/tmp (ensure you have /private/var/tmp shared with Docker on macOS).
Start DMaaP, crossing your fingers really tightly!
Check that DMaaP is running with a curl request to list topics
Create a topic called MyTopic
List the topics again, our topic should now be there: