Skip to content

test: fix flaky timing and correctness issues in reporter/plugin manager tests#142

Merged
intel352 merged 2 commits intofeat/issue-92-test-coveragefrom
copilot/sub-pr-130
Feb 23, 2026
Merged

test: fix flaky timing and correctness issues in reporter/plugin manager tests#142
intel352 merged 2 commits intofeat/issue-92-test-coveragefrom
copilot/sub-pr-130

Conversation

Copy link
Contributor

Copilot AI commented Feb 23, 2026

Four correctness and reliability issues in the test suite identified during review of #130.

observability/reporter_test.go

  • TestReporter_StopFlushesRemaining: handler was setting received=true for any request, meaning the async registration POST to /api/v1/admin/instances/register could satisfy the assertion before the actual flush to /api/v1/admin/ingest/executions ever happened. Now only the ingest path triggers the flag.

  • TestReporter_BufferAndFlush: replaced fixed time.Sleep waits with a deadline/poll loop — exits as soon as all three ingest paths are observed, fails fast with a descriptive message after 2s. Added t.Cleanup(cancel) to guarantee goroutine teardown.

deadline := time.Now().Add(2 * time.Second)
for {
    mu.Lock()
    execFlushed := receivedPaths["/api/v1/admin/ingest/executions"] > 0
    // ...
    mu.Unlock()
    if execFlushed && logsFlushed && eventsFlushed { break }
    if time.Now().After(deadline) {
        t.Fatalf("timed out waiting for reports to be flushed, got: %#v", receivedPaths)
    }
    time.Sleep(10 * time.Millisecond)
}

plugin/manager_test.go

  • DB setup: four tests were opening SQLite directly via sql.Open("sqlite", ":memory:") + defer db.Close(), bypassing the existing openTestDB(t) helper in native_test.go. Consolidated to use the helper (which registers cleanup via t.Cleanup). Removed now-unused database/sql and _ "modernc.org/sqlite" imports.

  • TestPluginManager_AllPlugins: Register/Enable calls were silently discarding errors with _ = .... Replaced with t.Fatalf so a future regression points directly at the failing call rather than a downstream assertion.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
Copilot AI changed the title [WIP] Add comprehensive tests for under-tested packages test: fix flaky timing and correctness issues in reporter/plugin manager tests Feb 23, 2026
Copilot AI requested a review from intel352 February 23, 2026 14:31
@intel352 intel352 marked this pull request as ready for review February 23, 2026 14:32
@intel352 intel352 merged commit 324adec into feat/issue-92-test-coverage Feb 23, 2026
@intel352 intel352 deleted the copilot/sub-pr-130 branch February 23, 2026 14:32
intel352 added a commit that referenced this pull request Feb 23, 2026
* test: improve test coverage for critical packages (#92)

Add comprehensive tests for under-tested packages:

- admin: LoadConfigRaw, LoadConfig, MergeInto (0% → 89.5%)
- config: LoadFromString, ResolveRelativePath, ResolvePathInConfig (40.7% → 100%)
- observability: Reporter lifecycle, IngestHandler endpoints (15.2% → 62.5%)
- plugin/admincore: Plugin metadata, UIPages, lifecycle (0% → 88.9%)
- plugin: PluginManager ServeHTTP, state persistence, dependency resolution
- sandbox: tar archive creation, CopyIn/CopyOut stubs, empty command validation

All tests use table-driven patterns with t.Run() subtests and t.Parallel().
Verified with -race flag and golangci-lint.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* test: fix flaky timing and correctness issues in reporter/plugin manager tests (#142)

* Initial plan

* test: apply review feedback to reporter and plugin manager tests

Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: intel352 <77607+intel352@users.noreply.github.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