From d4be6fd1f467fbbdb24a366137c199e88783fe19 Mon Sep 17 00:00:00 2001 From: Marek Smolinski Date: Wed, 29 Jun 2022 22:21:15 +0200 Subject: [PATCH 1/2] Try to fix TestAppServersHA flakiness --- integration/app_integration_test.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/integration/app_integration_test.go b/integration/app_integration_test.go index 7d8d4b0e5c60b..5e202c6a1e330 100644 --- a/integration/app_integration_test.go +++ b/integration/app_integration_test.go @@ -36,6 +36,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + "github.com/gravitational/teleport" "github.com/gravitational/teleport/api/breaker" apidefaults "github.com/gravitational/teleport/api/defaults" @@ -516,8 +517,9 @@ func (p *pack) appServersHA(t *testing.T) { } testCases := map[string]struct { - packInfo func(pack *pack) packInfo - startAppServers func(pack *pack, count int) []*service.TeleportProcess + packInfo func(pack *pack) packInfo + startAppServers func(pack *pack, count int) []*service.TeleportProcess + waitForTunnelConn func(t *testing.T, pack *pack, count int) }{ "RootServer": { packInfo: func(pack *pack) packInfo { @@ -531,6 +533,9 @@ func (p *pack) appServersHA(t *testing.T) { startAppServers: func(pack *pack, count int) []*service.TeleportProcess { return pack.startRootAppServers(t, count, []service.App{}) }, + waitForTunnelConn: func(t *testing.T, pack *pack, count int) { + waitForActiveTunnelConnections(t, pack.rootCluster.Tunnel, pack.rootCluster.Secrets.SiteName, count) + }, }, "LeafServer": { packInfo: func(pack *pack) packInfo { @@ -544,6 +549,9 @@ func (p *pack) appServersHA(t *testing.T) { startAppServers: func(pack *pack, count int) []*service.TeleportProcess { return pack.startLeafAppServers(t, count, []service.App{}) }, + waitForTunnelConn: func(t *testing.T, pack *pack, count int) { + waitForActiveTunnelConnections(t, pack.leafCluster.Tunnel, pack.leafCluster.Secrets.SiteName, count) + }, }, } @@ -600,11 +608,14 @@ func (p *pack) appServersHA(t *testing.T) { } servers := test.startAppServers(p, 1) + test.waitForTunnelConn(t, p, 1) makeRequests(t, p, httpCookie, wsCookie, responseWithoutError) // Start an additional app server and stop all current running // ones. test.startAppServers(p, 1) + test.waitForTunnelConn(t, p, 2) + for _, appServer := range servers { require.NoError(t, appServer.Close()) From 496dc0bd0ea157352049f44cb6942ece8f20adb4 Mon Sep 17 00:00:00 2001 From: Russell Jones Date: Thu, 30 Jun 2022 22:07:39 +0000 Subject: [PATCH 2/2] Fixed TestAppServersHA. --- integration/app_integration_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/integration/app_integration_test.go b/integration/app_integration_test.go index 5e202c6a1e330..b351bb1d50172 100644 --- a/integration/app_integration_test.go +++ b/integration/app_integration_test.go @@ -596,6 +596,7 @@ func (p *pack) appServersHA(t *testing.T) { // Stop all root app servers. for i, appServer := range info.appServers { require.NoError(t, appServer.Close()) + require.NoError(t, appServer.Wait()) if i == len(info.appServers)-1 { // fails only when the last one is closed. @@ -618,6 +619,7 @@ func (p *pack) appServersHA(t *testing.T) { for _, appServer := range servers { require.NoError(t, appServer.Close()) + require.NoError(t, appServer.Wait()) // Everytime an app server stops we issue a request to // guarantee that the requests are going to be resolved by