job_manager/create: support resperf tests

parent 85b89bde
......@@ -69,11 +69,7 @@ def load_test_case_config(test_case: str) -> Dict[str, Any]:
return yaml.load(f)
def create_template_files(directory: str, config: Dict[str, Any]):
create_file_from_template('run_respdiff.sh.j2', config, directory, executable=True)
create_file_from_template('restart-all.sh.j2', config, directory, executable=True)
create_file_from_template('docker-compose.yaml.j2', config, directory)
def create_resolver_configs(directory: str, config: Dict[str, Any]):
for name, resolver in config['resolvers'].items():
resolver['name'] = name
resolver['verbose'] = config['verbose']
......@@ -100,6 +96,19 @@ def create_template_files(directory: str, config: Dict[str, Any]):
raise NotImplementedError(
"unknown resolver type: '{}'".format(resolver['type']))
def create_resperf_files(directory: str, config: Dict[str, Any]):
create_file_from_template('run_resperf.sh.j2', config, directory, executable=True)
create_file_from_template('docker-compose.yaml.j2', config, directory)
create_resolver_configs(directory, config)
def create_respdiff_files(directory: str, config: Dict[str, Any]):
create_file_from_template('run_respdiff.sh.j2', config, directory, executable=True)
create_file_from_template('restart-all.sh.j2', config, directory, executable=True)
create_file_from_template('docker-compose.yaml.j2', config, directory)
create_resolver_configs(directory, config)
# omit resolvers without respdiff section from respdiff.cfg
config['resolvers'] = {
name: res for name, res
......@@ -108,6 +117,13 @@ def create_template_files(directory: str, config: Dict[str, Any]):
create_file_from_template('respdiff.cfg.j2', config, directory)
def create_template_files(directory: str, config: Dict[str, Any]):
if 'respdiff' in config:
create_respdiff_files(directory, config)
elif 'resperf' in config:
create_resperf_files(directory, config)
def get_test_case_list(nameglob: str = '') -> List[str]:
# test cases end with '*.jXXX' implying a number of jobs (less -> longer runtime)
# return them in ascending order, so more time consuming test cases run first
......
......@@ -13,7 +13,7 @@ services:
GIT_SHA: {{ git_sha }}
SSH_PRIVATE_KEY: ${SSH_PRIVATE_KEY}
KNOT_BRANCH: ${KNOT_BRANCH}
CFLAGS: {{ '-ggdb3 -O0 -fsanitize=address -fno-omit-frame-pointer' if asan else '' }}
CFLAGS: {{ '-ggdb3 -O0 -fsanitize=address -fno-omit-frame-pointer' if asan else "''" }}
image: knot-resolver:{{ git_sha }}{{ '-asan' if asan else '' }}
volumes:
- "./{{ name }}.conf:/etc/knot-resolver/kresd.conf:ro"
......@@ -43,3 +43,9 @@ services:
{%- endif -%}
{%- endfor -%}
{%- if resperf %}
resperf:
network_mode: host
image: registry.labs.nic.cz/knot/respdiff/resperf:latest
{%- endif -%}
#!/bin/bash
set -o xtrace
JOBNAME=j$1.$2
# HACK (condor): ensure files for transfer exist to avoid held jobs
touch ${JOBNAME}_kresd.docker.txt
touch ${JOBNAME}_resperf.txt
echo '0' > ${JOBNAME}_exitcode
mkdir logs
tar -czf ${JOBNAME}_logs.tar.gz -T /dev/null # empty tar by default
# HACK (condor): Create proper dir structure
mkdir -p docker-knot-resolver || :
mv Dockerfile docker-knot-resolver/ || :
# HACK (condor): set PATH, otherwise docker-compose exec will fail
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Check no other docker containers are running
if [ -n "$(docker ps -q)" ]; then
echo "ERROR: running docker containers detected" >&2
exit 2
fi
# Exit if any cmd fails from now on.
set -o errexit
cleanup() {
docker-compose --no-ansi rm -fsv || :
exit 0
}
trap cleanup EXIT
err_handle() {
echo '1' > ${JOBNAME}_exitcode
}
trap err_handle ERR
# Prepare ssh key for knot-resolver-security
set +o xtrace
SSH_PRIVATE_KEY=$(cat </home/respdiff/.ssh/knot_resolver_security.id_rsa || :)
export SSH_PRIVATE_KEY
set -o xtrace
# Attempt to build containers (to have stdout/err logs in case of failure)
export KNOT_BRANCH={{ knot_branch }}
time docker-compose --no-ansi up --no-start
# Run resperf test repeatedly
for i in $(seq 3); do
set +o xtrace
echo "Waiting for ports..."
# Ensure ports are empty, so we're not testing something else!
MAX_RETRIES=30 # x5s
{% for resolver in resolvers.values() -%}
retries=0
{% if resolver['port'] %}
while [ ! -z "$(ss --all --no-header '( dport = :{{ resolver["port"] }} or sport = :{{ resolver["port"] }} )')" ]; do
retries=$((retries+1))
if (( $retries > $MAX_RETRIES )); then
echo "ERROR: port {{ resolver['port'] }} not availble" >&2
exit 2
fi
sleep 5
done
{% endif %}
{% if resolver['tls_port'] %}
retries=0
while [ ! -z "$(ss --all --no-header '( dport = :{{ resolver["tls_port"] }} or sport = :{{ resolver["tls_port"] }} )')" ]; do
retries=$((retries+1))
if (( $retries > $MAX_RETRIES )); then
echo "ERROR: port {{ resolver['tls_port'] }} not availble" >&2
exit 2
fi
sleep 5
done
{% endif %}
{% endfor %}
set -o xtrace
# Execute resperf
docker-compose --no-ansi up -d
docker-compose --no-ansi exec -T resperf resperf -q 500000 -m 10000 -C 200 -c 30 -d shortlist -t 15 -r 0 -s 127.0.0.1 -p {{ resperf['port'] }} &>>${JOBNAME}_resperf.txt
docker-compose --no-ansi logs &>>${JOBNAME}_kresd.docker.txt
docker-compose --no-ansi ps | (! grep Exit)
docker-compose --no-ansi kill
done
Markdown is supported
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