Skip to content

Commit

Permalink
test: add long query runtime verification (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
stepansergeevitch authored Feb 13, 2024
1 parent 7833093 commit 24ad0f2
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 11 deletions.
31 changes: 31 additions & 0 deletions connection_common_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,3 +458,34 @@ func TestConnectionPreparedStatement(t *testing.T) {
}
}
}

func TestLongQuery(t *testing.T) {
var maxValue = 0
if v0Testing {
maxValue = 250000000000
} else {
maxValue = 430000000000
}

finished_in := make(chan time.Duration, 1)
go func() {
started := time.Now()
db, err := sql.Open("firebolt", dsnSystemEngineMock)
if err != nil {
t.Errorf("failed unexpectedly with %v", err)
}
_, err = db.Query("SELECT checksum(*) FROM generate_series(1, ?)", maxValue)
if err != nil {
t.Errorf("failed to run long query %v", err)
}
finished_in <- time.Since(started)
}()
select {
case elapsed := <-finished_in:
if elapsed > 350*time.Minute {
t.Errorf("Expected execution time to be more than 350 sec but was %v sec", elapsed)
}
case <-time.After(10 * time.Minute):
t.Errorf("Long query didn't finish in 10 minutes")
}
}
13 changes: 2 additions & 11 deletions driver_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ var (
clientMockWithAccount *ClientImpl
)

const v0Testing = false

// init populates mock variables and client for integration tests
func init() {
clientIdMock = os.Getenv("CLIENT_ID")
Expand Down Expand Up @@ -271,17 +273,6 @@ func TestDriverSystemEngine(t *testing.T) {
}
}

func TestLongQuery(t *testing.T) {
db, err := sql.Open("firebolt", dsnSystemEngineMock)
if err != nil {
t.Errorf("failed unexpectedly with %v", err)
}
_, err = db.Query("SELECT checksum(*) FROM generate_series(1, 100000000000)")
if err != nil {
t.Errorf("failed to run long query %v", err)
}
}

func containsDatabase(rows *sql.Rows, databaseToFind string) (bool, error) {
var databaseName, region, attachedEngines, createdOn, createdBy, errors string
for rows.Next() {
Expand Down
2 changes: 2 additions & 0 deletions driver_integration_v0_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ var (
clientMock *ClientImplV0
)

const v0Testing = true

// init populates mock variables and client for integration tests
func init() {
usernameMock = os.Getenv("USER_NAME")
Expand Down

0 comments on commit 24ad0f2

Please sign in to comment.