Skip to content

Commit 01ed1a9

Browse files
CI Botms2008
authored andcommitted
chore(version) added Kong Enterprise version 3.11.0.3 artifacts
1 parent 08a73d0 commit 01ed1a9

File tree

1,080 files changed

+185207
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,080 files changed

+185207
-0
lines changed
Lines changed: 275 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,275 @@
1+
OS := $(shell uname | awk '{print tolower($$0)}')
2+
MACHINE := $(shell uname -m)
3+
4+
BAZEL_REMOTE_CACHE_OPT := $(if $(BAZEL_REMOTE_CACHE),--remote_cache=$(BAZEL_REMOTE_CACHE))
5+
LUAROCKS_OPTS ?= --server https://kong.github.io/kongrocks-dev/rocks/ OPENSSL_DIR=$(OPENSSL_DIR) YAML_DIR=$(YAML_DIR) AVRO_INCDIR=$(AVRO_INCDIR) AVRO_LIBDIR=$(AVRO_LIBDIR)
6+
DEV_ROCKS = "busted 2.2.0" "busted-hjtest 0.0.5" "luacheck 1.2.0" "lua-llthreads2 0.1.6" "ldoc 1.5.0" "luacov 0.16.0" "lua-reqwest 0.1.2"
7+
WIN_SCRIPTS = "bin/busted" "bin/kong" "bin/kong-health"
8+
BUSTED_ARGS ?= -v
9+
TEST_CMD ?= bin/busted $(BUSTED_ARGS)
10+
PYTHON ?= python3
11+
TEST_PYTHON_REQUIREMENTS_FILE = "spec-ee/fixtures/mcp/requirements.txt"
12+
13+
BUILD_NAME ?= kong-dev
14+
BAZEL_ARGS ?= --verbose_failures --action_env=BUILD_NAME=$(BUILD_NAME) --//:skip_webui=true --//:skip_tools=true $(BAZEL_REMOTE_CACHE_OPT) --remote_upload_local_results=false
15+
16+
ifeq ($(OS), darwin)
17+
HOMEBREW_DIR ?= /opt/homebrew
18+
OPENSSL_DIR ?= $(shell brew --prefix)/opt/openssl
19+
EXPAT_DIR ?= $(HOMEBREW_DIR)/opt/expat
20+
LIBXML2_DIR ?= $(HOMEBREW_DIR)/opt/libxml2
21+
GRPCURL_OS ?= osx
22+
YAML_DIR ?= $(shell brew --prefix)/opt/libyaml
23+
AVRO_LIBDIR ?= $(shell brew --prefix)/opt/avro/lib
24+
AVRO_INCDIR ?= $(shell brew --prefix)/opt/avro/include
25+
else
26+
LIBRARY_PREFIX ?= /usr
27+
OPENSSL_DIR ?= $(LIBRARY_PREFIX)
28+
EXPAT_DIR ?= $(LIBRARY_PREFIX)
29+
LIBXML2_DIR ?= $(LIBRARY_PREFIX)
30+
GRPCURL_OS ?= $(OS)
31+
YAML_DIR ?= /usr
32+
AVRO_LIBDIR ?= /usr/local/kong/lib
33+
AVRO_INCDIR ?= /usr/local/kong/include/avro
34+
endif
35+
36+
ifeq ($(MACHINE), aarch64)
37+
GRPCURL_MACHINE ?= arm64
38+
H2CLIENT_MACHINE ?= arm64
39+
else
40+
GRPCURL_MACHINE ?= $(MACHINE)
41+
H2CLIENT_MACHINE ?= $(MACHINE)
42+
endif
43+
44+
ifeq ($(MACHINE), aarch64)
45+
BAZELISK_MACHINE ?= arm64
46+
else ifeq ($(MACHINE), x86_64)
47+
BAZELISK_MACHINE ?= amd64
48+
else
49+
BAZELISK_MACHINE ?= $(MACHINE)
50+
endif
51+
52+
.PHONY: install dev \
53+
sca test test-integration test-plugins test-all \
54+
pdk-phase-check functional-tests \
55+
fix-windows release test-logs
56+
57+
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
58+
KONG_SOURCE_LOCATION ?= $(ROOT_DIR)
59+
GRPCURL_VERSION ?= 1.8.5
60+
BAZLISK_VERSION ?= 1.26.0
61+
H2CLIENT_VERSION ?= 0.4.4
62+
BAZEL := $(shell command -v bazel 2> /dev/null)
63+
VENV = /dev/null # backward compatibility when no venv is built
64+
65+
# Use x86_64 grpcurl v1.8.5 for Apple silicon chips
66+
ifeq ($(GRPCURL_OS)_$(MACHINE)_$(GRPCURL_VERSION), osx_arm64_1.8.5)
67+
GRPCURL_MACHINE = x86_64
68+
endif
69+
70+
PACKAGE_TYPE ?= deb
71+
72+
bin/bazel:
73+
@curl -s -S -L \
74+
https://github.com/bazelbuild/bazelisk/releases/download/v$(BAZLISK_VERSION)/bazelisk-$(OS)-$(BAZELISK_MACHINE) -o bin/bazel
75+
@chmod +x bin/bazel
76+
77+
bin/grpcurl:
78+
@curl -s -S -L \
79+
https://github.com/fullstorydev/grpcurl/releases/download/v$(GRPCURL_VERSION)/grpcurl_$(GRPCURL_VERSION)_$(GRPCURL_OS)_$(GRPCURL_MACHINE).tar.gz | tar xz -C bin;
80+
@$(RM) bin/LICENSE
81+
82+
bin/h2client:
83+
@curl -s -S -L \
84+
https://github.com/Kong/h2client/releases/download/v$(H2CLIENT_VERSION)/h2client_$(H2CLIENT_VERSION)_$(OS)_$(H2CLIENT_MACHINE).tar.gz | tar xz -C bin;
85+
@$(RM) bin/README.md
86+
87+
install-rust-toolchain:
88+
@if command -v cargo; then \
89+
echo "Rust is already installed in the local directory, skipping"; \
90+
else \
91+
echo "Installing Rust..."; \
92+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path; \
93+
. $$HOME/.cargo/env; \
94+
rustup toolchain install stable; \
95+
rustup default stable; \
96+
fi
97+
98+
check-bazel: bin/bazel
99+
ifndef BAZEL
100+
$(eval BAZEL := bin/bazel)
101+
endif
102+
103+
build-cache: check-bazel
104+
$(BAZEL) build //build:cacheable-targets $(BAZEL_REMOTE_CACHE_OPT)
105+
106+
build-kong: check-bazel
107+
$(BAZEL) build //build:kong $(BAZEL_ARGS)
108+
109+
build-venv: check-bazel
110+
$(eval VENV := bazel-bin/build/$(BUILD_NAME)-venv.sh)
111+
112+
@if [ ! -e bazel-bin/build/$(BUILD_NAME)-venv.sh ]; then \
113+
$(BAZEL) build //build:venv $(BAZEL_ARGS); \
114+
fi
115+
116+
build-openresty: check-bazel
117+
118+
@if [ ! -e bazel-bin/build/$(BUILD_NAME)/openresty ]; then \
119+
$(BAZEL) build //build:install-openresty --verbose_failures --action_env=BUILD_NAME=$(BUILD_NAME); \
120+
else \
121+
$(BAZEL) build //build:dev-make-openresty --verbose_failures --action_env=BUILD_NAME=$(BUILD_NAME); \
122+
fi
123+
124+
build-static-assets: check-bazel
125+
$(BAZEL) build //build:install-static-assets --verbose_failures --action_env=BUILD_NAME=$(BUILD_NAME)
126+
127+
install-dev-rocks: build-venv
128+
@. $(VENV) ;\
129+
export PATH=$$PATH:$$HOME/.cargo/bin; \
130+
for rock in $(DEV_ROCKS) ; do \
131+
if luarocks list --porcelain $$rock | grep -q "installed" ; then \
132+
echo $$rock already installed, skipping ; \
133+
else \
134+
echo $$rock not found, installing via luarocks... ; \
135+
LIBRARY_PREFIX=$$(pwd)/bazel-bin/build/$(BUILD_NAME)/kong ; \
136+
luarocks install $$rock $(LUAROCKS_OPTS) || exit 1; \
137+
fi \
138+
done;
139+
140+
install-test-python-packages: build-venv
141+
@. $(VENV) ;\
142+
$(PYTHON) -m pip --version || { \
143+
echo "Python pip is not installed, install it first"; \
144+
bash ./scripts/install-pip.sh; \
145+
}; \
146+
for file in $(TEST_PYTHON_REQUIREMENTS_FILE); do \
147+
echo "Installing Python package from $$file"; \
148+
$(PYTHON) -m pip install --user --break-system-packages -r $$file; \
149+
done;
150+
151+
dev: install-rust-toolchain build-venv install-dev-rocks install-test-python-packages bin/grpcurl bin/h2client
152+
153+
build-release: check-bazel
154+
$(BAZEL) clean --expunge
155+
$(BAZEL) build //build:kong --verbose_failures --config release
156+
157+
package/deb: check-bazel build-release
158+
$(BAZEL) build --config release :kong_deb
159+
160+
package/rpm: check-bazel build-release
161+
$(BAZEL) build --config release :kong_el8 --action_env=RPM_SIGNING_KEY_FILE --action_env=NFPM_RPM_PASSPHRASE
162+
$(BAZEL) build --config release :kong_aws2 --action_env=RPM_SIGNING_KEY_FILE --action_env=NFPM_RPM_PASSPHRASE
163+
$(BAZEL) build --config release :kong_aws2022 --action_env=RPM_SIGNING_KEY_FILE --action_env=NFPM_RPM_PASSPHRASE
164+
165+
functional-tests: dev test
166+
167+
install: dev
168+
@$(VENV) luarocks make
169+
170+
clean: check-bazel
171+
$(BAZEL) clean
172+
$(RM) bin/bazel bin/grpcurl bin/h2client
173+
174+
expunge: check-bazel
175+
$(BAZEL) clean --expunge
176+
$(RM) bin/bazel bin/grpcurl bin/h2client
177+
178+
sca:
179+
@!(grep -R -E -I -n -w '#only|#o' spec && echo "#only or #o tag detected") >&2
180+
@!(grep -R -E -I -n -w '#only|#o' spec-ee && echo "#only or #o tag detected") >&2
181+
@!(grep -R -E -I -n -- '---\s+ONLY' t && echo "--- ONLY block detected") >&2
182+
@$(KONG_SOURCE_LOCATION)/scripts/copyright-header-checker
183+
184+
update-copyright: build-venv
185+
bash -c 'OPENSSL_DIR=$(OPENSSL_DIR) EXPAT_DIR=$(EXPAT_DIR) $(VENV) luajit $(KONG_SOURCE_LOCATION)/scripts/update-copyright'
186+
187+
trigger-api-tests:
188+
-docker manifest inspect kong/kong-gateway-internal:${DOCKER_IMAGE_TAG} 2>&1 >/dev/null && \
189+
curl \
190+
-X POST \
191+
-H "Accept: application/vnd.github+json" \
192+
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
193+
https://api.github.com/repos/kong/kong-api-tests/dispatches \
194+
-d '{"event_type":"per-commit-test","client_payload":{"docker_image":"kong/kong-gateway-internal:${DOCKER_IMAGE_TAG}"}' \
195+
196+
test: dev
197+
@$(VENV) $(TEST_CMD) spec/01-unit
198+
199+
test-integration: dev
200+
@$(VENV) $(TEST_CMD) spec/02-integration
201+
202+
test-plugins-spec: dev
203+
@$(VENV) $(TEST_CMD) spec/03-plugins
204+
205+
test-all: dev
206+
@$(VENV) $(TEST_CMD) spec/
207+
208+
test-ee: dev
209+
@$(VENV) $(TEST_CMD) spec-ee/01-unit
210+
211+
test-integration-ee: dev
212+
@$(VENV) $(TEST_CMD) spec-ee/02-integration
213+
214+
test-plugins-spec-ee: dev
215+
@$(VENV) $(TEST_CMD) spec-ee/03-plugins
216+
217+
test-all-ee: dev
218+
@$(VENV) $(TEST_CMD) spec-ee/
219+
220+
test-custom: dev
221+
ifndef test_spec
222+
$(error test_spec variable needs to be set, i.e. make test-custom test_spec=foo/bar/baz_spec.lua)
223+
endif
224+
@$(VENV) $(TEST_CMD) $(test_spec)
225+
226+
test-logs:
227+
tail -F servroot/logs/error.log
228+
229+
pdk-phase-checks: dev
230+
rm -f t/phase_checks.stats
231+
rm -f t/phase_checks.report
232+
PDK_PHASE_CHECKS_LUACOV=1 prove -I. t/01*/*/00-phase*.t
233+
luacov -c t/phase_checks.luacov
234+
grep "ngx\\." t/phase_checks.report
235+
grep "check_" t/phase_checks.report
236+
237+
test-plugins-ee:
238+
ifndef EE_PLUGIN
239+
$(error "Please use make plugins-ee EE_PLUGIN=plugin-name")
240+
endif
241+
scripts/enterprise_plugin.sh build-deps
242+
scripts/enterprise_plugin.sh test $(EE_PLUGIN)
243+
244+
fix-windows:
245+
@for script in $(WIN_SCRIPTS) ; do \
246+
echo Converting Windows file $$script ; \
247+
mv $$script $$script.win ; \
248+
tr -d '\015' <$$script.win >$$script ; \
249+
rm $$script.win ; \
250+
chmod 0755 $$script ; \
251+
done;
252+
253+
# the following targets are kept for backwards compatibility
254+
# dev is renamed to dev-legacy
255+
remove:
256+
$(warning 'remove' target is deprecated, please use `make dev` instead)
257+
-@luarocks remove kong
258+
259+
dependencies: install-rust-toolchain bin/grpcurl bin/h2client
260+
$(warning 'dependencies' target is deprecated, this is now not needed when using `make dev`, but are kept for installation that are not built by Bazel)
261+
262+
export PATH=$$PATH:$$HOME/.cargo/bin; \
263+
for rock in $(DEV_ROCKS) ; do \
264+
if luarocks list --porcelain $$rock | grep -q "installed" ; then \
265+
echo $$rock already installed, skipping ; \
266+
else \
267+
echo $$rock not found, installing via luarocks... ; \
268+
luarocks install $$rock $(LUAROCKS_OPTS) || exit 1; \
269+
fi \
270+
done;
271+
272+
install-legacy:
273+
@luarocks make OPENSSL_DIR=$(OPENSSL_DIR) YAML_DIR=$(YAML_DIR) AVRO_INCDIR=$(AVRO_INCDIR) AVRO_LIBDIR=$(AVRO_LIBDIR)
274+
275+
dev-legacy: remove install-legacy dependencies
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#!/usr/bin/env resty
2+
3+
setmetatable(_G, nil)
4+
5+
if not os.getenv("KONG_BUSTED_RESPAWNED") then
6+
local pl_path = require("pl.path")
7+
local pl_file = require("pl.file")
8+
local tools_system = require("kong.tools.system")
9+
10+
local cert_path do
11+
local busted_cert_file = pl_path.tmpname()
12+
local busted_cert_content = pl_file.read("spec/fixtures/kong_spec.crt")
13+
14+
local system_cert_path, err = tools_system.get_system_trusted_certs_filepath()
15+
if system_cert_path then
16+
busted_cert_content = busted_cert_content .. "\n" .. pl_file.read(system_cert_path)
17+
end
18+
19+
local cluster_cert_content = assert(pl_file.read("spec/fixtures/kong_clustering.crt"))
20+
busted_cert_content = busted_cert_content .. "\n" .. cluster_cert_content
21+
22+
pl_file.write(busted_cert_file, busted_cert_content)
23+
cert_path = busted_cert_file
24+
end
25+
26+
local DEFAULT_RESTY_FLAGS = string.format(" -c 4096 --http-conf 'lua_ssl_trusted_certificate %s;' ", cert_path)
27+
28+
-- initial run, so go update the environment
29+
local script = {}
30+
for line in io.popen("set"):lines() do
31+
local ktvar, val = line:match("^KONG_TEST_([^=]*)=(.*)")
32+
if ktvar then
33+
-- reinserted KONG_TEST_xxx as KONG_xxx; append
34+
table.insert(script, "export KONG_" .. ktvar .. "=" ..val)
35+
end
36+
37+
local var = line:match("^(KONG_[^=]*)")
38+
local var_for_spec = line:match("^(KONG_SPEC_[^=]*)")
39+
if var and not var_for_spec then
40+
-- remove existing KONG_xxx and KONG_TEST_xxx variables; prepend
41+
table.insert(script, 1, "unset " .. var)
42+
end
43+
end
44+
-- add cli recursion detection
45+
table.insert(script, "export KONG_BUSTED_RESPAWNED=1")
46+
47+
-- XXX EE
48+
table.insert(script, "export KONG_IS_TESTING=1")
49+
50+
-- rebuild the invoked commandline, while inserting extra resty-flags
51+
local resty_flags = DEFAULT_RESTY_FLAGS
52+
local cmd = { "exec", "/usr/bin/env", "resty" }
53+
local cmd_prefix_count = #cmd
54+
for i = 0, #arg do
55+
if arg[i]:sub(1, 12) == "RESTY_FLAGS=" then
56+
resty_flags = arg[i]:sub(13, -1)
57+
58+
else
59+
table.insert(cmd, "'" .. arg[i] .. "'")
60+
end
61+
end
62+
63+
-- create shared dict
64+
resty_flags = resty_flags .. require("spec.fixtures.shared_dict")
65+
66+
-- create lmdb environment
67+
local lmdb_env = os.tmpname()
68+
resty_flags = resty_flags .. string.format(' --main-conf "lmdb_environment_path %s;" ', lmdb_env)
69+
resty_flags = resty_flags .. string.format(' --main-conf "lmdb_max_databases %s;" ', 3)
70+
resty_flags = resty_flags .. string.format(' --main-conf "lmdb_map_size %s;" ', "5m")
71+
72+
if resty_flags then
73+
table.insert(cmd, cmd_prefix_count+1, resty_flags)
74+
end
75+
76+
table.insert(script, table.concat(cmd, " "))
77+
78+
-- recurse cli command, with proper variables (un)set for clean testing
79+
local _, _, rc = os.execute(table.concat(script, "; "))
80+
os.exit(rc)
81+
end
82+
83+
if os.getenv("BUSTED_EMMY_DEBUGGER") then
84+
require("kong.tools.emmy_debugger").init({
85+
debugger = os.getenv("BUSTED_EMMY_DEBUGGER"),
86+
host = os.getenv("BUSTED_EMMY_DEBUGGER_HOST"),
87+
port = os.getenv("BUSTED_EMMY_DEBUGGER_PORT"),
88+
wait = true,
89+
source_path = os.getenv("BUSTED_EMMY_DEBUGGER_SOURCE_PATH"),
90+
})
91+
end
92+
93+
require("kong.globalpatches")({
94+
cli = true,
95+
rbusted = true
96+
})
97+
98+
-- some libraries used in test like spec/helpers
99+
-- calls cosocket in module level, and as LuaJIT's
100+
-- `require` is implemented in C, this throws
101+
-- "attempt to yield across C-call boundary" error
102+
-- the following pure-lua implementation is to bypass
103+
-- this limitation, without need to modify all tests
104+
_G.require = require "spec.require".require
105+
106+
-- Busted command-line runner
107+
require 'busted.runner'({ standalone = false })
108+
109+
110+
-- vim: set ft=lua ts=2 sw=2 sts=2 et :

0 commit comments

Comments
 (0)