Skip to content

tests: capture tarantool log tail in startup errors - #587

Merged
oleg-jukovec merged 1 commit into
masterfrom
bigbes/gh-147-capture-tarantool-log-tail
May 15, 2026
Merged

tests: capture tarantool log tail in startup errors#587
oleg-jukovec merged 1 commit into
masterfrom
bigbes/gh-147-capture-tarantool-log-tail

Conversation

@bigbes

@bigbes bigbes commented May 5, 2026

Copy link
Copy Markdown
Collaborator

When StartTarantool fails, the returned error gives only the connection or exit reason (exit status 1, context deadline exceeded), so a CI failure required re-running the test locally to see why tarantool actually refused to come up. Tarantool's own diagnostics — bad config, port conflicts, missing modules, Lua errors during init — were written to the child's stdout/stderr and silently dropped on the floor.

  • New logTailBuffer ring of the last 50 lines, wired into Cmd.Stdout/Cmd.Stderr. Safe for concurrent writes from the two copy goroutines; preserves a partial trailing line if the process exits without flushing a newline.

  • Append the captured tail to the StartTarantool error on both failure paths (unexpected exit, connect failure).

  • New (*TarantoolInstance).LogTail() exposing the same buffer for live tests.

  • New test_helpers.DumpLogsIfFailed(t, inst) helper for the idiom:

    inst, err := test_helpers.StartTarantool(opts)
    require.NoError(t, err)
    defer test_helpers.StopTarantoolWithCleanup(inst)
    defer test_helpers.DumpLogsIfFailed(t, inst)

Closes #147.

@bigbes
bigbes force-pushed the bigbes/gh-147-fix-invalid-startup-panics branch from 6dba26a to 0b5c01f Compare May 5, 2026 09:07
@bigbes
bigbes force-pushed the bigbes/gh-147-capture-tarantool-log-tail branch from e5cea2a to 009c5df Compare May 5, 2026 09:07
@oleg-jukovec
oleg-jukovec force-pushed the bigbes/gh-147-fix-invalid-startup-panics branch from 0b5c01f to fe5c21d Compare May 5, 2026 21:46
Base automatically changed from bigbes/gh-147-fix-invalid-startup-panics to master May 5, 2026 22:00
@bigbes
bigbes marked this pull request as ready for review May 6, 2026 10:33

@oleg-jukovec oleg-jukovec left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, rebase the PR.

@bigbes
bigbes force-pushed the bigbes/gh-147-capture-tarantool-log-tail branch from 009c5df to 3dcbbd6 Compare May 12, 2026 22:38
@bigbes
bigbes requested a review from oleg-jukovec May 12, 2026 22:47
@bigbes

bigbes commented May 12, 2026

Copy link
Copy Markdown
Collaborator Author

Rebased

@oleg-jukovec
oleg-jukovec force-pushed the bigbes/gh-147-capture-tarantool-log-tail branch from 3dcbbd6 to aa75d81 Compare May 15, 2026 11:29

@oleg-jukovec oleg-jukovec left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the patch! I've remove extra dot after Closes #147 from the commit message.

When StartTarantool fails, the returned error gives only the connection
or exit reason ("exit status 1", "context deadline exceeded"), so a CI
failure required re-running the test locally to see why tarantool
actually refused to come up. Tarantool's own diagnostics — bad config,
port conflicts, missing modules, Lua errors during init — were written
to the child's stdout/stderr and silently dropped on the floor.

Wire a small ring buffer into Cmd.Stdout/Stderr that retains the last
50 lines, append it to the StartTarantool error on the two failure
paths (unexpected exit and connect failure), and expose the same tail
on TarantoolInstance for live tests.

Add test_helpers.DumpLogsIfFailed so a passing StartTarantool followed
by a later assertion failure can surface the captured log via t.Logf.
Intended idiom:

    inst, err := test_helpers.StartTarantool(opts)
    require.NoError(t, err)
    defer test_helpers.StopTarantoolWithCleanup(inst)
    defer test_helpers.DumpLogsIfFailed(t, inst)

Buffer is safe for concurrent writes from exec.Cmd's two copy goroutines
and preserves a partial trailing line if the process exits without
flushing a newline.

Closes #147
@bigbes
bigbes force-pushed the bigbes/gh-147-capture-tarantool-log-tail branch from aa75d81 to fa8abb2 Compare May 15, 2026 11:44
@oleg-jukovec
oleg-jukovec merged commit 52bcfd5 into master May 15, 2026
27 checks passed
@oleg-jukovec
oleg-jukovec deleted the bigbes/gh-147-capture-tarantool-log-tail branch May 15, 2026 12:14
@oleg-jukovec oleg-jukovec mentioned this pull request Jun 8, 2026
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.

Problems with setup and teardown Tarantool in tests

3 participants