diff --git a/.drone.yml b/.drone.yml index 158bbdaa..823ff420 100644 --- a/.drone.yml +++ b/.drone.yml @@ -13,6 +13,8 @@ services: - 6379 - name: moar-redis image: redis:5 + commands: + - /usr/local/bin/redis-server --port 6380 ports: - 6380 - name: redis-cluster diff --git a/Dockerfile b/Dockerfile index e6d4dfff..4c886077 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ ENV TAG=$TAG RUN apk --no-cache add ca-certificates RUN BUILD_DATE=$(date +%F-%T) && CGO_ENABLED=0 GOOS=linux go build -o /redis_exporter \ - -ldflags "-s -w -extldflags \"-static\" -X main.VERSION=$TAG -X main.COMMIT_SHA1=$SHA1 -X main.BUILD_DATE=$BUILD_DATE" . + -ldflags "-s -w -extldflags \"-static\" -X main.BuildVersion=$TAG -X main.BuildCommitSha=$SHA1 -X main.BuildDate=$BUILD_DATE" . RUN /redis_exporter -version diff --git a/build-github-binaries.sh b/build-github-binaries.sh index 322a7c01..302636ad 100755 --- a/build-github-binaries.sh +++ b/build-github-binaries.sh @@ -10,7 +10,7 @@ fi echo "Building binaries for Github" echo "" export CGO_ENABLED=0 -export GO_LDFLAGS="-s -w -extldflags \"-static\" -X main.VERSION=$DRONE_TAG -X main.COMMIT_SHA1=$DRONE_COMMIT_SHA -X main.BUILD_DATE=$(date +%F-%T)" +export GO_LDFLAGS="-s -w -extldflags \"-static\" -X main.BuildVersion=$DRONE_TAG -X main.BuildCommitSha=$DRONE_COMMIT_SHA -X main.BuildDate=$(date +%F-%T)" echo "GO_LDFLAGS: $GO_LDFLAGS" go get github.com/mitchellh/gox diff --git a/exporter/redis_test.go b/exporter/redis_test.go index 4e0fbcfb..dcd8bdd3 100644 --- a/exporter/redis_test.go +++ b/exporter/redis_test.go @@ -1104,25 +1104,24 @@ func TestNonExistingHost(t *testing.T) { } func TestMoreThanOneHost(t *testing.T) { - firstHost := defaultRedisHost.Addrs[0] secondHostURI := os.Getenv("TEST_SECOND_REDIS_URI") if secondHostURI == "" { - secondHostURI = "redis://localhost:6380" + log.Printf("TEST_SECOND_REDIS_URI not set - skipping test") + t.SkipNow() + return } c, err := redis.DialURL(secondHostURI) if err != nil { - log.Printf("couldn't connect to second redis host, err: %s - skipping test \n", err) - t.SkipNow() + t.Errorf("couldn't connect to second redis host, err: %s - skipping test \n", err) return } defer c.Close() _, err = c.Do("PING") if err != nil { - log.Printf("couldn't connect to second redis host, err: %s - skipping test \n", err) - t.SkipNow() + t.Errorf("couldn't connect to second redis host, err: %s - skipping test \n", err) return } defer c.Close() @@ -1135,16 +1134,14 @@ func TestMoreThanOneHost(t *testing.T) { _, err = c.Do("SELECT", dbNumStr) if err != nil { - log.Printf("couldn't connect to second redis host, err: %s - skipping test \n", err) - t.SkipNow() + t.Errorf("couldn't connect to second redis host, err: %s - skipping test \n", err) return } secondHostValue := float64(5678.9) _, err = c.Do("SET", keys[0], secondHostValue) if err != nil { - log.Printf("couldn't connect to second redis host, err: %s - skipping test \n", err) - t.SkipNow() + t.Errorf("couldn't connect to second redis host, err: %s - skipping test \n", err) return } diff --git a/main.go b/main.go index 39fc59eb..86a83343 100644 --- a/main.go +++ b/main.go @@ -15,10 +15,10 @@ import ( ) var ( - // VERSION, BUILD_DATE, GIT_COMMIT are filled in by the build script - VERSION = "<<< filled in by build >>>" - BUILD_DATE = "<<< filled in by build >>>" - COMMIT_SHA1 = "<<< filled in by build >>>" + // BuildVersion, BuildDate, BuildCommitSha are filled in by the build script + BuildVersion = "<<< filled in by build >>>" + BuildDate = "<<< filled in by build >>>" + BuildCommitSha = "<<< filled in by build >>>" ) func getEnv(key string, defaultVal string) string { @@ -64,7 +64,7 @@ func main() { log.SetFormatter(&log.TextFormatter{}) } log.Printf("Redis Metrics Exporter %s build date: %s sha1: %s Go: %s", - VERSION, BUILD_DATE, COMMIT_SHA1, + BuildVersion, BuildDate, BuildCommitSha, runtime.Version(), ) if *isDebug { @@ -131,7 +131,7 @@ func main() { Name: "redis_exporter_build_info", Help: "redis exporter build_info", }, []string{"version", "commit_sha", "build_date", "golang_version"}) - buildInfo.WithLabelValues(VERSION, COMMIT_SHA1, BUILD_DATE, runtime.Version()).Set(1) + buildInfo.WithLabelValues(BuildVersion, BuildCommitSha, BuildDate, runtime.Version()).Set(1) if *redisMetricsOnly { registry := prometheus.NewRegistry() @@ -147,9 +147,9 @@ func main() { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte(` -Redis Exporter v` + VERSION + ` +Redis Exporter v` + BuildVersion + ` -

Redis Exporter ` + VERSION + `

+

Redis Exporter ` + BuildVersion + `

Metrics