(t *testing.T)
| 1875 | } |
| 1876 | |
| 1877 | func TestHeadDeleteSimple(t *testing.T) { |
| 1878 | buildSmpls := func(s []int64) []sample { |
| 1879 | ss := make([]sample, 0, len(s)) |
| 1880 | for _, t := range s { |
| 1881 | ss = append(ss, sample{t: t, f: float64(t)}) |
| 1882 | } |
| 1883 | return ss |
| 1884 | } |
| 1885 | smplsAll := buildSmpls([]int64{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}) |
| 1886 | lblDefault := labels.Label{Name: "a", Value: "b"} |
| 1887 | lblsDefault := labels.FromStrings("a", "b") |
| 1888 | |
| 1889 | cases := []struct { |
| 1890 | dranges tombstones.Intervals |
| 1891 | addSamples []sample // Samples to add after delete. |
| 1892 | smplsExp []sample |
| 1893 | }{ |
| 1894 | { |
| 1895 | dranges: tombstones.Intervals{{Mint: 0, Maxt: 3}}, |
| 1896 | smplsExp: buildSmpls([]int64{4, 5, 6, 7, 8, 9}), |
| 1897 | }, |
| 1898 | { |
| 1899 | dranges: tombstones.Intervals{{Mint: 1, Maxt: 3}}, |
| 1900 | smplsExp: buildSmpls([]int64{0, 4, 5, 6, 7, 8, 9}), |
| 1901 | }, |
| 1902 | { |
| 1903 | dranges: tombstones.Intervals{{Mint: 1, Maxt: 3}, {Mint: 4, Maxt: 7}}, |
| 1904 | smplsExp: buildSmpls([]int64{0, 8, 9}), |
| 1905 | }, |
| 1906 | { |
| 1907 | dranges: tombstones.Intervals{{Mint: 1, Maxt: 3}, {Mint: 4, Maxt: 700}}, |
| 1908 | smplsExp: buildSmpls([]int64{0}), |
| 1909 | }, |
| 1910 | { // This case is to ensure that labels and symbols are deleted. |
| 1911 | dranges: tombstones.Intervals{{Mint: 0, Maxt: 9}}, |
| 1912 | smplsExp: buildSmpls([]int64{}), |
| 1913 | }, |
| 1914 | { |
| 1915 | dranges: tombstones.Intervals{{Mint: 1, Maxt: 3}}, |
| 1916 | addSamples: buildSmpls([]int64{11, 13, 15}), |
| 1917 | smplsExp: buildSmpls([]int64{0, 4, 5, 6, 7, 8, 9, 11, 13, 15}), |
| 1918 | }, |
| 1919 | { |
| 1920 | // After delete, the appended samples in the deleted range should be visible |
| 1921 | // as the tombstones are clamped to head min/max time. |
| 1922 | dranges: tombstones.Intervals{{Mint: 7, Maxt: 20}}, |
| 1923 | addSamples: buildSmpls([]int64{11, 13, 15}), |
| 1924 | smplsExp: buildSmpls([]int64{0, 1, 2, 3, 4, 5, 6, 11, 13, 15}), |
| 1925 | }, |
| 1926 | } |
| 1927 | |
| 1928 | for _, compress := range []compression.Type{compression.None, compression.Snappy, compression.Zstd} { |
| 1929 | t.Run(fmt.Sprintf("compress=%s", compress), func(t *testing.T) { |
| 1930 | for _, c := range cases { |
| 1931 | head, w := newTestHead(t, 1000, compress, false) |
| 1932 | require.NoError(t, head.Init(0)) |
| 1933 | |
| 1934 | app := head.Appender(context.Background()) |
nothing calls this directly
no test coverage detected
searching dependent graphs…