mirror of
https://github.com/gravitational/teleport.git
synced 2026-10-11 22:49:54 +00:00
Introduce logtest package (#56741)
Moves all test related logger initialization and creation to the logtest package to reduce testing symbols in production code. The existing helpers in lib/utils have been left in place until the enterprise references can be converted. Updates #51023.
This commit is contained in:
@@ -56,7 +56,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/srv/db/common"
|
||||
"github.com/gravitational/teleport/lib/srv/db/postgres"
|
||||
"github.com/gravitational/teleport/lib/tlsca"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestDatabases(t *testing.T) {
|
||||
@@ -338,7 +338,7 @@ func connectPostgres(t *testing.T, ctx context.Context, info dbUserLogin, dbName
|
||||
_ = conn.Close(ctx)
|
||||
})
|
||||
return &pgConn{
|
||||
logger: utils.NewSlogLoggerForTests().With("test_name", t.Name()),
|
||||
logger: logtest.With("test_name", t.Name()),
|
||||
Conn: conn,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/client"
|
||||
"github.com/gravitational/teleport/lib/service/servicecfg"
|
||||
"github.com/gravitational/teleport/lib/services"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
// hostUser is the name of the host user used for tests.
|
||||
@@ -190,7 +190,7 @@ func newInstanceConfig(t *testing.T) helpers.InstanceConfig {
|
||||
NodeName: host,
|
||||
Priv: priv,
|
||||
Pub: pub,
|
||||
Logger: utils.NewSlogLoggerForTests(),
|
||||
Logger: logtest.NewLogger(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
|
||||
"github.com/gravitational/teleport/integration/helpers"
|
||||
"github.com/gravitational/teleport/lib"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -141,7 +141,7 @@ const (
|
||||
// TestMain will re-execute Teleport to run a command if "exec" is passed to
|
||||
// it as an argument. Otherwise, it will run tests as normal.
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
// agents connect over a reverse tunnel to proxy, so we use insecure mode.
|
||||
lib.SetInsecureDevMode(true)
|
||||
helpers.TestMainImplementation(m)
|
||||
|
||||
+2
-2
@@ -37,7 +37,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/auth/testauthority"
|
||||
"github.com/gravitational/teleport/lib/service/servicecfg"
|
||||
"github.com/gravitational/teleport/lib/services"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
// TestSignup sets up a test instance of Teleport and runs a playwright test against it to test the signup flow.
|
||||
@@ -98,7 +98,7 @@ func createTeleportTestInstanceForWebTests(t *testing.T) (instance *helpers.Tele
|
||||
ClusterName: "test-cluster",
|
||||
HostID: uuid.New().String(),
|
||||
NodeName: helpers.Host,
|
||||
Logger: utils.NewSlogLoggerForTests(),
|
||||
Logger: logtest.NewLogger(),
|
||||
Priv: privateKey,
|
||||
Pub: publicKey,
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@ import (
|
||||
apievents "github.com/gravitational/teleport/api/types/events"
|
||||
"github.com/gravitational/teleport/api/utils/prompt"
|
||||
"github.com/gravitational/teleport/api/utils/retryutils"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
logutils "github.com/gravitational/teleport/lib/utils/log"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestMigrateProcessDataObjects(t *testing.T) {
|
||||
@@ -62,7 +62,7 @@ func TestMigrateProcessDataObjects(t *testing.T) {
|
||||
},
|
||||
eventsEmitter: emitter,
|
||||
Config: Config{
|
||||
Logger: utils.NewSlogLoggerForTests(),
|
||||
Logger: logtest.NewLogger(),
|
||||
NoOfEmitWorkers: 5,
|
||||
bufferSize: 10,
|
||||
CheckpointPath: filepath.Join(t.TempDir(), "migration-tests.json"),
|
||||
@@ -133,7 +133,7 @@ func TestLargeEventsParse(t *testing.T) {
|
||||
},
|
||||
eventsEmitter: emitter,
|
||||
Config: Config{
|
||||
Logger: utils.NewSlogLoggerForTests(),
|
||||
Logger: logtest.NewLogger(),
|
||||
NoOfEmitWorkers: 5,
|
||||
bufferSize: 10,
|
||||
CheckpointPath: filepath.Join(t.TempDir(), "migration-tests.json"),
|
||||
@@ -223,7 +223,7 @@ func TestMigrationCheckpoint(t *testing.T) {
|
||||
|
||||
noOfWorkers := 3
|
||||
defaultConfig := Config{
|
||||
Logger: utils.NewSlogLoggerForTests(),
|
||||
Logger: logtest.NewLogger(),
|
||||
NoOfEmitWorkers: noOfWorkers,
|
||||
bufferSize: noOfWorkers * 5,
|
||||
CheckpointPath: filepath.Join(t.TempDir(), "migration-tests.json"),
|
||||
|
||||
@@ -41,6 +41,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/auth/testauthority"
|
||||
"github.com/gravitational/teleport/lib/service/servicecfg"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
type AppTestOptions struct {
|
||||
@@ -65,7 +66,7 @@ func SetupWithOptions(t *testing.T, opts AppTestOptions) *Pack {
|
||||
tr := utils.NewTracer(utils.ThisFunction()).Start()
|
||||
defer tr.Stop()
|
||||
|
||||
log := utils.NewSlogLoggerForTests()
|
||||
log := logtest.NewLogger()
|
||||
|
||||
// Insecure development mode needs to be set because the web proxy uses a
|
||||
// self-signed certificate during tests.
|
||||
|
||||
@@ -59,6 +59,7 @@ import (
|
||||
alpncommon "github.com/gravitational/teleport/lib/srv/alpnproxy/common"
|
||||
"github.com/gravitational/teleport/lib/srv/app/common"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
sliceutils "github.com/gravitational/teleport/lib/utils/slices"
|
||||
"github.com/gravitational/teleport/lib/web"
|
||||
"github.com/gravitational/teleport/lib/web/app"
|
||||
@@ -761,7 +762,7 @@ func (p *Pack) startRootAppServers(t *testing.T, count int, opts AppTestOptions)
|
||||
for i := range count {
|
||||
raConf := servicecfg.MakeDefaultConfig()
|
||||
raConf.Clock = opts.Clock
|
||||
raConf.Logger = utils.NewSlogLoggerForTests()
|
||||
raConf.Logger = logtest.NewLogger()
|
||||
raConf.DataDir = t.TempDir()
|
||||
raConf.SetToken("static-token-value")
|
||||
raConf.SetAuthServerAddress(utils.NetAddr{
|
||||
@@ -931,7 +932,7 @@ func (p *Pack) startLeafAppServers(t *testing.T, count int, opts AppTestOptions)
|
||||
for i := range count {
|
||||
laConf := servicecfg.MakeDefaultConfig()
|
||||
laConf.Clock = opts.Clock
|
||||
laConf.Logger = utils.NewSlogLoggerForTests()
|
||||
laConf.Logger = logtest.NewLogger()
|
||||
laConf.DataDir = t.TempDir()
|
||||
laConf.SetToken("static-token-value")
|
||||
laConf.SetAuthServerAddress(utils.NetAddr{
|
||||
|
||||
@@ -30,7 +30,7 @@ import (
|
||||
"github.com/gravitational/teleport/api/client"
|
||||
"github.com/gravitational/teleport/integration/helpers"
|
||||
"github.com/gravitational/teleport/lib/service/servicecfg"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
// TestClientWithExpiredCredentialsAndDetailedErrorMessage creates and connects to the Auth service
|
||||
@@ -41,7 +41,7 @@ func TestClientWithExpiredCredentialsAndDetailedErrorMessage(t *testing.T) {
|
||||
ClusterName: "root.example.com",
|
||||
HostID: uuid.New().String(),
|
||||
NodeName: Loopback,
|
||||
Logger: utils.NewSlogLoggerForTests(),
|
||||
Logger: logtest.NewLogger(),
|
||||
}
|
||||
cfg.Listeners = helpers.SingleProxyPortSetup(t, &cfg.Fds)
|
||||
rc := helpers.NewInstance(t, cfg)
|
||||
|
||||
@@ -51,6 +51,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/srv/db/postgres"
|
||||
"github.com/gravitational/teleport/lib/tlsca"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
type DatabasePack struct {
|
||||
@@ -253,7 +254,7 @@ func SetupDatabaseTest(t *testing.T, options ...TestOptionFunc) *DatabasePack {
|
||||
tracer := utils.NewTracer(utils.ThisFunction()).Start()
|
||||
t.Cleanup(func() { tracer.Stop() })
|
||||
lib.SetInsecureDevMode(true)
|
||||
log := utils.NewSlogLoggerForTests()
|
||||
log := logtest.NewLogger()
|
||||
|
||||
// Generate keypair.
|
||||
privateKey, publicKey, err := testauthority.New().GenerateKeyPair()
|
||||
|
||||
@@ -63,6 +63,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/services"
|
||||
"github.com/gravitational/teleport/lib/teleagent"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
// CommandOptions controls how the SSH command is built.
|
||||
@@ -379,7 +380,7 @@ func MakeTestServers(t *testing.T) (auth *service.TeleportProcess, proxy *servic
|
||||
cfg.SSH.Enabled = false
|
||||
cfg.Auth.Enabled = true
|
||||
cfg.Proxy.Enabled = false
|
||||
cfg.Logger = utils.NewSlogLoggerForTests()
|
||||
cfg.Logger = logtest.NewLogger()
|
||||
|
||||
auth, err = service.NewTeleport(cfg)
|
||||
require.NoError(t, err)
|
||||
@@ -417,7 +418,7 @@ func MakeTestServers(t *testing.T) (auth *service.TeleportProcess, proxy *servic
|
||||
cfg.Proxy.WebAddr,
|
||||
}
|
||||
cfg.Proxy.DisableWebInterface = true
|
||||
cfg.Logger = utils.NewSlogLoggerForTests()
|
||||
cfg.Logger = logtest.NewLogger()
|
||||
|
||||
proxy, err = service.NewTeleport(cfg)
|
||||
require.NoError(t, err)
|
||||
@@ -454,7 +455,7 @@ func MakeTestDatabaseServer(t *testing.T, proxyAddr utils.NetAddr, token string,
|
||||
cfg.Databases.Enabled = true
|
||||
cfg.Databases.Databases = dbs
|
||||
cfg.Databases.ResourceMatchers = resMatchers
|
||||
cfg.Logger = utils.NewSlogLoggerForTests()
|
||||
cfg.Logger = logtest.NewLogger()
|
||||
|
||||
db, err := service.NewTeleport(cfg)
|
||||
require.NoError(t, err)
|
||||
@@ -487,7 +488,7 @@ func MakeAgentServer(t *testing.T, cfg *servicecfg.Config, proxyAddr utils.NetAd
|
||||
cfg.Auth.Enabled = false
|
||||
cfg.Proxy.Enabled = false
|
||||
cfg.Databases.Enabled = false
|
||||
cfg.Logger = utils.NewSlogLoggerForTests()
|
||||
cfg.Logger = logtest.NewLogger()
|
||||
|
||||
agent, err := service.NewTeleport(cfg)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -26,14 +26,14 @@ import (
|
||||
"github.com/gravitational/teleport/lib/cryptosuites"
|
||||
"github.com/gravitational/teleport/lib/modules"
|
||||
"github.com/gravitational/teleport/lib/srv"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
"github.com/gravitational/teleport/tool/teleport/common"
|
||||
)
|
||||
|
||||
// TestMainImplementation will re-execute Teleport to run a command if "exec" is passed to
|
||||
// it as an argument. Otherwise, it will run tests as normal.
|
||||
func TestMainImplementation(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
cryptosuites.PrecomputeRSATestKeys(m)
|
||||
SetTestTimeouts(3 * time.Second)
|
||||
modules.SetInsecureTestMode(true)
|
||||
|
||||
@@ -54,6 +54,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/srv"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/host"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
"github.com/gravitational/teleport/lib/utils/testutils"
|
||||
)
|
||||
|
||||
@@ -652,7 +653,7 @@ func TestRootLoginAsHostUser(t *testing.T) {
|
||||
NodeName: Host,
|
||||
Priv: privateKey,
|
||||
Pub: publicKey,
|
||||
Logger: utils.NewSlogLoggerForTests(),
|
||||
Logger: logtest.NewLogger(),
|
||||
})
|
||||
|
||||
// Create a user that can create a host user.
|
||||
@@ -752,7 +753,7 @@ func TestRootStaticHostUsers(t *testing.T) {
|
||||
NodeName: Host,
|
||||
Priv: privateKey,
|
||||
Pub: publicKey,
|
||||
Logger: utils.NewSlogLoggerForTests(),
|
||||
Logger: logtest.NewLogger(),
|
||||
})
|
||||
|
||||
require.NoError(t, instance.Create(t, nil, false))
|
||||
|
||||
@@ -54,6 +54,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/service"
|
||||
"github.com/gravitational/teleport/lib/service/servicecfg"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
@@ -97,7 +98,7 @@ func liteBackendConfig(t *testing.T) *backend.Config {
|
||||
func TestHSMRotation(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
t.Cleanup(cancel)
|
||||
log := utils.NewSlogLoggerForTests().With(teleport.ComponentKey, "TestHSMRotation")
|
||||
log := logtest.With(teleport.ComponentKey, "TestHSMRotation")
|
||||
|
||||
log.DebugContext(ctx, "starting auth server")
|
||||
authConfig := newHSMAuthConfig(t, liteBackendConfig(t), log, clockwork.NewRealClock())
|
||||
@@ -208,7 +209,7 @@ func TestHSMDualAuthRotation(t *testing.T) {
|
||||
t.Setenv("TELEPORT_UNSTABLE_SKIP_VERSION_UPGRADE_CHECK", "1")
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
t.Cleanup(cancel)
|
||||
log := utils.NewSlogLoggerForTests().With(teleport.ComponentKey, "TestHSMDualAuthRotation")
|
||||
log := logtest.With(teleport.ComponentKey, "TestHSMDualAuthRotation")
|
||||
storageConfig := liteBackendConfig(t)
|
||||
|
||||
// start a cluster with 1 auth server
|
||||
@@ -390,7 +391,7 @@ func TestHSMMigrate(t *testing.T) {
|
||||
t.Setenv("TELEPORT_UNSTABLE_SKIP_VERSION_UPGRADE_CHECK", "1")
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
t.Cleanup(cancel)
|
||||
log := utils.NewSlogLoggerForTests().With(teleport.ComponentKey, "TestHSMMigrate")
|
||||
log := logtest.With(teleport.ComponentKey, "TestHSMMigrate")
|
||||
storageConfig := liteBackendConfig(t)
|
||||
|
||||
// start a dual auth non-hsm cluster
|
||||
@@ -537,7 +538,7 @@ func TestHSMRevert(t *testing.T) {
|
||||
clock := clockwork.NewFakeClock()
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
t.Cleanup(cancel)
|
||||
log := utils.NewSlogLoggerForTests().With(teleport.ComponentKey, "TestHSMRevert")
|
||||
log := logtest.With(teleport.ComponentKey, "TestHSMRevert")
|
||||
|
||||
log.DebugContext(ctx, "starting auth server")
|
||||
auth1Config := newHSMAuthConfig(t, liteBackendConfig(t), log, clock)
|
||||
|
||||
@@ -41,6 +41,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/service/servicecfg"
|
||||
"github.com/gravitational/teleport/lib/services"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
// basicDirCopy performs a very simplistic recursive copy from one directory to another. this helper was
|
||||
@@ -123,7 +124,7 @@ func TestInstanceCertReissue(t *testing.T) {
|
||||
authCfg.SSH.Enabled = true
|
||||
authCfg.SSH.Addr.Addr = "localhost:0"
|
||||
authCfg.CircuitBreakerConfig = breaker.NoopBreakerConfig()
|
||||
authCfg.Logger = utils.NewSlogLoggerForTests()
|
||||
authCfg.Logger = logtest.NewLogger()
|
||||
authCfg.InstanceMetadataClient = imds.NewDisabledIMDSClient()
|
||||
|
||||
authProc, err := service.NewTeleport(authCfg)
|
||||
@@ -162,7 +163,7 @@ func TestInstanceCertReissue(t *testing.T) {
|
||||
|
||||
agentCfg.WindowsDesktop.Enabled = true
|
||||
agentCfg.CircuitBreakerConfig = breaker.NoopBreakerConfig()
|
||||
agentCfg.Logger = utils.NewSlogLoggerForTests()
|
||||
agentCfg.Logger = logtest.NewLogger()
|
||||
agentCfg.MaxRetryPeriod = time.Second
|
||||
agentCfg.InstanceMetadataClient = imds.NewDisabledIMDSClient()
|
||||
|
||||
|
||||
@@ -104,6 +104,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/sshutils/x11"
|
||||
"github.com/gravitational/teleport/lib/tlsca"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
"github.com/gravitational/teleport/lib/web"
|
||||
"github.com/gravitational/teleport/tool/teleport/testenv"
|
||||
)
|
||||
@@ -123,7 +124,7 @@ func (s *integrationTestSuite) bind(test integrationTest) func(t *testing.T) {
|
||||
// Attempt to set a logger for the test. Be warned that parts of the
|
||||
// Teleport codebase do not honor the logger passed in via config and
|
||||
// will create their own. Do not expect to catch _all_ output with this.
|
||||
s.Log = utils.NewSlogLoggerForTests()
|
||||
s.Log = logtest.NewLogger()
|
||||
os.RemoveAll(profile.FullProfilePath(""))
|
||||
t.Cleanup(func() { s.Log = nil })
|
||||
test(t, s)
|
||||
@@ -1901,7 +1902,7 @@ func testClientIdleConnection(t *testing.T, suite *integrationTestSuite) {
|
||||
|
||||
tconf := servicecfg.MakeDefaultConfig()
|
||||
tconf.SSH.Enabled = true
|
||||
tconf.Logger = utils.NewSlogLoggerForTests()
|
||||
tconf.Logger = logtest.NewLogger()
|
||||
tconf.Proxy.DisableWebService = true
|
||||
tconf.Proxy.DisableWebInterface = true
|
||||
tconf.Auth.NetworkingConfig = netConfig
|
||||
@@ -7286,7 +7287,7 @@ func TestWebProxyInsecure(t *testing.T) {
|
||||
NodeName: Host,
|
||||
Priv: privateKey,
|
||||
Pub: publicKey,
|
||||
Logger: utils.NewSlogLoggerForTests(),
|
||||
Logger: logtest.NewLogger(),
|
||||
})
|
||||
|
||||
rcConf := servicecfg.MakeDefaultConfig()
|
||||
@@ -7320,7 +7321,7 @@ func TestWebProxyInsecure(t *testing.T) {
|
||||
// roles in root and leaf clusters.
|
||||
func TestTraitsPropagation(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
log := utils.NewSlogLoggerForTests()
|
||||
log := logtest.NewLogger()
|
||||
|
||||
privateKey, publicKey, err := testauthority.New().GenerateKeyPair()
|
||||
require.NoError(t, err)
|
||||
@@ -8501,7 +8502,7 @@ func TestProxySSHPortMultiplexing(t *testing.T) {
|
||||
NodeName: Host,
|
||||
Priv: privateKey,
|
||||
Pub: publicKey,
|
||||
Logger: utils.NewSlogLoggerForTests(),
|
||||
Logger: logtest.NewLogger(),
|
||||
})
|
||||
|
||||
rcConf := servicecfg.MakeDefaultConfig()
|
||||
@@ -8625,7 +8626,7 @@ func TestConnectivityWithoutAuth(t *testing.T) {
|
||||
|
||||
// Create auth config.
|
||||
authCfg := servicecfg.MakeDefaultConfig()
|
||||
authCfg.Logger = utils.NewSlogLoggerForTests()
|
||||
authCfg.Logger = logtest.NewLogger()
|
||||
authCfg.CircuitBreakerConfig = breaker.NoopBreakerConfig()
|
||||
authCfg.InstanceMetadataClient = imds.NewDisabledIMDSClient()
|
||||
authCfg.Auth.Preference.SetSecondFactor("off")
|
||||
@@ -8643,7 +8644,7 @@ func TestConnectivityWithoutAuth(t *testing.T) {
|
||||
NodeName: Host,
|
||||
Priv: privateKey,
|
||||
Pub: publicKey,
|
||||
Logger: utils.NewSlogLoggerForTests(),
|
||||
Logger: logtest.NewLogger(),
|
||||
})
|
||||
|
||||
// Create a user and role.
|
||||
@@ -8678,7 +8679,7 @@ func TestConnectivityWithoutAuth(t *testing.T) {
|
||||
NodeName: Host,
|
||||
Priv: privateKey,
|
||||
Pub: publicKey,
|
||||
Logger: utils.NewSlogLoggerForTests(),
|
||||
Logger: logtest.NewLogger(),
|
||||
})
|
||||
|
||||
// Create node config.
|
||||
@@ -8687,7 +8688,7 @@ func TestConnectivityWithoutAuth(t *testing.T) {
|
||||
nodeCfg.SetToken("token")
|
||||
nodeCfg.CachePolicy.Enabled = true
|
||||
nodeCfg.DataDir = t.TempDir()
|
||||
nodeCfg.Logger = utils.NewSlogLoggerForTests()
|
||||
nodeCfg.Logger = logtest.NewLogger()
|
||||
nodeCfg.CircuitBreakerConfig = breaker.NoopBreakerConfig()
|
||||
nodeCfg.InstanceMetadataClient = imds.NewDisabledIMDSClient()
|
||||
nodeCfg.Auth.Enabled = false
|
||||
@@ -8767,7 +8768,7 @@ func TestConnectivityDuringAuthRestart(t *testing.T) {
|
||||
|
||||
// Create auth config.
|
||||
authCfg := servicecfg.MakeDefaultConfig()
|
||||
authCfg.Logger = utils.NewSlogLoggerForTests()
|
||||
authCfg.Logger = logtest.NewLogger()
|
||||
authCfg.CircuitBreakerConfig = breaker.NoopBreakerConfig()
|
||||
authCfg.InstanceMetadataClient = imds.NewDisabledIMDSClient()
|
||||
authCfg.Auth.Preference.SetSecondFactor("off")
|
||||
@@ -8785,7 +8786,7 @@ func TestConnectivityDuringAuthRestart(t *testing.T) {
|
||||
NodeName: Host,
|
||||
Priv: privateKey,
|
||||
Pub: publicKey,
|
||||
Logger: utils.NewSlogLoggerForTests(),
|
||||
Logger: logtest.NewLogger(),
|
||||
})
|
||||
|
||||
// Create a user and role.
|
||||
@@ -8817,7 +8818,7 @@ func TestConnectivityDuringAuthRestart(t *testing.T) {
|
||||
NodeName: Host,
|
||||
Priv: privateKey,
|
||||
Pub: publicKey,
|
||||
Logger: utils.NewSlogLoggerForTests(),
|
||||
Logger: logtest.NewLogger(),
|
||||
})
|
||||
|
||||
// Create node config.
|
||||
@@ -8826,7 +8827,7 @@ func TestConnectivityDuringAuthRestart(t *testing.T) {
|
||||
nodeCfg.SetToken("token")
|
||||
nodeCfg.CachePolicy.Enabled = true
|
||||
nodeCfg.DataDir = t.TempDir()
|
||||
nodeCfg.Logger = utils.NewSlogLoggerForTests()
|
||||
nodeCfg.Logger = logtest.NewLogger()
|
||||
nodeCfg.CircuitBreakerConfig = breaker.NoopBreakerConfig()
|
||||
nodeCfg.InstanceMetadataClient = imds.NewDisabledIMDSClient()
|
||||
nodeCfg.DiagnosticAddr = *utils.MustParseAddr(helpers.NewListener(t, service.ListenerType("diag"), &node.Fds))
|
||||
|
||||
@@ -37,7 +37,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/openssh"
|
||||
"github.com/gravitational/teleport/lib/service"
|
||||
"github.com/gravitational/teleport/lib/service/servicecfg"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestJoinOpenSSH(t *testing.T) {
|
||||
@@ -47,7 +47,7 @@ func TestJoinOpenSSH(t *testing.T) {
|
||||
ClusterName: "root.example.com",
|
||||
HostID: uuid.New().String(),
|
||||
NodeName: Loopback,
|
||||
Logger: utils.NewSlogLoggerForTests(),
|
||||
Logger: logtest.NewLogger(),
|
||||
}
|
||||
cfg.Listeners = helpers.StandardListenerSetup(t, &cfg.Fds)
|
||||
rc := helpers.NewInstance(t, cfg)
|
||||
|
||||
@@ -88,6 +88,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/session"
|
||||
"github.com/gravitational/teleport/lib/tlsca"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
"github.com/gravitational/teleport/lib/web"
|
||||
"github.com/gravitational/teleport/lib/web/terminal"
|
||||
)
|
||||
@@ -170,7 +171,7 @@ type kubeIntegrationTest func(t *testing.T, suite *KubeSuite)
|
||||
|
||||
func (s *KubeSuite) bind(test kubeIntegrationTest) func(t *testing.T) {
|
||||
return func(t *testing.T) {
|
||||
s.log = utils.NewSlogLoggerForTests()
|
||||
s.log = logtest.NewLogger()
|
||||
os.RemoveAll(profile.FullProfilePath(""))
|
||||
t.Cleanup(func() { s.log = nil })
|
||||
test(t, s)
|
||||
@@ -1782,7 +1783,7 @@ func testKubeExecWeb(t *testing.T, suite *KubeSuite) {
|
||||
|
||||
ws := openWebsocketAndReadSession(t, endpoint, req)
|
||||
|
||||
wsStream := terminal.NewWStream(context.Background(), ws, utils.NewSlogLoggerForTests(), nil)
|
||||
wsStream := terminal.NewWStream(context.Background(), ws, logtest.NewLogger(), nil)
|
||||
|
||||
// Check for the expected string in the output.
|
||||
findTextInReader(t, wsStream, testNamespace, time.Second*2)
|
||||
@@ -1803,7 +1804,7 @@ func testKubeExecWeb(t *testing.T, suite *KubeSuite) {
|
||||
|
||||
ws := openWebsocketAndReadSession(t, endpoint, req)
|
||||
|
||||
wsStream := terminal.NewWStream(context.Background(), ws, utils.NewSlogLoggerForTests(), nil)
|
||||
wsStream := terminal.NewWStream(context.Background(), ws, logtest.NewLogger(), nil)
|
||||
|
||||
// Read first prompt from the server.
|
||||
readData := make([]byte, 255)
|
||||
|
||||
@@ -40,7 +40,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/auth/testauthority"
|
||||
"github.com/gravitational/teleport/lib/client"
|
||||
"github.com/gravitational/teleport/lib/service/servicecfg"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
"github.com/gravitational/teleport/lib/utils/testutils"
|
||||
)
|
||||
|
||||
@@ -171,7 +171,7 @@ func testPortForwarding(t *testing.T, suite *integrationTestSuite) {
|
||||
NodeName: Host,
|
||||
Priv: privateKey,
|
||||
Pub: publicKey,
|
||||
Logger: utils.NewSlogLoggerForTests(),
|
||||
Logger: logtest.NewLogger(),
|
||||
})
|
||||
|
||||
for _, login := range logins {
|
||||
@@ -197,7 +197,7 @@ func testPortForwarding(t *testing.T, suite *integrationTestSuite) {
|
||||
NodeName: Host,
|
||||
Priv: privateKey,
|
||||
Pub: publicKey,
|
||||
Logger: utils.NewSlogLoggerForTests(),
|
||||
Logger: logtest.NewLogger(),
|
||||
})
|
||||
|
||||
// Create node config.
|
||||
|
||||
@@ -37,7 +37,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/automaticupgrades"
|
||||
"github.com/gravitational/teleport/lib/automaticupgrades/constants"
|
||||
"github.com/gravitational/teleport/lib/service/servicecfg"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func createProxyWithChannels(t *testing.T, channels automaticupgrades.Channels) string {
|
||||
@@ -48,7 +48,7 @@ func createProxyWithChannels(t *testing.T, channels automaticupgrades.Channels)
|
||||
ClusterName: "root.example.com",
|
||||
HostID: uuid.New().String(),
|
||||
NodeName: helpers.Loopback,
|
||||
Logger: utils.NewSlogLoggerForTests(),
|
||||
Logger: logtest.NewLogger(),
|
||||
}
|
||||
cfg.Listeners = helpers.SingleProxyPortSetup(t, &cfg.Fds)
|
||||
rc := helpers.NewInstance(t, cfg)
|
||||
|
||||
@@ -69,6 +69,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/teleterm/gateway"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
awsutils "github.com/gravitational/teleport/lib/utils/aws"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
type Suite struct {
|
||||
@@ -115,7 +116,7 @@ func newSuite(t *testing.T, opts ...proxySuiteOptionsFunc) *Suite {
|
||||
ClusterName: "root.example.com",
|
||||
HostID: uuid.New().String(),
|
||||
NodeName: options.rootClusterNodeName,
|
||||
Logger: utils.NewSlogLoggerForTests(),
|
||||
Logger: logtest.NewLogger(),
|
||||
}
|
||||
rCfg.Listeners = options.rootClusterListeners(t, &rCfg.Fds)
|
||||
rc := helpers.NewInstance(t, rCfg)
|
||||
@@ -127,7 +128,7 @@ func newSuite(t *testing.T, opts ...proxySuiteOptionsFunc) *Suite {
|
||||
NodeName: options.leafClusterNodeName,
|
||||
Priv: rc.Secrets.PrivKey,
|
||||
Pub: rc.Secrets.PubKey,
|
||||
Logger: utils.NewSlogLoggerForTests(),
|
||||
Logger: logtest.NewLogger(),
|
||||
}
|
||||
lCfg.Listeners = options.leafClusterListeners(t, &lCfg.Fds)
|
||||
lc := helpers.NewInstance(t, lCfg)
|
||||
@@ -195,7 +196,7 @@ func newSuite(t *testing.T, opts ...proxySuiteOptionsFunc) *Suite {
|
||||
func (p *Suite) addNodeToLeafCluster(t *testing.T, tunnelNodeHostname string) {
|
||||
nodeConfig := func() *servicecfg.Config {
|
||||
tconf := servicecfg.MakeDefaultConfig()
|
||||
tconf.Logger = utils.NewSlogLoggerForTests()
|
||||
tconf.Logger = logtest.NewLogger()
|
||||
tconf.Hostname = tunnelNodeHostname
|
||||
tconf.SetToken("token")
|
||||
tconf.SetAuthServerAddress(utils.NetAddr{
|
||||
|
||||
@@ -68,6 +68,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/srv/db/postgres"
|
||||
"github.com/gravitational/teleport/lib/tlsca"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
// TestALPNSNIProxyMultiCluster tests SSH connection in multi-cluster setup with.
|
||||
@@ -562,7 +563,7 @@ func TestKubePROXYProtocol(t *testing.T) {
|
||||
ClusterName: "root.example.com",
|
||||
HostID: uuid.New().String(),
|
||||
NodeName: helpers.Loopback,
|
||||
Logger: utils.NewSlogLoggerForTests(),
|
||||
Logger: logtest.NewLogger(),
|
||||
}
|
||||
tconf := servicecfg.MakeDefaultConfig()
|
||||
tconf.Proxy.Kube.ListenAddr = *utils.MustParseAddr(helpers.NewListener(t, service.ListenerProxyKube, &cfg.Fds))
|
||||
@@ -1406,7 +1407,7 @@ func TestALPNProxyAuthClientConnectWithUserIdentity(t *testing.T) {
|
||||
ClusterName: "root.example.com",
|
||||
HostID: uuid.New().String(),
|
||||
NodeName: helpers.Loopback,
|
||||
Logger: utils.NewSlogLoggerForTests(),
|
||||
Logger: logtest.NewLogger(),
|
||||
}
|
||||
cfg.Listeners = helpers.SingleProxyPortSetup(t, &cfg.Fds)
|
||||
rc := helpers.NewInstance(t, cfg)
|
||||
@@ -1510,7 +1511,7 @@ func TestALPNProxyDialProxySSHWithoutInsecureMode(t *testing.T) {
|
||||
NodeName: helpers.Loopback,
|
||||
Priv: privateKey,
|
||||
Pub: publicKey,
|
||||
Logger: utils.NewSlogLoggerForTests(),
|
||||
Logger: logtest.NewLogger(),
|
||||
}
|
||||
rootCfg.Listeners = helpers.StandardListenerSetup(t, &rootCfg.Fds)
|
||||
rc := helpers.NewInstance(t, rootCfg)
|
||||
@@ -1580,7 +1581,7 @@ func TestALPNProxyHTTPProxyNoProxyDial(t *testing.T) {
|
||||
ClusterName: "root.example.com",
|
||||
HostID: uuid.New().String(),
|
||||
NodeName: addr,
|
||||
Logger: utils.NewSlogLoggerForTests(),
|
||||
Logger: logtest.NewLogger(),
|
||||
}
|
||||
instanceCfg.Listeners = helpers.SingleProxyPortSetupOn(addr)(t, &instanceCfg.Fds)
|
||||
rc := helpers.NewInstance(t, instanceCfg)
|
||||
@@ -1647,7 +1648,7 @@ func TestALPNProxyHTTPProxyBasicAuthDial(t *testing.T) {
|
||||
lib.SetInsecureDevMode(true)
|
||||
defer lib.SetInsecureDevMode(false)
|
||||
|
||||
log := utils.NewSlogLoggerForTests()
|
||||
log := logtest.NewLogger()
|
||||
|
||||
// We need to use the non-loopback address for our Teleport cluster, as the
|
||||
// Go HTTP library will recognize requests to the loopback address and
|
||||
|
||||
@@ -48,6 +48,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/srv/db/postgres"
|
||||
"github.com/gravitational/teleport/lib/tlsca"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
type proxyTunnelStrategy struct {
|
||||
@@ -300,7 +301,7 @@ func (p *proxyTunnelStrategy) makeAuth(t *testing.T) {
|
||||
NodeName: helpers.Loopback,
|
||||
Priv: privateKey,
|
||||
Pub: publicKey,
|
||||
Logger: utils.NewSlogLoggerForTests(),
|
||||
Logger: logtest.NewLogger(),
|
||||
})
|
||||
|
||||
auth.AddUser(p.username, []string{p.username})
|
||||
@@ -328,7 +329,7 @@ func (p *proxyTunnelStrategy) makeProxy(t *testing.T) {
|
||||
ClusterName: p.cluster,
|
||||
HostID: uuid.New().String(),
|
||||
NodeName: helpers.Loopback,
|
||||
Logger: utils.NewSlogLoggerForTests(),
|
||||
Logger: logtest.NewLogger(),
|
||||
})
|
||||
|
||||
authAddr := utils.MustParseAddr(p.auth.Auth)
|
||||
@@ -375,7 +376,7 @@ func (p *proxyTunnelStrategy) makeNode(t *testing.T) {
|
||||
ClusterName: p.cluster,
|
||||
HostID: uuid.New().String(),
|
||||
NodeName: helpers.Loopback,
|
||||
Logger: utils.NewSlogLoggerForTests(),
|
||||
Logger: logtest.NewLogger(),
|
||||
})
|
||||
|
||||
conf := servicecfg.MakeDefaultConfig()
|
||||
@@ -420,7 +421,7 @@ func (p *proxyTunnelStrategy) makeDatabase(t *testing.T) {
|
||||
ClusterName: p.cluster,
|
||||
HostID: uuid.New().String(),
|
||||
NodeName: helpers.Loopback,
|
||||
Logger: utils.NewSlogLoggerForTests(),
|
||||
Logger: logtest.NewLogger(),
|
||||
})
|
||||
|
||||
conf := servicecfg.MakeDefaultConfig()
|
||||
|
||||
@@ -46,6 +46,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/reversetunnelclient"
|
||||
"github.com/gravitational/teleport/lib/service/servicecfg"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
"github.com/gravitational/teleport/tool/tctl/common"
|
||||
)
|
||||
|
||||
@@ -62,7 +63,7 @@ func TestTCTLTerraformCommand_ProxyJoin(t *testing.T) {
|
||||
ClusterName: clusterName,
|
||||
HostID: uuid.New().String(),
|
||||
NodeName: helpers.Loopback,
|
||||
Logger: utils.NewSlogLoggerForTests(),
|
||||
Logger: logtest.NewLogger(),
|
||||
}
|
||||
cfg.Listeners = helpers.SingleProxyPortSetup(t, &cfg.Fds)
|
||||
rc := helpers.NewInstance(t, cfg)
|
||||
@@ -138,7 +139,7 @@ func TestTCTLTerraformCommand_AuthJoin(t *testing.T) {
|
||||
ClusterName: clusterName,
|
||||
HostID: uuid.New().String(),
|
||||
NodeName: helpers.Loopback,
|
||||
Logger: utils.NewSlogLoggerForTests(),
|
||||
Logger: logtest.NewLogger(),
|
||||
}
|
||||
cfg.Listeners = helpers.SingleProxyPortSetup(t, &cfg.Fds)
|
||||
rc := helpers.NewInstance(t, cfg)
|
||||
@@ -240,7 +241,7 @@ func getAuthClientForProxy(t *testing.T, tc *helpers.TeleInstance, username stri
|
||||
TLS: tlsConfig,
|
||||
SSH: sshConfig,
|
||||
AuthServers: []utils.NetAddr{*authAddr},
|
||||
Log: utils.NewSlogLoggerForTests(),
|
||||
Log: logtest.NewLogger(),
|
||||
CircuitBreakerConfig: breaker.Config{},
|
||||
DialTimeout: 0,
|
||||
DialOpts: nil,
|
||||
@@ -293,7 +294,7 @@ func getAuthClientForAuth(t *testing.T, tc *helpers.TeleInstance, username strin
|
||||
clientConfig := &authclient.Config{
|
||||
TLS: tlsConfig,
|
||||
AuthServers: []utils.NetAddr{*authAddr},
|
||||
Log: utils.NewSlogLoggerForTests(),
|
||||
Log: logtest.NewLogger(),
|
||||
CircuitBreakerConfig: breaker.Config{},
|
||||
DialTimeout: 0,
|
||||
DialOpts: nil,
|
||||
|
||||
@@ -63,7 +63,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/teleterm/clusters"
|
||||
"github.com/gravitational/teleport/lib/teleterm/daemon"
|
||||
"github.com/gravitational/teleport/lib/tlsca"
|
||||
libutils "github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestTeleterm(t *testing.T) {
|
||||
@@ -969,7 +969,7 @@ func testWaitForConnectMyComputerNodeJoin(t *testing.T, pack *dbhelpers.Database
|
||||
nodeConfig := newNodeConfig(t, "token", types.JoinMethodToken)
|
||||
nodeConfig.SetAuthServerAddress(pack.Root.Cluster.Config.Auth.ListenAddr)
|
||||
nodeConfig.DataDir = filepath.Join(agentsDir, profileName, "data")
|
||||
nodeConfig.Logger = libutils.NewSlogLoggerForTests()
|
||||
nodeConfig.Logger = logtest.NewLogger()
|
||||
nodeSvc, err := service.NewTeleport(nodeConfig)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, nodeSvc.Start())
|
||||
@@ -1044,7 +1044,7 @@ func testDeleteConnectMyComputerNode(t *testing.T, pack *dbhelpers.DatabasePack)
|
||||
nodeConfig := newNodeConfig(t, "token", types.JoinMethodToken)
|
||||
nodeConfig.SetAuthServerAddress(pack.Root.Cluster.Config.Auth.ListenAddr)
|
||||
nodeConfig.DataDir = filepath.Join(agentsDir, profileName, "data")
|
||||
nodeConfig.Logger = libutils.NewSlogLoggerForTests()
|
||||
nodeConfig.Logger = logtest.NewLogger()
|
||||
nodeSvc, err := service.NewTeleport(nodeConfig)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, nodeSvc.Start())
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func mustParseURL(t *testing.T, urlString string) *url.URL {
|
||||
@@ -31,7 +31,7 @@ func mustParseURL(t *testing.T, urlString string) *url.URL {
|
||||
|
||||
func Test_CheckChannelURL(t *testing.T) {
|
||||
b := &Bot{
|
||||
log: utils.NewSlogLoggerForTests(),
|
||||
log: logtest.NewLogger(),
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
|
||||
@@ -34,14 +34,14 @@ import (
|
||||
"github.com/gravitational/teleport/integrations/operator/controllers/resources/testlib"
|
||||
"github.com/gravitational/teleport/lib/service/servicecfg"
|
||||
"github.com/gravitational/teleport/lib/tbot/config"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestBotJoinAuth(t *testing.T) {
|
||||
// Configure and start Teleport server
|
||||
clusterName := "root.example.com"
|
||||
ctx := context.Background()
|
||||
logger := utils.NewSlogLoggerForTests()
|
||||
logger := logtest.NewLogger()
|
||||
teleportServer := helpers.NewInstance(t, helpers.InstanceConfig{
|
||||
ClusterName: clusterName,
|
||||
HostID: uuid.New().String(),
|
||||
|
||||
@@ -57,7 +57,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/modules"
|
||||
"github.com/gravitational/teleport/lib/modules/modulestest"
|
||||
"github.com/gravitational/teleport/lib/service/servicecfg"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
// scheme is our own test-specific scheme to avoid using the global
|
||||
@@ -218,7 +218,7 @@ func (s *TestSetup) StartKubernetesOperator(t *testing.T) {
|
||||
|
||||
slogLogger := s.log
|
||||
if slogLogger == nil {
|
||||
slogLogger = utils.NewSlogLoggerForTests()
|
||||
slogLogger = logtest.NewLogger()
|
||||
}
|
||||
|
||||
logger := logr.FromSlogHandler(slogLogger.Handler())
|
||||
|
||||
@@ -42,7 +42,7 @@ import (
|
||||
"github.com/gravitational/teleport/integrations/operator/controllers/resources/testlib"
|
||||
"github.com/gravitational/teleport/lib"
|
||||
"github.com/gravitational/teleport/lib/service/servicecfg"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
type trustedClusterV2TestingPrimitives struct {
|
||||
@@ -137,7 +137,7 @@ func (r *trustedClusterV2TestingPrimitives) setupTest(t *testing.T, clusterName
|
||||
ClusterName: clusterName,
|
||||
HostID: uuid.New().String(),
|
||||
NodeName: helpers.Loopback,
|
||||
Logger: utils.NewSlogLoggerForTests(),
|
||||
Logger: logtest.NewLogger(),
|
||||
})
|
||||
r.remoteCluster = remoteCluster
|
||||
|
||||
|
||||
@@ -25,12 +25,12 @@ import (
|
||||
"github.com/hashicorp/terraform-plugin-testing/terraform"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
"github.com/gravitational/teleport/tool/teleport/testenv"
|
||||
)
|
||||
|
||||
func TestAccKubernetesDataSource(t *testing.T) {
|
||||
log := utils.NewSlogLoggerForTests()
|
||||
log := logtest.NewLogger()
|
||||
ctx := t.Context()
|
||||
|
||||
process, kubeMock := setupKubernetesHarness(t, log)
|
||||
|
||||
@@ -26,12 +26,12 @@ import (
|
||||
"github.com/hashicorp/terraform-plugin-testing/tfversion"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
"github.com/gravitational/teleport/tool/teleport/testenv"
|
||||
)
|
||||
|
||||
func TestAccKubernetesEphemeralResource(t *testing.T) {
|
||||
log := utils.NewSlogLoggerForTests()
|
||||
log := logtest.NewLogger()
|
||||
ctx := t.Context()
|
||||
|
||||
process, kubeMock := setupKubernetesHarness(t, log)
|
||||
|
||||
@@ -87,6 +87,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/sshca"
|
||||
"github.com/gravitational/teleport/lib/tlsca"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
type testPack struct {
|
||||
@@ -228,7 +229,7 @@ func newAuthSuite(t *testing.T) *testPack {
|
||||
}
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
cryptosuites.PrecomputeRSATestKeys(m)
|
||||
modules.SetInsecureTestMode(true)
|
||||
os.Exit(m.Run())
|
||||
|
||||
@@ -38,7 +38,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/backend/memory"
|
||||
"github.com/gravitational/teleport/lib/inventory"
|
||||
"github.com/gravitational/teleport/lib/services/local"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func newFakeControlStream() fakeControlStream {
|
||||
@@ -245,7 +245,7 @@ func TestServer_generateAgentVersionReport(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
auth := &Server{
|
||||
cancelFunc: func() {},
|
||||
logger: utils.NewSlogLoggerForTests(),
|
||||
logger: logtest.NewLogger(),
|
||||
ServerID: uuid.NewString(),
|
||||
Services: &Services{
|
||||
// The inventory is running heartbeats on the background.
|
||||
@@ -321,7 +321,7 @@ func TestServer_reportAgentVersions(t *testing.T) {
|
||||
// If we don't create a presence service this will cause panics.
|
||||
PresenceInternal: local.NewPresenceService(bk),
|
||||
},
|
||||
logger: utils.NewSlogLoggerForTests(),
|
||||
logger: logtest.NewLogger(),
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
auth.Close()
|
||||
|
||||
@@ -38,7 +38,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/backend/memory"
|
||||
"github.com/gravitational/teleport/lib/inventory"
|
||||
"github.com/gravitational/teleport/lib/services/local"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestSampleAgentsFromGroup(t *testing.T) {
|
||||
@@ -50,7 +50,7 @@ func TestSampleAgentsFromGroup(t *testing.T) {
|
||||
cancelFunc: func() {},
|
||||
clock: clock,
|
||||
ServerID: uuid.NewString(),
|
||||
logger: utils.NewSlogLoggerForTests(),
|
||||
logger: logtest.NewLogger(),
|
||||
Services: &Services{
|
||||
// The inventory is running heartbeats on the background.
|
||||
// If we don't create a presence service this will cause panics.
|
||||
@@ -145,7 +145,7 @@ func TestLookupAgentInInventory(t *testing.T) {
|
||||
cancelFunc: func() {},
|
||||
clock: clock,
|
||||
ServerID: uuid.NewString(),
|
||||
logger: utils.NewSlogLoggerForTests(),
|
||||
logger: logtest.NewLogger(),
|
||||
Services: &Services{
|
||||
// The inventory is running heartbeats on the background.
|
||||
// If we don't create a presence service this will cause panics.
|
||||
|
||||
@@ -69,6 +69,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/tbot/identity"
|
||||
"github.com/gravitational/teleport/lib/tlsca"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func renewBotCerts(
|
||||
@@ -840,7 +841,7 @@ func authClientForRegisterResult(t *testing.T, ctx context.Context, addr *utils.
|
||||
nil /* clock */)
|
||||
require.NoError(t, err)
|
||||
|
||||
log := utils.NewSlogLoggerForTests()
|
||||
log := logtest.NewLogger()
|
||||
dialer, err := reversetunnelclient.NewTunnelAuthDialer(reversetunnelclient.TunnelAuthDialerConfig{
|
||||
Resolver: resolver,
|
||||
ClientConfig: sshConfig,
|
||||
|
||||
@@ -50,6 +50,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/modules/modulestest"
|
||||
"github.com/gravitational/teleport/lib/services"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
type githubContext struct {
|
||||
@@ -189,7 +190,7 @@ func TestValidateGithubAuthCallbackEventsEmitted(t *testing.T) {
|
||||
clientAddr := &net.TCPAddr{IP: net.IPv4(10, 255, 0, 0)}
|
||||
ctx := authz.ContextWithClientSrcAddr(context.Background(), clientAddr)
|
||||
tt := setupGithubContext(ctx, t)
|
||||
logger := utils.NewSlogLoggerForTests()
|
||||
logger := logtest.NewLogger()
|
||||
|
||||
auth := &authclient.GithubAuthResponse{
|
||||
Username: "test-name",
|
||||
|
||||
@@ -39,11 +39,11 @@ import (
|
||||
"github.com/gravitational/teleport/lib/services"
|
||||
"github.com/gravitational/teleport/lib/services/local"
|
||||
"github.com/gravitational/teleport/lib/tlsca"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
|
||||
@@ -47,11 +47,11 @@ import (
|
||||
"github.com/gravitational/teleport/lib/services"
|
||||
"github.com/gravitational/teleport/lib/services/local"
|
||||
"github.com/gravitational/teleport/lib/tlsca"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/service/servicecfg"
|
||||
"github.com/gravitational/teleport/lib/services"
|
||||
"github.com/gravitational/teleport/lib/tlsca"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -550,7 +550,7 @@ func newTestPack(ctx context.Context, t *testing.T) *testPack {
|
||||
var backends []*backendDesc
|
||||
|
||||
hostUUID := uuid.NewString()
|
||||
logger := utils.NewSlogLoggerForTests()
|
||||
logger := logtest.NewLogger()
|
||||
|
||||
unusedPKCS11Key, err := keyID{
|
||||
HostID: hostUUID,
|
||||
|
||||
@@ -45,7 +45,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/backend/memory"
|
||||
"github.com/gravitational/teleport/lib/fixtures"
|
||||
"github.com/gravitational/teleport/lib/services/local"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func makeTrustDomain(t *testing.T, name string) (spiffeid.TrustDomain, *spiffebundle.Bundle) {
|
||||
@@ -65,7 +65,7 @@ func TestSPIFFEFederationSyncer(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
t.Cleanup(cancel)
|
||||
|
||||
logger := utils.NewSlogLoggerForTests()
|
||||
logger := logtest.NewLogger()
|
||||
clock := clockwork.NewRealClock()
|
||||
backend, err := memory.New(memory.Config{})
|
||||
require.NoError(t, err)
|
||||
@@ -203,7 +203,7 @@ func TestSPIFFEFederationSyncer_syncFederation(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
t.Cleanup(cancel)
|
||||
|
||||
logger := utils.NewSlogLoggerForTests()
|
||||
logger := logtest.NewLogger()
|
||||
clock := clockwork.NewFakeClock()
|
||||
backend, err := memory.New(memory.Config{})
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -29,7 +29,7 @@ import (
|
||||
|
||||
"github.com/gravitational/teleport/lib/backend"
|
||||
"github.com/gravitational/teleport/lib/backend/memory"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
type testMigration struct {
|
||||
@@ -63,7 +63,7 @@ func (t testMigration) Name() string {
|
||||
}
|
||||
|
||||
func TestApply(t *testing.T) {
|
||||
log := utils.NewSlogLoggerForTests()
|
||||
log := logtest.NewLogger()
|
||||
cases := []struct {
|
||||
name string
|
||||
migrations []migration
|
||||
|
||||
@@ -42,7 +42,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/cryptosuites"
|
||||
"github.com/gravitational/teleport/lib/services"
|
||||
"github.com/gravitational/teleport/lib/services/local"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
type oaepDecrypter struct {
|
||||
@@ -137,7 +137,7 @@ func newManagerConfig(t *testing.T, bk backend.Backend, keyType types.PrivateKey
|
||||
Cache: recordingEncryptionService,
|
||||
ClusterConfig: clusterConfigService,
|
||||
KeyStore: &fakeKeyStore{keyType: keyType},
|
||||
Logger: utils.NewSlogLoggerForTests(),
|
||||
Logger: logtest.NewLogger(),
|
||||
LockConfig: backend.RunWhileLockedConfig{
|
||||
LockConfiguration: backend.LockConfiguration{
|
||||
Backend: bk,
|
||||
|
||||
@@ -37,11 +37,11 @@ import (
|
||||
"github.com/gravitational/teleport/lib/backend/memory"
|
||||
"github.com/gravitational/teleport/lib/services/local"
|
||||
"github.com/gravitational/teleport/lib/services/readonly"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/modules/modulestest"
|
||||
"github.com/gravitational/teleport/lib/services"
|
||||
"github.com/gravitational/teleport/lib/services/local"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
const ownerUser = "owner"
|
||||
@@ -739,7 +739,7 @@ func initGeneratorSvc(t *testing.T) (*Generator, *svc) {
|
||||
emitter := &eventstest.MockRecorderEmitter{}
|
||||
|
||||
generator, err := NewGenerator(GeneratorConfig{
|
||||
Log: utils.NewSlogLoggerForTests(),
|
||||
Log: logtest.NewLogger(),
|
||||
AccessLists: svc,
|
||||
Access: svc,
|
||||
UsageEvents: svc,
|
||||
|
||||
@@ -36,7 +36,7 @@ import (
|
||||
update "github.com/gravitational/teleport/api/types/autoupdate"
|
||||
apiutils "github.com/gravitational/teleport/api/utils"
|
||||
"github.com/gravitational/teleport/lib/backend"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
// rolloutEquals returns a require.ValueAssertionFunc that checks the rollout is identical.
|
||||
@@ -136,7 +136,7 @@ func TestGetMode(t *testing.T) {
|
||||
|
||||
func TestTryReconcile(t *testing.T) {
|
||||
t.Parallel()
|
||||
log := utils.NewSlogLoggerForTests()
|
||||
log := logtest.NewLogger()
|
||||
ctx := context.Background()
|
||||
clock := clockwork.NewFakeClock()
|
||||
|
||||
@@ -330,7 +330,7 @@ func TestTryReconcile(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestReconciler_Reconcile(t *testing.T) {
|
||||
log := utils.NewSlogLoggerForTests()
|
||||
log := logtest.NewLogger()
|
||||
ctx := context.Background()
|
||||
clock := clockwork.NewFakeClock()
|
||||
// Test setup: creating fixtures
|
||||
@@ -727,7 +727,7 @@ func (f *fakeRolloutStrategy) progressRollout(ctx context.Context, spec *autoupd
|
||||
}
|
||||
|
||||
func Test_reconciler_computeStatus(t *testing.T) {
|
||||
log := utils.NewSlogLoggerForTests()
|
||||
log := logtest.NewLogger()
|
||||
clock := clockwork.NewFakeClock()
|
||||
ctx := context.Background()
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import (
|
||||
|
||||
"github.com/gravitational/teleport/api/gen/proto/go/teleport/autoupdate/v1"
|
||||
headerv1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/header/v1"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func Test_canStartHaltOnError(t *testing.T) {
|
||||
@@ -135,7 +135,7 @@ func Test_canStartHaltOnError(t *testing.T) {
|
||||
|
||||
func Test_progressGroupsHaltOnError(t *testing.T) {
|
||||
clock := clockwork.NewFakeClockAt(testSunday)
|
||||
log := utils.NewSlogLoggerForTests()
|
||||
log := logtest.NewLogger()
|
||||
|
||||
fewSecondsAgo := clock.Now().Add(-3 * time.Second)
|
||||
fewMinutesAgo := clock.Now().Add(-5 * time.Minute)
|
||||
|
||||
@@ -31,12 +31,12 @@ import (
|
||||
|
||||
"github.com/gravitational/teleport/api/gen/proto/go/teleport/autoupdate/v1"
|
||||
headerv1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/header/v1"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func Test_progressGroupsTimeBased(t *testing.T) {
|
||||
clock := clockwork.NewFakeClockAt(testSunday)
|
||||
log := utils.NewSlogLoggerForTests()
|
||||
log := logtest.NewLogger()
|
||||
|
||||
groupName := "test-group"
|
||||
canStartToday := everyWeekday
|
||||
|
||||
@@ -44,12 +44,12 @@ import (
|
||||
"github.com/gravitational/teleport/integrations/lib/backoff"
|
||||
"github.com/gravitational/teleport/lib/backend"
|
||||
"github.com/gravitational/teleport/lib/backend/test"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/clocki"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
|
||||
@@ -33,8 +33,8 @@ import (
|
||||
|
||||
"github.com/gravitational/teleport/lib/backend"
|
||||
"github.com/gravitational/teleport/lib/backend/test"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/clocki"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -43,7 +43,7 @@ const (
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
|
||||
@@ -52,12 +52,12 @@ import (
|
||||
"github.com/gravitational/teleport"
|
||||
"github.com/gravitational/teleport/lib/backend"
|
||||
"github.com/gravitational/teleport/lib/backend/test"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/clocki"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
|
||||
@@ -30,12 +30,12 @@ import (
|
||||
|
||||
"github.com/gravitational/teleport/lib/backend"
|
||||
"github.com/gravitational/teleport/lib/backend/test"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/clocki"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
|
||||
@@ -31,12 +31,12 @@ import (
|
||||
|
||||
"github.com/gravitational/teleport/lib/backend"
|
||||
"github.com/gravitational/teleport/lib/backend/test"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/clocki"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
|
||||
@@ -27,11 +27,11 @@ import (
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
|
||||
@@ -30,12 +30,12 @@ import (
|
||||
|
||||
"github.com/gravitational/teleport/lib/backend"
|
||||
"github.com/gravitational/teleport/lib/backend/test"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/clocki"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -50,7 +50,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/cgroup"
|
||||
"github.com/gravitational/teleport/lib/events/eventstest"
|
||||
"github.com/gravitational/teleport/lib/service/servicecfg"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -61,7 +61,7 @@ const (
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
|
||||
// Check if the re-exec was requested.
|
||||
if len(os.Args) == 3 {
|
||||
|
||||
Vendored
+2
-1
@@ -87,6 +87,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/services/suite"
|
||||
"github.com/gravitational/teleport/lib/srv/db/common/databaseobject"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
const eventBufferSize = 1024
|
||||
@@ -103,7 +104,7 @@ func TestMain(m *testing.M) {
|
||||
},
|
||||
},
|
||||
})
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
|
||||
@@ -29,11 +29,11 @@ import (
|
||||
"github.com/google/uuid"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/service/servicecfg"
|
||||
"github.com/gravitational/teleport/lib/services"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestTeleportClient_Login_local(t *testing.T) {
|
||||
@@ -547,7 +548,7 @@ func newStandaloneTeleport(t *testing.T, clock clockwork.Clock) *standaloneBundl
|
||||
cfg.DataDir = makeDataDir()
|
||||
cfg.Hostname = "localhost"
|
||||
cfg.Clock = clock
|
||||
cfg.Logger = utils.NewSlogLoggerForTests()
|
||||
cfg.Logger = logtest.NewLogger()
|
||||
cfg.SetAuthServerAddress(randomAddr) // must be present
|
||||
cfg.Auth.Preference, err = types.NewAuthPreferenceFromConfigFile(types.AuthPreferenceSpecV2{
|
||||
Type: constants.Local,
|
||||
@@ -630,7 +631,7 @@ func newStandaloneTeleport(t *testing.T, clock clockwork.Clock) *standaloneBundl
|
||||
cfg.Hostname = "localhost"
|
||||
cfg.SetToken(staticToken)
|
||||
cfg.Clock = clock
|
||||
cfg.Logger = utils.NewSlogLoggerForTests()
|
||||
cfg.Logger = logtest.NewLogger()
|
||||
cfg.SetAuthServerAddress(*authAddr)
|
||||
cfg.Auth.Enabled = false
|
||||
cfg.Proxy.Enabled = true
|
||||
|
||||
@@ -49,10 +49,11 @@ import (
|
||||
"github.com/gravitational/teleport/lib/modules"
|
||||
"github.com/gravitational/teleport/lib/observability/tracing"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
modules.SetInsecureTestMode(true)
|
||||
cryptosuites.PrecomputeRSATestKeys(m)
|
||||
os.Exit(m.Run())
|
||||
|
||||
@@ -57,6 +57,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/services"
|
||||
"github.com/gravitational/teleport/lib/tlsca"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
type testConfigFiles struct {
|
||||
@@ -103,7 +104,7 @@ func (tc testConfigFiles) cleanup() {
|
||||
}
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
|
||||
if err := writeTestConfigs(); err != nil {
|
||||
testConfigs.cleanup()
|
||||
|
||||
@@ -42,11 +42,11 @@ import (
|
||||
apiutils "github.com/gravitational/teleport/api/utils"
|
||||
"github.com/gravitational/teleport/lib/backend"
|
||||
"github.com/gravitational/teleport/lib/events"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
|
||||
@@ -37,10 +37,11 @@ import (
|
||||
"github.com/gravitational/teleport/lib/events/eventstest"
|
||||
"github.com/gravitational/teleport/lib/session"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
|
||||
@@ -28,11 +28,11 @@ import (
|
||||
|
||||
"github.com/gravitational/teleport"
|
||||
"github.com/gravitational/teleport/lib/events/test"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
|
||||
@@ -49,12 +49,13 @@ import (
|
||||
"github.com/gravitational/teleport/lib/modules/modulestest"
|
||||
"github.com/gravitational/teleport/lib/session"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
const dynamoDBLargeQueryRetries int = 10
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
|
||||
@@ -29,12 +29,12 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestPlainFileOpsReservations(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
rec := NewPlainFileRecorder(utils.NewSlogLoggerForTests(), os.OpenFile)
|
||||
rec := NewPlainFileRecorder(logtest.NewLogger(), os.OpenFile)
|
||||
base := t.TempDir()
|
||||
reservation := filepath.Join(base, "reservation")
|
||||
var fileSize int64 = 512
|
||||
@@ -58,7 +58,7 @@ func TestPlainFileOpsReservations(t *testing.T) {
|
||||
|
||||
func TestPlainFileOpsCombineParts(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
rec := NewPlainFileRecorder(utils.NewSlogLoggerForTests(), os.OpenFile)
|
||||
rec := NewPlainFileRecorder(logtest.NewLogger(), os.OpenFile)
|
||||
base := t.TempDir()
|
||||
parts := []string{"part1", "part2", "part3"}
|
||||
partPaths := make([]string, len(parts))
|
||||
|
||||
@@ -29,11 +29,11 @@ import (
|
||||
|
||||
"github.com/gravitational/teleport/lib/events"
|
||||
"github.com/gravitational/teleport/lib/events/test"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
|
||||
@@ -31,10 +31,11 @@ import (
|
||||
|
||||
"github.com/gravitational/teleport/lib/events/test"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
|
||||
@@ -29,11 +29,11 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/gravitational/teleport/lib/events/test"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
|
||||
@@ -24,11 +24,11 @@ import (
|
||||
|
||||
"github.com/gravitational/teleport/lib/events/eventstest"
|
||||
"github.com/gravitational/teleport/lib/events/test"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
|
||||
@@ -37,11 +37,11 @@ import (
|
||||
pgcommon "github.com/gravitational/teleport/lib/backend/pgbk/common"
|
||||
"github.com/gravitational/teleport/lib/events"
|
||||
"github.com/gravitational/teleport/lib/events/test"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ func TestConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBuildSchema(t *testing.T) {
|
||||
testLog := utils.NewSlogLoggerForTests()
|
||||
testLog := logtest.NewLogger()
|
||||
|
||||
testConfig := &Config{
|
||||
Log: testLog,
|
||||
|
||||
@@ -34,11 +34,11 @@ import (
|
||||
|
||||
"github.com/gravitational/teleport/api/types"
|
||||
"github.com/gravitational/teleport/lib/modules/modulestest"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
|
||||
@@ -42,11 +42,11 @@ import (
|
||||
"github.com/gravitational/teleport/lib/defaults"
|
||||
"github.com/gravitational/teleport/lib/services"
|
||||
"github.com/gravitational/teleport/lib/services/local"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import (
|
||||
"github.com/gravitational/teleport"
|
||||
"github.com/gravitational/teleport/api/types"
|
||||
"github.com/gravitational/teleport/lib/automaticupgrades"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestGenerateServiceWithTaskDefinition(t *testing.T) {
|
||||
@@ -164,7 +164,7 @@ func TestUpdateDeployServices(t *testing.T) {
|
||||
semVer := teleport.SemVer()
|
||||
semVer.PreRelease = ""
|
||||
teleportVersion := semVer.String()
|
||||
log := utils.NewSlogLoggerForTests().With("test", t.Name())
|
||||
log := logtest.With("test", t.Name())
|
||||
|
||||
t.Run("only legacy service present", func(t *testing.T) {
|
||||
m := &mockDeployServiceClient{
|
||||
|
||||
@@ -40,7 +40,7 @@ import (
|
||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||
|
||||
"github.com/gravitational/teleport/api/types"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestGetChartUrl(t *testing.T) {
|
||||
@@ -396,7 +396,7 @@ func TestEnrollEKSClusters(t *testing.T) {
|
||||
}
|
||||
|
||||
response, err := EnrollEKSClusters(
|
||||
ctx, utils.NewSlogLoggerForTests().With("test", t.Name()), clock, proxyAddr, tc.enrollClient(t, tc.eksClusters), req)
|
||||
ctx, logtest.With("test", t.Name()), clock, proxyAddr, tc.enrollClient(t, tc.eksClusters), req)
|
||||
require.NoError(t, err)
|
||||
|
||||
tc.responseCheck(t, response)
|
||||
@@ -422,7 +422,7 @@ func TestEnrollEKSClusters(t *testing.T) {
|
||||
}
|
||||
|
||||
response, err := EnrollEKSClusters(
|
||||
ctx, utils.NewSlogLoggerForTests().With("test", t.Name()), clock, proxyAddr, mockClt, req)
|
||||
ctx, logtest.With("test", t.Name()), clock, proxyAddr, mockClt, req)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, response.Results, 1)
|
||||
require.Equal(t, "EKS1", response.Results[0].ClusterName)
|
||||
|
||||
@@ -32,7 +32,7 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/gravitational/teleport/api/types"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func stringPointer(s string) *string {
|
||||
@@ -141,7 +141,7 @@ func TestListDatabases(t *testing.T) {
|
||||
|
||||
t.Run("without vpc filter", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := utils.NewSlogLoggerForTests().With("test", t.Name())
|
||||
logger := logtest.With("test", t.Name())
|
||||
// First page must return pageSize number of DBs
|
||||
req := ListDatabasesRequest{
|
||||
Region: "us-east-1",
|
||||
@@ -166,7 +166,7 @@ func TestListDatabases(t *testing.T) {
|
||||
|
||||
t.Run("with vpc filter", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := utils.NewSlogLoggerForTests().With("test", t.Name())
|
||||
logger := logtest.With("test", t.Name())
|
||||
// First page must return at least pageSize number of DBs
|
||||
var gotDatabases []types.Database
|
||||
wantVPC := "vpc-2"
|
||||
@@ -694,7 +694,7 @@ func TestListDatabases(t *testing.T) {
|
||||
dbInstances: tt.mockInstances,
|
||||
dbClusters: tt.mockClusters,
|
||||
}
|
||||
logger := utils.NewSlogLoggerForTests().With("test", t.Name())
|
||||
logger := logtest.With("test", t.Name())
|
||||
resp, err := ListDatabases(ctx, mockListClient, logger, tt.req)
|
||||
require.True(t, tt.errCheck(err), "unexpected err: %v", err)
|
||||
if err != nil {
|
||||
|
||||
@@ -36,7 +36,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/auth/keystore"
|
||||
"github.com/gravitational/teleport/lib/integrations/awsra/createsession"
|
||||
"github.com/gravitational/teleport/lib/service/servicecfg"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
/*
|
||||
@@ -207,7 +207,7 @@ func TestRunAWSRolesAnywherProfileSyncer(t *testing.T) {
|
||||
KeyStoreManager: keyStoreManager,
|
||||
Cache: serverClient,
|
||||
AppServerUpserter: serverClient,
|
||||
Logger: utils.NewSlogLoggerForTests(),
|
||||
Logger: logtest.NewLogger(),
|
||||
createSession: mockCreateSession,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,10 +45,11 @@ import (
|
||||
"github.com/gravitational/teleport/lib/inventory/metadata"
|
||||
usagereporter "github.com/gravitational/teleport/lib/usagereporter/teleport"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
|
||||
@@ -24,12 +24,12 @@ import (
|
||||
"github.com/jonboulle/clockwork"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/interval"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/services"
|
||||
sessPkg "github.com/gravitational/teleport/lib/session"
|
||||
"github.com/gravitational/teleport/lib/tlsca"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
type TestContext struct {
|
||||
@@ -286,7 +286,7 @@ func SetupTestContext(ctx context.Context, t *testing.T, cfg TestConfig) *TestCo
|
||||
GetRotation: func(role types.SystemRole) (*types.Rotation, error) { return &types.Rotation{}, nil },
|
||||
ResourceMatchers: cfg.ResourceMatchers,
|
||||
OnReconcile: cfg.OnReconcile,
|
||||
Log: utils.NewSlogLoggerForTests(),
|
||||
Log: logtest.NewLogger(),
|
||||
InventoryHandle: inventoryHandle,
|
||||
ConnectedProxyGetter: reversetunnel.NewConnectedProxyGetter(),
|
||||
})
|
||||
@@ -364,7 +364,7 @@ func SetupTestContext(ctx context.Context, t *testing.T, cfg TestConfig) *TestCo
|
||||
LimiterConfig: limiter.Config{
|
||||
MaxConnections: 1000,
|
||||
},
|
||||
Log: utils.NewSlogLoggerForTests(),
|
||||
Log: logtest.NewLogger(),
|
||||
InventoryHandle: inventoryHandle,
|
||||
GetRotation: func(role types.SystemRole) (*types.Rotation, error) {
|
||||
return &types.Rotation{}, nil
|
||||
|
||||
@@ -43,7 +43,7 @@ import (
|
||||
"github.com/gravitational/teleport/api/types"
|
||||
testingkubemock "github.com/gravitational/teleport/lib/kube/proxy/testing/kube_server"
|
||||
"github.com/gravitational/teleport/lib/service/servicecfg"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestCheckImpersonationPermissions(t *testing.T) {
|
||||
@@ -332,7 +332,7 @@ current-context: foo
|
||||
CheckImpersonationPermissions: tt.impersonationCheck,
|
||||
Clock: clockwork.NewFakeClock(),
|
||||
},
|
||||
log: utils.NewSlogLoggerForTests(),
|
||||
log: logtest.NewLogger(),
|
||||
}
|
||||
err := fwd.getKubeDetails(ctx)
|
||||
tt.assertErr(t, err)
|
||||
|
||||
@@ -33,7 +33,7 @@ import (
|
||||
"k8s.io/client-go/kubernetes"
|
||||
|
||||
"github.com/gravitational/teleport/api/types"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestNewClusterDetails(t *testing.T) {
|
||||
@@ -47,7 +47,7 @@ func TestNewClusterDetails(t *testing.T) {
|
||||
kubeClient: client,
|
||||
},
|
||||
cluster: &types.KubernetesClusterV3{},
|
||||
log: utils.NewSlogLoggerForTests(),
|
||||
log: logtest.NewLogger(),
|
||||
clock: c,
|
||||
}, client
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/services/local"
|
||||
"github.com/gravitational/teleport/lib/tlsca"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -130,7 +131,7 @@ func TestAuthenticate(t *testing.T) {
|
||||
},
|
||||
}
|
||||
f := &Forwarder{
|
||||
log: utils.NewSlogLoggerForTests(),
|
||||
log: logtest.NewLogger(),
|
||||
cfg: ForwarderConfig{
|
||||
ClusterName: "local",
|
||||
CachingAuthClient: ap,
|
||||
@@ -1109,7 +1110,7 @@ func newMockForwader(ctx context.Context, t *testing.T) *Forwarder {
|
||||
require.NoError(t, err)
|
||||
|
||||
return &Forwarder{
|
||||
log: utils.NewSlogLoggerForTests(),
|
||||
log: logtest.NewLogger(),
|
||||
router: httprouter.New(),
|
||||
cfg: ForwarderConfig{
|
||||
Keygen: testauthority.New(),
|
||||
@@ -1274,7 +1275,7 @@ func (m *mockWatcher) Done() <-chan struct{} {
|
||||
|
||||
func newTestForwarder(ctx context.Context, cfg ForwarderConfig) *Forwarder {
|
||||
return &Forwarder{
|
||||
log: utils.NewSlogLoggerForTests(),
|
||||
log: logtest.NewLogger(),
|
||||
router: httprouter.New(),
|
||||
cfg: cfg,
|
||||
activeRequests: make(map[string]context.Context),
|
||||
@@ -1631,7 +1632,7 @@ func TestForwarderTLSConfigCAs(t *testing.T) {
|
||||
return x509.NewCertPool(), nil
|
||||
},
|
||||
},
|
||||
log: utils.NewSlogLoggerForTests(),
|
||||
log: logtest.NewLogger(),
|
||||
ctx: context.Background(),
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/fixtures"
|
||||
kubeutils "github.com/gravitational/teleport/lib/kube/utils"
|
||||
"github.com/gravitational/teleport/lib/services"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
type mockEKSClientGetter struct {
|
||||
@@ -365,7 +365,7 @@ func Test_DynamicKubeCreds(t *testing.T) {
|
||||
) error {
|
||||
return nil
|
||||
},
|
||||
log: utils.NewSlogLoggerForTests(),
|
||||
log: logtest.NewLogger(),
|
||||
kubeCluster: tt.args.cluster,
|
||||
client: tt.args.client,
|
||||
initialRenewInterval: ttl / 2,
|
||||
|
||||
@@ -42,7 +42,7 @@ import (
|
||||
"k8s.io/client-go/transport/spdy"
|
||||
|
||||
testingkubemock "github.com/gravitational/teleport/lib/kube/proxy/testing/kube_server"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestPortForwardKubeService(t *testing.T) {
|
||||
@@ -284,7 +284,7 @@ func TestPortForwardProxy_run_connsClosed(t *testing.T) {
|
||||
context: context.Background(),
|
||||
onPortForward: func(addr string, success bool) {},
|
||||
},
|
||||
logger: utils.NewSlogLoggerForTests(),
|
||||
logger: logtest.NewLogger(),
|
||||
sourceConn: sourceConn,
|
||||
targetConn: targetConn,
|
||||
streamChan: make(chan httpstream.Stream),
|
||||
|
||||
@@ -41,7 +41,7 @@ import (
|
||||
|
||||
"github.com/gravitational/teleport/api/types"
|
||||
"github.com/gravitational/teleport/lib/kube/proxy/responsewriters"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
libslices "github.com/gravitational/teleport/lib/utils/slices"
|
||||
)
|
||||
|
||||
@@ -186,7 +186,7 @@ func Test_filterBuffer(t *testing.T) {
|
||||
},
|
||||
verb: types.KubeVerbList,
|
||||
}
|
||||
err = filterBuffer(newResourceFilterer(mr, &globalKubeCodecs, allowedResources, nil, utils.NewSlogLoggerForTests()), buf)
|
||||
err = filterBuffer(newResourceFilterer(mr, &globalKubeCodecs, allowedResources, nil, logtest.NewLogger()), buf)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Decompress the buffer to compare the result.
|
||||
|
||||
@@ -53,7 +53,7 @@ import (
|
||||
"github.com/gravitational/teleport/api/types"
|
||||
"github.com/gravitational/teleport/lib/kube/proxy/responsewriters"
|
||||
tkm "github.com/gravitational/teleport/lib/kube/proxy/testing/kube_server"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestListPodRBAC(t *testing.T) {
|
||||
@@ -689,7 +689,7 @@ func TestWatcherResponseWriter(t *testing.T) {
|
||||
},
|
||||
verb: types.KubeVerbWatch,
|
||||
}
|
||||
filterWrapper := newResourceFilterer(mr, &globalKubeCodecs, tt.args.allowed, tt.args.denied, utils.NewSlogLoggerForTests())
|
||||
filterWrapper := newResourceFilterer(mr, &globalKubeCodecs, tt.args.allowed, tt.args.denied, logtest.NewLogger())
|
||||
// watcher parses the data written into itself and if the user is allowed to
|
||||
// receive the update, it writes the event into target.
|
||||
watcher, err := responsewriters.NewWatcherResponseWriter(newFakeResponseWriter(userWriter) /*target*/, negotiator, filterWrapper)
|
||||
|
||||
@@ -26,13 +26,13 @@ import (
|
||||
"k8s.io/client-go/discovery"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
// TestNewClusterSchemaBuilder tests that newClusterSchemaBuilder doesn't panic
|
||||
// when it's given types already registered in the global scheme.
|
||||
func Test_newClusterSchemaBuilder(t *testing.T) {
|
||||
_, _, _, err := newClusterSchemaBuilder(utils.NewSlogLoggerForTests(), &clientSet{})
|
||||
_, _, _, err := newClusterSchemaBuilder(logtest.NewLogger(), &clientSet{})
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ import (
|
||||
testingkubemock "github.com/gravitational/teleport/lib/kube/proxy/testing/kube_server"
|
||||
"github.com/gravitational/teleport/lib/reversetunnel"
|
||||
"github.com/gravitational/teleport/lib/tlsca"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestServeConfigureError(t *testing.T) {
|
||||
@@ -113,7 +113,7 @@ func TestMTLSClientCAs(t *testing.T) {
|
||||
userCert := genCert(t, "user")
|
||||
srv := &TLSServer{
|
||||
TLSServerConfig: TLSServerConfig{
|
||||
Log: utils.NewSlogLoggerForTests(),
|
||||
Log: logtest.NewLogger(),
|
||||
ForwarderConfig: ForwarderConfig{
|
||||
ClusterName: mainClusterName,
|
||||
},
|
||||
@@ -125,7 +125,7 @@ func TestMTLSClientCAs(t *testing.T) {
|
||||
GetRotation: func(role types.SystemRole) (*types.Rotation, error) { return &types.Rotation{}, nil },
|
||||
ConnectedProxyGetter: reversetunnel.NewConnectedProxyGetter(),
|
||||
},
|
||||
log: utils.NewSlogLoggerForTests(),
|
||||
log: logtest.NewLogger(),
|
||||
}
|
||||
|
||||
lis, err := net.Listen("tcp", "localhost:0")
|
||||
@@ -207,7 +207,7 @@ func TestGetServerInfo(t *testing.T) {
|
||||
|
||||
srv := &TLSServer{
|
||||
TLSServerConfig: TLSServerConfig{
|
||||
Log: utils.NewSlogLoggerForTests(),
|
||||
Log: logtest.NewLogger(),
|
||||
ForwarderConfig: ForwarderConfig{
|
||||
Clock: clockwork.NewFakeClock(),
|
||||
ClusterName: "kube-cluster",
|
||||
|
||||
@@ -47,7 +47,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/authz"
|
||||
"github.com/gravitational/teleport/lib/events"
|
||||
testingkubemock "github.com/gravitational/teleport/lib/kube/proxy/testing/kube_server"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestSessionEndError(t *testing.T) {
|
||||
@@ -282,7 +282,7 @@ func Test_session_trackSession(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
sess := &session{
|
||||
log: utils.NewSlogLoggerForTests(),
|
||||
log: logtest.NewLogger(),
|
||||
id: uuid.New(),
|
||||
req: &http.Request{
|
||||
URL: &url.URL{
|
||||
|
||||
@@ -67,7 +67,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/services"
|
||||
sessPkg "github.com/gravitational/teleport/lib/session"
|
||||
"github.com/gravitational/teleport/lib/tlsca"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
type TestContext struct {
|
||||
@@ -286,7 +286,7 @@ func SetupTestContext(ctx context.Context, t *testing.T, cfg TestConfig) *TestCo
|
||||
GetRotation: func(role types.SystemRole) (*types.Rotation, error) { return &types.Rotation{}, nil },
|
||||
ResourceMatchers: cfg.ResourceMatchers,
|
||||
OnReconcile: cfg.OnReconcile,
|
||||
Log: utils.NewSlogLoggerForTests(),
|
||||
Log: logtest.NewLogger(),
|
||||
InventoryHandle: inventoryHandle,
|
||||
ConnectedProxyGetter: reversetunnel.NewConnectedProxyGetter(),
|
||||
})
|
||||
@@ -364,7 +364,7 @@ func SetupTestContext(ctx context.Context, t *testing.T, cfg TestConfig) *TestCo
|
||||
LimiterConfig: limiter.Config{
|
||||
MaxConnections: 1000,
|
||||
},
|
||||
Log: utils.NewSlogLoggerForTests(),
|
||||
Log: logtest.NewLogger(),
|
||||
InventoryHandle: inventoryHandle,
|
||||
GetRotation: func(role types.SystemRole) (*types.Rotation, error) {
|
||||
return &types.Rotation{}, nil
|
||||
|
||||
@@ -28,11 +28,11 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/gravitational/teleport/api/types"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
|
||||
@@ -36,10 +36,11 @@ import (
|
||||
|
||||
"github.com/gravitational/teleport/lib/limiter/internal/ratelimit"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
|
||||
@@ -53,10 +53,11 @@ import (
|
||||
"github.com/gravitational/teleport/lib/tlsca"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/cert"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import (
|
||||
"github.com/gravitational/teleport"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
logutils "github.com/gravitational/teleport/lib/utils/log"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
// TestProxy is tcp passthrough proxy that sends a proxy-line when connecting
|
||||
@@ -52,7 +53,7 @@ func NewTestProxy(target string, v2 bool) (*TestProxy, error) {
|
||||
listener: listener,
|
||||
target: target,
|
||||
closeCh: make(chan struct{}),
|
||||
log: utils.NewSlogLoggerForTests().With(teleport.ComponentKey, "test:proxy"),
|
||||
log: logtest.With(teleport.ComponentKey, "test:proxy"),
|
||||
v2: v2,
|
||||
}, nil
|
||||
}
|
||||
|
||||
+2
-2
@@ -30,11 +30,11 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/gravitational/teleport/lib/service/servicecfg"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
|
||||
// Skip this test if the binary was not built with PAM support.
|
||||
if !BuildHasPAM() || !SystemHasPAM() {
|
||||
|
||||
@@ -32,7 +32,7 @@ import (
|
||||
"google.golang.org/grpc/credentials"
|
||||
|
||||
"github.com/gravitational/teleport/api/types"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
type testCredentials struct {
|
||||
@@ -113,7 +113,7 @@ func TestClientCredentials(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
creds := newClientCredentials(test.expectedPeerID, test.peerAddr, utils.NewSlogLoggerForTests(), newTestCredentials(cert))
|
||||
creds := newClientCredentials(test.expectedPeerID, test.peerAddr, logtest.NewLogger(), newTestCredentials(cert))
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||
defer cancel()
|
||||
|
||||
@@ -45,10 +45,11 @@ import (
|
||||
"github.com/gravitational/teleport/lib/proxy/peer/internal"
|
||||
"github.com/gravitational/teleport/lib/tlsca"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/cryptosuites"
|
||||
"github.com/gravitational/teleport/lib/sshutils"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
// TestAgentCertChecker validates that reverse tunnel agents properly validate
|
||||
@@ -89,7 +90,7 @@ func TestAgentCertChecker(t *testing.T) {
|
||||
dialer := agentDialer{
|
||||
client: &fakeClient{caKey: ca.PublicKey()},
|
||||
authMethods: []ssh.AuthMethod{ssh.PublicKeys(signer)},
|
||||
logger: utils.NewSlogLoggerForTests(),
|
||||
logger: logtest.NewLogger(),
|
||||
}
|
||||
|
||||
_, err = dialer.DialContext(context.Background(), *utils.MustParseAddr(sshServer.Addr()))
|
||||
|
||||
@@ -40,10 +40,11 @@ import (
|
||||
"github.com/gravitational/teleport/lib/auth/authclient"
|
||||
"github.com/gravitational/teleport/lib/services"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
@@ -62,7 +63,7 @@ func TestRemoteConnCleanup(t *testing.T) {
|
||||
watcher, err := services.NewProxyWatcher(ctx, services.ProxyWatcherConfig{
|
||||
ResourceWatcherConfig: services.ResourceWatcherConfig{
|
||||
Component: "test",
|
||||
Logger: utils.NewSlogLoggerForTests(),
|
||||
Logger: logtest.NewLogger(),
|
||||
Clock: clock,
|
||||
Client: clt,
|
||||
},
|
||||
@@ -77,7 +78,7 @@ func TestRemoteConnCleanup(t *testing.T) {
|
||||
ctx: ctx,
|
||||
Config: Config{Clock: clock},
|
||||
localAuthClient: &mockLocalSiteClient{},
|
||||
logger: utils.NewSlogLoggerForTests(),
|
||||
logger: logtest.NewLogger(),
|
||||
offlineThreshold: time.Second,
|
||||
proxyWatcher: watcher,
|
||||
}
|
||||
@@ -257,7 +258,7 @@ func TestProxyResync(t *testing.T) {
|
||||
watcher, err := services.NewProxyWatcher(ctx, services.ProxyWatcherConfig{
|
||||
ResourceWatcherConfig: services.ResourceWatcherConfig{
|
||||
Component: "test",
|
||||
Logger: utils.NewSlogLoggerForTests(),
|
||||
Logger: logtest.NewLogger(),
|
||||
Clock: clock,
|
||||
Client: clt,
|
||||
},
|
||||
@@ -272,7 +273,7 @@ func TestProxyResync(t *testing.T) {
|
||||
ctx: ctx,
|
||||
Config: Config{Clock: clock},
|
||||
localAuthClient: &mockLocalSiteClient{},
|
||||
logger: utils.NewSlogLoggerForTests(),
|
||||
logger: logtest.NewLogger(),
|
||||
offlineThreshold: 24 * time.Hour,
|
||||
proxyWatcher: watcher,
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ import (
|
||||
"github.com/gravitational/teleport/lib/auth/testauthority"
|
||||
"github.com/gravitational/teleport/lib/sshca"
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func newCAAndSigner(t *testing.T, caType types.CertAuthType, name string) (types.CertAuthority, ssh.Signer) {
|
||||
@@ -80,7 +81,7 @@ func TestServerKeyAuth(t *testing.T) {
|
||||
leafUserCA, leafUserCASigner := newCAAndSigner(t, types.UserCA, "leaf")
|
||||
|
||||
s := &server{
|
||||
logger: utils.NewSlogLoggerForTests(),
|
||||
logger: logtest.NewLogger(),
|
||||
Config: Config{Clock: clockwork.NewRealClock(), ClusterName: "root"},
|
||||
localAccessPoint: mockAccessPoint{
|
||||
cas: []types.CertAuthority{hostCA, userCA, leafHostCA, leafUserCA},
|
||||
@@ -346,7 +347,7 @@ func TestOnlyAuthDial(t *testing.T) {
|
||||
badListenerAddr := acceptAndCloseListener(t, true)
|
||||
|
||||
srv := &server{
|
||||
logger: utils.NewSlogLoggerForTests(),
|
||||
logger: logtest.NewLogger(),
|
||||
ctx: ctx,
|
||||
Config: Config{
|
||||
LocalAuthAddresses: []string{goodListenerAddr},
|
||||
|
||||
@@ -26,11 +26,11 @@ import (
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/gravitational/teleport/lib/utils"
|
||||
"github.com/gravitational/teleport/lib/utils/log/logtest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
utils.InitLoggerForTests()
|
||||
logtest.InitLogger(testing.Verbose)
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user