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:
Xavier Deguillard 2020-03-30 08:38:43 -07:00 committed by Facebook GitHub Bot
parent 11af551491
commit fd72344578
4 changed files with 135 additions and 113 deletions

View File

@ -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

View File

@ -5,7 +5,8 @@ authors = ["Facebook Source Control Team <sourcecontrol-dev@fb.com>"]
edition = "2018"
[features]
default = []
default = ["fb"]
fb = []
for-tests = []
[dependencies]

View File

@ -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,6 +763,14 @@ mod tests {
Ok(())
}
#[cfg(feature = "fb")]
mod fb_tests {
use super::*;
use std::str::FromStr;
use types::Sha256;
#[test]
fn test_lfs_remote() -> Result<()> {
let cachedir = TempDir::new()?;
@ -770,8 +778,9 @@ mod tests {
let config = make_lfs_config(&cachedir);
let k = key("a", "1");
let sha256 =
Sha256::from_str("fc613b4dfd6736a7bd268c8a0e74ed0d1c04a959f59dd74ef2874983fd443fc9")?;
let sha256 = Sha256::from_str(
"fc613b4dfd6736a7bd268c8a0e74ed0d1c04a959f59dd74ef2874983fd443fc9",
)?;
let size = 6;
let pointer = format!(
@ -798,6 +807,7 @@ mod tests {
Ok(())
}
}
#[cfg(fbcode_build)]
mod fbcode_tests {

View File

@ -1251,6 +1251,10 @@ mod tests {
Ok(())
}
#[cfg(feature = "fb")]
mod fb_test {
use super::*;
#[test]
fn test_lfs_non_present() -> Result<()> {
let cachedir = TempDir::new()?;
@ -1261,7 +1265,9 @@ mod tests {
let remote = LfsRemote::new(lfs, &config)?;
let blob = (
Sha256::from_str("0000000000000000000000000000000000000000000000000000000000000000")?,
Sha256::from_str(
"0000000000000000000000000000000000000000000000000000000000000000",
)?,
1,
Bytes::from(&b"nothing"[..]),
);
@ -1283,12 +1289,16 @@ mod tests {
let remote = LfsRemote::new(lfs, &config)?;
let blob1 = (
Sha256::from_str("fc613b4dfd6736a7bd268c8a0e74ed0d1c04a959f59dd74ef2874983fd443fc9")?,
Sha256::from_str(
"fc613b4dfd6736a7bd268c8a0e74ed0d1c04a959f59dd74ef2874983fd443fc9",
)?,
6,
Bytes::from(&b"master"[..]),
);
let blob2 = (
Sha256::from_str("ca3e228a1d8d845064112c4e92781f6b8fc2501f0aa0e415d4a1dcc941485b24")?,
Sha256::from_str(
"ca3e228a1d8d845064112c4e92781f6b8fc2501f0aa0e415d4a1dcc941485b24",
)?,
6,
Bytes::from(&b"1.44.0"[..]),
);
@ -1302,45 +1312,6 @@ mod tests {
Ok(())
}
#[test]
fn test_lfs_remote_file() -> Result<()> {
let cachedir = TempDir::new()?;
let mut config = make_lfs_config(&cachedir);
let lfsdir = TempDir::new()?;
let lfs = Arc::new(LfsStore::shared(&lfsdir, &config)?);
let remote = TempDir::new()?;
let remote_lfs_file_store = LfsBlobsStore::shared(remote.path())?;
let blob1 = (
Sha256::from_str("fc613b4dfd6736a7bd268c8a0e74ed0d1c04a959f59dd74ef2874983fd443fc9")?,
6,
Bytes::from(&b"master"[..]),
);
let blob2 = (
Sha256::from_str("ca3e228a1d8d845064112c4e92781f6b8fc2501f0aa0e415d4a1dcc941485b24")?,
6,
Bytes::from(&b"1.44.0"[..]),
);
remote_lfs_file_store.add(&blob1.0, blob1.2.clone())?;
remote_lfs_file_store.add(&blob2.0, blob2.2.clone())?;
let url = Url::from_file_path(&remote).unwrap();
config.set("lfs", "url", Some(url.as_str()), &Default::default());
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());
Ok(())
}
#[test]
fn test_lfs_remote_datastore() -> Result<()> {
let cachedir = TempDir::new()?;
@ -1383,6 +1354,46 @@ mod tests {
Ok(())
}
}
#[test]
fn test_lfs_remote_file() -> Result<()> {
let cachedir = TempDir::new()?;
let mut config = make_lfs_config(&cachedir);
let lfsdir = TempDir::new()?;
let lfs = Arc::new(LfsStore::shared(&lfsdir, &config)?);
let remote = TempDir::new()?;
let remote_lfs_file_store = LfsBlobsStore::shared(remote.path())?;
let blob1 = (
Sha256::from_str("fc613b4dfd6736a7bd268c8a0e74ed0d1c04a959f59dd74ef2874983fd443fc9")?,
6,
Bytes::from(&b"master"[..]),
);
let blob2 = (
Sha256::from_str("ca3e228a1d8d845064112c4e92781f6b8fc2501f0aa0e415d4a1dcc941485b24")?,
6,
Bytes::from(&b"1.44.0"[..]),
);
remote_lfs_file_store.add(&blob1.0, blob1.2.clone())?;
remote_lfs_file_store.add(&blob2.0, blob2.2.clone())?;
let url = Url::from_file_path(&remote).unwrap();
config.set("lfs", "url", Some(url.as_str()), &Default::default());
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());
Ok(())
}
#[test]
fn test_blob() -> Result<()> {