Skip to content

Commit

Permalink
tests(templates): add mock_upstream fixture to data plane for RLA t…
Browse files Browse the repository at this point in the history
…ests (#10224)

1. `control_plane` still uses port `15555/15556`.
2. `data_plane` uses a *new* port `16665/16666`.

The RLA tests currently have to use `httpbin.org`, which makes tests more flaky.
  • Loading branch information
outsinre authored Feb 20, 2023
1 parent 9a82caf commit 6ad8bf3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
8 changes: 6 additions & 2 deletions spec/fixtures/custom_nginx.template
Original file line number Diff line number Diff line change
Expand Up @@ -455,13 +455,18 @@ http {
}
> end -- role == "control_plane"

> if role ~= "data_plane" then
server {
server_name mock_upstream;

> if role ~= "data_plane" then
listen 15555;
listen 15556 ssl;

> else
listen 16665;
listen 16666 ssl;
> end -- role ~= "data_plane"

> for i = 1, #ssl_cert do
ssl_certificate $(ssl_cert[i]);
ssl_certificate_key $(ssl_cert_key[i]);
Expand Down Expand Up @@ -706,7 +711,6 @@ http {
}
}
}
> end -- role ~= "data_plane"

include '*.http_mock';

Expand Down
26 changes: 25 additions & 1 deletion spec/helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ local MOCK_UPSTREAM_PORT = 15555
local MOCK_UPSTREAM_SSL_PORT = 15556
local MOCK_UPSTREAM_STREAM_PORT = 15557
local MOCK_UPSTREAM_STREAM_SSL_PORT = 15558
local MOCK_UPSTREAM_DP_PORT = 16665
local MOCK_UPSTREAM_DP_SSL_PORT = 16666
local GRPCBIN_HOST = os.getenv("KONG_SPEC_TEST_GRPCBIN_HOST") or "localhost"
local GRPCBIN_PORT = tonumber(os.getenv("KONG_SPEC_TEST_GRPCBIN_PORT")) or 9000
local GRPCBIN_SSL_PORT = tonumber(os.getenv("KONG_SPEC_TEST_GRPCBIN_SSL_PORT")) or 9001
Expand Down Expand Up @@ -1859,7 +1861,7 @@ local function wait_for_all_config_update(opts)
if stream_enabled then
pwait_until(function ()
local proxy = proxy_client(proxy_client_timeout, stream_port, stream_ip)

res = proxy:get("/always_200")
local ok, err = pcall(assert, res.status == 200)
proxy:close()
Expand Down Expand Up @@ -3517,6 +3519,14 @@ end
-- @field mock_upstream_ssl_host
-- @field mock_upstream_ssl_port
-- @field mock_upstream_ssl_url Base url constructed from the components
-- @field mock_upstream_dp_protocol
-- @field mock_upstream_dp_host
-- @field mock_upstream_dp_port
-- @field mock_upstream_dp_url Base url constructed from the components
-- @field mock_upstream_dp_ssl_protocol
-- @field mock_upstream_dp_ssl_host
-- @field mock_upstream_dp_ssl_port
-- @field mock_upstream_dp_ssl_url Base url constructed from the components
-- @field mock_upstream_stream_port
-- @field mock_upstream_stream_ssl_port
-- @field mock_grpc_upstream_proto_path
Expand Down Expand Up @@ -3572,6 +3582,20 @@ end
MOCK_UPSTREAM_HOST .. ':' ..
MOCK_UPSTREAM_SSL_PORT,

mock_upstream_dp_protocol = MOCK_UPSTREAM_PROTOCOL,
mock_upstream_dp_host = MOCK_UPSTREAM_HOST,
mock_upstream_dp_port = MOCK_UPSTREAM_DP_PORT,
mock_upstream_dp_url = MOCK_UPSTREAM_PROTOCOL .. "://" ..
MOCK_UPSTREAM_HOST .. ':' ..
MOCK_UPSTREAM_DP_PORT,

mock_upstream_dp_ssl_protocol = MOCK_UPSTREAM_SSL_PROTOCOL,
mock_upstream_dp_ssl_host = MOCK_UPSTREAM_HOST,
mock_upstream_dp_ssl_port = MOCK_UPSTREAM_DP_SSL_PORT,
mock_upstream_dp_ssl_url = MOCK_UPSTREAM_SSL_PROTOCOL .. "://" ..
MOCK_UPSTREAM_HOST .. ':' ..
MOCK_UPSTREAM_DP_SSL_PORT,

mock_upstream_stream_port = MOCK_UPSTREAM_STREAM_PORT,
mock_upstream_stream_ssl_port = MOCK_UPSTREAM_STREAM_SSL_PORT,
mock_grpc_upstream_proto_path = MOCK_GRPC_UPSTREAM_PROTO_PATH,
Expand Down

1 comment on commit 6ad8bf3

@khcp-gha-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bazel Build

Docker image available kong/kong:6ad8bf399fe1c9b0587d28e33f8e2cb0caf7d226
Artifacts available https://github.com/Kong/kong/actions/runs/4221205614

Please sign in to comment.