Reduce noise in test logs

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
pull/8685/head
Edd Robinson 2017-08-04 15:39:49 +01:00
parent aacdb9bed2
commit 84aea2718a
2 changed files with 9 additions and 7 deletions

View File

@ -13,7 +13,6 @@ import (
"regexp"
"strings"
"sync"
"testing"
"time"
"github.com/influxdata/influxdb/cmd/influxd/run"
@ -472,13 +471,12 @@ func NewConfig() *run.Config {
c.ReportingDisabled = true
c.Coordinator.WriteTimeout = toml.Duration(30 * time.Second)
c.Meta.Dir = MustTempFile()
if !testing.Verbose() {
c.Meta.LoggingEnabled = false
}
c.Meta.LoggingEnabled = verboseServerLogs
c.Data.Dir = MustTempFile()
c.Data.WALDir = MustTempFile()
c.Data.QueryLogEnabled = verboseServerLogs
c.Data.TraceLoggingEnabled = verboseServerLogs
indexVersion := os.Getenv("INFLUXDB_DATA_INDEX_VERSION")
if indexVersion != "" {
@ -487,7 +485,7 @@ func NewConfig() *run.Config {
c.HTTPD.Enabled = true
c.HTTPD.BindAddress = "127.0.0.1:0"
c.HTTPD.LogEnabled = testing.Verbose()
c.HTTPD.LogEnabled = verboseServerLogs
c.Monitor.StoreEnabled = false
@ -724,7 +722,7 @@ func writeTestData(s Server, t *Test) error {
func configureLogging(s Server) {
// Set the logger to discard unless verbose is on
if !testing.Verbose() {
if !verboseServerLogs {
s.SetLogOutput(ioutil.Discard)
}
}

View File

@ -17,10 +17,14 @@ import (
// Global server used by benchmarks
var benchServer Server
var verboseServerLogs bool
func TestMain(m *testing.M) {
vv := flag.Bool("vv", false, "Turn on very verbose server logging.")
flag.Parse()
verboseServerLogs = *vv
// Setup
c := NewConfig()
c.Retention.Enabled = false