mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-03 19:47:10 +00:00
fix(ios): share one deadline across the restart and the second launch
the recovery a blown bound triggers now costs at most launchRecoveryTimeout whatever it spends it on, so the launch path tops out at 150s and testrun's three minute backstop stays a backstop.
This commit is contained in:
1 parent
8baea14245
commit
f073f2cc74
1 file changed
+16
-12
@@ -53,12 +53,13 @@ var shutdownGrace = 15 * time.Second
|
|||||||
// A variable so the timeout test can shrink it.
|
// A variable so the timeout test can shrink it.
|
||||||
var launchTimeout = 90 * time.Second
|
var launchTimeout = 90 * time.Second
|
||||||
|
|
||||||
// launchRecoveryTimeout bounds the session restart that a blown launch bound
|
// launchRecoveryTimeout bounds the whole recovery a blown launch bound
|
||||||
// triggers. Together with launchTimeout it keeps the whole launch path inside
|
// triggers, the session restart and the second attempt together. It keeps the
|
||||||
// the three minutes testrun allows it: launchTimeout to discover the wedge,
|
// launch path inside the three minutes testrun allows it, so what a user sees
|
||||||
// this to replace the session, and whatever is left of the caller's budget for
|
// when the app really cannot be launched stays the driver's error rather than
|
||||||
// the second attempt.
|
// that backstop firing over the top of it. A variable so the bound test can
|
||||||
const launchRecoveryTimeout = 60 * time.Second
|
// shrink it.
|
||||||
|
var launchRecoveryTimeout = 60 * time.Second
|
||||||
|
|
||||||
// longPressHoldMilliseconds is how long LongPress holds the finger down.
|
// longPressHoldMilliseconds is how long LongPress holds the finger down.
|
||||||
const longPressHoldMilliseconds = 600
|
const longPressHoldMilliseconds = 600
|
||||||
@@ -515,19 +516,22 @@ func (d *Driver) launchWithSessionRecovery(ctx context.Context) error {
|
|||||||
d.bundleID, launchTimeout, err)
|
d.bundleID, launchTimeout, err)
|
||||||
|
|
||||||
// The restart runs under the driver's own lifetime context for the same
|
// The restart runs under the driver's own lifetime context for the same
|
||||||
// reason withRecovery's does, but bounded: a launch that already spent
|
// reason withRecovery's does, while the second attempt stays on the
|
||||||
// launchTimeout must not then wait out the session's full cold-start
|
// caller's. Both end at one deadline, so a launch that already spent
|
||||||
// budget, or the launch path outgrows the backstop testrun puts around it.
|
// launchTimeout cannot then wait out a session cold start on top of it.
|
||||||
|
recoveryDeadline := time.Now().Add(launchRecoveryTimeout)
|
||||||
restartCtx := d.processContext
|
restartCtx := d.processContext
|
||||||
if restartCtx == nil {
|
if restartCtx == nil {
|
||||||
restartCtx = ctx
|
restartCtx = ctx
|
||||||
}
|
}
|
||||||
restartCtx, cancel := context.WithTimeout(restartCtx, launchRecoveryTimeout)
|
restartCtx, cancelRestart := context.WithDeadline(restartCtx, recoveryDeadline)
|
||||||
defer cancel()
|
defer cancelRestart()
|
||||||
if restartErr := d.restart(restartCtx); restartErr != nil {
|
if restartErr := d.restart(restartCtx); restartErr != nil {
|
||||||
return fmt.Errorf("session restart failed: %w (original: %v)", restartErr, err)
|
return fmt.Errorf("session restart failed: %w (original: %v)", restartErr, err)
|
||||||
}
|
}
|
||||||
return d.lifecycleCall(ctx, launch)
|
relaunchCtx, cancelRelaunch := context.WithDeadline(ctx, recoveryDeadline)
|
||||||
|
defer cancelRelaunch()
|
||||||
|
return d.lifecycleCall(relaunchCtx, launch)
|
||||||
}
|
}
|
||||||
|
|
||||||
// lifecycleCall runs an app lifecycle RPC against lifecycleCompanion under a
|
// lifecycleCall runs an app lifecycle RPC against lifecycleCompanion under a
|
||||||
|
|||||||
Reference in new issue
Block a user