Skip to content

Commit 45f2038

Browse files
authored
Move USE_VITESS variable into entrypoint.sh (#8567)
This allows standing up a boulder that uses Vitess even when not running a specific test: docker compose run -e USE_VITESS=true boulder It also allows us to run migrations for mariadb or Vitess depending on which environment we'll be using, which may save a small amount of startup time. Specify USE_VITESS: false as an environment variable in docker-compose.yml to indicate an easy place to change it to `true` if someone prefers to use `docker compose up` (which does not accept `-e`). This unfortunately means losing the `-b` flag to `test.sh` but I think that's an okay tradeoff.
1 parent d64c784 commit 45f2038

6 files changed

Lines changed: 55 additions & 53 deletions

File tree

.github/workflows/boulder-ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ jobs:
5555
- "./tn.sh --unit --enable-race-detection"
5656
- "./t.sh --start-py"
5757
# Same cases but backed by Vitess + MySQL 8 instead of ProxySQL + MariaDB
58-
- "./t.sh --use-vitess --integration"
59-
- "./tn.sh --use-vitess --integration"
60-
- "./t.sh --use-vitess --unit --enable-race-detection"
61-
- "./tn.sh --use-vitess --unit --enable-race-detection"
62-
- "./t.sh --use-vitess --start-py"
58+
- "USE_VITESS=true ./t.sh --integration"
59+
- "USE_VITESS=true ./tn.sh --integration"
60+
- "USE_VITESS=true ./t.sh --unit --enable-race-detection"
61+
- "USE_VITESS=true ./tn.sh --unit --enable-race-detection"
62+
- "USE_VITESS=true ./t.sh --start-py"
6363

6464
env:
6565
# This sets the docker image tag for the boulder-tools repository to

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ services:
1515
# pointing at the boulder service's "public" IP, where challtestsrv is.
1616
FAKE_DNS: 64.112.117.122
1717
BOULDER_CONFIG_DIR: test/config
18+
USE_VITESS: false
1819
GOCACHE: /boulder/.gocache/go-build
1920
volumes:
2021
- .:/boulder:cached

t.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ fi
1212
# Generate the test keys and certs necessary for the integration tests.
1313
docker compose run --rm bsetup
1414

15-
exec docker compose run --rm --name boulder_tests boulder ./test.sh "$@"
15+
exec docker compose run -e USE_VITESS --rm --name boulder_tests boulder ./test.sh "$@"

test.sh

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ fi
1212
# Defaults
1313
#
1414
export RACE="false"
15-
export USE_VITESS="false"
1615
STAGE="starting"
1716
STATUS="FAILURE"
1817
RUN=()
@@ -22,14 +21,6 @@ INTEGRATION_FLAGS=()
2221
FILTER=()
2322
COVERAGE="false"
2423
COVERAGE_DIR="test/coverage/$(date +%Y-%m-%d_%H-%M-%S)"
25-
DB_URL_FILES=(
26-
badkeyrevoker_dburl
27-
cert_checker_dburl
28-
incidents_dburl
29-
revoker_dburl
30-
sa_dburl
31-
sa_ro_dburl
32-
)
3324

3425
#
3526
# Cleanup Functions
@@ -87,23 +78,6 @@ function run_and_expect_silence() {
8778
rm "${result_file}"
8879
}
8980

90-
configure_database_endpoints() {
91-
dburl_target_dir="proxysql"
92-
export DB_ADDR="boulder-proxysql:6033"
93-
94-
if [[ "${USE_VITESS}" == "true" ]]
95-
then
96-
dburl_target_dir="vitess"
97-
export DB_ADDR="boulder-vitess:33577"
98-
fi
99-
100-
# Configure DBURL symlinks
101-
rm -f test/secrets/*_dburl || true
102-
for file in ${DB_URL_FILES:+${DB_URL_FILES[@]+"${DB_URL_FILES[@]}"}}
103-
do
104-
ln -sf "dburls/${dburl_target_dir}/${file}" "test/secrets/${file}"
105-
done
106-
}
10781
#
10882
# Testing Helpers
10983
#
@@ -147,7 +121,6 @@ With no options passed, runs standard battery of tests (lint, unit, and integrat
147121
Example:
148122
TestGenerateValidity/TestWFECORS
149123
-h, --help Shows this help message
150-
-b --use-vitess Run tests against Vitess + MySQL 8.0 database
151124
152125
EOM
153126
)"
@@ -172,17 +145,13 @@ while getopts luvwecisgnhbd:p:f:-: OPT; do
172145
n | config-next ) BOULDER_CONFIG_DIR="test/config-next" ;;
173146
c | coverage ) COVERAGE="true" ;;
174147
d | coverage-dir ) check_arg; COVERAGE_DIR="${OPTARG}" ;;
175-
b | use-vitess ) USE_VITESS="true" ;;
176148
h | help ) print_usage_exit ;;
177149
??* ) exit_msg "Illegal option --$OPT" ;; # bad long option
178150
? ) exit 2 ;; # bad short option (error reported via getopts)
179151
esac
180152
done
181153
shift $((OPTIND-1)) # remove parsed options and args from $@ list
182154

183-
# Defaults to MariaDB unless USE_VITESS is true.
184-
configure_database_endpoints
185-
186155
# The list of segments to run. Order doesn't matter.
187156
if [ -z "${RUN[@]+x}" ]
188157
then

test/entrypoint.sh

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,36 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
1010
rm -f /var/run/rsyslogd.pid
1111
rsyslogd
1212

13+
DB_URL_FILES=(
14+
badkeyrevoker_dburl
15+
cert_checker_dburl
16+
incidents_dburl
17+
revoker_dburl
18+
sa_dburl
19+
sa_ro_dburl
20+
)
21+
22+
configure_database_endpoints() {
23+
dburl_target_dir="proxysql"
24+
export DB_ADDR="boulder-proxysql:6033"
25+
26+
if [[ "${USE_VITESS}" == "true" ]]
27+
then
28+
dburl_target_dir="vitess"
29+
export DB_ADDR="boulder-vitess:33577"
30+
fi
31+
32+
# Configure DBURL symlinks
33+
rm -f test/secrets/*_dburl || true
34+
for file in ${DB_URL_FILES:+${DB_URL_FILES[@]+"${DB_URL_FILES[@]}"}}
35+
do
36+
ln -sf "dburls/${dburl_target_dir}/${file}" "test/secrets/${file}"
37+
done
38+
}
39+
40+
# Defaults to MariaDB/ProxySQL unless USE_VITESS is true.
41+
configure_database_endpoints
42+
1343
# make sure we can reach mariadb and proxysql
1444
./test/wait-for-it.sh boulder-mariadb 3306
1545
./test/wait-for-it.sh boulder-proxysql 6033
@@ -21,21 +51,23 @@ rsyslogd
2151
./test/wait-for-it.sh bpkimetal 8080
2252

2353
# create the databases
24-
MYSQL_CONTAINER=1 \
25-
DB_HOST="boulder-mariadb" \
26-
DB_PORT=3306 \
27-
DB_CONFIG_FILE="${DIR}/../sa/db/dbconfig.mariadb.yml" \
28-
SKIP_CREATE=0 \
29-
SKIP_USERS=0 \
30-
"$DIR/create_db.sh"
31-
32-
MYSQL_CONTAINER=1 \
33-
DB_HOST="boulder-vitess" \
34-
DB_PORT=33577 \
35-
DB_CONFIG_FILE="${DIR}/../sa/db/dbconfig.mysql8.yml" \
36-
SKIP_CREATE=1 \
37-
SKIP_USERS=1 \
38-
"$DIR/create_db.sh"
54+
if [[ "${USE_VITESS}" == "true" ]]; then
55+
MYSQL_CONTAINER=1 \
56+
DB_HOST="boulder-vitess" \
57+
DB_PORT=33577 \
58+
DB_CONFIG_FILE="${DIR}/../sa/db/dbconfig.mysql8.yml" \
59+
SKIP_CREATE=1 \
60+
SKIP_USERS=1 \
61+
"$DIR/create_db.sh"
62+
else
63+
MYSQL_CONTAINER=1 \
64+
DB_HOST="boulder-mariadb" \
65+
DB_PORT=3306 \
66+
DB_CONFIG_FILE="${DIR}/../sa/db/dbconfig.mariadb.yml" \
67+
SKIP_CREATE=0 \
68+
SKIP_USERS=0 \
69+
"$DIR/create_db.sh"
70+
fi
3971

4072
if [[ $# -eq 0 ]]; then
4173
exec python3 ./start.py

tn.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ fi
1212
# Generate the test keys and certs necessary for the integration tests.
1313
docker compose run --rm bsetup
1414

15-
exec docker compose -f docker-compose.yml -f docker-compose.next.yml run --rm --name boulder_tests boulder ./test.sh "$@"
15+
exec docker compose -f docker-compose.yml -f docker-compose.next.yml run -e USE_VITESS --rm --name boulder_tests boulder ./test.sh "$@"

0 commit comments

Comments
 (0)