Remove session-cookie-hash annotation
This commit is contained in:
parent
79c52cf094
commit
d3ac73be79
18 changed files with 22 additions and 189 deletions
|
|
@ -68,26 +68,6 @@ describe("Sticky", function()
|
|||
assert.equal(sticky_balancer_instance:cookie_name(), default_cookie_name)
|
||||
end)
|
||||
end)
|
||||
|
||||
context("when backend specifies hash function", function()
|
||||
it("returns an instance with the corresponding hash implementation", function()
|
||||
local sticky_balancer_instance = sticky:new(test_backend)
|
||||
local test_backend_hash_fn = test_backend.sessionAffinityConfig.cookieSessionAffinity.hash
|
||||
local test_backend_hash_implementation = util[test_backend_hash_fn .. "_digest"]
|
||||
assert.equal(sticky_balancer_instance.digest_func, test_backend_hash_implementation)
|
||||
end)
|
||||
end)
|
||||
|
||||
context("when backend does not specify hash function", function()
|
||||
it("returns an instance with the default implementation (md5)", function()
|
||||
local temp_backend = util.deepcopy(test_backend)
|
||||
temp_backend.sessionAffinityConfig.cookieSessionAffinity.hash = nil
|
||||
local sticky_balancer_instance = sticky:new(temp_backend)
|
||||
local default_hash_fn = "md5"
|
||||
local default_hash_implementation = util[default_hash_fn .. "_digest"]
|
||||
assert.equal(sticky_balancer_instance.digest_func, default_hash_implementation)
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
describe("balance()", function()
|
||||
|
|
@ -112,12 +92,9 @@ describe("Sticky", function()
|
|||
it("sets a cookie on the client", function()
|
||||
local s = {}
|
||||
cookie.new = function(self)
|
||||
local test_backend_hash_fn = test_backend.sessionAffinityConfig.cookieSessionAffinity.hash
|
||||
local cookie_instance = {
|
||||
set = function(self, payload)
|
||||
assert.equal(payload.key, test_backend.sessionAffinityConfig.cookieSessionAffinity.name)
|
||||
local expected_len = #util[test_backend_hash_fn .. "_digest"]("anything")
|
||||
assert.equal(#payload.value, expected_len)
|
||||
assert.equal(payload.path, ngx.var.location_path)
|
||||
assert.equal(payload.domain, nil)
|
||||
assert.equal(payload.httponly, true)
|
||||
|
|
@ -141,12 +118,9 @@ describe("Sticky", function()
|
|||
ngx.var.https = "on"
|
||||
local s = {}
|
||||
cookie.new = function(self)
|
||||
local test_backend_hash_fn = test_backend.sessionAffinityConfig.cookieSessionAffinity.hash
|
||||
local cookie_instance = {
|
||||
set = function(self, payload)
|
||||
assert.equal(payload.key, test_backend.sessionAffinityConfig.cookieSessionAffinity.name)
|
||||
local expected_len = #util[test_backend_hash_fn .. "_digest"]("anything")
|
||||
assert.equal(#payload.value, expected_len)
|
||||
assert.equal(payload.path, ngx.var.location_path)
|
||||
assert.equal(payload.domain, nil)
|
||||
assert.equal(payload.httponly, true)
|
||||
|
|
@ -177,12 +151,9 @@ describe("Sticky", function()
|
|||
it("does not set a cookie on the client", function()
|
||||
local s = {}
|
||||
cookie.new = function(self)
|
||||
local test_backend_hash_fn = test_backend.sessionAffinityConfig.cookieSessionAffinity.hash
|
||||
local cookie_instance = {
|
||||
set = function(self, payload)
|
||||
assert.equal(payload.key, test_backend.sessionAffinityConfig.cookieSessionAffinity.name)
|
||||
local expected_len = #util[test_backend_hash_fn .. "_digest"]("anything")
|
||||
assert.equal(#payload.value, expected_len)
|
||||
assert.equal(payload.path, ngx.var.location_path)
|
||||
assert.equal(payload.domain, ngx.var.host)
|
||||
assert.equal(payload.httponly, true)
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ local function reset_backends()
|
|||
{ address = "10.184.97.100", port = "8080", maxFails = 0, failTimeout = 0 },
|
||||
{ address = "10.184.98.239", port = "8080", maxFails = 0, failTimeout = 0 },
|
||||
},
|
||||
sessionAffinityConfig = { name = "", cookieSessionAffinity = { name = "", hash = "" } },
|
||||
sessionAffinityConfig = { name = "", cookieSessionAffinity = { name = "" } },
|
||||
},
|
||||
{ name = "my-dummy-app-1", ["load-balance"] = "round_robin", },
|
||||
{
|
||||
|
|
@ -38,12 +38,12 @@ local function reset_backends()
|
|||
},
|
||||
{
|
||||
name = "my-dummy-app-3", ["load-balance"] = "ewma",
|
||||
sessionAffinityConfig = { name = "cookie", cookieSessionAffinity = { name = "route", hash = "sha1" } }
|
||||
sessionAffinityConfig = { name = "cookie", cookieSessionAffinity = { name = "route" } }
|
||||
},
|
||||
{ name = "my-dummy-app-4", ["load-balance"] = "ewma", },
|
||||
{
|
||||
name = "my-dummy-app-5", ["load-balance"] = "ewma", ["upstream-hash-by"] = "$request_uri",
|
||||
sessionAffinityConfig = { name = "cookie", cookieSessionAffinity = { name = "route", hash = "sha1" } }
|
||||
sessionAffinityConfig = { name = "cookie", cookieSessionAffinity = { name = "route" } }
|
||||
},
|
||||
}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ function get_backends()
|
|||
{
|
||||
name = "my-dummy-backend-1", ["load-balance"] = "sticky",
|
||||
endpoints = { { address = "10.183.7.40", port = "8080", maxFails = 0, failTimeout = 0 } },
|
||||
sessionAffinityConfig = { name = "cookie", cookieSessionAffinity = { name = "route", hash = "sha1" } },
|
||||
sessionAffinityConfig = { name = "cookie", cookieSessionAffinity = { name = "route" } },
|
||||
},
|
||||
{
|
||||
name = "my-dummy-backend-2", ["load-balance"] = "ewma",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue