Skip to content

Commit d77068f

Browse files
committed
Fix tests
Signed-off-by: Justin Jung <[email protected]>
1 parent b4b6267 commit d77068f

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed
Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
//go:build requires_docker
2-
// +build requires_docker
1+
//go:build integration_querier
2+
// +build integration_querier
33

44
package integration
55

@@ -9,6 +9,8 @@ import (
99
"github.com/stretchr/testify/require"
1010

1111
"github.com/cortexproject/cortex/integration/e2e"
12+
e2edb "github.com/cortexproject/cortex/integration/e2e/db"
13+
"github.com/cortexproject/cortex/integration/e2ecortex"
1214
)
1315

1416
func Test_ResourceBasedLimiter_shouldStartWithoutError(t *testing.T) {
@@ -17,21 +19,22 @@ func Test_ResourceBasedLimiter_shouldStartWithoutError(t *testing.T) {
1719
defer s.Close()
1820

1921
flags := mergeFlags(BlocksStorageFlags(), map[string]string{
20-
"-monitored.resource": "cpu,heap",
22+
"-monitored.resources": "cpu,heap",
2123
})
2224

2325
// Start dependencies.
2426
consul := e2edb.NewConsul()
25-
require.NoError(t, s.StartAndWaitReady(consul))
27+
minio := e2edb.NewMinio(9000, flags["-blocks-storage.s3.bucket-name"])
28+
require.NoError(t, s.StartAndWaitReady(consul, minio))
2629

2730
// Start Cortex components.
2831
ingester := e2ecortex.NewIngester("ingester", e2ecortex.RingStoreConsul, consul.NetworkHTTPEndpoint(), mergeFlags(flags, map[string]string{
29-
"-ingester.instance-limits.cpu-utilization": 0.8,
30-
"-ingester.instance-limits.heap-utilization": 0.8,
32+
"-ingester.instance-limits.cpu-utilization": "0.8",
33+
"-ingester.instance-limits.heap-utilization": "0.8",
3134
}), "")
3235
storeGateway := e2ecortex.NewStoreGateway("store-gateway", e2ecortex.RingStoreConsul, consul.NetworkHTTPEndpoint(), mergeFlags(flags, map[string]string{
33-
"-store-gateway.instance-limits.cpu-utilization": 0.8,
34-
"-store-gateway.instance-limits.heap-utilization": 0.8,
36+
"-store-gateway.instance-limits.cpu-utilization": "0.8",
37+
"-store-gateway.instance-limits.heap-utilization": "0.8",
3538
}), "")
3639
require.NoError(t, s.StartAndWaitReady(ingester, storeGateway))
3740
}

pkg/cortex/modules.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,8 @@ func (t *Cortex) initResourceMonitor() (services.Service, error) {
774774
return nil, nil
775775
}
776776

777+
util_log.WarnExperimentalUse(fmt.Sprintf("resource monitor for [%s] [%v] [%v] [%v]", t.Cfg.MonitoredResources, t.Cfg.MonitoredResources, t.Cfg.MonitoredResources.String(), len(t.Cfg.MonitoredResources)))
778+
777779
containerLimits := make(map[resource.Type]float64)
778780
for _, res := range t.Cfg.MonitoredResources {
779781
switch resource.Type(res) {
@@ -788,7 +790,6 @@ func (t *Cortex) initResourceMonitor() (services.Service, error) {
788790

789791
var err error
790792
t.ResourceMonitor, err = resource.NewMonitor(containerLimits, prometheus.DefaultRegisterer)
791-
util_log.WarnExperimentalUse("resource monitor")
792793
return t.ResourceMonitor, err
793794
}
794795

@@ -797,7 +798,7 @@ func (t *Cortex) setupModuleManager() error {
797798

798799
// Register all modules here.
799800
// RegisterModule(name string, initFn func()(services.Service, error))
800-
mm.RegisterModule(ResourceMonitor, t.initResourceMonitor)
801+
mm.RegisterModule(ResourceMonitor, t.initResourceMonitor, modules.UserInvisibleModule)
801802
mm.RegisterModule(Server, t.initServer, modules.UserInvisibleModule)
802803
mm.RegisterModule(API, t.initAPI, modules.UserInvisibleModule)
803804
mm.RegisterModule(RuntimeConfig, t.initRuntimeConfig, modules.UserInvisibleModule)

pkg/util/resource/scanner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@ func newHeapScanner() (scanner, error) {
3939

4040
func (s *heapScanner) scan() (float64, error) {
4141
metrics.Read(s.metricSamples)
42-
return s.metricSamples[0].Value.Float64(), nil
42+
return float64(s.metricSamples[0].Value.Uint64()), nil
4343
}

0 commit comments

Comments
 (0)