MCPcopy Create free account
hub / github.com/buraksezer/consistent / TestConsistentLoad

Function TestConsistentLoad

consistent_test.go:97–124  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

95}
96
97func TestConsistentLoad(t *testing.T) {
98 var members []Member
99 for i := 0; i < 8; i++ {
100 member := testMember(fmt.Sprintf("node%d.olric", i))
101 members = append(members, member)
102 }
103 cfg := newConfig()
104
105 t.Run("Average load should be greater than the member's load", func(t *testing.T) {
106 c := New(members, cfg)
107 if len(c.GetMembers()) != len(members) {
108 t.Fatalf("inserted member count is different")
109 }
110 maxLoad := c.AverageLoad()
111 for member, load := range c.LoadDistribution() {
112 if load > maxLoad {
113 t.Fatalf("%s exceeds max load. Its load: %f, max load: %f", member, load, maxLoad)
114 }
115 }
116 })
117
118 t.Run("Average load should equal to zero if there are no members", func(t *testing.T) {
119 c := New(nil, cfg)
120 if c.AverageLoad() != 0 {
121 t.Fatalf("AverageLoad should equal to zero")
122 }
123 })
124}
125
126func TestConsistentLocateKey(t *testing.T) {
127 cfg := newConfig()

Callers

nothing calls this directly

Calls 6

testMemberTypeAlias · 0.85
newConfigFunction · 0.85
NewFunction · 0.85
GetMembersMethod · 0.80
AverageLoadMethod · 0.80
LoadDistributionMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…