-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Fix sqldb/v2 regressions
#10703
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
yyforyongyu
wants to merge
14
commits into
lightningnetwork:master
Choose a base branch
from
yyforyongyu:10697-review-fixes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Fix sqldb/v2 regressions
#10703
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
4e721cc
sqldb/v2: fix postgres time rewrite
yyforyongyu 780e483
sqldb/v2: align test helper build tags
yyforyongyu dbf4db7
sqldb/v2: fix no_sqlite target builds
yyforyongyu 19ad466
sqldb/v2: enforce require ssl mode
yyforyongyu 52a3584
sqldb/v2: restore sqlite conn limit
yyforyongyu 1b98bb2
sqldb/v2: fix sqlite migration errors
yyforyongyu 3ba13ff
sqldb/v2: align test helper args
yyforyongyu 170e403
sqldb/v2: use BaseDB skip flag
yyforyongyu 2900088
sqldb/v2: add executor backend
yyforyongyu 74bc6df
sqldb/v2: drop dead retry helper
yyforyongyu 770c6ca
sqldb/v2: harden fixture names
yyforyongyu ee21573
sqldb/v2: validate migration sets
yyforyongyu 67f6e67
sqldb/v2: scope retry rollbacks
yyforyongyu 16dbe89
sqldb/v2: align sqlite idle defaults
yyforyongyu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| package sqldb | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| // TestSqliteConfigMaxConns verifies that SQLite keeps the low default | ||
| // connection limit unless the caller overrides it explicitly. | ||
| func TestSqliteConfigMaxConns(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| testCases := []struct { | ||
| name string | ||
| maxConns int | ||
| expectedConn int | ||
| }{ | ||
| { | ||
| name: "default limit", | ||
| expectedConn: DefaultSqliteMaxConns, | ||
| }, | ||
| { | ||
| name: "explicit limit", | ||
| maxConns: 7, | ||
| expectedConn: 7, | ||
| }, | ||
| } | ||
|
|
||
| for _, testCase := range testCases { | ||
| testCase := testCase | ||
|
|
||
| t.Run(testCase.name, func(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| cfg := &SqliteConfig{ | ||
| MaxConnections: testCase.maxConns, | ||
| } | ||
|
|
||
| require.Equal(t, testCase.expectedConn, cfg.MaxConns()) | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| // TestSqliteConfigMaxIdleConns verifies that SQLite defaults its idle | ||
| // connections to the open connection limit unless the caller overrides it. | ||
| func TestSqliteConfigMaxIdleConns(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| testCases := []struct { | ||
| name string | ||
| maxConns int | ||
| maxIdleConns int | ||
| expectedIdleConn int | ||
| }{ | ||
| { | ||
| name: "default idle limit", | ||
| expectedIdleConn: DefaultSqliteMaxConns, | ||
| }, | ||
| { | ||
| name: "inherits explicit open limit", | ||
| maxConns: 4, | ||
| expectedIdleConn: 4, | ||
| }, | ||
| { | ||
| name: "explicit idle limit", | ||
| maxConns: 4, | ||
| maxIdleConns: 3, | ||
| expectedIdleConn: 3, | ||
| }, | ||
| } | ||
|
|
||
| for _, testCase := range testCases { | ||
| testCase := testCase | ||
|
|
||
| t.Run(testCase.name, func(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| cfg := &SqliteConfig{ | ||
| MaxConnections: testCase.maxConns, | ||
| MaxIdleConnections: testCase.maxIdleConns, | ||
| } | ||
|
|
||
| require.Equal(t, testCase.expectedIdleConn, | ||
| cfg.MaxIdleConns()) | ||
| }) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| package sqldb | ||
|
|
||
| import ( | ||
| "context" | ||
| "database/sql" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| // testQuerier is a minimal query wrapper used to instantiate the generic | ||
| // transaction executor in tests. | ||
| type testQuerier struct { | ||
| } | ||
|
|
||
| // testBatchedQuerier is a minimal BatchedQuerier implementation used to verify | ||
| // that TransactionExecutor forwards backend identity. | ||
| type testBatchedQuerier struct { | ||
| backend BackendType | ||
| } | ||
|
|
||
| // BeginTx is a stub implementation used to satisfy the BatchedQuerier | ||
| // interface in tests. | ||
| func (t testBatchedQuerier) BeginTx(context.Context, | ||
| TxOptions) (*sql.Tx, error) { | ||
|
|
||
| return nil, nil | ||
| } | ||
|
|
||
| // Backend returns the backend type used by the test batched querier. | ||
| func (t testBatchedQuerier) Backend() BackendType { | ||
| return t.backend | ||
| } | ||
|
|
||
| // TestTransactionExecutorBackend verifies that the executor forwards the | ||
| // backend type from its batched querier. | ||
| func TestTransactionExecutorBackend(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| executor := NewTransactionExecutor[testQuerier]( | ||
| testBatchedQuerier{backend: BackendTypePostgres}, | ||
| func(*sql.Tx) testQuerier { | ||
| return testQuerier{} | ||
| }, | ||
| ) | ||
|
|
||
| require.Equal(t, BackendTypePostgres, executor.Backend()) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.