Skip to content

Commit

Permalink
tracer: Reduce flakiness of tests (#2414)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajgajg1134 authored Dec 5, 2023
1 parent 74fc764 commit 3dc6559
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 12 deletions.
6 changes: 4 additions & 2 deletions contrib/database/sql/sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ func TestMain(m *testing.M) {
fmt.Println("--- SKIP: to enable integration test, set the INTEGRATION environment variable")
os.Exit(0)
}
defer sqltest.Prepare(tableName)()
os.Exit(m.Run())
cleanup := sqltest.Prepare(tableName)
testResult := m.Run()
cleanup()
os.Exit(testResult)
}

func TestSqlServer(t *testing.T) {
Expand Down
6 changes: 4 additions & 2 deletions contrib/gopkg.in/jinzhu/gorm.v1/gorm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ func TestMain(m *testing.M) {
fmt.Println("--- SKIP: to enable integration test, set the INTEGRATION environment variable")
os.Exit(0)
}
defer sqltest.Prepare(tableName)()
os.Exit(m.Run())
cleanup := sqltest.Prepare(tableName)
testResult := m.Run()
cleanup()
os.Exit(testResult)
}

func TestMySQL(t *testing.T) {
Expand Down
6 changes: 4 additions & 2 deletions contrib/gorm.io/gorm.v1/gorm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ func TestMain(m *testing.M) {
fmt.Println("--- SKIP: to enable integration test, set the INTEGRATION environment variable")
os.Exit(0)
}
defer sqltest.Prepare(tableName)()
os.Exit(m.Run())
cleanup := sqltest.Prepare(tableName)
testResult := m.Run()
cleanup()
os.Exit(testResult)
}

func TestMySQL(t *testing.T) {
Expand Down
6 changes: 4 additions & 2 deletions contrib/jinzhu/gorm/gorm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ func TestMain(m *testing.M) {
fmt.Println("--- SKIP: to enable integration test, set the INTEGRATION environment variable")
os.Exit(0)
}
defer sqltest.Prepare(tableName)()
os.Exit(m.Run())
cleanup := sqltest.Prepare(tableName)
testResult := m.Run()
cleanup()
os.Exit(testResult)
}

func TestSqlServer(t *testing.T) {
Expand Down
6 changes: 4 additions & 2 deletions contrib/jmoiron/sqlx/sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ func TestMain(m *testing.M) {
fmt.Println("--- SKIP: to enable integration test, set the INTEGRATION environment variable")
os.Exit(0)
}
defer sqltest.Prepare(tableName)()
os.Exit(m.Run())
cleanup := sqltest.Prepare(tableName)
testResult := m.Run()
cleanup()
os.Exit(testResult)
}

func TestMySQL(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/tracer/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ func TestReportHealthMetrics(t *testing.T) {

tracer.StartSpan("operation").Finish()
flush(1)
tg.Wait(3, 1*time.Second)
tg.Wait(3, 10*time.Second)

counts := tg.Counts()
assert.Equal(int64(1), counts["datadog.tracer.spans_started"])
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/tracer/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ func (h *agentTraceWriter) flush() {
p.clear()

<-h.climit
h.wg.Done()
h.statsd.Timing("datadog.tracer.flush_duration", time.Since(start), nil, 1)
h.wg.Done()
}(time.Now())

var count, size int
Expand Down

0 comments on commit 3dc6559

Please sign in to comment.