Sruhvx-jpg commented on code in PR #3288: URL: https://github.com/apache/iceberg-rust/pull/3288#discussion_r4153146001
########## crates/storage/common/tests/common/mod.rs: ########## @@ -0,0 +1,283 @@ +// 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 std::time::Duration; + +use iceberg::io::{ + FileIO, 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}; +use iceberg_test_utils::{ + get_gcs_endpoint, get_object_store_endpoint, normalize_test_name, set_up, +}; +use tempfile::TempDir; +use tokio::time::sleep; + +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) +} + +pub struct StorageHarness { + pub file_io: FileIO, + pub label: &'static str, + pub base_path: String, + pub _tempdirs: Vec<TempDir>, +} + +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()) + } +} + +/// Fast probe to check if an endpoint service is listening before entering retry loops. +pub async fn is_endpoint_reachable(endpoint: &str) -> bool { + let Ok(client) = reqwest::Client::builder() + .timeout(Duration::from_millis(300)) Review Comment: Great idea! -- 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]
