Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable End-to-End test during docker build #122

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,18 @@ WORKDIR /app/build/
RUN cmake -DCMAKE_BUILD_TYPE=Release .. && make -j $(nproc) && make test

FROM base as runtime
RUN apt-get update && apt-get install -y wget python3-yaml unzip curl
WORKDIR /app
ARG UID=1000
RUN groupadd -r qlever && useradd --no-log-init -r -u $UID -g qlever qlever && chown qlever:qlever /app
USER qlever
ENV PATH=/app/:$PATH
COPY --from=builder /app/build/*Main /app/src/web/* /app/
COPY --from=builder /app/e2e/* /app/e2e/
# We do the final End-to-End test in the runtime container so we are sure that
# has all the necessary libraries/runtime dependencies. Also it's nice to have
# the test queries accessible in the final image
USER qlever
RUN e2e/e2e.sh

EXPOSE 7001
VOLUME ["/input", "/index"]
Expand Down
46 changes: 30 additions & 16 deletions e2e/e2e.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
#!/usr/bin/env bash
set -e
PROJECT_DIR="$(dirname ${BASH_SOURCE[0]})/.."
PROJECT_DIR=$(readlink -f -- "$(dirname ${BASH_SOURCE[0]})/..")
# Change to the project directory so we can use simple relative paths
cd "$PROJECT_DIR"
pushd $PROJECT_DIR
BINARY_DIR=$(readlink -f -- ./build)
if [ ! -e $BINARY_DIR ]; then
BINARY_DIR=$(readlink -f -- .)
fi
function bail {
echo "$*"
exit 1
}

function cleanup_server {
echo "The Server Log follows:"
cat "build/server_log.txt"
cat "$BINARY_DIR/server_log.txt"
# Killing 0 sends the signal to all processes in the current
# process group
kill $SERVER_PID
Expand All @@ -25,34 +29,43 @@ else
export PYTHON_BINARY=`which python3`
fi

mkdir -p "e2e_data"
INDEX_DIR="$PROJECT_DIR/e2e_data"
INPUT_DIR="$INDEX_DIR/scientist-collection"
INPUT_PREFIX="scientists"
INPUT="$INPUT_DIR/$INPUT_PREFIX"
mkdir -p "$INDEX_DIR"
# Can't check for the scientist-collection directory because
# Travis' caching creates it
if [ ! -e "e2e_data/scientist-collection/scientists.nt" ]; then
if [ ! -e "$INPUT.nt" ]; then
# Why the hell is this a ZIP that can't easily be decompressed from stdin?!?
wget -O "e2e_data/scientist-collection.zip" \
wget -O "$INDEX_DIR/scientist-collection.zip" \
"http://filicudi.informatik.uni-freiburg.de/bjoern-data/scientist-collection.zip"
unzip "e2e_data/scientist-collection.zip" -d "e2e_data"
unzip -j "$INDEX_DIR/scientist-collection.zip" -d "$INPUT_DIR/"
rm "$INDEX_DIR/scientist-collection.zip"
fi;

INDEX="e2e_data/scientists-index"

INDEX_PREFIX="scientists-index"
INDEX="$INDEX_DIR/$INDEX_PREFIX"

# Delete and rebuild the index
if [ "$1" != "no-index" ]; then
rm -f "$INDEX.*"
pushd "./build"
./IndexBuilderMain -a -l -i "../$INDEX" \
-n "../e2e_data/scientist-collection/scientists.nt" \
-w "../e2e_data/scientist-collection/scientists.wordsfile.tsv" \
-d "../e2e_data/scientist-collection/scientists.docsfile.tsv" \
pushd "$BINARY_DIR"
echo "Building index $INDEX"
./IndexBuilderMain -a -l -i "$INDEX" \
-n "$INPUT.nt" \
-w "$INPUT.wordsfile.tsv" \
-d "$INPUT.docsfile.tsv" \
--patterns || bail "Building Index failed"
popd
fi

# Launch the Server using the freshly baked index. Can't simply use a subshell here because
# then we can't easily get the SERVER_PID out of that subshell
pushd "./build"
./ServerMain -i "../$INDEX" -p 9099 -t -a --patterns &> server_log.txt &
pushd "$BINARY_DIR"
echo "Launching server from path $(pwd)"
./ServerMain -i "$INDEX" -p 9099 -t -a --patterns &> server_log.txt &
SERVER_PID=$!
popd

Expand All @@ -62,4 +75,5 @@ echo "Waiting for ServerMain to launch and open port"
while ! curl --max-time 1 --output /dev/null --silent http://localhost:9099/; do
sleep 1
done
$PYTHON_BINARY e2e/queryit.py "e2e/scientists_queries.yaml" "http://localhost:9099" || bail "Querying Server failed"
$PYTHON_BINARY "$PROJECT_DIR/e2e/queryit.py" "$PROJECT_DIR/e2e/scientists_queries.yaml" "http://localhost:9099" || bail "Querying Server failed"
popd