Skip to content

Commit 5809f37

Browse files
authored
feat: Add dev.wait-for.% Make target; use in provisioning tests (#1201)
This target waits for a list of services to come up. While this is primarily intended as a developer feature, it should also fix some intermittent provisioning test failures that we think are race conditions (where dev.check is called too soon after dev.up). Also, increase check.sh log output limit to match dev.logs.
1 parent 591c664 commit 5809f37

File tree

5 files changed

+18
-10
lines changed

5 files changed

+18
-10
lines changed

.github/workflows/provisioning-tests.yml

+7-3
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,15 @@ jobs:
7070
- name: provision
7171
run: make dev.provision.${{matrix.services}}
7272

73-
- name: dev.up
73+
- name: "Bring up services"
7474
run: make dev.up.${{matrix.services}}
7575

76-
- name: dev.check
77-
run: make dev.check.${{matrix.services}}
76+
- name: "Wait for services to become ready"
77+
run: |
78+
# Wait a reasonable amount of time for services to come up. If they
79+
# don't, then call the checks one more time to ensure that diagnostic
80+
# information is printed out. (It's suppressed by wait-for.)
81+
timeout 5m make dev.wait-for.${{matrix.services}} || timeout 1m make dev.check.${{matrix.services}}
7882
7983
- name: notify on failure
8084
if: ${{ failure() && github.ref == 'refs/heads/master' }}

Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,9 @@ dev.check: dev.check.$(DEFAULT_SERVICES) ## Run checks for the default service s
381381
dev.check.%: # Run checks for a given service or set of services.
382382
$(WINPTY) bash ./check.sh $*
383383

384+
dev.wait-for.%: ## Wait for these services to become ready
385+
$(WINPTY) bash ./wait-ready.sh $$(echo $* | tr + " ")
386+
384387
dev.validate: ## Print effective Docker Compose config, validating files in COMPOSE_FILE.
385388
docker compose config
386389

@@ -463,7 +466,7 @@ DB_NAMES_LIST = credentials discovery ecommerce notes registrar xqueue edxapp ed
463466
_db_copy8_targets = $(addprefix dev.dbcopy8.,$(DB_NAMES_LIST))
464467
dev.dbcopyall8: ## Copy data from old mysql 5.7 containers into new mysql8 dbs
465468
$(MAKE) dev.up.mysql57+mysql80
466-
./wait-ready.sh mysql57 mysql80
469+
$(MAKE) dev.wait-for.mysql57+mysql80
467470
$(MAKE) $(_db_copy8_targets)
468471

469472
dev.dbcopy8.%: ## Copy data from old mysql 5.7 container into a new 8 db

check.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ run_check() {
4646
if bash -c "$cmd"; then # Run the command itself and check if it succeeded.
4747
succeeded="$succeeded $check_name"
4848
else
49-
docker compose logs --tail 30 "$service" # Just show recent logs, not all history
49+
docker compose logs --tail 500 "$service" # Just show recent logs, not all history
5050
failed="$failed $check_name"
5151
fi
5252
set -e # Re-enable exit-on-error

docs/devstack_interface.rst

+1
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ If you want to ensure you are getting the latest listing, simply use ``make help
200200
dev.up.without-deps.% Bring up services by themselves.
201201
dev.up.without-deps.shell.% Bring up a service by itself + shell into it.
202202
dev.validate Print effective Docker Compose config, validating files in COMPOSE_FILE.
203+
dev.wait-for.% Wait for these services to become ready
203204
devpi-password Get the root devpi password for the devpi container.
204205
docs generate Sphinx HTML documentation, including API docs
205206
hadoop-application-logs-% View hadoop logs by application Id.

provision.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -130,22 +130,22 @@ fi
130130

131131
# Ensure the MySQL5 server is online and usable
132132
echo "${GREEN}Waiting for MySQL 5.7.${NC}"
133-
./wait-ready.sh mysql57
133+
make dev.wait-for.mysql57
134134

135135
# Ensure the MySQL8 server is online and usable
136136
echo "${GREEN}Waiting for MySQL 8.0.${NC}"
137-
./wait-ready.sh mysql80
137+
make dev.wait-for.mysql80
138138

139139
# In the event of a fresh MySQL container, wait a few seconds for the server to restart
140140
# See https://github.com/docker-library/mysql/issues/245 for why this is necessary.
141141
sleep 10
142142

143143
echo "${GREEN}Waiting for MySQL 5.7 to restart.${NC}"
144-
./wait-ready.sh mysql57
144+
make dev.wait-for.mysql57
145145
echo -e "${GREEN}MySQL5 ready.${NC}"
146146

147147
echo "${GREEN}Waiting for MySQL 8.0 to restart.${NC}"
148-
./wait-ready.sh mysql80
148+
make dev.wait-for.mysql80
149149
echo -e "${GREEN}MySQL8 ready.${NC}"
150150

151151
# Ensure that the MySQL databases and users are created for all IDAs.
@@ -160,7 +160,7 @@ docker compose exec -T mysql80 bash -e -c "mysql -uroot mysql" < provision-mysql
160160
if needs_mongo "$to_provision_ordered"; then
161161
echo -e "${GREEN}Waiting for MongoDB...${NC}"
162162
# mongo container and mongo process/shell inside the container
163-
./wait-ready.sh mongo
163+
make dev.wait-for.mongo
164164
echo -e "${GREEN}MongoDB ready.${NC}"
165165
echo -e "${GREEN}Creating MongoDB users...${NC}"
166166
docker compose exec -T mongo bash -e -c "mongo" < mongo-provision.js

0 commit comments

Comments
 (0)