def test_find_all(self): phpfpm_manager = PHPFPMManager() assert_that(phpfpm_manager, not_none()) found_masters = phpfpm_manager._find_all() assert_that(found_masters, not_none()) assert_that(found_masters, has_length(1)) found_master = found_masters[0] assert_that( found_master['cmd'], equal_to('php-fpm: master process (/etc/php5/fpm/php-fpm.conf)')) assert_that(found_master['conf_path'], equal_to('/etc/php5/fpm/php-fpm.conf')) assert_that(found_master['pid'], not_none()) assert_that( found_master['local_id'], equal_to( 'af230c9e0343ec22e88333783e89857a0f5129b0fd8e4cfe21e12b1ae35fb3b4' )) assert_that(found_master['workers'], has_length(4))
def test_find_all(self): phpfpm_manager = PHPFPMManager() assert_that(phpfpm_manager, not_none()) found_masters = phpfpm_manager._find_all() assert_that(found_masters, not_none()) assert_that(found_masters, has_length(1)) found_master = found_masters[0] assert_that( found_master['cmd'], equal_to('php-fpm: master process (/etc/php5/fpm/php-fpm.conf)')) assert_that(found_master['conf_path'], equal_to('/etc/php5/fpm/php-fpm.conf')) assert_that(found_master['pid'], not_none()) assert_that( found_master['local_id'], equal_to( 'e5942daaa5bf35af722bac3b9582b17c07515f0f77936fb5c7f771c7736cc157' )) assert_that(found_master['workers'], has_length(4))
def test_bad_ps(self): phpfpm_manager = PHPFPMManager() assert_that(phpfpm_manager, not_none()) bad_ps_stdout = [ '15923 1 php-fpm: master process (/etc/php-fpm.conf)', '20704 15923 php-fpm: pool www', '20925 15923 php-fpm: pool www', '21350 15923 php-fpm: pool www', '21385 15923 php-fpm: pool www', '21386 15923 php-fpm: pool www', '21575 15923 php-fpm: pool www', '21699 15923 php-fpm: pool www', '21734 15923 php-fpm: pool www', '21735 15923 php-fpm: pool www', '21781 15923 php-fpm: pool www', '21782 15923 php-fpm: pool www', '22287 15923 php-fpm: pool www', '22330 15923 php-fpm: pool www', '22331 15923 php-fpm: pool www', '22495 15923 php-fpm: pool www', '22654 21386 php-fpm: pool www', # <---- Wut? '' ] # 16 workers found_masters = phpfpm_manager._find_all(ps=bad_ps_stdout) assert_that(found_masters, not_none()) assert_that(found_masters, has_length(1)) # ignore the second worker found_master = found_masters[0] assert_that(found_master['cmd'], equal_to('php-fpm: master process (/etc/php-fpm.conf)')) assert_that(found_master['conf_path'], equal_to('/etc/php-fpm.conf')) assert_that(found_master['pid'], not_none()) assert_that( found_master['local_id'], equal_to( '435ef2cd03cd3487d4c2f7c7047706c48bd61b4b34c99e96e1d5608e264893ed' )) assert_that(found_master['workers'], has_length(15))