mirror of https://github.com/status-im/consul.git
Fixing some tests
This commit is contained in:
parent
c0029c6967
commit
028829a36d
|
@ -213,13 +213,18 @@ func TestCatalogListNodes(t *testing.T) {
|
|||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
if len(out) != 1 {
|
||||
if len(out) != 2 {
|
||||
t.Fatalf("bad: %v", out)
|
||||
}
|
||||
if out[0].Node != "foo" {
|
||||
|
||||
// Server node is auto added from Serf
|
||||
if out[0].Node != s1.config.NodeName {
|
||||
t.Fatalf("bad: %v", out)
|
||||
}
|
||||
if out[0].Address != "127.0.0.1" {
|
||||
if out[1].Node != "foo" {
|
||||
t.Fatalf("bad: %v", out)
|
||||
}
|
||||
if out[1].Address != "127.0.0.1" {
|
||||
t.Fatalf("bad: %v", out)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,11 +40,16 @@ func TestHealth_ChecksInState(t *testing.T) {
|
|||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
if len(checks) != 1 {
|
||||
if len(checks) != 2 {
|
||||
t.Fatalf("Bad: %v", checks)
|
||||
}
|
||||
if checks[0].Name != "memory utilization" {
|
||||
t.Fatalf("Bad: %v", checks)
|
||||
|
||||
// First check is automatically added for the server node
|
||||
if checks[0].CheckID != serfCheckID {
|
||||
t.Fatalf("Bad: %v", checks[0])
|
||||
}
|
||||
if checks[1].Name != "memory utilization" {
|
||||
t.Fatalf("Bad: %v", checks[1])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package consul
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/serf/serf"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
@ -31,3 +32,31 @@ func TestIsPrivateIP(t *testing.T) {
|
|||
t.Fatalf("bad")
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsConsulServer(t *testing.T) {
|
||||
m := serf.Member{
|
||||
Role: "consul:east-aws:10000",
|
||||
}
|
||||
valid, dc, port := isConsulServer(m)
|
||||
if !valid || dc != "east-aws" || port != 10000 {
|
||||
t.Fatalf("bad: %v %v %v", valid, dc, port)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsConsulNode(t *testing.T) {
|
||||
m := serf.Member{
|
||||
Role: "node:east-aws",
|
||||
}
|
||||
valid, dc := isConsulNode(m)
|
||||
if !valid || dc != "east-aws" {
|
||||
t.Fatalf("bad: %v %v %v", valid, dc)
|
||||
}
|
||||
}
|
||||
|
||||
func TestByteConversion(t *testing.T) {
|
||||
var val uint64 = 2 << 50
|
||||
raw := uint64ToBytes(val)
|
||||
if bytesToUint64(raw) != val {
|
||||
t.Fatalf("no match")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue