mirror of
https://github.com/facebook/sapling.git
synced 2024-10-04 13:57:13 +03:00
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
This commit is contained in:
parent
8a958b660b
commit
d26a8f9f46
@ -1326,7 +1326,7 @@ class MinitopCmd(Subcmd):
|
||||
class PrefetchProfileCmd(Subcmd):
|
||||
def run(self, args: argparse.Namespace) -> int:
|
||||
print_stderr("This is not implemented for python edenfsctl.")
|
||||
return 1
|
||||
return EX_USAGE
|
||||
|
||||
|
||||
@subcmd("fsck", "Perform a filesystem check for EdenFS")
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
# pyre-unsafe
|
||||
|
||||
import subprocess
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
@ -164,3 +165,50 @@ reload-interval = "{reload_interval}"
|
||||
write_user_config("bogus value")
|
||||
time.sleep(0.200)
|
||||
assert_current_interval(default_interval)
|
||||
|
||||
|
||||
@testcase.eden_repo_test
|
||||
class RustRolloutConfigTest(testcase.EdenRepoTest):
|
||||
def populate_repo(self) -> None:
|
||||
self.repo.write_file("hello", "hola\n")
|
||||
self.repo.commit("Initial commit.")
|
||||
|
||||
def test_fallback_to_rust(self) -> None:
|
||||
# Testing the case where we fallback to Rust because a command marked
|
||||
# as "experimental" doesn't actually exist in Python.
|
||||
self.set_rust_rollout_config({"prefetch-profile": False})
|
||||
res = self.eden.run_cmd(
|
||||
"prefetch-profile", "list", "--checkout", f"{self.mount}"
|
||||
)
|
||||
self.assertIn("No active prefetch profiles.", res)
|
||||
|
||||
# If EDENFSCTL_SKIP_RUST is set, we shouldn't try to fallback to Rust
|
||||
with self.assertRaises(subprocess.CalledProcessError):
|
||||
self.eden.run_cmd(
|
||||
"prefetch-profile",
|
||||
"list",
|
||||
"--checkout",
|
||||
f"{self.mount}",
|
||||
env={"EDENFSCTL_SKIP_RUST": "1"},
|
||||
)
|
||||
|
||||
# If EDENFSCTL_ONLY_RUST is set, ignore the rollout config
|
||||
res = self.eden.run_cmd(
|
||||
"prefetch-profile",
|
||||
"list",
|
||||
"--checkout",
|
||||
f"{self.mount}",
|
||||
env={"EDENFSCTL_ONLY_RUST": "1"},
|
||||
)
|
||||
self.assertIn("No active prefetch profiles.", res)
|
||||
|
||||
# If EDENFSCTL_SKIP_RUST is set, ignore the rollout config
|
||||
self.set_rust_rollout_config({"prefetch-profile": True})
|
||||
with self.assertRaises(subprocess.CalledProcessError):
|
||||
self.eden.run_cmd(
|
||||
"prefetch-profile",
|
||||
"list",
|
||||
"--checkout",
|
||||
f"{self.mount}",
|
||||
env={"EDENFSCTL_SKIP_RUST": "1"},
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user