diff --git a/clientv3/integration/leasing_test.go b/clientv3/integration/leasing_test.go index 909897dbab6..e90c7c90e82 100644 --- a/clientv3/integration/leasing_test.go +++ b/clientv3/integration/leasing_test.go @@ -305,8 +305,8 @@ func TestLeasingConcurrentPut(t *testing.T) { if err != nil { t.Fatal(err) } - - if _, err := clus.Client(0).Get(context.TODO(), "k"); err != nil { + // force key into leasing key cache + if _, err := lkv.Get(context.TODO(), "k"); err != nil { t.Fatal(err) } @@ -695,3 +695,53 @@ func TestLeasingTxnNonOwnerPut(t *testing.T) { t.Errorf(`expected value "def", got %+v`, gresp) } } + +func TestLeasingOwnerPutError(t *testing.T) { + defer testutil.AfterTest(t) + clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1}) + defer clus.Terminate(t) + + lkv, err := leasing.NewleasingKV(clus.Client(0), "pfx/") + if err != nil { + t.Fatal(err) + } + if _, err := lkv.Get(context.TODO(), "k"); err != nil { + t.Fatal(err) + } + clus.Members[0].Stop(t) + if resp, err := lkv.Put(context.TODO(), "k", "v"); err == nil { + t.Fatalf("expected error, got response %+v", resp) + } +} + +func TestLeasingOwnerDeleteError(t *testing.T) { + defer testutil.AfterTest(t) + clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1}) + defer clus.Terminate(t) + + lkv, err := leasing.NewleasingKV(clus.Client(0), "pfx/") + if err != nil { + t.Fatal(err) + } + if _, err := lkv.Get(context.TODO(), "k"); err != nil { + t.Fatal(err) + } + clus.Members[0].Stop(t) + if resp, err := lkv.Delete(context.TODO(), "k"); err == nil { + t.Fatalf("expected error, got response %+v", resp) + } +} + +func TestLeasingNonOwnerPutError(t *testing.T) { + defer testutil.AfterTest(t) + clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1}) + defer clus.Terminate(t) + lkv, err := leasing.NewleasingKV(clus.Client(0), "pfx/") + if err != nil { + t.Fatal(err) + } + clus.Members[0].Stop(t) + if resp, err := lkv.Put(context.TODO(), "k", "v"); err == nil { + t.Fatalf("expected error, got response %+v", resp) + } +}