Judged runs and baselines

Start the local judged stack, describe a target in a target file, judge a suite by fixed queries, accept a baseline from six runs, and run against it.

A judged run does more than time deliveries. It asks Prometheus, through Grafana, what the server did during the run, and compares the answers with a baseline you accepted earlier. This page walks the whole path: stack, target, first runs, baseline, judged run.

Before you start

  • You can run the quick start and know the scenarios.
  • For the local stack: PowerShell 7 (pwsh), Docker and the Go toolchain.
  • A clean working tree. A record made from a dirty tree can never become a baseline.
  • Run every command from the repository root. -stress-dir defaults to stress, from the working directory.

What a judged run needs

-judge refuses to start unless it has all of these:

  • -url or a target that gives one,
  • -out,
  • a Grafana (-grafana-url, or the target’s),
  • an environment name (-environment, or the target’s),
  • queries.json in -stress-dir.

The server must export its metrics to the Prometheus behind that Grafana at least every 5 s, and it must serve nobody else during the run. The run is timed so that its window holds its load and nothing else, so a second user of the target breaks the measurement.

Start the local stack

pwsh scripts/judged-stack.ps1

The script stays in the foreground. It:

  • starts PostgreSQL and the pinned grafana/otel-lgtm image with Docker Compose, project robotelos-judged, profile telemetry,
  • migrates the database and builds the data plane,
  • creates database roles with fresh random passwords,
  • writes a generated token and a target file into <temp>/robotelos-judged/ (the -Dir parameter), outside the repository, and does not print the token,
  • runs the gateway with the mock agent, with rate and connection limits switched off (the generator drives everything as one principal), and exports metrics over OTLP every 5 s,
  • prints the robotelos-load command to run in a second window.

Default ports, all on 127.0.0.1:

WhatPortVariable that changes it
PostgreSQL54339ROBOTELOS_POSTGRES_PORT
Grafana3330ROBOTELOS_GRAFANA_PORT
OTLP over HTTP4318ROBOTELOS_OTLP_HTTP_PORT
OTLP over gRPC4317ROBOTELOS_OTLP_GRPC_PORT
Gateway HTTP and WebSocket8797ROBOTELOS_JUDGED_HTTP_PORT
Gateway gRPC8798ROBOTELOS_JUDGED_GRPC_PORT

The generated target is named judged-local, with environment local, disposable: true and the Grafana of the stack. The stack needs no Grafana token.

To remove the containers, their data, the gateway process and the generated files:

pwsh scripts/judged-stack.ps1 -Stop

The target file

A target file says where a server is and which variable or file holds its token. It holds no secret. Copy stress/targets.example.yaml to ~/.robotelos/stress-targets.yaml, or name the file with -targets or ROBOTELOS_STRESS_TARGETS, and pick a target with -target NAME. The copy is not committed.

targets:
  local:
    environment: local
    url: ws://127.0.0.1:8787/v1/ws
    token-env: ROBOTELOS_LOAD_TOKEN
    disposable: true # a throwaway server: a run may leave its data there
    grafana:
      url: http://127.0.0.1:3330

  dev:
    environment: dev # dev, stg and prod are never disposable
    url: wss://gateway.dev.example.invalid:443/v1/ws
    token-env: ROBOTELOS_DEV_TOKEN
    grafana:
      url: https://grafana.dev.example.invalid
      token-file: ~/.robotelos/grafana-dev.token
KeyMeaning
environmentWhat the target is expected to be. It becomes a directory name in the baseline path.
urlThe address of the server, for the transport you give with -transport. No user, query or fragment.
token-envName of the variable that holds the bearer token.
token-filePath of a file that holds it (~/ is your home directory). Use one of token-env and token-file, not both.
disposabletrue marks a throwaway server where a run may leave its data. Refused for dev, stg and prod.
grafana.urlThe Grafana of the target.
grafana.token-env, grafana.token-fileWhere the Grafana token comes from. One of them at most.

The tool refuses unknown keys, so a token written into the file by mistake is not accepted. Without a token source the token is read from ROBOTELOS_LOAD_TOKEN, and the Grafana token from ROBOTELOS_GRAFANA_TOKEN.

Flags override the file. If you give another -url than the file’s, the token and disposable of the file are not used. The same holds for -grafana-url and the Grafana token. A token must not reach a server it was not meant for. -targets without -target exits with 2.

Without disposable: true, a record of a run against a -url is INCOMPLETE, because nothing says the run left the target clean.

Run the first judged runs

On the local stack, in a second window, from the repository root, use the command the script printed. It has this shape:

go run -buildvcs=true ./protocol/cmd/robotelos-load -judge -targets /path/to/targets.yaml -target judged-local -transport ws -suite smoke -out stress-runs

-buildvcs=true stamps the commit into the build. Without it the record has no commit, and no baseline can be accepted from it. You can also build once with go build -buildvcs=true -o robotelos-load ./protocol/cmd/robotelos-load.

Each case is timed like this:

warm-up | quiet 2E | load, at least 60 s | quiet E | next case, or the queries

E is the export interval in stress/queries.json, 15 s. A case therefore takes at least 105 s: 30 s quiet, 60 s window, 15 s quiet. The load is padded with idle time if it is shorter than 60 s, so that a rate has several exports to go by. The smoke suite has 4 cases and takes at least 7 minutes. The baseline suite has 10 cases, and its two idle cases hold their connections for 30 s in each run, so its window is longer than 60 s. All records are judged after the last case. A case with a slow timing is then run twice more, which adds at least 2 x 105 s for it.

You can also judge a single run, with the scenario flags in place of -suite. Its baseline files are named after the scenario.

At the start and end of every run the tool writes an annotation tagged robotelos-run to the Grafana, so the window shows on the dashboards. A start annotation that cannot be written stops the run. An end annotation that fails is a warning.

The queries

stress/queries.json holds five fixed queries, asked for the window of the run. A timing has a tolerance. A count has none.

QueryKindToleranceAsks for
delivery-lag-p99timing0.25p99 of the delivery lag, by transport. Not asked for idle.
request-duration-p99timing0.25p99 of the request duration, by operation.
store-operation-p99timing0.25p99 of the duration of each store operation.
store-operationscountHow many store operations the run caused.
journal-eventscountHow many events the run added to the journal.

Before a baseline exists, every run is INCOMPLETE (exit 3). That is expected.

Accept a baseline

A baseline needs at least 6 runs of one case, each a separate invocation with -judge. A suite with -runs 6 gives one record per case, not six. Run the suite six times, one invocation each, into separate directories. The loop must not stop on exit code 3:

for i in 1 2 3 4 5 6; do
  go run -buildvcs=true ./protocol/cmd/robotelos-load -judge -targets /path/to/targets.yaml -target judged-local -transport ws -suite smoke -out stress-runs/r$i || true
done

Then accept them. Every flag goes before the first directory:

go run ./protocol/cmd/robotelos-load -accept-baseline [-stress-dir DIR] stress-runs

The command reads every run.json below the directories, asks no server, groups the records by environment, suite and case, and writes <stress-dir>/baselines/<env>/<suite>/<case>.json. For each query and label set the file holds the median, minimum, maximum and the number of runs, with the query hash, the commit and the load. Review and commit these files like code. It prints one baseline written: line per file.

ExitMeaning
0The baselines are written.
1Refused, or a file could not be read or written.
2Bad arguments: no directory, a flag after a directory, or any flag other than -stress-dir.

If anything is refused, no file is written. Each refusal names the record. The common causes:

  • fewer than 6 records of a case, a duplicate run id, or another schema,
  • records of one case with different loads, commits or label sets,
  • a record without a commit, from a dirty tree, or without a load, window or queries,
  • a query that is missing, has a different hash than the current queries.json, has no value or an error, or is FAIL,
  • a run with an error, a cancel, an unusable generator, or a cleanup that was not done.

A query that was NOT_JUDGED only because there was nothing to compare with does not block. A timing that was above its limit once and was not confirmed is accepted. Its first value enters the baseline, and the command prints a note for it.

The baseline key is the environment, the suite and the case. For a single run, suite and case are both the scenario. The load is part of the baseline: scenario, its parameters, warm-up, -runs and transport. -drain and the seed are not. A run of another load is not compared.

To replace a baseline after an intended regression, delete the old file, run the six invocations again and accept those. The old baseline makes the new runs FAIL, and a FAIL run is refused.

Judge a run against the baseline

Run the same command once more, with the same suite, runs, transport and environment. Each query result is compared with its baseline:

KindLimitResult
timingbaseline max x (1 + tolerance)FAIL above the limit, else PASS
countbaseline max + (max - min)FAIL above the limit, else PASS. A count below the minimum is PASS with the reason improvement.

A constant count, where min equals max, may not grow at all. A baseline with fewer than 6 runs is not used.

A timing above its limit is not yet a FAIL. The case is run twice more as a whole, each with its own window. The timing fails only when the median of the three values is above the limit. Otherwise it is PASS with the reason “above the limit once, not confirmed” and the three values. A count is never confirmed. If a repetition fails or is cancelled, or the suite ended early, the remaining slow timings are NOT_JUDGED and the record is INCOMPLETE. They are never FAIL. The results of repetitions are in runs/repeat<k>.<n>.json of the record, not in all.txt or on stdout.

A query is NOT_JUDGED, and the record INCOMPLETE, when:

  • there is no baseline for the environment, suite and case,
  • the load of the run differs from the baseline’s,
  • queries.json changed since the baseline (its hash differs),
  • a series is in the baseline and missing from the run.

Slow a store operation on purpose

To see that a regression is found, start the stack with a deliberate delay:

pwsh scripts/judged-stack.ps1 -StoreDelay "update=250ms"

The script builds the gateway with -tags devtools and slows one store operation (view, update or create). Give runs of this stack their own output directory, stress-runs-slowed, which git ignores. Never accept a baseline from it, and never from a directory below one that holds such runs. A record does not say that its server was slowed. A release build has no code for the delay.

Known gaps

  • The commit is that of the load generator only. The tree of the server is not checked, and target.build says unknown.
  • Duplicate rows of one query and series in a hand-edited record are not refused.
  • Several baseline files are not replaced atomically. When a rename fails, the error says which were replaced.

Next steps