Skip to content

Commit 940574c

Browse files
muirdmfacebook-github-bot
authored andcommitted
scmstore: add test for aux data prefetching on CAS
Summary: Add a failing test showing the backingstore isn't getting file aux data when fetching trees on CAS. I tried to get a good test running a real eden, but I couldn't find a good way. Instead, I added a --store-model flag to the debugscmstore command which causes the scmstore query to use the storemodel trait entry point instead if the direct scmstore struct types. This way we can directly test what the backingstore gets from scmstore. Reviewed By: zzl0 Differential Revision: D71522122 fbshipit-source-id: a9af328b43400c8d5895341a08436960fa15e12f
1 parent 03c785c commit 940574c

4 files changed

Lines changed: 60 additions & 7 deletions

File tree

eden/scm/lib/commands/debugcommands/cmddebugscmstore/BUCK

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ rust_library(
2525
"//eden/scm/lib/metrics:metrics",
2626
"//eden/scm/lib/repo:repo",
2727
"//eden/scm/lib/revisionstore:revisionstore",
28+
"//eden/scm/lib/storemodel:storemodel",
2829
"//eden/scm/lib/types:types",
2930
],
3031
)

eden/scm/lib/commands/debugcommands/cmddebugscmstore/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ sapling-manifest = { version = "0.1.0", path = "../../../manifest" }
1717
sapling-metrics = { version = "0.1.0", path = "../../../metrics" }
1818
sapling-repo = { version = "0.1.0", path = "../../../repo" }
1919
sapling-revisionstore = { version = "0.1.0", path = "../../../revisionstore" }
20+
sapling-storemodel = { version = "0.1.0", path = "../../../storemodel" }
2021
sapling-types = { version = "0.1.0", path = "../../../types" }
2122
serde = { version = "1.0.185", features = ["derive", "rc"] }

eden/scm/lib/commands/debugcommands/cmddebugscmstore/src/lib.rs

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use revisionstore::scmstore::FileAttributes;
2929
use serde::de::value;
3030
use serde::de::value::StringDeserializer;
3131
use serde::de::Deserialize;
32+
use storemodel::TreeStore;
3233
use types::fetch_mode::FetchMode;
3334
use types::Key;
3435
use types::RepoPathBuf;
@@ -53,6 +54,9 @@ define_flags! {
5354
/// Request tree parents.
5455
tree_parents: bool,
5556

57+
/// Run in storemodel (using storemodel traits). This is what eden uses.
58+
store_model: bool,
59+
5660
/// Revision for positional file paths.
5761
#[short('r')]
5862
#[argtype("REV")]
@@ -138,6 +142,7 @@ pub fn run(ctx: ReqCtx<DebugScmStoreOpts>, repo: &Repo) -> Result<u8> {
138142
&fresh_repo,
139143
keys,
140144
fetch_mode,
145+
ctx.opts.store_model,
141146
ctx.opts.tree_parents,
142147
ctx.opts.aux_only,
143148
)?,
@@ -213,6 +218,7 @@ fn fetch_trees(
213218
repo: &Repo,
214219
keys: Vec<Key>,
215220
fetch_mode: FetchMode,
221+
store_model: bool,
216222
tree_parents: bool,
217223
aux_only: bool,
218224
) -> Result<()> {
@@ -230,14 +236,30 @@ fn fetch_trees(
230236
attrs |= TreeAttributes::PARENTS;
231237
}
232238

233-
let fetch_result = store.fetch_batch(keys.into_iter(), attrs, fetch_mode);
239+
if store_model {
240+
for tree in store.get_tree_iter(keys, fetch_mode)? {
241+
let (key, tree) = tree?;
234242

235-
let (found, missing, _errors) = fetch_result.consume();
236-
for complete in found.into_iter() {
237-
write!(stdout, "Successfully fetched tree: {:#?}\n", complete)?;
238-
}
239-
for incomplete in missing.into_iter() {
240-
write!(stdout, "Failed to fetch tree: {:#?}\n", incomplete)?;
243+
writeln!(stdout, "Tree '{}' entries", key.path)?;
244+
for entry in tree.iter()? {
245+
writeln!(stdout, " {:?}", entry?)?;
246+
}
247+
248+
writeln!(stdout, "Tree '{}' file aux", key.path)?;
249+
for entry in tree.file_aux_iter()? {
250+
writeln!(stdout, " {:?}", entry?)?;
251+
}
252+
}
253+
} else {
254+
let fetch_result = store.fetch_batch(keys.into_iter(), attrs, fetch_mode);
255+
256+
let (found, missing, _errors) = fetch_result.consume();
257+
for complete in found.into_iter() {
258+
write!(stdout, "Successfully fetched tree: {:#?}\n", complete)?;
259+
}
260+
for incomplete in missing.into_iter() {
261+
write!(stdout, "Failed to fetch tree: {:#?}\n", incomplete)?;
262+
}
241263
}
242264

243265
Ok(())
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
$ setconfig scmstore.cas-mode=on
3+
4+
$ setconfig push.edenapi=true
5+
$ setconfig scmstore.tree-metadata-mode=always
6+
7+
$ newserver server
8+
9+
$ newclientrepo client server
10+
$ drawdag <<EOS
11+
> A # A/dir/foo = foo
12+
> # A/dir/bar = bar
13+
> EOS
14+
$ hg push -qr $A --to main --create
15+
16+
Reset local repo stores
17+
$ newclientrepo client2 server
18+
$ hg pull -qr $A
19+
20+
First fetch aux data for root dir (needed to for subsequent fetch).
21+
$ hg debugscmstore --mode tree -r $A "" >/dev/null
22+
23+
--store-model uses the storemodel trait (which is what EdenFS uses)
24+
FIXME: missing aux data
25+
$ hg debugscmstore --mode tree -r $A "dir" --store-model
26+
Tree 'dir' entries
27+
(PathComponentBuf("bar"), HgId("a324b8bf63f7d56de9d36f8747e3b68a72a4d968"), File(Regular))
28+
(PathComponentBuf("foo"), HgId("49d8cbb15ce257920447006b46978b7af980a979"), File(Regular))
29+
Tree 'dir' file aux

0 commit comments

Comments
 (0)