From 2b23741b489fdc0679150689a32ab1ce8f7a2da4 Mon Sep 17 00:00:00 2001 From: Nikolai Vladimirov Date: Fri, 24 May 2024 07:03:13 +0300 Subject: [PATCH] chore: cleanup test output Raise log level to warn when running certain tests to avoid poluting the test output. --- internal/chart/chart_cmd_stage_test.go | 3 +++ internal/run/run_stage_test.go | 2 +- internal/trigger/file/file_parser_test.go | 2 ++ internal/trigger/file/file_rate.go | 4 ++-- internal/trigger/gaussian/gaussian_rate.go | 4 ++-- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/internal/chart/chart_cmd_stage_test.go b/internal/chart/chart_cmd_stage_test.go index 024aaad4..e8950123 100644 --- a/internal/chart/chart_cmd_stage_test.go +++ b/internal/chart/chart_cmd_stage_test.go @@ -6,6 +6,7 @@ import ( "testing" "time" + "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" "github.com/form3tech-oss/f1/v2/internal/console" @@ -22,6 +23,8 @@ type ChartTestStage struct { func NewChartTestStage(t *testing.T) (*ChartTestStage, *ChartTestStage, *ChartTestStage) { t.Helper() + logrus.SetLevel(logrus.WarnLevel) + stage := &ChartTestStage{ t: t, assert: assert.New(t), diff --git a/internal/run/run_stage_test.go b/internal/run/run_stage_test.go index c4089e67..d453fc18 100644 --- a/internal/run/run_stage_test.go +++ b/internal/run/run_stage_test.go @@ -241,7 +241,7 @@ func (s *RunTestStage) the_command_should_have_run_for_approx(expectedDuration t } func (s *RunTestStage) the_number_of_started_iterations_should_be(expected uint32) *RunTestStage { - s.assert.Equal(expected, s.runCount.Load(), "number of started iterations") + s.assert.Equal(int(expected), int(s.runCount.Load()), "number of started iterations") return s } diff --git a/internal/trigger/file/file_parser_test.go b/internal/trigger/file/file_parser_test.go index 2d59c494..8ca0261e 100644 --- a/internal/trigger/file/file_parser_test.go +++ b/internal/trigger/file/file_parser_test.go @@ -4,6 +4,7 @@ import ( "testing" "time" + "github.com/sirupsen/logrus" "github.com/stretchr/testify/require" ) @@ -414,6 +415,7 @@ stages: func TestFileRate_FileErrors(t *testing.T) { t.Parallel() + logrus.SetLevel(logrus.WarnLevel) for _, test := range []struct { fileContent, expectedError string diff --git a/internal/trigger/file/file_rate.go b/internal/trigger/file/file_rate.go index d605d146..15faea64 100644 --- a/internal/trigger/file/file_rate.go +++ b/internal/trigger/file/file_rate.go @@ -7,7 +7,7 @@ import ( "path/filepath" "time" - log "github.com/sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/spf13/pflag" "github.com/form3tech-oss/f1/v2/internal/trace" @@ -79,7 +79,7 @@ func readFile(filename string) (*[]byte, error) { } defer func() { if err = file.Close(); err != nil { - log.WithError(err).Error("unable to close the config file") + logrus.WithError(err).Error("unable to close the config file") } }() diff --git a/internal/trigger/gaussian/gaussian_rate.go b/internal/trigger/gaussian/gaussian_rate.go index 59518571..dc7478e6 100644 --- a/internal/trigger/gaussian/gaussian_rate.go +++ b/internal/trigger/gaussian/gaussian_rate.go @@ -7,7 +7,7 @@ import ( "strings" "time" - log "github.com/sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/spf13/pflag" "github.com/form3tech-oss/f1/v2/internal/gaussian" @@ -97,7 +97,7 @@ func Rate() api.Builder { } if peakRate != "" { if volume != defaultVolume { - log.Warn("--peak-rate is provided, the value given for --volume will be ignored") + logrus.Warn("--peak-rate is provided, the value given for --volume will be ignored") } volume, err = calculateVolume(peakRate, peakDuration, stddevDuration) if err != nil {