MCPcopy
hub / github.com/olric-data/olric / TestDMap_Put_WriteQuorum

Function TestDMap_Put_WriteQuorum

internal/dmap/put_test.go:117–148  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

115}
116
117func TestDMap_Put_WriteQuorum(t *testing.T) {
118 cluster := testcluster.New(NewService)
119 // Create DMap services with custom configuration
120 c1 := testutil.NewConfig()
121 c1.ReplicaCount = 2
122 c1.WriteQuorum = 2
123 e1 := testcluster.NewEnvironment(c1)
124 s1 := cluster.AddMember(e1).(*Service)
125 defer cluster.Shutdown()
126
127 ctx := context.Background()
128 var hit bool
129 dm, err := s1.NewDMap("mydmap")
130 require.NoError(t, err)
131
132 for i := 0; i < 10; i++ {
133 key := testutil.ToKey(i)
134
135 hkey := partitions.HKey(dm.name, key)
136 host := dm.s.primary.PartitionByHKey(hkey).Owner()
137 if s1.rt.This().CompareByID(host) {
138 err = dm.Put(ctx, key, testutil.ToVal(i), nil)
139 if err != ErrWriteQuorum {
140 t.Fatalf("Expected ErrWriteQuorum. Got: %v", err)
141 }
142 hit = true
143 }
144 }
145 if !hit {
146 t.Fatalf("No keys checked on %v", s1)
147 }
148}
149
150func TestDMap_Put_PX(t *testing.T) {
151 cluster := testcluster.New(NewService)

Callers

nothing calls this directly

Calls 14

PutMethod · 0.95
NewFunction · 0.92
NewConfigFunction · 0.92
NewEnvironmentFunction · 0.92
ToKeyFunction · 0.92
HKeyFunction · 0.92
ToValFunction · 0.92
AddMemberMethod · 0.80
OwnerMethod · 0.80
PartitionByHKeyMethod · 0.80
CompareByIDMethod · 0.80
ThisMethod · 0.80

Tested by

no test coverage detected