Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e: Fix flaky memcached test #4740

Merged
merged 1 commit into from
Oct 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/e2e/compact_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ func testCompactWithStoreGateway(t *testing.T, penaltyDedup bool) {
Insecure: true,
},
}
str, err := e2ethanos.NewStoreGW(e, "1", svcConfig, nil)
str, err := e2ethanos.NewStoreGW(e, "1", svcConfig, "")
testutil.Ok(t, err)
testutil.Ok(t, e2e.StartAndWaitReady(str))
testutil.Ok(t, str.WaitSumMetrics(e2e.Equals(float64(len(rawBlockIDs)+7)), "thanos_blocks_meta_synced"))
Expand Down
14 changes: 3 additions & 11 deletions test/e2e/e2ethanos/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/thanos-io/thanos/pkg/objstore/client"
"github.com/thanos-io/thanos/pkg/queryfrontend"
"github.com/thanos-io/thanos/pkg/receive"
storecache "github.com/thanos-io/thanos/pkg/store/cache"
)

const (
Expand Down Expand Up @@ -588,7 +587,7 @@ receivers:
return s, nil
}

func NewStoreGW(e e2e.Environment, name string, bucketConfig client.BucketConfig, cacheConfig *storecache.CachingWithBackendConfig, relabelConfig ...relabel.Config) (*e2e.InstrumentedRunnable, error) {
func NewStoreGW(e e2e.Environment, name string, bucketConfig client.BucketConfig, cacheConfig string, relabelConfig ...relabel.Config) (*e2e.InstrumentedRunnable, error) {
dir := filepath.Join(e.SharedDir(), "data", "store", name)
container := filepath.Join(ContainerSharedDir, "data", "store", name)
if err := os.MkdirAll(dir, 0750); err != nil {
Expand All @@ -604,13 +603,6 @@ func NewStoreGW(e e2e.Environment, name string, bucketConfig client.BucketConfig
if err != nil {
return nil, errors.Wrapf(err, "generate store relabel file: %v", relabelConfig)
}
cacheConfigBytes := []byte{}
if cacheConfig != nil {
cacheConfigBytes, err = yaml.Marshal(*cacheConfig)
if err != nil {
return nil, errors.Wrapf(err, "generate cache config file: %v", *cacheConfig)
}
}

args := e2e.BuildArgs(map[string]string{
"--debug.name": fmt.Sprintf("store-gw-%v", name),
Expand All @@ -628,8 +620,8 @@ func NewStoreGW(e e2e.Environment, name string, bucketConfig client.BucketConfig
"--consistency-delay": "30m",
})

if len(cacheConfigBytes) != 0 {
args = append(args, "--store.caching-bucket.config", string(cacheConfigBytes))
if cacheConfig != "" {
args = append(args, "--store.caching-bucket.config", cacheConfig)
}

store := NewService(
Expand Down
59 changes: 19 additions & 40 deletions test/e2e/store_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package e2e_test

import (
"context"
"fmt"
"net/http"
"os"
"path"
Expand All @@ -14,6 +15,7 @@ import (

"github.com/efficientgo/e2e"
e2edb "github.com/efficientgo/e2e/db"
"github.com/efficientgo/e2e/matchers"
"github.com/go-kit/kit/log"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/pkg/labels"
Expand All @@ -22,12 +24,10 @@ import (

"github.com/thanos-io/thanos/pkg/block"
"github.com/thanos-io/thanos/pkg/block/metadata"
"github.com/thanos-io/thanos/pkg/cacheutil"
"github.com/thanos-io/thanos/pkg/objstore"
"github.com/thanos-io/thanos/pkg/objstore/client"
"github.com/thanos-io/thanos/pkg/objstore/s3"
"github.com/thanos-io/thanos/pkg/promclient"
storecache "github.com/thanos-io/thanos/pkg/store/cache"
"github.com/thanos-io/thanos/pkg/testutil"
"github.com/thanos-io/thanos/pkg/testutil/e2eutil"
"github.com/thanos-io/thanos/test/e2e/e2ethanos"
Expand All @@ -49,20 +49,13 @@ func TestStoreGateway(t *testing.T) {
memcached := e2ethanos.NewMemcached(e, "1")
testutil.Ok(t, e2e.StartAndWaitReady(memcached))

memcachedConfig := storecache.CachingWithBackendConfig{
Type: storecache.MemcachedBucketCacheProvider,
BackendConfig: cacheutil.MemcachedClientConfig{
Addresses: []string{memcached.InternalEndpoint("memcached")},
MaxIdleConnections: 100,
MaxAsyncConcurrency: 20,
MaxGetMultiConcurrency: 100,
MaxGetMultiBatchSize: 0,
Timeout: time.Minute,
MaxAsyncBufferSize: 10000,
DNSProviderUpdateInterval: 10 * time.Second,
},
ChunkSubrangeSize: 16000,
}
memcachedConfig := fmt.Sprintf(`type: MEMCACHED
config:
addresses: [%s]
blocks_iter_ttl: 0s
metafile_exists_ttl: 0s
metafile_doesnt_exist_ttl: 0s
metafile_content_ttl: 0s`, memcached.InternalEndpoint("memcached"))

s1, err := e2ethanos.NewStoreGW(
e,
Expand All @@ -77,7 +70,7 @@ func TestStoreGateway(t *testing.T) {
Insecure: true,
},
},
&memcachedConfig,
memcachedConfig,
relabel.Config{
Action: relabel.Drop,
Regex: relabel.MustNewRegexp("value2"),
Expand Down Expand Up @@ -289,20 +282,10 @@ func TestStoreGatewayMemcachedCache(t *testing.T) {
memcached := e2ethanos.NewMemcached(e, "1")
testutil.Ok(t, e2e.StartAndWaitReady(memcached))

memcachedConfig := storecache.CachingWithBackendConfig{
Type: storecache.MemcachedBucketCacheProvider,
BackendConfig: cacheutil.MemcachedClientConfig{
Addresses: []string{memcached.InternalEndpoint("memcached")},
MaxIdleConnections: 100,
MaxAsyncConcurrency: 20,
MaxGetMultiConcurrency: 100,
MaxGetMultiBatchSize: 0,
Timeout: time.Minute,
MaxAsyncBufferSize: 10000,
DNSProviderUpdateInterval: 10 * time.Second,
},
ChunkSubrangeSize: 16000,
}
memcachedConfig := fmt.Sprintf(`type: MEMCACHED
config:
addresses: [%s]
blocks_iter_ttl: 0s`, memcached.InternalEndpoint("memcached"))

s1, err := e2ethanos.NewStoreGW(
e,
Expand All @@ -317,17 +300,12 @@ func TestStoreGatewayMemcachedCache(t *testing.T) {
Insecure: true,
},
},
&memcachedConfig,
memcachedConfig,
)
testutil.Ok(t, err)
testutil.Ok(t, e2e.StartAndWaitReady(s1))

// We need Prometheus to monitor the metrics exposed by Thanos Store.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to suggest dropping this, nice 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 😄

prom, sidecar, err := e2ethanos.NewPrometheusWithSidecar(e, "1", defaultPromConfig("test", 0, "", "", s1.InternalEndpoint("http")), e2ethanos.DefaultPrometheusImage())
testutil.Ok(t, err)
testutil.Ok(t, e2e.StartAndWaitReady(prom, sidecar))

q, err := e2ethanos.NewQuerierBuilder(e, "1", s1.InternalEndpoint("grpc"), sidecar.InternalEndpoint("grpc")).Build()
q, err := e2ethanos.NewQuerierBuilder(e, "1", s1.InternalEndpoint("grpc")).Build()
testutil.Ok(t, err)
testutil.Ok(t, e2e.StartAndWaitReady(q))

Expand Down Expand Up @@ -380,7 +358,7 @@ func TestStoreGatewayMemcachedCache(t *testing.T) {
},
)

testutil.Ok(t, s1.WaitSumMetrics(e2e.Equals(0), "thanos_store_bucket_cache_operation_hits_total"))
testutil.Ok(t, s1.WaitSumMetricsWithOptions(e2e.Equals(0), []string{`thanos_store_bucket_cache_operation_hits_total`}, e2e.WithLabelMatchers(matchers.MustNewMatcher(matchers.MatchEqual, "config", "chunks"))))
})

t.Run("query with cache hit", func(t *testing.T) {
Expand All @@ -398,7 +376,8 @@ func TestStoreGatewayMemcachedCache(t *testing.T) {
},
)

testutil.Ok(t, s1.WaitSumMetrics(e2e.Greater(0), "thanos_store_bucket_cache_operation_hits_total"))
testutil.Ok(t, s1.WaitSumMetricsWithOptions(e2e.Greater(0), []string{`thanos_store_bucket_cache_operation_hits_total`}, e2e.WithLabelMatchers(matchers.MustNewMatcher(matchers.MatchEqual, "config", "chunks"))))
testutil.Ok(t, s1.WaitSumMetrics(e2e.Greater(0), "thanos_cache_memcached_hits_total"))
})

}