16723: Fail test if a crunch-run stub is killed before finishing.
authorTom Clegg <tom@tomclegg.ca>
Fri, 21 Aug 2020 15:24:50 +0000 (11:24 -0400)
committerTom Clegg <tom@tomclegg.ca>
Fri, 21 Aug 2020 15:24:50 +0000 (11:24 -0400)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@tomclegg.ca>

lib/dispatchcloud/dispatcher_test.go
lib/dispatchcloud/test/stub_driver.go

index 3b45e75fd063f76f4bbe5f96b37025c738e8aad2..f8940f720575dcc9774efd76228c63a85bfd54fb 100644 (file)
@@ -171,6 +171,7 @@ func (s *DispatcherSuite) TestDispatchToStubDriver(c *check.C) {
                        stubvm.CrunchRunCrashRate = 0.1
                }
        }
+       s.stubDriver.Bugf = c.Errorf
 
        start := time.Now()
        go s.disp.run()
index f45d37352fa8d5c7f3fe9715a0d467cb54ad70f8..f6e06d3f7cebd05a97c8851f65d8d79812d18297 100644 (file)
@@ -34,6 +34,11 @@ type StubDriver struct {
        // VM's error rate and other behaviors.
        SetupVM func(*StubVM)
 
+       // Bugf, if set, is called if a bug is detected in the caller
+       // or stub. Typically set to (*check.C)Errorf. If unset,
+       // logger.Warnf is called instead.
+       Bugf func(string, ...interface{})
+
        // StubVM's fake crunch-run uses this Queue to read and update
        // container state.
        Queue *Queue
@@ -273,7 +278,11 @@ func (svm *StubVM) Exec(env map[string]string, command string, stdin io.Reader,
                                defer svm.Unlock()
                                if svm.running[uuid] != pid {
                                        if !completed {
-                                               logger.Errorf("[test] StubDriver bug or caller bug: pid %d exiting, running[%s]==%d", pid, uuid, svm.running[uuid])
+                                               bugf := svm.sis.driver.Bugf
+                                               if bugf == nil {
+                                                       bugf = logger.Warnf
+                                               }
+                                               bugf("[test] StubDriver bug or caller bug: pid %d exiting, running[%s]==%d", pid, uuid, svm.running[uuid])
                                        }
                                } else {
                                        delete(svm.running, uuid)