mirror of
https://github.com/esengine/DeepSeek-Reasonix.git
synced 2026-11-07 10:45:59 -10:00
test(history): assert a complete index only once the projection has settled
CI's Windows full suite saw the index answer State=ready with Indexed=Total=1 while a rescan was still pending, so SearchIndexProgress honestly reported building and the test, which had only waited for the hit to appear, failed. The test now retries until the projection reports every source indexed and nothing pending, fails at once on any unreadable-source signal, and only then asserts that no incomplete-index signal is raised. Not reproduced locally: the base passed 20x on macOS, 90x under six concurrent processes on Windows, and a full package run on Windows.
This commit is contained in:
1 parent
bbdfaebdf3
commit
fd6fa05b19
1 file changed
+25
-11
@@ -125,17 +125,31 @@ func TestHistorySearchSaysNothingExtraWhenTheIndexAnsweredForEverySource(t *test
|
||||
waitHistorySearch(t, "zebra migration", 1)
|
||||
|
||||
for _, query := range []string{"zebra", "quux nonexistent"} {
|
||||
rec := httptest.NewRecorder()
|
||||
historySearch(rec, httptest.NewRequest(http.MethodGet, "/history/search?q="+url.QueryEscape(query), nil))
|
||||
var got historySearchResponse
|
||||
if err := json.Unmarshal(rec.Body.Bytes(), &got); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("%q: status %d body %q, want 200", query, rec.Code, rec.Body.String())
|
||||
}
|
||||
if got.Index.Partial || got.Index.Reason != "" || got.Index.Failed != 0 || got.Index.Indexed != got.Index.Total {
|
||||
t.Fatalf("%q: a complete projection raised an incomplete-index signal: %+v", query, got.Index)
|
||||
deadline := time.Now().Add(20 * time.Second)
|
||||
for {
|
||||
rec := httptest.NewRecorder()
|
||||
historySearch(rec, httptest.NewRequest(http.MethodGet, "/history/search?q="+url.QueryEscape(query), nil))
|
||||
var got historySearchResponse
|
||||
if err := json.Unmarshal(rec.Body.Bytes(), &got); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("%q: status %d body %q, want 200", query, rec.Code, rec.Body.String())
|
||||
}
|
||||
if got.Index.Failed != 0 || got.Index.Reason == history.SearchIndexFailed {
|
||||
t.Fatalf("%q: a readable source was reported as unreadable: %+v", query, got.Index)
|
||||
}
|
||||
settled := got.Index.State == "ready" && got.Index.Total > 0 && got.Index.Indexed == got.Index.Total
|
||||
if settled && history.SearchIndexStatus().Pending == 0 {
|
||||
if got.Index.Partial || got.Index.Reason != "" {
|
||||
t.Fatalf("%q: a complete projection raised an incomplete-index signal: %+v", query, got.Index)
|
||||
}
|
||||
break
|
||||
}
|
||||
if time.Now().After(deadline) {
|
||||
t.Fatalf("%q: the projection never settled: %+v", query, got.Index)
|
||||
}
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user