Skip to content

Commit

Permalink
Stop module after smokes (#7909)
Browse files Browse the repository at this point in the history
  • Loading branch information
johannaratliff authored Apr 17, 2024
1 parent 555e5e5 commit dea4445
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
9 changes: 7 additions & 2 deletions cmd/mimir-continuous-test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ package main

import (
"context"
"errors"
"flag"
"fmt"
"os"

"github.com/go-kit/log/level"
"github.com/grafana/dskit/flagext"
"github.com/grafana/dskit/log"
"github.com/grafana/dskit/modules"
"github.com/grafana/dskit/tracing"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/collectors"
Expand Down Expand Up @@ -74,8 +76,11 @@ func main() {
m := continuoustest.NewManager(cfg.Manager, logger)
m.AddTest(continuoustest.NewWriteReadSeriesTest(cfg.WriteReadSeriesTest, client, logger, registry))
if err := m.Run(context.Background()); err != nil {
level.Error(logger).Log("msg", "Failed to run continuous test", "err", err.Error())
if !errors.Is(err, modules.ErrStopProcess) {
level.Error(logger).Log("msg", "Failed to run continuous test", "err", err.Error())
util_log.Flush()
os.Exit(1)
}
util_log.Flush()
os.Exit(1)
}
}
7 changes: 6 additions & 1 deletion pkg/continuoustest/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/grafana/dskit/modules"
"golang.org/x/sync/errgroup"
)

Expand Down Expand Up @@ -92,5 +93,9 @@ func (m *Manager) Run(ctx context.Context) error {
})
}

return group.Wait()
err := group.Wait()
if err == nil && m.cfg.SmokeTest {
err = modules.ErrStopProcess
}
return err
}
3 changes: 2 additions & 1 deletion pkg/continuoustest/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

"github.com/go-kit/log"
"github.com/grafana/dskit/modules"
"github.com/pkg/errors"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -72,7 +73,7 @@ func TestManager_SmokeTest(t *testing.T) {
defer cancel()
err := manager.Run(ctx)

require.NoError(t, err)
require.EqualError(t, err, modules.ErrStopProcess.Error())
require.Equal(t, dummyTest.runs, 1)
})

Expand Down
1 change: 1 addition & 0 deletions pkg/mimir/mimir.go
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,7 @@ func (t *Mimir) setupObjstoreTracing() {
// Run starts Mimir running, and blocks until a Mimir stops.
func (t *Mimir) Run() error {
mimirpb.TimeseriesUnmarshalCachingEnabled = t.Cfg.TimeseriesUnmarshalCachingOptimizationEnabled
defer util_log.Flush()

// Register custom process metrics.
if c, err := process.NewProcessCollector(); err == nil {
Expand Down

0 comments on commit dea4445

Please sign in to comment.