(t *testing.T)
| 1913 | } |
| 1914 | |
| 1915 | func TestDropOldTimeSeries(t *testing.T) { |
| 1916 | t.Parallel() |
| 1917 | // Test both v1 and v2 remote write protocols |
| 1918 | for _, protoMsg := range []remoteapi.WriteMessageType{remoteapi.WriteV1MessageType, remoteapi.WriteV2MessageType} { |
| 1919 | t.Run(fmt.Sprint(protoMsg), func(t *testing.T) { |
| 1920 | size := 10 |
| 1921 | nSeries := 6 |
| 1922 | nSamples := config.DefaultQueueConfig.Capacity * size |
| 1923 | noST := protoMsg == remoteapi.WriteV1MessageType // RW1 |
| 1924 | pastRecs := testwal.GenerateRecords(recCase{ |
| 1925 | NoST: noST, |
| 1926 | Series: nSeries, |
| 1927 | SamplesPerSeries: (nSamples / nSeries) / 2, // Half data is past. |
| 1928 | TsFn: func(_, j int) int64 { |
| 1929 | past := timestamp.FromTime(time.Now().Add(-5 * time.Minute)) |
| 1930 | return past + int64(j) |
| 1931 | }, |
| 1932 | }) |
| 1933 | newRecs := testwal.GenerateRecords(recCase{ |
| 1934 | NoST: noST, |
| 1935 | Series: nSeries, |
| 1936 | SamplesPerSeries: (nSamples / nSeries) / 2, // Half data is past. |
| 1937 | TsFn: func(_, j int) int64 { |
| 1938 | return time.Now().UnixMilli() + int64(j) |
| 1939 | }, |
| 1940 | }) |
| 1941 | |
| 1942 | series := pastRecs.Series // Series is the same for both old and new. |
| 1943 | newSamples := newRecs.Samples |
| 1944 | samples := append(pastRecs.Samples, newRecs.Samples...) |
| 1945 | |
| 1946 | c := NewTestWriteClient(protoMsg) |
| 1947 | c.expectSamples(newSamples, series) |
| 1948 | |
| 1949 | cfg := config.DefaultQueueConfig |
| 1950 | mcfg := config.DefaultMetadataConfig |
| 1951 | cfg.MaxShards = 1 |
| 1952 | cfg.SampleAgeLimit = model.Duration(60 * time.Second) |
| 1953 | m := newTestQueueManager(t, cfg, mcfg, defaultFlushDeadline, c, protoMsg) |
| 1954 | m.StoreSeries(series, 0) |
| 1955 | |
| 1956 | m.Start() |
| 1957 | defer m.Stop() |
| 1958 | |
| 1959 | m.Append(samples) |
| 1960 | c.waitForExpectedData(t, 30*time.Second) |
| 1961 | }) |
| 1962 | } |
| 1963 | } |
| 1964 | |
| 1965 | func TestIsSampleOld(t *testing.T) { |
| 1966 | currentTime := time.Now() |
nothing calls this directly
no test coverage detected
searching dependent graphs…