Skip to content

Commit

Permalink
tests(prometheus) update tests to include per route data
Browse files Browse the repository at this point in the history
  • Loading branch information
hbagdi authored and gszr committed Sep 9, 2019
1 parent e4677a7 commit 136ce69
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
11 changes: 7 additions & 4 deletions spec/02-access_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe("Plugin: prometheus (access)", function()

bp.routes:insert {
protocols = { "http" },
name = "http-route",
paths = { "/" },
methods = { "GET" },
service = service,
Expand All @@ -31,6 +32,7 @@ describe("Plugin: prometheus (access)", function()

bp.routes:insert {
protocols = { "grpc" },
name = "grpc-route",
hosts = { "grpc" },
service = grpc_service,
}
Expand All @@ -42,6 +44,7 @@ describe("Plugin: prometheus (access)", function()

bp.routes:insert {
protocols = { "grpcs" },
name = "grpcs-route",
hosts = { "grpcs" },
service = grpcs_service,
}
Expand Down Expand Up @@ -87,7 +90,7 @@ describe("Plugin: prometheus (access)", function()
path = "/metrics",
})
local body = assert.res_status(200, res)
return body:find('kong_http_status{code="200",service="mock-service"} 1', nil, true)
return body:find('kong_http_status{code="200",service="mock-service",route="http-route"} 1', nil, true)
end)

res = assert(proxy_client:send {
Expand All @@ -105,7 +108,7 @@ describe("Plugin: prometheus (access)", function()
path = "/metrics",
})
local body = assert.res_status(200, res)
return body:find('kong_http_status{code="400",service="mock-service"} 1', nil, true)
return body:find('kong_http_status{code="400",service="mock-service",route="http-route"} 1', nil, true)
end)
end)

Expand All @@ -128,7 +131,7 @@ describe("Plugin: prometheus (access)", function()
path = "/metrics",
})
local body = assert.res_status(200, res)
return body:find('kong_http_status{code="200",service="mock-grpc-service"} 1', nil, true)
return body:find('kong_http_status{code="200",service="mock-grpc-service",route="grpc-route"} 1', nil, true)
end)

ok, resp = proxy_client_grpcs({
Expand All @@ -149,7 +152,7 @@ describe("Plugin: prometheus (access)", function()
path = "/metrics",
})
local body = assert.res_status(200, res)
return body:find('kong_http_status{code="200",service="mock-grpc-service"} 1', nil, true)
return body:find('kong_http_status{code="200",service="mock-grpcs-service",route="grpcs-route"} 1', nil, true)
end)
end)

Expand Down
3 changes: 2 additions & 1 deletion spec/03-custom-serve_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe("Plugin: prometheus (custom server)",function()

bp.routes:insert {
protocols = { "http" },
name = "http-route",
paths = { "/" },
service = service,
}
Expand Down Expand Up @@ -56,7 +57,7 @@ describe("Plugin: prometheus (custom server)",function()
path = "/metrics",
})
local body = assert.res_status(200, res)
assert.matches('kong_http_status{code="200",service="mock-service"} 1', body, nil, true)
assert.matches('kong_http_status{code="200",service="mock-service",route="http-route"} 1', body, nil, true)
end)
it("custom port returns 404 for anything other than /metrics", function()
local client = helpers.http_client("127.0.0.1", 9542)
Expand Down

0 comments on commit 136ce69

Please sign in to comment.