-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7320fda
commit b45947e
Showing
21 changed files
with
1,403 additions
and
29 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,37 @@ | ||
name: migration tests | ||
|
||
on: [pull_request] | ||
on: | ||
- pull_request | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-20.04 | ||
strategy: | ||
matrix: | ||
version: [mysql-5.7.25,mysql-8.0.16,PerconaServer-8.0.21] | ||
tests: | ||
- image: mysql:5.7 | ||
engine: innodb | ||
- image: mysql:8.0 | ||
engine: innodb | ||
- image: percona:5.7 | ||
engine: innodb | ||
- image: percona:8.0 | ||
engine: innodb | ||
- image: percona:5.7 | ||
engine: rocksdb | ||
- image: percona:8.0 | ||
engine: rocksdb | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.17 | ||
- name: generate mysql environment file | ||
env: | ||
TEST_STORAGE_ENGINE: "${{ matrix.tests.engine }}" | ||
run: localtests/mysql-env.sh | ||
|
||
- name: migration tests | ||
- name: run localtests | ||
env: | ||
TEST_MYSQL_VERSION: ${{ matrix.version }} | ||
run: script/cibuild-gh-ost-replica-tests | ||
TEST_DOCKER_IMAGE: "${{ matrix.tests.image }}" | ||
run: docker-compose -f localtests/docker-compose.yml up --abort-on-container-exit --no-log-prefix tests | ||
|
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/.gopath/ | ||
/bin/ | ||
/libexec/ | ||
/localtests/mysql.env | ||
/.vendor/ | ||
.idea/ |
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,104 @@ | ||
package main | ||
|
||
import ( | ||
"database/sql" | ||
"flag" | ||
"fmt" | ||
"log" | ||
"os" | ||
|
||
_ "github.com/go-sql-driver/mysql" | ||
|
||
"github.com/github/gh-ost/go/localtests" | ||
) | ||
|
||
var AppVersion string | ||
|
||
func envStringVarOrDefault(envVar, defaultVal string) string { | ||
if val := os.Getenv(envVar); val != "" { | ||
return val | ||
} | ||
return defaultVal | ||
} | ||
|
||
func main() { | ||
// flags | ||
var printVersion, testNoop bool | ||
var testName string | ||
var cnf localtests.Config | ||
flag.StringVar(&cnf.Host, "host", localtests.DefaultHost, "mysql host") | ||
flag.Int64Var(&cnf.Port, "port", localtests.DefaultPort, "mysql port") | ||
flag.StringVar(&cnf.Username, "username", localtests.DefaultUsername, "mysql username") | ||
flag.StringVar(&cnf.Password, "password", localtests.DefaultPassword, "mysql password") | ||
flag.StringVar(&cnf.TestsDir, "tests-dir", "/etc/localtests", "path to localtests directory") | ||
flag.StringVar(&testName, "test", "", "run a single test by name (default: run all tests)") | ||
flag.BoolVar(&testNoop, "test-noop", false, "run a single noop migration, eg: --alter='ENGINE=InnoDB'") | ||
flag.StringVar(&cnf.StorageEngine, "storage-engine", envStringVarOrDefault("TEST_STORAGE_ENGINE", "innodb"), "mysql storage engine") | ||
flag.StringVar(&cnf.GhostBinary, "binary", "gh-ost", "path to gh-ost binary") | ||
flag.StringVar(&cnf.MysqlBinary, "mysql-binary", "mysql", "path to mysql binary") | ||
flag.BoolVar(&printVersion, "version", false, "print version and exit") | ||
flag.Parse() | ||
|
||
// print version | ||
if printVersion { | ||
fmt.Println(AppVersion) | ||
os.Exit(0) | ||
} | ||
|
||
// connect to replica | ||
replica, err := sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s:%d)/?interpolateParams=true", | ||
cnf.Username, | ||
cnf.Password, | ||
cnf.Host, | ||
cnf.Port, | ||
)) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
defer replica.Close() | ||
|
||
// connect to primary | ||
primary, err := sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s:%d)/?interpolateParams=true", | ||
cnf.Username, | ||
cnf.Password, | ||
"primary", // TODO: fix me | ||
cnf.Port, | ||
)) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
defer primary.Close() | ||
|
||
// start tester | ||
tester := localtests.NewTester(cnf, primary, replica) | ||
if err = tester.WaitForMySQLAvailable(); err != nil { | ||
log.Fatalf("Failed to setup MySQL database servers: %+v", err) | ||
} | ||
|
||
// find tests | ||
var tests []localtests.Test | ||
if testNoop { | ||
tests = []localtests.Test{ | ||
{ | ||
Name: "noop", | ||
ExtraArgs: []string{ | ||
fmt.Sprintf("--alter='ENGINE=%s'", cnf.StorageEngine), | ||
}, | ||
}, | ||
} | ||
} else { | ||
tests, err = tester.ReadTests(testName) | ||
if err != nil { | ||
log.Fatalf("Failed to read tests: %+v", err) | ||
} | ||
} | ||
|
||
// run tests | ||
for _, test := range tests { | ||
log.Println("------------------------------------------------------------------------------------------------------------") | ||
log.Printf("Loading test %q at %s/%s", test.Name, cnf.TestsDir, test.Name) | ||
if err = tester.RunTest(test); err != nil { | ||
log.Fatalf("Failed to run test %s: %+v", test.Name, err) | ||
} | ||
} | ||
} |
Oops, something went wrong.