testsuite/ui: fixes to setup
* Remove "enable-logging", because it ends up spawning consoles on Windows. * Remove "disable-gpu", if we have a GPU, then let's use it. * Create custom client, so we can attach logging to CDP. * Ignore potential context.Canceled. * Fix onboarding wizard test for new objects browser. * Return an error on a context cancellation. * Wire all loggers to planet. Change-Id: I67eb138ba31252f55ac5b383679d033bcf71f1b2
This commit is contained in:
parent
debb82f596
commit
dfd2977a01
@ -199,8 +199,8 @@ pipeline {
|
||||
|
||||
post {
|
||||
always {
|
||||
sh script: 'cat .build/tests.json | tparse -all -top -slow 100', returnStatus: true
|
||||
archiveArtifacts artifacts: '.build/tests.json'
|
||||
sh script: 'cat .build/tests.json | tparse -all -top -slow 100', returnStatus: true
|
||||
junit '.build/tests.xml'
|
||||
|
||||
script {
|
||||
@ -382,13 +382,13 @@ pipeline {
|
||||
steps {
|
||||
sh 'psql -U postgres -c \'create database testui;\''
|
||||
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
|
||||
sh 'cd testsuite && go test -parallel 1 -p 1 -short -vet=off -timeout 32m -json -race ./... 2>&1 | tee ../.build/ui-tests.json | xunit -out ../.build/ui-tests.xml'
|
||||
sh 'cd testsuite && go test -parallel 1 -p 1 -short -vet=off -timeout 5m -json -race ./... 2>&1 | tee ../.build/ui-tests.json | xunit -out ../.build/ui-tests.xml'
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
sh script: 'cat .build/ui-tests.json | tparse -all -top -slow 100', returnStatus: true
|
||||
archiveArtifacts artifacts: '.build/ui-tests.json'
|
||||
sh script: 'cat .build/ui-tests.json | tparse -all -top -slow 100', returnStatus: true
|
||||
junit '.build/ui-tests.xml'
|
||||
}
|
||||
}
|
||||
|
@ -297,6 +297,9 @@ func (planet *Planet) FindNode(nodeID storj.NodeID) *StorageNode {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Log returns the root logger.
|
||||
func (planet *Planet) Log() *zap.Logger { return planet.log }
|
||||
|
||||
// Shutdown shuts down all the nodes and deletes temporary directories.
|
||||
func (planet *Planet) Shutdown() error {
|
||||
if !planet.started {
|
||||
|
@ -70,6 +70,6 @@ func TestOnboardingWizardBrowser(t *testing.T) {
|
||||
waitVueTick(page)
|
||||
|
||||
// Verify that browser component has loaded and that the dropzone is present
|
||||
page.MustElementR("h4", "Drop Files Here to Upload")
|
||||
page.MustElementR("p", "Drop Files Here to Upload")
|
||||
})
|
||||
}
|
||||
|
@ -12,14 +12,16 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/go-rod/rod"
|
||||
"github.com/go-rod/rod/lib/cdp"
|
||||
"github.com/go-rod/rod/lib/defaults"
|
||||
"github.com/go-rod/rod/lib/launcher"
|
||||
"github.com/go-rod/rod/lib/launcher/flags"
|
||||
"github.com/go-rod/rod/lib/utils"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uber.org/zap/zaptest"
|
||||
|
||||
"storj.io/common/errs2"
|
||||
"storj.io/common/testcontext"
|
||||
"storj.io/storj/private/testplanet"
|
||||
)
|
||||
|
||||
// Our testing suite heavily uses randomly selected ports, which may collide
|
||||
@ -28,11 +30,11 @@ import (
|
||||
func init() { defaults.LockPort = 0 }
|
||||
|
||||
// Browser starts a browser for testing using environment variables for configuration.
|
||||
func Browser(t *testing.T, ctx *testcontext.Context, fn func(*rod.Browser)) {
|
||||
func Browser(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet, fn func(*rod.Browser)) {
|
||||
showBrowser := os.Getenv("STORJ_TEST_SHOW_BROWSER") != ""
|
||||
slowBrowser := os.Getenv("STORJ_TEST_SHOW_BROWSER") == "slow"
|
||||
|
||||
logLauncher := zaptest.NewLogger(t).Named("launcher")
|
||||
logLauncher := planet.Log().Named("launcher")
|
||||
|
||||
browserLoaded := browserTimeoutDetector(10 * time.Second)
|
||||
defer browserLoaded()
|
||||
@ -44,8 +46,6 @@ func Browser(t *testing.T, ctx *testcontext.Context, fn func(*rod.Browser)) {
|
||||
NoSandbox(true).
|
||||
UserDataDir(ctx.Dir("browser")).
|
||||
Logger(zapWriter{Logger: logLauncher}).
|
||||
Set("enable-logging").
|
||||
Set("disable-gpu").
|
||||
Set("disable-web-security") // TODO: ensure we have proper CORS for testing.
|
||||
|
||||
if browserHost := os.Getenv("STORJ_TEST_BROWER_HOSTPORT"); browserHost != "" {
|
||||
@ -66,12 +66,17 @@ func Browser(t *testing.T, ctx *testcontext.Context, fn func(*rod.Browser)) {
|
||||
url, err := launch.Launch()
|
||||
require.NoError(t, err)
|
||||
|
||||
logBrowser := zaptest.NewLogger(t).Named("rod")
|
||||
logBrowser := planet.Log().Named("rod")
|
||||
logBrowserCDP := logBrowser.Named("cdp")
|
||||
|
||||
client := cdp.New(url).Logger(utils.Log(func(msg ...interface{}) {
|
||||
logBrowserCDP.Debug(fmt.Sprintln(msg...))
|
||||
}))
|
||||
|
||||
browser := rod.New().
|
||||
Timeout(time.Minute).
|
||||
Sleeper(MaxDuration(5 * time.Second)).
|
||||
ControlURL(url).
|
||||
Client(client).
|
||||
Logger(utils.Log(func(msg ...interface{}) {
|
||||
logBrowser.Info(fmt.Sprintln(msg...))
|
||||
})).
|
||||
@ -82,7 +87,10 @@ func Browser(t *testing.T, ctx *testcontext.Context, fn func(*rod.Browser)) {
|
||||
browser = browser.SlowMotion(300 * time.Millisecond).Trace(true)
|
||||
}
|
||||
|
||||
defer ctx.Check(browser.Close)
|
||||
defer ctx.Check(func() error {
|
||||
// browser.Close may sometimes return context.Canceled.
|
||||
return errs2.IgnoreCanceled(browser.Close())
|
||||
})
|
||||
|
||||
require.NoError(t, browser.Connect())
|
||||
|
||||
@ -109,7 +117,7 @@ func browserTimeoutDetector(duration time.Duration) context.CancelFunc {
|
||||
// MaxDuration returns a sleeper constructor with the max duration.
|
||||
func MaxDuration(max time.Duration) func() utils.Sleeper {
|
||||
return func() utils.Sleeper {
|
||||
singleSleep := 50 * time.Millisecond
|
||||
singleSleep := 100 * time.Millisecond
|
||||
totalSlept := time.Duration(0)
|
||||
return func(ctx context.Context) error {
|
||||
if totalSlept > max {
|
||||
@ -125,6 +133,7 @@ func MaxDuration(max time.Duration) func() utils.Sleeper {
|
||||
select {
|
||||
case <-t.C:
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -19,7 +19,6 @@ import (
|
||||
"github.com/spf13/pflag"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zaptest"
|
||||
|
||||
"storj.io/common/sync2"
|
||||
"storj.io/common/testcontext"
|
||||
@ -72,6 +71,7 @@ func Edge(t *testing.T, test EdgeTest) {
|
||||
config.Console.StaticDir = dir
|
||||
}
|
||||
config.Console.NewOnboarding = true
|
||||
config.Console.NewObjectsFlow = true
|
||||
config.Console.NewBrowser = true
|
||||
// TODO: this should be dynamically set from the auth service
|
||||
config.Console.GatewayCredentialsRequestURL = "http://" + authSvcAddr
|
||||
@ -92,7 +92,7 @@ func Edge(t *testing.T, test EdgeTest) {
|
||||
authClient, err := authclient.New(authURL, "super-secret", 5*time.Minute)
|
||||
require.NoError(t, err)
|
||||
|
||||
gateway, err := server.New(gwConfig, zaptest.NewLogger(t).Named("gateway"), nil, trustedip.NewListTrustAll(), []string{}, authClient)
|
||||
gateway, err := server.New(gwConfig, planet.Log().Named("gateway"), nil, trustedip.NewListTrustAll(), []string{}, authClient)
|
||||
require.NoError(t, err)
|
||||
|
||||
defer ctx.Check(gateway.Close)
|
||||
@ -108,7 +108,7 @@ func Edge(t *testing.T, test EdgeTest) {
|
||||
authConfig.AllowedSatellites = append(authConfig.AllowedSatellites, sat.NodeURL().String())
|
||||
}
|
||||
|
||||
auth, err := auth.New(ctx, zaptest.NewLogger(t).Named("auth"), authConfig, ctx.Dir("authservice"))
|
||||
auth, err := auth.New(ctx, planet.Log().Named("auth"), authConfig, ctx.Dir("authservice"))
|
||||
require.NoError(t, err)
|
||||
|
||||
defer ctx.Check(auth.Close)
|
||||
@ -129,7 +129,7 @@ func Edge(t *testing.T, test EdgeTest) {
|
||||
edge.Gateway.Addr = gateway.Address()
|
||||
edge.Auth.Addr = authSvcAddr
|
||||
|
||||
Browser(t, ctx, func(browser *rod.Browser) {
|
||||
Browser(t, ctx, planet, func(browser *rod.Browser) {
|
||||
test(t, ctx, edge, browser)
|
||||
})
|
||||
})
|
||||
|
@ -27,7 +27,7 @@ func Multinode(t *testing.T, multinodeCount int, test Test) {
|
||||
},
|
||||
NonParallel: true,
|
||||
}, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
|
||||
Browser(t, ctx, func(browser *rod.Browser) {
|
||||
Browser(t, ctx, planet, func(browser *rod.Browser) {
|
||||
test(t, ctx, planet, browser)
|
||||
})
|
||||
})
|
||||
|
@ -46,9 +46,8 @@ func Run(t *testing.T, test Test) {
|
||||
config.Console.NewObjectsFlow = true
|
||||
},
|
||||
},
|
||||
NonParallel: true,
|
||||
}, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
|
||||
Browser(t, ctx, func(browser *rod.Browser) {
|
||||
Browser(t, ctx, planet, func(browser *rod.Browser) {
|
||||
test(t, ctx, planet, browser)
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user