From 9b5bb1b07ab974fd608db97d03829032165113ac Mon Sep 17 00:00:00 2001 From: Vlad Stan Date: Thu, 28 Mar 2024 11:22:39 +0200 Subject: [PATCH] [test] add jmeter tests to install and enable all vetted extensions (#2371) * test: initial commit * feat: allow excluding of certain releases * test: activate and enable * fix: title indexes * chore: remove disabled element * test: skip `cashu` too many DB errors * chore: improve logs * chore: test logs * chore: logs * fix: condition * fix: condition harder * test: disable some listeners * fix: remove hanging element * fix: multiple reports with: `-m 1, --max-count, stop reading a file after 1 matching line` * chore: test that github actions still detect failures * Revert "chore: test that github actions still detect failures" This reverts commit a6769c5fd18824a05a3b6d215e32a9ba0ebf3323. --- .github/workflows/jmeter.yml | 11 +- integration/extensions-enable-all.jmx | 947 ++++++++++++++++++++++++++ 2 files changed, 954 insertions(+), 4 deletions(-) create mode 100644 integration/extensions-enable-all.jmx diff --git a/.github/workflows/jmeter.yml b/.github/workflows/jmeter.yml index b14e56046..2373589c6 100644 --- a/.github/workflows/jmeter.yml +++ b/.github/workflows/jmeter.yml @@ -65,13 +65,16 @@ jobs: echo "Running test with $file" filename=$(basename "$file" ".jmx") $GITHUB_WORKSPACE/apache-jmeter-5.6.2/bin/jmeter -n -t $file -l logs/$filename.log -e -o reports ; - error_count=$(cat jmeter.log | grep "summary =" | awk '{print $19}') - echo "Error count: $error_count" - if [[ "$error_count" == "0" ]]; then + error_count=$(cat jmeter.log | grep -m 1 "summary =" | awk '{print $19}') + echo "Error count: '$error_count'" + echo "##########" + echo "$error_count" == "0" + echo "###########$error_count ###########" + if [ "$error_count" = "0" ]; then echo "Test $filename OK." rm -r reports/* else - echo "Test $filename failed. Error count: $error_count." + echo "Test $filename failed. Error count: '$error_count'." exit 1 fi done diff --git a/integration/extensions-enable-all.jmx b/integration/extensions-enable-all.jmx new file mode 100644 index 000000000..ab841a865 --- /dev/null +++ b/integration/extensions-enable-all.jmx @@ -0,0 +1,947 @@ + + + + + false + false + + + + + + + + + + + host + ${__property(host,,127.0.0.1)} + = + + + scheme + ${__property(scheme,,http)} + = + + + port + ${__property(port,,5000)} + = + + + excludedExtensions + discordbot,cashu + Comma separated values, no spaces. + = + + + + + + + + + ${host} + ${port} + ${scheme} + + + 6 + Java + 20000 + 30000 + + + + + + + + stopthread + + false + 1 + + 1 + 1 + 1370726934000 + 1370726934000 + false + + + false + + + + + false + false + + + + false + true + + + + fragments/init-server.jmx + + + + + true + + + + false + {"username":"admin","password":"admin_password"} + = + + + + ${host} + ${port} + ${scheme} + UTF-8 + /api/v1/auth + POST + true + false + true + false + + + + + + + + + Referer + ${scheme}://${host}:${port}/ + + + Accept-Language + en-US,en;q=0.5 + + + Origin + ${scheme}://${host}:${port} + + + Content-Type + application/json + + + Accept-Encoding + gzip, deflate + + + User-Agent + Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:123.0) Gecko/20100101 Firefox/123.0 + + + Accept + application/json, text/plain, */* + + + + + + + 200 + + + Assertion.response_code + false + 8 + + + + + + + + raw.githubusercontent.com + "" + https + + /lnbits/lnbits-extensions/main/extensions.json + GET + true + false + true + false + + + + + + + + 200 + + + Assertion.response_code + false + 8 + + + + javascript + + + true + var resp = JSON.parse(prev.getResponseDataAsString()); +var excludedExtensions = (vars.get("excludedExtensions") || "").split(","); + +var extensions = {}; + +for (var i = 0; i < resp.extensions.length; i++) { + var ext = resp.extensions[i]; + if (excludedExtensions.indexOf(ext.id) === -1) { + extensions[ext.id] = true; + } +} + +extensionList = Object.keys(extensions); +vars.put("extensions", extensionList); +vars.put("extensionsLength", extensionList.length); + + + + + + false + true + false + + + + true + ${extensionsLength} + + + + 1 + ${extensionsLength} + 1 + extensionIndex + + true + + + + javascript + + + true + var extensions = vars.get("extensions") +var extensionIndex = vars.get("extensionIndex") + +vars.put("extension", extensions.split(",")[extensionIndex - 1]) + + + + + false + true + by admin + + + + + + + ${host} + ${port} + ${scheme} + utf-8 + /api/v1/extension/${extension}/releases + GET + true + false + true + false + + + + + + + + + Sec-Fetch-Mode + same-origin + + + Sec-Fetch-Site + same-origin + + + Accept-Language + en-US,en;q=0. + + + Upgrade-Insecure-Requests + 1 + + + Accept-Encoding + gzip, deflate, br + + + User-Agent + Mozilla.0 (Macintosh; Intel Mac OS X 10.15; rv:106.0) Gecko/20100101 Firefox/106.0 + + + Accept + text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8 + + + Sec-Fetch-Dest + empty + + + X-Api-Key + ${adminWalletKey} + + + + + + + 200 + + + Assertion.response_code + false + 8 + + + + + true + + + + false + { + "ext_id": "${ext_id}", + "archive": "${archive}", + "source_repo": "${source_repo}", + "version": "${version}" +} + = + + + + ${host} + ${port} + ${scheme} + UTF-8 + /api/v1/extension + POST + true + false + true + false + + + + + + + + + Sec-Fetch-Mode + cors + + + Sec-Fetch-Site + same-origin + + + Accept-Language + en-US,en;q=0.${lnurlpCount} + + + Origin + ${scheme}://${host}:${port} + + + Accept + application/json, text/plain, */* + + + X-Api-Key + ${adminkey} + + + Content-Type + application/json + + + Accept-Encoding + gzip, deflate, br + + + User-Agent + Mozilla/${lnurlpCount}.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/118.0 + + + Sec-Fetch-Dest + empty + + + + + + + 200 + + + Assertion.response_code + false + 8 + + + + javascript + + + true + var resp = JSON.parse(prev.getResponseDataAsString()) +var latestRelease = resp[resp.length - 1] + +var ext_id = vars.get("extension") + +vars.put("ext_id", ext_id) +vars.put("archive", latestRelease.archive) +vars.put("source_repo", latestRelease.source_repo) +vars.put("version", latestRelease.version) + + + + + + + + + false + ${extension} + = + true + activate + + + + ${host} + ${port} + ${scheme} + utf-8 + extensions + GET + true + false + true + false + + + + + + + + + Sec-Fetch-Mode + same-origin + + + Sec-Fetch-Site + same-origin + + + Accept-Language + en-US,en;q=0. + + + Upgrade-Insecure-Requests + 1 + + + Accept-Encoding + gzip, deflate, br + + + User-Agent + Mozilla.0 (Macintosh; Intel Mac OS X 10.15; rv:106.0) Gecko/20100101 Firefox/106.0 + + + Accept + text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8 + + + Sec-Fetch-Dest + empty + + + X-Api-Key + ${adminWalletKey} + + + + + + + 200 + + + Assertion.response_code + false + 8 + + + + + + false + true + + + + + + + false + enable + ${extension} + = + true + + + + ${host} + ${port} + ${scheme} + utf-8 + /extensions + GET + true + false + true + false + + + + + + + + + Sec-Fetch-Mode + same-origin + + + Sec-Fetch-Site + same-origin + + + Accept-Language + en-US,en;q=0.${paidChargeCount} + + + Upgrade-Insecure-Requests + 1 + + + Accept-Encoding + gzip, deflate, br + + + User-Agent + Mozilla/${paidChargeCount}.0 (Macintosh; Intel Mac OS X 10.15; rv:106.0) Gecko/20100101 Firefox/106.0 + + + Accept + text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8 + + + Sec-Fetch-Dest + empty + + + + + + + 200 + + + Assertion.response_code + false + 8 + + + + 3000 + for the callback to be invoked + + + + + + + + ${host} + ${port} + ${scheme} + UTF-8 + /${extension} + GET + true + false + true + false + + + + + + + + + Sec-Fetch-Mode + same-origin + + + Referer + ${scheme}://${host}:${port}/tpos/ + + + Sec-Fetch-Site + same-origin + + + Accept-Language + en-US,en;q=0.${lnurlpCount} + + + Upgrade-Insecure-Requests + 1 + + + Accept-Encoding + gzip, deflate, br + + + User-Agent + Mozilla/${lnurlpCount}.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/118.0 + + + Accept + text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8 + + + Sec-Fetch-Dest + empty + + + + + + + 200 + + + Assertion.response_code + false + 8 + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + 100 + true + (wallet){1} + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + + 8888 + + windowsupdate\.microsoft\.com.* + (?i).*\.(bmp|css|js|gif|ico|jpe?g|png|swf|eot|otf|ttf|mp4|woff|woff2) + .*msg\.yahoo\.com.* + www\.download\.windowsupdate\.com.* + toolbarqueries\.google\..* + http?://self-repair\.mozilla\.org.* + tiles.*\.mozilla\.com.* + .*detectportal\.firefox\.com.* + us\.update\.toolbar\.yahoo\.com.* + .*\.google\.com.*/safebrowsing/.* + api\.bing\.com.* + toolbar\.google\.com.* + .*yimg\.com.* + toolbar\.msn\.com.* + (?i).*\.(bmp|css|js|gif|ico|jpe?g|png|swf|eot|otf|ttf|mp4|woff|woff2)[\?;].* + toolbar\.avg\.com/.* + www\.google-analytics\.com.* + pgq\.yahoo\.com.* + safebrowsing.*\.google\.com.* + sqm\.microsoft\.com.* + g\.msn.* + clients.*\.google.* + .*toolbar\.yahoo\.com.* + geo\.yahoo\.com.* + + + true + 4 + false + + false + true + true + false + true + + + false + + 0 + + true + UTF-8 + + + + 8081 + 0 + 25 + + + + +