-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Run relevant unit tests on both indexes #8685
Conversation
|
@jwilder that must be a flaky test |
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.
Some comments on usage. I can review further depending on what consensus we come to.
} | ||
if query.skip { | ||
t.Skipf("SKIP:: %s", query.name) | ||
} |
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.
This doesn't have to be done in this PR but we can take out all the .skip
fields now that we're using t.Run()
.
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.
You mean the skip
fields on the query
type? How would we skip tests we don't want to run? I'll admit I have no idea why we're skipping any of them in the first place :)
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 believe the skip
field was there to allow someone to isolate a test instead of commenting out the other tests. With subtests we can isolate with -run
.
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 think we still need skip. We've marked things as skip in the past because the tests ended up being flaky and need to be be disabled (and looked at later). If we just comment them out, the output in the log is lost so we can't easily just search the output to see if any tests happened to be skipped.
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.
We can use t.Skip()
on the subtest.
// Create a few points. | ||
p1 := MustParsePointString("cpu,host=A value=1.1 1000000000") | ||
p2 := MustParsePointString("cpu,host=B value=1.2 2000000000") | ||
p3 := MustParsePointString("cpu,host=A sum=1.3 3000000000") |
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.
Can we use a helper function (e.g. RunForEachIndex(func(*testing.T))
) that loops the registered indexes?
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.
Here or everywhere? Are you concerned about indentation?
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 thought it was being used in a bunch of places but it seems to be less than I thought. Indentation was one concern. Another concern was DRY and consistency.
err := e.WritePoints(pp) | ||
if err != nil { | ||
b.Fatal(err) | ||
b.Run(fmt.Sprintf("%s_%d", index, sz), func(b *testing.B) { |
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.
Can this be two nested b.Run()
calls instead of concatenating index
& sz
?
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 didn't know that was an option. Neat.
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.
Hmmm:
BenchmarkEngine_WritePoints/10/inmem-4 20000 77541 ns/op 2701 B/op 48 allocs/op
BenchmarkEngine_WritePoints/10#01/tsi1-4 20000 75302 ns/op 2702 B/op 48 allocs/op
Not exactly as nice.
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 it work if you invert index
& sz
? Does it change it to:
BenchmarkEngine_WritePoints/inmem/10-4 20000 77541 ns/op 2701 B/op 48 allocs/op
BenchmarkEngine_WritePoints/tsi1/10/-4 20000 75302 ns/op 2702 B/op 48 allocs/op
if err != nil { | ||
errC <- err | ||
return | ||
b.Run(fmt.Sprintf("%s_%d", index, sz), func(b *testing.B) { |
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.
Nest b.Run()
here as well.
tsdb/shard_test.go
Outdated
var ( | ||
sh *Shard | ||
itr influxql.Iterator | ||
) |
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 personally loathe the block var
declaration. :)
Why use four lines for what can be declared in two?
} | ||
|
||
for _, index := range tsdb.RegisteredIndexes() { | ||
t.Run(index, func(t *testing.T) { test(index) }) |
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.
Why is this calling an variable function instead of being nested inside Run
?
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 was concerned about the indentation of nesting everything inside of t.Run
64705eb
to
ee16983
Compare
This commit reduces noise in the test logs by adding a -vv flag, and silencing server log output, even when verbose testing mode is enabled. Verbose testing mode (-v) is useful for seeing where sub-tests may be failing, but it's currently too noisy with the server logs. The -vv flag can now be used to see all server output. The flag should be placed _after_ the package you're testing, e.g., go test github.com/influxdata/influxdb/tests -vv
fafe675
to
673cbcd
Compare
673cbcd
to
0c97d6b
Compare
0c97d6b
to
d011e43
Compare
Required for all non-trivial PRs
This PR ensure that where appropriate, unit tests are run on both indexes using sub-tests. Benchmarks have also been updated in a similar way.
In terms of the
tests
package tests, I found that the test output was too noisy when using Go's verbose-v
mode, which itself is useful for seeing the sub-test result output. Therefore I've added a new-vv
flag for that package, if the server logs are desirable output. /cc @mark-rushakoff @aanthony1243.Finally, regarding the
tests
package, all queries for each test will now run as sub-tests.