Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/slo-verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Verify SLO workflow

on:
pull_request:
types: [opened, reopened, synchronize, labeled]
branches: [master]
paths:
- ".github/workflows/slo*.yml"
- "slo-workload/**"

jobs:
slo:
if: contains(github.event.pull_request.labels.*.name, 'SLO')
permissions:
actions: read
contents: read
pull-requests: write
issues: write
uses: ./.github/workflows/slo.yml
with:
# Explicit SDK revisions make this examples-side PR check reproducible.
sdk_current_ref: 39325794c491cbedab1ece0c0893b17eadf5fc1e
sdk_baseline_ref: 72cf8182fe21d9c97e18f43003f7608456d73764
examples_ref: ${{ github.event.pull_request.head.sha }}
github_issue: ${{ format('{0}', github.event.pull_request.number) }}
165 changes: 165 additions & 0 deletions .github/workflows/slo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
name: SLO

on:
workflow_dispatch:
inputs:
sdk_current_ref:
description: "Current ydb-java-sdk commit, branch or tag"
required: true
sdk_baseline_ref:
description: "Baseline ydb-java-sdk commit, branch or tag"
required: true
examples_ref:
description: "Workload revision (empty uses this workflow's revision)"
required: false
github_issue:
description: "Optional issue or pull request for the report"
required: false
workflow_call:
inputs:
sdk_current_ref:
type: string
required: true
sdk_baseline_ref:
type: string
required: true
examples_ref:
type: string
required: true
github_issue:
type: string
required: false

permissions:
contents: read

jobs:
ydb-slo-action:
name: Run YDB SLO Tests (${{ matrix.workload.name }})
runs-on: large-runner-java-sdk
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
workload:
- name: java-query-kv
module: query
jar: ydb-slo-query-workload.jar
copy_libs: "true"
- name: java-jdbc-kv
module: jdbc
jar: ydb-slo-jdbc-workload.jar
copy_libs: "true"
- name: java-spring-data-jdbc-kv
module: spring-data-jdbc
jar: ydb-slo-spring-data-jdbc-workload.jar
copy_libs: "false"
- name: java-spring-data-jpa-kv
module: spring-data-jpa
jar: ydb-slo-spring-data-jpa-workload.jar
copy_libs: "false"
concurrency:
group: slo-${{ github.ref }}-${{ matrix.workload.name }}
cancel-in-progress: true
steps:
- name: Install dependencies
run: |
set -euxo pipefail
YQ_VERSION=v4.48.2
BUILDX_VERSION=0.30.1
COMPOSE_VERSION=2.40.3
sudo curl -fLo /usr/local/bin/yq \
"https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64"
sudo chmod +x /usr/local/bin/yq
sudo mkdir -p /usr/local/lib/docker/cli-plugins
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
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

- name: Checkout workload sources
uses: actions/checkout@v5
with:
repository: ydb-platform/ydb-java-examples
ref: ${{ inputs.examples_ref || github.sha }}
path: examples

- name: Checkout current SDK
uses: actions/checkout@v5
with:
repository: ydb-platform/ydb-java-sdk
ref: ${{ inputs.sdk_current_ref }}
path: build-current/ydb-java-sdk

- name: Checkout baseline SDK
uses: actions/checkout@v5
with:
repository: ydb-platform/ydb-java-sdk
ref: ${{ inputs.sdk_baseline_ref }}
path: build-baseline/ydb-java-sdk

- name: Record SDK revisions and stage shared harness
id: revisions
run: |
set -euxo pipefail
echo "current=current@$(git -C build-current/ydb-java-sdk rev-parse HEAD)" >> "$GITHUB_OUTPUT"
echo "baseline=baseline@$(git -C build-baseline/ydb-java-sdk rev-parse HEAD)" >> "$GITHUB_OUTPUT"
cp -a examples build-current/ydb-java-examples
cp -a examples build-baseline/ydb-java-examples

- name: Build current workload image
run: |
docker build --platform linux/amd64 \
--build-arg WORKLOAD_MODULE=slo-workload/${{ matrix.workload.module }} \
--build-arg WORKLOAD_JAR=${{ matrix.workload.jar }} \
--build-arg COPY_LIBS=${{ matrix.workload.copy_libs }} \
-f examples/slo-workload/docker/Dockerfile.sdk \
-t ydb-app-current build-current

- name: Build baseline workload image
run: |
docker build --platform linux/amd64 \
--build-arg WORKLOAD_MODULE=slo-workload/${{ matrix.workload.module }} \
--build-arg WORKLOAD_JAR=${{ matrix.workload.jar }} \
--build-arg COPY_LIBS=${{ matrix.workload.copy_libs }} \
-f examples/slo-workload/docker/Dockerfile.sdk \
-t ydb-app-baseline build-baseline

- name: Run SLO Tests
# Pin legacy telemetry fixes until ydb-slo-action#81 is merged.
uses: ydb-platform/ydb-slo-action/init@d66bd1e10f893e5f70d542c4430a3cffb6d6f9f8
timeout-minutes: 30
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
github_issue: ${{ inputs.github_issue }}
workload_name: ${{ matrix.workload.name }}
workload_duration: "600"
fail_on_workload_error: "true"
workload_current_ref: ${{ steps.revisions.outputs.current }}
workload_current_image: ydb-app-current
workload_current_command: --read-rps 1000 --write-rps 100
workload_baseline_ref: ${{ steps.revisions.outputs.baseline }}
workload_baseline_image: ydb-app-baseline
workload_baseline_command: --read-rps 1000 --write-rps 100
workload_type: table

publish-slo-report:
needs: ydb-slo-action
if: ${{ !cancelled() && needs.ydb-slo-action.result != 'skipped' }}
name: Publish YDB SLO Report
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
pull-requests: write
issues: write
steps:
- name: Publish YDB SLO Report
uses: ydb-platform/ydb-slo-action/report@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
github_issue: ${{ inputs.github_issue }}
github_run_id: ${{ github.run_id }}
post_comment: ${{ inputs.github_issue != '' }}
21 changes: 12 additions & 9 deletions slo-workload/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ The CI workflows in `ydb-java-sdk` and `ydb-jdbc-driver` need to test SDK/driver
code **as it is in the PR** — not whatever version is pinned in this repo's
`pom.xml`. The pattern is:

1. The component-under-test repo has the workflow file (`slo.yml` / `slo.yaml`)
and a `build-slo-image.sh` script.
1. The component-under-test repo can own a consumer workflow. This repository
also provides manual/reusable SLO CI with explicit current and baseline SDK
refs; it builds both sources independently with no current-image fallback.
2. The workflow checks out **three** trees with `actions/checkout`:
- current SDK/driver (the PR's HEAD)
- baseline SDK/driver (the merge-base commit with `master`)
Expand Down Expand Up @@ -114,10 +115,9 @@ availability still computes correctly.
test from source (mirror `jdbc/Dockerfile`), or extend `Dockerfile.sdk`
and pass `WORKLOAD_MODULE=slo-workload/<name>` from CI.
4. Register the module in `pom.xml` under the `jdk17-slo-workload` profile.
5. Wire it into the SLO workflow of the component-under-test repository
(`ydb-java-sdk/.github/workflows/slo.yml` or
`ydb-jdbc-driver/.github/workflows/slo.yaml`). This repo does **not** run
SLO CI by itself — there's no YDB cluster here.
5. Wire it into the appropriate SLO workflow. The manual/reusable workflow here
uses Action v3 with `workload_type: table`; existing component-owned
consumer workflows are separate rollout targets.

## Local sanity checks

Expand Down Expand Up @@ -147,9 +147,12 @@ pushing to CI.
Locally that's fine; in CI it would merge current and baseline series. The
action always sets it, but watch out when reproducing CI behaviour
manually.
- **Prefill failure threshold is 50%**. If half the writes during prefill
fail, the runner refuses to start the read loop — empty key-space means
meaningless read latency. Don't lower the threshold to "fix" a flaky test.
- **Any final operation failure fails the workload**, including prefill.
Recovered retries stay successful. The first terminal cause survives peer
shutdown and cleanup; successful later operations cannot erase it.
- **Each launcher owns a process-private table for its whole lifecycle.**
One owner checks a reserved control key's exact generation and payload before,
during and after load; random load reads do not assert committed-key presence.
- **`acceptUnknownOptions(false)`** on JCommander is intentional. A typo in
the ydb-slo-action `workload_*_command` input should fail loudly, not
silently fall back to defaults.
Expand Down
38 changes: 28 additions & 10 deletions slo-workload/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,38 @@ during cross-driver experiments.

## How CI uses this module

This repository only hosts the workload sources. The CI that actually runs them
lives in the repository of the component under test — for `jdbc` that is
[`ydb-jdbc-driver`](https://github.com/ydb-platform/ydb-jdbc-driver) — mirroring
how the SDK SLO workload in [`../slo`](../slo) is driven from the
`ydb-java-sdk` repository rather than from here.

The driver's workflow, via [`ydb-platform/ydb-slo-action`](https://github.com/ydb-platform/ydb-slo-action):
The [SLO workflow](../.github/workflows/slo.yml) in this repository runs the four
existing Java workloads through Action v3 with `workload_type: table`.
The metrics above, 600-second duration and 1000/100 read/write RPS remain unchanged.

For a manual run, select the examples branch and supply `sdk_current_ref` and
`sdk_baseline_ref` from `ydb-platform/ydb-java-sdk`. Both are required: the
workflow checks out and builds each SDK independently, pins the shared workload
to the version built from that checkout, and never falls back to the current
image after a baseline build failure. Reports label each SDK with its resolved
commit. `examples_ref` optionally overrides the selected workload revision;
`github_issue` optionally selects a report comment in this repository.

The same workflow supports `workflow_call`. Callers must provide all three
source refs explicitly and grant the report job's permissions. No consumer
workflow in the SDK repository is changed by this migration. Existing consumers,
including [`ydb-jdbc-driver`](https://github.com/ydb-platform/ydb-jdbc-driver),
can still build these workload sources from their own CI.

For SLO-labeled pull requests here, `slo-verify.yml` calls that reusable workflow
with two explicit pinned SDK commits and the PR's examples revision. This verifies
the same four workloads before the new manual workflow is available on the default
branch; it does not require merging the PR to test it.

A consumer workflow, via [`ydb-platform/ydb-slo-action`](https://github.com/ydb-platform/ydb-slo-action):

1. checks out the driver under test (current and baseline) and this repository
for the workload sources;
2. `ydb-platform/ydb-slo-action/init` deploys a YDB cluster (storage + database
2. builds the workload images against their respective SDK or driver sources;
3. `ydb-platform/ydb-slo-action/init` deploys a YDB cluster (storage + database
nodes), Prometheus with an OTLP receiver, and a chaos monkey, exposing the
database node IPs and the OTLP endpoint as step outputs;
3. builds the workload jar and runs it, pointing `YDB_CONNECTION_STRING` at a
database node IPs and the OTLP endpoint as step outputs,
and runs both images, pointing `YDB_CONNECTION_STRING` at a
database node and `OTEL_EXPORTER_OTLP_ENDPOINT` at the Prometheus OTLP
receiver;
4. `ydb-platform/ydb-slo-action/report` compares the current run against the
Expand Down
6 changes: 6 additions & 0 deletions slo-workload/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
</description>

<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.beust</groupId>
<artifactId>jcommander</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public final class Config {
private final int durationSeconds;
private final String otlpEndpoint;

private Config(
Config(
String connectionString,
String jdbcUrl,
String token,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ public static int run(
}

public static String tablePathFor(Config config) {
return sanitize(config.workloadName()) + "_" + sanitize(config.ref());
return sanitize(config.workloadName()) + "_" + sanitize(config.ref())
+ "_" + java.util.UUID.randomUUID().toString().replace("-", "");
}

private static void closeQuietly(AutoCloseable closeable, String name) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package tech.ydb.slo.core.kv;

import java.time.Instant;
import java.time.temporal.ChronoUnit;

/** One runner owns this key in its process-private table; load IDs start at zero. */
final class ControlRows {
private Row published;
private long generation;

void verify(KvSession session, KvWorkloadParams params) {
if (published != null) {
requireRow(session.read(published.id(), params.readTimeoutMs()), published);
}
Row next = new Row(Long.MAX_VALUE, "control/" + generation, generation + 0.25,
Instant.now().truncatedTo(ChronoUnit.MICROS), generation);
requireSuccess(session.write(next, params.writeTimeoutMs()));
published = next;
requireRow(session.read(next.id(), params.readTimeoutMs()), next);
generation++;
}

private static void requireSuccess(OpOutcome outcome) {
if (!outcome.isSuccess()) {
throw new IllegalStateException("Control operation failed: " + outcome.errorKind(), outcome.cause());
}
}

static void requireRow(OpOutcome outcome, Row expected) {
requireSuccess(outcome);
if (outcome.rows().size() != 1) {
throw new IllegalStateException("Control row cardinality: " + outcome.rows().size());
}
Row actual = outcome.rows().get(0);
if (actual.id() != expected.id() || actual.payloadHash() != expected.payloadHash()
|| !expected.payloadStr().equals(actual.payloadStr())
|| Double.compare(expected.payloadDouble(), actual.payloadDouble()) != 0
|| !expected.payloadTimestamp().equals(actual.payloadTimestamp())) {
throw new IllegalStateException("Control row mismatch at generation " + expected.payloadHash());
}
}
}
Loading
Loading