You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "Ji-Xinyou (via GitHub)" <gi...@apache.org> on 2023/06/23 09:44:15 UTC
[GitHub] [incubator-opendal] Ji-Xinyou commented on a diff in pull request #2517: feat: Implement test harness via libtest-mimic instead
Ji-Xinyou commented on code in PR #2517:
URL: https://github.com/apache/incubator-opendal/pull/2517#discussion_r1239609752
##########
core/tests/behavior/presign.rs:
##########
@@ -22,56 +22,26 @@ use anyhow::Result;
use http::header;
use log::debug;
use opendal::raw;
-use opendal::Operator;
use reqwest::Url;
use sha2::Digest;
use sha2::Sha256;
-use super::utils::*;
-
-/// Test services that meet the following capability:
-///
-/// - can_read
-/// - can_write
-/// - can_presign
-macro_rules! behavior_presign_test {
- ($service:ident, $($(#[$meta:meta])* $test:ident),*,) => {
- paste::item! {
- $(
- #[test]
- $(
- #[$meta]
- )*
- fn [<presign_ $test >]() -> anyhow::Result<()> {
- match OPERATOR.as_ref() {
- Some(op) if op.info().can_read() && op.info().can_write() && op.info().can_presign() => RUNTIME.block_on($crate::presign::$test(op.clone())),
- Some(_) => {
- log::warn!("service {} doesn't support presign, ignored", opendal::Scheme::$service);
- Ok(())
- },
- None => {
- Ok(())
- }
- }
- }
- )*
- }
- };
-}
+use crate::*;
+
+pub fn behavior_presign_tests(runtime: &Runtime, op: &Operator) -> Vec<Trial> {
+ let cap = op.info().capability();
+
+ if !(cap.list && cap.write && cap.presign) {
Review Comment:
cap.stat and cap.delete may also be added
##########
core/tests/behavior/blocking_list.rs:
##########
@@ -20,62 +20,27 @@ use std::collections::HashSet;
use anyhow::Result;
use log::debug;
-use opendal::BlockingOperator;
-use opendal::EntryMode;
-
-use super::utils::*;
-
-/// Test services that meet the following capability:
-///
-/// - can_read
-/// - can_write
-/// - can_blocking
-/// - can_list or can_scan
-macro_rules! behavior_blocking_list_test {
- ($service:ident, $($(#[$meta:meta])* $test:ident),*,) => {
- paste::item! {
- $(
- #[test]
- $(
- #[$meta]
- )*
- fn [<blocking_list_ $test >]() -> anyhow::Result<()> {
- match OPERATOR.as_ref() {
- Some(op) if op.info().can_read()
- && op.info().can_write()
- && op.info().can_blocking() && op.info().can_list() => $crate::blocking_list::$test(op.blocking()),
- Some(_) => {
- log::warn!("service {} doesn't support blocking_list, ignored", opendal::Scheme::$service);
- Ok(())
- },
- None => {
- Ok(())
- }
- }
- }
- )*
- }
- };
-}
-#[macro_export]
-macro_rules! behavior_blocking_list_tests {
- ($($service:ident),*) => {
- $(
- behavior_blocking_list_test!(
- $service,
-
- test_list_dir,
- test_list_non_exist_dir,
- test_scan,
- test_remove_all,
- );
- )*
- };
+use crate::*;
+
+pub fn behavior_blocking_list_tests(op: &Operator) -> Vec<Trial> {
+ let cap = op.info().capability();
+
+ if !(cap.read && cap.write && cap.copy && cap.blocking && cap.list) {
+ return vec![];
+ }
+
+ blocking_trials!(
+ op,
+ test_blocking_list_dir,
+ test_blocking_list_non_exist_dir,
+ test_blocking_scan,
+ test_remove_all
Review Comment:
We should rename `test_remove_all` to `test_blocking_remove_all` for consistentcy.
##########
core/tests/behavior/write.rs:
##########
@@ -28,97 +28,66 @@ use futures::StreamExt;
use http::StatusCode;
use log::debug;
use log::warn;
-use opendal::EntryMode;
-use opendal::ErrorKind;
-use opendal::Operator;
use reqwest::Url;
use sha2::Digest;
use sha2::Sha256;
-use super::utils::*;
-
-/// Test services that meet the following capability:
-///
-/// - can_read
-/// - can_write
-macro_rules! behavior_write_test {
- ($service:ident, $($(#[$meta:meta])* $test:ident),*,) => {
- paste::item! {
- $(
- #[test]
- $(
- #[$meta]
- )*
- fn [<write_ $test >]() -> anyhow::Result<()> {
- match OPERATOR.as_ref() {
- Some(op) if op.info().can_read() && op.info().can_write() => RUNTIME.block_on($crate::write::$test(op.clone())),
- Some(_) => {
- log::warn!("service {} doesn't support write, ignored", opendal::Scheme::$service);
- Ok(())
- },
- None => {
- Ok(())
- }
- }
- }
- )*
- }
- };
-}
+use crate::*;
-#[macro_export]
-macro_rules! behavior_write_tests {
- ($($service:ident),*) => {
- $(
- behavior_write_test!(
- $service,
-
- test_create_dir,
- test_create_dir_existing,
- test_write_only,
- test_write_with_dir_path,
- test_write_with_special_chars,
- test_write_with_cache_control,
- test_write_with_content_type,
- test_write_with_content_disposition,
- test_stat_file,
- test_stat_dir,
- test_stat_with_special_chars,
- test_stat_not_cleaned_path,
- test_stat_not_exist,
- test_stat_with_if_match,
- test_stat_with_if_none_match,
- test_stat_root,
- test_read_full,
- test_read_range,
- test_read_large_range,
- test_reader_range,
- test_reader_from,
- test_reader_tail,
- test_read_not_exist,
- test_read_with_if_match,
- test_read_with_if_none_match,
- test_fuzz_range_reader,
- test_fuzz_offset_reader,
- test_fuzz_part_reader,
- test_read_with_dir_path,
- test_read_with_special_chars,
- test_read_with_override_cache_control,
- test_read_with_override_content_disposition,
- test_delete_file,
- test_delete_empty_dir,
- test_delete_with_special_chars,
- test_delete_not_existing,
- test_delete_stream,
- test_remove_one_file,
- test_writer_write,
- test_writer_sink,
- test_writer_abort,
- test_writer_futures_copy,
- test_fuzz_unsized_writer,
- );
- )*
- };
+pub fn behavior_write_tests(runtime: &Runtime, op: &Operator) -> Vec<Trial> {
+ let cap = op.info().capability();
+
+ if !(cap.read && cap.write && cap.rename) {
Review Comment:
I think the skips on capablities need a more fine-grained way of setting.
Take this as an example, this line requires the service to support `rename` but many of the tests below do not require the `rename` capability.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org