ci: remove useless ci and tests (#11610)
diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml
deleted file mode 100644
index 3322735..0000000
--- a/.github/workflows/performance.yml
+++ /dev/null
@@ -1,65 +0,0 @@
-name: Performance Test
-
-on:
- pull_request:
- branches: [master, 'release/**']
- paths-ignore:
- - 'docs/**'
- - '**/*.md'
-
-permissions:
- contents: read
-
-jobs:
- performance:
- if: ${{ startsWith(github.event.pull_request.title, 'perf:') }}
- runs-on: ubuntu-20.04
- timeout-minutes: 45
-
- steps:
- - name: Check out code
- uses: actions/checkout@v4
- with:
- submodules: recursive
-
- - name: Cache deps
- uses: actions/cache@v4
- env:
- cache-name: cache-deps
- with:
- path: deps
- key: ${{ runner.os }}-${{ env.cache-name }}-${{ matrix.os_name }}-${{ hashFiles('apisix-master-0.rockspec') }}
-
- - name: Install Dependencies
- run: sudo ./ci/performance_test.sh install_dependencies
-
- - name: Install wrk2
- run: sudo ./ci/performance_test.sh install_wrk2
-
- - name: Install SystemTap Tools
- run: sudo ./ci/performance_test.sh install_stap_tools
-
- - name: Perf Test
- run: ./ci/performance_test.sh run_performance_test
-
- - name: Upload Performance Test Result
- uses: actions/upload-artifact@v3
- with:
- name: perf.txt
- path: |
- output/performance.txt
- retention-days: 3
-
- - name: Upload flamegrpah
- uses: actions/upload-artifact@v3
- with:
- name: flamegraph.svg
- path: |
- output/flamegraph.svg
- retention-days: 3
-
-# you can view the generated flamegraph by
-# 1. open https://github.com/apache/apisix/actions
-# 2. click the "Performance Test" button
-# 3. choose the workflows that belong to your commits
-# we need a way to have this address automatically appear in the comments of the PR running this workflow.
diff --git a/.licenserc.yaml b/.licenserc.yaml
index 6a60835..edb970d 100644
--- a/.licenserc.yaml
+++ b/.licenserc.yaml
@@ -49,7 +49,6 @@
- 't/plugin/authz-casbin'
- 't/coredns'
- 't/fuzzing/requirements.txt'
- - 't/perf/requirements.txt'
- 'autodocs/'
- 'docs/**/*.md'
- '.ignore_words'
diff --git a/ci/performance_test.sh b/ci/performance_test.sh
deleted file mode 100755
index 0ec2f1e..0000000
--- a/ci/performance_test.sh
+++ /dev/null
@@ -1,117 +0,0 @@
-#!/usr/bin/env bash
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-. ./ci/common.sh
-
-set -ex
-
-install_dependencies() {
- apt-get -y update --fix-missing
- apt-get -y install lua5.1 liblua5.1-0-dev libldap2-dev
- export_or_prefix
- export OPENRESTY_VERSION=source
- ./ci/linux-install-openresty.sh
- bash utils/install-dependencies.sh install_luarocks
- make deps
-}
-
-install_wrk2() {
- cd ..
- git clone https://github.com/giltene/wrk2
- cd wrk2 || true
- make
- ln -s $PWD/wrk /usr/bin
- cd ..
-}
-
-install_stap_tools() {
- # install ddeb source repo
- sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C8CAB6595FDFF622
-
- codename=$(lsb_release -c | awk '{print $2}')
- sudo tee /etc/apt/sources.list.d/ddebs.list << EOF
- deb http://ddebs.ubuntu.com/ ${codename} main restricted universe multiverse
- deb http://ddebs.ubuntu.com/ ${codename}-updates main restricted universe multiverse
- deb http://ddebs.ubuntu.com/ ${codename}-proposed main restricted universe multiverse
-EOF
-
- sudo apt-get update
- sudo apt-get install linux-image-$(uname -r)-dbgsym
- sudo apt install elfutils libdw-dev
- sudo apt-get install -y python3-setuptools python3-wheel
-
- # install systemtap
- cd /usr/local/
- wget -q http://sourceware.org/systemtap/ftp/releases/systemtap-4.6.tar.gz
- tar -zxf systemtap-4.6.tar.gz
- mv systemtap-4.6 systemtap
- cd systemtap
- ./configure && make all && sudo make install && stap --version
- cd ..
-
- # see https://github.com/openresty/stapxx/pull/48
- git clone https://github.com/api7/stapxx.git -b luajit-gc64
- git clone https://github.com/openresty/openresty-systemtap-toolkit.git
- git clone https://github.com/brendangregg/FlameGraph.git
-}
-
-
-run_performance_test() {
- sudo chmod -R 777 ./
- ulimit -n 10240
-
- pip3 install -r t/perf/requirements.txt --user
-
- #openresty-debug
- export OPENRESTY_PREFIX="/usr/local/openresty"
- export PATH=$OPENRESTY_PREFIX/nginx/sbin:$OPENRESTY_PREFIX/bin:$OPENRESTY_PREFIX/luajit/bin:$PATH
-
- mkdir output
- python3 ./t/perf/test_http.py >$PWD/output/performance.txt 2>&1 &
-
- sleep 1
-
- # stapxx
- export STAP_PLUS_HOME=/usr/local/stapxx
- export PATH=/usr/local/stapxx:/usr/local/stapxx/samples:$PATH
- # openresty-systemtap-toolkit
- export PATH=/usr/local/openresty-systemtap-toolkit:$PATH
- # FlameGraph
- export PATH=/usr/local/FlameGraph:$PATH
-
- sudo env PATH=$PATH /usr/local/stapxx/samples/lj-lua-stacks.sxx --arg time=30 --skip-badvars -x $(pgrep -P $(cat logs/nginx.pid) -n -f worker) > /tmp/tmp.bt
- sudo env PATH=$PATH /usr/local/openresty-systemtap-toolkit/fix-lua-bt /tmp/tmp.bt > /tmp/flame.bt
- sudo env PATH=$PATH /usr/local/FlameGraph/stackcollapse-stap.pl /tmp/flame.bt > /tmp/flame.cbt
- sudo env PATH=$PATH /usr/local/FlameGraph/flamegraph.pl /tmp/flame.cbt > $PWD/output/flamegraph.svg
-}
-
-case_opt=$1
-case $case_opt in
- (install_dependencies)
- install_dependencies
- ;;
- (install_wrk2)
- install_wrk2
- ;;
- (install_stap_tools)
- install_stap_tools
- ;;
- (run_performance_test)
- run_performance_test
- ;;
-esac
diff --git a/t/fips/jwt-auth.t b/t/fips/jwt-auth.t
deleted file mode 100644
index ec10613..0000000
--- a/t/fips/jwt-auth.t
+++ /dev/null
@@ -1,267 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-use t::APISIX 'no_plan';
-
-repeat_each(2);
-no_long_string();
-no_root_location();
-no_shuffle();
-
-add_block_preprocessor(sub {
- my ($block) = @_;
-
- if (!defined $block->request) {
- $block->set_value("request", "GET /t");
- }
-});
-
-run_tests;
-
-__DATA__
-
-=== TEST 1: create public API route (jwt-auth sign)
---- config
- location /t {
- content_by_lua_block {
- local t = require("lib.test_admin").test
- local code, body = t('/apisix/admin/routes/2',
- ngx.HTTP_PUT,
- [[{
- "plugins": {
- "public-api": {}
- },
- "uri": "/apisix/plugin/jwt/sign"
- }]]
- )
-
- if code >= 300 then
- ngx.status = code
- end
- ngx.say(body)
- }
- }
---- response_body
-passed
-
-
-
-=== TEST 2: add consumer with username and plugins with public_key, private_key(private_key numbits = 512)
---- config
- location /t {
- content_by_lua_block {
- local t = require("lib.test_admin").test
- local code, body = t('/apisix/admin/consumers',
- ngx.HTTP_PUT,
- [[{
- "username": "kerouac",
- "plugins": {
- "jwt-auth": {
- "key": "user-key-rs256",
- "algorithm": "RS256",
- "public_key": "-----BEGIN PUBLIC KEY-----\nMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKebDxlvQMGyEesAL1r1nIJBkSdqu3Hr\n7noq/0ukiZqVQLSJPMOv0oxQSutvvK3hoibwGakDOza+xRITB7cs2cECAwEAAQ==\n-----END PUBLIC KEY-----",
- "private_key": "-----BEGIN RSA PRIVATE KEY-----\nMIIBOgIBAAJBAKebDxlvQMGyEesAL1r1nIJBkSdqu3Hr7noq/0ukiZqVQLSJPMOv\n0oxQSutvvK3hoibwGakDOza+xRITB7cs2cECAwEAAQJAYPWh6YvjwWobVYC45Hz7\n+pqlt1DWeVQMlN407HSWKjdH548ady46xiQuZ5Cfx3YyCcnsfVWaQNbC+jFbY4YL\nwQIhANfASwz8+2sKg1xtvzyaChX5S5XaQTB+azFImBJumixZAiEAxt93Td6JH1RF\nIeQmD/K+DClZMqSrliUzUqJnCPCzy6kCIAekDsRh/UF4ONjAJkKuLedDUfL3rNFb\n2M4BBSm58wnZAiEAwYLMOg8h6kQ7iMDRcI9I8diCHM8yz0SfbfbsvzxIFxECICXs\nYvIufaZvBa8f+E/9CANlVhm5wKAyM8N8GJsiCyEG\n-----END RSA PRIVATE KEY-----"
- }
- }
- }]]
- )
-
- if code >= 300 then
- ngx.status = code
- end
- ngx.say(body)
- }
- }
---- response_body
-passed
-
-
-
-=== TEST 3: JWT sign and verify use RS256 algorithm(private_key numbits = 512)
---- config
- location /t {
- content_by_lua_block {
- local t = require("lib.test_admin").test
- local code, body = t('/apisix/admin/routes/1',
- ngx.HTTP_PUT,
- [[{
- "plugins": {
- "jwt-auth": {}
- },
- "upstream": {
- "nodes": {
- "127.0.0.1:1980": 1
- },
- "type": "roundrobin"
- },
- "uri": "/hello"
- }]]
- )
-
- if code >= 300 then
- ngx.status = code
- end
- ngx.say(body)
- }
- }
---- response_body
-passed
-
-
-
-=== TEST 4: sign/verify use RS256 algorithm(private_key numbits = 512)
---- config
- location /t {
- content_by_lua_block {
- local t = require("lib.test_admin").test
- local code, err, sign = t('/apisix/plugin/jwt/sign?key=user-key-rs256',
- ngx.HTTP_GET
- )
-
- if code > 200 then
- ngx.status = code
- ngx.say(err)
- return
- end
-
- local code, _, res = t('/hello?jwt=' .. sign,
- ngx.HTTP_GET
- )
-
- ngx.status = code
- }
- }
---- error_code: 401
---- error_log
-JWT token invalid: invalid jwt string
-
-
-
-=== TEST 5: add consumer with username and plugins with public_key, private_key(private_key numbits = 1024)
---- config
- location /t {
- content_by_lua_block {
- local t = require("lib.test_admin").test
- local code, body = t('/apisix/admin/consumers',
- ngx.HTTP_PUT,
- [[{
- "username": "kerouac",
- "plugins": {
- "jwt-auth": {
- "key": "user-key-rs256",
- "algorithm": "RS256",
- "public_key": "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDGxOfVe/seP5T/V8pkS5YNAPRC\n3Ffxxedi7v0pyZh/4d4p9Qx0P9wOmALwlOq4Ftgks311pxG0zL0LcTJY4ikbc3r0\nh8SM0yhj9UV1VGtuia4YakobvpM9U+kq3lyIMO9ZPRez0cP3AJIYCt5yf8E7bNYJ\njbJNjl8WxvM1tDHqVQIDAQAB\n-----END PUBLIC KEY-----",
- ]] .. [[
- "private_key": "-----BEGIN RSA PRIVATE KEY-----\nMIICXQIBAAKBgQDGxOfVe/seP5T/V8pkS5YNAPRC3Ffxxedi7v0pyZh/4d4p9Qx0\nP9wOmALwlOq4Ftgks311pxG0zL0LcTJY4ikbc3r0h8SM0yhj9UV1VGtuia4Yakob\nvpM9U+kq3lyIMO9ZPRez0cP3AJIYCt5yf8E7bNYJjbJNjl8WxvM1tDHqVQIDAQAB\nAoGAYFy9eAXvLC7u8QuClzT9vbgksvVXvWKQVqo+GbAeOoEpz3V5YDJFYN3ZLwFC\n+ZQ5nTFXNV6Veu13CMEMA4NBIa8I4r3aYzSjq7X7UEBkLDBtEUge52mYakNfXD8D\nqViHkyJqvtVnBl7jNZVqbBderQnXA0kigaeZPL3+hkYKBgECQQDmiDbUL3FBynLy\nNX6/JdAbO4g1Nl/1RsGg8svhb6vRM8WQyIQWt5EKi7yoP/9nIRXcIgdwpVO6wZRU\nDojL0oy1AkEA3LpjqXxIRzcy2ALsqKN3hoNPGAlkPyG3Mlph91mqSZ2jYpXCX9LW\nhhQdf9GmfO8jZtYhYAJqEMOJrKeZHToLIQJBAJbrJbnTNTn05ztZehh5ELxDRPBR\nIJDaOXi8emyjRsA2PGiEXLTih7l3sZIUE4fYSQ9L18MO+LmScSB2Q2fr9uECQFc7\nIh/dCgN7ARD1Nun+kEIMqrlpHMEGZgv0RDsoqG+naOaRINwVysn6MR5OkGlXaLo/\nbbkvuxMc88/T/GLciYECQQC4oUveCOic4Qs6TQfMUKKv/kJ09slbD70HkcBzA5nY\nyro4RT4z/SN6T3SD+TuWn2//I5QxiQEIbOCTySci7yuh\n-----END RSA PRIVATE KEY-----"
- }
- }
- }
- ]]
- )
- ngx.status = code
- ngx.say(body)
- }
- }
---- response_body
-passed
-
-
-
-=== TEST 6: JWT sign and verify use RS256 algorithm(private_key numbits = 1024)
---- config
- location /t {
- content_by_lua_block {
- local t = require("lib.test_admin").test
- local code, body = t('/apisix/admin/routes/1',
- ngx.HTTP_PUT,
- [[{
- "plugins": {
- "jwt-auth": {}
- },
- "upstream": {
- "nodes": {
- "127.0.0.1:1980": 1
- },
- "type": "roundrobin"
- },
- "uri": "/hello"
- }]]
- )
-
- if code >= 300 then
- ngx.status = code
- end
- ngx.say(body)
- }
- }
---- response_body
-passed
-
-
-
-=== TEST 7: sign/verify use RS256 algorithm(private_key numbits = 1024)
---- config
- location /t {
- content_by_lua_block {
- local t = require("lib.test_admin").test
- local code, err, sign = t('/apisix/plugin/jwt/sign?key=user-key-rs256',
- ngx.HTTP_GET
- )
-
- if code > 200 then
- ngx.status = code
- ngx.say(err)
- return
- end
-
- local code, _, res = t('/hello?jwt=' .. sign,
- ngx.HTTP_GET
- )
-
- ngx.status = code
- }
- }
---- error_code: 401
---- error_log
-JWT token invalid: invalid jwt string
-
-
-
-=== TEST 8: sign/verify use RS256 algorithm(private_key numbits = 1024,with extra payload)
---- config
- location /t {
- content_by_lua_block {
- local t = require("lib.test_admin").test
- local code, err, sign = t('/apisix/plugin/jwt/sign?key=user-key-rs256&payload=%7B%22aaa%22%3A%2211%22%2C%22bb%22%3A%22222%22%7D',
- ngx.HTTP_GET
- )
-
- if code > 200 then
- ngx.status = code
- ngx.say(err)
- return
- end
-
- local code, _, res = t('/hello?jwt=' .. sign,
- ngx.HTTP_GET
- )
-
- ngx.status = code
- }
- }
---- error_code: 401
---- error_log
-JWT token invalid: invalid jwt string
diff --git a/t/fips/openid-connect.t b/t/fips/openid-connect.t
deleted file mode 100644
index 8a23501..0000000
--- a/t/fips/openid-connect.t
+++ /dev/null
@@ -1,111 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-use t::APISIX 'no_plan';
-
-log_level('warn');
-repeat_each(1);
-no_long_string();
-no_root_location();
-no_shuffle();
-
-add_block_preprocessor(sub {
- my ($block) = @_;
-
- if ((!defined $block->error_log) && (!defined $block->no_error_log)) {
- $block->set_value("no_error_log", "[error]");
- }
-
- if (!defined $block->request) {
- $block->set_value("request", "GET /t");
- }
-});
-
-run_tests();
-
-__DATA__
-
-=== TEST 1: configure oidc plugin with small public key
---- config
- location /t {
- content_by_lua_block {
- local t = require("lib.test_admin").test
- local code, body = t('/apisix/admin/routes/1',
- ngx.HTTP_PUT,
- [[{ "plugins": {
- "openid-connect": {
- "client_id": "kbyuFDidLLm280LIwVFiazOqjO3ty8KH",
- "client_secret": "60Op4HFM0I8ajz0WdiStAbziZ-VFQttXuxixHHs2R7r7-CW8GR79l-mmLqMhc-Sa",
- "discovery": "https://samples.auth0.com/.well-known/openid-configuration",
- "redirect_uri": "https://iresty.com",
- "ssl_verify": false,
- "timeout": 10,
- "bearer_only": true,
- "scope": "apisix",
- "public_key": "-----BEGIN PUBLIC KEY-----\n]] ..
- [[MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANW16kX5SMrMa2t7F2R1w6Bk/qpjS4QQ\n]] ..
- [[hnrbED3Dpsl9JXAx90MYsIWp51hBxJSE/EPVK8WF/sjHK1xQbEuDfEECAwEAAQ==\n]] ..
- [[-----END PUBLIC KEY-----",
- "token_signing_alg_values_expected": "RS256"
- }
- },
- "upstream": {
- "nodes": {
- "127.0.0.1:1980": 1
- },
- "type": "roundrobin"
- },
- "uri": "/hello"
- }]]
- )
-
- if code >= 300 then
- ngx.status = code
- end
- ngx.say(body)
- }
- }
---- response_body
-passed
-
-
-
-=== TEST 2: hit failed
---- config
- location /t {
- content_by_lua_block {
- local http = require "resty.http"
- local httpc = http.new()
- local uri = "http://127.0.0.1:" .. ngx.var.server_port .. "/hello"
- local res, err = httpc:request_uri(uri, {
- method = "GET",
- headers = {
- ["Authorization"] = "Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9" ..
- ".eyJkYXRhMSI6IkRhdGEgMSIsImlhdCI6MTU4NTEyMjUwMiwiZXhwIjoxOTAwNjk" ..
- "4NTAyLCJhdWQiOiJodHRwOi8vbXlzb2Z0Y29ycC5pbiIsImlzcyI6Ik15c29mdCB" ..
- "jb3JwIiwic3ViIjoic29tZUB1c2VyLmNvbSJ9.u1ISx7JbuK_GFRIUqIMP175FqX" ..
- "RyF9V7y86480Q4N3jNxs3ePbc51TFtIHDrKttstU4Tub28PYVSlr-HXfjo7w",
- }
- })
- ngx.status = res.status
- if res.status == 200 then
- ngx.say(true)
- end
- }
- }
---- error_code: 401
---- error_log
-jwt signature verification failed: invalid key length
diff --git a/t/fips/ssls.t b/t/fips/ssls.t
deleted file mode 100644
index d7f0837..0000000
--- a/t/fips/ssls.t
+++ /dev/null
@@ -1,75 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-use t::APISIX 'no_plan';
-
-repeat_each(1);
-log_level('warn');
-no_root_location();
-no_shuffle();
-
-run_tests();
-
-__DATA__
-
-=== TEST 1: configure cert with smaller key
---- config
- location /t {
- content_by_lua_block {
- local t = require("lib.test_admin")
- local json = require("toolkit.json")
- local ssl_cert = t.read_file("t/certs/server_1024.crt")
- local ssl_key = t.read_file("t/certs/server_1024.key")
-
- local data = {
- upstream = {
- type = "roundrobin",
- nodes = {
- ["127.0.0.1:1980"] = 1,
- },
- },
- uri = "/hello"
- }
- assert(t.test('/apisix/admin/routes/1',
- ngx.HTTP_PUT,
- json.encode(data)
- ))
-
- local data = {
- cert = ssl_cert,
- key = ssl_key,
- sni = "localhost",
- }
- local code = t.test('/apisix/admin/ssls/1',
- ngx.HTTP_PUT,
- json.encode(data)
- )
-
- if code >= 300 then
- ngx.status = code
- end
- }
- }
---- request
-GET /t
-
-
-
-=== TEST 2: curl failed
---- exec
-curl -k https://localhost:1994/hello -H "Host: localhost"
---- error_log
-failed to set PEM cert: SSL_use_certificate() failed
diff --git a/t/perf/conf/nginx.conf b/t/perf/conf/nginx.conf
deleted file mode 100644
index 307e725..0000000
--- a/t/perf/conf/nginx.conf
+++ /dev/null
@@ -1,38 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-master_process on;
-daemon off;
-worker_processes 1;
-error_log logs/error.log error;
-pid logs/nginx.pid;
-worker_rlimit_nofile 204800;
-events {
- worker_connections 204800;
-}
-http {
- access_log off;
- server_tokens off;
- more_clear_headers Server;
-
- server {
- listen 6666 reuseport;
- location / {
- return 200;
- }
- }
-}
diff --git a/t/perf/requirements.txt b/t/perf/requirements.txt
deleted file mode 100644
index 932bd69..0000000
--- a/t/perf/requirements.txt
+++ /dev/null
@@ -1 +0,0 @@
-PyYAML==5.4.1
diff --git a/t/perf/test_http.py b/t/perf/test_http.py
deleted file mode 100755
index 36bb236..0000000
--- a/t/perf/test_http.py
+++ /dev/null
@@ -1,201 +0,0 @@
-#! /usr/bin/env python
-
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# Usage:
-# 1. pip3 install -r t/perf/requirements.txt --user
-# 2. python3 ./t/perf/test_http.py
-import http.client
-import os
-import shutil
-import subprocess
-import tempfile
-import time
-import unittest
-import yaml
-
-
-RULE_SIZE = 100
-
-
-def create_conf():
- with open("./conf/config-perf.yaml", "w") as f:
- conf = {
- "apisix": {
- "enable_admin": False,
- },
- "deployment": {
- "role": "data_plane",
- "role_data_plane": {
- "config_provider": "yaml",
- }
-
- },
- "nginx_config": {
- "worker_processes": 2
- }
- }
- yaml.dump(conf, f)
-
- routes = []
- consumers = []
- for i in range(RULE_SIZE):
- i = str(i)
- consumers.append({
- "username": "jack" + i,
- "plugins": {
- "jwt-auth": {
- "key": "user-key-" + i,
- "secret": "my-secret-key"
- }
- }
- })
- routes.append({
- "upstream_id": 1,
- "uri": "/*",
- "host": "test" + i + ".com",
- "plugins": {
- "limit-count": {
- "count": 1e8,
- "time_window": 3600,
- },
- "jwt-auth": {
- },
- "proxy-rewrite": {
- "uri": "/" + i,
- "headers": {
- "X-APISIX-Route": "apisix-" + i
- }
- },
- "response-rewrite": {
- "headers": {
- "X-APISIX-Route": "$http_x_apisix_route"
- }
- },
- },
- })
- upstreams = [{
- "id": 1,
- "nodes": {
- "127.0.0.1:6666": 1
- },
- "type": "roundrobin"
- }]
-
- # expose public api
- routes.append({
- "uri": "/gen_token",
- "plugins": {
- "public-api": {
- "uri": "/apisix/plugin/jwt/sign"
- }
- },
- })
-
- conf = {}
- conf["routes"] = routes
- conf["consumers"] = consumers
- conf["upstreams"] = upstreams
- with open("./conf/apisix-perf.yaml", "w") as f:
- yaml.dump(conf, f)
- f.write("#END\n")
-
-def apisix_executable():
- exe = "apisix"
- if os.path.exists("./bin/apisix"):
- exe = "./bin/apisix"
- return exe
-
-def start_apisix():
- os.environ["APISIX_PROFILE"] = "perf"
- create_conf()
- subprocess.run([apisix_executable(), "start"])
- time.sleep(2)
-
-def stop_apisix():
- subprocess.run([apisix_executable(), "stop"])
-
-def start_upstream(wd):
- return subprocess.Popen(["nginx", "-p", wd])
-
-def create_env():
- temp = tempfile.mkdtemp()
- print("Create test directory %s" % temp)
- shutil.copytree("t/perf/conf", os.path.join(temp, "conf"))
- os.mkdir(os.path.join(temp, "logs"))
- return temp
-
-
-class TestHTTP(unittest.TestCase):
-
- def setUp(self):
- self.duration = os.environ.get("APISIX_PERF_DURATION", "300")
- self.n_client = os.environ.get("APISIX_PERF_CLIENT", "100")
- self.n_thread = os.environ.get("APISIX_PERF_THREAD", "2")
- self.qps = os.environ.get("APISIX_PERF_QPS", "8000")
-
- start_apisix()
- tempdir = create_env()
- self.upstream = start_upstream(tempdir)
- self.tempdir = tempdir
-
- def test_perf(self):
- signs = []
- conn = http.client.HTTPConnection("127.0.0.1", port=9080)
- for i in range(RULE_SIZE):
- i = str(i)
- conn.request("GET", "/gen_token?key=user-key-" + i)
- response = conn.getresponse()
- if response.status >= 300:
- print("failed to sign, got: %s" % response.read())
- conn.close()
- return
- signs.append('"' + response.read().decode() + '"')
- conn.close()
-
- script = os.path.join(self.tempdir, "wrk.lua")
- with open(script, "w") as f:
- sign_list = ",\n".join(signs)
- s = """
- signs = {%s}
- function request()
- local i = math.random(%s) - 1
- wrk.headers["Host"] = "test" .. i .. ".com"
- wrk.headers["Authorization"] = signs[i+1]
- return wrk.format()
- end
- """ % (sign_list, RULE_SIZE)
- f.write(s)
- # We use https://github.com/giltene/wrk2
- subprocess.run(["wrk",
- "-d", self.duration,
- "-c", self.n_client,
- "-t", self.n_thread,
- "-s", script,
- "-R", self.qps,
- "--u_latency", "http://127.0.0.1:9080/12345",
- ])
-
- def tearDown(self):
- stop_apisix()
- self.upstream.terminate()
- self.upstream.wait()
-
-
-if __name__ == '__main__':
- unittest.main()