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