integration-tests/go-sql-server-driver: PR feedback.

This commit is contained in:
Aaron Son
2025-03-24 17:52:53 -07:00
parent 7bde4e7198
commit fdb00a3853
3 changed files with 58 additions and 56 deletions

View File

@@ -111,6 +111,21 @@ func (gct gcTest) createDB(t *testing.T, ctx context.Context, db *sql.DB) {
require.NoError(t, err)
}
// When running with kill_connections GC safepoints, asserts that the
// error we got is not an error that was not allowed.
func assertExpectedGCError(t *testing.T, err error) bool {
if !assert.NotContains(t, err.Error(), "dangling ref") {
return false
}
if !assert.NotContains(t, err.Error(), "is unexpected noms value") {
return false
}
if !assert.NotContains(t, err.Error(), "interface conversion: types.Value is nil") {
return false
}
return true
}
func (gct gcTest) doUpdate(t *testing.T, ctx context.Context, db *sql.DB, i int) error {
conn, err := db.Conn(ctx)
if gct.sessionAware {
@@ -123,6 +138,7 @@ func (gct gcTest) doUpdate(t *testing.T, ctx context.Context, db *sql.DB, i int)
return nil
}
defer conn.Close()
tx, err := conn.BeginTx(ctx, nil)
if gct.sessionAware {
assert.NoError(t, err)
@@ -136,50 +152,36 @@ func (gct gcTest) doUpdate(t *testing.T, ctx context.Context, db *sql.DB, i int)
if gct.sessionAware {
assert.NoError(t, err)
} else if err != nil {
if !assert.NotContains(t, err.Error(), "dangling ref") {
return err
}
if !assert.NotContains(t, err.Error(), "is unexpected noms value") {
return err
}
if !assert.NotContains(t, err.Error(), "interface conversion: types.Value is nil") {
if !assertExpectedGCError(t, err) {
return err
}
t.Logf("err in Exec update: %v", err)
}
if err == nil {
if gct.commit {
_, err = tx.ExecContext(ctx, fmt.Sprintf("call dolt_commit('-am', 'increment vals id = %d')", i))
if gct.sessionAware {
assert.NoError(t, err)
} else if err != nil {
if !assert.NotContains(t, err.Error(), "dangling ref") {
return err
}
if !assert.NotContains(t, err.Error(), "is unexpected noms value") {
return err
}
if !assert.NotContains(t, err.Error(), "interface conversion: types.Value is nil") {
return err
}
t.Logf("err in Exec call dolt_commit: %v", err)
if err != nil {
// Early return so we do not try to continue using the
// broken connection or attempt to commit something
// with no changes.
return nil
}
if gct.commit {
_, err = tx.ExecContext(ctx, fmt.Sprintf("call dolt_commit('-am', 'increment vals id = %d')", i))
if gct.sessionAware {
assert.NoError(t, err)
} else if err != nil {
if !assertExpectedGCError(t, err) {
return err
}
} else {
err = tx.Commit()
if gct.sessionAware {
assert.NoError(t, err)
} else if err != nil {
if !assert.NotContains(t, err.Error(), "dangling ref") {
return err
}
if !assert.NotContains(t, err.Error(), "is unexpected noms value") {
return err
}
if !assert.NotContains(t, err.Error(), "interface conversion: types.Value is nil") {
return err
}
t.Logf("err in tx commit: %v", err)
t.Logf("err in Exec call dolt_commit: %v", err)
}
} else {
err = tx.Commit()
if gct.sessionAware {
assert.NoError(t, err)
} else if err != nil {
if !assertExpectedGCError(t, err) {
return err
}
t.Logf("err in tx commit: %v", err)
}
}
return nil

View File

@@ -46,7 +46,7 @@ func TestGCConjoinsOldgen(t *testing.T) {
require.NoError(t, err)
server := MakeServer(t, repo, &driver.Server{
Args: []string{"--port", "{{get_port \"server\"}}"},
Args: []string{"--port", `{{get_port "server"}}`},
DynamicPort: "server",
}, &ports)
server.DBName = "concurrent_gc_test"

View File

@@ -49,7 +49,7 @@ func TestSQLServerInfoFile(t *testing.T) {
ports.global = &GlobalPorts
ports.t = t
RunServerUntilEndOfTest(t, rs, &driver.Server{
Args: []string{"--port", "{{get_port \"server_one\"}}"},
Args: []string{"--port", `{{get_port "server_one"}}`},
DynamicPort: "server_one",
}, &ports)
@@ -61,7 +61,7 @@ func TestSQLServerInfoFile(t *testing.T) {
})
t.Run("Running again in root fails", func(t *testing.T) {
_ = MakeServer(t, rs, &driver.Server{
Args: []string{"--port", "{{get_port \"server_two\"}}"},
Args: []string{"--port", `{{get_port "server_two"}}`},
DynamicPort: "server_two",
ErrorMatches: []string{
"locked by another dolt process",
@@ -70,7 +70,7 @@ func TestSQLServerInfoFile(t *testing.T) {
})
t.Run("Running in db_one fails", func(t *testing.T) {
_ = MakeServer(t, dbOne, &driver.Server{
Args: []string{"--port", "{{get_port \"server_two\"}}"},
Args: []string{"--port", `{{get_port "server_two"}}`},
DynamicPort: "server_two",
ErrorMatches: []string{
"locked by another dolt process",
@@ -122,13 +122,13 @@ func TestSQLServerInfoFile(t *testing.T) {
ports.global = &GlobalPorts
ports.t = t
RunServerUntilEndOfTest(t, dbOne, &driver.Server{
Args: []string{"--port", "{{get_port \"server_one\"}}"},
Args: []string{"--port", `{{get_port "server_one"}}`},
DynamicPort: "server_one",
}, &ports)
t.Run("Running server in root fails", func(t *testing.T) {
_ = MakeServer(t, rs, &driver.Server{
Args: []string{"--port", "{{get_port \"server_two\"}}"},
Args: []string{"--port", `{{get_port "server_two"}}`},
DynamicPort: "server_two",
ErrorMatches: []string{
"locked by another dolt process",
@@ -137,7 +137,7 @@ func TestSQLServerInfoFile(t *testing.T) {
})
t.Run("Running server in db_two succeeds", func(t *testing.T) {
RunServerUntilEndOfTest(t, dbTwo, &driver.Server{
Args: []string{"--port", "{{get_port \"server_two\"}}"},
Args: []string{"--port", `{{get_port "server_two"}}`},
DynamicPort: "server_two",
}, &ports)
})
@@ -168,7 +168,7 @@ func TestSQLServerInfoFile(t *testing.T) {
t.Run("Running server in root fails", func(t *testing.T) {
_ = MakeServer(t, rs, &driver.Server{
Args: []string{"--port", "{{get_port \"server_two\"}}"},
Args: []string{"--port", `{{get_port "server_two"}}`},
DynamicPort: "server_two",
ErrorMatches: []string{
"locked by another dolt process",
@@ -177,7 +177,7 @@ func TestSQLServerInfoFile(t *testing.T) {
})
t.Run("Running server in db_one fails", func(t *testing.T) {
_ = MakeServer(t, dbOne, &driver.Server{
Args: []string{"--port", "{{get_port \"server_two\"}}"},
Args: []string{"--port", `{{get_port "server_two"}}`},
DynamicPort: "server_two",
ErrorMatches: []string{
"locked by another dolt process",
@@ -206,7 +206,7 @@ func TestSQLServerInfoFile(t *testing.T) {
t.Run("Running server in root fails", func(t *testing.T) {
_ = MakeServer(t, rs, &driver.Server{
Args: []string{"--port", "{{get_port \"server_two\"}}"},
Args: []string{"--port", `{{get_port "server_two"}}`},
DynamicPort: "server_two",
ErrorMatches: []string{
"locked by another dolt process",
@@ -215,7 +215,7 @@ func TestSQLServerInfoFile(t *testing.T) {
})
t.Run("Running server in db_one fails", func(t *testing.T) {
_ = MakeServer(t, dbOne, &driver.Server{
Args: []string{"--port", "{{get_port \"server_two\"}}"},
Args: []string{"--port", `{{get_port "server_two"}}`},
DynamicPort: "server_two",
ErrorMatches: []string{
"locked by another dolt process",
@@ -224,7 +224,7 @@ func TestSQLServerInfoFile(t *testing.T) {
})
t.Run("Running server in db_two succeeds", func(t *testing.T) {
RunServerUntilEndOfTest(t, dbTwo, &driver.Server{
Args: []string{"--port", "{{get_port \"server_two\"}}"},
Args: []string{"--port", `{{get_port "server_two"}}`},
DynamicPort: "server_two",
}, &ports)
})
@@ -260,14 +260,14 @@ func TestSQLServerInfoFile(t *testing.T) {
t.Run("sql-server can run in root", func(t *testing.T) {
Setup(t)
RunServerUntilEndOfTest(t, rs, &driver.Server{
Args: []string{"--port", "{{get_port \"server_one\"}}"},
Args: []string{"--port", `{{get_port "server_one"}}`},
DynamicPort: "server_one",
}, &ports)
})
t.Run("sql-server can run in db_one", func(t *testing.T) {
Setup(t)
RunServerUntilEndOfTest(t, dbOne, &driver.Server{
Args: []string{"--port", "{{get_port \"server_one\"}}"},
Args: []string{"--port", `{{get_port "server_one"}}`},
DynamicPort: "server_one",
}, &ports)
})
@@ -302,14 +302,14 @@ func TestSQLServerInfoFile(t *testing.T) {
t.Run("sql-server can run in root", func(t *testing.T) {
Setup(t)
RunServerUntilEndOfTest(t, rs, &driver.Server{
Args: []string{"--port", "{{get_port \"server_one\"}}"},
Args: []string{"--port", `{{get_port "server_one"}}`},
DynamicPort: "server_one",
}, &ports)
})
t.Run("sql-server can run in db_one", func(t *testing.T) {
Setup(t)
RunServerUntilEndOfTest(t, rs, &driver.Server{
Args: []string{"--port", "{{get_port \"server_one\"}}"},
Args: []string{"--port", `{{get_port "server_one"}}`},
DynamicPort: "server_one",
}, &ports)
})
@@ -370,11 +370,11 @@ func TestSQLServerInfoFile(t *testing.T) {
ports.global = &GlobalPorts
ports.t = t
RunServerUntilEndOfTest(t, rs, &driver.Server{
Args: []string{"--port", "{{get_port \"server_one\"}}"},
Args: []string{"--port", `{{get_port "server_one"}}`},
DynamicPort: "server_one",
}, &ports)
RunServerUntilEndOfTest(t, rs, &driver.Server{
Args: []string{"--port", "{{get_port \"server_two\"}}"},
Args: []string{"--port", `{{get_port "server_two"}}`},
DynamicPort: "server_two",
}, &ports)
})