Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
timvaillancourt committed Dec 3, 2022
1 parent a578991 commit 23181e7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
4 changes: 3 additions & 1 deletion go/localtests/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (test *Test) Migrate(config Config, primary, replica *sql.DB) (err error) {
cmd.Stdout = &output

if err = cmd.Run(); err != nil {
if isExpectedFailureOutput(stderr, test.ExpectedFailure) {
if isExpectedFailureOutput(&stderr, test.ExpectedFailure) {
return nil
}
output.Write(stderr.Bytes())
Expand All @@ -136,9 +136,11 @@ func (test *Test) Migrate(config Config, primary, replica *sql.DB) (err error) {
return err
}

/*
func getPrimaryOrUniqueKey(db *sql.DB, database, table string) (string, error) {
return "id", nil // TODO: fix this
}
*/

// Validate performs a validation of the migration test results.
func (test *Test) Validate(config Config, primary, replica *sql.DB) error {
Expand Down
9 changes: 6 additions & 3 deletions go/localtests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ func getMysqlHostInfo(db *sql.DB) (*MysqlInfo, error) {
return &info, err
}

func isExpectedFailureOutput(output bytes.Buffer, expectedFailure string) bool {
scanner := bufio.NewScanner(&output)
func isExpectedFailureOutput(output io.Reader, expectedFailure string) bool {
scanner := bufio.NewScanner(output)
for scanner.Scan() {
if !strings.Contains(scanner.Text(), "FATAL") {
continue
Expand Down Expand Up @@ -109,7 +109,10 @@ func pingAndGetGTIDExecuted(db *sql.DB, timeout time.Duration) (*mysql.UUIDSet,

func readTestFile(file string) (string, error) {
bytes, err := ioutil.ReadFile(file)
return strings.TrimSpace(string(bytes)), err
if err != nil {
return "", err
}
return strings.TrimSpace(string(bytes)), nil
}

func setDBGlobalSqlMode(db *sql.DB, sqlMode string) (err error) {
Expand Down
4 changes: 2 additions & 2 deletions localtests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ services:
- "replica"
primary:
image: ${TEST_DOCKER_IMAGE}
command: "--enforce-gtid-consistency --gtid-mode=ON --event-scheduler=ON --log-bin --log-slave-updates --server-id=1"
command: "--bind-address=0.0.0.0 --enforce-gtid-consistency --gtid-mode=ON --event-scheduler=ON --log-bin --log-slave-updates --server-id=1"
env_file: "mysql.env"
volumes:
- "./init.sql:/docker-entrypoint-initdb.d/01-init.sql:ro"
replica:
image: ${TEST_DOCKER_IMAGE}
command: "--enforce-gtid-consistency --gtid-mode=ON --log-bin --log-slave-updates --read-only=ON --server-id=2"
command: "--bind-address=0.0.0.0 --enforce-gtid-consistency --gtid-mode=ON --log-bin --log-slave-updates --read-only=ON --server-id=2"
env_file: "mysql.env"
depends_on:
- "primary"
Expand Down
4 changes: 3 additions & 1 deletion localtests/init.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
CREATE DATABASE IF NOT EXISTS `test`;

GRANT ALL ON *.* TO `gh-ost`@`%` IDENTIFIED BY 'gh-ost';
CREATE USER IF NOT EXISTS `gh-ost`@`%`;
SET PASSWORD FOR `gh-ost`@`%` = PASSWORD('gh-ost');
GRANT ALL ON *.* TO `gh-ost`@`%`;

0 comments on commit 23181e7

Please sign in to comment.