Skip to content

Commit

Permalink
Use storage engine flag
Browse files Browse the repository at this point in the history
  • Loading branch information
timvaillancourt committed Dec 3, 2022
1 parent 118c086 commit a578991
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 10 deletions.
10 changes: 9 additions & 1 deletion go/cmd/gh-ost-localtests/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ import (

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
Expand All @@ -26,6 +33,7 @@ func main() {
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")
Expand Down Expand Up @@ -74,7 +82,7 @@ func main() {
{
Name: "noop",
ExtraArgs: []string{
`--alter='ENGINE=InnoDB'`,
fmt.Sprintf("--alter='ENGINE=%s'", cnf.StorageEngine),
},
},
}
Expand Down
3 changes: 2 additions & 1 deletion go/localtests/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func (test *Test) Migrate(config Config, primary, replica *sql.DB) (err error) {
fmt.Sprintf("--throttle-query=%s", throttleQuery),
fmt.Sprintf("--throttle-flag-file=%s", throttleFlagFile),
fmt.Sprintf("--serve-socket-file=%s", testSocketFile),
fmt.Sprintf("--storage-engine=%s", config.StorageEngine),
"--allow-on-master",
"--assume-rbr",
"--debug",
Expand All @@ -112,7 +113,7 @@ func (test *Test) Migrate(config Config, primary, replica *sql.DB) (err error) {
"--verbose",
}
if !flagsSliceContainsAlter(test.ExtraArgs) {
test.ExtraArgs = append(test.ExtraArgs, `--alter=ENGINE=InnoDB`)
test.ExtraArgs = append(test.ExtraArgs, fmt.Sprintf(`--alter=ENGINE=%s`, config.StorageEngine))
}
if len(test.ExtraArgs) > 0 {
flags = append(flags, test.ExtraArgs...)
Expand Down
15 changes: 8 additions & 7 deletions go/localtests/tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ const (

// Config represents the configuration.
type Config struct {
Host string
Port int64
Username string
Password string
GhostBinary string
MysqlBinary string
TestsDir string
Host string
Port int64
Username string
Password string
GhostBinary string
MysqlBinary string
StorageEngine string
TestsDir string
}

type Tester struct {
Expand Down
3 changes: 3 additions & 0 deletions localtests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ services:
build:
context: "../"
dockerfile: "localtests/Dockerfile"
env_file: "mysql.env"
depends_on:
- "primary"
- "replica"
Expand All @@ -17,6 +18,8 @@ services:
image: ${TEST_DOCKER_IMAGE}
command: "--enforce-gtid-consistency --gtid-mode=ON --log-bin --log-slave-updates --read-only=ON --server-id=2"
env_file: "mysql.env"
depends_on:
- "primary"
volumes:
- "./init.sql:/docker-entrypoint-initdb.d/01-init.sql:ro"
- "./init-replica.sql:/docker-entrypoint-initdb.d/02-init-replica.sql:ro"
3 changes: 2 additions & 1 deletion localtests/mysql-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ FILE=$DIR/mysql.env

(
echo 'MYSQL_ALLOW_EMPTY_PASSWORD=true'


echo "TEST_STORAGE_ENGINE=${TEST_STORAGE_ENGINE}"
if [ "$TEST_STORAGE_ENGINE" == "rocksdb" ]; then
echo 'INIT_ROCKSDB=true'
fi
Expand Down

0 comments on commit a578991

Please sign in to comment.