|
| 1 | +name: Performance test |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + benchmark_sizes: |
| 7 | + description: 'Comma-separated database sizes to test' |
| 8 | + required: false |
| 9 | + default: '1000,10000,100000,1000000,2000000,4000000' |
| 10 | + benchmark_users: |
| 11 | + description: 'Virtual users per Gatling run' |
| 12 | + required: false |
| 13 | + default: '100' |
| 14 | + benchmark_ramp_seconds: |
| 15 | + description: 'Ramp-up duration in seconds per Gatling run' |
| 16 | + required: false |
| 17 | + default: '30' |
| 18 | + |
| 19 | +jobs: |
| 20 | + benchmark: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + timeout-minutes: 180 |
| 23 | + |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v6 |
| 26 | + |
| 27 | + - name: Set up JDK 21 |
| 28 | + uses: actions/setup-java@v5 |
| 29 | + with: |
| 30 | + java-version: 21 |
| 31 | + distribution: temurin |
| 32 | + cache: maven |
| 33 | + |
| 34 | + - name: Set up Node.js |
| 35 | + uses: actions/setup-node@v6 |
| 36 | + with: |
| 37 | + node-version: '24.3.0' |
| 38 | + |
| 39 | + - name: Install mongosh |
| 40 | + run: | |
| 41 | + sudo apt-get update |
| 42 | + sudo apt-get install -y wget gnupg |
| 43 | + wget -qO - https://pgp.mongodb.com/server-7.0.asc | sudo gpg --dearmor -o /usr/share/keyrings/mongodb-server-7.0.gpg |
| 44 | + echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list |
| 45 | + sudo apt-get update |
| 46 | + sudo apt-get install -y mongodb-mongosh |
| 47 | +
|
| 48 | + - name: Start MongoDB and Mailpit |
| 49 | + run: docker compose up -d mongo mailpit |
| 50 | + |
| 51 | + - name: Wait for MongoDB |
| 52 | + run: | |
| 53 | + for i in $(seq 1 60); do |
| 54 | + if docker compose exec -T mongo mongosh --quiet --eval "db.adminCommand({ ping: 1 }).ok" | grep -q 1; then |
| 55 | + exit 0 |
| 56 | + fi |
| 57 | + sleep 2 |
| 58 | + done |
| 59 | + echo "MongoDB did not become ready in time" |
| 60 | + exit 1 |
| 61 | +
|
| 62 | + - name: Start backend |
| 63 | + run: | |
| 64 | + mkdir -p myconext-performance-test/target |
| 65 | + cd myconext-server |
| 66 | + nohup mvn spring-boot:run -Dspring-boot.run.profiles=dev > ../myconext-performance-test/target/backend.log 2>&1 & |
| 67 | + echo $! > ../myconext-performance-test/target/backend.pid |
| 68 | +
|
| 69 | + - name: Wait for backend |
| 70 | + run: | |
| 71 | + for i in $(seq 1 120); do |
| 72 | + if curl --silent --fail http://localhost:8081/myconext/api/swagger-ui/index.html >/dev/null; then |
| 73 | + exit 0 |
| 74 | + fi |
| 75 | + sleep 5 |
| 76 | + done |
| 77 | + echo "Backend did not become ready in time" |
| 78 | + tail -200 myconext-performance-test/target/backend.log || true |
| 79 | + exit 1 |
| 80 | +
|
| 81 | + - name: Run database growth benchmark |
| 82 | + working-directory: myconext-performance-test/src/test/scripts |
| 83 | + env: |
| 84 | + BENCHMARK_SIZES: ${{ inputs.benchmark_sizes }} |
| 85 | + BENCHMARK_USERS_PER_RUN: ${{ inputs.benchmark_users }} |
| 86 | + BENCHMARK_RAMP_SECONDS: ${{ inputs.benchmark_ramp_seconds }} |
| 87 | + run: bash ./benchmark_database_growth.sh |
| 88 | + |
| 89 | + - name: Stop backend |
| 90 | + if: always() |
| 91 | + run: | |
| 92 | + if [ -f myconext-performance-test/target/backend.pid ]; then |
| 93 | + kill $(cat myconext-performance-test/target/backend.pid) || true |
| 94 | + fi |
| 95 | +
|
| 96 | + - name: Stop Docker services |
| 97 | + if: always() |
| 98 | + run: docker compose down -v |
| 99 | + |
| 100 | + |
| 101 | + - name: Write workflow summary |
| 102 | + if: always() |
| 103 | + run: | |
| 104 | + { |
| 105 | + echo "## Database Growth Benchmark" |
| 106 | + echo |
| 107 | + echo "Artifacts uploaded: `database-growth-benchmark`" |
| 108 | + echo |
| 109 | + echo "Important files inside the artifact:" |
| 110 | + echo "- `myconext-performance-test/target/gatling/compare.html`" |
| 111 | + echo "- `myconext-performance-test/src/test/scripts/benchmark_database_growth.log`" |
| 112 | + echo "- `myconext-performance-test/target/backend.log`" |
| 113 | + echo |
| 114 | + echo "Inputs used:" |
| 115 | + echo "- sizes: `${{ inputs.benchmark_sizes }}`" |
| 116 | + echo "- benchmark users: `${{ inputs.benchmark_users }}`" |
| 117 | + echo "- ramp seconds: `${{ inputs.benchmark_ramp_seconds }}`" |
| 118 | + } >> "$GITHUB_STEP_SUMMARY" |
| 119 | +
|
| 120 | + - name: Upload benchmark artifacts |
| 121 | + if: always() |
| 122 | + uses: actions/upload-artifact@v4 |
| 123 | + with: |
| 124 | + name: database-growth-benchmark |
| 125 | + path: | |
| 126 | + myconext-performance-test/target/gatling |
| 127 | + myconext-performance-test/src/test/scripts/benchmark_database_growth.log |
| 128 | + myconext-performance-test/target/backend.log |
0 commit comments