def test_eden_start_launches_separate_processes_for_separate_eden_dirs( self, ) -> None: eden_dir_1 = self.eden_dir eden_dir_2 = self.make_temp_dir("eden2") self.start_edenfs(eden_dir=eden_dir_1) self.start_edenfs(eden_dir=eden_dir_2) instance_1_health: HealthStatus = EdenInstance( str(eden_dir_1), etc_eden_dir=None, home_dir=None).check_health() self.assertEqual( instance_1_health.status, fb303_status.ALIVE, f"First edenfs process should be healthy, but it isn't: " f"{instance_1_health}", ) instance_2_health: HealthStatus = EdenInstance( str(eden_dir_2), etc_eden_dir=None, home_dir=None).check_health() self.assertEqual( instance_2_health.status, fb303_status.ALIVE, f"Second edenfs process should be healthy, but it isn't: " f"{instance_2_health}", ) self.assertNotEqual( instance_1_health.pid, instance_2_health.pid, f"The edenfs process should have separate process IDs", )
def check_edenfs_version(tracker: ProblemTracker, instance: EdenInstance) -> None: rver, release = instance.get_running_version_parts() if not rver or not release: # This could be a dev build that returns the empty # string for both of these values. return running_version = version.format_eden_version((rver, release)) installed_version = version.get_current_version() if running_version == installed_version: return tracker.add_problem( Problem( dedent( f"""\ The version of Eden that is installed on your machine is: fb-eden-{installed_version}.x86_64 but the version of Eden that is currently running is: fb-eden-{running_version}.x86_64 Consider running `eden restart --graceful` to migrate to the newer version, which may have important bug fixes or performance improvements. """ ), severity=ProblemSeverity.ADVICE, ) )
def _os_is_bad_release(instance: EdenInstance, release: str) -> bool: known_bad_kernel_versions = instance.get_config_value( "doctor.known-bad-kernel-versions", default="") if not known_bad_kernel_versions: return False for regex in known_bad_kernel_versions.split(","): if re.search(regex, release): return True # matched known bad release return False # no match to bad release
def run_kerberos_certificate_checks(self, instance: EdenInstance, tracker: ProblemTracker) -> None: if not instance.get_config_bool("doctor.enable-kerberos-check", default=False): return result = subprocess.call(["klist", "-s"]) if result: tracker.add_problem(KerberosProblem())
def _os_is_kernel_version_too_old(instance: EdenInstance, release: str) -> bool: min_kernel_version = instance.get_config_value( "doctor.minimum-kernel-version", default="") if not min_kernel_version: return False try: return _parse_os_kernel_version(release) < _parse_os_kernel_version( min_kernel_version) except ValueError: # If the kernel version failed to parse because one of the # components wasn't an int, whatever. return False
def check_disk_usage( tracker: ProblemTracker, mount_paths: List[str], instance: EdenInstance, fs_util: FsUtil, ) -> None: prob_advice_space_used_ratio_threshold = 0.90 prob_error_absolute_space_used_threshold = 1024 * 1024 * 1024 # 1GB eden_mount_pts_set = get_mount_pts_set(tracker, mount_paths, instance) for eden_mount_pt in eden_mount_pts_set: if eden_mount_pt and os.path.exists(eden_mount_pt): disk_status = fs_util.statvfs(eden_mount_pt) avail = disk_status.f_frsize * disk_status.f_bavail size = disk_status.f_frsize * disk_status.f_blocks if size == 0: continue used = size - avail used_percent = float(used) / size message = ( "Eden lazily loads your files and needs enough disk space to " "store these files when loaded." ) extra_message = instance.get_config_value( "doctor.low-disk-space-message", "" ) if extra_message: message = f"{message} {extra_message}" if avail <= prob_error_absolute_space_used_threshold: tracker.add_problem( Problem( f"{eden_mount_pt} " f"has only {str(avail)} bytes available. " f"{message}", severity=ProblemSeverity.ERROR, ) ) elif used_percent >= prob_advice_space_used_ratio_threshold: tracker.add_problem( Problem( f"{eden_mount_pt} " f"is {used_percent:.2%} full. " f"{message}", severity=ProblemSeverity.ADVICE, ) )
def check_materialized_are_accessible( tracker: ProblemTracker, instance: EdenInstance, checkout: EdenCheckout, ) -> None: mismatched_mode = [] inaccessible_inodes = [] with instance.get_thrift_client_legacy() as client: materialized = client.debugInodeStatus( bytes(checkout.path), b"", flags=DIS_REQUIRE_MATERIALIZED, sync=SyncBehavior(), ) for materialized_dir in materialized: path = Path(os.fsdecode(materialized_dir.path)) try: st = os.lstat(checkout.path / path) except OSError: inaccessible_inodes += [path] continue if not stat.S_ISDIR(st.st_mode): mismatched_mode += [(path, stat.S_IFDIR, st.st_mode)] for dirent in materialized_dir.entries: if dirent.materialized: dirent_path = path / Path(os.fsdecode(dirent.name)) try: dirent_stat = os.lstat(checkout.path / dirent_path) except OSError: inaccessible_inodes += [dirent_path] continue # TODO(xavierd): Symlinks are for now recognized as files. dirent_mode = (stat.S_IFREG if stat.S_ISLNK( dirent_stat.st_mode) else stat.S_IFMT(dirent_stat.st_mode)) if dirent_mode != stat.S_IFMT(dirent.mode): mismatched_mode += [(dirent_path, dirent_stat.st_mode, dirent.mode)] if inaccessible_inodes != []: tracker.add_problem( MaterializedInodesAreInaccessible(inaccessible_inodes)) if mismatched_mode != []: tracker.add_problem( MaterializedInodesHaveDifferentModeOnDisk(mismatched_mode))
def check_loaded_content( tracker: ProblemTracker, instance: EdenInstance, checkout: EdenCheckout, query_prjfs_file: Callable[[Path], PRJ_FILE_STATE], ) -> None: with instance.get_thrift_client_legacy() as client: loaded = client.debugInodeStatus( bytes(checkout.path), b"", flags=DIS_REQUIRE_LOADED, sync=SyncBehavior(), ) errors = [] for loaded_dir in loaded: path = Path(os.fsdecode(loaded_dir.path)) for dirent in loaded_dir.entries: if not stat.S_ISREG(dirent.mode) or dirent.materialized: continue dirent_path = path / Path(os.fsdecode(dirent.name)) filestate = query_prjfs_file(checkout.path / dirent_path) if (filestate & PRJ_FILE_STATE.HydratedPlaceholder != PRJ_FILE_STATE.HydratedPlaceholder): # We should only compute the sha1 of files that have been read. continue def compute_file_sha1(file: Path) -> bytes: hasher = hashlib.sha1() with open(checkout.path / dirent_path, "rb") as f: while True: buf = f.read(1024 * 1024) if buf == b"": break hasher.update(buf) return hasher.digest() sha1 = client.getSHA1(bytes(checkout.path), [bytes(dirent_path)], sync=SyncBehavior())[0].get_sha1() on_disk_sha1 = compute_file_sha1(checkout.path / dirent_path) if sha1 != on_disk_sha1: errors += [(dirent_path, sha1, on_disk_sha1)] if errors != []: tracker.add_problem(LoadedFileHasDifferentContentOnDisk(errors))
def check_edenfs_version(tracker: ProblemTracker, instance: EdenInstance) -> None: def date_from_version(version: str) -> date: return datetime.strptime(version, "%Y%m%d").date() rver, release = instance.get_running_version_parts() if not rver or not release: # This could be a dev build that returns the empty # string for both of these values. return # get installed version parts iversion, irelease = version.get_current_version_parts() if not iversion or not irelease: # dev build of eden client returns empty strings here return # check if the runnig version is more than two weeks old daysgap = date_from_version(iversion) - date_from_version(rver) if daysgap.days < 14: return running_version = version.format_eden_version((rver, release)) installed_version = version.format_eden_version((iversion, irelease)) if sys.platform == "win32": help_string = f"""\ The version of EdenFS that is installed on your machine is: fb.eden {installed_version} but the version of EdenFS that is currently running is: fb.eden {running_version} Consider running `edenfsctl restart` to migrate to the newer version, which may have important bug fixes or performance improvements. """ else: help_string = f"""\ The version of EdenFS that is installed on your machine is: fb-eden-{installed_version}.x86_64 but the version of EdenFS that is currently running is: fb-eden-{running_version}.x86_64 Consider running `edenfsctl restart --graceful` to migrate to the newer version, which may have important bug fixes or performance improvements. """ tracker.add_problem( Problem(dedent(help_string), severity=ProblemSeverity.ADVICE))
def test_eden_start_fails_if_service_is_running(self) -> None: with self.spawn_fake_edenfs(self.eden_dir): # Make fake_edenfs inaccessible and undetectable (without talking to # systemd), but keep the systemd service alive. (self.eden_dir / "lock").unlink() (self.eden_dir / "socket").unlink() health: HealthStatus = EdenInstance(str(self.eden_dir), etc_eden_dir=None, home_dir=None).check_health() self.assertEqual(health.status, fb303_status.DEAD) service = self.get_edenfs_systemd_service(eden_dir=self.eden_dir) self.assertEqual(service.query_active_state(), "active") proc = self.expect_start_failure( f"error: edenfs systemd service is already running") # edenfsctl should show the output of 'systemctl status'. self.assertRegex(proc.stdout, r"\bfb-edenfs@.*?\.service\b") self.assertRegex(proc.stdout, r"Active:[^\n]*active \(running\)")
def test_no_mounts(self) -> None: out = TestOutput() mounts = EdenInstance._combine_mount_info([], []) main_mod.ListCmd.print_mounts(out, mounts) self.assertEqual(out.getvalue(), "")
def test_list_mounts_no_state(self) -> None: self.maxDiff = None # Simulate an older edenfs daemon that does not send the "state" field thrift_mounts = [ MountInfo( mountPoint=b"/data/users/johndoe/mercurial", edenClientPath=b"/home/johndoe/.eden/clients/mercurial", ), MountInfo( mountPoint=b"/data/users/johndoe/git", edenClientPath=b"/home/johndoe/.eden/clients/git", ), MountInfo( mountPoint=b"/data/users/johndoe/configs", edenClientPath=b"/home/johndoe/.eden/clients/configs", ), ] instance = EdenInstance( config_dir="/home/johndoe/.eden", etc_eden_dir="/etc/eden", home_dir="/home/johndoe", ) checkout1 = EdenCheckout( instance, Path("/data/users/johndoe/mercurial"), Path("/home/johndoe/.eden/clients/mercurial"), ) checkout1.set_config( CheckoutConfig( backing_repo=Path("/home/johndoe/eden-repos/mercurial"), scm_type="hg", guid="789", mount_protocol="fuse", case_sensitive=False, require_utf8_path=True, default_revision=DEFAULT_REVISION["hg"], redirections={}, active_prefetch_profiles=[], predictive_prefetch_profiles_active=False, predictive_prefetch_num_dirs=0, enable_tree_overlay=False, ) ) checkout2 = EdenCheckout( instance, Path("/data/users/johndoe/git"), Path("/home/johndoe/.eden/clients/git"), ) checkout2.set_config( CheckoutConfig( backing_repo=Path("/home/johndoe/eden-repos/git"), scm_type="git", guid="321", mount_protocol="fuse", case_sensitive=False, require_utf8_path=True, default_revision=DEFAULT_REVISION["git"], redirections={}, active_prefetch_profiles=[], predictive_prefetch_profiles_active=False, predictive_prefetch_num_dirs=0, enable_tree_overlay=False, ) ) checkout3 = EdenCheckout( instance, Path("/data/users/johndoe/www"), Path("/home/johndoe/.eden/clients/www"), ) checkout3.set_config( CheckoutConfig( backing_repo=Path("/home/johndoe/eden-repos/www"), scm_type="hg", guid="654", mount_protocol="fuse", case_sensitive=False, require_utf8_path=True, default_revision=DEFAULT_REVISION["hg"], redirections={}, active_prefetch_profiles=[], predictive_prefetch_profiles_active=False, predictive_prefetch_num_dirs=0, enable_tree_overlay=False, ) ) config_checkouts = [ checkout1, checkout2, checkout3, ] mounts = EdenInstance._combine_mount_info(thrift_mounts, config_checkouts) normal_out = TestOutput() main_mod.ListCmd.print_mounts(normal_out, mounts) self.assertEqual( """\ /data/users/johndoe/configs (unconfigured) /data/users/johndoe/git /data/users/johndoe/mercurial /data/users/johndoe/www (not mounted) """, normal_out.getvalue(), ) json_out = TestOutput() main_mod.ListCmd.print_mounts_json(json_out, mounts) self.assertEqual( """\ { "/data/users/johndoe/configs": { "backing_repo": null, "configured": false, "data_dir": "/home/johndoe/.eden/clients/configs", "state": "RUNNING" }, "/data/users/johndoe/git": { "backing_repo": "/home/johndoe/eden-repos/git", "configured": true, "data_dir": "/home/johndoe/.eden/clients/git", "state": "RUNNING" }, "/data/users/johndoe/mercurial": { "backing_repo": "/home/johndoe/eden-repos/mercurial", "configured": true, "data_dir": "/home/johndoe/.eden/clients/mercurial", "state": "RUNNING" }, "/data/users/johndoe/www": { "backing_repo": "/home/johndoe/eden-repos/www", "configured": true, "data_dir": "/home/johndoe/.eden/clients/www", "state": "NOT_RUNNING" } } """, json_out.getvalue(), )
def _check_edenfs_health(self) -> HealthStatus: instance = EdenInstance(str(self.eden_dir), etc_eden_dir=None, home_dir=None) return instance.check_health()
def test_list_mounts(self): self.maxDiff = None thrift_mounts = [ MountInfo( mountPoint=b"/data/users/johndoe/mercurial", edenClientPath=b"/home/johndoe/.eden/clients/mercurial", state=MountState.RUNNING, ), MountInfo( mountPoint=b"/data/users/johndoe/git", edenClientPath=b"/home/johndoe/.eden/clients/git", state=MountState.SHUTTING_DOWN, ), MountInfo( mountPoint=b"/data/users/johndoe/apache", edenClientPath=b"/home/johndoe/.eden/clients/apache", state=MountState.RUNNING, ), MountInfo( mountPoint=b"/data/users/johndoe/configs", edenClientPath=b"/home/johndoe/.eden/clients/configs", state=MountState.INITIALIZING, ), MountInfo( mountPoint=b"/data/users/johndoe/repos/linux", edenClientPath=b"/home/johndoe/.eden/clients/linux", state=MountState.RUNNING, ), MountInfo( mountPoint=b"/data/users/johndoe/other_repos/linux", edenClientPath=b"/home/johndoe/.eden/clients/linux2", state=MountState.RUNNING, ), ] instance = EdenInstance( config_dir="/home/johndoe/.eden", etc_eden_dir="/etc/eden", home_dir="/home/johndoe", ) config_checkouts = [ EdenCheckout( instance, Path("/data/users/johndoe/mercurial"), Path("/home/johndoe/.eden/clients/mercurial"), ), EdenCheckout( instance, Path("/data/users/johndoe/git"), Path("/home/johndoe/.eden/clients/git"), ), EdenCheckout( instance, Path("/data/users/johndoe/repos/linux"), Path("/home/johndoe/.eden/clients/linux"), ), EdenCheckout( instance, Path("/data/users/johndoe/other_repos/linux"), Path("/home/johndoe/.eden/clients/linux2"), ), EdenCheckout( instance, Path("/data/users/johndoe/www"), Path("/home/johndoe/.eden/clients/www"), ), ] mounts = main_mod.ListCmd.combine_mount_info(thrift_mounts, config_checkouts) normal_out = TestOutput() main_mod.ListCmd.print_mounts(normal_out, mounts) self.assertEqual( """\ /data/users/johndoe/apache (unconfigured) /data/users/johndoe/configs (INITIALIZING) (unconfigured) /data/users/johndoe/git (SHUTTING_DOWN) /data/users/johndoe/mercurial /data/users/johndoe/other_repos/linux /data/users/johndoe/repos/linux /data/users/johndoe/www (not mounted) """, normal_out.getvalue(), ) json_out = TestOutput() main_mod.ListCmd.print_mounts_json(json_out, mounts) self.assertEqual( """\ { "/data/users/johndoe/apache": { "configured": false, "data_dir": "/home/johndoe/.eden/clients/apache", "state": "RUNNING" }, "/data/users/johndoe/configs": { "configured": false, "data_dir": "/home/johndoe/.eden/clients/configs", "state": "INITIALIZING" }, "/data/users/johndoe/git": { "configured": true, "data_dir": "/home/johndoe/.eden/clients/git", "state": "SHUTTING_DOWN" }, "/data/users/johndoe/mercurial": { "configured": true, "data_dir": "/home/johndoe/.eden/clients/mercurial", "state": "RUNNING" }, "/data/users/johndoe/other_repos/linux": { "configured": true, "data_dir": "/home/johndoe/.eden/clients/linux2", "state": "RUNNING" }, "/data/users/johndoe/repos/linux": { "configured": true, "data_dir": "/home/johndoe/.eden/clients/linux", "state": "RUNNING" }, "/data/users/johndoe/www": { "configured": true, "data_dir": "/home/johndoe/.eden/clients/www", "state": "NOT_RUNNING" } } """, json_out.getvalue(), )
def test_list_mounts_no_backing_repos(self) -> None: self.maxDiff = None thrift_mounts = [ MountInfo( mountPoint=b"/data/users/johndoe/mercurial", edenClientPath=b"/home/johndoe/.eden/clients/mercurial", state=MountState.RUNNING, ), MountInfo( mountPoint=b"/data/users/johndoe/git", edenClientPath=b"/home/johndoe/.eden/clients/git", state=MountState.SHUTTING_DOWN, ), MountInfo( mountPoint=b"/data/users/johndoe/apache", edenClientPath=b"/home/johndoe/.eden/clients/apache", state=MountState.RUNNING, ), MountInfo( mountPoint=b"/data/users/johndoe/configs", edenClientPath=b"/home/johndoe/.eden/clients/configs", state=MountState.INITIALIZING, ), MountInfo( mountPoint=b"/data/users/johndoe/repos/linux", edenClientPath=b"/home/johndoe/.eden/clients/linux", state=MountState.RUNNING, ), MountInfo( mountPoint=b"/data/users/johndoe/other_repos/linux", edenClientPath=b"/home/johndoe/.eden/clients/linux2", state=MountState.RUNNING, ), ] instance = EdenInstance( config_dir="/home/johndoe/.eden", etc_eden_dir="/etc/eden", home_dir="/home/johndoe", ) checkout1 = EdenCheckout( instance, Path("/data/users/johndoe/mercurial"), Path("/home/johndoe/.eden/clients/mercurial"), ) checkout1.set_config( CheckoutConfig( backing_repo=Path("/home/johndoe/eden-repos/mercurial"), scm_type="hg", mount_protocol="fuse", default_revision=DEFAULT_REVISION["hg"], redirections={}, active_prefetch_profiles=[], predictive_prefetch_profiles_active=False, predictive_prefetch_num_dirs=0, ) ) checkout2 = EdenCheckout( instance, Path("/data/users/johndoe/git"), Path("/home/johndoe/.eden/clients/git"), ) checkout2.set_config( CheckoutConfig( backing_repo=Path("/home/johndoe/eden-repos/git"), scm_type="git", mount_protocol="fuse", default_revision=DEFAULT_REVISION["git"], redirections={}, active_prefetch_profiles=[], predictive_prefetch_profiles_active=False, predictive_prefetch_num_dirs=0, ) ) checkout3 = EdenCheckout( instance, Path("/data/users/johndoe/repos/linux"), Path("/home/johndoe/.eden/clients/linux"), ) checkout3.set_config( CheckoutConfig( backing_repo=Path("/home/johndoe/eden-repos/linux"), scm_type="git", mount_protocol="fuse", default_revision=DEFAULT_REVISION["git"], redirections={}, active_prefetch_profiles=[], predictive_prefetch_profiles_active=False, predictive_prefetch_num_dirs=0, ) ) checkout4 = EdenCheckout( instance, Path("/data/users/johndoe/other_repos/linux"), Path("/home/johndoe/.eden/clients/linux2"), ) checkout4.set_config( CheckoutConfig( backing_repo=Path("/home/johndoe/eden-repos/linux"), scm_type="git", mount_protocol="fuse", default_revision=DEFAULT_REVISION["git"], redirections={}, active_prefetch_profiles=[], predictive_prefetch_profiles_active=False, predictive_prefetch_num_dirs=0, ) ) checkout5 = EdenCheckout( instance, Path("/data/users/johndoe/www"), Path("/home/johndoe/.eden/clients/www"), ) checkout5.set_config( CheckoutConfig( backing_repo=Path("/home/johndoe/eden-repos/www"), scm_type="hg", mount_protocol="fuse", default_revision=DEFAULT_REVISION["hg"], redirections={}, active_prefetch_profiles=[], predictive_prefetch_profiles_active=False, predictive_prefetch_num_dirs=0, ) ) config_checkouts = [ checkout1, checkout2, checkout3, checkout4, checkout5, ] mounts = EdenInstance._combine_mount_info(thrift_mounts, config_checkouts) normal_out = TestOutput() main_mod.ListCmd.print_mounts(normal_out, mounts) self.assertEqual( """\ /data/users/johndoe/apache (unconfigured) /data/users/johndoe/configs (INITIALIZING) (unconfigured) /data/users/johndoe/git (SHUTTING_DOWN) /data/users/johndoe/mercurial /data/users/johndoe/other_repos/linux /data/users/johndoe/repos/linux /data/users/johndoe/www (not mounted) """, normal_out.getvalue(), ) json_out = TestOutput() main_mod.ListCmd.print_mounts_json(json_out, mounts) self.assertEqual( """\ { "/data/users/johndoe/apache": { "backing_repo": null, "configured": false, "data_dir": "/home/johndoe/.eden/clients/apache", "state": "RUNNING" }, "/data/users/johndoe/configs": { "backing_repo": null, "configured": false, "data_dir": "/home/johndoe/.eden/clients/configs", "state": "INITIALIZING" }, "/data/users/johndoe/git": { "backing_repo": "/home/johndoe/eden-repos/git", "configured": true, "data_dir": "/home/johndoe/.eden/clients/git", "state": "SHUTTING_DOWN" }, "/data/users/johndoe/mercurial": { "backing_repo": "/home/johndoe/eden-repos/mercurial", "configured": true, "data_dir": "/home/johndoe/.eden/clients/mercurial", "state": "RUNNING" }, "/data/users/johndoe/other_repos/linux": { "backing_repo": "/home/johndoe/eden-repos/linux", "configured": true, "data_dir": "/home/johndoe/.eden/clients/linux2", "state": "RUNNING" }, "/data/users/johndoe/repos/linux": { "backing_repo": "/home/johndoe/eden-repos/linux", "configured": true, "data_dir": "/home/johndoe/.eden/clients/linux", "state": "RUNNING" }, "/data/users/johndoe/www": { "backing_repo": "/home/johndoe/eden-repos/www", "configured": true, "data_dir": "/home/johndoe/.eden/clients/www", "state": "NOT_RUNNING" } } """, json_out.getvalue(), )
def test_list_mounts_no_backing_repos(self) -> None: self.maxDiff = None thrift_mounts = [ MountInfo( mountPoint=b"/data/users/johndoe/mercurial", edenClientPath=b"/home/johndoe/.eden/clients/mercurial", state=MountState.RUNNING, backingRepoPath=b"/home/johndoe/eden-repos/mercurial", ), MountInfo( mountPoint=b"/data/users/johndoe/git", edenClientPath=b"/home/johndoe/.eden/clients/git", state=MountState.SHUTTING_DOWN, backingRepoPath=None, ), MountInfo( mountPoint=b"/data/users/johndoe/apache", edenClientPath=b"/home/johndoe/.eden/clients/apache", state=MountState.RUNNING, backingRepoPath=b"/home/johndoe/eden-repos/apache", ), MountInfo( mountPoint=b"/data/users/johndoe/configs", edenClientPath=b"/home/johndoe/.eden/clients/configs", state=MountState.INITIALIZING, ), ] instance = EdenInstance( config_dir="/home/johndoe/.eden", etc_eden_dir="/etc/eden", home_dir="/home/johndoe", ) checkout1 = EdenCheckout( instance, Path("/data/users/johndoe/mercurial"), Path("/home/johndoe/.eden/clients/mercurial"), ) checkout1.set_config( CheckoutConfig( # note the backing repo is never expected to be different in the # daemon and client, but for the sake of testing that the # backing repo will be taken from the daemon we make them # different backing_repo=Path("/home/johndoe/eden-repos/mercurial1"), scm_type="hg", guid="123", mount_protocol="fuse", case_sensitive=False, require_utf8_path=True, default_revision=DEFAULT_REVISION["hg"], redirections={}, active_prefetch_profiles=[], predictive_prefetch_profiles_active=False, predictive_prefetch_num_dirs=0, enable_tree_overlay=False, ) ) checkout2 = EdenCheckout( instance, Path("/data/users/johndoe/git"), Path("/home/johndoe/.eden/clients/git"), ) checkout2.set_config( CheckoutConfig( backing_repo=Path("/home/johndoe/eden-repos/git"), scm_type="git", guid="456", mount_protocol="fuse", case_sensitive=False, require_utf8_path=True, default_revision=DEFAULT_REVISION["git"], redirections={}, active_prefetch_profiles=[], predictive_prefetch_profiles_active=False, predictive_prefetch_num_dirs=0, enable_tree_overlay=False, ) ) config_checkouts = [ checkout1, checkout2, ] mounts = EdenInstance._combine_mount_info(thrift_mounts, config_checkouts) normal_out = TestOutput() main_mod.ListCmd.print_mounts(normal_out, mounts) self.assertEqual( """\ /data/users/johndoe/apache (unconfigured) /data/users/johndoe/configs (INITIALIZING) (unconfigured) /data/users/johndoe/git (SHUTTING_DOWN) /data/users/johndoe/mercurial """, normal_out.getvalue(), ) json_out = TestOutput() main_mod.ListCmd.print_mounts_json(json_out, mounts) self.assertEqual( """\ { "/data/users/johndoe/apache": { "backing_repo": "/home/johndoe/eden-repos/apache", "configured": false, "data_dir": "/home/johndoe/.eden/clients/apache", "state": "RUNNING" }, "/data/users/johndoe/configs": { "backing_repo": null, "configured": false, "data_dir": "/home/johndoe/.eden/clients/configs", "state": "INITIALIZING" }, "/data/users/johndoe/git": { "backing_repo": "/home/johndoe/eden-repos/git", "configured": true, "data_dir": "/home/johndoe/.eden/clients/git", "state": "SHUTTING_DOWN" }, "/data/users/johndoe/mercurial": { "backing_repo": "/home/johndoe/eden-repos/mercurial", "configured": true, "data_dir": "/home/johndoe/.eden/clients/mercurial", "state": "RUNNING" } } """, json_out.getvalue(), )
def test_list_mounts_old_thrift(self): self.maxDiff = None # Simulate an older edenfs daemon that does not send the "state" field thrift_mounts = [ MountInfo( mountPoint=b"/data/users/johndoe/mercurial", edenClientPath=b"/home/johndoe/.eden/clients/mercurial", ), MountInfo( mountPoint=b"/data/users/johndoe/git", edenClientPath=b"/home/johndoe/.eden/clients/git", ), MountInfo( mountPoint=b"/data/users/johndoe/configs", edenClientPath=b"/home/johndoe/.eden/clients/configs", ), ] instance = EdenInstance( config_dir="/home/johndoe/.eden", etc_eden_dir="/etc/eden", home_dir="/home/johndoe", ) config_checkouts = [ EdenCheckout( instance, Path("/data/users/johndoe/mercurial"), Path("/home/johndoe/.eden/clients/mercurial"), ), EdenCheckout( instance, Path("/data/users/johndoe/git"), Path("/home/johndoe/.eden/clients/git"), ), EdenCheckout( instance, Path("/data/users/johndoe/www"), Path("/home/johndoe/.eden/clients/www"), ), ] mounts = main_mod.ListCmd.combine_mount_info(thrift_mounts, config_checkouts) normal_out = TestOutput() main_mod.ListCmd.print_mounts(normal_out, mounts) self.assertEqual( """\ /data/users/johndoe/configs (unconfigured) /data/users/johndoe/git /data/users/johndoe/mercurial /data/users/johndoe/www (not mounted) """, normal_out.getvalue(), ) json_out = TestOutput() main_mod.ListCmd.print_mounts_json(json_out, mounts) self.assertEqual( """\ { "/data/users/johndoe/configs": { "configured": false, "data_dir": "/home/johndoe/.eden/clients/configs", "state": "RUNNING" }, "/data/users/johndoe/git": { "configured": true, "data_dir": "/home/johndoe/.eden/clients/git", "state": "RUNNING" }, "/data/users/johndoe/mercurial": { "configured": true, "data_dir": "/home/johndoe/.eden/clients/mercurial", "state": "RUNNING" }, "/data/users/johndoe/www": { "configured": true, "data_dir": "/home/johndoe/.eden/clients/www", "state": "NOT_RUNNING" } } """, json_out.getvalue(), )