Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • gitlab-org/build/omnibus-mirror/redis_exporter
1 result
Show changes
Commits on Source (3)
Loading
@@ -34,6 +34,7 @@ steps:
Loading
@@ -34,6 +34,7 @@ steps:
- name: tests - name: tests
image: "golang:1.12" image: "golang:1.12"
environment: environment:
LOG_LEVEL: "debug"
TEST_TILE38_URI: "tile38:9851" TEST_TILE38_URI: "tile38:9851"
TEST_SECOND_REDIS_URI: "redis://moar-redis:6380" TEST_SECOND_REDIS_URI: "redis://moar-redis:6380"
TEST_REDIS_CLUSTER_MASTER_URI: "redis-cluster:7000" TEST_REDIS_CLUSTER_MASTER_URI: "redis-cluster:7000"
Loading
@@ -45,7 +46,7 @@ steps:
Loading
@@ -45,7 +46,7 @@ steps:
- 'echo " ! gofmt -d exporter/*.go 2>&1 | read " | bash' - 'echo " ! gofmt -d exporter/*.go 2>&1 | read " | bash'
- 'go vet ./exporter/...' - 'go vet ./exporter/...'
- 'go build' - 'go build'
- "sleep 10" - "sleep 2"
- 'go test -v -covermode=atomic -cover -race -coverprofile=coverage.txt ./exporter/... --redis.addr=redis' - 'go test -v -covermode=atomic -cover -race -coverprofile=coverage.txt ./exporter/... --redis.addr=redis'
- 'go get github.com/mattn/goveralls' - 'go get github.com/mattn/goveralls'
- '/go/bin/goveralls -coverprofile=coverage.txt -service=drone.io' - '/go/bin/goveralls -coverprofile=coverage.txt -service=drone.io'
Loading
Loading
Loading
@@ -1043,6 +1043,8 @@ func (e *Exporter) scrape(scrapes chan<- scrapeResult) {
Loading
@@ -1043,6 +1043,8 @@ func (e *Exporter) scrape(scrapes chan<- scrapeResult) {
now := time.Now().UnixNano() now := time.Now().UnixNano()
e.totalScrapes.Inc() e.totalScrapes.Inc()
   
log.Printf("e.redis.Addrs: %#v", e.redis.Addrs)
errorCount := 0 errorCount := 0
for idx, addr := range e.redis.Addrs { for idx, addr := range e.redis.Addrs {
var up float64 = 1 var up float64 = 1
Loading
Loading
Loading
@@ -9,7 +9,6 @@ package exporter
Loading
@@ -9,7 +9,6 @@ package exporter
*/ */
   
import ( import (
"bytes"
"flag" "flag"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
Loading
@@ -152,7 +151,7 @@ func resetSlowLog(t *testing.T, addr string) error {
Loading
@@ -152,7 +151,7 @@ func resetSlowLog(t *testing.T, addr string) error {
return nil return nil
} }
   
func downloadUrl(t *testing.T, url string) []byte { func downloadUrl(t *testing.T, url string) string {
log.Debugf("downloadURL() %s", url) log.Debugf("downloadURL() %s", url)
resp, err := http.Get(url) resp, err := http.Get(url)
if err != nil { if err != nil {
Loading
@@ -163,7 +162,7 @@ func downloadUrl(t *testing.T, url string) []byte {
Loading
@@ -163,7 +162,7 @@ func downloadUrl(t *testing.T, url string) []byte {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
return body return string(body)
} }
   
func TestLatencySpike(t *testing.T) { func TestLatencySpike(t *testing.T) {
Loading
@@ -1044,7 +1043,7 @@ func TestHTTPEndpoint(t *testing.T) {
Loading
@@ -1044,7 +1043,7 @@ func TestHTTPEndpoint(t *testing.T) {
`cmd="get"`, `cmd="get"`,
} }
for _, test := range tests { for _, test := range tests {
if !bytes.Contains(body, []byte(test)) { if !strings.Contains(body, test) {
t.Errorf("want metrics to include %q, have:\n%s", test, body) t.Errorf("want metrics to include %q, have:\n%s", test, body)
} }
} }
Loading
@@ -1223,16 +1222,14 @@ func TestKeysReset(t *testing.T) {
Loading
@@ -1223,16 +1222,14 @@ func TestKeysReset(t *testing.T) {
}() }()
   
body := downloadUrl(t, ts.URL+"/metrics") body := downloadUrl(t, ts.URL+"/metrics")
if !strings.Contains(body, keys[0]) {
if !bytes.Contains(body, []byte(keys[0])) {
t.Errorf("Did not found key %q\n%s", keys[0], body) t.Errorf("Did not found key %q\n%s", keys[0], body)
} }
   
deleteKeysFromDB(t, defaultRedisHost.Addrs[0]) deleteKeysFromDB(t, defaultRedisHost.Addrs[0])
   
body = downloadUrl(t, ts.URL+"/metrics") body = downloadUrl(t, ts.URL+"/metrics")
if strings.Contains(body, keys[0]) {
if bytes.Contains(body, []byte(keys[0])) {
t.Errorf("Metric is present in metrics list %q\n%s", keys[0], body) t.Errorf("Metric is present in metrics list %q\n%s", keys[0], body)
} }
} }
Loading
@@ -1249,10 +1246,11 @@ func TestClusterMaster(t *testing.T) {
Loading
@@ -1249,10 +1246,11 @@ func TestClusterMaster(t *testing.T) {
   
addr := "redis://" + os.Getenv("TEST_REDIS_CLUSTER_MASTER_URI") addr := "redis://" + os.Getenv("TEST_REDIS_CLUSTER_MASTER_URI")
host := RedisHost{Addrs: []string{addr}, Aliases: []string{"master"}} host := RedisHost{Addrs: []string{addr}, Aliases: []string{"master"}}
log.Printf("master - using host cfg: %#v", host)
e, _ := NewRedisExporter(host, "test", "", "") e, _ := NewRedisExporter(host, "test", "", "")
   
setupDBKeys(t, defaultRedisHost.Addrs[0]) setupDBKeys(t, addr)
defer deleteKeysFromDB(t, defaultRedisHost.Addrs[0]) defer deleteKeysFromDB(t, addr)
prometheus.Register(e) prometheus.Register(e)
   
chM := make(chan prometheus.Metric, 10000) chM := make(chan prometheus.Metric, 10000)
Loading
@@ -1262,9 +1260,11 @@ func TestClusterMaster(t *testing.T) {
Loading
@@ -1262,9 +1260,11 @@ func TestClusterMaster(t *testing.T) {
}() }()
   
body := downloadUrl(t, ts.URL+"/metrics") body := downloadUrl(t, ts.URL+"/metrics")
log.Printf("body: %s", body) log.Printf("master - body: %s", body)
if !bytes.Contains(body, []byte("test_instance_info")) { for _, want := range []string{"test_instance_info", "test_master_repl_offset"} {
t.Errorf("Did not found key %q\n%s", keys[0], body) if !strings.Contains(body, want) {
t.Errorf("Did not find key [%s] \nbody: %s", want, body)
}
} }
} }
   
Loading
@@ -1312,8 +1312,8 @@ func TestPasswordProtectedInstance(t *testing.T) {
Loading
@@ -1312,8 +1312,8 @@ func TestPasswordProtectedInstance(t *testing.T) {
   
body := downloadUrl(t, ts.URL+"/metrics") body := downloadUrl(t, ts.URL+"/metrics")
   
if !bytes.Contains(body, []byte("test_up")) { if !strings.Contains(body, "test_up") {
t.Errorf("error") t.Errorf("error, missing test_up")
} }
} }
   
Loading
@@ -1360,7 +1360,7 @@ func TestPasswordInvalid(t *testing.T) {
Loading
@@ -1360,7 +1360,7 @@ func TestPasswordInvalid(t *testing.T) {
}() }()
   
body := downloadUrl(t, ts.URL+"/metrics") body := downloadUrl(t, ts.URL+"/metrics")
if !bytes.Contains(body, []byte("test_exporter_last_scrape_error 1")) { if !strings.Contains(body, "test_exporter_last_scrape_error 1") {
t.Errorf(`error, expected string "test_exporter_last_scrape_error 1" in body`) t.Errorf(`error, expected string "test_exporter_last_scrape_error 1" in body`)
} }
} }
Loading
@@ -1377,6 +1377,7 @@ func TestClusterSlave(t *testing.T) {
Loading
@@ -1377,6 +1377,7 @@ func TestClusterSlave(t *testing.T) {
   
addr := "redis://" + os.Getenv("TEST_REDIS_CLUSTER_SLAVE_URI") addr := "redis://" + os.Getenv("TEST_REDIS_CLUSTER_SLAVE_URI")
host := RedisHost{Addrs: []string{addr}, Aliases: []string{"slave"}} host := RedisHost{Addrs: []string{addr}, Aliases: []string{"slave"}}
log.Printf("slave - using host cfg: %#v", host)
e, _ := NewRedisExporter(host, "test", "", "") e, _ := NewRedisExporter(host, "test", "", "")
   
setupDBKeys(t, defaultRedisHost.Addrs[0]) setupDBKeys(t, defaultRedisHost.Addrs[0])
Loading
@@ -1390,8 +1391,8 @@ func TestClusterSlave(t *testing.T) {
Loading
@@ -1390,8 +1391,8 @@ func TestClusterSlave(t *testing.T) {
}() }()
   
body := downloadUrl(t, ts.URL+"/metrics") body := downloadUrl(t, ts.URL+"/metrics")
log.Printf("body: %s", body) log.Printf("slave - body: %s", body)
if !bytes.Contains(body, []byte("test_instance_info")) { if !strings.Contains(body, "test_instance_info") {
t.Errorf("Did not found key %q\n%s", keys[0], body) t.Errorf("Did not found key %q\n%s", keys[0], body)
} }
} }
Loading
Loading