mirror of
https://github.com/grafana/loki.git
synced 2025-08-02 03:06:14 +08:00
Add integration for SSD (read & write targets) (#6585)
* Add integration for SSD (read & write targets) * Hardcode randStringRunes to fix linter
This commit is contained in:
@ -65,7 +65,7 @@ func TestMicroServicesDeleteRequest(t *testing.T) {
|
|||||||
|
|
||||||
require.NoError(t, clu.Run())
|
require.NoError(t, clu.Run())
|
||||||
|
|
||||||
tenantID := randStringRunes(12)
|
tenantID := randStringRunes()
|
||||||
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
cliDistributor := client.New(tenantID, "", tDistributor.HTTPURL().String())
|
cliDistributor := client.New(tenantID, "", tDistributor.HTTPURL().String())
|
||||||
|
@ -52,7 +52,7 @@ func TestMicroServicesIngestQuery(t *testing.T) {
|
|||||||
|
|
||||||
require.NoError(t, clu.Run())
|
require.NoError(t, clu.Run())
|
||||||
|
|
||||||
tenantID := randStringRunes(12)
|
tenantID := randStringRunes()
|
||||||
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
cliDistributor := client.New(tenantID, "", tDistributor.HTTPURL().String())
|
cliDistributor := client.New(tenantID, "", tDistributor.HTTPURL().String())
|
||||||
|
75
integration/loki_simple_scalable_test.go
Normal file
75
integration/loki_simple_scalable_test.go
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
package integration
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/grafana/loki/integration/client"
|
||||||
|
"github.com/grafana/loki/integration/cluster"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestSimpleScalableIngestQuery(t *testing.T) {
|
||||||
|
clu := cluster.New()
|
||||||
|
defer func() {
|
||||||
|
assert.NoError(t, clu.Cleanup())
|
||||||
|
}()
|
||||||
|
|
||||||
|
var (
|
||||||
|
tRead = clu.AddComponent(
|
||||||
|
"read",
|
||||||
|
"-target=read",
|
||||||
|
)
|
||||||
|
tWrite = clu.AddComponent(
|
||||||
|
"write",
|
||||||
|
"-target=write",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
require.NoError(t, clu.Run())
|
||||||
|
|
||||||
|
tenantID := randStringRunes()
|
||||||
|
|
||||||
|
now := time.Now()
|
||||||
|
cliWrite := client.New(tenantID, "", tWrite.HTTPURL().String())
|
||||||
|
cliWrite.Now = now
|
||||||
|
cliRead := client.New(tenantID, "", tRead.HTTPURL().String())
|
||||||
|
cliRead.Now = now
|
||||||
|
|
||||||
|
t.Run("ingest logs", func(t *testing.T) {
|
||||||
|
// ingest some log lines
|
||||||
|
require.NoError(t, cliWrite.PushLogLineWithTimestamp("lineA", now.Add(-45*time.Minute), map[string]string{"job": "fake"}))
|
||||||
|
require.NoError(t, cliWrite.PushLogLineWithTimestamp("lineB", now.Add(-45*time.Minute), map[string]string{"job": "fake"}))
|
||||||
|
|
||||||
|
require.NoError(t, cliWrite.PushLogLine("lineC", map[string]string{"job": "fake"}))
|
||||||
|
require.NoError(t, cliWrite.PushLogLine("lineD", map[string]string{"job": "fake"}))
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("query", func(t *testing.T) {
|
||||||
|
resp, err := cliRead.RunRangeQuery(`{job="fake"}`)
|
||||||
|
require.NoError(t, err)
|
||||||
|
assert.Equal(t, "streams", resp.Data.ResultType)
|
||||||
|
|
||||||
|
var lines []string
|
||||||
|
for _, stream := range resp.Data.Stream {
|
||||||
|
for _, val := range stream.Values {
|
||||||
|
lines = append(lines, val[1])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert.ElementsMatch(t, []string{"lineA", "lineB", "lineC", "lineD"}, lines)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("label-names", func(t *testing.T) {
|
||||||
|
resp, err := cliRead.LabelNames()
|
||||||
|
require.NoError(t, err)
|
||||||
|
assert.ElementsMatch(t, []string{"job"}, resp)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("label-values", func(t *testing.T) {
|
||||||
|
resp, err := cliRead.LabelValues("job")
|
||||||
|
require.NoError(t, err)
|
||||||
|
assert.ElementsMatch(t, []string{"fake"}, resp)
|
||||||
|
})
|
||||||
|
}
|
@ -26,7 +26,7 @@ func TestSingleBinaryIngestQuery(t *testing.T) {
|
|||||||
|
|
||||||
require.NoError(t, clu.Run())
|
require.NoError(t, clu.Run())
|
||||||
|
|
||||||
tenantID := randStringRunes(12)
|
tenantID := randStringRunes()
|
||||||
cli := client.New(tenantID, "", tAll.HTTPURL().String())
|
cli := client.New(tenantID, "", tAll.HTTPURL().String())
|
||||||
|
|
||||||
t.Run("ingest-logs-store", func(t *testing.T) {
|
t.Run("ingest-logs-store", func(t *testing.T) {
|
||||||
|
@ -11,8 +11,8 @@ func init() {
|
|||||||
|
|
||||||
var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
||||||
|
|
||||||
func randStringRunes(n int) string {
|
func randStringRunes() string {
|
||||||
b := make([]rune, n)
|
b := make([]rune, 12)
|
||||||
for i := range b {
|
for i := range b {
|
||||||
b[i] = letterRunes[rand.Intn(len(letterRunes))]
|
b[i] = letterRunes[rand.Intn(len(letterRunes))]
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user