Skip to content

Commit

Permalink
test: Integration test fix for engines v2 (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
ptiurin authored Jun 4, 2024
1 parent 1669382 commit dda746b
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 22 deletions.
1 change: 0 additions & 1 deletion .github/workflows/integration-tests-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ jobs:
firebolt-client-secret: ${{ secrets.FIREBOLT_CLIENT_SECRET_STG_NEW_IDN}}
api-endpoint: "api.staging.firebolt.io"
account: ${{ vars.FIREBOLT_ACCOUNT_V1 }}
instance-type: "B2"

- name: Run integration tests
env:
Expand Down
4 changes: 3 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"errors"
"fmt"
"strings"
)

type ClientImpl struct {
Expand Down Expand Up @@ -221,7 +222,8 @@ func (c *ClientImpl) getConnectionParametersV1(
if err != nil {
return "", params, ConstructNestedError("error during getting engine info", err)
}
if status != engineStatusRunning {
// Case-insensitive comparison
if !strings.EqualFold(status, engineStatusRunning) {
return "", params, fmt.Errorf("engine %s is not running", engineName)
}
if len(dbName) == 0 {
Expand Down
9 changes: 3 additions & 6 deletions client_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package fireboltgosdk

import (
"context"
"strings"
"testing"
"time"
)
Expand All @@ -19,20 +20,16 @@ func TestGetEnginePropsByName(t *testing.T) {
t.Errorf("Empty system engine url returned by getSystemEngineURL for account: %s", accountNameV1Mock)
}

engineURL, status, dbName, err := clientMockWithAccount.getEngineUrlStatusDBByName(context.TODO(), engineNameMock, systemEngineURL)
engineURL, status, _, err := clientMockWithAccount.getEngineUrlStatusDBByName(context.TODO(), engineNameMock, systemEngineURL)
if err != nil {
t.Errorf("Error returned by getEngineUrlStatusDBByName: %s", err)
}
if engineURL == "" {
t.Errorf("Empty engine url returned by getEngineUrlStatusDBByName")
}
if status != "Running" {
if !strings.EqualFold(status, "Running") {
t.Errorf("Invalid status returned by getEngineUrlStatusDBByName. Got: %s, should be Running", status)
}
if dbName != databaseMock {
t.Errorf("Invalid database returned by getEngineUrlStatusDBByName: expected %s, got %s", databaseMock, dbName)
}

}

// TestQuery tests simple query
Expand Down
5 changes: 3 additions & 2 deletions connection_common_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,8 @@ func TestConnectionPreparedStatement(t *testing.T) {

assert(dest[0], int32(1), t, "int32 results are not equal")
assert(dest[1], int64(2), t, "int64 results are not equal")
assert(dest[2], float32(0.333333), t, "float32 results are not equal")
// float is now alias for double so both 32 an 64 bit float values are converted to float64
assert(dest[2], 0.333333, t, "float32 results are not equal")
assert(dest[3], 0.333333333333, t, "float64 results are not equal")
assert(dest[4], "text", t, "string results are not equal")
assert(dest[5], d, t, "date results are not equal")
Expand All @@ -460,7 +461,7 @@ func TestConnectionPreparedStatement(t *testing.T) {
}

func TestLongQuery(t *testing.T) {
var maxValue = 400000000000
var maxValue = 450000000000

finished_in := make(chan time.Duration, 1)
go func() {
Expand Down
16 changes: 6 additions & 10 deletions connection_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ func cleanupEngineAndDatabase(t *testing.T) {
}

func TestConnectionUseDatabase(t *testing.T) {
// tableName := "test_use_database"
// createTableSQL := "CREATE TABLE IF NOT EXISTS " + tableName + " (id INT)"
// selectTableSQL := "SELECT table_name FROM information_schema.tables WHERE table_name = ?"
tableName := "test_use_database"
createTableSQL := "CREATE TABLE IF NOT EXISTS " + tableName + " (id INT)"
selectTableSQL := "SELECT table_name FROM information_schema.tables WHERE table_name = ?"
useDatabaseSQL := "USE DATABASE "
// newDatabaseName := databaseMock + "_new"
newDatabaseName := databaseMock + "_new"

conn, err := sql.Open("firebolt", dsnMock)
if err != nil {
Expand All @@ -60,12 +60,8 @@ func TestConnectionUseDatabase(t *testing.T) {
}

_, err = conn.ExecContext(context.Background(), useDatabaseSQL+databaseMock)
if err == nil {
t.Errorf("use database works on a user engine. The test can be enabled")
t.FailNow()
}

/*if err != nil {
if err != nil {
t.Errorf("use database statement failed with %v", err)
t.FailNow()
}
Expand Down Expand Up @@ -108,7 +104,7 @@ func TestConnectionUseDatabase(t *testing.T) {
if rows.Next() {
t.Errorf("use database statement didn't update the database")
t.FailNow()
}*/
}
}

func TestConnectionV2(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions driver_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,7 @@ func TestDriverSystemEngine(t *testing.T) {
}
ddlStatements := []string{
fmt.Sprintf("CREATE DATABASE \"%s\"", databaseName),
fmt.Sprintf("CREATE ENGINE \"%s\" WITH SPEC = 'C1' SCALE = 1", engineName),
fmt.Sprintf("ATTACH ENGINE \"%s\" TO \"%s\"", engineName, databaseName),
fmt.Sprintf("CREATE ENGINE \"%s\" WITH TYPE = S NODES = 1 AUTO_START = false", engineName),
fmt.Sprintf("ALTER DATABASE \"%s\" SET DESCRIPTION = 'GO SDK Integration test'", databaseName),
fmt.Sprintf("ALTER ENGINE \"%s\" RENAME TO %s", engineName, engineNewName),
fmt.Sprintf("START ENGINE \"%s\"", engineNewName),
Expand Down

0 comments on commit dda746b

Please sign in to comment.