mirror of
https://github.com/facebook/sapling.git
synced 2024-12-25 05:53:24 +03:00
revisionstore: feature gate the Mononoke LFS tests
Summary: Due to the Mononoke LFS server only being available on FB's network, the tests using them cannot run outside of FB, including in the github workflows. Reviewed By: quark-zju Differential Revision: D20698062 fbshipit-source-id: f780c35665cf8dc314d1f20a637ed615705fd6cf
This commit is contained in:
parent
11af551491
commit
fd72344578
2
.github/workflows/edenscm-libs.yml
vendored
2
.github/workflows/edenscm-libs.yml
vendored
@ -82,7 +82,7 @@ jobs:
|
||||
- name: Run renderdag tests
|
||||
run: cargo test --verbose --target-dir target --manifest-path eden/scm/lib/renderdag/Cargo.toml
|
||||
- name: Run revisionstore tests
|
||||
run: cargo test --verbose --target-dir target --manifest-path eden/scm/lib/revisionstore/Cargo.toml
|
||||
run: cargo test --verbose --target-dir target --no-default-features --manifest-path eden/scm/lib/revisionstore/Cargo.toml
|
||||
- name: Run stackdesc tests
|
||||
run: cargo test --verbose --target-dir target --manifest-path eden/scm/lib/stackdesc/Cargo.toml
|
||||
# fbthrift is not published
|
||||
|
@ -5,7 +5,8 @@ authors = ["Facebook Source Control Team <sourcecontrol-dev@fb.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
default = ["fb"]
|
||||
fb = []
|
||||
for-tests = []
|
||||
|
||||
[dependencies]
|
||||
|
@ -401,12 +401,12 @@ impl<'a> ContentStoreBuilder<'a> {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
use std::{collections::HashMap, str::FromStr};
|
||||
use std::collections::HashMap;
|
||||
|
||||
use bytes::Bytes;
|
||||
use tempfile::TempDir;
|
||||
|
||||
use types::{testutil::*, Sha256};
|
||||
use types::testutil::*;
|
||||
use util::path::create_dir;
|
||||
|
||||
use crate::{
|
||||
@ -763,40 +763,50 @@ mod tests {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_lfs_remote() -> Result<()> {
|
||||
let cachedir = TempDir::new()?;
|
||||
let localdir = TempDir::new()?;
|
||||
let config = make_lfs_config(&cachedir);
|
||||
#[cfg(feature = "fb")]
|
||||
mod fb_tests {
|
||||
use super::*;
|
||||
|
||||
let k = key("a", "1");
|
||||
let sha256 =
|
||||
Sha256::from_str("fc613b4dfd6736a7bd268c8a0e74ed0d1c04a959f59dd74ef2874983fd443fc9")?;
|
||||
let size = 6;
|
||||
use std::str::FromStr;
|
||||
|
||||
let pointer = format!(
|
||||
"version https://git-lfs.github.com/spec/v1\noid sha256:{}\nsize {}\nx-is-binary 0\n",
|
||||
sha256.to_hex(),
|
||||
size
|
||||
);
|
||||
use types::Sha256;
|
||||
|
||||
let data = Bytes::from(pointer);
|
||||
#[test]
|
||||
fn test_lfs_remote() -> Result<()> {
|
||||
let cachedir = TempDir::new()?;
|
||||
let localdir = TempDir::new()?;
|
||||
let config = make_lfs_config(&cachedir);
|
||||
|
||||
let mut map = HashMap::new();
|
||||
map.insert(k.clone(), (data, Some(0x2000)));
|
||||
let mut remotestore = FakeHgIdRemoteStore::new();
|
||||
remotestore.data(map);
|
||||
let k = key("a", "1");
|
||||
let sha256 = Sha256::from_str(
|
||||
"fc613b4dfd6736a7bd268c8a0e74ed0d1c04a959f59dd74ef2874983fd443fc9",
|
||||
)?;
|
||||
let size = 6;
|
||||
|
||||
let store = ContentStoreBuilder::new(&config)
|
||||
.local_path(&localdir)
|
||||
.remotestore(Box::new(remotestore))
|
||||
.build()?;
|
||||
let pointer = format!(
|
||||
"version https://git-lfs.github.com/spec/v1\noid sha256:{}\nsize {}\nx-is-binary 0\n",
|
||||
sha256.to_hex(),
|
||||
size
|
||||
);
|
||||
|
||||
let data = store.get(&k)?.map(|vec| Bytes::from(vec));
|
||||
let data = Bytes::from(pointer);
|
||||
|
||||
assert_eq!(data, Some(Bytes::from(&b"master"[..])));
|
||||
let mut map = HashMap::new();
|
||||
map.insert(k.clone(), (data, Some(0x2000)));
|
||||
let mut remotestore = FakeHgIdRemoteStore::new();
|
||||
remotestore.data(map);
|
||||
|
||||
Ok(())
|
||||
let store = ContentStoreBuilder::new(&config)
|
||||
.local_path(&localdir)
|
||||
.remotestore(Box::new(remotestore))
|
||||
.build()?;
|
||||
|
||||
let data = store.get(&k)?.map(|vec| Bytes::from(vec));
|
||||
|
||||
assert_eq!(data, Some(Bytes::from(&b"master"[..])));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(fbcode_build)]
|
||||
|
@ -1251,55 +1251,109 @@ mod tests {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_lfs_non_present() -> Result<()> {
|
||||
let cachedir = TempDir::new()?;
|
||||
let lfsdir = TempDir::new()?;
|
||||
let config = make_lfs_config(&cachedir);
|
||||
#[cfg(feature = "fb")]
|
||||
mod fb_test {
|
||||
use super::*;
|
||||
|
||||
let lfs = Arc::new(LfsStore::shared(&lfsdir, &config)?);
|
||||
let remote = LfsRemote::new(lfs, &config)?;
|
||||
#[test]
|
||||
fn test_lfs_non_present() -> Result<()> {
|
||||
let cachedir = TempDir::new()?;
|
||||
let lfsdir = TempDir::new()?;
|
||||
let config = make_lfs_config(&cachedir);
|
||||
|
||||
let blob = (
|
||||
Sha256::from_str("0000000000000000000000000000000000000000000000000000000000000000")?,
|
||||
1,
|
||||
Bytes::from(&b"nothing"[..]),
|
||||
);
|
||||
let lfs = Arc::new(LfsStore::shared(&lfsdir, &config)?);
|
||||
let remote = LfsRemote::new(lfs, &config)?;
|
||||
|
||||
let resp = remote.batch(&[(blob.0, blob.1)]);
|
||||
let err = resp.err().unwrap();
|
||||
assert_eq!(err.to_string(), "Couldn't fetch oid 0000000000000000000000000000000000000000000000000000000000000000: ObjectError { code: 404, message: \"Object does not exist\" }");
|
||||
let blob = (
|
||||
Sha256::from_str(
|
||||
"0000000000000000000000000000000000000000000000000000000000000000",
|
||||
)?,
|
||||
1,
|
||||
Bytes::from(&b"nothing"[..]),
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
let resp = remote.batch(&[(blob.0, blob.1)]);
|
||||
let err = resp.err().unwrap();
|
||||
assert_eq!(err.to_string(), "Couldn't fetch oid 0000000000000000000000000000000000000000000000000000000000000000: ObjectError { code: 404, message: \"Object does not exist\" }");
|
||||
|
||||
#[test]
|
||||
fn test_lfs_remote() -> Result<()> {
|
||||
let cachedir = TempDir::new()?;
|
||||
let lfsdir = TempDir::new()?;
|
||||
let config = make_lfs_config(&cachedir);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
let lfs = Arc::new(LfsStore::shared(&lfsdir, &config)?);
|
||||
let remote = LfsRemote::new(lfs, &config)?;
|
||||
#[test]
|
||||
fn test_lfs_remote() -> Result<()> {
|
||||
let cachedir = TempDir::new()?;
|
||||
let lfsdir = TempDir::new()?;
|
||||
let config = make_lfs_config(&cachedir);
|
||||
|
||||
let blob1 = (
|
||||
Sha256::from_str("fc613b4dfd6736a7bd268c8a0e74ed0d1c04a959f59dd74ef2874983fd443fc9")?,
|
||||
6,
|
||||
Bytes::from(&b"master"[..]),
|
||||
);
|
||||
let blob2 = (
|
||||
Sha256::from_str("ca3e228a1d8d845064112c4e92781f6b8fc2501f0aa0e415d4a1dcc941485b24")?,
|
||||
6,
|
||||
Bytes::from(&b"1.44.0"[..]),
|
||||
);
|
||||
let lfs = Arc::new(LfsStore::shared(&lfsdir, &config)?);
|
||||
let remote = LfsRemote::new(lfs, &config)?;
|
||||
|
||||
let resp = remote
|
||||
.batch(&[(blob1.0, blob1.1), (blob2.0, blob2.1)])?
|
||||
.collect::<Result<Vec<_>>>()?
|
||||
.sort();
|
||||
assert_eq!(resp, vec![(blob1.0, blob1.2), (blob2.0, blob2.2)].sort());
|
||||
let blob1 = (
|
||||
Sha256::from_str(
|
||||
"fc613b4dfd6736a7bd268c8a0e74ed0d1c04a959f59dd74ef2874983fd443fc9",
|
||||
)?,
|
||||
6,
|
||||
Bytes::from(&b"master"[..]),
|
||||
);
|
||||
let blob2 = (
|
||||
Sha256::from_str(
|
||||
"ca3e228a1d8d845064112c4e92781f6b8fc2501f0aa0e415d4a1dcc941485b24",
|
||||
)?,
|
||||
6,
|
||||
Bytes::from(&b"1.44.0"[..]),
|
||||
);
|
||||
|
||||
Ok(())
|
||||
let resp = remote
|
||||
.batch(&[(blob1.0, blob1.1), (blob2.0, blob2.1)])?
|
||||
.collect::<Result<Vec<_>>>()?
|
||||
.sort();
|
||||
assert_eq!(resp, vec![(blob1.0, blob1.2), (blob2.0, blob2.2)].sort());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_lfs_remote_datastore() -> Result<()> {
|
||||
let cachedir = TempDir::new()?;
|
||||
let lfsdir = TempDir::new()?;
|
||||
let config = make_lfs_config(&cachedir);
|
||||
|
||||
let lfs = Arc::new(LfsStore::shared(&lfsdir, &config)?);
|
||||
let remote = LfsRemote::new(lfs.clone(), &config)?;
|
||||
|
||||
let key = key("a/b", "1234");
|
||||
|
||||
let mut content_hashes = HashMap::new();
|
||||
content_hashes.insert(
|
||||
ContentHashType::Sha256,
|
||||
ContentHash::Sha256(Sha256::from_str(
|
||||
"ca3e228a1d8d845064112c4e92781f6b8fc2501f0aa0e415d4a1dcc941485b24",
|
||||
)?),
|
||||
);
|
||||
|
||||
let pointer = LfsPointersEntry {
|
||||
hgid: key.hgid.clone(),
|
||||
size: 6,
|
||||
is_binary: false,
|
||||
copy_from: None,
|
||||
content_hashes,
|
||||
};
|
||||
|
||||
// Populate the pointer store. Usually, this would be done via a previous remotestore call.
|
||||
lfs.pointers.write().add(pointer)?;
|
||||
|
||||
let remotedatastore = remote.datastore(lfs.clone());
|
||||
|
||||
let expected_delta = Delta {
|
||||
data: Bytes::from(&b"1.44.0"[..]),
|
||||
base: None,
|
||||
key: key.clone(),
|
||||
};
|
||||
|
||||
assert_eq!(remotedatastore.get_delta(&key)?, Some(expected_delta));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1341,49 +1395,6 @@ mod tests {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_lfs_remote_datastore() -> Result<()> {
|
||||
let cachedir = TempDir::new()?;
|
||||
let lfsdir = TempDir::new()?;
|
||||
let config = make_lfs_config(&cachedir);
|
||||
|
||||
let lfs = Arc::new(LfsStore::shared(&lfsdir, &config)?);
|
||||
let remote = LfsRemote::new(lfs.clone(), &config)?;
|
||||
|
||||
let key = key("a/b", "1234");
|
||||
|
||||
let mut content_hashes = HashMap::new();
|
||||
content_hashes.insert(
|
||||
ContentHashType::Sha256,
|
||||
ContentHash::Sha256(Sha256::from_str(
|
||||
"ca3e228a1d8d845064112c4e92781f6b8fc2501f0aa0e415d4a1dcc941485b24",
|
||||
)?),
|
||||
);
|
||||
|
||||
let pointer = LfsPointersEntry {
|
||||
hgid: key.hgid.clone(),
|
||||
size: 6,
|
||||
is_binary: false,
|
||||
copy_from: None,
|
||||
content_hashes,
|
||||
};
|
||||
|
||||
// Populate the pointer store. Usually, this would be done via a previous remotestore call.
|
||||
lfs.pointers.write().add(pointer)?;
|
||||
|
||||
let remotedatastore = remote.datastore(lfs.clone());
|
||||
|
||||
let expected_delta = Delta {
|
||||
data: Bytes::from(&b"1.44.0"[..]),
|
||||
base: None,
|
||||
key: key.clone(),
|
||||
};
|
||||
|
||||
assert_eq!(remotedatastore.get_delta(&key)?, Some(expected_delta));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_blob() -> Result<()> {
|
||||
let dir = TempDir::new()?;
|
||||
|
Loading…
Reference in New Issue
Block a user