diff --git a/docs/gitbook/contributing/run-the-load-tests.md b/docs/gitbook/contributing/run-the-load-tests.md index 2e0fdbc8a3..4670809184 100644 --- a/docs/gitbook/contributing/run-the-load-tests.md +++ b/docs/gitbook/contributing/run-the-load-tests.md @@ -50,7 +50,7 @@ The runner reads further settings from its environment: | `INGOT_LOADTEST_CPU_MODEL` | CPU model of the load test nodes, kept in the result record. Required with `--size`, because a Kubernetes node does not report it. | | `INGOT_LOADTEST_QUERY_URL` | Prometheus HTTP API of the metrics store, as the machine of the runner reaches it, for example `http:///prometheus`. The runner reads the maximum and its p95 of the run from it. Without it, the runner uses the query API on the host of `INGOT_LOADTEST_RW_URL`, which works when that host also resolves outside the cluster. | -With `--size`, the runner applies that reference size with requests equal to limits, and after the run it writes the result record. It reads the highest passed plateau step of the run from the metrics store, with the p95 over that step's hold. A run without a passed step writes no record. +With `--size`, the runner applies that reference size with requests equal to limits, and after the run it writes the result record. Every sample of such a run carries the tag `size` with its pod size, which the dashboard's Pod size variable filters on. A run without `--size` carries no `size` tag. The artifact size of a deploy request is tagged `artifact_size`. It reads the highest passed plateau step of the run from the metrics store, with the p95 over that step's hold. A run without a passed step writes no record. Pass `--reference` only for a published run. A reference run first counts the nodes that carry the load test label and refuses to start when there are fewer than its topology needs, with the number found and the number needed. Only a reference run pins the load generator to the labelled nodes. A run without the flag may share nodes, and its record is marked `reference: false`, so its numbers are never published. diff --git a/loadtest/runner/environment.test.ts b/loadtest/runner/environment.test.ts index 7ea6724c0a..afe6d4ae12 100644 --- a/loadtest/runner/environment.test.ts +++ b/loadtest/runner/environment.test.ts @@ -15,7 +15,14 @@ */ import assert from 'node:assert/strict'; import { test } from 'node:test'; -import { remoteWriteUrl, runnerEnvironment, scriptVariables, type RunIdentity, type RunTargets } from './environment.ts'; +import { + remoteWriteUrl, + runnerEnvironment, + scriptVariables, + type RunEnvironment, + type RunIdentity, + type RunTargets, +} from './environment.ts'; const run: RunIdentity = { testId: 'lt-abc123', @@ -130,3 +137,34 @@ test('the profile inputs are read from the runner environment, and only those', { LOADTEST_CEILING: '300', LOADTEST_ABORT_ON_FAIL: 'false' }, ); }); + +function tagsOf(environment: RunEnvironment): string[] { + return environment.arguments.flatMap((argument, index) => (argument === '--tag' ? [environment.arguments[index + 1] ?? ''] : [])); +} + +test('the runner environment tags every sample with the pod size of the run when the run has one', () => { + const tags = tagsOf(runnerEnvironment({ ...run, size: 'M' }, targets)); + + assert.deepEqual(tags, [ + 'testid=lt-abc123', + 'topology=ha', + 'scenario=resolve', + 'profile=plateau', + 'ingot_version=2.0.0', + 'size=M', + ]); +}); + +test('the runner environment omits the size tag when the run has no pod size', () => { + const tags = tagsOf(runnerEnvironment(run, targets)); + + assert.equal( + tags.some((tag) => tag.startsWith('size=')), + false, + 'a run on the chart default resources must not carry a size', + ); +}); + +test('the runner environment refuses a pod size that is not a tag value and names the tag', () => { + assert.throws(() => runnerEnvironment({ ...run, size: 'M L' }, targets), /size/); +}); diff --git a/loadtest/runner/environment.ts b/loadtest/runner/environment.ts index 5fea9a888e..f8c4dc2cf5 100644 --- a/loadtest/runner/environment.ts +++ b/loadtest/runner/environment.ts @@ -14,7 +14,7 @@ * limitations under the License. */ // The k6 environment of one run: the remote write output with native histograms, and the tags of design D8 on every -// sample. Only the values are checked here; no k6 runtime and no cluster is needed to build them. +// sample, with the pod size of the run when it has one. Only the values are checked here; no k6 runtime and no cluster is needed to build them. export interface RunIdentity { /** Generated per run, a lower case DNS label such as `lt-3k9x2a`. */ @@ -24,6 +24,8 @@ export interface RunIdentity { readonly scenario: string; /** The image tag the runner installed. */ readonly ingotVersion: string; + /** The reference pod size of the run, such as M. Absent when the run keeps the chart default resources. */ + readonly size?: string; } /** Where the run sends its samples and its requests. */ @@ -94,6 +96,7 @@ export function runnerEnvironment(run: RunIdentity, targets: RunTargets): RunEnv ['scenario', run.scenario], ['profile', run.profile], ['ingot_version', run.ingotVersion], + ...(run.size === undefined ? [] : [['size', run.size] as [string, string]]), ]; const tagArguments = tags.flatMap(([name, value]) => { if (!TAG_VALUE.test(value)) { diff --git a/loadtest/runner/main.ts b/loadtest/runner/main.ts index 339fb002d1..68c50c7be3 100644 --- a/loadtest/runner/main.ts +++ b/loadtest/runner/main.ts @@ -114,6 +114,7 @@ async function main(argv: readonly string[]): Promise { profile: options.profile, scenario: options.scenario, ingotVersion, + size: size?.name, parallelism, configMap, archiveFile, diff --git a/loadtest/runner/testrun.test.ts b/loadtest/runner/testrun.test.ts index 593803c5fb..5148a97e07 100644 --- a/loadtest/runner/testrun.test.ts +++ b/loadtest/runner/testrun.test.ts @@ -127,3 +127,11 @@ test('the test run refuses a namespace other than the load test namespace', () = test('the test run is kept after it ends, so the runner reads its stage and the uninstall removes it', () => { assert.equal('cleanup' in buildTestRun(input).spec, false); }); + +test('the test run tags its samples with the pod size when the run has one', () => { + assert.match(buildTestRun({ ...input, size: 'M' }).spec.arguments, /--tag size=M/); +}); + +test('the test run carries no size tag when the run has no pod size', () => { + assert.doesNotMatch(buildTestRun(input).spec.arguments, /--tag size=/); +}); diff --git a/loadtest/scenarios/deploy-plan.ts b/loadtest/scenarios/deploy-plan.ts index 4eaad2add3..73d85bbef0 100644 --- a/loadtest/scenarios/deploy-plan.ts +++ b/loadtest/scenarios/deploy-plan.ts @@ -28,6 +28,14 @@ export const DEPLOY_P95_MS = Math.max(...DEPLOY_SIZES.map((size) => thresholdFor /** A successful Maven deploy answers 200 OK, measured against Ingot 1.1.1. */ export const DEPLOY_EXPECTED_STATUSES: readonly number[] = [200]; +/** + * The tags of one deploy request. The artifact size has its own key: `size` is the pod size of the run, which the runner + * tags every sample with, and a request tag of the same key would replace it on the deploy samples. + */ +export function deployRequestTags(size: ArtifactSize): Record { + return { scenario: 'deploy', artifact_size: size }; +} + /** * The path of one deploy. The sequence number must be unique within a run, so that concurrent deploys never write the * same file and a release repository never refuses a redeploy. diff --git a/loadtest/scenarios/deploy.test.ts b/loadtest/scenarios/deploy.test.ts index d46285f14c..7d7e3085c9 100644 --- a/loadtest/scenarios/deploy.test.ts +++ b/loadtest/scenarios/deploy.test.ts @@ -20,7 +20,7 @@ import { fileURLToPath } from 'node:url'; import { test } from 'node:test'; import { ARTIFACT_SIZES } from '../lib/artifacts.ts'; import { thresholdFor } from '../lib/thresholds.ts'; -import { DEPLOY_EXPECTED_STATUSES, DEPLOY_P95_MS, DEPLOY_SIZES, deployPath } from './deploy-plan.ts'; +import { DEPLOY_EXPECTED_STATUSES, DEPLOY_P95_MS, DEPLOY_SIZES, deployPath, deployRequestTags } from './deploy-plan.ts'; const SCENARIO_DIRECTORY = dirname(fileURLToPath(import.meta.url)); @@ -57,3 +57,10 @@ test('the deploy script runs the profile the runner chose instead of a single it test('the deploy profile is held to the p95 limit of its largest size, which dominates the p95 of the cycle', () => { assert.equal(DEPLOY_P95_MS, thresholdFor('deploy', '200MB').p95Ms); }); + +test('the deploy requests carry the artifact size under their own key, so the pod size tag of the run is kept', () => { + const tags = deployRequestTags('1MB'); + + assert.deepEqual(tags, { scenario: 'deploy', artifact_size: '1MB' }); + assert.equal('size' in tags, false, 'size is the pod size tag of the run'); +}); diff --git a/loadtest/scenarios/deploy.ts b/loadtest/scenarios/deploy.ts index 818d33d3ca..43ec8743c3 100644 --- a/loadtest/scenarios/deploy.ts +++ b/loadtest/scenarios/deploy.ts @@ -22,7 +22,7 @@ import { ARTIFACT_SIZES, type ArtifactSize, generateArtifact } from '../lib/arti import { basicAuthHeader } from '../lib/auth.ts'; import { statusIs } from '../lib/checks.ts'; import { profileOptions } from '../profiles/options.ts'; -import { DEPLOY_EXPECTED_STATUSES, DEPLOY_P95_MS, DEPLOY_SIZES, deployPath } from './deploy-plan.ts'; +import { DEPLOY_EXPECTED_STATUSES, DEPLOY_P95_MS, DEPLOY_SIZES, deployPath, deployRequestTags } from './deploy-plan.ts'; /** The executor of the profile the runner chose, with the p95 limit of this scenario. */ export const options = profileOptions(__ENV, 'deploy', DEPLOY_P95_MS); @@ -52,7 +52,7 @@ export function deployIteration(sequence: number, size: ArtifactSize): void { const body = bodyOf(size).buffer as ArrayBuffer; const response = http.put(`${BASE_URL}${deployPath(REPOSITORY, COORDINATE, sequence)}`, body, { headers: basicAuthHeader(__ENV.LOADTEST_USER ?? '', __ENV.LOADTEST_PASSWORD ?? ''), - tags: { scenario: 'deploy', size }, + tags: deployRequestTags(size), responseCallback: http.expectedStatuses(...DEPLOY_EXPECTED_STATUSES), }); check(response, { [`deploy ${size} answered 200`]: statusIs(200) });