Skip to content

Commit ebcb3ac

Browse files
committed
Test Mongo against an embedded MongoDB instance, not external
1 parent 29919f9 commit ebcb3ac

15 files changed

Lines changed: 800 additions & 193 deletions

File tree

.github/workflows/native-cargo.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
run: cargo build --all --profile=smol
5050

5151
- name: Test on ${{ runner.os }}
52-
run: cargo test --all --profile=smol
52+
run: cargo test --all --profile=smol -- --nocapture
5353

5454
- name: Check schema export
5555
run: cargo run --bin build-schema --features dev-schema --package nativelink-config

Cargo.lock

Lines changed: 82 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nativelink-error/BUILD.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ rust_library(
1515
deps = [
1616
"//nativelink-metric",
1717
"//nativelink-proto",
18+
"@crates//:mongodb",
1819
"@crates//:prost",
1920
"@crates//:prost-types",
2021
"@crates//:redis",
22+
"@crates//:reqwest",
2123
"@crates//:rustls-pki-types",
2224
"@crates//:serde",
2325
"@crates//:serde_json5",
@@ -26,6 +28,7 @@ rust_library(
2628
"@crates//:url",
2729
"@crates//:uuid",
2830
"@crates//:walkdir",
31+
"@crates//:zip",
2932
],
3033
)
3134

nativelink-error/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@ version = "1.0.0-rc4"
1414
nativelink-metric = { path = "../nativelink-metric" }
1515
nativelink-proto = { path = "../nativelink-proto" }
1616

17+
mongodb = { version = "3", features = [
18+
"compat-3-0-0",
19+
"rustls-tls",
20+
], default-features = false }
1721
prost = { version = "0.13.5", default-features = false }
1822
prost-types = { version = "0.13.5", default-features = false }
1923
redis = { version = "1.0.0", default-features = false }
24+
reqwest = { version = "0.12", default-features = false }
2025
rustls-pki-types = { version = "1.13.1", default-features = false }
2126
serde = { version = "1.0.219", default-features = false }
2227
serde_json5 = { version = "0.2.1", default-features = false }
@@ -33,3 +38,4 @@ tonic = { version = "0.13.0", features = [
3338
url = { version = "2.5.7", default-features = false }
3439
uuid = { version = "1.16.0", default-features = false }
3540
walkdir = { version = "2.5.0", default-features = false }
41+
zip = { version = "7.2.0", default-features = false }

nativelink-error/src/lib.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,24 @@ impl From<url::ParseError> for Error {
324324
}
325325
}
326326

327+
impl From<mongodb::error::Error> for Error {
328+
fn from(value: mongodb::error::Error) -> Self {
329+
Self::new(Code::Internal, value.to_string())
330+
}
331+
}
332+
333+
impl From<reqwest::Error> for Error {
334+
fn from(value: reqwest::Error) -> Self {
335+
Self::new(Code::Internal, value.to_string())
336+
}
337+
}
338+
339+
impl From<zip::result::ZipError> for Error {
340+
fn from(value: zip::result::ZipError) -> Self {
341+
Self::new(Code::Internal, value.to_string())
342+
}
343+
}
344+
327345
pub trait ResultExt<T> {
328346
/// # Errors
329347
///

nativelink-store/BUILD.bazel

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ rust_test_suite(
130130
"tests/size_partitioning_store_test.rs",
131131
"tests/verify_store_test.rs",
132132
],
133+
compile_data = [
134+
"tests/mongo_runner/mod.rs",
135+
"tests/mongo_runner/process.rs",
136+
"tests/mongo_runner/extractor.rs",
137+
"tests/mongo_runner/downloader.rs",
138+
],
133139
proc_macro_deps = [
134140
"//nativelink-macro",
135141
"@crates//:async-trait",
@@ -149,6 +155,8 @@ rust_test_suite(
149155
"@crates//:aws-smithy-types",
150156
"@crates//:bincode",
151157
"@crates//:bytes",
158+
"@crates//:dirs",
159+
"@crates//:flate2",
152160
"@crates//:futures",
153161
"@crates//:hex",
154162
"@crates//:http",
@@ -162,16 +170,19 @@ rust_test_suite(
162170
"@crates//:rand",
163171
"@crates//:redis",
164172
"@crates//:redis-test",
173+
"@crates//:reqwest",
165174
"@crates//:serde_json",
166175
"@crates//:serial_test",
167176
"@crates//:sha2",
177+
"@crates//:tar",
168178
"@crates//:tempfile",
169179
"@crates//:tokio",
170180
"@crates//:tokio-stream",
171181
"@crates//:tonic",
172182
"@crates//:tracing",
173183
"@crates//:tracing-test",
174184
"@crates//:uuid",
185+
"@crates//:zip",
175186
],
176187
)
177188

nativelink-store/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ aws-smithy-runtime-api = { version = "1.7.4", default-features = false }
126126
aws-smithy-types = { version = "1.3.0", default-features = false, features = [
127127
"http-body-1-x",
128128
] }
129+
dirs = { version = "6.0.0", default-features = false }
130+
flate2 = { version = "1.1.9", default-features = false, features = ["zlib-rs"] }
129131
futures = { version = "0.3.31", default-features = false, features = [
130132
"executor",
131133
] }
@@ -141,10 +143,12 @@ rand = { version = "0.9.0", default-features = false, features = [
141143
] }
142144
redis-test = { version = "1.0.0", default-features = false, features = ["aio"] }
143145
serde_json = { version = "1.0.140", default-features = false }
146+
tar = { version = "0.4.44", default-features = false }
144147
tempfile = { version = "3.8.1", default-features = false }
145148
tracing-test = { version = "0.2.5", default-features = false, features = [
146149
"no-env-filter",
147150
] }
151+
zip = { version = "7.2.0", default-features = false }
148152

149153
[package.metadata.cargo-machete]
150154
# Used by nativelink_test macro
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Most of this is based off the defunct https://docs.rs/crate/mongo-embedded/1.0.0/source/ code and should be extracted out again as a separate crate at some point

0 commit comments

Comments
 (0)