Skip to content

Commit

Permalink
WIP Add python
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeASSIER committed Dec 1, 2023
1 parent 271473c commit 58440d7
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 9 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/bench.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import subprocess
import logging
import time

logging.info("💣 Launching benchmark")


def run(url: str, bombardierduration: str):
logging.info("🎯 Initalize environnment")
try:
lagging_server = subprocess.Popen(
["lagging_server", "-w", "4", "-p", "4444"], shell=True, text=True
)
sozu = subprocess.Popen(
["sozu", "start", "-c", "bench.toml"], shell=True, text=True
)

time.sleep(3)
except subprocess.CalledProcessError as e:
logging.error(f"🚨 Command failed with return code {e.returncode}")

try:
subprocess.run(["bombardier","-c","400","-d",bombardierduration,url])
except subprocess.CalledProcessError as e:
logging.error(f"🚨 Failed to run benchmark {e.returncode}")

logging.info("🪓 Destroy environment")
try:
subprocess.run(["kill", lagging_server.pid.str()], shell=True, text=True)
subprocess.run(["kill", sozu.pid.str()], shell=True, text=True)
except subprocess.CalledProcessError as e:
logging.error(f"🚨 Failed to destroy environnement {e.returncode}")


run("https://rsa-2048.sozu.io:8443/api", "2m")
run("https://rsa-4096.sozu.io:8443/api", "2m")
run("https://edcsa.sozu.io:8443/api", "2m")

20 changes: 12 additions & 8 deletions .github/workflows/bench.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
#!/bin/bash


# Start the lagging_server command in background and save its PID
nohup ./lagging_server -w 4 -p 4444 > lagging_server.log 2>&1 &
pid_lagging_server=$!

# Start the sozu command in background and save its PID
nohup ./sozu start -c bench.toml > sozu.log 2>&1 &
pid_sozu=$!

# Waiting
sleep 3
Expand All @@ -29,5 +23,15 @@ curl -vvv https://ecdsa.sozu.io:8443/api
./bombardier -c 400 -d 2m https://ecdsa.sozu.io:8443/api

# Kill the lagging_server and sozu
kill $pid_lagging_server
kill $pid_sozu


run() {
echo "Launching benchmark"
nohup ./lagging_server -w 4 -p 4444 > lagging_server.log 2>&1 &
pid_lagging_server=$!
nohup ./sozu start -c bench.toml > sozu.log 2>&1 &
pid_sozu=$!

kill $pid_lagging_server
kill $pid_sozu
}
7 changes: 6 additions & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,19 @@ jobs:
sudo cp ecdsa.pem /usr/local/share/ca-certificates/ecdsa.crt
sudo update-ca-certificates
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.12

- name: Run Benchmark
working-directory: .github/workflows
run: |
chmod +x bench.sh
chmod +x bombardier
chmod +x lagging_server
chmod +x sozu
sh bench.sh
python bench.py
- name: 📤 Upload lagging_server logs
uses: actions/upload-artifact@v3
Expand Down
File renamed without changes.

0 comments on commit 58440d7

Please sign in to comment.