Skip to content

Add rerun, retry, parameters, issue type and finish flags to the atomic report commands - #41

Open
DzmitryHumianiuk wants to merge 1 commit into
masterfrom
feat/report-steps-flags
Open

DzmitryHumianiuk wants to merge 1 commit into
masterfrom
feat/report-steps-flags

Conversation

@DzmitryHumianiuk

Copy link
Copy Markdown
Member

Summary

Part of #26 (slice C1). No dependencies: the branch is cut from master and touches only
internal/commands/report_steps.go, its test file, README.md and the ReportPortal skill.
git merge-tree --write-tree HEAD <branch> reports no conflict with origin/fix/test2json-reporting (#29),
origin/fix/openapi-errorcode-integer (#33), origin/fix/api-errors (#36), origin/fix/openapi-compat-v5-aliases,
origin/fix/host-path-prefix and origin/chore/codegen-hygiene (text merge only; the merged trees were not built).

The atomic commands (gorp report start-launch | start-test | finish-test | finish-launch) can now send the
fields that the Java agents send: rerun, test case ID, parameters, retries, nested steps, defect types, and
attributes/description at finish. --mode and --type are checked before any request is sent.

Changes

Command New flags Request field (v2 API)
start-launch --rerun, --rerun-of <uuid> StartLaunchRQ.rerun, .rerunOf
start-test --test-case-id, --param key=value (repeatable), --retry-of <uuid>, --has-stats (default true) StartTestItemRQ.testCaseId, .parameters[]{key,value}, .retry + .retryOf, .hasStats
finish-test --issue-type <locator or NOT_ISSUE>, --attr, --description FinishTestItemRQ.issue.issueType, .attributes, .description
finish-launch --attr, --description FinishExecutionRQ.attributes, .description

Details:

  • --rerun-of implies --rerun. The server reads rerunOf only when rerun is true, so --rerun-of alone
    would silently start a new launch.
  • --retry-of sends retry=true and retryOf. It needs --parent-uuid: the server refuses a root retry, but
    on v2 only after it has answered 201, so the command refuses it locally. There was no --retry flag before
    (the command always sent retry=false) and this PR does not add one.
  • --param splits on the first =. The key is required, the value may be empty. An argument without = or
    without a key is an error.
  • --issue-type is passed through without a check, because projects have custom locators.
  • --mode and --type are upper-cased and compared with gorp.LaunchModes / gorp.TestItemTypes. An unknown
    value fails with, for example, invalid --mode "DEBAG": must be one of DEFAULT, DEBUG, and no request is sent.
  • --status is not validated (unchanged): the server stays the judge.
  • start-test rejects a stray argument. --has-stats false (without =) leaves false as an argument and the
    flag stays true, so the item would silently be reported with statistics; now it fails with
    unexpected argument "false": a boolean flag takes its value with '=', e.g. --has-stats=false.
  • finish-launch prints the link from FinishLaunchRS.link on a second line, after the UUID.
  • Field names follow the Java client model (rerun, rerunOf, testCaseId, parameters, retry, retryOf,
    hasStats, issue.issueType); flag names are the kebab-case form of those names.
  • Issue and ParameterResource have no short alias in pkg/openapi/compat.go, so the code uses the generated
    long names instead of adding aliases (other open PRs change the alias template).

Behaviour change

  • finish-launch prints two lines when the server returns a link: the UUID (first line, as before) and the
    link. A script that captures the whole output into one variable now gets both lines.
  • --mode and --type values that are not in the enums now fail in the CLI. Before, they were passed through
    unchecked (an unknown --type gets 400 / 4001 from the server according to its @In constraint; what the server
    did with an unknown or lower-case --mode was not probed). Both are now sent in upper case.
  • start-test with a positional argument now fails; before, the argument was ignored.
  • The payload of a call without the new flags is unchanged (test "start-test defaults are unchanged",
    "start-launch without rerun flags sends neither field", "finish-test without the new flags sends none of the fields").

Verification

Commands, run in the worktree:

  • go build ./... && go vet ./...: OK
  • go test -race ./...: OK (internal/commands, pkg/gorp)
  • go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.15.0 run --allow-parallel-runners ./...: 0 issues
  • go test -tags e2e -count=1 ./e2e/... against the live server: OK (30 s)

New unit tests (TestReportStepFlags) parse real command lines with the real flag definitions and assert the
JSON body that reaches an httptest server, including --has-stats=false, repeated --param, and that a
validation error sends no request.

Live check on the ReportPortal 6.0.0 rc demo (scripts: scratchpad/wave/c1/live1.sh, live2.sh, live3.sh,
read-back verify.sh, cleanup.sh). Everything below was read back through GET /api/v1/{project}/launch/uuid/{uuid}
and GET /api/v1/{project}/item?filter.eq.launchId=…:

Sent Stored by the server
start-launch --name gorp-wave-c1 --mode default --attr slice:c1 --description "pass 1" mode: DEFAULT, attribute slice:c1
start-test --type suite / --type step (lower case) type: SUITE / STEP
--test-case-id tc-A --param browser=chrome --param "url=http://x?a=b" --code-ref pkg/testA testCaseId: tc-A, parameters: [{browser, chrome}, {url, http://x?a=b}], codeRef: pkg/testA
--has-stats=false on a child of testA hasStats: false; not counted (launch total 4 for 4 tests)
finish-test --status FAILED --issue-type pb001 --attr at:finish --description "finish desc" issue.issueType: pb001; attributes at:start and at:finish (added); description finish desc (replaced start desc)
testB FAILED, then start-test --name testB-second-attempt --code-ref pkg/testB-other --retry-of <testB uuid>, PASSED the second item lists testB under retries; statistics count one item (different name and code ref, so the grouping comes from retryOf and not from the server's implicit matching)
finish-test --status FAILED --issue-type NOT_ISSUE issue: null
finish-test --status FAILED without --issue-type issue.issueType: ti001 (server default, as before)
finish-launch --attr at:launch-finish --description "pass 1 finished" attribute added; description pass 1 pass 1 finished (appended, not replaced); output: UUID, then <host>/ui/#organizations/…/projects/…/launches/all/<uuid>
start-launch --name gorp-wave-c1 --rerun-of <uuid> --attr pass:2 --description "pass 2" printed UUID equals the original; rerun: true, same launch id and number, attribute pass:2 added, description pass 2
in the rerun: testD again (PASSED) and a new testE --param run=2 testD is PASSED with the earlier FAILED testD under retries; testE added; total 5
--rerun-of 00000000-0000-4000-8000-000000000000 exit 1, 404 … errorCode 4041 … Launch '0000…' not found
start-launch --name gorp-wave-c1-no-such-launch --rerun exit 1, 404 / 4041
--mode DEBAG, --type CASE exit 1 with the validation message, no request
finish-test --status FAILED --issue-type zz999 exit 0; the item stays IN_PROGRESS (v2 answers before the locator is checked)
finish-test --status PASSED --issue-type pb001 issue: null (the server drops it)
finish-test --status SKIPPED --issue-type AB001 issue.issueType: ab001 (locator is case-insensitive)

Cleanup: both launches created for this check (gorp-wave-c1, gorp-wave-c1-issue) were deleted;
GET …/launch/uuid/<uuid> returns 404 and filter.cnt.name=gorp-wave-c1 returns an empty list. Nothing was merged.

Investigation log

Paths: S = src/main/java/com/epam/reportportal/base in a reportportal/service-api checkout (local branch
develop at 017642e9e48ad37b0a6ec8aae6caeadc0f001969), J = client-java/src/main/java/com/epam in the clone
of reportportal/client-java under scratchpad/consilium/java, W = the goRP worktree. The references were
read with sed -n '<from>,<to>p' <file> and found with grep -n for the field name in the file, e.g.
grep -n "JsonProperty\|private " S/reporting/StartTestItemRQ.java,
grep -rn "isHasStats\|getRetryOf" S/core, grep -n "ttributes" S/core/launch/impl/FinishLaunchHandlerImpl.java.

  1. Plan: gh api repos/reportportal/goRP/issues/comments/7228933728 --jq .body lists the C1 flags.
  2. Current state: W/internal/commands/report_steps.go on master sends HasStats: true, Retry: false
    hard-coded and has no --retry flag (grep -n retry internal/commands/report_steps.go).
  3. Field names and types in the generated client: W/pkg/openapi/model_com_epam_reportportal_base_reporting_{start_launch_rq,start_test_item_rq,finish_test_item_rq,finish_execution_rq,issue,parameter_resource}.go
    and model_com_epam_reportportal_base_model_launch_finish_launch_rs.go (link).
  4. Same fields in the server model: S/reporting/StartLaunchRQ.java:32-40 (mode, rerun, rerunOf),
    S/reporting/StartTestItemRQ.java:52-89 (codeRef, parameters, testCaseId, type, retry, hasStats = true, retryOf),
    S/reporting/FinishExecutionRQ.java:57-69 (status, description, attributes),
    S/reporting/FinishTestItemRQ.java:36-50 (issue, retry, testCaseId, retryOf),
    S/reporting/Issue.java:47-50 (issueType, @NotBlank), S/reporting/ParameterResource.java:33-38 (key @NotNull, value optional).
  5. Java naming (grep -rnE '"(rerunOf|retryOf|hasStats|testCaseId|issueType|rerun|retry|parameters)"|"rp\.rerun' .
    in the Java clones): properties rp.rerun, rp.rerun.of (J/reportportal/utils/properties/ListenerProperty.java:98-99);
    J/ta/reportportal/ws/model/launch/StartLaunchRQ.java:30,33 (rerun, rerunOf);
    J/ta/reportportal/ws/model/StartTestItemRQ.java:32-53 (parameters, testCaseId, retry, hasStats, retryOf);
    J/ta/reportportal/ws/model/issue/Issue.java:32 (issueType). The flag names are the same words in kebab-case.
  6. rerunOf needs rerun: S/reporting/async/producer/LaunchStartProducer.java:58-60 calls the rerun lookup only
    inside if (request.isRerun()). The lookup (S/core/launch/rerun/RerunHandlerImpl.java:113-124) throws
    LAUNCH_NOT_FOUND → 404 before the 201. Confirmed live (row "--rerun-of 0000…").
  7. Retry: S/core/item/impl/StartTestItemHandlerImpl.java:136-137 treats retry == true or a non-blank
    retryOf as a retry; :201-202 rejects a root item with retry=true ("Root test item can't be a retry").
    This check runs in the consumer, after v2 answered, hence the local check for --parent-uuid.
  8. Issue type: S/core/item/impl/FinishTestItemHandlerImpl.java:289-291 removes the issue for PASSED;
    :344-347 requires FAILED/SKIPPED, no retryOf, and hasStats; :353-373 resolves the locator or
    NOT_ISSUE, default To Investigate. Unknown locator: S/core/item/impl/IssueTypeHandler.java:53-65 throws.
    All three confirmed live (live3.sh).
  9. Attributes and description at finish: item — FinishTestItemHandlerImpl.java:171-175 with
    S/ws/converter/builders/TestItemBuilder.java:108-114 (description set) and :130-137 (attributes addAll);
    launch — S/core/launch/impl/FinishLaunchHandlerImpl.java:109-112 (buildDescription(old, new), attributes
    addAll in S/ws/converter/builders/LaunchBuilder.java:95-102). Live: item description replaced, launch
    description appended, attributes added in both. The help texts and the docs say so.
  10. Link: S/reporting/async/producer/LaunchFinishProducer.java:73-78 always sets link on v2. The command
    still skips the line when the link is empty (unit test "prints only the UUID when the server returns no link").
  11. Validation: S/reporting/StartTestItemRQ.java:72-76 — the server upper-cases type and allows exactly the
    15 values of gorp.TestItemTypes (W/pkg/gorp/model_enums.go:82-98); S/reporting/Mode.java is a Java
    enum DEFAULT, DEBUG (gorp.LaunchModes). So the CLI upper-cases first and then checks.
  12. Rerun item matching: RerunHandlerImpl.java:126-131,160-185 matches by test case hash (and name for
    containers); a matched leaf goes through handleRetry. Live: testD in the rerun.
  13. --has-stats=false: urfave/cli v3 bool flags take the value only with =; covered by the unit test
    "start-test sends test case id, parameters, retry and hasStats" and the live run. With a space, false
    became a positional argument and the body carried hasStats: true (observed in a unit test before the
    guard was added), hence the stray-argument check; test "start-test rejects '--has-stats false'".
  14. Slice flags: urfave/cli v3 splits slice values on , (command.go:112-115, flag_map_impl.go:87 in
    v3.14.0). This already applies to --attr. Observed in unit tests: --param a=1,b=2 gives two parameters,
    and --param list=a,b fails with invalid --param "b": expected 'key=value', so a parameter value can't
    contain a comma. Documented, not changed here (changing it would also change --attr).
  15. The new tests reuse the flag instances of the package-level commands, so they are not parallel, and the
    helper clears LAUNCH_UUID, PARENT_UUID, ITEM_UUID (PARENT_UUID=x go test -count=1 -run TestReportStepFlags ./internal/commands/ passes).

Not verified

  • Servers older than 6.0.0 rc. The plan notes (scratchpad/consilium2/server.md) say the v2 rerun returns the
    original UUID only from 5.13.5; the README states that floor, but I did not run against 5.x.
  • What the server answers to an unknown or lower-case mode (the CLI no longer sends one).
  • The trees merged with the open PR branches were not built or tested.
  • --rerun by name on a project where several launches share the name (live check used --rerun-of; the
    by-name path was only checked for the "no such launch" case).
  • --issue-type with a custom project locator and with nd001/si001 (checked: pb001, AB001, NOT_ISSUE, default ti001, unknown).
  • The local service-api develop (017642e9) differs from origin/develop; the live server is 6.0.0 rc, and the
    behaviours I rely on were each confirmed live as listed above.

Open questions for maintainers:

  • Should finish-test --issue-type check the locator through the API first? Today an unknown locator exits 0
    and the item silently stays in progress (v2 behaviour).
  • --issue-comment (Issue.comment) and a bare --retry (retry without retryOf, as the Java agents send)
    are not in the C1 list and were left out.
  • Comma splitting of --param / --attr values (item 14).

🤖 Generated with Claude Code

…ic report commands

- start-launch: --rerun, --rerun-of (implies --rerun)
- start-test: --test-case-id, --param key=value, --retry-of, --has-stats
- finish-test: --issue-type, --attr, --description
- finish-launch: --attr, --description; prints the launch link after the UUID
- --mode and --type are checked against the known values (case-insensitive) before any request

Part of #26

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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