| 960 | } |
| 961 | |
| 962 | func ComputeStreamingTimeoutSeconds(tc *models.TestCase, defaultSeconds uint64) uint64 { |
| 963 | baseTimeout := defaultSeconds |
| 964 | if baseTimeout == 0 { |
| 965 | baseTimeout = 10 |
| 966 | } |
| 967 | |
| 968 | if tc == nil { |
| 969 | return baseTimeout |
| 970 | } |
| 971 | |
| 972 | reqTs := tc.HTTPReq.Timestamp |
| 973 | respTs := tc.HTTPResp.Timestamp |
| 974 | if reqTs.IsZero() || respTs.IsZero() { |
| 975 | return baseTimeout |
| 976 | } |
| 977 | |
| 978 | diff := respTs.Sub(reqTs) |
| 979 | if diff < 0 { |
| 980 | diff = -diff |
| 981 | } |
| 982 | |
| 983 | timeout := diff + 10*time.Second |
| 984 | if timeout < 10*time.Second { |
| 985 | timeout = 10 * time.Second |
| 986 | } |
| 987 | streamTimeoutSeconds := uint64(math.Ceil(timeout.Seconds())) |
| 988 | if streamTimeoutSeconds < 10 { |
| 989 | streamTimeoutSeconds = 10 |
| 990 | } |
| 991 | if baseTimeout > streamTimeoutSeconds { |
| 992 | return baseTimeout |
| 993 | } |
| 994 | return streamTimeoutSeconds |
| 995 | } |
| 996 | |
| 997 | // CollectStreamingGlobalNoiseKeys extracts noise keys from global body noise and test case noise configurations |
| 998 | // that should be ignored during streaming response comparison. |