20705: 10% failure on stub Create to ensure running error path. 20705-crunchstat-warn-missing-data
authorTom Clegg <tom@curii.com>
Mon, 7 Aug 2023 14:31:56 +0000 (10:31 -0400)
committerTom Clegg <tom@curii.com>
Mon, 7 Aug 2023 14:31:56 +0000 (10:31 -0400)
Fixes occasional test failures due to absence of rate-limiting errors.

Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

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

index 17121ffeb60d65a6871cbc631310402d80136747..4583a596eebfe48a08fd862e6d840d8df401c047 100644 (file)
@@ -49,6 +49,7 @@ func (s *DispatcherSuite) SetUpTest(c *check.C) {
        s.stubDriver = &test.StubDriver{
                HostKey:                   hostpriv,
                AuthorizedKeys:            []ssh.PublicKey{dispatchpub},
+               ErrorRateCreate:           0.1,
                ErrorRateDestroy:          0.1,
                MinTimeBetweenCreateCalls: time.Millisecond,
        }
index e91878527c45f82f934b8968e1f208f308088d33..5ca83d263c1c481bd71c968299744e2cf9b2486d 100644 (file)
@@ -45,7 +45,8 @@ type StubDriver struct {
        Queue *Queue
 
        // Frequency of artificially introduced errors on calls to
-       // Destroy. 0=always succeed, 1=always fail.
+       // Create and Destroy. 0=always succeed, 1=always fail.
+       ErrorRateCreate  float64
        ErrorRateDestroy float64
 
        // If Create() or Instances() is called too frequently, return
@@ -120,6 +121,9 @@ func (sis *StubInstanceSet) Create(it arvados.InstanceType, image cloud.ImageID,
        if sis.allowCreateCall.After(time.Now()) {
                return nil, RateLimitError{sis.allowCreateCall}
        }
+       if math_rand.Float64() < sis.driver.ErrorRateCreate {
+               return nil, fmt.Errorf("StubInstanceSet: rand < ErrorRateCreate %f", sis.driver.ErrorRateCreate)
+       }
        sis.allowCreateCall = time.Now().Add(sis.driver.MinTimeBetweenCreateCalls)
        ak := sis.driver.AuthorizedKeys
        if authKey != nil {