From 4d19e8d19c6dbc07eba5cf6f5ebacad95266f928 Mon Sep 17 00:00:00 2001 From: Qi Date: Sun, 23 Apr 2023 11:07:28 +0800 Subject: [PATCH] chore(build): build Kong binary for testing --- .github/workflows/lint.yml | 6 ++- .github/workflows/tests.yml | 76 ++++++++++------------------ t/005-indexed-var-openresty-suites.t | 11 ++-- t/008-log.t | 1 - 4 files changed, 34 insertions(+), 60 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f106dc0b..fff4eb8e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,6 +1,10 @@ name: Lint -on: [push, pull_request] +on: [pull_request] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true jobs: tests: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 76a60837..ce8f94f5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,53 +1,34 @@ name: Tests -on: [push, pull_request] +on: [pull_request] + +env: + KONG_VERSION: master + BUILD_ROOT: ${{ github.workspace }}/kong/bazel-bin/build + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true jobs: - tests: - name: Tests - runs-on: ubuntu-20.04 - - strategy: - matrix: - include: - # TODO: arm64 - - openresty: "1.19.3.2" - luarocks: "3.7.0" - openssl: "1.1.1k" - - openresty: "1.19.9.1" - luarocks: "3.8.0" - openssl: "1.1.1m" - - openresty: "1.21.4.1" - luarocks: "3.9.1" - openssl: "1.1.1q" - - env: - JOBS: 1 # must be 1 as socket tests interfere with each other - - INSTALL_ROOT: /home/runner/work/install-root - DOWNLOAD_ROOT: /home/runner/work/download-root - - OPENSSL_INSTALL: /home/runner/work/install-root/openssl - OPENSSL_DIR: /home/runner/work/install-root/openssl - OPENRESTY_INSTALL: /home/runner/work/install-root/openresty - LUAROCKS_INSTALL: /home/runner/work/install-root/luarocks - - BUILD_TOOLS_DOWNLOAD: /home/runner/work/download-root/kong-build-tools - BUILD_TOOLS_BRANCH: master - - OPENRESTY: ${{ matrix.openresty }} - LUAROCKS: ${{ matrix.luarocks }} - OPENSSL: ${{ matrix.openssl }} + build: + name: Build dependencies + runs-on: ubuntu-22.04 steps: - name: Checkout source code - uses: actions/checkout@v2 + uses: actions/checkout@v3 + + - name: Checkout Kong source code + uses: actions/checkout@v3 with: - submodules: 'true' + repository: kong/kong + ref: ${{ env.KONG_VERSION }} + path: kong - - name: Setup cache - uses: actions/cache@v2 + - name: Lookup build cache id: cache-deps + uses: actions/cache@v3 with: path: | ${{ env.BUILD_ROOT }} @@ -96,7 +77,7 @@ jobs: - name: Install packages run: | sudo apt update - sudo apt-get install -qq -y cpanminus net-tools libpcre3-dev build-essential valgrind + sudo apt install libyaml-dev valgrind libprotobuf-dev cpanminus net-tools libpcre3-dev build-essential - name: Install Test::Nginx run: | @@ -109,21 +90,18 @@ jobs: - name: Run Test run: | - export PATH=$OPENSSL_INSTALL/bin:$OPENRESTY_INSTALL/nginx/sbin:$OPENRESTY_INSTALL/bin:$LUAROCKS_INSTALL/bin:$PATH - export LD_LIBRARY_PATH=$OPENSSL_INSTALL/lib:$LD_LIBRARY_PATH # for openssl's CLI invoked in the test suite + source ${{ env.BUILD_ROOT }}/kong-dev-venv.sh nginx -V resty -V luarocks --version openssl version - eval `luarocks path` - prove -j$JOBS -r t + prove -r t - name: Run Test with Valgrind run: | - export PATH=$OPENSSL_INSTALL/bin:$OPENRESTY_INSTALL/nginx/sbin:$OPENRESTY_INSTALL/bin:$LUAROCKS_INSTALL/bin:$PATH - export LD_LIBRARY_PATH=$OPENSSL_INSTALL/lib:$LD_LIBRARY_PATH # for openssl's CLI invoked in the test suite + source ${{ env.BUILD_ROOT }}/kong-dev-venv.sh export TEST_NGINX_VALGRIND='--num-callers=100 -q --tool=memcheck --leak-check=full --show-possibly-lost=no --gen-suppressions=all --suppressions=valgrind.suppress --track-origins=yes' TEST_NGINX_TIMEOUT=60 TEST_NGINX_SLEEP=1 export TEST_NGINX_USE_VALGRIND=1 @@ -133,7 +111,5 @@ jobs: luarocks --version openssl version - eval `luarocks path` # fail if definite leak found - prove -j$JOBS -r t 2>&1 | tee /dev/stderr | grep -q "match-leak-kinds: definite" && exit 1 || exit 0 - + prove -r t 2>&1 | tee /dev/stderr | grep -q "match-leak-kinds: definite" && exit 1 || exit 0 diff --git a/t/005-indexed-var-openresty-suites.t b/t/005-indexed-var-openresty-suites.t index ecc8c78b..e646fe68 100644 --- a/t/005-indexed-var-openresty-suites.t +++ b/t/005-indexed-var-openresty-suites.t @@ -346,17 +346,12 @@ variable not changeable } } --- config - location =/balancer { - set $port ''; - set_by_lua_block $port { - local args, _ = ngx.req.get_uri_args() - local port = args['port'] - return port - } + location ~ /balancer/(?\d+) { + set $port $target_port; proxy_pass http://balancer; } --- pipelined_requests eval -["GET /balancer?port=8091", "GET /balancer?port=8092"] +["GET /balancer/8091", "GET /balancer/8092"] --- response_body eval ["this is backend peer 8091", "this is backend peer 8092"] diff --git a/t/008-log.t b/t/008-log.t index 586f8fd6..98bc1003 100644 --- a/t/008-log.t +++ b/t/008-log.t @@ -74,7 +74,6 @@ ok log.set_log_level(ngx.DEBUG, 2) assert(log.get_log_level(ngx.WARN) == ngx.DEBUG) - ngx.update_time() ngx.sleep(3) assert(log.get_log_level(ngx.WARN) == ngx.WARN)