feat(bloomberg): enrich article content for summaries (#36)
This commit is contained in:
@ -143,7 +143,7 @@ type ticket32BrokenBody struct{}
|
||||
func (ticket32BrokenBody) Read([]byte) (int, error) { return 0, io.ErrUnexpectedEOF }
|
||||
func (ticket32BrokenBody) Close() error { return nil }
|
||||
|
||||
func TestTicket32ProductionShapedLongContentTimeoutAfterFifteenRequests(t *testing.T) {
|
||||
func TestTicket32ProductionShapedBudgetedContentTimeoutAfterFiveRequests(t *testing.T) {
|
||||
var logs bytes.Buffer
|
||||
previous := log.Writer()
|
||||
log.SetOutput(&logs)
|
||||
@ -160,7 +160,7 @@ func TestTicket32ProductionShapedLongContentTimeoutAfterFifteenRequests(t *testi
|
||||
calls := 0
|
||||
ranker.client = &http.Client{Transport: ticket31Transport(func(r *http.Request) (*http.Response, error) {
|
||||
calls++
|
||||
if calls == 15 {
|
||||
if calls == 5 {
|
||||
<-r.Context().Done()
|
||||
return nil, r.Context().Err()
|
||||
}
|
||||
@ -176,11 +176,11 @@ func TestTicket32ProductionShapedLongContentTimeoutAfterFifteenRequests(t *testi
|
||||
return &http.Response{StatusCode: 200, Body: io.NopCloser(bytes.NewReader(raw)), Header: make(http.Header)}, nil
|
||||
})}
|
||||
got, err := ranker.Rank(context.Background(), "title_content", assets, candidates)
|
||||
if err == nil || err.Error() != "laya: timeout" || got != nil || calls != 15 {
|
||||
if err == nil || err.Error() != "laya: timeout" || got != nil || calls != 5 {
|
||||
t.Fatalf("calls=%d err=%v", calls, err)
|
||||
}
|
||||
summary := ticket32Metrics(t, logs.String(), "laya ranking diagnostics ")
|
||||
for key, want := range map[string]float64{"candidates": 233, "assets": 30, "states_planned": 6990, "requests_planned": 110, "states_sent": 960, "requests_sent": 15, "requests_validated": 14, "batch_size_min": 64, "batch_size_max": 64, "batch_size_mean": 64} {
|
||||
for key, want := range map[string]float64{"candidates": 233, "assets": 30, "states_planned": 699, "requests_planned": 11, "states_sent": 320, "requests_sent": 5, "requests_validated": 4, "batch_size_min": 64, "batch_size_max": 64, "batch_size_mean": 64} {
|
||||
if summary[key] != want {
|
||||
t.Errorf("%s=%v want=%v", key, summary[key], want)
|
||||
}
|
||||
@ -188,7 +188,7 @@ func TestTicket32ProductionShapedLongContentTimeoutAfterFifteenRequests(t *testi
|
||||
if strings.Contains(logs.String(), "PRIVATE_") {
|
||||
t.Fatal("sensitive diagnostic")
|
||||
}
|
||||
t.Log("233 candidates / 30 assets, long content: planned 6990 states / 110 requests; timeout after 15 attempts / 960 states, 14 batches validated")
|
||||
t.Log("233 candidates / 30 assets, long content: planned 699 states / 11 requests; timeout after 5 attempts / 320 states, 4 batches validated")
|
||||
}
|
||||
|
||||
func TestTicket32EmptyAndInvalidInputsHaveFiniteZeroAttemptMetrics(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user