Skip to content

Commit 3379d57

Browse files
test: run multiple workflows
Signed-off-by: Harshit Gangal <[email protected]>
1 parent e75333d commit 3379d57

File tree

2 files changed

+56
-15
lines changed

2 files changed

+56
-15
lines changed

go/test/endtoend/vtgate/routing/main_test.go

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"context"
2121
_ "embed"
2222
"flag"
23+
"fmt"
2324
"os"
2425
"testing"
2526
"time"
@@ -42,6 +43,8 @@ var (
4243

4344
//go:embed schema.sql
4445
SchemaSQL string
46+
47+
tables = []string{"t1", "t2", "t3", "t4", "t5"}
4548
)
4649

4750
func TestMain(m *testing.M) {
@@ -100,19 +103,26 @@ func TestQueriesWithRoutingRules(t *testing.T) {
100103
}()
101104
startQueries(t, ctx)
102105

103-
workflow := "TestQueriesWithRoutingRules"
104-
mtw := cluster.NewMoveTables(t, clusterInstance, workflow, tks, sks, "t1", nil)
105-
out, err := mtw.Create()
106-
t.Logf("movetables created: %s", out)
107-
require.NoError(t, err)
106+
mtws := make([]*cluster.MoveTablesWorkflow, 0, len(tables))
107+
for _, table := range tables {
108+
workflow := "TestQueriesWithRoutingRules_" + table
109+
mtw := cluster.NewMoveTables(t, clusterInstance, workflow, tks, sks, table, nil)
110+
mtws = append(mtws, mtw)
111+
out, err := mtw.Create()
112+
t.Logf("movetables created: %s", out)
113+
require.NoError(t, err)
114+
}
108115

109-
mtw.WaitForVreplCatchup(5 * time.Second)
110-
t.Logf("movetables catchup phase completed")
116+
for i, mtw := range mtws {
117+
mtw.WaitForVreplCatchup(5 * time.Second)
118+
t.Logf("%s catchup phase completed", tables[i])
119+
}
111120

112-
time.Sleep(2 * time.Second)
113-
out, err = mtw.SwitchReads()
114-
t.Logf("movetables switch reads: %v", out)
115-
require.NoError(t, err)
121+
for _, mtw := range mtws {
122+
out, err := mtw.SwitchReads()
123+
t.Logf("switch reads: %v", out)
124+
require.NoError(t, err)
125+
}
116126
}
117127

118128
func startQueries(t *testing.T, ctx context.Context) {
@@ -124,14 +134,16 @@ func startQueries(t *testing.T, ctx context.Context) {
124134
conns = append(conns, conn)
125135
}
126136

127-
query := "select * from t1"
128-
for _, conn := range conns {
129-
go func(conn *mysql.Conn) {
137+
queryTemp := "select * from %s"
138+
for idx, conn := range conns {
139+
go func(i int, conn *mysql.Conn) {
130140
defer conn.Close()
131141
if _, err := conn.ExecuteFetch("use @replica", 1000, true); err != nil {
132142
t.Logf("error in use @primary: (%d, %v)", conn.ID(), err)
133143
}
144+
query := fmt.Sprintf(queryTemp, tables[i%len(tables)])
134145
for {
146+
// t.Logf("query: %s", query)
135147
if ctx.Err() != nil {
136148
return
137149
}
@@ -146,6 +158,6 @@ func startQueries(t *testing.T, ctx context.Context) {
146158
}
147159
// time.Sleep(10 * time.Millisecond)
148160
}
149-
}(conn)
161+
}(idx, conn)
150162
}
151163
}

go/test/endtoend/vtgate/routing/schema.sql

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,33 @@
11
create table t1
2+
(
3+
id1 bigint,
4+
id2 bigint,
5+
primary key (id1)
6+
) Engine = InnoDB;
7+
8+
create table t2
9+
(
10+
id1 bigint,
11+
id2 bigint,
12+
primary key (id1)
13+
) Engine = InnoDB;
14+
15+
create table t3
16+
(
17+
id1 bigint,
18+
id2 bigint,
19+
primary key (id1)
20+
) Engine = InnoDB;
21+
22+
create table t4
23+
(
24+
id1 bigint,
25+
id2 bigint,
26+
primary key (id1)
27+
) Engine = InnoDB;
28+
29+
30+
create table t5
231
(
332
id1 bigint,
433
id2 bigint,

0 commit comments

Comments
 (0)