Skip to content

Commit

Permalink
test: fix two issues running tests locally (#4220)
Browse files Browse the repository at this point in the history
Two issues with testing locally on my dev laptop:

1. `docker-compose` (i.e. Docker Compose v1) is dead and, in some versions, now gone. Time for `docker compose ...` (i.e. v2): https://docs.docker.com/compose/migrate/

```
% npm test

> [email protected] test
> ./test/script/run_tests.sh

./test/script/run_tests.sh: line 93: docker-compose: command not found
```

2. The mysql image has no layer for ARM, i.e. that natively runs on Apple Silicon.

```
% npm test

> [email protected] test
> ./test/script/run_tests.sh

[+] Running 0/1
 ⠼ mysql Pulling                                                                                                                                                                                                                                                                                 1.4s
no matching manifest for linux/arm64/v8 in the manifest list entries
```
  • Loading branch information
trentm authored Sep 5, 2024
1 parent 73a160a commit ebd9380
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ npm run lint # or 'make check' if you are a Makefile kind of pe

npm test # run test services and tests in Docker

docker-compose -f test/docker-compose.yml config --services # list test services
docker compose -f test/docker-compose.yml config --services # list test services
npm run docker:start # start all test services
npm run docker:start redis # start one or more test services
npm run docker:stop # stop all test services
Expand Down
4 changes: 2 additions & 2 deletions test/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '2.1'

services:
postgres:
user: postgres
Expand Down Expand Up @@ -51,6 +49,8 @@ services:

mysql:
image: mysql:5.7
# No ARM64 image layer. See https://stackoverflow.com/a/65592942
platform: linux/x86_64
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 1
ports:
Expand Down
4 changes: 2 additions & 2 deletions test/script/docker/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ else
CMD='npm test'
fi

NODE_VERSION=${1} docker-compose --no-ansi --log-level ERROR -f ./test/docker-compose.yml -f ./test/docker-compose.ci.yml run \
NODE_VERSION=${1} docker compose --no-ansi --log-level ERROR -f ./test/docker-compose.yml -f ./test/docker-compose.ci.yml run \
-e NODE_VERSION=${NODE_VERSION} \
-e TAV=${TAV_MODULES} \
-e CI=true \
Expand All @@ -33,4 +33,4 @@ NODE_VERSION=${1} docker-compose --no-ansi --log-level ERROR -f ./test/docker-co
npm --version
${CMD}"

NODE_VERSION=${1} docker-compose --no-ansi --log-level ERROR -f ./test/docker-compose.yml -f ./test/docker-compose.ci.yml down -v
NODE_VERSION=${1} docker compose --no-ansi --log-level ERROR -f ./test/docker-compose.yml -f ./test/docker-compose.ci.yml down -v
6 changes: 3 additions & 3 deletions test/script/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ then
else
# No arguments was given. Let's just assume that the user wants to
# spin up all dependencies inside Docker and run the tests locally
services=$(docker-compose -f ./test/docker-compose.yml config --services)
services=$(docker compose -f ./test/docker-compose.yml config --services)
fi

service_arr=( $services )
Expand All @@ -106,11 +106,11 @@ then
elif [[ $healthy -lt $expected_healthy || $containers -lt $expected_containers ]]
then
finish () {
docker-compose -f ./test/docker-compose.yml down
docker compose -f ./test/docker-compose.yml down
}
trap finish EXIT

docker-compose -f ./test/docker-compose.yml up -d $services
docker compose -f ./test/docker-compose.yml up -d $services
wait_for_healthy
fi

Expand Down

0 comments on commit ebd9380

Please sign in to comment.