Skip to content
Snippets Groups Projects
Commit 6fc75f86 authored by Daniel Salzman's avatar Daniel Salzman
Browse files

Add Docker hook

parent 5ecfd8c9
No related merge requests found
#!/usr/bin/env bash
source ${HOOKDIR}/wait_start.hook
#
# Knot DNS benchmark hook
#
export REPO="git://git.nic.cz/knot-dns.git"
export CONFIGURE_PARAMS="--enable-fastparser --enable-static --disable-shared --disable-utilities --disable-documentation"
export SRC_DIR="${BASEDIR}/knot.src"
export BIN="${SRC_DIR}/src/knotd"
#export DOCKER="docker run --net=host -v CONFDIR:CONFDIR -v ${SRC_DIR}:${SRC_DIR} -i -t knot3 sudo -u knot"
export DOCKER="docker run --net=host -v CONFDIR:CONFDIR -v ${SRC_DIR}:${SRC_DIR} -w PWD -i knot4 sudo -u dnsbench"
function ns_info() {
echo "Knot DNS $(${BIN} -V|awk '{print $5}')"
}
function ns_pid() {
echo $PID
}
function ns_init() {
if [ -n "${knot2_bin}" ]; then
BIN=${knot2_bin}
echo "using '$(ns_info)'"
else
# Check out specific branch if set
version="master"
[ -n "${1}" ] && version=${1}
[ -d ${SRC_DIR} ] && rm -r ${SRC_DIR} &>>$LOG
if ! git clone --depth 1 $REPO -b ${version} ${SRC_DIR} &>>$LOG; then
echo "error: couldn't fetch '${version}' from '${REPO}'"
return 1
fi
echo "checked out '${version}'"
# Build sources
pushd ${SRC_DIR} > /dev/null
autoreconf -if &>>$LOG
CFLAGS=$CFLAGS ./configure ${CONFIGURE_PARAMS} &>>$LOG
make -j${CPUS} &>>$LOG
popd > /dev/null
if [ ! -x ${BIN} ]; then
echo "error: couldn't make an executable"
return 1
fi
echo "built '$(ns_info)'"
fi
}
function ns_prep() {
return 2 # Don't measure
}
function ns_start() {
CONFDIR=$(cd $(dirname "$1"); pwd)
_DOCKER=$(echo "$DOCKER" | sed 's%CONFDIR%'$CONFDIR'%g;s%PWD%'$(pwd)'%g')
echo "${_DOCKER} ${BIN} -c ${1}" >&2
${_DOCKER} ${BIN} -c ${1} &>server.log &
PID=$!
CID=$(docker ps -a -q | head -n 1)
# wait_start "control, binding to"
sleep 10
return 0
}
function ns_stop() {
wait_stop
}
#!/usr/bin/env bash
export PID=""
export CID=""
export DIG="$(which dig)"
export DIG_ADDR="127.0.0.1"
if [ -f ${BASEDIR}/queries-ipv6.pcap ]; then
......@@ -53,8 +54,16 @@ wait_start()
wait_stop()
{
echo "wait_stop for PID $PID"
kill $PID &>/dev/null
wait $PID &>/dev/null
if [ -n "$CID" ]; then
docker exec "$CID" killall knotd
sleep 10
docker stop "$CID"
docker rm "$CID"
CID=""
else
kill $PID &>/dev/null
wait $PID &>/dev/null
fi
PID=""
sleep 10
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment