feat: Add system test for etcd

This commit is contained in:
hudeng
2022-02-09 18:21:00 +08:00
committed by André Roth
parent 78172d11d7
commit f29449db14
4 changed files with 46 additions and 14 deletions
+11 -13
View File
@@ -12,11 +12,7 @@ COVERAGE_DIR?=$(shell mktemp -d)
# Uncomment to update test outputs
# CAPTURE := "--capture"
# etcd test env
ETCD_VER=v3.5.2
DOWNLOAD_URL=https://storage.googleapis.com/etcd
all: modules test bench check system-test
all: modules test bench check system-test system-test-etcd
# Self-documenting Makefile
# https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
@@ -26,13 +22,6 @@ help: ## Print this help
prepare:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin $(GOLANGCI_LINT_VERSION)
etcd-prepare:
# etcd test prepare
rm -rf /tmp/etcd-download-test/test-data && mkdir -p /tmp/etcd-download-test/test-data
if [ ! -e /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz ]; then curl -L ${DOWNLOAD_URL}/${ETCD_VER}/etcd-${ETCD_VER}-linux-amd64.tar.gz -o /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz; fi
tar xzvf /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz -C /tmp/etcd-download-test --strip-components=1
/tmp/etcd-download-test/etcd --data-dir /tmp/etcd-download-test/test-data &
modules:
go mod download
go mod verify
@@ -79,9 +68,18 @@ docker-test: install
export APTLY_VERSION=$(VERSION); \
$(PYTHON) system/run.py --long $(TESTS) --coverage-dir $(COVERAGE_DIR) $(CAPTURE) $(TEST)
test: etcd-prepare
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 && APTLY_VERSION=$(VERSION) $(PYTHON) system/leveldb2etcd.py --datadir ~/aptly-fixture-db
PATH=$(BINPATH)/:$(PATH) && . system/env/bin/activate && APTLY_ETCD_DATABASE="127.0.0.1:2379" APTLY_VERSION=$(VERSION) $(PYTHON) system/run.py --long $(TESTS)
endif
bench:
go test -v ./deb -run=nothing -bench=. -benchmem