Repository navigation
pkg/gorp: add SaveLogBatch and LogBatcher, use it in report test2json - #47
Open
DzmitryHumianiuk wants to merge 2 commits into
Open
DzmitryHumianiuk wants to merge 2 commits into
DzmitryHumianiuk wants to merge 2 commits into
Conversation
ReportPortal answers a multipart log batch with 201 even when it rejects some of its logs: such a log is an entry of responses[] without id. SaveLogMultipart returns only the first id, so the rest went unnoticed. SaveLogBatch returns the entry of every log (LogBatchEntry: Failed, Reason). LogBatcher collects logs and sends a batch when it has 10 entries, when the next log would take it over 16 MiB or 49 attachments, and every 5 seconds; up to 4 requests are in flight, managed by an errgroup. Close sends the rest and returns failed requests and rejected logs (LogBatchError). One request can carry 49 attachments: the server allows 50 multipart parts, one of which is the JSON part. The test2json reporter uses the batcher with its previous limits (10 entries, 4 in flight). New for it: logs of a long-running test are sent while it runs, and a rejected log fails the report like a failed request. A log that later output may be merged into is held back by the reporter, for at most a second of silence, since the batcher owns what it is given. Part of #27. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 28, 2026
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 #27 (slice L3). Stacked on C6 → C5 → C4 → C3 → C2 → #29. The library part needs only #29 (multipart
SaveLog); the reporter part touches the same code as C4 and C5.Two gaps in the log API of
pkg/gorp:is an entry of
responses[]withmessage/stackTraceinstead ofid.SaveLogMultipartreturns only thefirst ID, so rejected logs were never noticed.
output of a long-running test stayed in the reporter until 10 lines had been printed or the run ended.
Changes
pkg/gorp:ReportingClient.SaveLogBatch(ctx, logs, files) ([]LogBatchEntry, error): same request asSaveLogMultipart,returns the answer for every log.
LogBatchEntry{ID, Message, StackTrace}withFailed()andReason().Reason()returns the one-line message whichever field it is in: the server fillsmessagewith the stack traceand
stackTracewith the message (Investigation log 2).SaveLogMultipartis now a thin wrapper and behaves as before (first ID, no error for a rejected log).LogBatcher(NewLogBatcher(ctx, client, LogBatcherOptions),Add(log, files...),Flush(),Close()):MaxEntrieslogs (default 10), when the next log would take it overMaxBytes(16 MiB) or
MaxAttachments(49), everyFlushInterval(5 s; negative disables), and onFlush/Close;errgroup.Grouplimited toMaxInFlight(4);Addblocks while that many are under way;default;Closestops and waits forit before it waits for the requests, and the buffer lock is not held while a request is started;
Closereturns the first failed request, or*LogBatchErrorfor rejected logs; it is idempotent;AddafterClosereturnsErrLogBatcherClosed;DefaultLogBatchAttachments = 49: verified, see below.report test2json:LogBatcherwithMaxEntries: 10,MaxInFlight: 4set explicitly (the previous values) andthe library defaults for the rest.
it, so the reporter now holds back the one log that may still be continued (
pendingLog:error/error-continueoutput of Go 1.27+, or any line of a stream withoutOutputType). It is handed to the batcherwhen the next log or any non-output event arrives, and after at most one second of silent input
(
pendingLogMaxAge, a ticker in the receive loop).Behaviour change
continued) instead of with the tenth line or at the end.
INTERRUPTEDand the command exitsnon-zero, exactly like a failed log request did already. Before, such a log was lost silently. The reporter
builds well-formed logs, so this is expected only when something is wrong (for example an expired launch).
ERRORlog; before it was appended to whatever log was last in the buffer, which could be the other test's.reporting logs: sending a batch of N logs: …; theper-batch
unable to report logslog line is gone (the error is reported once, at the end).Verification
go build ./... && go vet ./... && go vet -tags e2e ./e2e/ && go test -race -count=1 ./...: ok; the batcher testsalso with
-race -count=5. Lint (run ./...,run --build-tags e2e ./e2e/...): 0 issues.pkg/gorp/log_batcher_test.go: every entry returned; flush by count (25 logs → 10, 10, 5), by size (incl.an oversized log on its own), by attachments (never more than the limit, a file travels with its log), by timer
(no
Flush/Close),Flush; at mostMaxInFlightconcurrent requests;Closewith rejected logs and with afailed request;
AddafterClose; 8 goroutines adding 400 logs while the timer flushes every millisecond →every log arrives exactly once.
internal/commands: held-back log is released while the input is silent; only continuable output is heldback; rejected logs fail the report and interrupt the launch; all earlier reporter tests pass unchanged except
the three white-box tests that read
reporter.logs(they now read what the fake server received).scratchpad/wave/probe_l3.py, logscratchpad/wave/live/l3-probe.log), oneJSON part plus N file parts in one request: N = 10, 48, 49 →
201, N ids; N = 50, 51 →500 {"errorCode":5000,"message":"Unclassified error [Could not access multipart servlet request]"}.60 logs without attachments in one request →
201, 60 entries: the limit is on parts, not on logs.go test -tags e2e -run TestLogBatcher→PASS TestLogBatcher_SplitsAttachmentsAndReportsRejectedLogs (3.50s):60 logs with attachments through
LogBatcherare all stored with their files (two requests); 50 files in oneSaveLogBatch→HTTPError500; a log naming a file that is not sent → entryFailed()with reason…There is no request part or file with name not-sent.txtinside a 201; the batcher'sClosereturns*LogBatchError.PASS TestReportTest2JSON_LogsOfRunningTestAreSent (7.06s): with stdin still open, the one output line of arunning test is in ReportPortal while the launch is
IN_PROGRESS, and is not sent again at the end.go test -tags e2e -count=1 -v ./e2e/...on this branch → all 18 tests pass (71 s), logscratchpad/wave/live/top-e2e-full.log.Investigation log
develop,src/main/java/com/epam/reportportal/base/reporting/async/controller/LogAsyncController.java:147-179: eachlog is validated and created inside a
try; thecatchaddsnew BatchElementCreatedRS(stackTrace, message)and the method returns
CREATED. Live: a batch of a good log, a log withoutlaunchUuidand a log naming amissing file →
201,responses: [{id}, {message, stackTrace}, {message, stackTrace}].catchpassesExceptionUtils.getStackTrace(e)first andExceptionUtils.getMessage(e)second. Live, the entry has"message": "com.epam…ReportPortalException: … \n\tat com.epam…"(the trace) and"stackTrace": "ReportPortalException: Binary data cannot be saved. There is no request part or file with name absent.txt"(the message).Reason()therefore takes the shorter field's first line.scratchpad/consilium2/server.mdderived "49 attachments" from Spring Boot'sserver.tomcat.max-part-count=50default and the absence of an override in service-api(
grep -n "max-part-count\|multipart" src/main/resources/application.propertiesshows only thespring.servlet.multipart.*size settings). That was configuration metadata, not an observation; the probe inVerification confirms it on the 6.0.0 demo. It is a deployment setting, so the cap is an option
(
MaxAttachments), and the e2e test only logs when a server accepts 50.The test fakes of this repo answer one entry per request, and nothing in the server produces a short
responses[], so only entries without ID count as failures.reporter.logappended continuation output tor.logs[len(r.logs)-1], a log thebatcher may already be sending from its timer goroutine. Holding the log in the reporter until it cannot be
continued anymore keeps the batcher free of a "change the last log" API and of the data race.
OutputTypeevery line can be continued, so the last linebefore a hang would never leave the reporter. Hence the one-second release in the receive loop; the e2e test
uses such a stream.
Closeorder: mark closed → stop the timer goroutine and wait for it → flush →errgroup.Wait. The timer isthe only internal caller of
Go, so no request can be started afterWaitbegan.Addconcurrently withCloseis documented as not allowed.Open questions
failed log requests.
MaxBytescounts the JSON of the logs and the size ofFileMultipartattachments. The size of aReaderMultipartis unknown without reading it and is not counted.DefaultLogFlushIntervalof 5 s is a choice, not a measured value.Not verified
server.md; not run).500 … TransientObjectException, also by hand. Not related to this change.🤖 Generated with Claude Code