Repository navigation
fix: a timed-out install step says why and how to resume #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| <?php | ||
|
|
||
| namespace Saucebase\Installer\Tests\Feature\Environments; | ||
|
|
||
| use Illuminate\Process\Exceptions\ProcessTimedOutException; | ||
| use Illuminate\Process\ProcessResult; | ||
| use Saucebase\Installer\Console\Commands\InstallCommand; | ||
| use Saucebase\Installer\Environments\NativeEnvironment; | ||
| use Saucebase\Installer\Tests\Feature\TestableInstallCommand; | ||
| use Saucebase\Installer\Tests\TestCase; | ||
| use Symfony\Component\Process\Exception\ProcessTimedOutException as SymfonyTimeoutException; | ||
| use Symfony\Component\Process\Process; | ||
|
|
||
| /** A step that runs out of time ends like any failed step: why, the step, and how to resume. */ | ||
| class InstallTimeoutTest extends TestCase | ||
| { | ||
| public function test_a_timed_out_step_names_the_command_and_prints_the_resume_command(): void | ||
| { | ||
| $command = new class extends TestableInstallCommand | ||
| { | ||
| /** @var string[] */ | ||
| public array $warned = []; | ||
|
|
||
| public ?string $failedAt = null; | ||
|
|
||
| public bool $failureShown = false; | ||
|
|
||
| public function install(): int | ||
| { | ||
| $process = new Process(['docker', 'compose', 'exec', '-T', 'app', 'php', 'artisan', 'optimize:clear']); | ||
| $process->setTimeout(120); | ||
|
|
||
| throw ProcessTimedOutException::make( | ||
| new SymfonyTimeoutException($process, SymfonyTimeoutException::TYPE_GENERAL), | ||
| new ProcessResult($process), | ||
| ); | ||
| } | ||
|
|
||
| public function warn($string, $verbosity = null): void | ||
| { | ||
| $this->warned[] = $string; | ||
| } | ||
|
|
||
| public function promptForModules(): void {} | ||
|
|
||
| public function displayFailure(?string $step = null, array $resumeOptions = []): void | ||
| { | ||
| $this->failedAt = $step; | ||
| $this->failureShown = true; | ||
| } | ||
| }; | ||
| $command->fakeOptions = ['path' => sys_get_temp_dir()]; | ||
|
|
||
| $result = (new NativeEnvironment)->run($command); | ||
|
|
||
| $this->assertSame(InstallCommand::FAILURE, $result); | ||
| $this->assertTrue($command->failureShown); | ||
| $this->assertSame('Running `docker compose exec -T app php artisan optimize:clear`', $command->failedAt); | ||
| $this->assertSame(['`docker compose exec -T app php artisan optimize:clear` ran longer than 120 seconds, so it was stopped.'], $command->warned); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Include the demo-account lookup in the timeout handler.
With
--demoandDEMO_PASSWORDpresent, Line 66 callsdemoStep()after this handler has ended. That method runsmodules:demo-accountswith a 120-second timeout. If the lookup times out, the exception still escapes without the failure box or resume command. This leaves the timeout fix incomplete for demo installs. (raw.githubusercontent.com)Prepare the success steps inside the
try, then display them after successful completion.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Valid, and deferred: v3.11.2 behaves the same, so it is not a regression. The fix will differ from the suggestion. By this point the install has succeeded, so a slow demo-account lookup should not show the failure box.
artisanOutput()already returns null when its command fails; it will do the same on a timeout, anddemoStep()then falls back to the plainDEMO_PASSWORDline.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@roble You’re right. My suggested failure box would misreport a successful install. The demo-account lookup should instead fall back to the
DEMO_PASSWORDline on timeout.The finding is deferred, so I’m not marking it as addressed.
Learnings added
You are interacting with an AI system.