def _test_periodic_reload(self, client: EdenClient) -> None: def write_user_config(reload_interval: str) -> None: config_text = f""" [config] reload-interval = "{reload_interval}" """ self.eden.user_rc_path.write_text(config_text) def assert_current_interval(expected: str) -> None: no_reload_params = GetConfigParams( reload=ConfigReloadBehavior.NoReload) config = client.getConfig(no_reload_params) current_interval = config.values[ "config:reload-interval"].parsedValue self.assertEqual(expected, current_interval) # By default EdenFS currently automatically reloads # the config every 5 minutes default_interval = "5m" assert_current_interval(default_interval) # Tell EdenFS to reload the config file every 10ms write_user_config("10ms") # Make EdenFS reload the config immediately to get the new config values client.reloadConfig() assert_current_interval("10ms") # Update the reload interval again to 0ms. # This tells EdenFS not to auto-reload the config any more. write_user_config("0ms") # This change should be picked up automatically after ~10ms # Sleep for longer than this, then verify the config was updated. time.sleep(0.200) assert_current_interval("0ns") # Update the reload interval to 6ms. # This shouldn't be picked up automatically, since auto-reloads are disabled # right now. write_user_config("6ms") time.sleep(0.200) assert_current_interval("0ns") # Force this change to be picked up now client.reloadConfig() assert_current_interval("6ms") # Update the reload interval again. # This should be picked up automatically again now that re-enabled the # periodic reload interval. write_user_config("7ms") time.sleep(0.200) assert_current_interval("7ms") # If we put a bogus value in the config file it should be ignored, # and the normal default (5 minutes) should be used. write_user_config("bogus value") time.sleep(0.200) assert_current_interval(default_interval)
def assert_shutdown_fails_with_in_progress_graceful_restart( self, client: EdenClient) -> None: # call initiateShutdown. This should not throw. try: client.initiateShutdown( "shutdown requested during graceful restart") except Exception: self.fail( "initiateShutdown should not throw when graceful restart is in progress" ) self.assertEqual(client.getStatus(), fb303_status.STOPPING)
def assert_sigkill_fails_with_in_progress_graceful_restart( self, client: EdenClient) -> None: # send SIGTERM to process. This should not throw. pid = self.eden.get_pid_via_thrift() try: os.kill(pid, signal.SIGTERM) except Exception: self.fail( "sending SIGTERM should not throw when graceful restart is in progress" ) self.assertEqual(client.getStatus(), fb303_status.STOPPING)
def assert_restart_fails_with_in_progress_graceful_restart( self, client: EdenClient) -> None: pid = self.eden.get_pid_via_thrift() p = self.run_restart() p.expect_exact( f"The current edenfs daemon (pid {pid}) is in the middle of stopping." f"\r\nUse `eden restart --force` if you want to forcibly restart the current daemon\r\n" ) p.wait() self.assertEqual(p.exitstatus, 4) self.assertEqual(client.getStatus(), fb303_status.STOPPING)
def _assert_thrift_calls_fail_during_mount_init( self, client: EdenClient) -> None: error_regex = "mount point .* is still initializing" mount_path = Path(self.mount) null_commit = b"\00" * 20 with self.assertRaisesRegex(EdenError, error_regex) as ctx: client.getFileInformation(mountPoint=bytes(mount_path), paths=[b""], sync=SyncBehavior()) self.assertEqual(EdenErrorType.POSIX_ERROR, ctx.exception.errorType) with self.assertRaisesRegex(EdenError, error_regex) as ctx: client.getScmStatus(mountPoint=bytes(mount_path), listIgnored=False, commit=null_commit) self.assertEqual(EdenErrorType.POSIX_ERROR, ctx.exception.errorType) parents = WorkingDirectoryParents(parent1=null_commit) params = ResetParentCommitsParams() with self.assertRaisesRegex(EdenError, error_regex) as ctx: client.resetParentCommits(mountPoint=bytes(mount_path), parents=parents, params=params) self.assertEqual(EdenErrorType.POSIX_ERROR, ctx.exception.errorType)