tests: cmd/cosift round-4 — fake fetcher + fake cluster#5
Merged
Conversation
Lifts cmd/cosift coverage from 50.5% (post-round-3) to 65.3% by adding: - fakeCluster: array of httptest peer shards for scatterSearch + the four gateway handlers (search / find_similar / answer / research) - Whole-runner sweeps for runServe (with /healthz round-trip + graceful shutdown), runCrawl (sqlite + pebble + seeds-file + duration paths), runEval (-api short-circuit + local bm25 + unknown-retriever guards), runBench (vector/bm25/storage/json modes), runAnswerEval (-dry-run), runAnswerEvalCompare (multi-strategy diff + missing-file guards), runCrawlErrors, runVerifyPebble (local + via -server + drift) - Direct unit tests for the iter-391 hnswPassageWriter bridge - Direct unit tests for eval-side retriever adapters (hybridAdapter, rerankAdapter, paraphraseRetriever, plannerRetriever, httpAPIRetriever) via stub Retriever / stub ChatClient - SSE coverage for streamAnswer + streamResearch via real httptest.Server (httptest.NewRecorder doesn't implement http.Flusher) - doRerank counter wrapper (happy + error) via a realFakeReranker All scaffolding builds on the round-3 openaiTestServer + populatedPebbleStore fixtures from zz_round3_test.go. No production code modified.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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
Round-4 coverage push for
cmd/cosift. Lifts coverage from 50.5% (post-round-3) to 65.3% by extending the round-3 scaffolds (OpenAI httptest mock + populated Pebble fixture) with a fake peer cluster and whole-runner sweeps.What's new
fakeCluster— array ofhttptest.Serverpeer shards. DrivesscatterSearch+ the four gateway handlers (handleSearchGateway,handleFindSimilarGateway,handleAnswerGateway,handleResearchGateway) end-to-end without spinning up real cosift instances.runServe— full lifecycle (free-port pick,/healthzround-trip, graceful shutdown) + the admin-token / trusted-proxies / chunker / defaults wiring branches + bad-CIDR error path.runCrawl— sqlite + pebble backends,-seeds-file(happy + missing + comments/blanks),-duration, pre-cancelled ctx, unknown backend.runEval—-apishort-circuit against a fake httptest endpoint (with-save), local-bm25 path against a synthesized corpus, unknown-retriever guard, dense-without-key guard.runBench— vector / bm25 / storage /-jsonmodes (tiny N so the suite stays fast).runAnswerEval -dry-run+ bad-key/bad-corpus/bad-queries guards.runAnswerEvalCompare— multi-strategy diff with per-query moves, no-moves, wrong-arg, missing-baseline, missing-new paths.runCrawlErrors(empty + custom-limit) andrunVerifyPebble(local + via-serverhappy + drift +-json).hnswPassageWriterbridge (UpsertPassage,UpsertPassageBatch,MarkURLInvalid+ ctx-cancelled).Retriever+ stubChatClient:hybridAdapter,rerankAdapter(happy / inner-err / single-URL short-circuit / rerank-err fallback / candidateK default),paraphraseRetriever(chat-err / main-weight / inner-err / cache hit),plannerRetriever(happy / chat-err / unparseable / cap-at-5),httpAPIRetriever(happy / non-200 / dial-err / bad JSON).streamAnswer+streamResearchvia realhttptest.NewServer(httptest.NewRecorderdoesn't implementhttp.Flusher).doRerankcounter wrapper (happy + err) via arealFakeRerankerthat satisfies the realrerank.Rerankerinterface.applyBM25EnvOverrides— valid / malformed / negative / unset.handleCheckpoint,handleCrawlEnqueuehappy/hook-err/bad-body,handleSitemapImporthappy/bad-body/hook-err,handleFrontierPurgeHosthappy/bad-body,handleSitePackbad-host/missing-host,handlePQTrainno-hnsw,handlePQEncodeno-codebook,handleWETImportBulkbad-body/manifest-unreachable,handleCrawlNowempty-urls).Test plan
go test -race -count=1 -timeout 180s ./cmd/cosift/...passesgo tool cover -func=…cmd/cosift/zz_round4_test.goadded (2061 LOC)openaiTestServer,populatedPebbleStore,seedTinyStore,captureStdoutCosift); no duplicate test names with rounds 2 or 3What's still gated
runReembed(16.2%),expandQuery(8.7%),handleEvalQuick(10.4%),handleEmbedBackfill(13.8%),handlePQTrain(12.9%), and the streaming-detail tails insidestreamAnswer/streamResearchstill have uncovered branches — most need either a working OpenAI key, a deep multi-step setup with passages persisted to disk, or the iter-402 in-serve crawler (startInProcessCrawl) which is currently entirely 0% and would require a substantial new fake-fetcher harness.main()is unreachable from unit tests.Searchmethods atmain.go:2547(denseAdapter),2592(rerankAdapter — partly covered), etc. —denseAdapteris still 0% because it requires a workingEmbedder; the mock embedder could be wired here in a follow-up round.