createOverlappingSeriesHandler creates responses with same series from multiple queries.
(t *testing.T, queries []*prompb.Query)
| 1058 | |
| 1059 | // createOverlappingSeriesHandler creates responses with same series from multiple queries. |
| 1060 | func createOverlappingSeriesHandler(t *testing.T, queries []*prompb.Query) http.HandlerFunc { |
| 1061 | return http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { |
| 1062 | w.Header().Set("Content-Type", "application/x-streamed-protobuf; proto=prometheus.ChunkedReadResponse") |
| 1063 | |
| 1064 | flusher, ok := w.(http.Flusher) |
| 1065 | require.True(t, ok) |
| 1066 | |
| 1067 | cw := NewChunkedWriter(w, flusher) |
| 1068 | |
| 1069 | // Same series labels for both queries (will be merged) |
| 1070 | commonLabels := []prompb.Label{ |
| 1071 | {Name: "__name__", Value: "up"}, |
| 1072 | {Name: "job", Value: "prometheus"}, |
| 1073 | } |
| 1074 | |
| 1075 | // Send response for each query with the same series |
| 1076 | for queryIndex := range queries { |
| 1077 | chunk := buildTestChunks(t)[0] // Use first chunk with 5 samples |
| 1078 | |
| 1079 | cSeries := prompb.ChunkedSeries{ |
| 1080 | Labels: commonLabels, |
| 1081 | Chunks: []prompb.Chunk{chunk}, |
| 1082 | } |
| 1083 | |
| 1084 | readResp := prompb.ChunkedReadResponse{ |
| 1085 | ChunkedSeries: []*prompb.ChunkedSeries{&cSeries}, |
| 1086 | QueryIndex: int64(queryIndex), |
| 1087 | } |
| 1088 | |
| 1089 | b, err := proto.Marshal(&readResp) |
| 1090 | require.NoError(t, err) |
| 1091 | |
| 1092 | _, err = cw.Write(b) |
| 1093 | require.NoError(t, err) |
| 1094 | } |
| 1095 | }) |
| 1096 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…