Sruhvx-jpg commented on code in PR #3288: URL: https://github.com/apache/iceberg-rust/pull/3288#discussion_r4431045664
########## crates/storage/common/tests/common/mod.rs: ########## @@ -0,0 +1,193 @@ +// 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. + +//! Shared test harness and helpers for storage integration suites. + +#![allow(dead_code)] + +use std::collections::HashMap; +use std::sync::Arc; + +use iceberg::io::{ + FileIOBuilder, GCS_NO_AUTH, GCS_SERVICE_HOST, S3_ACCESS_KEY_ID, S3_ENDPOINT, + S3_PATH_STYLE_ACCESS, S3_REGION, S3_SECRET_ACCESS_KEY, +}; +use iceberg_storage_opendal::{OpenDalResolvingStorageFactory, OpenDalStorageFactory}; +#[allow(unused_imports)] +pub use iceberg_test_utils::storage::{ + StorageHarness, handle_unreachable_endpoint, is_endpoint_reachable, roundtrip_file_io, + unique_path, wait_until_ready, +}; +use iceberg_test_utils::{get_gcs_endpoint, get_object_store_endpoint, set_up}; +use tempfile::TempDir; + +static FAKE_GCS_BUCKET: &str = "test-bucket"; + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum StorageKind { + OpenDalS3, + OpenDalGcs, + OpenDalFs, + OpenDalMemory, + OpenDalResolving, + // TODO: Wire ObjectStoreStorage::S3 once PR #3165 is merged (https://github.com/apache/iceberg-rust/pull/3165) +} + +impl StorageKind { + pub const fn as_str(&self) -> &'static str { + match self { + Self::OpenDalS3 => "opendal_s3", + Self::OpenDalGcs => "opendal_gcs", + Self::OpenDalFs => "opendal_fs", + Self::OpenDalMemory => "opendal_memory", + Self::OpenDalResolving => "opendal_resolving", + } + } +} + +impl std::fmt::Display for StorageKind { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.as_str()) + } +} + +pub async fn load_storage(kind: StorageKind) -> Option<StorageHarness> { + set_up(); + match kind { + StorageKind::OpenDalS3 => load_opendal_s3().await, + StorageKind::OpenDalGcs => load_opendal_gcs().await, + StorageKind::OpenDalFs => load_opendal_fs().await, + StorageKind::OpenDalMemory => load_opendal_memory().await, + StorageKind::OpenDalResolving => load_opendal_resolving().await, + } +} + +async fn load_opendal_s3() -> Option<StorageHarness> { Review Comment: ohhhh, yeah taking into account the fact that more loader will be made then yes. Thanks for the suggestion! -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
