-
Notifications
You must be signed in to change notification settings - Fork 804
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Friedrich Gonzalez <friedrichg@gmail.com>
- Loading branch information
1 parent
b8fd660
commit 6bb670c
Showing
2 changed files
with
147 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
//go:build requires_docker | ||
// +build requires_docker | ||
|
||
package integration | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
"time" | ||
|
||
"github.com/prometheus/common/model" | ||
"github.com/prometheus/prometheus/prompb" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/cortexproject/cortex/integration/e2e" | ||
e2edb "github.com/cortexproject/cortex/integration/e2e/db" | ||
"github.com/cortexproject/cortex/integration/e2ecortex" | ||
) | ||
|
||
func TestOTLP(t *testing.T) { | ||
s, err := e2e.NewScenario(networkName) | ||
require.NoError(t, err) | ||
defer s.Close() | ||
|
||
// Start dependencies. | ||
minio := e2edb.NewMinio(9000, bucketName) | ||
require.NoError(t, s.StartAndWaitReady(minio)) | ||
|
||
// Start Cortex components. | ||
require.NoError(t, copyFileToSharedDir(s, "docs/configuration/single-process-config-blocks.yaml", cortexConfigFile)) | ||
|
||
// Start Cortex in single binary mode, reading the config from file and overwriting | ||
// the backend config to make it work with Minio. | ||
flags := map[string]string{ | ||
"-blocks-storage.s3.access-key-id": e2edb.MinioAccessKey, | ||
"-blocks-storage.s3.secret-access-key": e2edb.MinioSecretKey, | ||
"-blocks-storage.s3.bucket-name": bucketName, | ||
"-blocks-storage.s3.endpoint": fmt.Sprintf("%s-minio-9000:9000", networkName), | ||
"-blocks-storage.s3.insecure": "true", | ||
} | ||
|
||
cortex := e2ecortex.NewSingleBinaryWithConfigFile("cortex-1", cortexConfigFile, flags, "", 9009, 9095) | ||
require.NoError(t, s.StartAndWaitReady(cortex)) | ||
|
||
c, err := e2ecortex.NewClient(cortex.HTTPEndpoint(), cortex.HTTPEndpoint(), "", "", "user-1") | ||
require.NoError(t, err) | ||
|
||
// Push some series to Cortex. | ||
now := time.Now() | ||
series, expectedVector := generateSeries("series_1", now, prompb.Label{Name: "foo", Value: "bar"}) | ||
|
||
res, err := c.OTLP(series) | ||
require.NoError(t, err) | ||
require.Equal(t, 200, res.StatusCode) | ||
|
||
// Query the series. | ||
result, err := c.Query("series_1", now) | ||
require.NoError(t, err) | ||
require.Equal(t, model.ValVector, result.Type()) | ||
assert.Equal(t, expectedVector, result.(model.Vector)) | ||
|
||
labelValues, err := c.LabelValues("foo", time.Time{}, time.Time{}, nil) | ||
require.NoError(t, err) | ||
require.Equal(t, model.LabelValues{"bar"}, labelValues) | ||
|
||
labelNames, err := c.LabelNames(time.Time{}, time.Time{}) | ||
require.NoError(t, err) | ||
require.Equal(t, []string{"__name__", "foo"}, labelNames) | ||
|
||
// Check that a range query does not return an error to sanity check the queryrange tripperware. | ||
_, err = c.QueryRange("series_1", now.Add(-15*time.Minute), now, 15*time.Second) | ||
require.NoError(t, err) | ||
|
||
//TODO(friedrichg): test histograms | ||
} |