-
Notifications
You must be signed in to change notification settings - Fork 26
integration tests: wait for index creation #407
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// +build integration regression | ||
|
||
package cmdtests | ||
|
||
import ( | ||
"strings" | ||
"time" | ||
|
||
"github.com/stretchr/testify/require" | ||
"gotest.tools/icmd" | ||
) | ||
|
||
// building/loading index takes some time, wait maximum 15s | ||
func IndexIsVisible(s commandSuite, table, name string) string { | ||
var visibleValue string | ||
for i := 0; i < 15; i++ { | ||
visibleValue = hasIndex(s, table, name) | ||
if visibleValue != "YES" { | ||
time.Sleep(time.Second) | ||
} else { | ||
break | ||
} | ||
} | ||
|
||
return visibleValue | ||
} | ||
|
||
func hasIndex(s commandSuite, table, name string) string { | ||
r := s.RunCommand("sql", "SHOW INDEX FROM "+table) | ||
s.Require().NoError(r.Error, r.Combined()) | ||
|
||
// parse result and check that correct index was built and it is visiable | ||
lines := strings.Split(r.Stdout(), "\n") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we could add an example output. This way if the format changes in the future we can compare it and fix the code easier. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added a link instead of output itself (it's huge). The link contains version of mysql so it won't change. |
||
for _, line := range lines { | ||
cols := strings.Split(line, "|") | ||
if len(cols) < 15 { | ||
continue | ||
} | ||
if strings.TrimSpace(cols[1]) != table { | ||
continue | ||
} | ||
if strings.TrimSpace(cols[3]) != name { | ||
continue | ||
} | ||
|
||
return strings.TrimSpace(cols[14]) | ||
} | ||
|
||
return "NO" | ||
} | ||
|
||
type commandSuite interface { | ||
RunCommand(cmd string, args ...string) *icmd.Result | ||
Require() *require.Assertions | ||
} |
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.
Does the visible column have other values than "YES" and "NO"?
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.
according to mysql documentation no. At least there is no mention of any other value.
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'd then change the return value to
bool
so that the handling of "YES" and "NO" values is done only within this function.