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

Function TestDMap_lockLeaseCommandHandler

internal/dmap/lock_test.go:359–384  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

357}
358
359func TestDMap_lockLeaseCommandHandler(t *testing.T) {
360 cluster := testcluster.New(NewService)
361 s := cluster.AddMember(nil).(*Service)
362 defer cluster.Shutdown()
363
364 key := "lock.test.foo"
365 dm, err := s.NewDMap("lock.test")
366 require.NoError(t, err)
367
368 ctx := context.Background()
369
370 token, err := dm.Lock(ctx, key, time.Second, time.Second)
371 require.NoError(t, err)
372
373 // Update the timeout
374 etoken := hex.EncodeToString(token)
375 cmd := protocol.NewLockLease("lock.test", key, etoken, 10).Command(s.ctx)
376 rc := s.client.Get(s.rt.This().String())
377 err = rc.Process(s.ctx, cmd)
378 require.NoError(t, err)
379
380 <-time.After(2 * time.Second)
381
382 err = dm.Unlock(ctx, key, token)
383 require.NoError(t, err)
384}
385
386func TestDMap_plockLeaseCommandHandler(t *testing.T) {
387 cluster := testcluster.New(NewService)

Callers

nothing calls this directly

Calls 11

LockMethod · 0.95
UnlockMethod · 0.95
NewFunction · 0.92
NewLockLeaseFunction · 0.92
AddMemberMethod · 0.80
ThisMethod · 0.80
ShutdownMethod · 0.65
NewDMapMethod · 0.65
GetMethod · 0.65
CommandMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected