// TestTaskResurrectionInt ensures that a Claim won't recreate a task that had
// been deleted (marked as done). taskmgr has a non-integration version of this
// test.
TestTaskResurrectionInt ensures that a Claim won't recreate a task that had
been deleted (marked as done). taskmgr has a non-integration version of this
test.
// TestTaskResurrectionInt ensures that a Claim won ' t recreate a task that had // been deleted ( marked as done ) . taskmgr has a non - integration version of this // test .
func TestTaskResurrectionInt(t *testing.T) {
	etcdv3c := testutil.NewEtcdV3Client(t)
	kvc := etcdv3.NewKV(etcdv3c)
	c := context.Background()
	t.Parallel()
	kvc.Delete(c, "/test-resurrect", etcdv3.WithPrefix())
	task := metcdv3.DefaultTaskFunc("xyz", "")
	conf := metcdv3.NewConfig("testclient", "/test-resurrect")
	coord := metcdv3.NewEtcdV3Coordinator(conf, etcdv3c)
	if err := coord.Init(nil); err != nil {
		t.Fatalf("Error initializing coordinator: %v", err)
	}
	defer coord.Close()
	if claimed := coord.Claim(task); claimed {
		t.Fatal("Claiming a nonexistent task should not work but did!")
	}
	client := metcdv3.NewClient("/test-resurrect", etcdv3c)
	if err := client.SubmitTask(metcdv3.DefaultTaskFunc("xyz", "")); err != nil {
		t.Fatalf("Error submitting task xyz: %v", err)
	}
	if claimed := coord.Claim(task); !claimed {
		t.Fatal("Failed to claim task xyz")
	}
	coord.Done(task)
	if claimed := coord.Claim(task); claimed {
		t.Fatal("Reclaimed task that was marked as done.")
	}
}
func TestTaskResurrectionInt ( t * testing . T ) { etcdv3c := testutil . NewEtcdV3Client ( t ) kvc := etcdv3 . NewKV ( etcdv3c ) c := context . Background ( ) t . Parallel ( ) kvc . Delete ( c , " " , etcdv3 . WithPrefix ( ) ) task := metcdv3 . DefaultTaskFunc ( " " , " " ) conf := metcdv3 . NewConfig ( " " , " " ) coord := metcdv3 . NewEtcdV3Coordinator ( conf , etcdv3c ) if err := coord . Init ( nil ) ; err != nil { t . Fatalf ( " " , err ) } defer coord . Close ( ) if claimed := coord . Claim ( task ) ; claimed { t . Fatal ( " " ) } client := metcdv3 . NewClient ( " " , etcdv3c ) if err := client . SubmitTask ( metcdv3 . DefaultTaskFunc ( " " , " " ) ) ; err != nil { t . Fatalf ( " " , err ) } if claimed := coord . Claim ( task ) ; ! claimed { t . Fatal ( " " ) } coord . Done ( task ) if claimed := coord . Claim ( task ) ; claimed { t . Fatal ( " " ) } }
TestTaskResurrectionInt ensures that a Claim won't recreate a task that had
been deleted (marked as done).
TestTaskResurrectionInt ensures that a Claim won ' t recreate a task that had been deleted ( marked as done ) .
// Try to claim a nonexistent // Create a task, mark it as done, and try to claim it again