Browse Source

fix tests

pull/3001/head
chrislu 3 years ago
parent
commit
2c0fdf3693
  1. 18
      weed/cluster/cluster_test.go

18
weed/cluster/cluster_test.go

@ -9,24 +9,24 @@ import (
func TestClusterAddRemoveNodes(t *testing.T) { func TestClusterAddRemoveNodes(t *testing.T) {
c := NewCluster() c := NewCluster()
c.AddClusterNode("filer", pb.ServerAddress("111:1"), "23.45")
c.AddClusterNode("filer", pb.ServerAddress("111:2"), "23.45")
c.AddClusterNode("", "filer", pb.ServerAddress("111:1"), "23.45")
c.AddClusterNode("", "filer", pb.ServerAddress("111:2"), "23.45")
assert.Equal(t, []pb.ServerAddress{ assert.Equal(t, []pb.ServerAddress{
pb.ServerAddress("111:1"), pb.ServerAddress("111:1"),
pb.ServerAddress("111:2"), pb.ServerAddress("111:2"),
}, c.filerLeaders.GetLeaders()) }, c.filerLeaders.GetLeaders())
c.AddClusterNode("filer", pb.ServerAddress("111:3"), "23.45")
c.AddClusterNode("filer", pb.ServerAddress("111:4"), "23.45")
c.AddClusterNode("", "filer", pb.ServerAddress("111:3"), "23.45")
c.AddClusterNode("", "filer", pb.ServerAddress("111:4"), "23.45")
assert.Equal(t, []pb.ServerAddress{ assert.Equal(t, []pb.ServerAddress{
pb.ServerAddress("111:1"), pb.ServerAddress("111:1"),
pb.ServerAddress("111:2"), pb.ServerAddress("111:2"),
pb.ServerAddress("111:3"), pb.ServerAddress("111:3"),
}, c.filerLeaders.GetLeaders()) }, c.filerLeaders.GetLeaders())
c.AddClusterNode("filer", pb.ServerAddress("111:5"), "23.45")
c.AddClusterNode("filer", pb.ServerAddress("111:6"), "23.45")
c.RemoveClusterNode("filer", pb.ServerAddress("111:4"))
c.AddClusterNode("", "filer", pb.ServerAddress("111:5"), "23.45")
c.AddClusterNode("", "filer", pb.ServerAddress("111:6"), "23.45")
c.RemoveClusterNode("", "filer", pb.ServerAddress("111:4"))
assert.Equal(t, []pb.ServerAddress{ assert.Equal(t, []pb.ServerAddress{
pb.ServerAddress("111:1"), pb.ServerAddress("111:1"),
pb.ServerAddress("111:2"), pb.ServerAddress("111:2"),
@ -34,7 +34,7 @@ func TestClusterAddRemoveNodes(t *testing.T) {
}, c.filerLeaders.GetLeaders()) }, c.filerLeaders.GetLeaders())
// remove oldest // remove oldest
c.RemoveClusterNode("filer", pb.ServerAddress("111:1"))
c.RemoveClusterNode("", "filer", pb.ServerAddress("111:1"))
assert.Equal(t, []pb.ServerAddress{ assert.Equal(t, []pb.ServerAddress{
pb.ServerAddress("111:6"), pb.ServerAddress("111:6"),
pb.ServerAddress("111:2"), pb.ServerAddress("111:2"),
@ -42,6 +42,6 @@ func TestClusterAddRemoveNodes(t *testing.T) {
}, c.filerLeaders.GetLeaders()) }, c.filerLeaders.GetLeaders())
// remove oldest // remove oldest
c.RemoveClusterNode("filer", pb.ServerAddress("111:1"))
c.RemoveClusterNode("", "filer", pb.ServerAddress("111:1"))
} }
Loading…
Cancel
Save