Skip to content

Commit

Permalink
Updated Prom dep; cleaned and fixed leaking unit tests. (#1450)
Browse files Browse the repository at this point in the history
Signed-off-by: Bartek Plotka <[email protected]>
  • Loading branch information
bwplotka authored Aug 26, 2019
1 parent 8feb079 commit af53b38
Show file tree
Hide file tree
Showing 31 changed files with 732 additions and 3,182 deletions.
18 changes: 5 additions & 13 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,14 @@ jobs:
- run: make format
- run:
name: "Run all tests"
# TODO(bplotka): Setup some S3 tests for CI.
# TODO(bwplotka): Setup some S3 tests for CI.
# taskset sets CPU affinity to 2 (current CPU limit).
command: |
if [ -z ${GCP_PROJECT} ]; then
export THANOS_SKIP_GCS_TESTS="true"
echo "Skipping GCS tests."
taskset 2 make test-local
exit
fi
export THANOS_SKIP_S3_AWS_TESTS="true"
echo "Skipping AWS tests."
export THANOS_SKIP_AZURE_TESTS="true"
echo "Skipping Azure tests."
export THANOS_SKIP_SWIFT_TESTS="true"
echo "Skipping SWIFT tests."
export THANOS_SKIP_TENCENT_COS_TESTS="true"
echo "Skipping TENCENT COS tests."
make test
taskset 2 make test-only-gcs
# Cross build is needed for publish_release but needs to be done outside of docker.
cross_build:
Expand Down
11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,12 @@ tarballs-release: $(PROMU)

# test runs all Thanos golang tests against each supported version of Prometheus.
.PHONY: test
test: export GOCACHE= $(TMP_GOPATH)/gocache
test: check-git test-deps
# Be careful on GOCACHE. Those tests are sometimes using built Thanos/Prometheus binaries directly. Don't cache those.
@rm -rf ${GOCACHE}
@echo ">> running all tests. Do export THANOS_SKIP_GCS_TESTS='true' or/and THANOS_SKIP_S3_AWS_TESTS='true' or/and THANOS_SKIP_AZURE_TESTS='true' and/or THANOS_SKIP_SWIFT_TESTS='true' and/or THANOS_SKIP_TENCENT_COS_TESTS='true' if you want to skip e2e tests against real store buckets"
THANOS_TEST_PROMETHEUS_VERSIONS="$(PROM_VERSIONS)" THANOS_TEST_ALERTMANAGER_PATH="alertmanager-$(ALERTMANAGER_VERSION)" go test $(shell go list ./... | grep -v /vendor/ | grep -v /benchmark/);
THANOS_TEST_PROMETHEUS_VERSIONS="$(PROM_VERSIONS)" THANOS_TEST_ALERTMANAGER_PATH="alertmanager-$(ALERTMANAGER_VERSION)" go test $(shell go list ./... | grep -v /vendor/);

.PHONY: test-only-gcs
test-only-gcs: export THANOS_SKIP_S3_AWS_TESTS = true
Expand All @@ -203,6 +206,7 @@ test-local:
# It installs current Thanos, supported versions of Prometheus and alertmanager to test against in e2e.
.PHONY: test-deps
test-deps:
@echo ">> install thanos GOOPTS=${GOOPTS}"
@go install github.com/thanos-io/thanos/cmd/thanos
$(foreach ver,$(PROM_VERSIONS),$(call fetch_go_bin_version,github.com/prometheus/prometheus/cmd/prometheus,$(ver)))
$(call fetch_go_bin_version,github.com/prometheus/alertmanager/cmd/alertmanager,$(ALERTMANAGER_VERSION))
Expand All @@ -217,7 +221,6 @@ else
@echo >&2 "No git binary found."; exit 1
endif


.PHONY: web-pre-process
web-pre-process:
@echo ">> running documentation website pre processing"
Expand All @@ -237,8 +240,8 @@ web: web-pre-process $(HUGO)
#
# to debug big allocations during linting.
lint: check-git $(GOLANGCILINT) $(MISSPELL)
@echo ">> linting all of the Go files"
@$(GOLANGCILINT) run -v --enable goimports --enable goconst --skip-dirs vendor
@echo ">> linting all of the Go files GOGC=${GOGC}"
@$(GOLANGCILINT) run --enable goimports --enable goconst --skip-dirs vendor
@echo ">> detecting misspells"
@find . -type f | grep -v vendor/ | grep -vE '\./\..*' | xargs $(MISSPELL) -error

Expand Down
3 changes: 1 addition & 2 deletions cmd/thanos/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,7 @@ func runQuery(
}

ins := extpromhttp.NewInstrumentationMiddleware(reg)

ui.NewQueryUI(logger, stores, flagsMap).Register(router.WithPrefix(webRoutePrefix), ins)
ui.NewQueryUI(logger, reg, stores, flagsMap).Register(router.WithPrefix(webRoutePrefix), ins)

api := v1.NewAPI(logger, reg, engine, queryableCreator, enableAutodownsampling, enablePartialResponse)

Expand Down
4 changes: 2 additions & 2 deletions cmd/thanos/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,9 +529,9 @@ func runRule(

ins := extpromhttp.NewInstrumentationMiddleware(reg)

ui.NewRuleUI(logger, ruleMgrs, alertQueryURL.String(), flagsMap).Register(router.WithPrefix(webRoutePrefix), ins)
ui.NewRuleUI(logger, reg, ruleMgrs, alertQueryURL.String(), flagsMap).Register(router.WithPrefix(webRoutePrefix), ins)

api := v1.NewAPI(logger, ruleMgrs)
api := v1.NewAPI(logger, reg, ruleMgrs)
api.Register(router.WithPrefix(path.Join(webRoutePrefix, "/api/v1")), tracer, logger, ins)

mux := http.NewServeMux()
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ require (
github.com/pkg/errors v0.8.1
github.com/prometheus/client_golang v1.1.0
github.com/prometheus/common v0.6.0
github.com/prometheus/prometheus v0.0.0-20190814090039-b5c833ca2194
github.com/prometheus/prometheus v1.8.2-0.20190819201610-48b2c9c8eae2 // v1.8.2 is misleading as Prometheus does not have v2 module. This is pointing to one commit after 2.12.0.
github.com/uber-go/atomic v1.4.0 // indirect
github.com/uber/jaeger-client-go v2.16.0+incompatible
github.com/uber/jaeger-lib v2.0.0+incompatible
Expand Down
Loading

0 comments on commit af53b38

Please sign in to comment.