bug74083-concurrent-reload.phpt 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. --TEST--
  2. Concurrent reload signals should not kill PHP-FPM master process. (Bug: #74083)
  3. --SKIPIF--
  4. <?php
  5. include "skipif.inc";
  6. if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
  7. ?>
  8. --FILE--
  9. <?php
  10. require_once "tester.inc";
  11. $cfg = <<<EOT
  12. [global]
  13. error_log = {{FILE:LOG}}
  14. pid = {{FILE:PID}}
  15. process_control_timeout=1
  16. [unconfined]
  17. listen = {{ADDR}}
  18. ping.path = /ping
  19. ping.response = pong
  20. pm = dynamic
  21. pm.max_children = 5
  22. pm.start_servers = 1
  23. pm.min_spare_servers = 1
  24. pm.max_spare_servers = 1
  25. EOT;
  26. $code = <<<EOT
  27. <?php
  28. /* empty */
  29. EOT;
  30. $tester = new FPM\Tester($cfg, $code);
  31. $tester->start();
  32. $tester->expectLogStartNotices();
  33. $tester->ping('{{ADDR}}');
  34. /* Vary interval between concurrent reload requests
  35. since performance of test instance is not known in advance */
  36. $max_interval = 25000;
  37. $step = 1000;
  38. $pid = $tester->getPid();
  39. for ($interval = 0; $interval < $max_interval; $interval += $step) {
  40. exec("kill -USR2 $pid", $out, $killExitCode);
  41. if ($killExitCode) {
  42. echo "ERROR: master process is dead\n";
  43. break;
  44. }
  45. usleep($interval);
  46. }
  47. echo "Reached interval $interval us with $step us steps\n";
  48. $tester->readAllLogNotices('Reloading in progress ...');
  49. $tester->reload();
  50. $tester->expectLogReloadingNotices();
  51. $tester->ping('{{ADDR}}');
  52. $tester->terminate();
  53. $tester->expectLogTerminatingNotices();
  54. $tester->close();
  55. ?>
  56. Done
  57. --EXPECT--
  58. Reached interval 25000 us with 1000 us steps
  59. Done
  60. --CLEAN--
  61. <?php
  62. require_once "tester.inc";
  63. FPM\Tester::clean();
  64. ?>