effectiveStreamMockWindow calculates the effective time window for streaming mocks. It returns the start time (request timestamp) and end time (anchor + timeout), where anchor is the later of request/response timestamps (falling back to time.Now). The timeout is calculated using pkg.ComputeStreaming
(tc *models.TestCase, defaultAPITimeout uint64)
| 484 | // where anchor is the later of request/response timestamps (falling back to time.Now). |
| 485 | // The timeout is calculated using pkg.ComputeStreamingTimeoutSeconds which considers the test case's timeout configuration. |
| 486 | func effectiveStreamMockWindow(tc *models.TestCase, defaultAPITimeout uint64) (time.Time, time.Time) { |
| 487 | if tc == nil { |
| 488 | return time.Time{}, time.Time{} |
| 489 | } |
| 490 | |
| 491 | reqTs := tc.HTTPReq.Timestamp |
| 492 | respTs := tc.HTTPResp.Timestamp |
| 493 | timeoutSeconds := pkg.ComputeStreamingTimeoutSeconds(tc, defaultAPITimeout) |
| 494 | |
| 495 | anchor := reqTs |
| 496 | if anchor.IsZero() || (!respTs.IsZero() && respTs.After(anchor)) { |
| 497 | anchor = respTs |
| 498 | } |
| 499 | if anchor.IsZero() { |
| 500 | anchor = time.Now().UTC() |
| 501 | } |
| 502 | |
| 503 | return reqTs, anchor.Add(time.Duration(timeoutSeconds) * time.Second) |
| 504 | } |
| 505 | |
| 506 | func timeWithUnits(duration time.Duration) string { |
| 507 | if duration.Seconds() < 1 { |