Created
September 17, 2024 15:42
-
-
Save moio/20a43fa406432cec5fc8aee0394d3e1f to your computer and use it in GitHub Desktop.
Benchmark Steve list API while resources are being changed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
# Global variables | |
KUBECONFIG="../tofu/main/k3d/config/upstream.yaml" | |
CONTEXT="k3d-st-upstream" | |
KUBERNETES_BASE_URL="https://localhost:6445" | |
STEVE_BASE_URL="https://localhost:8444" | |
USERNAME="admin" | |
PASSWORD="adminadminadmin" | |
CONFIGMAPS=(1 1000 3000 6000) | |
CHANGES_PER_SECOND=(0 100 200 400) | |
rm -f prepare_config_maps.log | |
rm -f change_config_maps.log | |
rm -f api_benchmark.log | |
echo "base_config_maps,config_map_changes_per_vu_per_second,p(95)" | |
# Iterate over configmaps | |
for cm in "${CONFIGMAPS[@]}"; do | |
# Prepare a set of configmaps which will not change | |
k6 run -e KUBECONFIG=$KUBECONFIG -e CONTEXT=$CONTEXT -e BASE_URL=$KUBERNETES_BASE_URL -e CONFIG_MAP_COUNT=$cm -e SECRET_COUNT=10 create_k8s_resources.js 2>&1 >> prepare_config_maps.log | |
# Iterate over changes per second | |
for cps in "${CHANGES_PER_SECOND[@]}"; do | |
# Run change_config_maps.js in the background | |
if [[ $cps -gt 0 ]]; then | |
k6 run -e KUBECONFIG=$KUBECONFIG -e CONTEXT=$CONTEXT -e BASE_URL=$KUBERNETES_BASE_URL -e RATE=$cps -e VUS=100 change_config_maps.js 2>&1 >> change_config_maps.log & | |
change_pid=$! | |
sleep 10 | |
fi | |
# Run load_test in the foreground | |
k6_output=$(k6 run -e BASE_URL=https://localhost:8444 -e USERNAME=admin -e PASSWORD=adminadminadmin -e RESOURCE=configmaps -e PER_VU_ITERATIONS=500 -e PAGINATION_STYLE=steve -e FIRST_PAGE_ONLY=true api_benchmark.js 2>&1 | tee -a api_benchmark.log) | |
# extract http_req_duration's p(95) value | |
p95_value=$(echo "$k6_output" | grep "http_req_duration" | awk '{for(i=1;i<=NF;i++) if ($i ~ /^p\(95\)=/) print $i}' | cut -d'=' -f2) | |
echo "$cm,$cps,$p95_value" | |
# Kill the background change_configmaps process | |
if [[ $cps -gt 0 ]]; then | |
kill $change_pid 2>/dev/null || true | |
fi | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment