Repository navigation
feat(api): idempotent test creation and an sla on flat requests - #607
Merged
Merged
Conversation
A controller that crashes between POST /api/tests and recording the run id would start a second run on restart, and only a scenario could carry an sla. The Kubernetes operator needs both. POST /api/tests takes an Idempotency-Key, stored in a unique column from the run's first INSERT, so a repeat answers 200 with the run and starts nothing. GET /api/tests?clientKey= finds the run, and /api/health lists the capability. A save that fails leaves the key free, so the retry can start the run once the fault is gone. A flat request takes a top-level sla. One beside a scenario is refused, since the scenario path would otherwise drop it and grade the run without the gate.
CodeQL flagged the cast in TopicService.createTopic once this branch's request path reached it: an int too large for a short silently wrapped into a different replication factor. Out-of-range values now fail with IllegalArgumentException, which @Retry already aborts on, and POST /topics answers 400 rather than a 500. -1 still means the broker default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A Kubernetes operator that crashes between
POST /api/testsand recording the run id would start a second run on restart: the API had no client-supplied key, andGET /api/testscould not find a run by one. A second gap: only a scenario could carry ansla, so a flat request could not be graded by the API. This is PR 1 of the operator work and stands on its own.What changed
POST /api/teststakesIdempotency-Key. The key is stored intest_runs.client_key(V29, unique) from the run's first INSERT. A repeat answers 200 with the existing run, takes no permit and writes no handler audit row. A blank key, one over 128 characters or one with a control character is a 400 withfieldErrors.GET /api/tests?clientKey=finds the run for a caller that must not create.TestRunreturnsclientKey, and/api/healthlistscapabilities: [clientKey], so a client can tell an API that honours the key.CreateTestRequesttakes a top-levelsla, threaded onto the run on the spec path.slabeside ascenariois refused with a 400: the scenario path would otherwise drop it and grade the run without the gate.WireSchemaTestpins the Jackson property names ofTestSpec,SlaDefinition,TestScenarioandScenarioPhaseto the request schema, minus a named file-only list.File.java:linesrefs undercli/cmdare re-pointed for the shifted lines. All schema mirrors are synced.Deliberately not done
docs/book/11-api-reference.mdis not updated; the header, the query parameter and the capability are documented in the OpenAPI annotations only.Known limits
Tests
Passing locally:
./mvnw verify(1,812 unit, 3 skipped; 100 ITs on Postgres, includingIdempotentCreateIT, which forces the race with a table lock),spotless:check,go test ./...,go vet ./...,golangci-lint --new-from-rev=origin/main,govulncheck,check-cli-style.sh,check-cli-compat.sh.The Maven runs used
-Dquarkus.grpc.codegen.skip=true. Native image, CodeQL, Trivy and Kind were not run locally.