diff --git a/Makefile b/Makefile index 89f4fb3f2..e1372c5bf 100644 --- a/Makefile +++ b/Makefile @@ -156,6 +156,7 @@ TEST_TARGET ?= "./..." .PHONY: test/setup test/setup: + @docker compose -f docker-compose.tests.yaml down -v --remove-orphans ## cleanup previous data @docker compose -f docker-compose.tests.yaml up -d @sleep 3 @docker exec -it storj-crdb1-1 bash -c 'cockroach sql --insecure -e "create database testcockroach;"' @@ -166,42 +167,47 @@ test/setup: @docker exec -it storj-crdb4-1 bash -c 'cockroach sql --insecure -e "create database testmetabase;"' @docker exec -it storj-postgres-1 bash -c 'echo "postgres" | psql -U postgres -c "create database teststorj;"' @docker exec -it storj-postgres-1 bash -c 'echo "postgres" | psql -U postgres -c "create database testmetabase;"' + @docker exec -it storj-postgres-1 bash -c 'echo "postgres" | psql -U postgres -c "ALTER ROLE postgres CONNECTION LIMIT -1;"' .PHONY: test/postgres test/postgres: test/setup ## Run tests against Postgres (developer) @env \ - STORJ_TEST_POSTGRES='postgres://postgres:postgres@localhost/teststorj?sslmode=disable' \ + STORJ_TEST_POSTGRES='postgres://postgres:postgres@localhost:5532/teststorj?sslmode=disable' \ + STORJ_TEST_COCKROACH='omit' \ STORJ_TEST_LOG_LEVEL='info' \ go test -tags noembed -parallel 4 -p 6 -vet=off -race -v -cover -coverprofile=.coverprofile $(TEST_TARGET) || { \ - docker compose -f docker-compose.tests.yaml rm -fs; \ + docker compose -f docker-compose.tests.yaml down -v; \ } - @docker compose -f docker-compose.tests.yaml rm -fs + @docker compose -f docker-compose.tests.yaml down -v @echo done .PHONY: test/cockroach test/cockroach: test/setup ## Run tests against CockroachDB (developer) @env \ - STORJ_TEST_COCKROACH="cockroach://root@localhost:26256/testcockroach?sslmode=disable" \ - STORJ_TEST_COCKROACH="$$STORJ_TEST_COCKROACH;cockroach://root@localhost:26257/testcockroach?sslmode=disable" \ - STORJ_TEST_COCKROACH="$$STORJ_TEST_COCKROACH;cockroach://root@localhost:26258/testcockroach?sslmode=disable" \ - STORJ_TEST_COCKROACH="$$STORJ_TEST_COCKROACH;cockroach://root@localhost:26259/testcockroach?sslmode=disable" \ - STORJ_TEST_COCKROACH_ALT='cockroach://root@localhost:26260/testcockroach?sslmode=disable' \ + STORJ_TEST_COCKROACH_NODROP='true' \ + STORJ_TEST_POSTGRES='omit' \ + STORJ_TEST_COCKROACH="cockroach://root@localhost:26356/testcockroach?sslmode=disable" \ + STORJ_TEST_COCKROACH="$$STORJ_TEST_COCKROACH;cockroach://root@localhost:26357/testcockroach?sslmode=disable" \ + STORJ_TEST_COCKROACH="$$STORJ_TEST_COCKROACH;cockroach://root@localhost:26358/testcockroach?sslmode=disable" \ + STORJ_TEST_COCKROACH="$$STORJ_TEST_COCKROACH;cockroach://root@localhost:26359/testcockroach?sslmode=disable" \ + STORJ_TEST_COCKROACH_ALT='cockroach://root@localhost:26360/testcockroach?sslmode=disable' \ STORJ_TEST_LOG_LEVEL='info' \ go test -tags noembed -parallel 4 -p 6 -vet=off -race -v -cover -coverprofile=.coverprofile $(TEST_TARGET) || { \ - docker compose -f docker-compose.tests.yaml rm -fs; \ + docker compose -f docker-compose.tests.yaml down -v; \ } - @docker compose -f docker-compose.tests.yaml rm -fs + @docker compose -f docker-compose.tests.yaml down -v @echo done .PHONY: test test: test/setup ## Run tests against CockroachDB and Postgres (developer) @env \ - STORJ_TEST_POSTGRES='postgres://postgres:postgres@localhost/teststorj?sslmode=disable' \ - STORJ_TEST_COCKROACH="cockroach://root@localhost:26256/testcockroach?sslmode=disable" \ - STORJ_TEST_COCKROACH="$$STORJ_TEST_COCKROACH;cockroach://root@localhost:26257/testcockroach?sslmode=disable" \ - STORJ_TEST_COCKROACH="$$STORJ_TEST_COCKROACH;cockroach://root@localhost:26258/testcockroach?sslmode=disable" \ - STORJ_TEST_COCKROACH="$$STORJ_TEST_COCKROACH;cockroach://root@localhost:26259/testcockroach?sslmode=disable" \ - STORJ_TEST_COCKROACH_ALT='cockroach://root@localhost:26260/testcockroach?sslmode=disable' \ + STORJ_TEST_COCKROACH_NODROP='true' \ + STORJ_TEST_POSTGRES='postgres://postgres:postgres@localhost:5532/teststorj?sslmode=disable' \ + STORJ_TEST_COCKROACH="cockroach://root@localhost:26356/testcockroach?sslmode=disable" \ + STORJ_TEST_COCKROACH="$$STORJ_TEST_COCKROACH;cockroach://root@localhost:26357/testcockroach?sslmode=disable" \ + STORJ_TEST_COCKROACH="$$STORJ_TEST_COCKROACH;cockroach://root@localhost:26358/testcockroach?sslmode=disable" \ + STORJ_TEST_COCKROACH="$$STORJ_TEST_COCKROACH;cockroach://root@localhost:26359/testcockroach?sslmode=disable" \ + STORJ_TEST_COCKROACH_ALT='cockroach://root@localhost:26360/testcockroach?sslmode=disable' \ STORJ_TEST_LOG_LEVEL='info' \ go test -tags noembed -parallel 4 -p 6 -vet=off -race -v -cover -coverprofile=.coverprofile $(TEST_TARGET) || { \ docker compose -f docker-compose.tests.yaml rm -fs; \ diff --git a/docker-compose.tests.yaml b/docker-compose.tests.yaml index f4ca6104f..08392382b 100644 --- a/docker-compose.tests.yaml +++ b/docker-compose.tests.yaml @@ -10,35 +10,34 @@ services: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres ports: - - "5432:5432" - + - "5532:5432" crdb1: hostname: crdb1 - command: [ "start-single-node", "--insecure" ] + command: [ "start-single-node", "--insecure", "--store=type=mem,size=2GiB", "--http-addr=localhost:8086", "--cache=512MiB", "--max-sql-memory=512MiB" ] image: cockroachdb/cockroach ports: - - "26256:26257" + - "26356:26257" crdb2: hostname: crdb2 - command: [ "start-single-node", "--insecure" ] + command: [ "start-single-node", "--insecure", "--store=type=mem,size=2GiB", "--http-addr=localhost:8086", "--cache=512MiB", "--max-sql-memory=512MiB" ] image: cockroachdb/cockroach ports: - - "26257:26257" + - "26357:26257" crdb3: hostname: crdb3 - command: [ "start-single-node", "--insecure" ] + command: [ "start-single-node", "--insecure", "--store=type=mem,size=2GiB", "--http-addr=localhost:8086", "--cache=512MiB", "--max-sql-memory=512MiB" ] image: cockroachdb/cockroach ports: - - "26258:26257" + - "26358:26257" crdb4: hostname: crdb4 - command: [ "start-single-node", "--insecure" ] + command: [ "start-single-node", "--insecure", "--store=type=mem,size=2GiB", "--http-addr=localhost:8086", "--cache=512MiB", "--max-sql-memory=512MiB" ] image: cockroachdb/cockroach ports: - - "26259:26257" + - "26359:26257" crdb5: hostname: crdb5 - command: [ "start-single-node", "--insecure" ] + command: [ "start-single-node", "--insecure", "--store=type=mem,size=2GiB", "--http-addr=localhost:8086", "--cache=512MiB", "--max-sql-memory=512MiB" ] image: cockroachdb/cockroach ports: - - "26260:26257" + - "26360:26257"