Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

PostgresNode::pid is improved#199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

dmitry-lipetsk
Copy link
Collaborator

  • We do multiple attempts to read pid file.
  • We process a case when we see that node is stopped between test and read.
  • We process a case when pid-file is empty.

- We do multiple attempts to read pid file.- We process a case when we see that node is stopped between test and read.- We process a case when pid-file is empty.
@dmitry-lipetsk
Copy link
CollaboratorAuthor

Example of problem with PostgresNode.pid:
https://app.travis-ci.com/github/postgrespro/testgres/jobs/630950715

____________________ TestgresTests.test_pg_ctl_wait_option _____________________[gw3] linux -- Python 3.12.3 /tmp/testgres_venv/bin/pythonself = <testgres.tests.test_simple.TestgresTests object at 0x7fbc7ed0e900>    def test_pg_ctl_wait_option(self):>       with get_new_node() as node:node       = PostgresNode(name='testgres-3103c943-9757-416e-b7c5-55899be2539e', port=None, base_dir='/tmp/tgsn_05zpeoer')self       = <testgres.tests.test_simple.TestgresTests object at 0x7fbc7ed0e900>tests/test_simple.py:431: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ testgres/node.py:197: in __exit__    self.cleanup(attempts)        attempts   = 3        c1         = True        c2         = False        got_exception = False        self       = PostgresNode(name='testgres-3103c943-9757-416e-b7c5-55899be2539e', port=None, base_dir='/tmp/tgsn_05zpeoer')        traceback  = None        type       = None        value      = Nonetestgres/node.py:1040: in cleanup    self._try_shutdown(max_attempts)        full       = False        max_attempts = 3        self       = PostgresNode(name='testgres-3103c943-9757-416e-b7c5-55899be2539e', port=None, base_dir='/tmp/tgsn_05zpeoer')testgres/node.py:342: in _try_shutdown    node_pid = self.pid        attempts   = 0        max_attempts = 3        self       = PostgresNode(name='testgres-3103c943-9757-416e-b7c5-55899be2539e', port=None, base_dir='/tmp/tgsn_05zpeoer')        with_force = Falsetestgres/node.py:213: in pid    lines = self.os_ops.readlines(pid_file)        pid_file   = '/tmp/tgsn_05zpeoer/data/postmaster.pid'        self       = PostgresNode(name='testgres-3103c943-9757-416e-b7c5-55899be2539e', port=None, base_dir='/tmp/tgsn_05zpeoer')_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <testgres.testgres.operations.local_ops.LocalOperations object at 0x7fbc7edc9640>filename = '/tmp/tgsn_05zpeoer/data/postmaster.pid', num_lines = 0binary = False, encoding = None    def readlines(self, filename, num_lines=0, binary=False, encoding=None):        """        Read lines from a local file.        If num_lines is greater than 0, only the last num_lines lines will be read.        """        assert num_lines >= 0        mode = 'rb' if binary else 'r'        if num_lines == 0:>           with open(filename, mode, encoding=encoding) as file:  # open in binary modeE           FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tgsn_05zpeoer/data/postmaster.pid'binary     = Falseencoding   = Nonefilename   = '/tmp/tgsn_05zpeoer/data/postmaster.pid'mode       = 'r'num_lines  = 0self       = <testgres.testgres.operations.local_ops.LocalOperations object at 0x7fbc7edc9640>testgres/operations/local_ops.py:341: FileNotFoundError

@dmitry-lipetsk
Copy link
CollaboratorAuthor

The current implementation of PostgresNode::pid() is bad.

We have to check and use the information from pg_ctl:

dima@ubuntu-work-01:/home$ pg_ctl statuspg_ctl: server is running (PID: 2864920)/usr/local/pgsql/bin/postgres

@dmitry-lipetsk
Copy link
CollaboratorAuthor

https://app.travis-ci.com/github/postgrespro/testgres/jobs/630986028

=================================== FAILURES ===================================____________________ TestgresTests.test_pg_ctl_wait_option _____________________[gw3] linux -- Python 3.12.9 /tmp/testgres_venv/bin/pythonself = <testgres.tests.test_simple.TestgresTests object at 0x7f08e4a1b0b0>    def test_pg_ctl_wait_option(self):>       with get_new_node() as node:node       = PostgresNode(name='testgres-4d7c717e-cc68-4a62-b7be-4577c2d40eae', port=None, base_dir='/tmp/tgsn_glidbijf')self       = <testgres.tests.test_simple.TestgresTests object at 0x7f08e4a1b0b0>tests/test_simple.py:431: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ testgres/node.py:197: in __exit__    self.cleanup(attempts)        attempts   = 3        c1         = True        c2         = False        got_exception = False        self       = PostgresNode(name='testgres-4d7c717e-cc68-4a62-b7be-4577c2d40eae', port=None, base_dir='/tmp/tgsn_glidbijf')        traceback  = None        type       = None        value      = Nonetestgres/node.py:1040: in cleanup    self._try_shutdown(max_attempts)        full       = False        max_attempts = 3        self       = PostgresNode(name='testgres-4d7c717e-cc68-4a62-b7be-4577c2d40eae', port=None, base_dir='/tmp/tgsn_glidbijf')testgres/node.py:342: in _try_shutdown    node_pid = self.pid        attempts   = 0        max_attempts = 3        self       = PostgresNode(name='testgres-4d7c717e-cc68-4a62-b7be-4577c2d40eae', port=None, base_dir='/tmp/tgsn_glidbijf')        with_force = Falsetestgres/node.py:213: in pid    lines = self.os_ops.readlines(pid_file)        pid_file   = '/tmp/tgsn_glidbijf/data/postmaster.pid'        self       = PostgresNode(name='testgres-4d7c717e-cc68-4a62-b7be-4577c2d40eae', port=None, base_dir='/tmp/tgsn_glidbijf')_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <testgres.testgres.operations.local_ops.LocalOperations object at 0x7f08e4afa060>filename = '/tmp/tgsn_glidbijf/data/postmaster.pid', num_lines = 0binary = False, encoding = None    def readlines(self, filename, num_lines=0, binary=False, encoding=None):        """        Read lines from a local file.        If num_lines is greater than 0, only the last num_lines lines will be read.        """        assert num_lines >= 0        mode = 'rb' if binary else 'r'        if num_lines == 0:>           with open(filename, mode, encoding=encoding) as file:  # open in binary modeE           FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tgsn_glidbijf/data/postmaster.pid'binary     = Falseencoding   = Nonefilename   = '/tmp/tgsn_glidbijf/data/postmaster.pid'mode       = 'r'num_lines  = 0self       = <testgres.testgres.operations.local_ops.LocalOperations object at 0x7f08e4afa060>testgres/operations/local_ops.py:341: FileNotFoundError=============================== warnings summary ===============================../../tmp/testgres_venv/lib/python3.12/site-packages/_pytest/config/__init__.py:1500../../tmp/testgres_venv/lib/python3.12/site-packages/_pytest/config/__init__.py:1500../../tmp/testgres_venv/lib/python3.12/site-packages/_pytest/config/__init__.py:1500../../tmp/testgres_venv/lib/python3.12/site-packages/_pytest/config/__init__.py:1500../../tmp/testgres_venv/lib/python3.12/site-packages/_pytest/config/__init__.py:1500  /tmp/testgres_venv/lib/python3.12/site-packages/_pytest/config/__init__.py:1500: PytestConfigWarning: No files were found in testpaths; consider removing or adjusting your testpaths configuration. Searching recursively from the current directory instead.    self.args, self.args_source = self._decide_args(testgres/exceptions.py:6testgres/exceptions.py:6testgres/exceptions.py:6testgres/exceptions.py:6  /pg/testgres/testgres/exceptions.py:6: PytestCollectionWarning: cannot collect test class 'TestgresException' because it has a __init__ constructor (from: tests/test_simple.py)    class TestgresException(Exception):testgres/exceptions.py:6testgres/exceptions.py:6testgres/exceptions.py:6testgres/exceptions.py:6  /pg/testgres/testgres/exceptions.py:6: PytestCollectionWarning: cannot collect test class 'TestgresException' because it has a __init__ constructor (from: tests/test_simple_remote.py)    class TestgresException(Exception):-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html=========================== short test summary info ============================FAILED tests/test_simple.py::TestgresTests::test_pg_ctl_wait_option - FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tgsn_glidbijf/data/postmaster.pid'======= 1 failed, 50 passed, 1 skipped, 13 warnings in 66.76s (0:01:06) ========

@dmitry-lipetskdmitry-lipetsk merged commit22826e0 intopostgrespro:masterMar 1, 2025
1 check passed
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@demonolockdemonolockAwaiting requested review from demonolock

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant
@dmitry-lipetsk

[8]ページ先頭

©2009-2025 Movatter.jp