diff --git a/cmd/agent/app/agent_test.go b/cmd/agent/app/agent_test.go index e11e88e2769..0cd3cb08d48 100644 --- a/cmd/agent/app/agent_test.go +++ b/cmd/agent/app/agent_test.go @@ -44,9 +44,7 @@ func TestAgentSamplingEndpoint(t *testing.T) { } select { case err := <-errorch: - if err != nil { - t.Fatalf("error from agent: %s", err) - } + require.NoError(t, err, "error from agent") break wait_loop default: time.Sleep(time.Millisecond) @@ -155,9 +153,7 @@ func TestStartStopRace(t *testing.T) { // Before the bug was fixed this test was failing as expected when // run with -race flag. - if err := agent.Run(); err != nil { - t.Fatalf("error from agent.Run(): %s", err) - } + require.NoError(t, agent.Run()) t.Log("stopping agent") agent.Stop() @@ -192,9 +188,7 @@ func TestStartStopWithSocketBufferSet(t *testing.T) { agent, err := cfg.CreateAgent(fakeCollectorProxy{}, zap.NewNop(), metricsFactory) require.NoError(t, err) - if err := agent.Run(); err != nil { - t.Fatalf("error from agent.Run(): %s", err) - } + require.NoError(t, agent.Run()) t.Log("stopping agent") agent.Stop() diff --git a/internal/metrics/prometheus/factory_test.go b/internal/metrics/prometheus/factory_test.go index 6acede6b73f..e4531d12a3e 100644 --- a/internal/metrics/prometheus/factory_test.go +++ b/internal/metrics/prometheus/factory_test.go @@ -401,9 +401,7 @@ func findMetric(t *testing.T, snapshot []*promModel.MetricFamily, name string, t continue } for _, m := range mf.GetMetric() { - if len(m.GetLabel()) != len(tags) { - t.Fatalf("Mismatching labels for metric %v: want %v, have %v", name, tags, m.GetLabel()) - } + require.Lenf(t, m.GetLabel(), len(tags), "Mismatching labels for metric %v: want %v, have %v", name, tags, m.GetLabel()) match := true for _, l := range m.GetLabel() { if v, ok := tags[l.GetName()]; !ok || v != l.GetValue() { diff --git a/pkg/gogocodec/codec_test.go b/pkg/gogocodec/codec_test.go index 9349e74c62f..5b9d3c5741a 100644 --- a/pkg/gogocodec/codec_test.go +++ b/pkg/gogocodec/codec_test.go @@ -97,9 +97,7 @@ func BenchmarkCodecUnmarshal25Spans(b *testing.B) { for i := 0; i < b.N; i++ { var trace model.Trace err := c.Unmarshal(bytes, &trace) - if err != nil { - b.Fatal(err) - } + require.NoError(b, err) } } diff --git a/plugin/storage/integration/elasticsearch_test.go b/plugin/storage/integration/elasticsearch_test.go index 57b0d8a1ed8..5aae3614262 100644 --- a/plugin/storage/integration/elasticsearch_test.go +++ b/plugin/storage/integration/elasticsearch_test.go @@ -156,9 +156,7 @@ func healthCheck() error { func testElasticsearchStorage(t *testing.T, allTagsAsFields bool) { SkipUnlessEnv(t, "elasticsearch", "opensearch") - if err := healthCheck(); err != nil { - t.Fatal(err) - } + require.NoError(t, healthCheck()) s := &ESStorageIntegration{ StorageIntegration: StorageIntegration{ Fixtures: LoadAndParseQueryTestCases(t, "fixtures/queries_es.json"), @@ -182,9 +180,7 @@ func TestElasticsearchStorage_AllTagsAsObjectFields(t *testing.T) { func TestElasticsearchStorage_IndexTemplates(t *testing.T) { SkipUnlessEnv(t, "elasticsearch", "opensearch") - if err := healthCheck(); err != nil { - t.Fatal(err) - } + require.NoError(t, healthCheck()) s := &ESStorageIntegration{} s.initializeES(t, true) esVersion, err := s.getVersion()