From 514d95f170fd02357942e0f32f5c4ddb72a7a5c3 Mon Sep 17 00:00:00 2001 From: Tengu Date: Tue, 16 Dec 2025 19:26:39 +0800 Subject: [PATCH 1/2] t# This is a combination of 2 commits. Added a nginx test suit , fix some bugs and modified the file --- daemon/nginx-server | 43 +++++++++++++++++++++++++++--- programs/wrk/PKGBUILD | 36 +++++++++++++++++++++++++ programs/wrk/create_key.sh | 32 ++++++++++++++++++++++ programs/wrk/jobs/wrk.yaml | 40 ++++++++++++++++++++++++++++ programs/wrk/meta.yaml | 40 ++++++++++++++++++++++++++++ programs/wrk/nginx_4.conf | 48 +++++++++++++++++++++++++++++++++ programs/wrk/parse | 1 + programs/wrk/run | 54 ++++++++++++++++++++++++++++++++++++++ 8 files changed, 290 insertions(+), 4 deletions(-) create mode 100644 programs/wrk/PKGBUILD create mode 100644 programs/wrk/create_key.sh create mode 100644 programs/wrk/jobs/wrk.yaml create mode 100644 programs/wrk/meta.yaml create mode 100644 programs/wrk/nginx_4.conf create mode 100644 programs/wrk/parse create mode 100644 programs/wrk/run diff --git a/daemon/nginx-server b/daemon/nginx-server index f3cad9b68..9d5dbbcd0 100755 --- a/daemon/nginx-server +++ b/daemon/nginx-server @@ -1,5 +1,7 @@ #!/bin/sh # Job yaml can send below ENVIRONMENT VARIABLES to me +# - workers +# - bench_type # - nics # - nics_ips # - core_nums @@ -17,6 +19,8 @@ : "${protocol:=https}" # http or https : "${alive_type:=short}" # short or long +workers=${workers:-4} +bench_type="${bench_type:-wrk} nics=(${nics//,/ }) nics_ips=(${nics_ips//,/ }) [ -n "$BENCHMARK_ROOT" ] || BENCHMARK_ROOT=/lkp/benchmarks @@ -150,7 +154,33 @@ assign_core_ranges() fi } -main() +create_key() +{ + + chmod +x ${WRK_SRC_DIR}/create_key.sh + ${WRK_SRC_DIR}/create_key.sh + cp server_2048.crt server_2048.key $BENCHMARK_ROOT/nginx-server/ +} + +modify_conf() +{ + sed -i "s#{{WORKERS}}#${workers}#g" "${WRK_SRC_DIR}/nginx_4.conf" + sed -i "s#{{BENCHMARK_ROOT}}#${BENCHMARK_ROOT}#g" "${WRK_SRC_DIR}/nginx_4.conf" + cp "${WRK_SRC_DIR}/nginx_4.conf" $BENCHMARK_ROOT/nginx-server/ +} +} + +wrk_test() +{ + WRK_SRC_DIR="${LKP_SRC}/programs/wrk" + create_key + modify_conf + $BENCHMARK_ROOT/nginx-server/sbin/nginx \ + -c $BENCHMARK_ROOT/nginx-server/nginx_4.conf \ + -e $BENCHMARK_ROOT/nginx-server/logs/error.log +} + +main_test() { local core_ranges local nginx_path="$BENCHMARK_ROOT/nginx-server/sbin/nginx" @@ -158,9 +188,10 @@ main() check_nginx_install prepare - assign_core_ranges - + assign_core_ranges + index=0 + for core_range in $core_ranges do local nic=${nics[$index]} @@ -172,4 +203,8 @@ main() done } -main +if [[ "${bench_type}" == "wrk" ]]; then + wrk_test +elif [[ "${bench_type}" == "nginx" ]]; then + main_test +fi \ No newline at end of file diff --git a/programs/wrk/PKGBUILD b/programs/wrk/PKGBUILD new file mode 100644 index 000000000..28357f42c --- /dev/null +++ b/programs/wrk/PKGBUILD @@ -0,0 +1,36 @@ +pkgname=nginx +pkgver=1.22 +pkgrel=1 +arch=('aarch64' 'x86_64') +url="https://nginx.org/ru/" +license=('GPL') +makedepends_debian_11=(unzip tar gcc gcc-c++ make libatomic libtool zlib zlib-devel pcre pcre-devel perl-devel perl-ExtUtils-Embed openssl openssl-devel net-tools git) +source=( + "https://repo.huaweicloud.com/nginx/${pkgname}-$pkgver.$pkgrel.tar.gz" + "https://github.com/wg/wrk/archive/refs/tags/4.2.0.tar.gz") +md5sums=('8296d957561aeed0261d9be4d3decaec' 'SKIP' ) + +build() +{ + cd "$srcdir"/wrk-4.2.0 + make -j + + mkdir -p /lkp/benchmarks/${pkgname}-server/logs/ + cd "$srcdir/$pkgname-$pkgver.$pkgrel" + ./configure \ + --prefix="/lkp/benchmarks/nginx-server/" \ + --with-http_ssl_module \ + --without-http_gzip_module \ + --error-log-path="/lkp/benchmarks/nginx-server/logs/error.log" \ + --http-log-path="/lkp/benchmarks/nginx-server/logs/access.log" + make -j +} + +package() +{ + cd "$srcdir/$pkgname-$pkgver.$pkgrel" + make DESTDIR="${pkgdir}" install + + mkdir -p ${pkgdir}/lkp/benchmarks/wrk-bench/ + cp "${srcdir}"/wrk-4.2.0/wrk ${pkgdir}/lkp/benchmarks/wrk-bench/ +} \ No newline at end of file diff --git a/programs/wrk/create_key.sh b/programs/wrk/create_key.sh new file mode 100644 index 000000000..63b854c42 --- /dev/null +++ b/programs/wrk/create_key.sh @@ -0,0 +1,32 @@ +#!/usr/bin/expect +set timeout 1 +spawn openssl genrsa -des3 -out server_2048.key 2048 +expect "Enter pass phrase for server_2048.key:" +send "123456\r" +expect "Verifying - Enter pass phrase for server_2048.key:" +send "123456\r" +expect eof + +spawn openssl rsa -in server_2048.key -out server_2048.key +expect "Enter pass phrase for server_2048.key:" +send "123456\r" +expect eof + +spawn openssl req -new -key server_2048.key -out server_2048.csr +expect "Country Name (2 letter code) \[AU\]:" +send "CN\r" +send "\r" +send "\r" +send "\r" +send "\r" +send "\r" +send "\r" +send "\r" +send "\r" +expect eof + +spawn openssl rsa -in server_2048.key -out server_2048.key +expect eof + +spawn openssl x509 -req -days 365 -in server_2048.csr -signkey server_2048.key -out server_2048.crt +expect eof \ No newline at end of file diff --git a/programs/wrk/jobs/wrk.yaml b/programs/wrk/jobs/wrk.yaml new file mode 100644 index 000000000..3d8bc4ad3 --- /dev/null +++ b/programs/wrk/jobs/wrk.yaml @@ -0,0 +1,40 @@ +suite: wrk +category: benchmark +cluster: taishan200-2280-2s48p-256g +cluster_spec: + node: + taishan200-2280-2s48p-256g--a16: + roles: + - server + taishan200-2280-2s48p-256g--a18: + roles: + - client + +set_nic_irq_affinity: 1 + +#if role server: +daemon.nginx-server: + if-role: server + workers: + - 4 + bench_type: + - wrk +#if role client: +program.wrk: + if-role: client + concurrent: + - 2000 + duration: + - 60s + threads: + - 20 + protocols: + - http + - https + alive_type: + - close + - keep-alive + timeout: + - 5s + testIp: + - testip \ No newline at end of file diff --git a/programs/wrk/meta.yaml b/programs/wrk/meta.yaml new file mode 100644 index 000000000..f2d832416 --- /dev/null +++ b/programs/wrk/meta.yaml @@ -0,0 +1,40 @@ +metadata: + name: wrk + summary: . + +type: client +depends: + openeuler@22.03: + - tar + - gcc + - gcc-c++ + - make + - libtool + - zlib + - zlib-devel + - pcre + - pcre-devel + - perl + - openssl + - openssl-devel + - perl-ExtUtils-Embed + - net-tools + - git + - expect + - jq + PKGBUILD: + - wrk + +params: + workers: + bench_type: + concurrent: + duration: + threads: + protocols: + alive_type: + layency: + timeout: + +results: + diff --git a/programs/wrk/nginx_4.conf b/programs/wrk/nginx_4.conf new file mode 100644 index 000000000..22f7b5915 --- /dev/null +++ b/programs/wrk/nginx_4.conf @@ -0,0 +1,48 @@ +user root; +worker_processes {{WORKERS}}; +worker_cpu_affinity auto; +worker_rlimit_nofile 1024000; +events { + use epoll; + worker_connections 32768; + accept_mutex off; + multi_accept off; +} +http{ + include {{BENCHMARK_ROOT}}/nginx-server/conf/mime.types; + default_type application/octet-stream; + access_log off; + sendfile on; + tcp_nopush on; + keepalive_timeout 65; + + open_file_cache max=102400 inactive=40s; + open_file_cache_valid 50s; + open_file_cache_min_uses 1; + open_file_cache_errors on; + server { + listen 10000; + location / { + root {{BENCHMARK_ROOT}}/nginx-server/html; + index index.html index.gtm; + } + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root htmls; + } + } + server { + listen 20000 ssl; + server_name localhost; + ssl_certificate {{BENCHMARK_ROOT}}/nginx-server/server_2048.crt; + ssl_certificate_key {{BENCHMARK_ROOT}}/nginx-server/server_2048.key; + ssl_session_cache shared:SSL:1m; + ssl_session_timeout 5m; + ssl_ciphers HIGH:!aNULL:!MD5; + ssl_prefer_server_ciphers on; + location / { + root {{BENCHMARK_ROOT}}/nginx-server/html; + index index.html index.htm; + } + } +} \ No newline at end of file diff --git a/programs/wrk/parse b/programs/wrk/parse new file mode 100644 index 000000000..49ffd26f7 --- /dev/null +++ b/programs/wrk/parse @@ -0,0 +1 @@ +#!/usr/bin/env ruby diff --git a/programs/wrk/run b/programs/wrk/run new file mode 100644 index 000000000..21f5bd436 --- /dev/null +++ b/programs/wrk/run @@ -0,0 +1,54 @@ +#!/bin/sh +# Job yaml can send below ENVIRONMENT VARIABLES to me +# concurrent: +# duration: +# threads: +# protocols: +# alive_type: +# timeout: +# testIp: +# . "$LKP_SRC"/lib/reproduce-log.sh +# . "$LKP_SRC"/lib/numactl.sh + +concurrent=${concurrent:-"2000"} +duration=${duration:-"60s"} +threads=${threads:-"20"} +timeout=${timeout:-"5s"} + +ulimit -n 2048 + +handle_data() +{ + echo http_short + cat http_close.log|grep Requests/sec | awk -F ' ' {'print'} + echo http_long + cat http_keep-alive.log|grep Requests/sec | awk -F ' ' {'print'} + echo https_short + cat https_close.log|grep Requests/sec | awk -F ' ' {'print'} + echo https_long + cat https_keep-alive.log|grep Requests/sec | awk -F ' ' {'print'} +} + +[ -n "$direct_ips" ] && server_ip=${direct_ips} + +for i in `seq 1 3`; do + echo "The ${i}-th iteration test" + for protocol in ${protocols[@]};do + for alive in ${alive_type[@]};do + if [ "$protocol" = "http" ]; then + PORT=10000 + elif [ "$protocol" = "https" ]; then + PORT=20000 + else + echo "Unsupported protocol: $protocol" + exit 1 + fi + echo 3 > /proc/sys/vm/drop_caches + sleep 5s + echo "./wrk -c ${concurrent} -d ${duration} -t ${threads} -H "Connection: ${alive}" --timeout ${timeout} ${protocol}://${server_ip}:${PORT}/index.html" + $BENCHMARK_ROOT/wrk-bench/wrk -c ${concurrent} -d ${duration} -t ${threads} -H "Connection: ${alive}" --timeout ${timeout} ${protocol}://${server_ip}:${PORT}/index.html >> ${protocol}_${alive}.log + done + done +done + +handle_data \ No newline at end of file -- Gitee From fdeb693623dbb4d1ec3196f2899ad3920735f5c1 Mon Sep 17 00:00:00 2001 From: Tengu Date: Tue, 27 Jan 2026 16:02:20 +0800 Subject: [PATCH 2/2] modify the file --- daemon/nginx-server | 6 ++---- programs/wrk/run | 32 +++++++++++++++++++------------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/daemon/nginx-server b/daemon/nginx-server index 9d5dbbcd0..7ebee02af 100755 --- a/daemon/nginx-server +++ b/daemon/nginx-server @@ -156,10 +156,8 @@ assign_core_ranges() create_key() { - - chmod +x ${WRK_SRC_DIR}/create_key.sh - ${WRK_SRC_DIR}/create_key.sh - cp server_2048.crt server_2048.key $BENCHMARK_ROOT/nginx-server/ + cd $BENCHMARK_ROOT/nginx-server/ + ${WRK_SRC_DIR}/create_key.sh } modify_conf() diff --git a/programs/wrk/run b/programs/wrk/run index 21f5bd436..f3fb7f6a0 100644 --- a/programs/wrk/run +++ b/programs/wrk/run @@ -33,20 +33,26 @@ handle_data() for i in `seq 1 3`; do echo "The ${i}-th iteration test" - for protocol in ${protocols[@]};do - for alive in ${alive_type[@]};do - if [ "$protocol" = "http" ]; then - PORT=10000 - elif [ "$protocol" = "https" ]; then - PORT=20000 - else - echo "Unsupported protocol: $protocol" - exit 1 - fi + for protocol in ${protocols[@]}; do + if [ "$protocol" = "http" ]; then + PORT=10000 + elif [ "$protocol" = "https" ]; then + PORT=20000 + else + echo "Unsupported protocol: $protocol" + exit 1 + fi + for alive in ${alive_type[@]}; do echo 3 > /proc/sys/vm/drop_caches - sleep 5s - echo "./wrk -c ${concurrent} -d ${duration} -t ${threads} -H "Connection: ${alive}" --timeout ${timeout} ${protocol}://${server_ip}:${PORT}/index.html" - $BENCHMARK_ROOT/wrk-bench/wrk -c ${concurrent} -d ${duration} -t ${threads} -H "Connection: ${alive}" --timeout ${timeout} ${protocol}://${server_ip}:${PORT}/index.html >> ${protocol}_${alive}.log + local cmd=("$BENCHMARK_ROOT/wrk-bench/wrk" + -c "${concurrent}" + -d "${duration}" + -t "${threads}" + -H "Connection: ${alive}" + --timeout "${timeout}" + "${protocol}://${server_ip}:${PORT}/index.html") + echo "Running: ${cmd[*]}" + "${cmd[@]}" done done done -- Gitee