Skip to content
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

Merged
merged 11 commits into from
Aug 23, 2017
Merged

Run relevant unit tests on both indexes #8685

merged 11 commits into from
Aug 23, 2017

Conversation

e-dard
Copy link
Contributor

@e-dard e-dard commented Aug 10, 2017

Required for all non-trivial PRs
  • Rebased/mergable
  • Tests pass

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.

go test -v github.com/influxdata/influxdb/tests -vv

@jwilder
Copy link
Contributor

jwilder commented Aug 10, 2017

=== RUN   TestStore_Cardinality_Compactions/inmem
[I] 2017-08-10T15:21:33Z Using data dir: /tmp/influxdb-tsdb-960455470 service=store
panic: test executed panic(nil) or runtime.Goexit

goroutine 87907 [running]:
testing.tRunner.func1(0xc42056f110)
	/usr/local/go/src/testing/testing.go:622 +0x55f
runtime.Goexit()
	/usr/local/go/src/runtime/panic.go:366 +0x15c
testing.(*common).SkipNow(0xc42005f860)
	/usr/local/go/src/testing/testing.go:555 +0x59
testing.(*common).Skip(0xc42005f860, 0xc420479e60, 0x1, 0x1)
	/usr/local/go/src/testing/testing.go:536 +0x7d
github.com/influxdata/influxdb/tsdb_test.testStoreCardinalityCompactions(0xc42005f860, 0xc4201300d0)
	/root/go/src/github.com/influxdata/influxdb/tsdb/store_test.go:766 +0x142
github.com/influxdata/influxdb/tsdb_test.TestStore_Cardinality_Compactions.func1(0xc85fad, 0x5)
	/root/go/src/github.com/influxdata/influxdb/tsdb/store_test.go:823 +0x155
github.com/influxdata/influxdb/tsdb_test.TestStore_Cardinality_Compactions.func2(0xc42056f110)
	/root/go/src/github.com/influxdata/influxdb/tsdb/store_test.go:827 +0x72
testing.tRunner(0xc42056f110, 0xc4205b1c00)
	/usr/local/go/src/testing/testing.go:657 +0x108
created by testing.(*T).Run
	/usr/local/go/src/testing/testing.go:697 +0x544
FAIL	github.com/influxdata/influxdb/tsdb	78.467s

@e-dard
Copy link
Contributor Author

e-dard commented Aug 10, 2017

@jwilder that must be a flaky test

Copy link
Contributor

@benbjohnson benbjohnson left a 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)
}
Copy link
Contributor

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().

Copy link
Contributor Author

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 :)

Copy link
Contributor

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.

Copy link
Contributor

@jwilder jwilder Aug 10, 2017

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.

Copy link
Contributor

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")
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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) {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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) {
Copy link
Contributor

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.

var (
sh *Shard
itr influxql.Iterator
)
Copy link
Contributor

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) })
Copy link
Contributor

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?

Copy link
Contributor Author

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

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
@e-dard e-dard force-pushed the er-8663-tsi1-tests branch 2 times, most recently from fafe675 to 673cbcd Compare August 22, 2017 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants