projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch '20649-ssh-help'
[arvados.git]
/
lib
/
dispatchcloud
/
test
/
stub_driver.go
diff --git
a/lib/dispatchcloud/test/stub_driver.go
b/lib/dispatchcloud/test/stub_driver.go
index 9bc1e4c8f773ed338fcf455abc25be79808f12f5..6e0b1294875dfc9e50c2794b3b79cdd069c1e5ce 100644
(file)
--- a/
lib/dispatchcloud/test/stub_driver.go
+++ b/
lib/dispatchcloud/test/stub_driver.go
@@
-55,6
+55,8
@@
type StubDriver struct {
MinTimeBetweenCreateCalls time.Duration
MinTimeBetweenInstancesCalls time.Duration
MinTimeBetweenCreateCalls time.Duration
MinTimeBetweenInstancesCalls time.Duration
+ QuotaMaxInstances int
+
// If true, Create and Destroy calls block until Release() is
// called.
HoldCloudOps bool
// If true, Create and Destroy calls block until Release() is
// called.
HoldCloudOps bool
@@
-125,6
+127,9
@@
func (sis *StubInstanceSet) Create(it arvados.InstanceType, image cloud.ImageID,
if math_rand.Float64() < sis.driver.ErrorRateCreate {
return nil, fmt.Errorf("StubInstanceSet: rand < ErrorRateCreate %f", sis.driver.ErrorRateCreate)
}
if math_rand.Float64() < sis.driver.ErrorRateCreate {
return nil, fmt.Errorf("StubInstanceSet: rand < ErrorRateCreate %f", sis.driver.ErrorRateCreate)
}
+ if max := sis.driver.QuotaMaxInstances; max > 0 && len(sis.servers) >= max {
+ return nil, QuotaError{fmt.Errorf("StubInstanceSet: reached QuotaMaxInstances %d", max)}
+ }
sis.allowCreateCall = time.Now().Add(sis.driver.MinTimeBetweenCreateCalls)
ak := sis.driver.AuthorizedKeys
if authKey != nil {
sis.allowCreateCall = time.Now().Add(sis.driver.MinTimeBetweenCreateCalls)
ak := sis.driver.AuthorizedKeys
if authKey != nil {
@@
-490,3
+495,9
@@
func copyTags(src cloud.InstanceTags) cloud.InstanceTags {
func (si stubInstance) PriceHistory(arvados.InstanceType) []cloud.InstancePrice {
return nil
}
func (si stubInstance) PriceHistory(arvados.InstanceType) []cloud.InstancePrice {
return nil
}
+
+type QuotaError struct {
+ error
+}
+
+func (QuotaError) IsQuotaError() bool { return true }