feat(ops): log detailed wrapper path, stdin length, env keys, stdout and stderr when proc_open wrapper exits non-zero
This commit is contained in:
parent
7eaff36e75
commit
27b8f34392
|
|
@ -106,8 +106,23 @@ public function handle(): int
|
|||
|
||||
$exitCode = proc_close($process);
|
||||
|
||||
$stdinLength = strlen($promptInput);
|
||||
$envKeys = implode(', ', array_keys($env));
|
||||
|
||||
if ($exitCode !== 0) {
|
||||
$this->error("❌ WRAPPER AGY FALLITO (Exit Code: {$exitCode}): {$stderr}");
|
||||
$this->error('❌ WRAPPER AGY FALLITO');
|
||||
$this->line("WRAPPER_PATH: {$wrapperScript}");
|
||||
$this->line("STDIN_LENGTH: {$stdinLength}");
|
||||
$this->line("ENV_KEYS: {$envKeys}");
|
||||
$this->line("EXIT_CODE: {$exitCode}");
|
||||
$this->line('STDOUT:');
|
||||
if ($stdout !== '') {
|
||||
$this->line(trim($stdout));
|
||||
}
|
||||
$this->line('STDERR:');
|
||||
if ($stderr !== '') {
|
||||
$this->line(trim($stderr));
|
||||
}
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@
|
|||
});
|
||||
});
|
||||
|
||||
it('does not publish report when wrapper exit code is non-zero', function () {
|
||||
it('does not publish report when wrapper exit code is non-zero and displays stdout and stderr', function () {
|
||||
$taskId = 'task-test-err-001';
|
||||
|
||||
Http::fake([
|
||||
|
|
@ -84,18 +84,34 @@
|
|||
]);
|
||||
|
||||
$mockScript = tempnam(sys_get_temp_dir(), 'mock_wrapper_err_') . '.sh';
|
||||
file_put_contents($mockScript, "#!/usr/bin/env bash\necho 'Fatal wrapper error' >&2\nexit 1\n");
|
||||
$jsonErrorOutput = json_encode(['ok' => false, 'missing' => ['task_id']], JSON_PRETTY_PRINT);
|
||||
|
||||
$scriptContent = <<<BASH
|
||||
#!/usr/bin/env bash
|
||||
echo 'Standard error log message' >&2
|
||||
cat << JSON
|
||||
{$jsonErrorOutput}
|
||||
JSON
|
||||
exit 1
|
||||
BASH;
|
||||
|
||||
file_put_contents($mockScript, $scriptContent);
|
||||
chmod($mockScript, 0755);
|
||||
|
||||
$exitCode = $this->artisan('netgescon:control-tower-poll', [
|
||||
$this->artisan('netgescon:control-tower-poll', [
|
||||
'--task-id' => $taskId,
|
||||
'--wrapper-script' => $mockScript,
|
||||
])->run();
|
||||
])
|
||||
->expectsOutputToContain('WRAPPER AGY FALLITO')
|
||||
->expectsOutputToContain('EXIT_CODE: 1')
|
||||
->expectsOutputToContain('STDOUT:')
|
||||
->expectsOutputToContain('"ok": false')
|
||||
->expectsOutputToContain('STDERR:')
|
||||
->expectsOutputToContain('Standard error log message')
|
||||
->assertExitCode(Command::FAILURE);
|
||||
|
||||
@unlink($mockScript);
|
||||
|
||||
expect($exitCode)->toBe(Command::FAILURE);
|
||||
|
||||
Http::assertNotSent(function ($request) {
|
||||
return str_contains($request->url(), '/api/reports');
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user