etcd: implement separate system tests

- add t13_etcd test directory
- etcd will be started for the unit tests and each system test
- etcd will load fixture DB export if requested by the test
- existing tests are reused for etcd testing
This commit is contained in:
André Roth
2024-04-21 14:33:15 +02:00
parent f10acb3df8
commit 640c202ee5
57 changed files with 571 additions and 63 deletions
+11 -14
View File
@@ -12,16 +12,13 @@ COVERAGE_DIR?=$(shell mktemp -d)
# Uncomment to update test outputs
# CAPTURE := "--capture"
all: modules test bench check system-test system-test-etcd
all: modules test bench check system-test
# Self-documenting Makefile
# https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
help: ## Print this help
@grep -E '^[a-zA-Z][a-zA-Z0-9_-]*:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
prepare:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin $(GOLANGCI_LINT_VERSION)
modules:
go mod download
go mod verify
@@ -53,9 +50,14 @@ endif
system-test: install system/env
ifeq ($(RUN_LONG_TESTS), yes)
go generate
test -d /srv/etcd || system/t13_etcd/install-etcd.sh
system/t13_etcd/start-etcd.sh &
go test -v -coverpkg="./..." -c -tags testruncli
kill `cat /tmp/etcd.pid`
if [ ! -e ~/aptly-fixture-db ]; then git clone https://github.com/aptly-dev/aptly-fixture-db.git ~/aptly-fixture-db/; fi
if [ ! -e ~/aptly-fixture-pool ]; then git clone https://github.com/aptly-dev/aptly-fixture-pool.git ~/aptly-fixture-pool/; fi
cd /home/runner; curl -O http://repo.aptly.info/system-tests/etcd.db
PATH=$(BINPATH)/:$(PATH) && . system/env/bin/activate && APTLY_VERSION=$(VERSION) FORCE_COLOR=1 $(PYTHON) system/run.py --long $(TESTS) --coverage-dir $(COVERAGE_DIR) $(CAPTURE)
endif
@@ -69,16 +71,11 @@ docker-test: install
$(PYTHON) system/run.py --long $(TESTS) --coverage-dir $(COVERAGE_DIR) $(CAPTURE) $(TEST)
test:
test -d /srv/etcd || system/t13_etcd/install-etcd.sh
system/t13_etcd/start-etcd.sh &
echo Running go test
go test -v ./... -gocheck.v=true -coverprofile=unit.out
system-test-etcd: install system/env
ifeq ($(RUN_LONG_TESTS), yes)
if [ ! -e ~/aptly-fixture-db ]; then git clone https://github.com/aptly-dev/aptly-fixture-db.git ~/aptly-fixture-db/; fi
if [ ! -e ~/aptly-fixture-pool ]; then git clone https://github.com/aptly-dev/aptly-fixture-pool.git ~/aptly-fixture-pool/; fi
# TODO: maybe we can skip imgrading levledb data to etcd
PATH=$(BINPATH)/:$(PATH) && . system/env/bin/activate && $(PYTHON) system/leveldb2etcd.py --datadir ~/aptly-fixture-db
PATH=$(BINPATH)/:$(PATH) && . system/env/bin/activate && APTLY_DATABASE_TYPE="etcd" APTLY_DATABASE_URL="127.0.0.1:2379" APTLY_VERSION=$(VERSION) $(PYTHON) system/run.py --long $(TESTS)
endif
kill `cat /tmp/etcd.pid`
bench:
go test -v ./deb -run=nothing -bench=. -benchmem
@@ -113,7 +110,7 @@ docker-build-system-tests: ## Build system-test docker image
docker build -f system/Dockerfile . -t aptly-system-test
docker-unit-tests: ## Run unit tests in docker container
docker run -it --rm -v ${PWD}:/app aptly-system-test go test -v ./... -gocheck.v=true
docker run -it --rm -v ${PWD}:/app aptly-system-test /app/system/run-unit-tests
docker-system-tests: ## Run system tests in docker container (add TEST=t04_mirror to run only specific tests)
docker run -it --rm -v ${PWD}:/app aptly-system-test /app/system/run-system-tests $(TEST)