run-benchmark-orly-only.sh raw

   1  #!/bin/bash
   2  
   3  # Run benchmark for ORLY only (no other relays)
   4  
   5  set -e
   6  
   7  cd "$(dirname "$0")"
   8  
   9  # Determine docker-compose command
  10  if docker compose version &> /dev/null 2>&1; then
  11      DOCKER_COMPOSE="docker compose"
  12  else
  13      DOCKER_COMPOSE="docker-compose"
  14  fi
  15  
  16  # Clean old data directories (may be owned by root from Docker)
  17  if [ -d "data" ]; then
  18      echo "Cleaning old data directories..."
  19      if ! rm -rf data/ 2>/dev/null; then
  20          echo ""
  21          echo "ERROR: Cannot remove data directories due to permission issues."
  22          echo "Please run: sudo rm -rf data/"
  23          echo "Then run this script again."
  24          exit 1
  25      fi
  26  fi
  27  
  28  # Create fresh data directories with correct permissions
  29  echo "Preparing data directories..."
  30  mkdir -p data/next-orly
  31  chmod 777 data/next-orly
  32  
  33  echo "Building ORLY container..."
  34  $DOCKER_COMPOSE build next-orly
  35  
  36  echo "Starting ORLY relay..."
  37  echo ""
  38  
  39  # Start only next-orly and benchmark-runner
  40  $DOCKER_COMPOSE up next-orly -d
  41  
  42  # Wait for ORLY to be healthy
  43  echo "Waiting for ORLY to be healthy..."
  44  for i in {1..30}; do
  45      if curl -sf http://localhost:8001/ > /dev/null 2>&1; then
  46          echo "ORLY is ready!"
  47          break
  48      fi
  49      sleep 2
  50      if [ $i -eq 30 ]; then
  51          echo "ERROR: ORLY failed to become healthy"
  52          $DOCKER_COMPOSE logs next-orly
  53          exit 1
  54      fi
  55  done
  56  
  57  # Run benchmark against ORLY
  58  echo ""
  59  echo "Running benchmark against ORLY..."
  60  echo "Target: http://localhost:8001"
  61  echo ""
  62  
  63  # Run the benchmark binary directly against the running ORLY instance
  64  docker run --rm --network benchmark_benchmark-net \
  65      -e BENCHMARK_TARGETS=next-orly:8080 \
  66      -e BENCHMARK_EVENTS=10000 \
  67      -e BENCHMARK_WORKERS=24 \
  68      -e BENCHMARK_DURATION=20s \
  69      -v "$(pwd)/reports:/reports" \
  70      benchmark-benchmark-runner \
  71      /app/benchmark-runner --output-dir=/reports
  72  
  73  echo ""
  74  echo "Benchmark complete!"
  75  echo "Stopping ORLY..."
  76  $DOCKER_COMPOSE down
  77  
  78  echo ""
  79  echo "Results saved to ./reports/"
  80  echo "Check the latest run_* directory for detailed results."
  81