Skip to content

Commit

Permalink
chore(version) added Kong open source version 3.0.2 artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
mashapedeployment authored and Tieske committed Dec 17, 2022
1 parent fd24a3e commit 9ac335e
Show file tree
Hide file tree
Showing 226 changed files with 47,826 additions and 0 deletions.
217 changes: 217 additions & 0 deletions kong-versions/3.0.2/kong/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
$(info starting make in kong)

OS := $(shell uname | awk '{print tolower($$0)}')
MACHINE := $(shell uname -m)

DEV_ROCKS = "busted 2.0.0" "busted-htest 1.0.0" "luacheck 0.26.1" "lua-llthreads2 0.1.6" "http 0.4" "ldoc 1.4.6"
WIN_SCRIPTS = "bin/busted" "bin/kong"
BUSTED_ARGS ?= -v
TEST_CMD ?= bin/busted $(BUSTED_ARGS)

ifeq ($(OS), darwin)
OPENSSL_DIR ?= /usr/local/opt/openssl
GRPCURL_OS ?= osx
else
OPENSSL_DIR ?= /usr
GRPCURL_OS ?= $(OS)
endif

ifeq ($(MACHINE), aarch64)
GRPCURL_MACHINE ?= arm64
else
GRPCURL_MACHINE ?= $(MACHINE)
endif

.PHONY: install dependencies dev remove grpcurl \
setup-ci setup-kong-build-tools \
lint test test-integration test-plugins test-all \
pdk-phase-check functional-tests \
fix-windows release

ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
KONG_SOURCE_LOCATION ?= $(ROOT_DIR)
KONG_BUILD_TOOLS_LOCATION ?= $(KONG_SOURCE_LOCATION)/../kong-build-tools
RESTY_VERSION ?= `grep RESTY_VERSION $(KONG_SOURCE_LOCATION)/.requirements | awk -F"=" '{print $$2}'`
RESTY_LUAROCKS_VERSION ?= `grep RESTY_LUAROCKS_VERSION $(KONG_SOURCE_LOCATION)/.requirements | awk -F"=" '{print $$2}'`
RESTY_OPENSSL_VERSION ?= `grep RESTY_OPENSSL_VERSION $(KONG_SOURCE_LOCATION)/.requirements | awk -F"=" '{print $$2}'`
RESTY_PCRE_VERSION ?= `grep RESTY_PCRE_VERSION $(KONG_SOURCE_LOCATION)/.requirements | awk -F"=" '{print $$2}'`
KONG_BUILD_TOOLS ?= `grep KONG_BUILD_TOOLS_VERSION $(KONG_SOURCE_LOCATION)/.requirements | awk -F"=" '{print $$2}'`
GRPCURL_VERSION ?= 1.8.5
OPENRESTY_PATCHES_BRANCH ?= master
KONG_NGINX_MODULE_BRANCH ?= master

PACKAGE_TYPE ?= deb
# This logic should mirror the kong-build-tools equivalent
KONG_VERSION ?= `$(KONG_SOURCE_LOCATION)/distribution/grep-kong-version.sh`

TAG := $(shell git describe --exact-match --tags HEAD || true)


ifneq ($(TAG),)
# if we're building a tag the tag name is the KONG_VERSION (allows for environment var to override)
ISTAG = true
KONG_TAG = $(TAG)
OFFICIAL_RELEASE = true
else
# we're not building a tag so this is a nightly build
RELEASE_DOCKER_ONLY = true
OFFICIAL_RELEASE = false
ISTAG = false
endif

release-docker-images:
cd $(KONG_BUILD_TOOLS_LOCATION); \
$(MAKE) \
KONG_SOURCE_LOCATION=${KONG_SOURCE_LOCATION} \
package-kong && \
$(MAKE) \
KONG_SOURCE_LOCATION=${KONG_SOURCE_LOCATION} \
release-kong-docker-images

release:
ifeq ($(ISTAG),false)
sed -i -e '/return string\.format/,/\"\")/c\return "$(KONG_VERSION)\"' kong/meta.lua
endif
cd $(KONG_BUILD_TOOLS_LOCATION); \
$(MAKE) \
KONG_SOURCE_LOCATION=${KONG_SOURCE_LOCATION} \
KONG_VERSION=${KONG_VERSION} \
KONG_TAG=${KONG_TAG} \
package-kong && \
$(MAKE) \
KONG_SOURCE_LOCATION=${KONG_SOURCE_LOCATION} \
KONG_VERSION=${KONG_VERSION} \
RELEASE_DOCKER_ONLY=${RELEASE_DOCKER_ONLY} \
OFFICIAL_RELEASE=$(OFFICIAL_RELEASE) \
KONG_TAG=${KONG_TAG} \
release-kong

setup-ci:
OPENRESTY=$(RESTY_VERSION) \
LUAROCKS=$(RESTY_LUAROCKS_VERSION) \
OPENSSL=$(RESTY_OPENSSL_VERSION) \
OPENRESTY_PATCHES_BRANCH=$(OPENRESTY_PATCHES_BRANCH) \
KONG_NGINX_MODULE_BRANCH=$(KONG_NGINX_MODULE_BRANCH) \
.ci/setup_env.sh

package/deb: setup-kong-build-tools
cd $(KONG_BUILD_TOOLS_LOCATION); \
PACKAGE_TYPE=deb RESTY_IMAGE_BASE=ubuntu RESTY_IMAGE_TAG=22.04 $(MAKE) package-kong && \
cp $(KONG_BUILD_TOOLS_LOCATION)/output/*.deb .

package/apk: setup-kong-build-tools
cd $(KONG_BUILD_TOOLS_LOCATION); \
PACKAGE_TYPE=apk RESTY_IMAGE_BASE=alpine RESTY_IMAGE_TAG=3 $(MAKE) package-kong && \
cp $(KONG_BUILD_TOOLS_LOCATION)/output/*.apk.* .

package/rpm: setup-kong-build-tools
cd $(KONG_BUILD_TOOLS_LOCATION); \
PACKAGE_TYPE=rpm RESTY_IMAGE_BASE=rhel RESTY_IMAGE_TAG=8.6 $(MAKE) package-kong && \
cp $(KONG_BUILD_TOOLS_LOCATION)/output/*.rpm .

package/test/deb: package/deb
cd $(KONG_BUILD_TOOLS_LOCATION); \
PACKAGE_TYPE=deb RESTY_IMAGE_BASE=ubuntu RESTY_IMAGE_TAG=22.04 $(MAKE) test

package/test/apk: package/apk
cd $(KONG_BUILD_TOOLS_LOCATION); \
PACKAGE_TYPE=apk RESTY_IMAGE_BASE=alpine RESTY_IMAGE_TAG=3 $(MAKE) test

package/test/rpm: package/rpm
cd $(KONG_BUILD_TOOLS_LOCATION); \
PACKAGE_TYPE=rpm RESTY_IMAGE_BASE=rhel RESTY_IMAGE_TAG=8.6 $(MAKE) test

package/docker/deb: package/deb
cd $(KONG_BUILD_TOOLS_LOCATION); \
PACKAGE_TYPE=deb RESTY_IMAGE_BASE=ubuntu RESTY_IMAGE_TAG=22.04 $(MAKE) build-test-container

package/docker/apk: package/apk
cd $(KONG_BUILD_TOOLS_LOCATION); \
PACKAGE_TYPE=apk RESTY_IMAGE_BASE=alpine RESTY_IMAGE_TAG=3 $(MAKE) build-test-container

package/docker/rpm: package/rpm
cd $(KONG_BUILD_TOOLS_LOCATION); \
PACKAGE_TYPE=rpm RESTY_IMAGE_BASE=rhel RESTY_IMAGE_TAG=8.6 $(MAKE) build-test-container

release/docker/deb: package/docker/deb
cd $(KONG_BUILD_TOOLS_LOCATION); \
PACKAGE_TYPE=deb RESTY_IMAGE_BASE=ubuntu RESTY_IMAGE_TAG=22.04 $(MAKE) release-kong-docker-images

release/docker/apk: package/docker/apk
cd $(KONG_BUILD_TOOLS_LOCATION); \
PACKAGE_TYPE=apk RESTY_IMAGE_BASE=alpine RESTY_IMAGE_TAG=3 $(MAKE) release-kong-docker-images

release/docker/rpm: package/docker/rpm
cd $(KONG_BUILD_TOOLS_LOCATION); \
PACKAGE_TYPE=rpm RESTY_IMAGE_BASE=rhel RESTY_IMAGE_TAG=8.6 $(MAKE) release-kong-docker-images

setup-kong-build-tools:
-git submodule update --init --recursive
-git submodule status
-rm -rf $(KONG_BUILD_TOOLS_LOCATION)
-git clone https://github.com/Kong/kong-build-tools.git --recursive $(KONG_BUILD_TOOLS_LOCATION)
cd $(KONG_BUILD_TOOLS_LOCATION); \
git reset --hard && git checkout $(KONG_BUILD_TOOLS); \

functional-tests: setup-kong-build-tools
cd $(KONG_BUILD_TOOLS_LOCATION); \
$(MAKE) setup-build && \
$(MAKE) build-kong && \
$(MAKE) test

install:
@luarocks make OPENSSL_DIR=$(OPENSSL_DIR) CRYPTO_DIR=$(OPENSSL_DIR)

remove:
-@luarocks remove kong

dependencies: bin/grpcurl
@for rock in $(DEV_ROCKS) ; do \
if luarocks list --porcelain $$rock | grep -q "installed" ; then \
echo $$rock already installed, skipping ; \
else \
echo $$rock not found, installing via luarocks... ; \
luarocks install $$rock OPENSSL_DIR=$(OPENSSL_DIR) CRYPTO_DIR=$(OPENSSL_DIR) || exit 1; \
fi \
done;

bin/grpcurl:
@curl -s -S -L \
https://github.com/fullstorydev/grpcurl/releases/download/v$(GRPCURL_VERSION)/grpcurl_$(GRPCURL_VERSION)_$(GRPCURL_OS)_$(GRPCURL_MACHINE).tar.gz | tar xz -C bin;
@rm bin/LICENSE

dev: remove install dependencies

lint:
@luacheck -q .
@!(grep -R -E -I -n -w '#only|#o' spec && echo "#only or #o tag detected") >&2
@!(grep -R -E -I -n -- '---\s+ONLY' t && echo "--- ONLY block detected") >&2

test:
@$(TEST_CMD) spec/01-unit

test-integration:
@$(TEST_CMD) spec/02-integration

test-plugins:
@$(TEST_CMD) spec/03-plugins

test-all:
@$(TEST_CMD) spec/

pdk-phase-checks:
rm -f t/phase_checks.stats
rm -f t/phase_checks.report
PDK_PHASE_CHECKS_LUACOV=1 prove -I. t/01*/*/00-phase*.t
luacov -c t/phase_checks.luacov
grep "ngx\\." t/phase_checks.report
grep "check_" t/phase_checks.report

fix-windows:
@for script in $(WIN_SCRIPTS) ; do \
echo Converting Windows file $$script ; \
mv $$script $$script.win ; \
tr -d '\015' <$$script.win >$$script ; \
rm $$script.win ; \
chmod 0755 $$script ; \
done;
58 changes: 58 additions & 0 deletions kong-versions/3.0.2/kong/bin/busted
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env resty

local DEFAULT_RESTY_FLAGS="-c 4096"

if not os.getenv("KONG_BUSTED_RESPAWNED") then
-- initial run, so go update the environment
local script = {}
for line in io.popen("set"):lines() do
local ktvar, val = line:match("^KONG_TEST_([^=]*)=(.*)")
if ktvar then
-- reinserted KONG_TEST_xxx as KONG_xxx; append
table.insert(script, "export KONG_" .. ktvar .. "=" ..val)
end

local var = line:match("^(KONG_[^=]*)")
local var_for_spec = line:match("^(KONG_SPEC_[^=]*)")
if var and not var_for_spec then
-- remove existing KONG_xxx and KONG_TEST_xxx variables; prepend
table.insert(script, 1, "unset " .. var)
end
end
-- add cli recursion detection
table.insert(script, "export KONG_BUSTED_RESPAWNED=1")

-- rebuild the invoked commandline, while inserting extra resty-flags
local resty_flags = DEFAULT_RESTY_FLAGS
local cmd = { "exec" }
for i = -1, #arg do
if arg[i]:sub(1, 12) == "RESTY_FLAGS=" then
resty_flags = arg[i]:sub(13, -1)

else
table.insert(cmd, "'" .. arg[i] .. "'")
end
end

if resty_flags then
table.insert(cmd, 3, resty_flags)
end

table.insert(script, table.concat(cmd, " "))

-- recurse cli command, with proper variables (un)set for clean testing
local _, _, rc = os.execute(table.concat(script, "; "))
os.exit(rc)
end

setmetatable(_G, nil)

pcall(require, "luarocks.loader")

require("kong.globalpatches")({
cli = true,
rbusted = true
})

-- Busted command-line runner
require 'busted.runner'({ standalone = false })
9 changes: 9 additions & 0 deletions kong-versions/3.0.2/kong/bin/kong
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env resty

setmetatable(_G, nil)

pcall(require, "luarocks.loader")

package.path = (os.getenv("KONG_LUA_PATH_OVERRIDE") or "") .. "./?.lua;./?/init.lua;" .. package.path

require("kong.cmd.init")(arg)
31 changes: 31 additions & 0 deletions kong-versions/3.0.2/kong/spec/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Test helpers for Kong (integration) tests
=========================================

To generate the documentation run the following command in the Kong source tree:

```
# install ldoc using LuaRocks
luarocks install ldoc
# generate and open the docs
cd spec && ldoc . && open docs/index.html && cd ..
```

## Environment variables

When testing, Kong will ignore the `KONG_xxx` environment variables that are
usually used to configure it. This is to make sure that the tests run deterministically.
If this behaviour needs to be overridden, the `KONG_TEST_xxx`
version of the variable can be used, which will be respected by the Kong test
instance.

To prevent the test helpers from cleaning the Kong working directory, the
variable `KONG_TEST_DONT_CLEAN` can be set.
This comes in handy when inspecting the logs after the tests complete.

When testing with Redis, the environment variable `KONG_SPEC_REDIS_HOST` can be
used to specify where the Redis server can be found. If not specified, it will default
to `127.0.0.1`. This setting is available to tests via `helpers.redis_host`.

The configuration file to be used can be set with `KONG_SPEC_TEST_CONF_PATH`. It can be
accessed via helpers as `helpers.test_conf_path`.
11 changes: 11 additions & 0 deletions kong-versions/3.0.2/kong/spec/config.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
project='Kong test helpers'
title='Kong test framework'
description='Test helper functions for Kong (integration) testing'
format='markdown'
file='./helpers.lua'
dir='docs'
readme='README.md'
sort=true
sort_modules=true
style='./'
no_space_before_args=true
Loading

0 comments on commit 9ac335e

Please sign in to comment.