Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/go_modules/dev-dependencies-f7b…
Browse files Browse the repository at this point in the history
…f212301
  • Loading branch information
teem0n authored Apr 4, 2024
2 parents 3f2886a + 617d60f commit 2fda036
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 48 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jepsen_test:
GOOS=linux go build -tags netgo,osusergo -o ./cmd/mysync/mysync ./cmd/mysync/...
go build ./tests/...
rm -fr ./tests/images/mysql_jepsen/mysync && cp ./cmd/mysync/mysync ./tests/images/mysql_jepsen/mysync
docker-compose -p mysync -f ./tests/images/jepsen-compose.yml up -d --force-recreate --build
docker compose -p mysync -f ./tests/images/jepsen-compose.yml up -d --force-recreate --build
timeout 600 docker exec mysync_zoo1_1 /usr/local/bin/generate_certs_with_restart.sh mysync_zookeeper1_1.mysync_mysql_net
timeout 600 docker exec mysync_zoo2_1 /usr/local/bin/generate_certs_with_restart.sh mysync_zookeeper2_1.mysync_mysql_net
timeout 600 docker exec mysync_zoo3_1 /usr/local/bin/generate_certs_with_restart.sh mysync_zookeeper3_1.mysync_mysql_net
Expand All @@ -48,7 +48,7 @@ jepsen_test:
timeout 600 docker exec mysync_mysql1_1 setup.sh
mkdir -p ./tests/logs
(docker exec mysync_jepsen_1 /root/jepsen/run.sh > ./tests/logs/jepsen.log 2>&1 && tail -n 4 ./tests/logs/jepsen.log) || ./tests/images/jepsen_main/save_logs.sh
docker-compose -p mysync -f ./tests/images/jepsen-compose.yml down --rmi all
docker compose -p mysync -f ./tests/images/jepsen-compose.yml down --rmi all

clean:
docker ps | grep mysync | awk '{print $$1}' | xargs docker rm -f || true
Expand Down
52 changes: 26 additions & 26 deletions tests/features/external_replication.feature
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Feature: external replication
[{
"source_host": "test_source_2",
"source_password": "test_pass_2",
"source_port": "2222",
"source_port": 2222,
"source_user": "test_user_2"
}]
"""
Expand All @@ -53,7 +53,7 @@ Feature: external replication
"""
[{
"source_host": "test_source_2",
"source_port": "2222",
"source_port": 2222,
"source_password": "test_pass_2",
"source_user": "test_user_2"
}]
Expand Down Expand Up @@ -86,11 +86,11 @@ Feature: external replication
Then SQL result should match json
"""
[{
"Exec_Source_Log_Pos": "0",
"Exec_Source_Log_Pos": 0,
"Replica_IO_State": "Connecting to source",
"Replica_SQL_Running": "Yes",
"Source_Host": "test_source",
"Source_Port": "1111",
"Source_Port": 1111,
"Source_User": "test_user",
"Replica_IO_Running": "Connecting",
"Relay_Source_Log_File": "",
Expand Down Expand Up @@ -182,12 +182,12 @@ YZQy1bHIhscLf8wjTYbzAg==
[{
"Replica_IO_State": "Connecting to source",
"Source_Host": "test_source_2",
"Source_Port": "2222",
"Source_Port": 2222,
"Source_User": "test_user_2",
"Replica_IO_Running": "Connecting",
"Replica_SQL_Running": "Yes",
"Relay_Source_Log_File": "",
"Exec_Source_Log_Pos": "0",
"Exec_Source_Log_Pos": 0,
"Channel_Name": "external",
"Replicate_Ignore_DB": "mysql",
"Source_SSL_CA_File": "/etc/mysql/ssl/external_CA.pem"
Expand All @@ -212,7 +212,7 @@ YZQy1bHIhscLf8wjTYbzAg==
"source_host": "test_source_2",
"source_user": "test_user_2",
"source_password": "test_pass_2",
"source_port": "2222"
"source_port": 2222
}]
"""

Expand Down Expand Up @@ -260,13 +260,13 @@ YZQy1bHIhscLf8wjTYbzAg==
[{
"Replica_IO_State": "",
"Source_Host": "test_source",
"Source_Port": "1111",
"Source_Port": 1111,
"Source_User": "test_user",
"Replica_IO_Running": "No",
"Replica_SQL_Running": "No",
"Source_SSL_CA_File": "",
"Relay_Source_Log_File": "",
"Exec_Source_Log_Pos": "0",
"Exec_Source_Log_Pos": 0,
"Channel_Name": "external"
}]
"""
Expand All @@ -280,13 +280,13 @@ YZQy1bHIhscLf8wjTYbzAg==
[{
"Replica_IO_State": "",
"Source_Host": "test_source",
"Source_Port": "1111",
"Source_Port": 1111,
"Source_User": "test_user",
"Replica_IO_Running": "No",
"Replica_SQL_Running": "No",
"Source_SSL_CA_File": "",
"Relay_Source_Log_File": "",
"Exec_Source_Log_Pos": "0",
"Exec_Source_Log_Pos": 0,
"Channel_Name": "external"
}]
"""
Expand Down Expand Up @@ -324,13 +324,13 @@ YZQy1bHIhscLf8wjTYbzAg==
[{
"Replica_IO_State": "",
"Source_Host": "test_source",
"Source_Port": "1111",
"Source_Port": 1111,
"Source_User": "test_user",
"Replica_IO_Running": "No",
"Replica_SQL_Running": "No",
"Source_SSL_CA_File": "",
"Relay_Source_Log_File": "",
"Exec_Source_Log_Pos": "0",
"Exec_Source_Log_Pos": 0,
"Channel_Name": "external"
}]
"""
Expand All @@ -350,13 +350,13 @@ YZQy1bHIhscLf8wjTYbzAg==
[{
"Replica_IO_State": "",
"Source_Host": "test_source",
"Source_Port": "1111",
"Source_Port": 1111,
"Source_User": "test_user",
"Replica_IO_Running": "No",
"Replica_SQL_Running": "No",
"Source_SSL_CA_File": "",
"Relay_Source_Log_File": "",
"Exec_Source_Log_Pos": "0",
"Exec_Source_Log_Pos": 0,
"Channel_Name": "external"
}]
"""
Expand Down Expand Up @@ -394,13 +394,13 @@ Y2AirKuDzA5GErKOfQ==
[{
"Replica_IO_State": "",
"Source_Host": "test_source",
"Source_Port": "1111",
"Source_Port": 1111,
"Source_User": "test_user",
"Replica_IO_Running": "No",
"Replica_SQL_Running": "No",
"Source_SSL_CA_File": "",
"Relay_Source_Log_File": "",
"Exec_Source_Log_Pos": "0",
"Exec_Source_Log_Pos": 0,
"Channel_Name": "external"
}]
"""
Expand All @@ -418,13 +418,13 @@ Y2AirKuDzA5GErKOfQ==
[{
"Replica_IO_State": "Connecting to source",
"Source_Host": "test_source",
"Source_Port": "1111",
"Source_Port": 1111,
"Source_User": "test_user",
"Replica_IO_Running": "Connecting",
"Replica_SQL_Running": "Yes",
"Source_SSL_CA_File": "",
"Relay_Source_Log_File": "",
"Exec_Source_Log_Pos": "0",
"Exec_Source_Log_Pos": 0,
"Channel_Name": "external"
}]
"""
Expand Down Expand Up @@ -469,7 +469,7 @@ Y2AirKuDzA5GErKOfQ==
[{
"source_host": "test_source_2",
"source_password": "test_pass_2",
"source_port": "2222",
"source_port": 2222,
"source_user": "test_user_2"
}]
"""
Expand All @@ -482,7 +482,7 @@ Y2AirKuDzA5GErKOfQ==
"""
[{
"source_host": "test_source_2",
"source_port": "2222",
"source_port": 2222,
"source_password": "test_pass_2",
"source_user": "test_user_2"
}]
Expand Down Expand Up @@ -515,10 +515,10 @@ Y2AirKuDzA5GErKOfQ==
Then SQL result should match json
"""
[{
"Exec_Source_Log_Pos": "0",
"Exec_Source_Log_Pos": 0,
"Replica_IO_State": "Connecting to source",
"Source_Host": "test_source",
"Source_Port": "1111",
"Source_Port": 1111,
"Source_User": "test_user",
"Replica_IO_Running": "Connecting",
"Replica_SQL_Running": "Yes",
Expand Down Expand Up @@ -564,12 +564,12 @@ Y2AirKuDzA5GErKOfQ==
[{
"Replica_IO_State": "",
"Source_Host": "test_source_2",
"Source_Port": "2222",
"Source_Port": 2222,
"Source_User": "test_user_2",
"Replica_IO_Running": "No",
"Replica_SQL_Running": "No",
"Relay_Source_Log_File": "",
"Exec_Source_Log_Pos": "0",
"Exec_Source_Log_Pos": 0,
"Channel_Name": "external",
"Replicate_Ignore_DB": "mysql",
"Source_SSL_CA_File": ""
Expand All @@ -592,7 +592,7 @@ Y2AirKuDzA5GErKOfQ==
"source_host": "test_source_2",
"source_user": "test_user_2",
"source_password": "test_pass_2",
"source_port": "2222"
"source_port": 2222
}]
"""

31 changes: 15 additions & 16 deletions tests/mysync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"log"
"os"
"path/filepath"
"strconv"
"strings"
"sync"
"testing"
Expand Down Expand Up @@ -371,19 +370,13 @@ func (tctx *testContext) runSlaveStatusQuery(host string) (map[string]string, er
if err != nil {
return nil, err
}
MajorVersion, err := strconv.Atoi(res[0]["MajorVersion"].(string))
MajorVersion := res[0]["MajorVersion"].(int64)
MinorVersion := res[0]["MinorVersion"].(int64)
PatchVersion := res[0]["PatchVersion"].(int64)
if err != nil {
return nil, err
}
MinorVersion, err := strconv.Atoi(res[0]["MinorVersion"].(string))
if err != nil {
return nil, err
}
PatchVersion, err := strconv.Atoi(res[0]["PatchVersion"].(string))
if err != nil {
return nil, err
}
v := mysql_internal.Version{MajorVersion: MajorVersion, MinorVersion: MinorVersion, PatchVersion: PatchVersion}
v := mysql_internal.Version{MajorVersion: int(MajorVersion), MinorVersion: int(MinorVersion), PatchVersion: int(PatchVersion)}
query = mysql_internal.DefaultQueries[v.GetSlaveStatusQuery()]
query = mysql_internal.Mogrify(query, map[string]interface{}{
"channel": replicationChannel,
Expand Down Expand Up @@ -910,7 +903,7 @@ func (tctx *testContext) stepBreakReplicationOnHostInARepairableWay(host string)
if err != nil {
return err
}
if _, err := tctx.queryMysql(host, fmt.Sprintf("KILL %s", queryReqult[0]["id"]), struct{}{}); err != nil {
if _, err := tctx.queryMysql(host, fmt.Sprintf("KILL %d", queryReqult[0]["id"].(uint64)), struct{}{}); err != nil {
return err
}
return nil
Expand Down Expand Up @@ -1036,7 +1029,13 @@ func (tctx *testContext) stepMysqlHostShouldHaveVariableSet(host string, name st
if err != nil {
return err
}
actual := res[0]["actual"].(string)
actual := ""
switch res[0]["actual"].(type) {
case int64:
actual = fmt.Sprint(res[0]["actual"].(int64))
default:
actual = res[0]["actual"].(string)
}
if actual != value {
return fmt.Errorf("@@%s is %s, while expected %s", name, actual, value)
}
Expand Down Expand Up @@ -1218,9 +1217,9 @@ func (tctx *testContext) queryMysqlReadOnlyStatus(host string) (bool, bool, erro
if err != nil {
return false, false, err
}
ro := res[0]["ro"].(string)
superRo := res[0]["superRo"].(string)
return ro == "1", superRo == "1", nil
ro := res[0]["ro"].(int64)
superRo := res[0]["superRo"].(int64)
return ro == 1, superRo == 1, nil
}

func (tctx *testContext) stepMysqlHostShouldBeReadOnly(host string) error {
Expand Down
8 changes: 4 additions & 4 deletions tests/testutil/docker_composer.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type Composer interface {
CheckIfFileExist(service, path string) (bool, error)
}

// DockerComposer is a Composer implementation based on docker and docker-compose
// DockerComposer is a Composer implementation based on docker and docker compose
type DockerComposer struct {
projectName string
config string
Expand Down Expand Up @@ -92,14 +92,14 @@ func NewDockerComposer(project, config string) (*DockerComposer, error) {
}

func (dc *DockerComposer) runCompose(args []string, env []string) error {
args2 := []string{}
args2 := []string{"compose"}
args2 = append(args2, "-f", dc.config, "-p", dc.projectName)
args2 = append(args2, args...)
cmd := exec.Command("docker-compose", args2...)
cmd := exec.Command("docker", args2...)
cmd.Env = append(os.Environ(), env...)
out, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("failed to run 'docker-compose %s': %s\n%s", strings.Join(args2, " "), err, out)
return fmt.Errorf("failed to run 'docker compose %s': %s\n%s", strings.Join(args2, " "), err, out)
}
return nil
}
Expand Down

0 comments on commit 2fda036

Please sign in to comment.