Skip to content

Commit d26a8f9

Browse files
MichaelCuevasfacebook-github-bot
authored andcommitted
add tests for Rust rollout config
Summary: # Context Our last attempt at removing the Python version of `eden redirect` failed (see the SEV attached to D55426809). Our next attempt should be done in a phased manner to avoid similar breakages. # Solution We will slowly remove all possible fallbacks to Python so that we can be sure no commands are running the Python version of `eden redirect` prior to deleting the code. New rollout plan is as follows: 1) Remove the Chef recipe that writes `/etc/eden/edenfsctl_rollout.json` (Done) 2) Remove "redirect" from the default list of experimental commands in the Rust code. 3) Add a fallback to Rust if Python parsing fails for experimental commands 4) Add an EdenFS event that's logged every time we fallback to the Python `eden redirect` codepath 5) Monitor Scuba data to ensure the Python codepath isn't being hit 6) Delete Python `eden redirect` altogether # This diff Adds tests to verify that the new logic from #3 (and old existing logic for rollouts) works as expected. Reviewed By: kmancini Differential Revision: D56331275 fbshipit-source-id: 369242d1343b58d78d05dcd41847430ae7304569
1 parent 8a958b6 commit d26a8f9

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

eden/fs/cli/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,7 @@ def run(self, args: argparse.Namespace) -> int:
13261326
class PrefetchProfileCmd(Subcmd):
13271327
def run(self, args: argparse.Namespace) -> int:
13281328
print_stderr("This is not implemented for python edenfsctl.")
1329-
return 1
1329+
return EX_USAGE
13301330

13311331

13321332
@subcmd("fsck", "Perform a filesystem check for EdenFS")

eden/integration/config_test.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
# pyre-unsafe
88

9+
import subprocess
910
import time
1011
from pathlib import Path
1112

@@ -164,3 +165,50 @@ def assert_current_interval(expected: str) -> None:
164165
write_user_config("bogus value")
165166
time.sleep(0.200)
166167
assert_current_interval(default_interval)
168+
169+
170+
@testcase.eden_repo_test
171+
class RustRolloutConfigTest(testcase.EdenRepoTest):
172+
def populate_repo(self) -> None:
173+
self.repo.write_file("hello", "hola\n")
174+
self.repo.commit("Initial commit.")
175+
176+
def test_fallback_to_rust(self) -> None:
177+
# Testing the case where we fallback to Rust because a command marked
178+
# as "experimental" doesn't actually exist in Python.
179+
self.set_rust_rollout_config({"prefetch-profile": False})
180+
res = self.eden.run_cmd(
181+
"prefetch-profile", "list", "--checkout", f"{self.mount}"
182+
)
183+
self.assertIn("No active prefetch profiles.", res)
184+
185+
# If EDENFSCTL_SKIP_RUST is set, we shouldn't try to fallback to Rust
186+
with self.assertRaises(subprocess.CalledProcessError):
187+
self.eden.run_cmd(
188+
"prefetch-profile",
189+
"list",
190+
"--checkout",
191+
f"{self.mount}",
192+
env={"EDENFSCTL_SKIP_RUST": "1"},
193+
)
194+
195+
# If EDENFSCTL_ONLY_RUST is set, ignore the rollout config
196+
res = self.eden.run_cmd(
197+
"prefetch-profile",
198+
"list",
199+
"--checkout",
200+
f"{self.mount}",
201+
env={"EDENFSCTL_ONLY_RUST": "1"},
202+
)
203+
self.assertIn("No active prefetch profiles.", res)
204+
205+
# If EDENFSCTL_SKIP_RUST is set, ignore the rollout config
206+
self.set_rust_rollout_config({"prefetch-profile": True})
207+
with self.assertRaises(subprocess.CalledProcessError):
208+
self.eden.run_cmd(
209+
"prefetch-profile",
210+
"list",
211+
"--checkout",
212+
f"{self.mount}",
213+
env={"EDENFSCTL_SKIP_RUST": "1"},
214+
)

0 commit comments

Comments
 (0)