mirror of
https://github.com/openfaas/faas.git
synced 2025-06-18 03:56:37 +00:00
Refactor scaling to use existing code
Existing code has been used for scaling up and querying replicas. This meant the new code was deleted and there is less duplication now. The cache store a whole query response rather than just the available replica count and the tests were updated. This has been tested with Docker swarm and the image: openfaas/gateway:scale-17-07-2018 This feature now needs the env-var of scale_from_zero to be enabled in order to turn on the scaling behaviour. Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
This commit is contained in:
committed by
Alex Ellis
parent
c58af8da56
commit
9512f09d2b
@ -20,7 +20,7 @@ func Test_LastRefreshSet(t *testing.T) {
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
cache.Set(fnName, 1)
|
||||
cache.Set(fnName, ServiceQueryResponse{AvailableReplicas: 1})
|
||||
|
||||
if _, exists := cache.Cache[fnName]; !exists {
|
||||
t.Errorf("Expected entry to exist after setting %s", fnName)
|
||||
@ -41,7 +41,7 @@ func Test_CacheExpiresIn1MS(t *testing.T) {
|
||||
Expiry: time.Millisecond * 1,
|
||||
}
|
||||
|
||||
cache.Set(fnName, 1)
|
||||
cache.Set(fnName, ServiceQueryResponse{AvailableReplicas: 1})
|
||||
time.Sleep(time.Millisecond * 2)
|
||||
|
||||
_, hit := cache.Get(fnName)
|
||||
@ -61,7 +61,7 @@ func Test_CacheGivesHitWithLongExpiry(t *testing.T) {
|
||||
Expiry: time.Millisecond * 500,
|
||||
}
|
||||
|
||||
cache.Set(fnName, 1)
|
||||
cache.Set(fnName, ServiceQueryResponse{AvailableReplicas: 1})
|
||||
|
||||
_, hit := cache.Get(fnName)
|
||||
wantHit := true
|
||||
|
Reference in New Issue
Block a user