Skip to content

Commit ca398a9

Browse files
authored
Test example config with filesystem backend (#5072)
Signed-off-by: Friedrich Gonzalez <[email protected]> Signed-off-by: Friedrich Gonzalez <[email protected]>
1 parent ee26341 commit ca398a9

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
//go:build requires_docker
2+
// +build requires_docker
3+
4+
package integration
5+
6+
import (
7+
"testing"
8+
"time"
9+
10+
"github.com/prometheus/common/model"
11+
"github.com/prometheus/prometheus/prompb"
12+
"github.com/stretchr/testify/assert"
13+
"github.com/stretchr/testify/require"
14+
15+
"github.com/cortexproject/cortex/integration/e2e"
16+
"github.com/cortexproject/cortex/integration/e2ecortex"
17+
)
18+
19+
func TestGettingStartedSingleProcessConfigWithFilesystem(t *testing.T) {
20+
s, err := e2e.NewScenario(networkName)
21+
require.NoError(t, err)
22+
defer s.Close()
23+
24+
// Start Cortex components.
25+
require.NoError(t, copyFileToSharedDir(s, "docs/configuration/single-process-config-blocks-local.yaml", cortexConfigFile))
26+
27+
flags := map[string]string{}
28+
29+
cortex := e2ecortex.NewSingleBinaryWithConfigFile("cortex-1", cortexConfigFile, flags, "", 9009, 9095)
30+
require.NoError(t, s.StartAndWaitReady(cortex))
31+
32+
c, err := e2ecortex.NewClient(cortex.HTTPEndpoint(), cortex.HTTPEndpoint(), "", "", "user-1")
33+
require.NoError(t, err)
34+
35+
// Push some series to Cortex.
36+
now := time.Now()
37+
series, expectedVector := generateSeries("series_1", now, prompb.Label{Name: "foo", Value: "bar"})
38+
39+
res, err := c.Push(series)
40+
require.NoError(t, err)
41+
require.Equal(t, 200, res.StatusCode)
42+
43+
// Query the series.
44+
result, err := c.Query("series_1", now)
45+
require.NoError(t, err)
46+
require.Equal(t, model.ValVector, result.Type())
47+
assert.Equal(t, expectedVector, result.(model.Vector))
48+
49+
labelValues, err := c.LabelValues("foo", time.Time{}, time.Time{}, nil)
50+
require.NoError(t, err)
51+
require.Equal(t, model.LabelValues{"bar"}, labelValues)
52+
53+
labelNames, err := c.LabelNames(time.Time{}, time.Time{})
54+
require.NoError(t, err)
55+
require.Equal(t, []string{"__name__", "foo"}, labelNames)
56+
57+
// Check that a range query does not return an error to sanity check the queryrange tripperware.
58+
_, err = c.QueryRange("series_1", now.Add(-15*time.Minute), now, 15*time.Second)
59+
require.NoError(t, err)
60+
}

0 commit comments

Comments
 (0)