-
Notifications
You must be signed in to change notification settings - Fork 105
Update SLO Action #1939
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update SLO Action #1939
Changes from all commits
79cfcdc
b6dade1
4cd5a02
a6de9c3
3808da4
cf99ad6
63d7dbb
94135d4
a55d792
a4d7f90
c9fced6
17779ec
2beb0dc
5bff14a
54b778a
1592c6c
96c2402
a6ac4af
0925fae
0edcb9b
0ad25cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| name: slo | ||
| name: SLO | ||
|
|
||
| on: | ||
| push: | ||
|
|
@@ -10,26 +10,34 @@ on: | |
| - release-* | ||
| workflow_dispatch: | ||
| inputs: | ||
| github_pull_request_number: | ||
| github_issue: | ||
| description: "GitHub issue number where the SLO results will be reported" | ||
| required: true | ||
| baseline_ref: | ||
| description: "Baseline commit/branch/tag to compare against (leave empty to auto-detect merge-base with main)" | ||
| required: false | ||
| slo_workload_duration_seconds: | ||
| default: '600' | ||
| description: "Duration of the SLO workload in seconds" | ||
| required: false | ||
| default: "600" | ||
| slo_workload_read_max_rps: | ||
| default: '1000' | ||
| description: "Maximum read RPS for the SLO workload" | ||
| required: false | ||
| default: "1000" | ||
| slo_workload_write_max_rps: | ||
| default: '100' | ||
| description: "Maximum write RPS for the SLO workload" | ||
| required: false | ||
| default: "100" | ||
|
|
||
| jobs: | ||
| ydb-slo-action-init: | ||
| ydb-slo-action: | ||
| if: (!contains(github.event.pull_request.labels.*.name, 'no slo')) | ||
|
|
||
| name: Run YDB SLO Tests | ||
| runs-on: ubuntu-latest | ||
| runs-on: "large-runner" | ||
|
|
||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| sdk: | ||
| - id: database_sql_table | ||
|
|
@@ -56,85 +64,230 @@ jobs: | |
| name: native-bulk-upsert | ||
| path: ./native/bulk-upsert | ||
| label: native/bulk-upsert | ||
| - id: gorm_table | ||
| name: gorm-table | ||
| path: ./gorm/table | ||
| label: gorm/table | ||
| - id: gorm_query | ||
| name: gorm-query | ||
| path: ./gorm/query | ||
| label: gorm/query | ||
| - id: xorm_table | ||
| name: xorm-table | ||
| path: ./xorm/table | ||
| label: xorm/table | ||
| - id: xorm_query | ||
| name: xorm-query | ||
| path: ./xorm/query | ||
| label: xorm/query | ||
|
|
||
| concurrency: | ||
| group: slo-${{ github.ref }}-${{ matrix.sdk.name }} | ||
| cancel-in-progress: true | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| - name: Install dependencies | ||
| run: | | ||
| YQ_VERSION=v4.48.2 | ||
| BUILDX_VERSION=0.30.1 | ||
| COMPOSE_VERSION=2.40.3 | ||
|
|
||
| sudo curl -L https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64 -o /usr/local/bin/yq && \ | ||
| sudo chmod +x /usr/local/bin/yq | ||
|
|
||
| echo "Updating Docker plugins..." | ||
| sudo mkdir -p /usr/local/lib/docker/cli-plugins | ||
|
|
||
| echo "Installing Docker Buildx ${BUILDX_VERSION}..." | ||
| sudo curl -fLo /usr/local/lib/docker/cli-plugins/docker-buildx \ | ||
| "https://github.com/docker/buildx/releases/download/v${BUILDX_VERSION}/buildx-v${BUILDX_VERSION}.linux-amd64" | ||
| sudo chmod +x /usr/local/lib/docker/cli-plugins/docker-buildx | ||
|
|
||
| - name: Install Go | ||
| uses: actions/setup-go@v5 | ||
| echo "Installing Docker Compose ${COMPOSE_VERSION}..." | ||
| sudo curl -fLo /usr/local/lib/docker/cli-plugins/docker-compose \ | ||
| "https://github.com/docker/compose/releases/download/v${COMPOSE_VERSION}/docker-compose-linux-x86_64" | ||
| sudo chmod +x /usr/local/lib/docker/cli-plugins/docker-compose | ||
|
|
||
| echo "Installed versions:" | ||
| yq --version | ||
| docker --version | ||
| docker buildx version | ||
| docker compose version | ||
|
|
||
| - name: Checkout current version | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| go-version: 1.25.x | ||
| cache: true | ||
| path: current | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Build workload | ||
| - name: Determine baseline commit | ||
| id: baseline | ||
| run: | | ||
| cd ./tests/slo | ||
| go build -o .bin/${{matrix.sdk.id}}_linux_amd64 -ldflags "-X \"main.ref=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}\" -X \"main.label=${{matrix.sdk.label}}\" -X \"main.jobName=${{matrix.sdk.name}}\"" ${{matrix.sdk.path}} | ||
| chmod +x .bin/${{matrix.sdk.id}}_linux_amd64 | ||
| cd current | ||
| if [[ -n "${{ inputs.baseline_ref }}" ]]; then | ||
| BASELINE="${{ inputs.baseline_ref }}" | ||
| else | ||
| BASELINE=$(git merge-base HEAD origin/master) | ||
| fi | ||
| echo "sha=$BASELINE" >> $GITHUB_OUTPUT | ||
|
|
||
| # Try to determine a human-readable ref name for baseline | ||
| # Check if baseline is on master | ||
| if git merge-base --is-ancestor $BASELINE origin/master && \ | ||
| [ "$(git rev-parse origin/master)" = "$BASELINE" ]; then | ||
| BASELINE_REF="master" | ||
| else | ||
| # Try to find a branch containing this commit | ||
| BRANCH=$(git branch -r --contains $BASELINE | grep -v HEAD | head -1 | sed 's/.*\///' || echo "") | ||
| if [ -n "$BRANCH" ]; then | ||
| BASELINE_REF="${BRANCH}@${BASELINE:0:7}" | ||
| else | ||
| BASELINE_REF="${BASELINE:0:7}" | ||
| fi | ||
| fi | ||
| echo "ref=$BASELINE_REF" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Checkout baseline version | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| ref: ${{ steps.baseline.outputs.sha }} | ||
| path: baseline | ||
| fetch-depth: 1 | ||
|
|
||
| - name: Build workload images | ||
| run: | | ||
| # Build current version | ||
| if [ -f "$GITHUB_WORKSPACE/current/tests/slo/Dockerfile" ]; then | ||
| echo "Building current app image..." | ||
| cd "$GITHUB_WORKSPACE/current" | ||
| CURRENT_REF="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" | ||
| docker build -t ydb-app-current \ | ||
| --build-arg SRC_PATH=${{ matrix.sdk.label }} \ | ||
| --build-arg JOB_NAME=${{ matrix.sdk.name }} \ | ||
| --build-arg REF="${CURRENT_REF}" \ | ||
| -f tests/slo/Dockerfile . | ||
| else | ||
| echo "No current app Dockerfile found" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Build baseline version | ||
| if [ -f "$GITHUB_WORKSPACE/baseline/tests/slo/Dockerfile" ]; then | ||
| echo "Building baseline app image..." | ||
| cd "$GITHUB_WORKSPACE/baseline" | ||
|
|
||
| # Copy current versions of build infrastructure to baseline | ||
| echo "Copying current Dockerfile, go.mod, go.sum, and internal to baseline..." | ||
| cp "$GITHUB_WORKSPACE/current/tests/slo/Dockerfile" "$GITHUB_WORKSPACE/baseline/tests/slo/Dockerfile" | ||
| cp "$GITHUB_WORKSPACE/current/tests/slo/go.mod" "$GITHUB_WORKSPACE/baseline/tests/slo/go.mod" | ||
| cp "$GITHUB_WORKSPACE/current/tests/slo/go.sum" "$GITHUB_WORKSPACE/baseline/tests/slo/go.sum" | ||
| rm -rf "$GITHUB_WORKSPACE/baseline/tests/slo/internal" | ||
| cp -r "$GITHUB_WORKSPACE/current/tests/slo/internal" "$GITHUB_WORKSPACE/baseline/tests/slo/internal" | ||
|
|
||
| - name: Inititialize YDB SLO | ||
| docker build -t ydb-app-baseline \ | ||
| --build-arg SRC_PATH=${{ matrix.sdk.label }} \ | ||
| --build-arg JOB_NAME=${{ matrix.sdk.name }} \ | ||
| --build-arg REF="${{ steps.baseline.outputs.ref }}" \ | ||
| -f tests/slo/Dockerfile . | ||
| else | ||
| echo "No baseline app Dockerfile found" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Initialize YDB SLO | ||
| uses: ydb-platform/ydb-slo-action/init@main | ||
| with: | ||
| github_pull_request_number: ${{ github.event.inputs.github_pull_request_number }} | ||
| github_issue: ${{ github.event.inputs.github_issue }} | ||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
| sdk_name: ${{ matrix.sdk.name }} | ||
| ydb_database_node_count: 5 | ||
| workload_name: ${{ matrix.sdk.name }} | ||
| workload_current_ref: ${{ github.head_ref || github.ref_name }} | ||
| workload_baseline_ref: ${{ steps.baseline.outputs.ref }} | ||
|
|
||
| - name: Prepare SLO Database | ||
| run: | | ||
| ./tests/slo/.bin/${{matrix.sdk.id}}_linux_amd64 create grpc://localhost:2135 /Root/testdb | ||
| echo "Preparing SLO database..." | ||
| docker run --rm --network ydb_ydb-net \ | ||
| --add-host "ydb:172.28.0.11" \ | ||
polRk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| --add-host "ydb:172.28.0.12" \ | ||
| --add-host "ydb:172.28.0.13" \ | ||
| --add-host "ydb:172.28.0.99" \ | ||
| ydb-app-current create grpc://ydb:2136 /Root/testdb | ||
|
|
||
| - name: Run SLO Tests | ||
| - name: Run SLO Tests (parallel) | ||
| timeout-minutes: 15 | ||
| run: | | ||
| DURATION=${{ inputs.slo_workload_duration_seconds || 600 }} | ||
| READ_RPS=${{ inputs.slo_workload_read_max_rps || 1000 }} | ||
| WRITE_RPS=${{ inputs.slo_workload_write_max_rps || 1000 }} | ||
kprokopenko marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| EXTRA_ARGS="" | ||
| if [ "${{ matrix.sdk.id }}" = "native_bulk_upsert" ]; then | ||
| EXTRA_ARGS="--batch-size=10" | ||
| fi | ||
|
|
||
| ./tests/slo/.bin/${{matrix.sdk.id}}_linux_amd64 run grpc://localhost:2135 /Root/testdb \ | ||
| -prom-pgw localhost:9091 \ | ||
| ARGS="run grpc://ydb:2136 /Root/testdb \ | ||
| -otlp-endpoint prometheus:9090 \ | ||
| -report-period 250 \ | ||
| -time ${{inputs.slo_workload_duration_seconds || 600}} \ | ||
| -read-rps ${{inputs.slo_workload_read_max_rps || 1000}} \ | ||
| -write-rps ${{inputs.slo_workload_write_max_rps || 100}} \ | ||
| -read-timeout 1000 \ | ||
| -write-timeout 1000 \ | ||
| $EXTRA_ARGS | ||
| -time $DURATION \ | ||
| -read-rps $READ_RPS \ | ||
| -write-rps $WRITE_RPS \ | ||
| -read-timeout 100 \ | ||
| -write-timeout 100 \ | ||
| $EXTRA_ARGS" | ||
|
|
||
| echo "Starting ydb-app-current..." | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Хорошо бы вынести в отдельный shell файл. Проще потом будет редактировать.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Да, я думаю можно, но кода меньше не станет :) Только подсветка синтаксиса появится |
||
| docker run -d \ | ||
| --name ydb-app-current \ | ||
| --network ydb_ydb-net \ | ||
| --add-host "ydb:172.28.0.11" \ | ||
| --add-host "ydb:172.28.0.12" \ | ||
| --add-host "ydb:172.28.0.13" \ | ||
| --add-host "ydb:172.28.0.99" \ | ||
| ydb-app-current $ARGS | ||
|
|
||
| echo "Starting ydb-app-baseline..." | ||
| docker run -d \ | ||
| --name ydb-app-baseline \ | ||
| --network ydb_ydb-net \ | ||
| --add-host "ydb:172.28.0.11" \ | ||
| --add-host "ydb:172.28.0.12" \ | ||
| --add-host "ydb:172.28.0.13" \ | ||
| --add-host "ydb:172.28.0.99" \ | ||
| ydb-app-baseline $ARGS | ||
|
|
||
| # Show initial logs | ||
| echo "" | ||
| echo "==================== INITIAL CURRENT LOGS ====================" | ||
| docker logs -n 15 ydb-app-current 2>&1 || echo "No current container" | ||
| echo "" | ||
| echo "==================== INITIAL BASELINE LOGS ====================" | ||
| docker logs -n 15 ydb-app-baseline 2>&1 || echo "No baseline container" | ||
| echo "" | ||
|
|
||
| # Wait for workloads to complete | ||
| echo "Waiting for workloads to complete (${DURATION}s)..." | ||
| sleep ${DURATION} | ||
|
|
||
| # Stop containers after workload duration and wait for graceful shutdown | ||
| echo "Stopping containers after ${DURATION}s..." | ||
| docker stop --timeout=30 ydb-app-current ydb-app-baseline 2>&1 || true | ||
|
|
||
| # Force kill if still running | ||
| docker kill ydb-app-current ydb-app-baseline 2>&1 || true | ||
|
|
||
| # Check exit codes | ||
| CURRENT_EXIT=$(docker inspect ydb-app-current --format='{{.State.ExitCode}}' 2>/dev/null || echo "1") | ||
| BASELINE_EXIT=$(docker inspect ydb-app-baseline --format='{{.State.ExitCode}}' 2>/dev/null || echo "0") | ||
|
|
||
| echo "Current container exit code: $CURRENT_EXIT" | ||
| echo "Baseline container exit code: $BASELINE_EXIT" | ||
|
|
||
| # Show final logs | ||
| echo "" | ||
| echo "==================== FINAL CURRENT LOGS ====================" | ||
| docker logs -n 15 ydb-app-current 2>&1 || echo "No current container" | ||
| echo "" | ||
| echo "==================== FINAL BASELINE LOGS ====================" | ||
| docker logs -n 15 ydb-app-baseline 2>&1 || echo "No baseline container" | ||
| echo "" | ||
|
|
||
| echo "SUCCESS: Workloads completed successfully" | ||
|
|
||
| - if: always() | ||
| name: Store ydb chaos testing logs | ||
| name: Store logs | ||
| run: | | ||
| docker logs ydb-chaos > chaos-ydb.log | ||
| docker logs ydb-app-current > current.log 2>&1 || echo "No current container" | ||
| docker logs ydb-app-baseline > baseline.log 2>&1 || echo "No baseline container" | ||
|
|
||
| - if: always() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: ${{matrix.sdk.name}}-chaos-ydb.log | ||
| path: ./chaos-ydb.log | ||
| name: ${{matrix.sdk.name}}-logs | ||
| path: | | ||
| ./current.log | ||
| ./baseline.log | ||
| retention-days: 1 | ||
|
|
||
| - if: always() | ||
| name: Cleanup SLO Database | ||
| run: | | ||
| ./tests/slo/.bin/${{matrix.sdk.id}}_linux_amd64 cleanup grpc://localhost:2135 /Root/testdb || true | ||
Uh oh!
There was an error while loading. Please reload this page.