public function testRunProcess()
 {
     $this->skipIfNotUnix();
     $command = './tests/commands/unix/sleep_binary';
     $logger = new MockPsrLogger();
     $process = new ProcessBlockSigTerm(new UnixEnvironment(), $command, getcwd(), -1, 1000, new AllLogger($logger));
     $process->stop();
     $this->assertLogsMatch(array(array('level' => LogLevel::DEBUG, 'message' => 'Process created', 'context' => array('command' => './tests/commands/unix/sleep_binary')), array('level' => LogLevel::DEBUG, 'message' => 'Signal sent', 'context' => array('signal' => ProcessInterface::SIGKILL))), $logger->getLogs());
 }
예제 #2
0
 public function testCalled()
 {
     $this->skipIfNotUnix();
     $command = './tests/commands/unix/test_binary';
     $mockLogger = new MockPsrLogger();
     $process = new Process(new UnixEnvironment(), $command, getcwd(), -1, 1000, new AllLogger($mockLogger));
     $process->wait();
     $this->assertLogsMatch(array(array('level' => LogLevel::DEBUG, 'message' => 'Process created', 'context' => array('command' => './tests/commands/unix/test_binary')), array('level' => LogLevel::DEBUG, 'message' => 'Read from stdout', 'context' => array('stdout' => 'Test command' . PHP_EOL . PHP_EOL)), array('level' => LogLevel::DEBUG, 'message' => 'Process exited', 'context' => array('exit_code' => 0))), $mockLogger->getLogs());
 }
예제 #3
0
 public function testSendSignal()
 {
     $this->skipIfNotUnix();
     $command = './tests/commands/unix/sleep_binary';
     $mockLogger = new MockPsrLogger();
     $process = new Process(new UnixEnvironment(), $command, getcwd(), -1, 1000, new ErrorLogger($mockLogger));
     $process->stop();
     $this->assertLogsMatch(array(array('level' => LogLevel::ERROR, 'message' => 'Process exited', 'context' => array('exit_code' => -1))), $mockLogger->getLogs());
 }
 public function testAggregateLogger()
 {
     $this->skipIfNotUnix();
     $command = './tests/commands/unix/long_sleep_binary';
     $mockLogger = new MockPsrLogger();
     $allLogger = new AllLogger($mockLogger);
     $process = new Process(new UnixEnvironment(), $command, getcwd(), -1, 1000, new AggregateLogger(array($allLogger, new NullProcessObserver())));
     $process->sendSignal(Process::SIGTERM);
     $process->wait();
     $this->assertLogsMatch(array(array('level' => LogLevel::DEBUG, 'message' => 'Process created', 'context' => array('command' => './tests/commands/unix/long_sleep_binary')), array('level' => LogLevel::DEBUG, 'message' => 'Signal sent', 'context' => array('signal' => 'SIGTERM')), array('level' => LogLevel::DEBUG, 'message' => 'Process exited', 'context' => array('exit_code' => -1))), $mockLogger->getLogs());
 }
예제 #5
0
 public function testTimeoutLongRunning()
 {
     $this->skipIfNotUnix();
     $command = './tests/commands/unix/long_sleep_binary';
     $logger = new MockPsrLogger();
     $process = new Process(new UnixEnvironment(), $command, getcwd(), 500000, 1000, new AllLogger($logger));
     $process->wait();
     $this->assertLogsMatch(array(array('level' => LogLevel::DEBUG, 'message' => 'Process created', 'context' => array('command' => './tests/commands/unix/long_sleep_binary')), array('level' => LogLevel::DEBUG, 'message' => 'Signal sent', 'context' => array('signal' => ProcessInterface::SIGTERM)), array('level' => LogLevel::DEBUG, 'message' => 'Process exited', 'context' => array('exit_code' => -1))), $logger->getLogs());
 }