[AETHER-1265] Integrate Java profiler in TOST env

- Adds a dockerfile to build ONOS image with profiler agent enabled
- Prevents the overriding of the JAVA_OPTS when using the profiler
- Deploy profiler also in the atomix nodes when using stc

Change-Id: I00d5091428083f44360989c701350b7fead66038
diff --git a/tools/test/bin/atomix-service b/tools/test/bin/atomix-service
index 7b60d93..5910a8c 100755
--- a/tools/test/bin/atomix-service
+++ b/tools/test/bin/atomix-service
@@ -39,11 +39,19 @@
     nodes=$(find_node ${1:-$OCI})
 fi
 
+# Define the java options for atomix
+# FIXME atomix-agent already provides a gc algorithm. Once we fix atomix-agent we can allow this
+# JAVA_OPTS="${JAVA_OPTS:--XX:+UseG1GC -XX:MaxGCPauseMillis=200}"
+if [ ! -z "$ONOS_YOURKIT" ]; then
+    #JAVA_OPTS+=" -agentpath:$ATOMIX_INSTALL_DIR/libyjpagent.so=listen=all"
+    JAVA_OPTS="${JAVA_OPTS:--agentpath:$ATOMIX_INSTALL_DIR/libyjpagent.so=listen=all}"
+fi
+
 case $2 in
     start)
         # Execute the remote commands
         for node in $nodes; do
-            ssh $ONOS_USER@${node} "nohup $ATOMIX_INSTALL_DIR/bin/atomix-agent -c $ATOMIX_INSTALL_DIR/atomix.json >/dev/null 2>&1 &"
+            ssh $ONOS_USER@${node} "JAVA_OPTS=\"${JAVA_OPTS}\" nohup $ATOMIX_INSTALL_DIR/bin/atomix-agent -c $ATOMIX_INSTALL_DIR/atomix.json >/dev/null 2>&1 &"
         done
     ;;
     stop)