Skip to content
Snippets Groups Projects
Commit 7c1e78bb authored by Oliver's avatar Oliver
Browse files

bytes,. i never liked you

parent 2d55bcfd
No related branches found
No related tags found
No related merge requests found
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,6 +1246,7 @@ 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])
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("slave - 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment