@@ -36,6 +36,23 @@ import (
36
36
37
37
const testLease = 5 * time .Millisecond
38
38
39
+ type testInfo struct {
40
+ cluster * integration.ClusterV3
41
+ client * clientv3.Client
42
+ }
43
+
44
+ func newTestInfo (t * testing.T ) * testInfo {
45
+ cluster := integration .NewClusterV3 (t , & integration.ClusterConfig {Size : 1 })
46
+ return & testInfo {
47
+ cluster : cluster ,
48
+ client : cluster .Client (0 ),
49
+ }
50
+ }
51
+
52
+ func (ti * testInfo ) Close (t * testing.T ) {
53
+ ti .cluster .Terminate (t )
54
+ }
55
+
39
56
func TestSingle (t * testing.T ) {
40
57
if runtime .GOOS == "windows" {
41
58
t .Skip ("integration.NewClusterV3 will create file contains a colon which is not allowed on Windows" )
@@ -340,3 +357,20 @@ func deleteLeader(cli *clientv3.Client, prefixKey string) error {
340
357
_ , err = cli .Delete (context .Background (), string (resp .Kvs [0 ].Key ))
341
358
return errors .Trace (err )
342
359
}
360
+
361
+ func TestImmediatelyCancel (t * testing.T ) {
362
+ if runtime .GOOS == "windows" {
363
+ t .Skip ("integration.NewClusterV3 will create file contains a colon which is not allowed on Windows" )
364
+ }
365
+ integration .BeforeTestExternal (t )
366
+
367
+ tInfo := newTestInfo (t )
368
+ defer tInfo .Close (t )
369
+ ownerMgr := owner .NewOwnerManager (context .Background (), tInfo .client , "ddl" , "1" , "/owner/key" )
370
+ defer ownerMgr .Cancel ()
371
+ for i := 0 ; i < 10 ; i ++ {
372
+ err := ownerMgr .CampaignOwner ()
373
+ require .NoError (t , err )
374
+ ownerMgr .CampaignCancel ()
375
+ }
376
+ }
0 commit comments