Skip to content

Commit

Permalink
session: migrate test-infra to testify for parts of session_test (#34560
Browse files Browse the repository at this point in the history
)

Signed-off-by: tison <[email protected]>

Co-authored-by: Ti Chi Robot <[email protected]>
  • Loading branch information
tisonkun and ti-chi-bot authored May 11, 2022
1 parent dd48f2e commit 145058c
Show file tree
Hide file tree
Showing 9 changed files with 591 additions and 542 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package session_test
package server_test

import (
"runtime"
Expand Down
2 changes: 1 addition & 1 deletion session/backup_restore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestBackupAndRestore(t *testing.T) {
t.Skip("only run BR SQL integration test with tikv store")
}

store, clean := createStorage(t)
store, clean := createMockStoreAndSetup(t)
defer clean()

cfg := config.GetGlobalConfig()
Expand Down
20 changes: 10 additions & 10 deletions session/isolation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ These test cases come from the paper <A Critique of ANSI SQL Isolation Levels>.
The sign 'P0', 'P1'.... can be found in the paper. These cases will run under snapshot isolation.
*/
func TestP0DirtyWrite(t *testing.T) {
store, clean := createStorage(t)
store, clean := createMockStoreAndSetup(t)
defer clean()
session1 := testkit.NewTestKit(t, store)
session2 := testkit.NewTestKit(t, store)
Expand Down Expand Up @@ -86,7 +86,7 @@ func TestP0DirtyWrite(t *testing.T) {
}

func TestP1DirtyRead(t *testing.T) {
store, clean := createStorage(t)
store, clean := createMockStoreAndSetup(t)
defer clean()
session1 := testkit.NewTestKit(t, store)
session2 := testkit.NewTestKit(t, store)
Expand Down Expand Up @@ -136,7 +136,7 @@ func TestP1DirtyRead(t *testing.T) {
}

func TestP2NonRepeatableRead(t *testing.T) {
store, clean := createStorage(t)
store, clean := createMockStoreAndSetup(t)
defer clean()
session1 := testkit.NewTestKit(t, store)
session2 := testkit.NewTestKit(t, store)
Expand Down Expand Up @@ -207,7 +207,7 @@ func TestP2NonRepeatableRead(t *testing.T) {
}

func TestP3Phantom(t *testing.T) {
store, clean := createStorage(t)
store, clean := createMockStoreAndSetup(t)
defer clean()
session1 := testkit.NewTestKit(t, store)
session2 := testkit.NewTestKit(t, store)
Expand Down Expand Up @@ -275,7 +275,7 @@ func TestP3Phantom(t *testing.T) {
}

func TestP4LostUpdate(t *testing.T) {
store, clean := createStorage(t)
store, clean := createMockStoreAndSetup(t)
defer clean()
session1 := testkit.NewTestKit(t, store)
session2 := testkit.NewTestKit(t, store)
Expand Down Expand Up @@ -336,7 +336,7 @@ func TestP4LostUpdate(t *testing.T) {
func TestP4CLostUpdate(t *testing.T) {}

func TestA3Phantom(t *testing.T) {
store, clean := createStorage(t)
store, clean := createMockStoreAndSetup(t)
defer clean()
session1 := testkit.NewTestKit(t, store)
session2 := testkit.NewTestKit(t, store)
Expand Down Expand Up @@ -389,7 +389,7 @@ func TestA3Phantom(t *testing.T) {
}

func TestA5AReadSkew(t *testing.T) {
store, clean := createStorage(t)
store, clean := createMockStoreAndSetup(t)
defer clean()
session1 := testkit.NewTestKit(t, store)
session2 := testkit.NewTestKit(t, store)
Expand Down Expand Up @@ -454,7 +454,7 @@ func TestA5AReadSkew(t *testing.T) {
}

func TestA5BWriteSkew(t *testing.T) {
store, clean := createStorage(t)
store, clean := createMockStoreAndSetup(t)
defer clean()
session1 := testkit.NewTestKit(t, store)
session2 := testkit.NewTestKit(t, store)
Expand Down Expand Up @@ -551,7 +551,7 @@ These test cases come from the paper <Highly Available Transactions: Virtues and
for tidb, we support read-after-write on cluster level.
*/
func TestReadAfterWrite(t *testing.T) {
store, clean := createStorage(t)
store, clean := createMockStoreAndSetup(t)
defer clean()
session1 := testkit.NewTestKit(t, store)
session2 := testkit.NewTestKit(t, store)
Expand Down Expand Up @@ -604,7 +604,7 @@ func TestReadAfterWrite(t *testing.T) {
This case will do harm in Innodb, even if in snapshot isolation, but harmless in tidb.
*/
func TestPhantomReadInInnodb(t *testing.T) {
store, clean := createStorage(t)
store, clean := createMockStoreAndSetup(t)
defer clean()
session1 := testkit.NewTestKit(t, store)
session2 := testkit.NewTestKit(t, store)
Expand Down
32 changes: 16 additions & 16 deletions session/nontransactional_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
)

func TestNonTransactionalDeleteSharding(t *testing.T) {
store, clean := createStorage(t)
store, clean := createMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("set @@tidb_max_chunk_size=35")
Expand Down Expand Up @@ -70,7 +70,7 @@ func TestNonTransactionalDeleteSharding(t *testing.T) {
}

func TestNonTransactionalDeleteDryRun(t *testing.T) {
store, clean := createStorage(t)
store, clean := createMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("set @@tidb_max_chunk_size=35")
Expand All @@ -89,7 +89,7 @@ func TestNonTransactionalDeleteDryRun(t *testing.T) {
}

func TestNonTransactionalDeleteErrorMessage(t *testing.T) {
store, clean := createStorage(t)
store, clean := createMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("set @@tidb_max_chunk_size=35")
Expand Down Expand Up @@ -124,7 +124,7 @@ func TestNonTransactionalDeleteErrorMessage(t *testing.T) {
}

func TestNonTransactionalDeleteSplitOnTiDBRowID(t *testing.T) {
store, clean := createStorage(t)
store, clean := createMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("set @@tidb_max_chunk_size=35")
Expand All @@ -138,7 +138,7 @@ func TestNonTransactionalDeleteSplitOnTiDBRowID(t *testing.T) {
}

func TestNonTransactionalDeleteNull(t *testing.T) {
store, clean := createStorage(t)
store, clean := createMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("set @@tidb_max_chunk_size=35")
Expand All @@ -161,7 +161,7 @@ func TestNonTransactionalDeleteNull(t *testing.T) {
}

func TestNonTransactionalDeleteSmallBatch(t *testing.T) {
store, clean := createStorage(t)
store, clean := createMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("set @@tidb_max_chunk_size=1024")
Expand All @@ -177,7 +177,7 @@ func TestNonTransactionalDeleteSmallBatch(t *testing.T) {
}

func TestNonTransactionalDeleteShardOnGeneratedColumn(t *testing.T) {
store, clean := createStorage(t)
store, clean := createMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("set @@tidb_max_chunk_size=35")
Expand All @@ -191,7 +191,7 @@ func TestNonTransactionalDeleteShardOnGeneratedColumn(t *testing.T) {
}

func TestNonTransactionalDeleteAutoDetectShardColumn(t *testing.T) {
store, clean := createStorage(t)
store, clean := createMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("set @@tidb_max_chunk_size=35")
Expand Down Expand Up @@ -229,7 +229,7 @@ func TestNonTransactionalDeleteAutoDetectShardColumn(t *testing.T) {
}

func TestNonTransactionalDeleteInvisibleIndex(t *testing.T) {
store, clean := createStorage(t)
store, clean := createMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("set @@tidb_max_chunk_size=35")
Expand All @@ -249,7 +249,7 @@ func TestNonTransactionalDeleteInvisibleIndex(t *testing.T) {
}

func TestNonTransactionalDeleteIgnoreSelectLimit(t *testing.T) {
store, clean := createStorage(t)
store, clean := createMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("set @@tidb_max_chunk_size=35")
Expand All @@ -264,7 +264,7 @@ func TestNonTransactionalDeleteIgnoreSelectLimit(t *testing.T) {
}

func TestNonTransactionalDeleteReadStaleness(t *testing.T) {
store, clean := createStorage(t)
store, clean := createMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("set @@tidb_max_chunk_size=35")
Expand All @@ -280,7 +280,7 @@ func TestNonTransactionalDeleteReadStaleness(t *testing.T) {
}

func TestNonTransactionalDeleteCheckConstraint(t *testing.T) {
store, clean := createStorage(t)
store, clean := createMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)

Expand Down Expand Up @@ -348,7 +348,7 @@ func TestNonTransactionalDeleteCheckConstraint(t *testing.T) {
}

func TestNonTransactionalDeleteOptimizerHints(t *testing.T) {
store, clean := createStorage(t)
store, clean := createMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
Expand All @@ -361,7 +361,7 @@ func TestNonTransactionalDeleteOptimizerHints(t *testing.T) {
}

func TestNonTransactionalDeleteMultiTables(t *testing.T) {
store, clean := createStorage(t)
store, clean := createMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)

Expand All @@ -380,7 +380,7 @@ func TestNonTransactionalDeleteMultiTables(t *testing.T) {
}

func TestNonTransactionalDeleteAlias(t *testing.T) {
store, clean := createStorage(t)
store, clean := createMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)

Expand Down Expand Up @@ -423,7 +423,7 @@ func TestNonTransactionalDeleteAlias(t *testing.T) {

func TestNonTransactionalDeleteShardOnUnsupportedTypes(t *testing.T) {
// When some day the test fail because such types are supported, we can update related docs and consider remove the test.
store, clean := createStorage(t)
store, clean := createMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
Expand Down
12 changes: 6 additions & 6 deletions session/session_fail_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
)

func TestFailStatementCommitInRetry(t *testing.T) {
store, clean := createStorage(t)
store, clean := createMockStoreAndSetup(t)
defer clean()

tk := createTestKit(t, store)
Expand All @@ -47,7 +47,7 @@ func TestFailStatementCommitInRetry(t *testing.T) {
}

func TestGetTSFailDirtyState(t *testing.T) {
store, clean := createStorage(t)
store, clean := createMockStoreAndSetup(t)
defer clean()

tk := createTestKit(t, store)
Expand Down Expand Up @@ -77,7 +77,7 @@ func TestGetTSFailDirtyStateInretry(t *testing.T) {
require.NoError(t, failpoint.Disable("tikvclient/mockGetTSErrorInRetry"))
}()

store, clean := createStorage(t)
store, clean := createMockStoreAndSetup(t)
defer clean()

tk := createTestKit(t, store)
Expand All @@ -95,7 +95,7 @@ func TestGetTSFailDirtyStateInretry(t *testing.T) {
func TestKillFlagInBackoff(t *testing.T) {
// This test checks the `killed` flag is passed down to the backoffer through
// session.KVVars.
store, clean := createStorage(t)
store, clean := createMockStoreAndSetup(t)
defer clean()

tk := createTestKit(t, store)
Expand All @@ -113,7 +113,7 @@ func TestKillFlagInBackoff(t *testing.T) {
}

func TestClusterTableSendError(t *testing.T) {
store, clean := createStorage(t)
store, clean := createMockStoreAndSetup(t)
defer clean()

tk := createTestKit(t, store)
Expand All @@ -125,7 +125,7 @@ func TestClusterTableSendError(t *testing.T) {
}

func TestAutoCommitNeedNotLinearizability(t *testing.T) {
store, clean := createStorage(t)
store, clean := createMockStoreAndSetup(t)
defer clean()

tk := createTestKit(t, store)
Expand Down
Loading

0 comments on commit 145058c

Please sign in to comment.