Example #1
0
    def test_ls_cmd(self):
        ps, _ = subp.call(PS_CMD)
        parsed_lines = [PS_PARSER(line) for line in ps]
        master_pid, master_ppid, master_command = parsed_lines[0]

        ls, _ = subp.call(LS_CMD % master_pid)
        assert_that(ls, not_none())
Example #2
0
    def test_ls_parser(self):
        ps, _ = subp.call(PS_CMD)
        parsed_lines = [PS_PARSER(line) for line in ps]
        master_pid, master_ppid, master_command = parsed_lines[0]

        ls, _ = subp.call(LS_CMD % master_pid)
        assert_that(ls, not_none())

        parsed = LS_PARSER(ls[0])
        assert_that(parsed, not_none())
        assert_that(parsed, equal_to('/usr/sbin/php5-fpm'))
Example #3
0
    def test_ps_parser(self):
        ps, _ = subp.call(PS_CMD)
        assert_that(ps, not_none())

        parsed_lines = [PS_PARSER(line) for line in ps]
        assert_that(parsed_lines, not_none())
        assert_that(parsed_lines, has_length(6))

        # just for ease of testing, let's trim the None at the end
        parsed_lines = filter(lambda item: item is not None, parsed_lines)
        assert_that(parsed_lines, has_length(5))

        master_pid, master_ppid, master_command = parsed_lines[0]
        assert_that(master_pid, not_none())
        assert_that(master_ppid, equal_to(1))
        assert_that(
            master_command,
            string_contains_in_order('php-fpm:', 'master', 'process',
                                     'php-fpm.conf'))

        for child_id, child_ppid, child_command in parsed_lines[1:]:
            assert_that(child_id, not_none())
            assert_that(child_ppid, equal_to(master_pid))
            assert_that(child_command,
                        string_contains_in_order('php-fpm:', 'pool', 'www'))
Example #4
0
    def test_version_parser(self):
        # get master_pid
        ps, _ = subp.call(PS_CMD)
        ps_parsed_lines = [PS_PARSER(line) for line in ps]
        master_pid, master_ppid, master_command = ps_parsed_lines[0]

        # get bin_path
        ls, _ = subp.call(LS_CMD % master_pid)
        bin_path = LS_PARSER(ls[0])

        version, raw_line = VERSION_PARSER(bin_path)
        assert_that(version, not_none())
        assert_that(raw_input, not_none)

        # these checks may be too specific...will definitely break on alternate
        # systems/versions
        assert_that(version, equal_to('5.5.9-1'))
        assert_that(raw_line, starts_with('PHP 5.5.9-1'))
Example #5
0
    def test_ps_master_parser(self):
        ps, _ = subp.call(PS_CMD)
        assert_that(ps, not_none())

        parsed_lines = [PS_PARSER(line) for line in ps]
        assert_that(parsed_lines, not_none())
        assert_that(parsed_lines, has_length(6))

        master_pid, master_ppid, master_command = parsed_lines[0]

        parsed_master = MASTER_PARSER(master_command)
        assert_that(parsed_master, not_none())
        assert_that(parsed_master, equal_to('/etc/php5/fpm/php-fpm.conf'))
Example #6
0
    def test_ps_cmd(self):
        ps, _ = subp.call(PS_CMD)

        assert_that(ps, not_none())
        assert_that(ps, has_length(
            6))  # TODO: Try to eliminate blank line capture from ps (at end)
        assert_that(
            ps[0],
            string_contains_in_order('php-fpm:', 'master', 'process',
                                     'php-fpm.conf'))
        for child in ps[1:-1]:
            assert_that(child,
                        string_contains_in_order('php-fpm:', 'pool', 'www'))
        assert_that(ps[-1], equal_to(''))  # Try to eliminate this in future.
Example #7
0
    def test_version_parser(self):
        # get master_pid
        ps, _ = subp.call(PS_CMD)
        ps_parsed_lines = [PS_PARSER(line) for line in ps]
        master_pid, master_ppid, master_command = ps_parsed_lines[0]

        # get bin_path
        ls, _ = subp.call(LS_CMD % master_pid)
        bin_path = LS_PARSER(ls[0])

        version, raw_line = VERSION_PARSER(bin_path)
        assert_that(version, not_none())
        assert_that(raw_input, not_none)

        # these checks may be too specific...will definitely break on alternate
        # systems/versions
        assert_that(version, equal_to('5.5.9-1'))
        assert_that(
            raw_line,
            any_of(
                'PHP 5.5.9-1ubuntu4.21 (fpm-fcgi) (built: Feb  9 2017 21:00:52)',
                'PHP 5.5.9-1ubuntu4.22 (fpm-fcgi) (built: Aug  4 2017 19:44:16)'
            ))