diff --git a/contrib/database/sql/sql_test.go b/contrib/database/sql/sql_test.go index c92e2517b1..686dbb6240 100644 --- a/contrib/database/sql/sql_test.go +++ b/contrib/database/sql/sql_test.go @@ -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) { diff --git a/contrib/gopkg.in/jinzhu/gorm.v1/gorm_test.go b/contrib/gopkg.in/jinzhu/gorm.v1/gorm_test.go index cd0350f78c..91b24eba01 100644 --- a/contrib/gopkg.in/jinzhu/gorm.v1/gorm_test.go +++ b/contrib/gopkg.in/jinzhu/gorm.v1/gorm_test.go @@ -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) { diff --git a/contrib/gorm.io/gorm.v1/gorm_test.go b/contrib/gorm.io/gorm.v1/gorm_test.go index 0b3a9ea28a..46263512a8 100644 --- a/contrib/gorm.io/gorm.v1/gorm_test.go +++ b/contrib/gorm.io/gorm.v1/gorm_test.go @@ -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) { diff --git a/contrib/jinzhu/gorm/gorm_test.go b/contrib/jinzhu/gorm/gorm_test.go index 2c7b07f812..cfaf091185 100644 --- a/contrib/jinzhu/gorm/gorm_test.go +++ b/contrib/jinzhu/gorm/gorm_test.go @@ -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) { diff --git a/contrib/jmoiron/sqlx/sql_test.go b/contrib/jmoiron/sqlx/sql_test.go index 54322f839a..8b1e7d0ce2 100644 --- a/contrib/jmoiron/sqlx/sql_test.go +++ b/contrib/jmoiron/sqlx/sql_test.go @@ -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) { diff --git a/ddtrace/tracer/metrics_test.go b/ddtrace/tracer/metrics_test.go index 12c58c2239..e976e00d63 100644 --- a/ddtrace/tracer/metrics_test.go +++ b/ddtrace/tracer/metrics_test.go @@ -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"]) diff --git a/ddtrace/tracer/writer.go b/ddtrace/tracer/writer.go index a4665bddb5..a4c56e0c90 100644 --- a/ddtrace/tracer/writer.go +++ b/ddtrace/tracer/writer.go @@ -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