Skip to content

report test2json: add --launch-uuid to report into an existing launch - #43

Open
DzmitryHumianiuk wants to merge 2 commits into
feat/test2json-launch-optionsfrom
feat/test2json-launch-uuid
Open

DzmitryHumianiuk wants to merge 2 commits into
feat/test2json-launch-optionsfrom
feat/test2json-launch-uuid

Conversation

@DzmitryHumianiuk

Copy link
Copy Markdown
Member

Summary

Part of #26 (slice C3). Stacked on C2 (feat/test2json-launch-options), which is stacked on #29.

Sharded CI needs several report test2json runs to write into one launch. ReportPortal has no "join" call: an
item only names its launchUuid, and the asynchronous v2 API accepts whatever it is given. This PR adds
--launch-uuid and the two checks that make the missing server feedback visible.

Changes

  • report test2json --launch-uuid <uuid>: report into an existing launch.
    • The launch is never started and never finished by this command. On interrupt (Ctrl-C, broken input, failed log
      upload) only the items this reporter started are finished as INTERRUPTED; the launch is left alone.
    • Pre-check. Before the input is read, the launch is looked up with
      GET /api/v1/{project}/launch/uuid/{uuid}. A 404 is retried every second for up to 10 s (a launch that was
      just started by start-launch may not exist yet); after that the command fails. Any other error fails at once.
      The 10 s limit applies to the retries only, so a slow answer is not reported as "not found".
    • Time check. The command fails if the first test event is older than the launch's start time (see
      Investigation log 3: the server drops such items silently).
    • A launch that is not IN_PROGRESS gives a warning only.
  • How it combines with other flags (also in the README):
    • --print-launch-uuid: prints ReportPortal Launch UUID: <the given uuid>. No link line, because the link
      comes from the finish response and the launch is not finished here.
    • --quality-gate-check: rejected (exit 1) before anything is sent. The gate is calculated when the launch is
      finished, so the check could only time out. The message names the alternative:
      gorp quality-gate check --launch-uuid <uuid> after gorp report finish-launch.
    • --rerun, --rerun-of: rejected (exit 1).
    • --launchName, --attr, --description, --mode: ignored with a warning when set.
    • --skipped-issue=false keeps working: gorp sets "No Defect" on each skipped item itself. Only the
      skippedIssue launch attribute cannot be set.
    • Empty input is not an error.
  • pkg/gorp: ReportingClient.GetLaunchByUUID(ctx, uuid) (*LaunchInfo, error). LaunchInfo has ID, UUID,
    Name, Status, StartTime and decodes startTime both as epoch milliseconds (what 6.0.0 sends on this
    endpoint) and as RFC3339. An unknown UUID is an *HTTPError with status 404.
  • e2e: TestReportTest2JSON_TwoShardsIntoOneLaunch (start-launch, two concurrent shards, finish-launch) and
    TestReportTest2JSON_UnknownLaunchUUID.

Behaviour change

None without --launch-uuid. The flag has no environment variable on purpose (see Open questions).

Verification

  • go build ./... && go vet ./... && go vet -tags e2e ./e2e/ && go test -race ./...: ok.
  • golangci-lint@v2.15.0 run ./... and run --build-tags e2e ./e2e/...: 0 issues.
  • Unit tests (internal/commands/report_join_test.go): no launch start/finish requests and the right
    launchUuid on items; no launch finish on interrupt while items are finished INTERRUPTED; events older than
    the launch are refused and nothing is sent; flag conflicts are found before any request; 404 is retried and then
    fails; a 401 is not retried; startTime in epoch milliseconds. pkg/gorp: TestGetLaunchByUUID.
  • Live, ReportPortal 6.0.0 (demo):
    go test -tags e2e -count=1 -v -run 'Shards|UnknownLaunchUUID' ./e2e/... →
    PASS TestReportTest2JSON_TwoShardsIntoOneLaunch (4.27s), PASS TestReportTest2JSON_UnknownLaunchUUID (10.02s).
    The shard test asserts: one launch with that name, still IN_PROGRESS after both shards, 4 items (2 suites,
    2 tests) with the right parents; after finish-launch without --status the launch is FAILED with executions
    total 2, passed 1, failed 1.

Investigation log

  1. No join on the server; unknown launch is accepted on v2. service-api develop
    (src/main/java/com/epam/reportportal/base/): core/item/impl/StartTestItemHandlerImpl.java:94,119 throws
    LAUNCH_NOT_FOUND only when the queued message is processed;
    reporting/async/exception/ReportingErrorHandler.java:50,58,83-98 re-queues it up to
    reporting.retry.max-count (20) times and then sends it to the parking-lot queue. The client already got 201.
  2. Lookup endpoint: ws/controller/LaunchController.java:233 (GET /uuid/{launchId}). Live:
    unknown UUID → 404 {"errorCode":4041,"message":"Launch '…' not found. Did you use correct Launch ID?"};
    known → {"id":4,"uuid":"…","status":"IN_PROGRESS","startTime":1795818722097,…}. startTime is epoch
    milliseconds, which the generated launch model cannot decode, hence the small LaunchInfo type
    (same reason as MergedLaunch in pkg/gorp/launches.go).
  3. Items older than the launch: StartTestItemHandlerImpl.java:193-199 checks
    rq.getStartTime() against launch.getStartTime() (CHILD_START_TIME_EARLIER_THAN_PARENT). Live probe
    (scratchpad/wave/probe-c3.sh, log scratchpad/wave/live/c3-probe.log): a suite with
    startTime 2026-01-01 posted to v2 into a launch started "now" got 201 {"id":…} and never appeared in the
    launch; a suite stamped "now" did. This is the usual mistake with saved go test -json files (tests run first,
    launch started afterwards), so the command refuses it instead of reporting nothing. It also bit the first draft
    of the e2e test, whose fixtures were stamped 2026-01-01.
  4. Delay after an asynchronous launch start: in the same probe the first lookup, sent right after start-launch
    returned, already answered 200. The retry is kept because creation is queued and the delay depends on server
    load; 10 s is a guess, not a measured bound.
  5. Finished launch: the probe posted a suite into a finished launch: 201, the item appeared IN_PROGRESS, the
    launch stayed FAILED with its old endTime. Not an error on the server, so only a warning here.
  6. First e2e run failed: with the 10 s limit as a context deadline on the request, the last lookup was cut off
    and the error said context deadline exceeded instead of "not found". The limit is now a timer next to the
    ticker (findLaunchToJoin in internal/commands/report.go); requests use the caller's context.
  7. --quality-gate-check: checkQualityGateInternal (internal/commands/quality_gate.go) polls the launch
    metadata until the gate is resolved; for an unfinished launch that is the timeout. Rejecting is cheaper than
    waiting a minute for exit code 10.

Open questions

  • LAUNCH_UUID env var. The step commands and quality-gate check read --launch-uuid from LAUNCH_UUID.
    Here the flag has no env source: a pipeline that exports LAUNCH_UUID for step commands and also runs
    report test2json would silently change from "new launch" to "join". Adding the env var later is compatible;
    removing it would not be.
  • Clock skew between the machine that starts the launch and a shard can trigger the time check. The server would
    drop those items anyway; the check only makes it visible.

Not verified

  • Servers older than 6.0.0 (the lookup endpoint and the drop behaviour were read in develop and observed on the
    6.0.0 demo only).
  • The time check was verified against the server with raw requests and in unit tests, not through the CLI
    end to end.
  • Interrupt with --launch-uuid against a real server (unit test only; the non-join interrupt path has an e2e
    test in report test2json: report tests as STEPs, handle skips, send system attributes #29).

🤖 Generated with Claude Code

With --launch-uuid the results go into a launch that exists already, for
sharded CI. The launch is neither started nor finished, also not when the
command is interrupted: only the items of this reporter are finished.

The reporting API accepts items for an unknown launch UUID and for items
older than their launch, and drops them without telling the client. So
the launch is looked up first (GET /api/v1/{project}/launch/uuid/{uuid},
a 404 is retried for 10 s since launches are created asynchronously), and
the first event must not be older than the launch.

--rerun, --rerun-of and --quality-gate-check are rejected with
--launch-uuid; the flags that describe a launch to start are ignored with
a warning. pkg/gorp gets ReportingClient.GetLaunchByUUID.

Part of #26.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The launch stays open in this test, so nothing guarantees that the server
has processed the item finishes when the four items exist. On a local
ReportPortal 6.0.0 the FAILED test was still IN_PROGRESS in 5 of 5 runs.
finishedItems also waits until no item is IN_PROGRESS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DzmitryHumianiuk

Copy link
Copy Markdown
Member Author

Fix for the e2e test added here, found on a local ReportPortal 6.0.0 (same build as demo, rc/6.0.0-038258bf):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants