pants icon indicating copy to clipboard operation
pants copied to clipboard

`test_invalidated_after_parent_deletion` in `fs_test.py` is flaky

Open wilsonliam opened this issue 4 years ago • 3 comments

See https://github.com/pantsbuild/pants/pull/12297; especially this comment.

=================================== FAILURES ===================================
____________________ test_invalidated_after_parent_deletion ____________________

rule_runner = RuleRunner(build_root=/tmp/_BUILD_ROOTi3s8cytb)

    def test_invalidated_after_parent_deletion(rule_runner: RuleRunner) -> None:
        """Test that FileContent is invalidated after deleting parent directory."""
        setup_fs_test_tar(rule_runner)
    
        def read_file() -> Optional[str]:
            digest_contents = rule_runner.request(DigestContents, [PathGlobs(["a/b/1.txt"])])
            if not digest_contents:
                return None
            assert len(digest_contents) == 1
            return digest_contents[0].content.decode()
    
        # Read the original file so that we have nodes to invalidate.
        assert read_file() == "one\n"
    
        shutil.rmtree(Path(rule_runner.build_root, "a/b"))
>       assert try_with_backoff(lambda: read_file() is None)

src/python/pants/engine/fs_test.py:967: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
src/python/pants/engine/fs_test.py:123: in try_with_backoff
    if assertion_fn():
src/python/pants/engine/fs_test.py:967: in <lambda>
    assert try_with_backoff(lambda: read_file() is None)
src/python/pants/engine/fs_test.py:957: in read_file
    digest_contents = rule_runner.request(DigestContents, [PathGlobs(["a/b/1.txt"])])
src/python/pants/testutil/rule_runner.py:212: in request
    self.scheduler.product_request(output_type, [Params(*inputs)])
src/python/pants/engine/internals/scheduler.py:561: in product_request
    self._raise_on_error([t for _, t in throws])
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <pants.engine.internals.scheduler.SchedulerSession object at 0x7f21e09fad90>
throws = [Throw(exc=Exception('No such file or directory (os error 2)'), python_traceback='Traceback (no traceback):\n  <pants native internals>\nException: No such file or directory (os error 2)', engine_traceback=['snapshot', 'select'])]

    def _raise_on_error(self, throws: list[Throw]) -> NoReturn:
        exception_noun = pluralize(len(throws), "Exception")
    
        if self._scheduler.include_trace_on_error:
            throw = throws[0]
            etb = throw.engine_traceback
            python_traceback_str = throw.python_traceback or ""
            engine_traceback_str = ""
            others_msg = f"\n(and {len(throws) - 1} more)" if len(throws) > 1 else ""
            if etb:
                sep = "\n  in "
                engine_traceback_str = "Engine traceback:" + sep + sep.join(reversed(etb)) + "\n"
            raise ExecutionError(
                f"{exception_noun} encountered:\n\n"
                f"{engine_traceback_str}"
                f"{python_traceback_str}"
                f"{others_msg}",
>               wrapped_exceptions=tuple(t.exc for t in throws),
            )
E           pants.engine.internals.scheduler.ExecutionError: 1 Exception encountered:
E           
E           Engine traceback:
E             in select
E             in snapshot
E           Traceback (no traceback):
E             <pants native internals>
E           Exception: No such file or directory (os error 2)

src/python/pants/engine/internals/scheduler.py:501: ExecutionError
- generated xml file: /tmp/process-executionwVWltv/src.python.pants.engine.fs_test.py.tests.xml - 


wilsonliam avatar Jul 07 '21 23:07 wilsonliam

Still true: https://github.com/pantsbuild/pants/runs/5845293504?check_suite_focus=true#step:14:395

jsirois avatar Apr 06 '22 05:04 jsirois

And again: https://github.com/pantsbuild/pants/runs/6098005265?check_suite_focus=true#step:14:308

jsirois avatar Apr 20 '22 16:04 jsirois

This issue has been open for over one year without activity and is not labeled as a bug. It has been labeled as stale to invite any further updates. If you can confirm whether the issue is still applicable to the latest version of Pants, appears in other contexts, or its priority has changed, please let us know. Please feel free to close this issue if it is no longer relevant.

github-actions[bot] avatar Dec 02 '25 04:12 github-actions[bot]