MCPcopy Index your code
hub / github.com/prometheus/prometheus / TestMaxQuerySamples

Function TestMaxQuerySamples

promql/engine_test.go:1859–2034  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1857}
1858
1859func TestMaxQuerySamples(t *testing.T) {
1860 storage := promqltest.LoadedStorage(t, `
1861load 10s
1862 metric 1+1x100
1863 bigmetric{a="1"} 1+1x100
1864 bigmetric{a="2"} 1+1x100
1865`)
1866
1867 // These test cases should be touching the limit exactly (hence no exceeding).
1868 // Exceeding the limit will be tested by doing -1 to the MaxSamples.
1869 cases := []struct {
1870 Query string
1871 MaxSamples int
1872 Start time.Time
1873 End time.Time
1874 Interval time.Duration
1875 }{
1876 // Instant queries.
1877 {
1878 Query: "1",
1879 MaxSamples: 1,
1880 Start: time.Unix(1, 0),
1881 },
1882 {
1883 Query: "metric",
1884 MaxSamples: 1,
1885 Start: time.Unix(1, 0),
1886 },
1887 {
1888 Query: "metric[20s]",
1889 MaxSamples: 2,
1890 Start: time.Unix(10, 0),
1891 },
1892 {
1893 Query: "rate(metric[20s])",
1894 MaxSamples: 3,
1895 Start: time.Unix(10, 0),
1896 },
1897 {
1898 Query: "metric[20s:5s]",
1899 MaxSamples: 3,
1900 Start: time.Unix(10, 0),
1901 },
1902 {
1903 Query: "metric[20s] @ 10",
1904 MaxSamples: 2,
1905 Start: time.Unix(0, 0),
1906 },
1907 // Range queries.
1908 {
1909 Query: "1",
1910 MaxSamples: 3,
1911 Start: time.Unix(0, 0),
1912 End: time.Unix(2, 0),
1913 Interval: time.Second,
1914 },
1915 {
1916 Query: "1",

Callers

nothing calls this directly

Calls 9

ExecMethod · 0.95
StatsMethod · 0.95
LoadedStorageFunction · 0.92
NewTestEngineFunction · 0.92
ErrTooManySamplesTypeAlias · 0.92
newTestEngineFunction · 0.85
RunMethod · 0.65
NewInstantQueryMethod · 0.65
NewRangeQueryMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…