Skip to content

Commit 7cb7de9

Browse files
committed
Update CI for moved migrations.
Signed-off-by: Tom Wilkie <[email protected]>
1 parent 310897b commit 7cb7de9

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
- checkout
5757
- run:
5858
name: Integration Test
59-
command: MIGRATIONS_DIR=$(pwd)/pkg/configs/db/migrations make BUILD_IN_CONTAINER=false configs-integration-test
59+
command: MIGRATIONS_DIR=$(pwd)/cmd/cortex/migrations make BUILD_IN_CONTAINER=false configs-integration-test
6060

6161
build:
6262
<<: *defaults

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ configs-integration-test: build-image/$(UPTODATE)
101101
-v $(shell pwd)/.pkg:/go/pkg \
102102
-v $(shell pwd):/go/src/github.com/cortexproject/cortex \
103103
-v $(shell pwd)/cmd/cortex/migrations:/migrations \
104-
-e MIGRATIONS_DIR=/migrations \
105104
--workdir /go/src/github.com/cortexproject/cortex \
106105
--link "$$DB_CONTAINER":configs-db.cortex.local \
106+
-e DB_ADDR=configs-db.cortex.local \
107107
$(IMAGE_PREFIX)build-image $@; \
108108
status=$$?; \
109109
test -n "$(CIRCLECI)" || docker rm -f "$$DB_CONTAINER"; \
@@ -136,7 +136,7 @@ shell:
136136
bash
137137

138138
configs-integration-test:
139-
/bin/bash -c "go test -tags 'netgo integration' -timeout 30s ./pkg/configs/... ./pkg/ruler/..."
139+
/bin/bash -c "go test -v -tags 'netgo integration' -timeout 30s ./pkg/configs/... ./pkg/ruler/..."
140140

141141
mod-check:
142142
GO111MODULE=on go mod download
@@ -167,7 +167,7 @@ load-images:
167167
fi \
168168
done
169169

170-
# Loads the built Docker images into the minikube environmen, and tags them with
170+
# Loads the built Docker images into the minikube environment, and tags them with
171171
# "latest" so the k8s manifests shipped with this code work.
172172
prime-minikube: save-images
173173
eval $$(minikube docker-env) ; \

pkg/configs/db/dbtest/integration.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,29 @@ import (
1616

1717
var (
1818
done chan error
19+
dbAddr string
20+
migrationsDir string
1921
errRollback = fmt.Errorf("Rolling back test data")
20-
migrationsDir = os.Getenv("MIGRATIONS_DIR")
2122
)
2223

24+
func init() {
25+
dbAddr = os.Getenv("DB_ADDR")
26+
if dbAddr == "" {
27+
dbAddr = "127.0.0.1"
28+
}
29+
30+
migrationsDir = os.Getenv("MIGRATIONS_DIR")
31+
if migrationsDir == "" {
32+
migrationsDir = "/migrations"
33+
}
34+
}
35+
2336
// Setup sets up stuff for testing, creating a new database
2437
func Setup(t *testing.T) db.DB {
2538
require.NoError(t, logging.Setup("debug"))
2639
// Don't use db.MustNew, here so we can do a transaction around the whole test, to rollback.
2740
pg, err := postgres.New(
28-
"postgres://postgres@127.0.0.1/configs_test?sslmode=disable",
41+
fmt.Sprintf("postgres://postgres@%s/configs_test?sslmode=disable", dbAddr),
2942
migrationsDir,
3043
)
3144
require.NoError(t, err)

0 commit comments

Comments
 (0)