This is an automated email from the ASF dual-hosted git repository.
koushiro pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git
The following commit(s) were added to refs/heads/main by this push:
new e18961b32 refactor!: split opendal_core::raw::tests module into a
separate crate (#7025)
e18961b32 is described below
commit e18961b32219412b5b02340a350b5424e7b0c062
Author: Qinxuan Chen <[email protected]>
AuthorDate: Tue Dec 16 18:34:40 2025 +0800
refactor!: split opendal_core::raw::tests module into a separate crate
(#7025)
* refactor: split opendal_core::raw::tests module into a separate crate
* fix fmt
* fix license check
---
core/Cargo.lock | 15 +++++++-
core/Cargo.toml | 10 +++---
core/benches/ops/read.rs | 4 +--
core/benches/ops/utils.rs | 2 +-
core/benches/ops/write.rs | 4 +--
core/benches/vs_s3/src/main.rs | 2 +-
core/core/Cargo.toml | 20 -----------
core/core/src/raw/mod.rs | 2 --
.../src/main.rs | 2 +-
core/examples/basic/src/main.rs | 2 +-
core/examples/concurrent-upload/src/main.rs | 2 +-
core/examples/multipart-upload/src/main.rs | 2 +-
core/fuzz/fuzz_reader.rs | 8 ++---
core/fuzz/fuzz_writer.rs | 8 ++---
core/src/lib.rs | 3 ++
core/testkit/Cargo.toml | 41 ++++++++++++++++++++++
.../src/raw/tests/mod.rs => testkit/src/lib.rs} | 2 +-
core/{core/src/raw/tests => testkit/src}/read.rs | 3 +-
core/{core/src/raw/tests => testkit/src}/utils.rs | 4 ++-
core/{core/src/raw/tests => testkit/src}/write.rs | 0
core/tests/behavior/main.rs | 4 +--
core/tests/behavior/utils.rs | 2 +-
integrations/object_store/tests/behavior/main.rs | 2 +-
integrations/object_store/tests/behavior/utils.rs | 2 +-
24 files changed, 92 insertions(+), 54 deletions(-)
diff --git a/core/Cargo.lock b/core/Cargo.lock
index 6350dbe6e..2b33210c3 100644
--- a/core/Cargo.lock
+++ b/core/Cargo.lock
@@ -5577,6 +5577,7 @@ dependencies = [
"opendal-service-sqlite",
"opendal-service-tikv",
"opendal-service-vercel-blob",
+ "opendal-testkit",
"opentelemetry",
"opentelemetry-otlp",
"opentelemetry_sdk",
@@ -5630,7 +5631,6 @@ dependencies = [
"criterion",
"ctor",
"divan",
- "dotenvy",
"etcd-client",
"fastpool",
"flume",
@@ -6256,6 +6256,19 @@ dependencies = [
"tokio",
]
+[[package]]
+name = "opendal-testkit"
+version = "0.55.0"
+dependencies = [
+ "bytes",
+ "dotenvy",
+ "opendal-core",
+ "rand 0.8.5",
+ "sha2",
+ "tokio",
+ "uuid",
+]
+
[[package]]
name = "openssh"
version = "0.11.6"
diff --git a/core/Cargo.toml b/core/Cargo.toml
index 870af8ad1..23f4abb37 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -19,13 +19,14 @@
default-members = [".", "core"]
members = [
".",
+ "benches/vs_*",
"core",
+ "edge/*",
"examples/*",
"fuzz",
- "edge/*",
- "benches/vs_*",
- "services/*",
"layers/*",
+ "services/*",
+ "testkit",
]
[workspace.package]
@@ -163,7 +164,7 @@ services-vercel-blob = ["dep:opendal-service-vercel-blob"]
services-webdav = ["opendal-core/services-webdav"]
services-webhdfs = ["opendal-core/services-webhdfs"]
services-yandex-disk = ["opendal-core/services-yandex-disk"]
-tests = ["opendal-core/tests"]
+tests = ["opendal-testkit"]
[lib]
bench = false
@@ -228,6 +229,7 @@ opendal-service-sled = { path = "services/sled", version =
"0.55.0", optional =
opendal-service-sqlite = { path = "services/sqlite", version = "0.55.0",
optional = true, default-features = false }
opendal-service-tikv = { path = "services/tikv", version = "0.55.0", optional
= true, default-features = false }
opendal-service-vercel-blob = { path = "services/vercel-blob", version =
"0.55.0", optional = true, default-features = false }
+opendal-testkit = { path = "testkit", version = "0.55.0", optional = true }
[dev-dependencies]
anyhow = { version = "1.0.100", features = ["std"] }
diff --git a/core/benches/ops/read.rs b/core/benches/ops/read.rs
index ba9517fcd..f4cbfac7c 100644
--- a/core/benches/ops/read.rs
+++ b/core/benches/ops/read.rs
@@ -17,8 +17,8 @@
use divan::Bencher;
use divan::counter::BytesCount;
-use opendal::raw::tests::TEST_RUNTIME;
-use opendal::raw::tests::init_test_service;
+use opendal::tests::TEST_RUNTIME;
+use opendal::tests::init_test_service;
use rand::prelude::*;
use size::Size;
diff --git a/core/benches/ops/utils.rs b/core/benches/ops/utils.rs
index 39947835a..3b3adc1b3 100644
--- a/core/benches/ops/utils.rs
+++ b/core/benches/ops/utils.rs
@@ -16,7 +16,7 @@
// under the License.
use bytes::Bytes;
-use opendal::raw::tests::TEST_RUNTIME;
+use opendal::tests::TEST_RUNTIME;
use opendal::*;
use rand::prelude::*;
diff --git a/core/benches/ops/write.rs b/core/benches/ops/write.rs
index d1809cd74..a4a50f465 100644
--- a/core/benches/ops/write.rs
+++ b/core/benches/ops/write.rs
@@ -17,8 +17,8 @@
use divan::Bencher;
use divan::counter::BytesCount;
-use opendal::raw::tests::TEST_RUNTIME;
-use opendal::raw::tests::init_test_service;
+use opendal::tests::TEST_RUNTIME;
+use opendal::tests::init_test_service;
use rand::prelude::*;
use size::Size;
diff --git a/core/benches/vs_s3/src/main.rs b/core/benches/vs_s3/src/main.rs
index fe1e733f8..c279b81e0 100644
--- a/core/benches/vs_s3/src/main.rs
+++ b/core/benches/vs_s3/src/main.rs
@@ -22,8 +22,8 @@ use aws_config::Region;
use aws_credential_types::Credentials;
use criterion::Criterion;
use opendal::Operator;
-use opendal::raw::tests::TEST_RUNTIME;
use opendal::services;
+use opendal::tests::TEST_RUNTIME;
use rand::prelude::*;
use tokio::io::AsyncReadExt;
diff --git a/core/core/Cargo.toml b/core/core/Cargo.toml
index b6be8bb66..ce97a6d8b 100644
--- a/core/core/Cargo.toml
+++ b/core/core/Cargo.toml
@@ -45,21 +45,6 @@ reqwest-rustls-tls = ["reqwest/rustls-tls"]
# Enable opendal's blocking support.
blocking = ["internal-tokio-rt"]
-# Build test utils or not.
-#
-# These features are used to control whether to build opendal's test utils.
-# And doesn't have any other effects.
-#
-# You should never enable this feature unless you are developing opendal.
-tests = [
- "dep:rand",
- "dep:sha2",
- "dep:dotenvy",
- "services-http",
- "services-memory",
- "internal-tokio-rt",
-]
-
# Enable path cache.
# This is an internal feature, and should not be used by users.
internal-path-cache = ["dep:moka"]
@@ -152,10 +137,6 @@ tokio = { workspace = true, features = ["macros",
"io-util"] }
url = "2.5"
uuid = { workspace = true, features = ["serde", "v4"] }
-# Test only dependencies
-dotenvy = { version = "0.15", optional = true }
-rand = { workspace = true, optional = true }
-
# Optional dependencies
# Services
@@ -258,7 +239,6 @@ web-time = { version = "1.1.0" }
[dev-dependencies]
criterion = { version = "0.7", features = ["async", "async_tokio"] }
divan = { version = "0.1" }
-dotenvy = "0.15"
libtest-mimic = "0.8"
pretty_assertions = "1"
rand = { workspace = true }
diff --git a/core/core/src/raw/mod.rs b/core/core/src/raw/mod.rs
index f85f4bf86..11828804e 100644
--- a/core/core/src/raw/mod.rs
+++ b/core/core/src/raw/mod.rs
@@ -83,5 +83,3 @@ pub use atomic_util::*;
// Expose as a pub mod to avoid confusing.
pub mod oio;
-#[cfg(feature = "tests")]
-pub mod tests;
diff --git a/core/edge/s3_aws_assume_role_with_web_identity/src/main.rs
b/core/edge/s3_aws_assume_role_with_web_identity/src/main.rs
index 1b3774c29..0a0982583 100644
--- a/core/edge/s3_aws_assume_role_with_web_identity/src/main.rs
+++ b/core/edge/s3_aws_assume_role_with_web_identity/src/main.rs
@@ -16,7 +16,7 @@
// under the License.
use opendal::Result;
-use opendal::raw::tests::init_test_service;
+use opendal::tests::init_test_service;
#[tokio::main]
async fn main() -> Result<()> {
diff --git a/core/examples/basic/src/main.rs b/core/examples/basic/src/main.rs
index 32cf1e302..9ef69e097 100644
--- a/core/examples/basic/src/main.rs
+++ b/core/examples/basic/src/main.rs
@@ -43,7 +43,7 @@ async fn example(op: Operator) -> Result<()> {
#[tokio::main]
async fn main() -> Result<()> {
- use opendal::raw::tests::init_test_service;
+ use opendal::tests::init_test_service;
let op = init_test_service()?.expect("OPENDAL_TEST must be set");
println!("service {:?} has been initialized", op.info());
diff --git a/core/examples/concurrent-upload/src/main.rs
b/core/examples/concurrent-upload/src/main.rs
index 376fed05f..60f60b3ed 100644
--- a/core/examples/concurrent-upload/src/main.rs
+++ b/core/examples/concurrent-upload/src/main.rs
@@ -60,7 +60,7 @@ async fn example(op: Operator) -> Result<()> {
#[tokio::main]
async fn main() -> Result<()> {
- use opendal::raw::tests::init_test_service;
+ use opendal::tests::init_test_service;
let op = init_test_service()?.expect("OPENDAL_TEST must be set");
println!("service {:?} has been initialized", op.info());
diff --git a/core/examples/multipart-upload/src/main.rs
b/core/examples/multipart-upload/src/main.rs
index 0ec1d89a2..85dd819aa 100644
--- a/core/examples/multipart-upload/src/main.rs
+++ b/core/examples/multipart-upload/src/main.rs
@@ -48,7 +48,7 @@ async fn example(op: Operator) -> Result<()> {
#[tokio::main]
async fn main() -> Result<()> {
- use opendal::raw::tests::init_test_service;
+ use opendal::tests::init_test_service;
let op = init_test_service()?.expect("OPENDAL_TEST must be set");
println!("service {:?} has been initialized", op.info());
diff --git a/core/fuzz/fuzz_reader.rs b/core/fuzz/fuzz_reader.rs
index d7714f947..f5d9c116e 100644
--- a/core/fuzz/fuzz_reader.rs
+++ b/core/fuzz/fuzz_reader.rs
@@ -25,10 +25,10 @@ use libfuzzer_sys::arbitrary::Unstructured;
use libfuzzer_sys::fuzz_target;
use opendal::Operator;
use opendal::Result;
-use opendal::raw::tests::ReadAction;
-use opendal::raw::tests::ReadChecker;
-use opendal::raw::tests::TEST_RUNTIME;
-use opendal::raw::tests::init_test_service;
+use opendal::tests::ReadAction;
+use opendal::tests::ReadChecker;
+use opendal::tests::TEST_RUNTIME;
+use opendal::tests::init_test_service;
const MAX_DATA_SIZE: usize = 16 * 1024 * 1024;
diff --git a/core/fuzz/fuzz_writer.rs b/core/fuzz/fuzz_writer.rs
index aa3ed5815..266d1ec6b 100644
--- a/core/fuzz/fuzz_writer.rs
+++ b/core/fuzz/fuzz_writer.rs
@@ -22,10 +22,10 @@ use libfuzzer_sys::arbitrary::Unstructured;
use libfuzzer_sys::fuzz_target;
use opendal::Operator;
use opendal::Result;
-use opendal::raw::tests::TEST_RUNTIME;
-use opendal::raw::tests::WriteAction;
-use opendal::raw::tests::WriteChecker;
-use opendal::raw::tests::init_test_service;
+use opendal::tests::TEST_RUNTIME;
+use opendal::tests::WriteAction;
+use opendal::tests::WriteChecker;
+use opendal::tests::init_test_service;
const MAX_DATA_SIZE: usize = 16 * 1024 * 1024;
diff --git a/core/src/lib.rs b/core/src/lib.rs
index 2b9bf1a8c..7dd0006f5 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -24,6 +24,9 @@
pub use opendal_core::*;
+#[cfg(feature = "tests")]
+pub use opendal_testkit as tests;
+
/// Re-export of service implementations.
pub mod services {
pub use opendal_core::services::*;
diff --git a/core/testkit/Cargo.toml b/core/testkit/Cargo.toml
new file mode 100644
index 000000000..7f2e641cc
--- /dev/null
+++ b/core/testkit/Cargo.toml
@@ -0,0 +1,41 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+[package]
+description = "Test harness and utilities for Apache OpenDAL"
+name = "opendal-testkit"
+publish = false
+
+authors = { workspace = true }
+edition = { workspace = true }
+homepage = { workspace = true }
+license = { workspace = true }
+repository = { workspace = true }
+rust-version = { workspace = true }
+version = { workspace = true }
+
+[package.metadata.docs.rs]
+all-features = true
+
+[dependencies]
+bytes = { workspace = true }
+dotenvy = "0.15"
+opendal-core = { path = "../core", version = "0.55.0", default-features =
false }
+rand = { workspace = true }
+sha2 = { workspace = true }
+tokio = { workspace = true, features = ["rt-multi-thread"] }
+uuid = { workspace = true }
diff --git a/core/core/src/raw/tests/mod.rs b/core/testkit/src/lib.rs
similarity index 95%
rename from core/core/src/raw/tests/mod.rs
rename to core/testkit/src/lib.rs
index 9f59559ce..bb2295ec1 100644
--- a/core/core/src/raw/tests/mod.rs
+++ b/core/testkit/src/lib.rs
@@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.
-//! Utilities for opendal testing.
+//! Test harness and utilities for Apache OpenDAL.
mod read;
pub use read::ReadAction;
diff --git a/core/core/src/raw/tests/read.rs b/core/testkit/src/read.rs
similarity index 99%
rename from core/core/src/raw/tests/read.rs
rename to core/testkit/src/read.rs
index fbaf5e36a..44ea13609 100644
--- a/core/core/src/raw/tests/read.rs
+++ b/core/testkit/src/read.rs
@@ -16,13 +16,12 @@
// under the License.
use bytes::Bytes;
+use opendal_core::*;
use rand::RngCore;
use rand::thread_rng;
use sha2::Digest;
use sha2::Sha256;
-use crate::*;
-
/// ReadAction represents a read action.
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum ReadAction {
diff --git a/core/core/src/raw/tests/utils.rs b/core/testkit/src/utils.rs
similarity index 97%
rename from core/core/src/raw/tests/utils.rs
rename to core/testkit/src/utils.rs
index 81f75ac14..736a8597f 100644
--- a/core/core/src/raw/tests/utils.rs
+++ b/core/testkit/src/utils.rs
@@ -19,7 +19,9 @@ use std::collections::HashMap;
use std::env;
use std::sync::LazyLock;
-use crate::*;
+use opendal_core::Operator;
+use opendal_core::Result;
+use opendal_core::layers;
/// TEST_RUNTIME is the runtime used for running tests.
pub static TEST_RUNTIME: LazyLock<tokio::runtime::Runtime> = LazyLock::new(|| {
diff --git a/core/core/src/raw/tests/write.rs b/core/testkit/src/write.rs
similarity index 100%
rename from core/core/src/raw/tests/write.rs
rename to core/testkit/src/write.rs
diff --git a/core/tests/behavior/main.rs b/core/tests/behavior/main.rs
index a9ed00e0f..fd31fa2dc 100644
--- a/core/tests/behavior/main.rs
+++ b/core/tests/behavior/main.rs
@@ -34,8 +34,8 @@ mod async_write;
// External dependencies
use libtest_mimic::Arguments;
use libtest_mimic::Trial;
-use opendal::raw::tests::TEST_RUNTIME;
-use opendal::raw::tests::init_test_service;
+use opendal::tests::TEST_RUNTIME;
+use opendal::tests::init_test_service;
use opendal::*;
pub static TEST_FIXTURE: Fixture = Fixture::new();
diff --git a/core/tests/behavior/utils.rs b/core/tests/behavior/utils.rs
index 2e2d4d41e..c4a5440f0 100644
--- a/core/tests/behavior/utils.rs
+++ b/core/tests/behavior/utils.rs
@@ -21,8 +21,8 @@ use std::sync::Mutex;
use futures::Future;
use libtest_mimic::Failed;
use libtest_mimic::Trial;
-use opendal::raw::tests::TEST_RUNTIME;
use opendal::raw::*;
+use opendal::tests::TEST_RUNTIME;
use opendal::*;
use rand::distributions::uniform::SampleRange;
use rand::prelude::*;
diff --git a/integrations/object_store/tests/behavior/main.rs
b/integrations/object_store/tests/behavior/main.rs
index 1429eb5f5..371dad6c8 100644
--- a/integrations/object_store/tests/behavior/main.rs
+++ b/integrations/object_store/tests/behavior/main.rs
@@ -23,7 +23,7 @@ mod utils;
use libtest_mimic::Arguments;
fn main() -> anyhow::Result<()> {
- let Ok(Some(op)) = opendal::raw::tests::init_test_service() else {
+ let Ok(Some(op)) = opendal::tests::init_test_service() else {
return Ok(());
};
let store = object_store_opendal::OpendalStore::new(op);
diff --git a/integrations/object_store/tests/behavior/utils.rs
b/integrations/object_store/tests/behavior/utils.rs
index 96b58e4e8..f295fedb0 100644
--- a/integrations/object_store/tests/behavior/utils.rs
+++ b/integrations/object_store/tests/behavior/utils.rs
@@ -18,7 +18,7 @@
use libtest_mimic::{Failed, Trial};
use object_store_opendal::OpendalStore;
use opendal::raw::MaybeSend;
-use opendal::raw::tests::TEST_RUNTIME;
+use opendal::tests::TEST_RUNTIME;
use std::future::Future;
pub fn build_trail<F, Fut>(name: &str, store: &OpendalStore, f: F) -> Trial