Add "cluster introducer" functionality to nodes (ref #120)

This commit is contained in:
Jakob Borg
2014-09-23 16:04:20 +02:00
parent 24e5000c37
commit e596a45e9f
9 changed files with 133 additions and 17 deletions

View File

@@ -306,7 +306,8 @@ func TestClusterConfig(t *testing.T) {
cfg := config.New("/tmp/test", node1)
cfg.Nodes = []config.NodeConfiguration{
{
NodeID: node1,
NodeID: node1,
Introducer: true,
},
{
NodeID: node2,
@@ -351,9 +352,15 @@ func TestClusterConfig(t *testing.T) {
if id := r.Nodes[0].ID; bytes.Compare(id, node1[:]) != 0 {
t.Errorf("Incorrect node ID %x != %x", id, node1)
}
if r.Nodes[0].Flags&protocol.FlagIntroducer == 0 {
t.Error("Node1 should be flagged as Introducer")
}
if id := r.Nodes[1].ID; bytes.Compare(id, node2[:]) != 0 {
t.Errorf("Incorrect node ID %x != %x", id, node2)
}
if r.Nodes[1].Flags&protocol.FlagIntroducer != 0 {
t.Error("Node2 should not be flagged as Introducer")
}
r = cm.Repositories[1]
if r.ID != "repo2" {
@@ -365,9 +372,15 @@ func TestClusterConfig(t *testing.T) {
if id := r.Nodes[0].ID; bytes.Compare(id, node1[:]) != 0 {
t.Errorf("Incorrect node ID %x != %x", id, node1)
}
if r.Nodes[0].Flags&protocol.FlagIntroducer == 0 {
t.Error("Node1 should be flagged as Introducer")
}
if id := r.Nodes[1].ID; bytes.Compare(id, node2[:]) != 0 {
t.Errorf("Incorrect node ID %x != %x", id, node2)
}
if r.Nodes[1].Flags&protocol.FlagIntroducer != 0 {
t.Error("Node2 should not be flagged as Introducer")
}
}
func TestIgnores(t *testing.T) {