get(EntityManagerInterface::class), $httpClient, $container->get(CreatePartitionService::class), $container->get(LoggerInterface::class), $container->get(CreateService::class), $container->get(CreateRepositoryAction::class), $container->get(SshKeyAction::class), 'false', ); } public function testBusyClientWithQueueCreatesPendingTraceNotBusy(): void { /** @var Client $client */ $client = ClientFactory::createOne(['ip' => '127.0.0.1', 'token' => 'fake-token'])->_real(); $mockHttpClient = new MockHttpClient(fn() => new MockResponse('{"message":"busy"}', ['http_code' => 409])); $input = new CommandExecuteInput(); $input->clients = [new ClientOutput($client)]; $input->script = 'echo hello'; $input->queue = true; $this->buildRunScriptAction($mockHttpClient)->__invoke($input); $trace = static::getContainer()->get('doctrine')->getRepository(Trace::class) ->findOneBy(['client' => $client, 'command' => CommandTypes::RUN_SCRIPT]); $this->assertNotNull($trace, 'Debe haberse creado una traza para el script'); $this->assertSame(TraceStatus::PENDING, $trace->getStatus(), 'Con "encolar" marcado, la traza debe quedar PENDING (para que el reintento la recoja), no BUSY'); } public function testBusyClientWithoutQueueCreatesBusyTrace(): void { /** @var Client $client */ $client = ClientFactory::createOne(['ip' => '127.0.0.1', 'token' => 'fake-token'])->_real(); $mockHttpClient = new MockHttpClient(fn() => new MockResponse('{"message":"busy"}', ['http_code' => 409])); $input = new CommandExecuteInput(); $input->clients = [new ClientOutput($client)]; $input->script = 'echo hello'; $input->queue = false; $this->buildRunScriptAction($mockHttpClient)->__invoke($input); $trace = static::getContainer()->get('doctrine')->getRepository(Trace::class) ->findOneBy(['client' => $client, 'command' => CommandTypes::RUN_SCRIPT]); $this->assertNotNull($trace); $this->assertSame(TraceStatus::BUSY, $trace->getStatus(), 'Sin "encolar", debe mantenerse el comportamiento previo (traza BUSY, sin reintento)'); } }