fix an ewma unit test

This commit is contained in:
Elvin Efendi 2018-12-03 15:56:58 +04:00
parent 03dba21d17
commit a4bad90f1f
2 changed files with 5 additions and 2 deletions

View file

@ -42,8 +42,8 @@ describe("Balancer ewma", function()
}
}
local instance = balancer_ewma:new(backend)
local stats = { ["10.184.7.40:8080"] = 0.5, ["10.184.97.100:8080"] = 0.3 }
instance.ewma = { ["10.184.7.40:8080"] = 0.5, ["10.184.97.100:8080"] = 0.3 }
instance.ewma_last_touched_at = { ["10.184.7.40:8080"] = ngx.now(), ["10.184.97.100:8080"] = ngx.now() }
local peer = instance:balance()
assert.equal("10.184.97.100:8080", peer)

View file

@ -32,4 +32,7 @@ end
ngx.log = function(...) end
ngx.print = function(...) end
-- TODO(elvinefendi) once this is implemented for production (should be!), share the same code
math.randomseed(ngx.time() + ngx.worker.pid())
require "busted.runner"({ standalone = false })