Skip to content

Commit a731bda

Browse files
authored
Docker script tweaks (#331)
- Support testing server versions other that `latest` with docker compose scripts. - Fixup user setup for mysql-5 compose config. - Fixup some variable unset issues when running outside of the devcontainer.
1 parent a9d5482 commit a731bda

File tree

6 files changed

+23
-11
lines changed

6 files changed

+23
-11
lines changed

docker/README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,21 @@ For instance:
77
```bash
88
# Set which database to target.
99
export BENCHBASE_PROFILE='sqlserver'
10+
# Set which benchmark to run.
11+
benchmark='tpcc'
12+
13+
# Optional additional overrides (defaults shown):
14+
1015
# Set which profiles to build.
1116
export BENCHBASE_PROFILES=$BENCHBASE_PROFILE
17+
# Specify a different version of the profile to use (suffix in this directory).
18+
export PROFILE_VERSION='latest'
1219
# Whether or not to rebuild the package/image.
1320
export CLEAN_BUILD="false"
1421
# When rebuilding, whether or not to run the unit tests.
1522
export SKIP_TESTS="true"
1623

17-
# Set which benchmark to run.
18-
benchmark='tpcc'
19-
2024
./docker/build-run-benchmark-with-docker.sh $benchmark
2125
```
2226

23-
This will use the selected profile's `up.sh` script to start the database as a local container, and the [`run-full-image.sh`](./benchbase/run-full-image.sh) to optionally build benchbase and then run the benchmark against it.
27+
This will use the selected profile's `up.sh` script to start the database as a local container, and the [`run-full-image.sh`](./benchbase/run-full-image.sh) to optionally build benchbase and then run the benchmark against it.

docker/benchbase/devcontainer/build-in-container.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#
33
# A simple script for building one or more profiles (in parallel) inside the container.
44

5+
# TODO: Convert this to a multi-stage build for better caching.
6+
57
# Make sure any failure halts the rest of the operation.
68
set -eu -o pipefail
79

docker/benchbase/fullimage/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# TODO: Use a multi-stage build to build the fullimage from the devcontainer.
2+
13
# Use a smaller base image that only has the jre, not the full jdk.
24
#FROM --platform=linux eclipse-temurin:17-jre AS fullimage
35
FROM eclipse-temurin:17-jre AS fullimage

docker/benchbase/run-full-image.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ if [ "$imagename" != 'benchbase' ]; then
2323
echo "ERROR: Unexpected imagename: $imagename" >&2
2424
fi
2525

26-
SRC_DIR="$PWD"
27-
if [ -n "$LOCAL_WORKSPACE_FOLDER" ]; then
26+
SRC_DIR="$rootdir"
27+
if [ -n "${LOCAL_WORKSPACE_FOLDER:-}" ]; then
2828
SRC_DIR="$LOCAL_WORKSPACE_FOLDER"
2929
fi
3030

@@ -33,7 +33,7 @@ mkdir -p results/
3333
set -x
3434
docker run -it --rm \
3535
${EXTRA_DOCKER_ARGS:-} \
36-
--env=http_proxy="${http_proxy:-}" --env=https_proxy="${https_proxy:-}" \
36+
--env=http_proxy="${http_proxy:-}" --env=https_proxy="${https_proxy:-}" --env=no_proxy="${no_proxy:-}" \
3737
--env BENCHBASE_PROFILE="$BENCHBASE_PROFILE" \
3838
--user "$CONTAINERUSER_UID:$CONTAINERUSER_GID" \
3939
-v "$SRC_DIR/results:/benchbase/results" benchbase-$BENCHBASE_PROFILE:latest $*

docker/build-run-benchmark-with-docker.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ benchmark="${1:-noop}"
88
# Let these pass through from the .env file from the devcontainer.
99
export BENCHBASE_PROFILE="${BENCHBASE_PROFILE:-postgres}"
1010
export BENCHBASE_PROFILES="$BENCHBASE_PROFILE"
11+
PROFILE_VERSION=${PROFILE_VERSION:-latest}
1112

1213
# When we are running the full image we don't generally want to have to rebuild it repeatedly.
1314
export CLEAN_BUILD="${CLEAN_BUILD:-false}"
@@ -17,20 +18,21 @@ scriptdir=$(dirname "$(readlink -f "$0")")
1718
rootdir=$(readlink -f "$scriptdir/..")
1819
cd "$rootdir"
1920

21+
EXTRA_DOCKER_ARGS=''
2022
if [ "$BENCHBASE_PROFILE" == 'sqlite' ]; then
2123
# Map the sqlite db back to the host.
2224
touch $PWD/$benchmark.db
2325
SRC_DIR="$PWD"
24-
if [ -n "$LOCAL_WORKSPACE_FOLDER" ]; then
26+
if [ -n "${LOCAL_WORKSPACE_FOLDER:-}" ]; then
2527
SRC_DIR="$LOCAL_WORKSPACE_FOLDER"
2628
fi
2729
EXTRA_DOCKER_ARGS="-v $SRC_DIR/$benchmark.db:/benchbase/profiles/sqlite/$benchmark.db"
2830
else
29-
if [ ! -x "docker/${BENCHBASE_PROFILE}-latest/up.sh" ]; then
31+
if [ ! -x "docker/${BENCHBASE_PROFILE}-${PROFILE_VERSION}/up.sh" ]; then
3032
echo "ERROR: No docker up.sh script available for '$BENCHBASE_PROFILE'"
3133
fi
3234

33-
"./docker/${BENCHBASE_PROFILE}-latest/up.sh"
35+
"./docker/${BENCHBASE_PROFILE}-${PROFILE_VERSION}/up.sh"
3436
fi
3537

3638
CREATE_DB_ARGS='--create=true --load=true'
@@ -44,4 +46,4 @@ SKIP_TESTS=${SKIP_TESTS:-true} EXTRA_DOCKER_ARGS="--network=host $EXTRA_DOCKER_A
4446
$CREATE_DB_ARGS --execute=true \
4547
--sample 1 --interval-monitor 1000 \
4648
--json-histograms results/histograms.json
47-
./scripts/check_histogram_results.sh results/historgrams.json
49+
./scripts/check_histogram_results.sh results/histograms.json

docker/mysql-5/docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ services:
1010
environment:
1111
MYSQL_ROOT_PASSWORD: password
1212
MYSQL_ROOT_HOST: "%"
13+
MYSQL_USER: admin
14+
MYSQL_PASSWORD: password
1315
MYSQL_DATABASE: benchbase
1416
ports:
1517
- "3306:3306"

0 commit comments

Comments
 (0)