MCPcopy
hub / github.com/pingcap/tidb / TestTheSessionIsoation

Function TestTheSessionIsoation

br/pkg/gluetidb/glue_test.go:30–103  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

28)
29
30func TestTheSessionIsoation(t *testing.T) {
31 req := require.New(t)
32 store, dom := session.CreateStoreAndBootstrap(t)
33 ctx := context.Background()
34
35 // we want to test glue start domain explicitly, so close it first.
36 dom.Close()
37 g := New()
38 glueSe, err := g.CreateSession(store)
39 req.NoError(err)
40 t.Cleanup(func() {
41 existDom, _ := session.GetDomain(nil)
42 if existDom != nil {
43 existDom.Close()
44 }
45 })
46
47 require.NoError(t, glueSe.CreateDatabase(ctx, &model.DBInfo{
48 Name: pmodel.NewCIStr("test_db"),
49 }))
50 tk := testkit.NewTestKit(t, store)
51 tk.MustExec("use test_db")
52 tk.MustExec("create table t(id int)")
53
54 req.NoError(glueSe.ExecuteInternal(ctx, "use test;"))
55 infos := []*model.TableInfo{}
56 infos = append(infos, &model.TableInfo{
57 Name: pmodel.NewCIStr("tables_1"),
58 Columns: []*model.ColumnInfo{
59 {Name: pmodel.NewCIStr("foo"), FieldType: *types.NewFieldType(types.KindBinaryLiteral), State: model.StatePublic},
60 },
61 })
62 infos = append(infos, &model.TableInfo{
63 Name: pmodel.NewCIStr("tables_2"),
64 PlacementPolicyRef: &model.PolicyRefInfo{
65 Name: pmodel.NewCIStr("threereplication"),
66 },
67 Columns: []*model.ColumnInfo{
68 {Name: pmodel.NewCIStr("foo"), FieldType: *types.NewFieldType(types.KindBinaryLiteral), State: model.StatePublic},
69 },
70 })
71 infos = append(infos, &model.TableInfo{
72 Name: pmodel.NewCIStr("tables_3"),
73 PlacementPolicyRef: &model.PolicyRefInfo{
74 Name: pmodel.NewCIStr("fivereplication"),
75 },
76 Columns: []*model.ColumnInfo{
77 {Name: pmodel.NewCIStr("foo"), FieldType: *types.NewFieldType(types.KindBinaryLiteral), State: model.StatePublic},
78 },
79 })
80 polices := []*model.PolicyInfo{
81 {
82 PlacementSettings: &model.PlacementSettings{
83 Followers: 4,
84 },
85 Name: pmodel.NewCIStr("fivereplication"),
86 },
87 {

Callers

nothing calls this directly

Calls 15

MustExecMethod · 0.95
CreateStoreAndBootstrapFunction · 0.92
GetDomainFunction · 0.92
NewTestKitFunction · 0.92
NewFieldTypeFunction · 0.92
NewFunction · 0.70
NewMethod · 0.65
CloseMethod · 0.65
CreateSessionMethod · 0.65
CleanupMethod · 0.65
CreateDatabaseMethod · 0.65
ExecuteInternalMethod · 0.65

Tested by

no test coverage detected