Skip to content
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
20 changes: 18 additions & 2 deletions integration/helpers/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ func (i *TeleInstance) createTeleportProcess(tconf *servicecfg.Config) (*service
}

// CreateWithConf creates a new instance of Teleport using the supplied config
func (i *TeleInstance) CreateWithConf(_ *testing.T, tconf *servicecfg.Config) error {
func (i *TeleInstance) CreateWithConf(t *testing.T, tconf *servicecfg.Config) error {
i.Config = tconf
var err error
i.Process, err = i.createTeleportProcess(tconf)
Expand All @@ -677,7 +677,7 @@ func (i *TeleInstance) CreateWithConf(_ *testing.T, tconf *servicecfg.Config) er
// create users and roles if they don't exist, or sign their keys if they're
// already present
auth := i.Process.GetAuthServer()
ctx := context.TODO()
ctx := t.Context()

for _, user := range i.Secrets.Users {
teleUser, err := types.NewUser(user.Username)
Expand Down Expand Up @@ -1362,6 +1362,18 @@ func (i *TeleInstance) Start() error {
"received_events_count", len(receivedEvents),
)

// Wait for any SSH instances to be visible in the inventory before returning
// to prevent any immediate connection attempts from failing because the host
// has not yet been propagated to the caches.
expectedNodes := len(i.Nodes)
if i.Config.SSH.Enabled {
expectedNodes++
}

if err := i.WaitForNodeCount(context.Background(), i.Secrets.SiteName, expectedNodes); err != nil {
return trace.Wrap(err)
}

return nil
}

Expand Down Expand Up @@ -1940,6 +1952,10 @@ func (i *TeleInstance) WaitForNodeCount(ctx context.Context, clusterName string,
iterWaitTime = time.Second
)

if count <= 0 || i.Config == nil || !i.Config.Auth.Enabled || !i.Config.Proxy.Enabled {
return nil
}

err := retryutils.RetryStaticFor(deadline, iterWaitTime, func() error {
cluster, err := i.Tunnel.Cluster(ctx, clusterName)
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions integration/hostuser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -683,8 +683,6 @@ func TestRootLoginAsHostUser(t *testing.T) {
require.NoError(t, instance.StopAll())
})

instance.WaitForNodeCount(context.Background(), helpers.Site, 1)

tests := []struct {
name string
command []string
Expand Down Expand Up @@ -762,6 +760,7 @@ func TestRootStaticHostUsers(t *testing.T) {
require.NoError(t, instance.StopAll())
})
nodeCfg := servicecfg.MakeDefaultConfig()
nodeCfg.SSH.DisableCreateHostUser = false
nodeCfg.SSH.Labels = map[string]string{
"foo": "bar",
}
Expand Down
Loading
Loading