<commit_before>#!/bin/sh
# Runs the acceptance tests in a VM created using Docker

# Help function
function show_help {
	echo "Ontrack acceptance tests using Docker."
	echo ""
	echo "Available options are:"
	echo "General:"
	echo "    -h, --help                    Displays this help"
	echo "Input:"
	echo "    -j, --jar                     (* required) Path to the ontrack JAR"
	echo "    -a, --acceptance              (* required) Path to the acceptance test JAR"
	echo "Control:"
	echo "    -k, --keep                    If set, the container is not destroyed after"
}

# Check function

function check {
	if [ "$1" == "" ]
	then
		echo $2
		exit 1
	fi
}

# Defaults

ONTRACK_JAR=

CONTROL_KEEP=no

# Command central

for i in "$@"
do
	case $i in
		-h|--help)
			show_help
			exit 0
			;;
		-j=*|--jar=*)
            ONTRACK_JAR=`echo $i | sed 's/[-a-zA-Z0-9]*=//'`
			;;
		-k|--keep)
            CONTROL_KEEP=yes
			;;
		*)
			echo "Unknown option: $i"
			show_help
			exit 1
		;;
	esac
done

# Checks

check "$ONTRACK_JAR" "Ontrack JAR (--jar) is required."

# Logging
echo "Ontrack JAR:            ${ONTRACK_JAR}"
echo "Keeping containers:     ${CONTROL_KEEP}"

# Mount point

MOUNT=`pwd`/acceptance
rm -f ${MOUNT}
mkdir -p ${MOUNT}
echo "Ontrack data at:        ${MOUNT}"

# Docker Ontrack VM up
# TODO Docker nginx VM up

./docker-setup.sh \
    --docker-image=ontrack \
    --mount=${MOUNT} \
    --run \
    --jar=${ONTRACK_JAR}

ONTRACK_CID=`cat ontrack.cid`

echo "[ACCEPTANCE] Ontrack container created: ${ONTRACK_CID}"

# TODO Get the running URL

# ONTRACK_URL="http://${DOCKER_HOST}"

# TODO Running the acceptance tests

# echo "[ACCEPTANCE] Running acceptance tests against ${ONTRACK_URL}"

# Docker Ontrack VM down
# TODO Docker nginx VM down

if [ "${CONTROL_KEEP}" == "no" ]
then
    echo "[ACCEPTANCE] Removing Ontrack container at: ${ONTRACK_CID}"
    docker rm -f ${ONTRACK_CID}
fi<commit_msg>#107 Docker: acceptance tests, getting the container port<commit_after>#!/bin/sh
# Runs the acceptance tests in a VM created using Docker

# Help function
function show_help {
	echo "Ontrack acceptance tests using Docker."
	echo ""
	echo "Available options are:"
	echo "General:"
	echo "    -h, --help                    Displays this help"
	echo "Input:"
	echo "    -j, --jar                     (* required) Path to the ontrack JAR"
	echo "    -a, --acceptance              (* required) Path to the acceptance test JAR"
	echo "Control:"
	echo "    -k, --keep                    If set, the container is not destroyed after"
}

# Check function

function check {
	if [ "$1" == "" ]
	then
		echo $2
		exit 1
	fi
}

# Defaults

ONTRACK_JAR=

CONTROL_KEEP=no

# Command central

for i in "$@"
do
	case $i in
		-h|--help)
			show_help
			exit 0
			;;
		-j=*|--jar=*)
            ONTRACK_JAR=`echo $i | sed 's/[-a-zA-Z0-9]*=//'`
			;;
		-k|--keep)
            CONTROL_KEEP=yes
			;;
		*)
			echo "Unknown option: $i"
			show_help
			exit 1
		;;
	esac
done

# Checks

check "$ONTRACK_JAR" "Ontrack JAR (--jar) is required."

# Logging
echo "Ontrack JAR:            ${ONTRACK_JAR}"
echo "Keeping containers:     ${CONTROL_KEEP}"

# Mount point

MOUNT=`pwd`/acceptance
rm -f ${MOUNT}
mkdir -p ${MOUNT}
echo "Ontrack data at:        ${MOUNT}"

# Docker Ontrack VM up
# TODO Docker nginx VM up

./docker-setup.sh \
    --docker-image=ontrack \
    --mount=${MOUNT} \
    --run \
    --jar=${ONTRACK_JAR}

ONTRACK_CID=`cat ontrack.cid`

echo "[ACCEPTANCE] Ontrack container created: ${ONTRACK_CID}"

# Getting the public facing port

ONTRACK_PORT=`docker port ${ONTRACK_CID} 8080 | sed -E 's/.*:(.*)/\1/'`
echo "[ACCEPTANCE] Ontrack available in container at port ${ONTRACK_PORT}"

# TODO Get the running URL

# ONTRACK_URL="http://${DOCKER_HOST}"

# TODO Running the acceptance tests

# echo "[ACCEPTANCE] Running acceptance tests against ${ONTRACK_URL}"

# Docker Ontrack VM down
# TODO Docker nginx VM down

if [ "${CONTROL_KEEP}" == "no" ]
then
    echo "[ACCEPTANCE] Removing Ontrack container at: ${ONTRACK_CID}"
    docker rm -f ${ONTRACK_CID}
fi
{'fraction_non_alphanumeric': 0.13645320197044336, 'fraction_numerical': 0.00541871921182266, 'mean_word_length': 2.6323792486583186, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4876128', 'n_tokens_mistral': 1560, 'n_tokens_neox': 1451, 'n_words': 443}