Repository navigation
Add rerun, retry, parameters, issue type and finish flags to the atomic report commands - #41
Open
DzmitryHumianiuk wants to merge 1 commit into
Open
DzmitryHumianiuk wants to merge 1 commit into
DzmitryHumianiuk wants to merge 1 commit into
Conversation
…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>
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.
Summary
Part of #26 (slice C1). No dependencies: the branch is cut from
masterand touches onlyinternal/commands/report_steps.go, its test file,README.mdand the ReportPortal skill.git merge-tree --write-tree HEAD <branch>reports no conflict withorigin/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-prefixandorigin/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 thefields that the Java agents send: rerun, test case ID, parameters, retries, nested steps, defect types, and
attributes/description at finish.
--modeand--typeare checked before any request is sent.Changes
start-launch--rerun,--rerun-of <uuid>StartLaunchRQ.rerun,.rerunOfstart-test--test-case-id,--param key=value(repeatable),--retry-of <uuid>,--has-stats(defaulttrue)StartTestItemRQ.testCaseId,.parameters[]{key,value},.retry+.retryOf,.hasStatsfinish-test--issue-type <locator or NOT_ISSUE>,--attr,--descriptionFinishTestItemRQ.issue.issueType,.attributes,.descriptionfinish-launch--attr,--descriptionFinishExecutionRQ.attributes,.descriptionDetails:
--rerun-ofimplies--rerun. The server readsrerunOfonly whenrerunis true, so--rerun-ofalonewould silently start a new launch.
--retry-ofsendsretry=trueandretryOf. It needs--parent-uuid: the server refuses a root retry, buton v2 only after it has answered 201, so the command refuses it locally. There was no
--retryflag before(the command always sent
retry=false) and this PR does not add one.--paramsplits on the first=. The key is required, the value may be empty. An argument without=orwithout a key is an error.
--issue-typeis passed through without a check, because projects have custom locators.--modeand--typeare upper-cased and compared withgorp.LaunchModes/gorp.TestItemTypes. An unknownvalue fails with, for example,
invalid --mode "DEBAG": must be one of DEFAULT, DEBUG, and no request is sent.--statusis not validated (unchanged): the server stays the judge.start-testrejects a stray argument.--has-stats false(without=) leavesfalseas an argument and theflag stays
true, so the item would silently be reported with statistics; now it fails withunexpected argument "false": a boolean flag takes its value with '=', e.g. --has-stats=false.finish-launchprints the link fromFinishLaunchRS.linkon a second line, after the UUID.rerun,rerunOf,testCaseId,parameters,retry,retryOf,hasStats,issue.issueType); flag names are the kebab-case form of those names.IssueandParameterResourcehave no short alias inpkg/openapi/compat.go, so the code uses the generatedlong names instead of adding aliases (other open PRs change the alias template).
Behaviour change
finish-launchprints two lines when the server returns a link: the UUID (first line, as before) and thelink. A script that captures the whole output into one variable now gets both lines.
--modeand--typevalues that are not in the enums now fail in the CLI. Before, they were passed throughunchecked (an unknown
--typegets 400 / 4001 from the server according to its@Inconstraint; what the serverdid with an unknown or lower-case
--modewas not probed). Both are now sent in upper case.start-testwith a positional argument now fails; before, the argument was ignored."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 ./...: OKgo 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 issuesgo 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 theJSON body that reaches an
httptestserver, including--has-stats=false, repeated--param, and that avalidation 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 throughGET /api/v1/{project}/launch/uuid/{uuid}and
GET /api/v1/{project}/item?filter.eq.launchId=…:start-launch --name gorp-wave-c1 --mode default --attr slice:c1 --description "pass 1"mode: DEFAULT, attributeslice:c1start-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/testAtestCaseId: tc-A,parameters: [{browser, chrome}, {url, http://x?a=b}],codeRef: pkg/testA--has-stats=falseon a child of testAhasStats: 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; attributesat:startandat:finish(added); descriptionfinish desc(replacedstart desc)start-test --name testB-second-attempt --code-ref pkg/testB-other --retry-of <testB uuid>, PASSEDretries; statistics count one item (different name and code ref, so the grouping comes fromretryOfand not from the server's implicit matching)finish-test --status FAILED --issue-type NOT_ISSUEissue: nullfinish-test --status FAILEDwithout--issue-typeissue.issueType: ti001(server default, as before)finish-launch --attr at:launch-finish --description "pass 1 finished"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"rerun: true, same launch id and number, attributepass:2added, descriptionpass 2testDagain (PASSED) and a newtestE --param run=2retries; testE added; total 5--rerun-of 00000000-0000-4000-8000-000000000000404 … errorCode 4041 … Launch '0000…' not foundstart-launch --name gorp-wave-c1-no-such-launch --rerun--mode DEBAG,--type CASEfinish-test --status FAILED --issue-type zz999IN_PROGRESS(v2 answers before the locator is checked)finish-test --status PASSED --issue-type pb001issue: null(the server drops it)finish-test --status SKIPPED --issue-type AB001issue.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 andfilter.cnt.name=gorp-wave-c1returns an empty list. Nothing was merged.Investigation log
Paths:
S=src/main/java/com/epam/reportportal/basein areportportal/service-apicheckout (local branchdevelopat017642e9e48ad37b0a6ec8aae6caeadc0f001969),J=client-java/src/main/java/com/epamin the cloneof
reportportal/client-javaunderscratchpad/consilium/java,W= the goRP worktree. The references wereread with
sed -n '<from>,<to>p' <file>and found withgrep -nfor 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.gh api repos/reportportal/goRP/issues/comments/7228933728 --jq .bodylists the C1 flags.W/internal/commands/report_steps.goonmastersendsHasStats: true,Retry: falsehard-coded and has no
--retryflag (grep -n retry internal/commands/report_steps.go).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}.goand
model_com_epam_reportportal_base_model_launch_finish_launch_rs.go(link).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,valueoptional).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.rerunOfneedsrerun:S/reporting/async/producer/LaunchStartProducer.java:58-60calls the rerun lookup onlyinside
if (request.isRerun()). The lookup (S/core/launch/rerun/RerunHandlerImpl.java:113-124) throwsLAUNCH_NOT_FOUND→ 404 before the 201. Confirmed live (row "--rerun-of 0000…").S/core/item/impl/StartTestItemHandlerImpl.java:136-137treatsretry == trueor a non-blankretryOfas a retry;:201-202rejects a root item withretry=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.S/core/item/impl/FinishTestItemHandlerImpl.java:289-291removes the issue for PASSED;:344-347requires FAILED/SKIPPED, noretryOf, andhasStats;:353-373resolves the locator orNOT_ISSUE, default To Investigate. Unknown locator:S/core/item/impl/IssueTypeHandler.java:53-65throws.All three confirmed live (
live3.sh).FinishTestItemHandlerImpl.java:171-175withS/ws/converter/builders/TestItemBuilder.java:108-114(description set) and:130-137(attributesaddAll);launch —
S/core/launch/impl/FinishLaunchHandlerImpl.java:109-112(buildDescription(old, new), attributesaddAllinS/ws/converter/builders/LaunchBuilder.java:95-102). Live: item description replaced, launchdescription appended, attributes added in both. The help texts and the docs say so.
S/reporting/async/producer/LaunchFinishProducer.java:73-78always setslinkon v2. The commandstill skips the line when the link is empty (unit test "prints only the UUID when the server returns no link").
S/reporting/StartTestItemRQ.java:72-76— the server upper-casestypeand allows exactly the15 values of
gorp.TestItemTypes(W/pkg/gorp/model_enums.go:82-98);S/reporting/Mode.javais a Javaenum
DEFAULT, DEBUG(gorp.LaunchModes). So the CLI upper-cases first and then checks.RerunHandlerImpl.java:126-131,160-185matches by test case hash (and name forcontainers); a matched leaf goes through
handleRetry. Live: testD in the rerun.--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,
falsebecame a positional argument and the body carried
hasStats: true(observed in a unit test before theguard was added), hence the stray-argument check; test "start-test rejects '--has-stats false'".
,(command.go:112-115,flag_map_impl.go:87inv3.14.0). This already applies to
--attr. Observed in unit tests:--param a=1,b=2gives two parameters,and
--param list=a,bfails withinvalid --param "b": expected 'key=value', so a parameter value can'tcontain a comma. Documented, not changed here (changing it would also change
--attr).helper clears
LAUNCH_UUID,PARENT_UUID,ITEM_UUID(PARENT_UUID=x go test -count=1 -run TestReportStepFlags ./internal/commands/passes).Not verified
scratchpad/consilium2/server.md) say the v2 rerun returns theoriginal UUID only from 5.13.5; the README states that floor, but I did not run against 5.x.
mode(the CLI no longer sends one).--rerunby name on a project where several launches share the name (live check used--rerun-of; theby-name path was only checked for the "no such launch" case).
--issue-typewith a custom project locator and withnd001/si001(checked:pb001,AB001,NOT_ISSUE, defaultti001, unknown).develop(017642e9) differs fromorigin/develop; the live server is 6.0.0 rc, and thebehaviours I rely on were each confirmed live as listed above.
Open questions for maintainers:
finish-test --issue-typecheck the locator through the API first? Today an unknown locator exits 0and the item silently stays in progress (v2 behaviour).
--issue-comment(Issue.comment) and a bare--retry(retry withoutretryOf, as the Java agents send)are not in the C1 list and were left out.
--param/--attrvalues (item 14).🤖 Generated with Claude Code