Skip to content

Commit bd64c8b

Browse files
committed
fix(tests) healthcheck headers
1 parent 1589da5 commit bd64c8b

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

kong/db/schema/entities/upstreams.lua

+3-2
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,10 @@ local check_verify_certificate = Schema.define {
7575

7676
local check_headers = Schema.define {
7777
type = "array",
78+
len_min = 1,
7879
elements = {
7980
type = "string",
80-
len_min = 1,
81+
unique = true,
8182
},
8283
}
8384

@@ -99,7 +100,7 @@ local healthchecks_config = {
99100
http_path = "/",
100101
https_sni = NO_DEFAULT,
101102
https_verify_certificate = true,
102-
headers = {""},
103+
headers = NO_DEFAULT,
103104
healthy = {
104105
interval = 0, -- 0 = probing disabled by default
105106
http_statuses = { 200, 302 },

spec/01-unit/01-db/01-schema/09-upstreams_spec.lua

+13-11
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ describe("load upstreams", function()
7070
it("invalid healthckecks.active.headers produces error", function()
7171
local ok, errs = validate({ healthchecks = { active = { headers = { 114514 } } } } )
7272
assert.falsy(ok)
73-
assert.truthy(errs.healthchecks.active.http_path)
73+
assert.truthy(errs.healthchecks.active.headers)
7474
end)
7575

7676
it("invalid healthckecks.active.http_path produces error", function()
@@ -276,11 +276,12 @@ describe("load upstreams", function()
276276
local pos_integer = "value should be between 1 and 2147483648"
277277
local zero_integer = "value should be between 0 and 255"
278278
local status_code = "value should be between 100 and 999"
279-
local string = "expected a string"
280-
local empty_string = "vaule must be non-empty string"
281279
local integer = "expected an integer"
282280
local boolean = "expected a boolean"
283281
local number = "expected a number"
282+
local array = "expected an array"
283+
local string = "expected a string"
284+
local len_min_default = "length must be at least 1"
284285
local invalid_host = "invalid value: "
285286
local invalid_host_port = "must not have a port"
286287
local invalid_ip = "must not be an IP"
@@ -291,7 +292,7 @@ describe("load upstreams", function()
291292
{{ active = { concurrency = 0.5 }}, integer },
292293
{{ active = { concurrency = 0 }}, pos_integer },
293294
{{ active = { concurrency = -10 }}, pos_integer },
294-
{{ active = { http_path = "" }}, "length must be at least 1" },
295+
{{ active = { http_path = "" }}, len_min_default },
295296
{{ active = { http_path = "ovo" }}, "should start with: /" },
296297
{{ active = { https_sni = "127.0.0.1", }}, invalid_ip },
297298
{{ active = { https_sni = "127.0.0.1:8080", }}, invalid_ip },
@@ -306,13 +307,14 @@ describe("load upstreams", function()
306307
{{ active = { https_sni = "hello-.example.com", }}, invalid_host },
307308
{{ active = { https_sni = "example.com:1234", }}, invalid_host_port },
308309
{{ active = { https_verify_certificate = "ovo", }}, boolean },
309-
{{ active = { headers = 0, }}, "expected an array" },
310+
{{ active = { headers = 0, }}, array },
311+
{{ active = { headers = {}, }}, len_min_default },
310312
{{ active = { headers = { 0 }, }}, string },
311-
{{ active = { headers = { "" }, }}, empty_string },
312-
{{ active = { headers = { 0, "example" }, }}, string },
313+
{{ active = { headers = { "" }, }}, len_min_default },
314+
{{ active = { headers = { 123, "example" }, }}, string },
313315
{{ active = { healthy = { interval = -1 }}}, seconds },
314316
{{ active = { healthy = { interval = 1e+42 }}}, seconds },
315-
{{ active = { healthy = { http_statuses = 404 }}}, "expected an array" },
317+
{{ active = { healthy = { http_statuses = 404 }}}, array },
316318
{{ active = { healthy = { http_statuses = { "ovo" }}}}, integer },
317319
{{ active = { healthy = { http_statuses = { -1 }}}}, status_code },
318320
{{ active = { healthy = { http_statuses = { 99 }}}}, status_code },
@@ -328,7 +330,7 @@ describe("load upstreams", function()
328330
{{ active = { healthy = { successes = 256 }}}, zero_integer },
329331
{{ active = { unhealthy = { interval = -1 }}}, seconds },
330332
{{ active = { unhealthy = { interval = 1e+42 }}}, seconds },
331-
{{ active = { unhealthy = { http_statuses = 404 }}}, "expected an array" },
333+
{{ active = { unhealthy = { http_statuses = 404 }}}, array },
332334
{{ active = { unhealthy = { http_statuses = { "ovo" }}}}, integer },
333335
{{ active = { unhealthy = { http_statuses = { -1 }}}}, status_code },
334336
{{ active = { unhealthy = { http_statuses = { 99 }}}}, status_code },
@@ -344,15 +346,15 @@ describe("load upstreams", function()
344346
{{ active = { unhealthy = { http_failures = 0.5 }}}, integer},
345347
{{ active = { unhealthy = { http_failures = -1 }}}, zero_integer },
346348
{{ active = { unhealthy = { http_failures = 256 }}}, zero_integer },
347-
{{ passive = { healthy = { http_statuses = 404 }}}, "expected an array" },
349+
{{ passive = { healthy = { http_statuses = 404 }}}, array },
348350
{{ passive = { healthy = { http_statuses = { "ovo" }}}}, integer },
349351
{{ passive = { healthy = { http_statuses = { -1 }}}}, status_code },
350352
{{ passive = { healthy = { http_statuses = { 99 }}}}, status_code },
351353
{{ passive = { healthy = { http_statuses = { 1000 }}}}, status_code },
352354
{{ passive = { healthy = { successes = 0.5 }}}, integer },
353355
--{{ passive = { healthy = { successes = 0 }}}, integer },
354356
{{ passive = { healthy = { successes = -1 }}}, zero_integer },
355-
{{ passive = { unhealthy = { http_statuses = 404 }}}, "expected an array" },
357+
{{ passive = { unhealthy = { http_statuses = 404 }}}, array },
356358
{{ passive = { unhealthy = { http_statuses = { "ovo" }}}}, integer },
357359
{{ passive = { unhealthy = { http_statuses = { -1 }}}}, status_code },
358360
{{ passive = { unhealthy = { http_statuses = { 99 }}}}, status_code },

spec/01-unit/01-db/01-schema/11-declarative_config/03-flatten_spec.lua

+2
Original file line numberDiff line numberDiff line change
@@ -1781,6 +1781,7 @@ describe("declarative config: flatten", function()
17811781
http_path = "/",
17821782
https_sni = null,
17831783
https_verify_certificate = true,
1784+
headers = null,
17841785
timeout = 1,
17851786
type = "http",
17861787
unhealthy = {
@@ -1832,6 +1833,7 @@ describe("declarative config: flatten", function()
18321833
http_path = "/",
18331834
https_sni = null,
18341835
https_verify_certificate = true,
1836+
headers = null,
18351837
timeout = 1,
18361838
type = "http",
18371839
unhealthy = {

spec/02-integration/05-proxy/10-balancer/01-healthchecks_spec.lua

+1
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,7 @@ for _, strategy in helpers.each_strategy() do
729729
http_path = "/status",
730730
https_sni = cjson.null,
731731
https_verify_certificate = true,
732+
headers = cjson.null,
732733
timeout = 1,
733734
unhealthy = {
734735
http_failures = 1,

0 commit comments

Comments
 (0)