-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Reparenting endtoend testcases in Go migrated from Python [+ github actions] #5604
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
4a8b2e8
reparent test cases written in go
ajeetj 4c85a56
updated readme and config
ajeetj cbe9cc7
fixed intial sharding multi test case
ajeetj d03d3a1
testing go test file
ajeetj 1602423
Revert "testing go test file"
ajeetj 76d280e
addressed review comments
ajeetj 1ec88e1
changed the range for range based test
ajeetj 0c18dc1
Merge remote-tracking branch 'upstream/master' into tal_reparent_new
ajeetj f429154
Splitting github actions for endtoend go cluster in multiple nodes
ajeetj e32f26f
reverted unrequired files/changes
ajeetj 597d95c
code cleanup
ajeetj 95ffdee
review feedback addressed
ajeetj 332f821
removed unrequired replicas
ajeetj 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 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 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,31 @@ | ||
name: cluster_endtoend | ||
on: [push, pull_request] | ||
jobs: | ||
|
||
build: | ||
name: Cluster End-to-End Test for Shard 12 | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.13 | ||
|
||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Get dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y mysql-server mysql-client make unzip g++ etcd curl git wget | ||
sudo service mysql stop | ||
sudo service etcd stop | ||
sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/ | ||
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld | ||
go mod download | ||
|
||
- name: cluster_endtoend_shard_12 | ||
run: | | ||
source build.env | ||
go run test.go -docker=false -print-log -shard 12 |
This file contains 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,31 @@ | ||
name: cluster_endtoend | ||
on: [push, pull_request] | ||
jobs: | ||
|
||
build: | ||
name: Cluster End-to-End Test for Shard 13 | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.13 | ||
|
||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Get dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y mysql-server mysql-client make unzip g++ etcd curl git wget | ||
sudo service mysql stop | ||
sudo service etcd stop | ||
sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/ | ||
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld | ||
go mod download | ||
|
||
- name: cluster_endtoend_shard_13 | ||
run: | | ||
source build.env | ||
go run test.go -docker=false -print-log -shard 13 |
This file contains 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 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 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 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 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 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,175 @@ | ||
/* | ||
Copyright 2019 The Vitess Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package reparent | ||
|
||
import ( | ||
"context" | ||
"flag" | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
"path" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"vitess.io/vitess/go/mysql" | ||
"vitess.io/vitess/go/sqltypes" | ||
"vitess.io/vitess/go/test/endtoend/cluster" | ||
tmc "vitess.io/vitess/go/vt/vttablet/grpctmclient" | ||
) | ||
|
||
var ( | ||
// ClusterInstance instance to be used for test with different params | ||
clusterInstance *cluster.LocalProcessCluster | ||
tmClient *tmc.Client | ||
keyspaceName = "ks" | ||
shardName = "0" | ||
shard1Name = "0000000000000000-ffffffffffffffff" | ||
keyspaceShard = keyspaceName + "/" + shardName | ||
dbName = "vt_" + keyspaceName | ||
username = "vt_dba" | ||
hostname = "localhost" | ||
cell1 = "zone1" | ||
cell2 = "zone2" | ||
insertSQL = "insert into vt_insert_test(id, msg) values (%d, 'test %d')" | ||
sqlSchema = ` | ||
create table vt_insert_test ( | ||
id bigint, | ||
msg varchar(64), | ||
primary key (id) | ||
) Engine=InnoDB | ||
` | ||
// Tablets for for shard0 | ||
tablet62344 *cluster.Vttablet | ||
tablet62044 *cluster.Vttablet | ||
tablet41983 *cluster.Vttablet | ||
tablet31981 *cluster.Vttablet | ||
|
||
// Tablets for for shard1 | ||
masterTablet *cluster.Vttablet | ||
replicaTablet *cluster.Vttablet | ||
) | ||
|
||
func TestMain(m *testing.M) { | ||
flag.Parse() | ||
|
||
exitCode := func() int { | ||
clusterInstance = cluster.NewCluster(cell1, hostname) | ||
defer clusterInstance.Teardown() | ||
|
||
// Launch keyspace | ||
keyspace := &cluster.Keyspace{Name: keyspaceName} | ||
|
||
// Start topo server | ||
err := clusterInstance.StartTopo() | ||
if err != nil { | ||
return 1 | ||
} | ||
|
||
// Adding another cell in the same cluster | ||
err = clusterInstance.TopoProcess.ManageTopoDir("mkdir", "/vitess/"+cell2) | ||
if err != nil { | ||
return 1 | ||
} | ||
err = clusterInstance.VtctlProcess.AddCellInfo(cell2) | ||
if err != nil { | ||
return 1 | ||
} | ||
|
||
tablet62344 = clusterInstance.GetVttabletInstance("replica", 62344, "") | ||
tablet62044 = clusterInstance.GetVttabletInstance("replica", 62044, "") | ||
tablet41983 = clusterInstance.GetVttabletInstance("replica", 41983, "") | ||
tablet31981 = clusterInstance.GetVttabletInstance("replica", 31981, cell2) | ||
|
||
shard0 := &cluster.Shard{Name: shardName} | ||
shard0.Vttablets = []*cluster.Vttablet{tablet62344, tablet62044, tablet41983, tablet31981} | ||
|
||
// Initiate shard1 - required for ranged based reparenting | ||
masterTablet = clusterInstance.GetVttabletInstance("replica", 0, "") | ||
replicaTablet = clusterInstance.GetVttabletInstance("replica", 0, "") | ||
|
||
shard1 := &cluster.Shard{Name: shard1Name} | ||
shard1.Vttablets = []*cluster.Vttablet{masterTablet, replicaTablet} | ||
|
||
clusterInstance.VtTabletExtraArgs = []string{ | ||
"-lock_tables_timeout", "5s", | ||
"-enable_semi_sync", | ||
} | ||
|
||
// Initialize Cluster | ||
err = clusterInstance.LaunchCluster(keyspace, []cluster.Shard{*shard0, *shard1}) | ||
if err != nil { | ||
return 1 | ||
} | ||
|
||
//Start MySql | ||
var mysqlCtlProcessList []*exec.Cmd | ||
for _, shard := range clusterInstance.Keyspaces[0].Shards { | ||
for _, tablet := range shard.Vttablets { | ||
fmt.Println("Starting MySql for tablet ", tablet.Alias) | ||
if proc, err := tablet.MysqlctlProcess.StartProcess(); err != nil { | ||
return 1 | ||
} else { | ||
mysqlCtlProcessList = append(mysqlCtlProcessList, proc) | ||
} | ||
} | ||
} | ||
|
||
// Wait for mysql processes to start | ||
for _, proc := range mysqlCtlProcessList { | ||
if err := proc.Wait(); err != nil { | ||
return 1 | ||
} | ||
} | ||
|
||
// We do not need semiSync for this test case. | ||
clusterInstance.EnableSemiSync = false | ||
|
||
// create tablet manager client | ||
tmClient = tmc.NewClient() | ||
|
||
return m.Run() | ||
}() | ||
os.Exit(exitCode) | ||
} | ||
|
||
func getMysqlConnParam(tablet *cluster.Vttablet) mysql.ConnParams { | ||
connParams := mysql.ConnParams{ | ||
Uname: username, | ||
DbName: dbName, | ||
UnixSocket: path.Join(os.Getenv("VTDATAROOT"), fmt.Sprintf("/vt_%010d/mysql.sock", tablet.TabletUID)), | ||
} | ||
return connParams | ||
} | ||
|
||
func runSQL(ctx context.Context, t *testing.T, sql string, tablet *cluster.Vttablet) *sqltypes.Result { | ||
// Get Connection | ||
tabletParams := getMysqlConnParam(tablet) | ||
conn, err := mysql.Connect(ctx, &tabletParams) | ||
assert.Nil(t, err) | ||
defer conn.Close() | ||
|
||
// runSQL | ||
return execute(t, conn, sql) | ||
} | ||
|
||
func execute(t *testing.T, conn *mysql.Conn, query string) *sqltypes.Result { | ||
t.Helper() | ||
qr, err := conn.ExecuteFetch(query, 1000, true) | ||
assert.Nil(t, err) | ||
return qr | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to use this instead of just
0
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, copied from Python ones. Will test with
0-f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated it to
-80
. Let me know if that works for the testThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked at the original python test case. I think this does need to be the same as it was in python.
Also, in the python test, we basically run the same scenario for shard0 and shard1, the only difference is how the shard is represented:
0
vs0000...-ffff...
. We should preserve that while porting rather than changing the test to only have 1 master + 1 replica when the shard is represented as0000...-ffff...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have reverted the range to
000...-ffff...
.As wrt to replica counts I have only used master-replica as we just need to verify replication in a replica in range-based test.
As opposed to other Tests like
TestChangeTypeSemiSync
andTestReparentFromOutside
need 4 replicas setup which is already present in Shard0.