From cff1c3a6511f2bba42b25a7219ebae4c3da65a7f Mon Sep 17 00:00:00 2001 From: Rich Megginson Date: Tue, 20 Feb 2018 21:14:03 -0700 Subject: [PATCH 1/2] allow loader parameters to be passed to container as env vars --- Docker/Dockerfile | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/Docker/Dockerfile b/Docker/Dockerfile index 3b71588..012dfb4 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -1,5 +1,18 @@ -FROM registry.fedoraproject.org/fedora -RUN dnf -y install python -COPY ./loader / -RUN chmod +x /loader -#CMD ["/loader", "--msgpersec=10", "--report-interval=40"] +FROM registry.fedoraproject.org/fedora + +ENV MSGPERSEC=0 REPORT_INTERVAL=10 PAYLOAD_SIZE=1024 \ + DISTRIBUTION=gaussian PAYLOAD_GEN=random \ + STDDEV=32 OUTPUT=stdout REPORT=inline \ + TOTAL_SIZE=0 + +RUN dnf -y install python +COPY ./loader / +RUN chmod +x /loader +# build like this: +# docker build -t loader-container . +# run like this: +# contid=$( docker run -e MSGPERSEC=10 -e STDDEV=16 -d loader-container ) +# docker logs $contid +# docker stop $contid +# docker rm $contid +CMD /loader --msgpersec=${MSGPERSEC} --report-interval=${REPORT_INTERVAL} --total-size=${TOTAL_SIZE} --distribution=${DISTRIBUTION} --payload-gen=${PAYLOAD_GEN} --stddev=${STDDEV} --output=${OUTPUT} --report=${REPORT} ${PAYLOAD_SIZE} From cee0c53b0e33f6ddb101bf486dca8a570be2ab67 Mon Sep 17 00:00:00 2001 From: Rich Megginson Date: Wed, 21 Feb 2018 16:46:02 -0700 Subject: [PATCH 2/2] allow kill SIGINT to work the same as KeyboardInterrupt --- verify-loader | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/verify-loader b/verify-loader index a28aa8c..935157e 100755 --- a/verify-loader +++ b/verify-loader @@ -21,11 +21,19 @@ import sys import os import time import argparse +import signal from collections import defaultdict REPORT_INTERVAL = 10 MB = 1024 * 1024 +# if running verify-loader as a background process, +# we can still do a kill -2 $pid to make it exit +# the main loop and print the stats +def handle_sig_int(signum, frame): + raise KeyboardInterrupt + +signal.signal(signal.SIGINT, handle_sig_int) class Context(object):