Esempio n. 1
0
    def test_single_edenfs_process_per_dir_okay(self) -> None:
        # The rogue process finder should not complain about edenfs processes
        # when there is just a single edenfs process running per directory, even if the
        # pid file does not appear to currently contain that pid.
        #
        # The pid file check is inherently racy.  `eden doctor` may not read the correct
        # pid if edenfs was in the middle of (re)starting.  Therefore we intentionally
        # only report rogue processes when we can actually confirm there is more than
        # one edenfs process running for a given directory.
        process_finder = self.make_process_finder()
        # In config1/ replace the lock file contents with a different process ID
        process_finder.add_edenfs(123_203, "/tmp/config1/.eden", set_lockfile=False)
        process_finder.set_file_contents("/tmp/config1/.eden/lock", b"9765\n")
        # In config2/ do not write a lock file at all
        process_finder.add_edenfs(123_456, "/tmp/config2/.eden", set_lockfile=False)
        # In config3/ report two separate edenfs processes, with one legitimate rogue
        # process
        process_finder.add_edenfs(123_900, "/tmp/config3/.eden")
        process_finder.add_edenfs(123_901, "/tmp/config3/.eden", set_lockfile=False)

        fixer, out = self.run_check(process_finder, dry_run=False)
        self.assertEqual(
            out,
            f"""\
<yellow>- Found problem:<reset>
Many edenfs processes are running. Please keep only one for each config directory.
kill -9 123901

""",
        )
    def test_single_edenfs_process_per_dir_okay(self) -> None:
        # The rogue process finder should not complain about edenfs processes
        # when there is just a single edenfs process running per directory, even if the
        # pid file does not appear to currently contain that pid.
        #
        # The pid file check is inherently racy.  `eden doctor` may not read the correct
        # pid if edenfs was in the middle of (re)starting.  Therefore we intentionally
        # only report rogue processes when we can actually confirm there is more than
        # one edenfs process running for a given directory.
        process_finder = self.make_process_finder()
        # In config1/ replace the lock file contents with a different process ID
        process_finder.add_edenfs(123203, "/tmp/config1/.eden", set_lockfile=False)
        process_finder.set_file_contents("/tmp/config1/.eden/lock", b"9765\n")
        # In config2/ do not write a lock file at all
        process_finder.add_edenfs(123456, "/tmp/config2/.eden", set_lockfile=False)
        # In config3/ report two separate edenfs processes, with one legitimate rogue
        # process
        process_finder.add_edenfs(123900, "/tmp/config3/.eden")
        process_finder.add_edenfs(123901, "/tmp/config3/.eden", set_lockfile=False)

        fixer, out = self.run_check(process_finder, dry_run=False)
        self.assertEqual(
            out,
            f"""\
<yellow>- Found problem:<reset>
Many edenfs processes are running. Please keep only one for each config directory.
kill -9 123901

""",
        )
Esempio n. 3
0
 def test_when_lock_file_data_is_garbage(self) -> None:
     process_finder = self.make_process_finder()
     process_finder.add_edenfs(
         475_203, "/tmp/eden_test.68yxptnx/.eden", set_lockfile=False
     )
     process_finder.add_edenfs(
         475_204, "/tmp/eden_test.68yxptnx/.eden", set_lockfile=False
     )
     process_finder.set_file_contents("/tmp/eden_test.68yxptnx/.eden/lock", b"asdf")
     with self.assertLogs() as logs_assertion:
         fixer, out = self.run_check(process_finder, dry_run=False)
         self.assertEqual("", out)
         self.assert_results(fixer, num_problems=0)
     self.assertIn(
         "lock file contains data that cannot be parsed",
         "\n".join(logs_assertion.output),
     )
 def test_when_lock_file_data_is_garbage(self) -> None:
     process_finder = self.make_process_finder()
     process_finder.add_edenfs(
         475203, "/tmp/eden_test.68yxptnx/.eden", set_lockfile=False
     )
     process_finder.add_edenfs(
         475204, "/tmp/eden_test.68yxptnx/.eden", set_lockfile=False
     )
     process_finder.set_file_contents("/tmp/eden_test.68yxptnx/.eden/lock", b"asdf")
     with self.assertLogs() as logs_assertion:
         fixer, out = self.run_check(process_finder, dry_run=False)
         self.assertEqual("", out)
         self.assert_results(fixer, num_problems=0)
     self.assertIn(
         "lock file contains data that cannot be parsed",
         "\n".join(logs_assertion.output),
     )