Skip to content
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

pessimistictest: dedicated package for pessimistic txn tests #34353

Merged
merged 21 commits into from
May 3, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix create mock store
Signed-off-by: tison <wander4096@gmail.com>
  • Loading branch information
tisonkun committed May 1, 2022
commit 67b7b2da7b576ba8e9b2cc5eac9076aee6ad588e
32 changes: 21 additions & 11 deletions pessimistictest/pessimistic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,32 +124,42 @@ func clearEtcdStorage(t *testing.T, backend kv.EtcdBackend) {
}

func createMockStoreAndSetup(t *testing.T, opts ...mockstore.MockTiKVStoreOption) (kv.Storage, func()) {
// set it to 5 seconds for testing lock resolve.
atomic.StoreUint64(&transaction.ManagedLockTTL, 5000)
transaction.PrewriteMaxBackoff = 500

var store kv.Storage
var dom *domain.Domain
var err error

if *withRealTiKV {
var d driver.TiKVDriver
config.UpdateGlobal(func(conf *config.Config) {
conf.TxnLocalLatches.Enabled = false
})
store, err := d.Open("tikv://127.0.0.1:2379?disableGC=true")
store, err = d.Open("tikv://127.0.0.1:2379?disableGC=true")
require.NoError(t, err)

clearTiKVStorage(t, store)
clearEtcdStorage(t, store.(kv.EtcdBackend))

session.ResetStoreForWithTiKVTest(store)
dom, err := session.BootstrapSession(store)
dom, err = session.BootstrapSession(store)
require.NoError(t, err)

// set it to 5 seconds for testing lock resolve.
atomic.StoreUint64(&transaction.ManagedLockTTL, 5000)
transaction.PrewriteMaxBackoff = 500
} else {
store, err = mockstore.NewMockStore(opts...)
require.NoError(t, err)
session.DisableStats4Test()
dom, err = session.BootstrapSession(store)
require.NoError(t, err)
}

return store, func() {
transaction.PrewriteMaxBackoff = 20000
dom.Close()
require.NoError(t, store.Close())
}
return store, func() {
transaction.PrewriteMaxBackoff = 20000
dom.Close()
require.NoError(t, store.Close())
}
return testkit.CreateMockStore(t, opts...)
}

func createAsyncCommitTestKit(t *testing.T, store kv.Storage) *testkit.TestKit {
Expand Down