21353: Add cypress-wait-until to prevent cy.url before window.location is
[arvados.git] / lib / dispatchcloud / dispatcher_test.go
index 33d7f4e9acd2e5e15293faffefd4d2667e2899f7..20185554b8b1828fc92e24b1c1f7ecbc8603b6fc 100644 (file)
@@ -207,8 +207,9 @@ func (s *DispatcherSuite) TestDispatchToStubDriver(c *check.C) {
                finishContainer(ctr)
                return int(rand.Uint32() & 0x3)
        }
+       var type4BrokenUntil time.Time
        var countCapacityErrors int64
-       n := 0
+       vmCount := int32(0)
        s.stubDriver.Queue = queue
        s.stubDriver.SetupVM = func(stubvm *test.StubVM) error {
                if pt := stubvm.Instance().ProviderType(); pt == test.InstanceType(6).ProviderType {
@@ -216,13 +217,25 @@ func (s *DispatcherSuite) TestDispatchToStubDriver(c *check.C) {
                        atomic.AddInt64(&countCapacityErrors, 1)
                        return test.CapacityError{InstanceTypeSpecific: true}
                }
-               n++
+               n := atomic.AddInt32(&vmCount, 1)
+               c.Logf("SetupVM: instance %s n=%d", stubvm.Instance(), n)
                stubvm.Boot = time.Now().Add(time.Duration(rand.Int63n(int64(5 * time.Millisecond))))
                stubvm.CrunchRunDetachDelay = time.Duration(rand.Int63n(int64(10 * time.Millisecond)))
                stubvm.ExecuteContainer = executeContainer
                stubvm.CrashRunningContainer = finishContainer
                stubvm.ExtraCrunchRunArgs = "'--runtime-engine=stub' '--foo' '--extra='\\''args'\\'''"
                switch {
+               case stubvm.Instance().ProviderType() == test.InstanceType(4).ProviderType &&
+                       (type4BrokenUntil.IsZero() || time.Now().Before(type4BrokenUntil)):
+                       // Initially (at least 2*TimeoutBooting), all
+                       // instances of this type are completely
+                       // broken. This ensures the
+                       // boot_outcomes{outcome="failure"} metric is
+                       // not zero.
+                       stubvm.Broken = time.Now()
+                       if type4BrokenUntil.IsZero() {
+                               type4BrokenUntil = time.Now().Add(2 * s.cluster.Containers.CloudVMs.TimeoutBooting.Duration())
+                       }
                case n%7 == 0:
                        // some instances start out OK but then stop
                        // running any commands
@@ -234,11 +247,6 @@ func (s *DispatcherSuite) TestDispatchToStubDriver(c *check.C) {
                        // some instances start out OK but then start
                        // reporting themselves as broken
                        stubvm.ReportBroken = time.Now().Add(time.Duration(rand.Int63n(200)) * time.Millisecond)
-               case n == 3:
-                       // 1 instance is completely broken, ensuring
-                       // the boot_outcomes{outcome="failure"} metric
-                       // is not zero
-                       stubvm.CrunchRunCrashRate = 1
                default:
                        stubvm.CrunchRunCrashRate = 0.1
                        stubvm.ArvMountDeadlockRate = 0.1