Skip to content

Commit ecbd88e

Browse files
authored
Merge pull request #42 from grafana/fix-integration-tests
fix integration test backoff / limit
2 parents 53102e9 + 9db9364 commit ecbd88e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

query_integration_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"database/sql"
66
"errors"
7+
"log"
78
"os"
89
"strings"
910
"testing"
@@ -53,20 +54,19 @@ func TestQuery_MySQL(t *testing.T) {
5354
// Attempt to connect multiple times because these tests are ran in Drone, where the mysql server may not be immediately available when this test is ran.
5455
limit := 10
5556
for i := 0; i < limit; i++ {
57+
log.Println("Attempting mysql connection...")
5658
d, err := sql.Open("mysql", args.MySQLURL)
5759
if err == nil {
58-
db = d
59-
break
60+
if err := d.Ping(); err == nil {
61+
db = d
62+
break
63+
}
6064
}
6165

6266
<-ticker.C
6367
}
6468
defer db.Close()
6569

66-
if err := db.Ping(); err != nil {
67-
t.Fatal(err)
68-
}
69-
7070
t.Run("The query should return a context.Canceled if it exceeds the timeout", func(t *testing.T) {
7171
ctx, cancel := context.WithTimeout(ctx, time.Second)
7272
defer cancel()

0 commit comments

Comments
 (0)