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

ci: set test log level off in gha #12381

Merged
merged 2 commits into from
Mar 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test-core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ env:
CONSUL_VERSION: 1.11.3
VAULT_VERSION: 1.9.3
NOMAD_SLOW_TEST: 0
NOMAD_TEST_LOG_LEVEL: ERROR
NOMAD_TEST_LOG_LEVEL: OFF
jobs:
checks:
runs-on: ubuntu-20.04
Expand Down
2 changes: 2 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ test-nomad: dev ## Run Nomad test suites
$(if $(ENABLE_RACE),-race) $(if $(VERBOSE),-v) \
-cover \
-timeout=20m \
-count=1 \
-tags "$(GO_TAGS)" \
$(GOTEST_PKGS)

Expand All @@ -310,6 +311,7 @@ test-nomad-module: dev ## Run Nomad test suites on a sub-module
$(if $(ENABLE_RACE),-race) $(if $(VERBOSE),-v) \
-cover \
-timeout=20m \
-count=1 \
-tags "$(GO_TAGS)" \
./...

Expand Down
8 changes: 5 additions & 3 deletions command/agent/keyring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/hashicorp/go-hclog"
"github.com/hashicorp/nomad/ci"
"github.com/hashicorp/nomad/helper/testlog"
)

func TestAgent_LoadKeyrings(t *testing.T) {
Expand All @@ -29,9 +30,10 @@ func TestAgent_LoadKeyrings(t *testing.T) {

// Server should auto-load WAN keyring files
agent2 := &TestAgent{
T: t,
Name: t.Name() + "2",
Key: key,
T: t,
Name: t.Name() + "2",
Key: key,
logger: testlog.HCLogger(t),
}
agent2.Start()
defer agent2.Shutdown()
Expand Down
2 changes: 1 addition & 1 deletion command/agent/log_levels.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
// levels that we use.
func LevelFilter() *logutils.LevelFilter {
return &logutils.LevelFilter{
Levels: []logutils.LogLevel{"TRACE", "DEBUG", "INFO", "WARN", "ERROR"},
Levels: []logutils.LogLevel{"TRACE", "DEBUG", "INFO", "WARN", "ERROR", "OFF"},
MinLevel: "INFO",
Writer: ioutil.Discard,
}
Expand Down
29 changes: 7 additions & 22 deletions command/agent/testagent.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package agent

import (
"fmt"
"io"
"io/ioutil"
"math/rand"
"net/http"
Expand Down Expand Up @@ -55,9 +54,8 @@ type TestAgent struct {
// when Shutdown() is called.
Config *Config

// LogOutput is the sink for the logs. If nil, logs are written
// to os.Stderr.
LogOutput io.Writer
// logger is used for logging
logger hclog.InterceptLogger

// DataDir is the data directory which is used when Config.DataDir
// is not set. It is created automatically and removed when
Expand Down Expand Up @@ -102,6 +100,7 @@ func NewTestAgent(t testing.TB, name string, configCallback func(*Config)) *Test
Name: name,
ConfigCallback: configCallback,
Enterprise: EnterpriseTestAgent,
logger: testlog.HCLogger(t),
}

a.Start()
Expand Down Expand Up @@ -235,26 +234,14 @@ RETRY:
}

func (a *TestAgent) start() (*Agent, error) {
if a.LogOutput == nil {
prefix := fmt.Sprintf("%v:%v ", a.Config.BindAddr, a.Config.Ports.RPC)
a.LogOutput = testlog.NewPrefixWriter(a.T, prefix)
}

inm := metrics.NewInmemSink(10*time.Second, time.Minute)
metrics.NewGlobal(metrics.DefaultConfig("service-name"), inm)

if inm == nil {
return nil, fmt.Errorf("unable to set up in memory metrics needed for agent initialization")
}

logger := hclog.NewInterceptLogger(&hclog.LoggerOptions{
Name: "agent",
Level: hclog.LevelFromString(a.Config.LogLevel),
Output: a.LogOutput,
JSONFormat: a.Config.LogJson,
})

agent, err := NewAgent(a.Config, logger, a.LogOutput, inm)
agent, err := NewAgent(a.Config, a.logger, testlog.NewWriter(a.T), inm)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -349,8 +336,7 @@ func (a *TestAgent) pickRandomPorts(c *Config) {
}
}

// TestConfig returns a unique default configuration for testing an
// agent.
// TestConfig returns a unique default configuration for testing an agent.
func (a *TestAgent) config() *Config {
conf := DevConfig(nil)

Expand All @@ -361,10 +347,9 @@ func (a *TestAgent) config() *Config {
// Setup client config
conf.ClientConfig = client.DefaultConfig()

logger := testlog.HCLogger(a.T)
conf.LogLevel = testlog.HCLoggerTestLevel().String()
conf.NomadConfig.Logger = logger
conf.ClientConfig.Logger = logger
conf.NomadConfig.Logger = a.logger
conf.ClientConfig.Logger = a.logger

// Set the name
conf.NodeName = a.Name
Expand Down