TestCountOverTimeInstantNsWithCutoff simulates merge behavior in L2 and L3.
(t *testing.T)
| 1053 | |
| 1054 | // TestCountOverTimeInstantNsWithCutoff simulates merge behavior in L2 and L3. |
| 1055 | func TestCountOverTimeInstantNsWithCutoff(t *testing.T) { |
| 1056 | start := 1*time.Second + 300*time.Nanosecond // additional 300ns that can be accidentally dropped by ms conversion |
| 1057 | end := 3 * time.Second |
| 1058 | step := end - start // for instant queries step == end-start |
| 1059 | req := &tempopb.QueryRangeRequest{ |
| 1060 | Start: uint64(start), |
| 1061 | End: uint64(end), |
| 1062 | Step: uint64(step), |
| 1063 | Query: "{ } | count_over_time()", |
| 1064 | } |
| 1065 | req.SetInstant(true) |
| 1066 | |
| 1067 | cutoff := 2*time.Second + 300*time.Nanosecond |
| 1068 | // from start to cutoff |
| 1069 | req1 := *req |
| 1070 | req1.End = uint64(cutoff) |
| 1071 | req1.Step = req1.End - req1.Start |
| 1072 | // from cutoff to end |
| 1073 | req2 := *req |
| 1074 | req2.Start = uint64(cutoff) |
| 1075 | req2.Step = req2.End - req2.Start |
| 1076 | |
| 1077 | in1 := []Span{ |
| 1078 | // outside of the range but within the range for ms. Should be ignored. |
| 1079 | newMockSpan(nil).WithStartTime(uint64(start - 20*time.Nanosecond)).WithDuration(1), |
| 1080 | newMockSpan(nil).WithStartTime(uint64(start - time.Nanosecond)).WithDuration(1), |
| 1081 | |
| 1082 | // within the range |
| 1083 | newMockSpan(nil).WithStartTime(uint64(start)).WithDuration(1), |
| 1084 | newMockSpan(nil).WithStartTime(uint64(start + time.Nanosecond)).WithDuration(1), |
| 1085 | newMockSpan(nil).WithStartTime(uint64(cutoff - time.Nanosecond)).WithDuration(1), |
| 1086 | newMockSpan(nil).WithStartTime(uint64(cutoff)).WithDuration(1), |
| 1087 | |
| 1088 | // outside of cutoff |
| 1089 | newMockSpan(nil).WithStartTime(uint64(cutoff + time.Nanosecond)).WithDuration(1), |
| 1090 | } |
| 1091 | |
| 1092 | in2 := []Span{ |
| 1093 | // outside of cutoff |
| 1094 | newMockSpan(nil).WithStartTime(uint64(cutoff - time.Nanosecond)).WithDuration(1), |
| 1095 | |
| 1096 | // within the range |
| 1097 | newMockSpan(nil).WithStartTime(uint64(cutoff)).WithDuration(1), |
| 1098 | newMockSpan(nil).WithStartTime(uint64(cutoff + time.Nanosecond)).WithDuration(1), |
| 1099 | newMockSpan(nil).WithStartTime(uint64(end - time.Nanosecond)).WithDuration(1), |
| 1100 | newMockSpan(nil).WithStartTime(uint64(end)).WithDuration(10), |
| 1101 | |
| 1102 | // outside of the range but within the range for ms. Should be ignored. |
| 1103 | newMockSpan(nil).WithStartTime(uint64(end + time.Nanosecond)).WithDuration(1), |
| 1104 | newMockSpan(nil).WithStartTime(uint64(end + 20*time.Nanosecond)).WithDuration(1), |
| 1105 | } |
| 1106 | |
| 1107 | out := []TimeSeries{ |
| 1108 | { |
| 1109 | Labels: []Label{ |
| 1110 | {Name: "__name__", Value: NewStaticString("count_over_time")}, |
| 1111 | }, |
| 1112 | Values: []float64{8}, |
nothing calls this directly
no test coverage detected