Add unit test case for canary by weight

This commit is contained in:
s-shirayama 2019-06-11 22:21:03 +09:00
parent 7a15f52cf1
commit e9f4c0bb0e

View file

@ -117,6 +117,20 @@ describe("Balancer", function()
_balancer.alternative_backends[1] = "nonExistingBackend" _balancer.alternative_backends[1] = "nonExistingBackend"
assert.equal(false, balancer.route_to_alternative_balancer(_balancer)) assert.equal(false, balancer.route_to_alternative_balancer(_balancer))
end) end)
context("canary by weight", function()
it("returns true when weight is 100", function()
backend.trafficShapingPolicy.weight = 100
balancer.sync_backend(backend)
assert.equal(true, balancer.route_to_alternative_balancer(_balancer))
end)
it("returns false when weight is 0", function()
backend.trafficShapingPolicy.weight = 0
balancer.sync_backend(backend)
assert.equal(false, balancer.route_to_alternative_balancer(_balancer))
end)
end)
end) end)
describe("sync_backend()", function() describe("sync_backend()", function()