Fix HighAvailability suite randomness.

pull/482/head
Clement Michaud 2019-12-08 13:16:13 +01:00 committed by Clément Michaud
parent 3d20142292
commit 6f1ec2094d
2 changed files with 7 additions and 21 deletions

View File

@ -4,7 +4,6 @@ import (
"context" "context"
"fmt" "fmt"
"net/http" "net/http"
"strings"
"testing" "testing"
"time" "time"
@ -64,30 +63,17 @@ func (s *HighAvailabilityWebDriverSuite) TestShouldKeepUserDataInDB() {
} }
func (s *HighAvailabilityWebDriverSuite) TestShouldKeepSessionAfterAutheliaRestart() { func (s *HighAvailabilityWebDriverSuite) TestShouldKeepSessionAfterAutheliaRestart() {
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
defer cancel() defer cancel()
secret := s.doRegisterAndLogin2FA(ctx, s.T(), "john", "password", false, "") secret := s.doRegisterAndLogin2FA(ctx, s.T(), "john", "password", false, "")
s.verifyIsSecondFactorPage(ctx, s.T())
err := haDockerEnvironment.Restart("authelia-backend") err := haDockerEnvironment.Restart("authelia-backend")
s.Assert().NoError(err) s.Require().NoError(err)
loop := true err = waitUntilAutheliaBackendIsReady(haDockerEnvironment)
for loop { s.Require().NoError(err)
logs, err := haDockerEnvironment.Logs("authelia-backend", []string{"--tail", "10"})
s.Assert().NoError(err)
select {
case <-time.After(1 * time.Second):
if strings.Contains(logs, "Authelia is listening on :9091") {
loop = false
}
break
case <-ctx.Done():
loop = false
break
}
}
s.doVisit(s.T(), HomeBaseURL) s.doVisit(s.T(), HomeBaseURL)
s.verifyIsHome(ctx, s.T()) s.verifyIsHome(ctx, s.T())

View File

@ -4,7 +4,7 @@ import (
"context" "context"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/require"
"github.com/tebeka/selenium" "github.com/tebeka/selenium"
) )
@ -18,5 +18,5 @@ func (wds *WebDriverSession) verifyURLIs(ctx context.Context, t *testing.T, url
return currentURL == url, nil return currentURL == url, nil
}) })
assert.NoError(t, err) require.NoError(t, err)
} }