From 7cc257b4e4f60cca1ca0354d9972cb36c59a77fe Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Mon, 17 Aug 2020 10:16:47 -0400 Subject: [PATCH] 16663: Add comments in racy test. Arvados-DCO-1.1-Signed-off-by: Tom Clegg --- lib/dispatchcloud/scheduler/sync_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/dispatchcloud/scheduler/sync_test.go b/lib/dispatchcloud/scheduler/sync_test.go index ae264bb298..538f5ea8cf 100644 --- a/lib/dispatchcloud/scheduler/sync_test.go +++ b/lib/dispatchcloud/scheduler/sync_test.go @@ -84,6 +84,14 @@ func (*SchedulerSuite) TestCancelOrphanedContainers(c *check.C) { // Sync shouldn't cancel the container because it might be // running on the VM with state=="unknown". + // + // (Cancel+forget happens asynchronously and requires multiple + // sync() calls, so even after 10x sync-and-sleep iterations, + // we aren't 100% confident that sync isn't trying to + // cancel. But in the test environment, the goroutines started + // by sync() access stubs and therefore run quickly, so it + // works fine in practice. We accept that if the code is + // broken, the test will still pass occasionally.) for i := 0; i < 10; i++ { sch.sync() time.Sleep(time.Millisecond) @@ -94,6 +102,10 @@ func (*SchedulerSuite) TestCancelOrphanedContainers(c *check.C) { // Sync should cancel & forget the container when the // "unknown" node goes away. + // + // (As above, cancel+forget is async and requires multiple + // sync() calls, but stubs are fast so in practice this takes + // much less than 1s to complete.) pool.unknown = nil for deadline := time.Now().Add(time.Second); ; time.Sleep(time.Millisecond) { sch.sync() -- 2.30.2