mirror of https://github.com/status-im/consul.git
Adds an FSM persist and restore test for tagged addresses.
This commit is contained in:
parent
b59599742d
commit
33462ebea9
|
@ -360,7 +360,7 @@ func TestFSM_SnapshotRestore(t *testing.T) {
|
||||||
|
|
||||||
// Add some state
|
// Add some state
|
||||||
fsm.state.EnsureNode(1, &structs.Node{Node: "foo", Address: "127.0.0.1"})
|
fsm.state.EnsureNode(1, &structs.Node{Node: "foo", Address: "127.0.0.1"})
|
||||||
fsm.state.EnsureNode(2, &structs.Node{Node: "baz", Address: "127.0.0.2"})
|
fsm.state.EnsureNode(2, &structs.Node{Node: "baz", Address: "127.0.0.2", TaggedAddresses: map[string]string{"hello": "1.2.3.4"}})
|
||||||
fsm.state.EnsureService(3, "foo", &structs.NodeService{ID: "web", Service: "web", Tags: nil, Address: "127.0.0.1", Port: 80})
|
fsm.state.EnsureService(3, "foo", &structs.NodeService{ID: "web", Service: "web", Tags: nil, Address: "127.0.0.1", Port: 80})
|
||||||
fsm.state.EnsureService(4, "foo", &structs.NodeService{ID: "db", Service: "db", Tags: []string{"primary"}, Address: "127.0.0.1", Port: 5000})
|
fsm.state.EnsureService(4, "foo", &structs.NodeService{ID: "db", Service: "db", Tags: []string{"primary"}, Address: "127.0.0.1", Port: 5000})
|
||||||
fsm.state.EnsureService(5, "baz", &structs.NodeService{ID: "web", Service: "web", Tags: nil, Address: "127.0.0.2", Port: 80})
|
fsm.state.EnsureService(5, "baz", &structs.NodeService{ID: "web", Service: "web", Tags: nil, Address: "127.0.0.2", Port: 80})
|
||||||
|
@ -453,7 +453,18 @@ func TestFSM_SnapshotRestore(t *testing.T) {
|
||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
}
|
}
|
||||||
if len(nodes) != 2 {
|
if len(nodes) != 2 {
|
||||||
t.Fatalf("Bad: %v", nodes)
|
t.Fatalf("bad: %v", nodes)
|
||||||
|
}
|
||||||
|
if nodes[0].Node != "baz" ||
|
||||||
|
nodes[0].Address != "127.0.0.2" ||
|
||||||
|
len(nodes[0].TaggedAddresses) != 1 ||
|
||||||
|
nodes[0].TaggedAddresses["hello"] != "1.2.3.4" {
|
||||||
|
t.Fatalf("bad: %v", nodes[0])
|
||||||
|
}
|
||||||
|
if nodes[1].Node != "foo" ||
|
||||||
|
nodes[1].Address != "127.0.0.1" ||
|
||||||
|
len(nodes[1].TaggedAddresses) != 0 {
|
||||||
|
t.Fatalf("bad: %v", nodes[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
_, fooSrv, err := fsm2.state.NodeServices("foo")
|
_, fooSrv, err := fsm2.state.NodeServices("foo")
|
||||||
|
|
Loading…
Reference in New Issue