From 8d39e5b9de10cdc44add1fdff718c50e7e1cb892 Mon Sep 17 00:00:00 2001 From: Suyan Date: Tue, 18 Jun 2024 22:05:42 +0800 Subject: [PATCH] ci: set behavior test ci for aliyun drive (#4657) * ci: set behavior test ci for aliyun drive Signed-off-by: suyanhanx * refactor(aliyun-drive): lister without get file detail co-authored-by: yuchanns Signed-off-by: suyanhanx * bindings(py/nodejs/java): enable service aliyun_drive Signed-off-by: suyanhanx --------- Signed-off-by: suyanhanx Co-authored-by: yuchanns Co-authored-by: Xuanwo --- .env.example | 5 +++++ .../{disabled_action.yml => action.yml} | 6 ++++++ bindings/java/Cargo.toml | 2 ++ bindings/nodejs/Cargo.toml | 3 +++ bindings/python/Cargo.toml | 2 ++ core/src/services/aliyun_drive/lister.rs | 19 +++++++------------ 6 files changed, 25 insertions(+), 12 deletions(-) rename .github/services/aliyun_drive/aliyun_drive/{disabled_action.yml => action.yml} (90%) diff --git a/.env.example b/.env.example index 9466c86f28d..cd533521985 100644 --- a/.env.example +++ b/.env.example @@ -212,3 +212,8 @@ OPENDAL_ICLOUD_IS_CHINA_MAINLAND=true # vercel blob OPENDAL_VERCEL_BLOB_ROOT=/path/to/dir OPENDAL_VERCEL_BLOB_TOKEN= +# aliyun drive +OPENDAL_ALIYUN_DRIVE_ROOT=/path/to/dir +OPENDAL_ALIYUN_DRIVE_REFRESH_TOKEN= +OPENDAL_ALIYUN_DRIVE_CLIENT_ID= +OPENDAL_ALIYUN_DRIVE_CLIENT_SECRET= diff --git a/.github/services/aliyun_drive/aliyun_drive/disabled_action.yml b/.github/services/aliyun_drive/aliyun_drive/action.yml similarity index 90% rename from .github/services/aliyun_drive/aliyun_drive/disabled_action.yml rename to .github/services/aliyun_drive/aliyun_drive/action.yml index 3960a493474..581f9cc9351 100644 --- a/.github/services/aliyun_drive/aliyun_drive/disabled_action.yml +++ b/.github/services/aliyun_drive/aliyun_drive/action.yml @@ -30,3 +30,9 @@ runs: OPENDAL_ALIYUN_DRIVE_REFRESH_TOKEN: op://services/aliyun_drive/refresh_token OPENDAL_ALIYUN_DRIVE_CLIENT_ID: op://services/aliyun_drive/client_id OPENDAL_ALIYUN_DRIVE_CLIENT_SECRET: op://services/aliyun_drive/client_secret + - name: Setup test threads + shell: bash + run: | + cat << EOF >> $GITHUB_ENV + RUST_TEST_THREADS=1 + EOF diff --git a/bindings/java/Cargo.toml b/bindings/java/Cargo.toml index 236afafdff2..393393cdd79 100644 --- a/bindings/java/Cargo.toml +++ b/bindings/java/Cargo.toml @@ -51,6 +51,7 @@ default = [ services-all = [ "default", + "services-aliyun-drive", "services-cacache", "services-chainsafe", "services-dashmap", @@ -95,6 +96,7 @@ services-all = [ ] # Default services provided by opendal. +services-aliyun-drive = ["opendal/services-aliyun-drive"] services-azblob = ["opendal/services-azblob"] services-azdls = ["opendal/services-azdls"] services-chainsafe = ["opendal/services-chainsafe"] diff --git a/bindings/nodejs/Cargo.toml b/bindings/nodejs/Cargo.toml index 7597f3e125e..d66df7f2c3e 100644 --- a/bindings/nodejs/Cargo.toml +++ b/bindings/nodejs/Cargo.toml @@ -47,6 +47,8 @@ default = [ services-all = [ "default", + "services-aliyun-drive", + "services-alluxio", "services-azfile", "services-cacache", "services-chainsafe", @@ -92,6 +94,7 @@ services-all = [ ] # Default services provided by opendal. +services-aliyun-drive = ["opendal/services-aliyun-drive"] services-azblob = ["opendal/services-azblob"] services-azdls = ["opendal/services-azdls"] services-chainsafe = ["opendal/services-chainsafe"] diff --git a/bindings/python/Cargo.toml b/bindings/python/Cargo.toml index 1a58528f609..9363c237da3 100644 --- a/bindings/python/Cargo.toml +++ b/bindings/python/Cargo.toml @@ -47,6 +47,7 @@ default = [ services-all = [ "default", + "services-aliyun-drive", "services-azfile", "services-cacache", "services-chainsafe", @@ -92,6 +93,7 @@ services-all = [ ] # Default services provided by opendal. +services-aliyun-drive = ["opendal/services-aliyun-drive"] services-azblob = ["opendal/services-azblob"] services-azdls = ["opendal/services-azdls"] services-chainsafe = ["opendal/services-chainsafe"] diff --git a/core/src/services/aliyun_drive/lister.rs b/core/src/services/aliyun_drive/lister.rs index 5d0277e3d70..d3ec4ba8861 100644 --- a/core/src/services/aliyun_drive/lister.rs +++ b/core/src/services/aliyun_drive/lister.rs @@ -22,7 +22,6 @@ use chrono::Utc; use self::oio::Entry; use super::core::AliyunDriveCore; -use super::core::AliyunDriveFile; use super::core::AliyunDriveFileList; use crate::raw::*; use crate::EntryMode; @@ -93,20 +92,16 @@ impl oio::PageList for AliyunDriveLister { let n = result.items.len(); for item in result.items { - let res = self.core.get(&item.file_id).await?; - let file: AliyunDriveFile = - serde_json::from_reader(res.reader()).map_err(new_json_serialize_error)?; - let path = if parent.parent_path.starts_with('/') { - build_abs_path(&parent.parent_path, &file.name) + build_abs_path(&parent.parent_path, &item.name) } else { - build_abs_path(&format!("/{}", &parent.parent_path), &file.name) + build_abs_path(&format!("/{}", &parent.parent_path), &item.name) }; - let (path, md) = if file.path_type == "folder" { + let (path, md) = if item.path_type == "folder" { let path = format!("{}/", path); let meta = Metadata::new(EntryMode::DIR).with_last_modified( - file.updated_at + item.updated_at .parse::>() .map_err(|e| { Error::new(ErrorKind::Unexpected, "parse last modified time") @@ -116,17 +111,17 @@ impl oio::PageList for AliyunDriveLister { (path, meta) } else { let mut meta = Metadata::new(EntryMode::FILE).with_last_modified( - file.updated_at + item.updated_at .parse::>() .map_err(|e| { Error::new(ErrorKind::Unexpected, "parse last modified time") .set_source(e) })?, ); - if let Some(v) = file.size { + if let Some(v) = item.size { meta = meta.with_content_length(v); } - if let Some(v) = file.content_type { + if let Some(v) = item.content_type { meta = meta.with_content_type(v); } (path, meta)