github.com/thanos-io/thanos@v0.32.5/pkg/store/cache/factory_test.go (about)

     1  // Copyright (c) The Thanos Authors.
     2  // Licensed under the Apache License 2.0.
     3  
     4  package storecache
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/efficientgo/core/testutil"
    10  	"github.com/go-kit/log"
    11  	"github.com/prometheus/client_golang/prometheus"
    12  )
    13  
    14  func TestIndexCacheMetrics(t *testing.T) {
    15  	reg := prometheus.NewRegistry()
    16  	commonMetrics := newCommonMetrics(reg)
    17  
    18  	memcached := newMockedMemcachedClient(nil)
    19  	_, err := NewRemoteIndexCache(log.NewNopLogger(), memcached, commonMetrics, reg)
    20  	testutil.Ok(t, err)
    21  	conf := []byte(`
    22  max_size: 10MB
    23  max_item_size: 1MB
    24  `)
    25  	// Make sure that the in memory cache does not register the same metrics of the remote index cache.
    26  	// If so, we should move those metrics to the `commonMetrics`
    27  	_, err = NewInMemoryIndexCache(log.NewNopLogger(), commonMetrics, reg, conf)
    28  	testutil.Ok(t, err)
    29  }