You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@metron.apache.org by GitBox <gi...@apache.org> on 2019/02/05 15:02:05 UTC

[GitHub] JonZeolla commented on a change in pull request #21: METRON-1911 Docker setup for testing bro plugin

JonZeolla commented on a change in pull request #21: METRON-1911 Docker setup for testing bro plugin
URL: https://github.com/apache/metron-bro-plugin-kafka/pull/21#discussion_r253900089
 
 

 ##########
 File path: docker/scripts/docker_run_bro_container.sh
 ##########
 @@ -0,0 +1,168 @@
+#!/usr/bin/env bash
+
+#
+#  Licensed to the Apache Software Foundation (ASF) under one or more
+#  contributor license agreements.  See the NOTICE file distributed with
+#  this work for additional information regarding copyright ownership.
+#  The ASF licenses this file to You 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.
+#
+
+shopt -s nocasematch
+set -e # errexit
+set -E # errtrap
+set -o pipefail
+
+#
+# Runs the bro container
+#
+
+function help {
+  echo " "
+  echo "usage: ${0}"
+  echo "    --container-name                [OPTIONAL] The Docker container name. Default: bro"
+  echo "    --network-name                  [OPTIONAL] The Docker network name. Default: bro-network"
+  echo "    --scripts-path                  [OPTIONAL] The path with the scripts you may run in the container. These are your scripts, not the built in scripts"
+  echo "    --data-path                     [OPTIONAL] The name of the directory to map to /root/data in the container"
+  echo "    --test-output-path              [REQUIRED] The path to log test data to"
+  echo "    --docker-parameter              [OPTIONAL, MULTIPLE] Each parameter with this name will be passed to docker run"
+  echo "    -h/--help                       Usage information."
+  echo " "
+}
+
+BRO_PLUGIN_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && cd ../.. && pwd)"
+CONTAINER_NAME=bro
+NETWORK_NAME=bro-network
+OUR_SCRIPTS_PATH="${BRO_PLUGIN_PATH}/docker/in_docker_scripts"
+SCRIPTS_PATH=
+DATA_PATH=
+TEST_OUTPUT_PATH=
+
+declare -a DOCKER_PARAMETERS
+
+# Handle command line options
+for i in "$@"; do
+  case $i in
+  #
+  # CONTAINER_NAME
+  #
+  #   --container-name
+  #
+    --container-name=*)
+      CONTAINER_NAME="${i#*=}"
+      shift # past argument=value
+    ;;
+
+  #
+  # NETWORK_NAME
+  #
+  #   --network-name
+  #
+    --network-name=*)
+      NETWORK_NAME="${i#*=}"
+      shift # past argument=value
+    ;;
+
+  #
+  # DATA_PATH
+  #
+  #   --data-path
+  #
+    --data-path=*)
+      DATA_PATH="${i#*=}"
+      shift # past argument=value
+    ;;
+
+  #
+  # SCRIPTS_PATH
+  #
+  #   --scripts-path
+  #
+    --scripts-path=*)
+      SCRIPTS_PATH="${i#*=}"
+      shift # past argument=value
+    ;;
+
+  #
+  # TEST_OUTPUT_PATH
+  #
+  #   --test-output-path
+  #
+    --test-output-path=*)
+      TEST_OUTPUT_PATH="${i#*=}"
+      shift # past argument=value
+    ;;
+
+  #
+  # DOCKER_PARAMETERS
+  #
+  #   --docker-parameter
+  #
+    --docker-parameter=*)
+      DOCKER_PARAMETERS=( "${DOCKER_PARAMETERS[@]}" "${i#*=}" )
+      shift # past argument=value
+    ;;
+
+  #
+  # -h/--help
+  #
+    -h | --help)
+      help
+      exit 0
+      shift # past argument with no value
+    ;;
+  esac
+done
+
+echo "Running docker_run_bro_container with "
+echo "CONTAINER_NAME = $CONTAINER_NAME"
+echo "NETWORK_NAME = ${NETWORK_NAME}"
+echo "SCRIPT_PATH = ${SCRIPTS_PATH}"
+echo "DATA_PATH = ${DATA_PATH}"
+echo "TEST_OUTPUT_PATH = ${TEST_OUTPUT_PATH}"
+echo "DOCKER_PARAMETERS = " "${DOCKER_PARAMETERS[@]}"
+echo "==================================================="
+
+
+# Build the docker command line
+declare -a DOCKER_CMD_BASE
+DOCKER_CMD="bash"
+DOCKER_CMD_BASE[0]="docker run -d -t --name ${CONTAINER_NAME} --network ${NETWORK_NAME} "
+DOCKER_CMD_BASE[2]="-v \"${OUR_SCRIPTS_PATH}:/root/built_in_scripts\" "
 
 Review comment:
   Is there a reason we're skipping [1] here?  I believe it used to be logs, which got removed recently.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services