fix: disable config load in int test

Signed-off-by: discord9 <discord9@163.com>
This commit is contained in:
discord9
2025-12-11 14:57:02 +08:00
parent 84b4777925
commit b8c362ec65
4 changed files with 20 additions and 2 deletions

View File

@@ -89,6 +89,10 @@ wrap_with_clap_prefix! {
region: Option<String>,
#[doc = "Enable virtual host style for the object store."]
enable_virtual_host_style: bool = Default::default(),
#[doc = "Allow anonymous access (disable credential signing) for testing."]
allow_anonymous: bool = Default::default(),
#[doc = "Disable config load from environment and files for testing."]
disable_config_load: bool = Default::default(),
}
}

View File

@@ -117,6 +117,10 @@ pub struct S3Connection {
/// By default, opendal will send API to https://s3.us-east-1.amazonaws.com/bucket_name
/// Enabled, opendal will send API to https://bucket_name.s3.us-east-1.amazonaws.com
pub enable_virtual_host_style: bool,
/// Allow anonymous access (disable credential signing) - useful for local testing
pub allow_anonymous: bool,
/// Disable config load from environment and files - useful for local testing
pub disable_config_load: bool,
}
impl From<&S3Connection> for S3 {
@@ -139,6 +143,14 @@ impl From<&S3Connection> for S3 {
builder = builder.enable_virtual_host_style();
}
if connection.allow_anonymous {
builder = builder.allow_anonymous();
}
if connection.disable_config_load {
builder = builder.disable_config_load();
}
builder
}
}

View File

@@ -117,8 +117,8 @@ pub async fn new_oss_object_store(oss_config: &OssConfig) -> Result<ObjectStore>
pub async fn new_s3_object_store(s3_config: &S3Config) -> Result<ObjectStore> {
let root = util::normalize_dir(&s3_config.connection.root);
info!(
"The s3 storage bucket is: {}, root is: {}",
s3_config.connection.bucket, &root
"The s3 storage bucket is: {}, root is: {}, endpoint: {:?}",
s3_config.connection.bucket, &root, s3_config.connection.endpoint
);
let client = build_http_client(&s3_config.http_client)?;

View File

@@ -147,6 +147,8 @@ fn s3_test_config() -> S3Config {
bucket: env::var("GT_S3_BUCKET").unwrap(),
region: Some(env::var("GT_S3_REGION").unwrap()),
endpoint: env::var("GT_S3_ENDPOINT_URL").ok(),
allow_anonymous: true, // Enable anonymous access to bypass reqsign for local testing
disable_config_load: true, // Disable config load to bypass reqsign for local MinIO
..Default::default()
},
..Default::default()