feat: add a test macro (#170)
This commit is contained in:
@@ -3,7 +3,7 @@ $Env:SERVER_ENDPOINT = "http://localhost:9000/"
|
||||
$Env:ACCESS_KEY = "minioadmin"
|
||||
$Env:SECRET_KEY = "minioadmin"
|
||||
$Env:ENABLE_HTTPS = "false"
|
||||
$Env:SSL_CERT_FILE = "./tests/public.crt"
|
||||
$Env:MINIO_SSL_CERT_FILE = "./tests/public.crt"
|
||||
$Env:IGNORE_CERT_CHECK = "false"
|
||||
$Env:SERVER_REGION = ""
|
||||
|
||||
|
||||
@@ -73,15 +73,8 @@ async fn create_object_helper(
|
||||
}
|
||||
|
||||
/// Append to the end of an existing object (happy flow)
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn append_object_0() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
if !ctx.client.is_minio_express().await {
|
||||
println!("Skipping test because it is NOT running in MinIO Express mode");
|
||||
return;
|
||||
}
|
||||
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
#[minio_macros::test(skip_if_not_express)]
|
||||
async fn append_object_0(ctx: TestContext, bucket_name: String) {
|
||||
let object_name = rand_object_name();
|
||||
|
||||
let content1 = "aaaa";
|
||||
@@ -129,15 +122,8 @@ async fn append_object_0() {
|
||||
}
|
||||
|
||||
/// Append to the beginning of an existing object (happy flow)
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn append_object_1() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
if !ctx.client.is_minio_express().await {
|
||||
println!("Skipping test because it is NOT running in MinIO Express mode");
|
||||
return;
|
||||
}
|
||||
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
#[minio_macros::test(skip_if_not_express)]
|
||||
async fn append_object_1(ctx: TestContext, bucket_name: String) {
|
||||
let object_name = rand_object_name();
|
||||
|
||||
let content1 = "aaaa";
|
||||
@@ -185,15 +171,8 @@ async fn append_object_1() {
|
||||
}
|
||||
|
||||
/// Append to the middle of an existing object (error InvalidWriteOffset)
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn append_object_2() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
if !ctx.client.is_minio_express().await {
|
||||
println!("Skipping test because it is NOT running in MinIO Express mode");
|
||||
return;
|
||||
}
|
||||
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
#[minio_macros::test(skip_if_not_express)]
|
||||
async fn append_object_2(ctx: TestContext, bucket_name: String) {
|
||||
let object_name = rand_object_name();
|
||||
|
||||
let content1 = "aaaa";
|
||||
@@ -221,15 +200,8 @@ async fn append_object_2() {
|
||||
}
|
||||
|
||||
/// Append beyond the size of an existing object (error InvalidWriteOffset)
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn append_object_3() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
if !ctx.client.is_minio_express().await {
|
||||
println!("Skipping test because it is NOT running in MinIO Express mode");
|
||||
return;
|
||||
}
|
||||
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
#[minio_macros::test(skip_if_not_express)]
|
||||
async fn append_object_3(ctx: TestContext, bucket_name: String) {
|
||||
let object_name = rand_object_name();
|
||||
|
||||
let content1 = "aaaa";
|
||||
@@ -257,15 +229,8 @@ async fn append_object_3() {
|
||||
}
|
||||
|
||||
/// Append to the beginning/end of a non-existing object (happy flow)
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn append_object_4() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
if !ctx.client.is_minio_express().await {
|
||||
println!("Skipping test because it is NOT running in MinIO Express mode");
|
||||
return;
|
||||
}
|
||||
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
#[minio_macros::test(skip_if_not_express)]
|
||||
async fn append_object_4(ctx: TestContext, bucket_name: String) {
|
||||
let object_name = rand_object_name();
|
||||
|
||||
let content1 = "aaaa";
|
||||
@@ -309,15 +274,8 @@ async fn append_object_4() {
|
||||
}
|
||||
|
||||
/// Append beyond the size of a non-existing object (error NoSuchKey)
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn append_object_5() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
if !ctx.client.is_minio_express().await {
|
||||
println!("Skipping test because it is NOT running in MinIO Express mode");
|
||||
return;
|
||||
}
|
||||
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
#[minio_macros::test(skip_if_not_express)]
|
||||
async fn append_object_5(ctx: TestContext, bucket_name: String) {
|
||||
let object_name = rand_object_name();
|
||||
|
||||
let content1 = "aaaa";
|
||||
@@ -339,15 +297,8 @@ async fn append_object_5() {
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn append_object_content_0() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
if !ctx.client.is_minio_express().await {
|
||||
println!("Skipping test because it is NOT running in MinIO Express mode");
|
||||
return;
|
||||
}
|
||||
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
#[minio_macros::test(skip_if_not_express)]
|
||||
async fn append_object_content_0(ctx: TestContext, bucket_name: String) {
|
||||
let object_name = rand_object_name();
|
||||
|
||||
let content1 = "aaaaa";
|
||||
@@ -389,15 +340,8 @@ async fn append_object_content_0() {
|
||||
assert_eq!(content, format!("{}{}", content1, content2));
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn append_object_content_1() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
if !ctx.client.is_minio_express().await {
|
||||
println!("Skipping test because it is NOT running in MinIO Express mode");
|
||||
return;
|
||||
}
|
||||
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
#[minio_macros::test(skip_if_not_express)]
|
||||
async fn append_object_content_1(ctx: TestContext, bucket_name: String) {
|
||||
let object_name = rand_object_name();
|
||||
|
||||
let n_parts = 3;
|
||||
@@ -441,15 +385,8 @@ async fn append_object_content_1() {
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn append_object_content_2() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
if !ctx.client.is_minio_express().await {
|
||||
println!("Skipping test because it is NOT running in MinIO Express mode");
|
||||
return;
|
||||
}
|
||||
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
#[minio_macros::test(skip_if_not_express)]
|
||||
async fn append_object_content_2(ctx: TestContext, bucket_name: String) {
|
||||
let object_name = rand_object_name();
|
||||
|
||||
let sizes = [16_u64, 5 * 1024 * 1024, 16 + 5 * 1024 * 1024];
|
||||
@@ -492,15 +429,8 @@ async fn append_object_content_2() {
|
||||
}
|
||||
|
||||
/// Test sending AppendObject across async tasks.
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn append_object_content_3() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
if !ctx.client.is_minio_express().await {
|
||||
println!("Skipping test because it is NOT running in MinIO Express mode");
|
||||
return;
|
||||
}
|
||||
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
#[minio_macros::test(skip_if_not_express)]
|
||||
async fn append_object_content_3(ctx: TestContext, bucket_name: String) {
|
||||
let object_name = rand_object_name();
|
||||
let sizes = vec![16_u64, 5 * 1024 * 1024, 16 + 5 * 1024 * 1024];
|
||||
|
||||
|
||||
@@ -21,9 +21,8 @@ use minio::s3::types::S3Api;
|
||||
use minio_common::test_context::TestContext;
|
||||
use minio_common::utils::rand_bucket_name;
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn bucket_create() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
#[minio_macros::test(no_bucket)]
|
||||
async fn bucket_create(ctx: TestContext) {
|
||||
let bucket_name = rand_bucket_name();
|
||||
|
||||
// try to create a bucket that does not exist
|
||||
@@ -49,9 +48,8 @@ async fn bucket_create() {
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn bucket_delete() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
#[minio_macros::test(no_bucket)]
|
||||
async fn bucket_delete(ctx: TestContext) {
|
||||
let bucket_name = rand_bucket_name();
|
||||
|
||||
// try to remove a bucket that does not exist
|
||||
|
||||
@@ -21,11 +21,8 @@ use minio::s3::response::{
|
||||
use minio::s3::types::{S3Api, SseConfig};
|
||||
use minio_common::test_context::TestContext;
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn bucket_encryption() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
|
||||
#[minio_macros::test]
|
||||
async fn bucket_encryption(ctx: TestContext, bucket_name: String) {
|
||||
let config = SseConfig::default();
|
||||
|
||||
if false {
|
||||
|
||||
@@ -19,11 +19,8 @@ use minio::s3::response::{BucketExistsResponse, DeleteBucketResponse};
|
||||
use minio::s3::types::S3Api;
|
||||
use minio_common::test_context::TestContext;
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn bucket_exists() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
|
||||
#[minio_macros::test(no_cleanup)]
|
||||
async fn bucket_exists(ctx: TestContext, bucket_name: String) {
|
||||
let resp: BucketExistsResponse = ctx.client.bucket_exists(&bucket_name).send().await.unwrap();
|
||||
assert!(resp.exists());
|
||||
assert_eq!(resp.bucket(), bucket_name);
|
||||
|
||||
@@ -24,11 +24,8 @@ use minio::s3::types::S3Api;
|
||||
use minio_common::example::create_bucket_lifecycle_config_examples;
|
||||
use minio_common::test_context::TestContext;
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn bucket_lifecycle() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
|
||||
#[minio_macros::test]
|
||||
async fn bucket_lifecycle(ctx: TestContext, bucket_name: String) {
|
||||
let config: LifecycleConfig = create_bucket_lifecycle_config_examples();
|
||||
|
||||
let resp: PutBucketLifecycleResponse = ctx
|
||||
|
||||
@@ -24,16 +24,8 @@ use minio_common::test_context::TestContext;
|
||||
|
||||
const SQS_ARN: &str = "arn:minio:sqs::miniojavatest:webhook";
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn test_bucket_notification() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
if ctx.client.is_minio_express().await {
|
||||
println!("Skipping test because it is running in MinIO Express mode");
|
||||
return;
|
||||
}
|
||||
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
|
||||
#[minio_macros::test(skip_if_express)]
|
||||
async fn test_bucket_notification(ctx: TestContext, bucket_name: String) {
|
||||
let config: NotificationConfig = create_bucket_notification_config_example();
|
||||
|
||||
let resp: PutBucketNotificationResponse = ctx
|
||||
|
||||
@@ -22,11 +22,8 @@ use minio::s3::types::S3Api;
|
||||
use minio_common::example::create_bucket_policy_config_example;
|
||||
use minio_common::test_context::TestContext;
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn bucket_policy() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
|
||||
#[minio_macros::test]
|
||||
async fn bucket_policy(ctx: TestContext, bucket_name: String) {
|
||||
let config: String = create_bucket_policy_config_example(&bucket_name);
|
||||
|
||||
let resp: PutBucketPolicyResponse = ctx
|
||||
|
||||
@@ -27,17 +27,10 @@ use minio_common::example::{
|
||||
};
|
||||
use minio_common::test_context::TestContext;
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn bucket_replication_s3() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
if ctx.client.is_minio_express().await {
|
||||
println!("Skipping test because it is running in MinIO Express mode");
|
||||
return;
|
||||
}
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
|
||||
#[minio_macros::test(skip_if_express)]
|
||||
async fn bucket_replication_s3(ctx: TestContext, bucket_name: String) {
|
||||
let ctx2 = TestContext::new_from_env();
|
||||
let (bucket_name2, _cleanup2) = ctx2.create_bucket_helper().await;
|
||||
let (bucket_name2, cleanup2) = ctx2.create_bucket_helper().await;
|
||||
|
||||
{
|
||||
let resp: PutBucketVersioningResponse = ctx
|
||||
@@ -132,19 +125,12 @@ async fn bucket_replication_s3() {
|
||||
.send()
|
||||
.await
|
||||
.unwrap();
|
||||
cleanup2.cleanup().await;
|
||||
//println!("response of getting replication: resp={:?}", resp);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn bucket_replication_s3express() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
|
||||
if !ctx.client.is_minio_express().await {
|
||||
println!("Skipping test because it is NOT running in MinIO Express mode");
|
||||
return;
|
||||
}
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
|
||||
#[minio_macros::test(skip_if_not_express)]
|
||||
async fn bucket_replication_s3express(ctx: TestContext, bucket_name: String) {
|
||||
let config: ReplicationConfig = create_bucket_replication_config_example(&bucket_name);
|
||||
|
||||
let resp: Result<PutBucketReplicationResponse, Error> = ctx
|
||||
|
||||
@@ -23,15 +23,8 @@ use minio::s3::types::S3Api;
|
||||
use minio_common::example::create_tags_example;
|
||||
use minio_common::test_context::TestContext;
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn bucket_tags_s3() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
if ctx.client.is_minio_express().await {
|
||||
println!("Skipping test because it is running in MinIO Express mode");
|
||||
return;
|
||||
}
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
|
||||
#[minio_macros::test(skip_if_express)]
|
||||
async fn bucket_tags_s3(ctx: TestContext, bucket_name: String) {
|
||||
let tags = create_tags_example();
|
||||
|
||||
let resp: PutBucketTaggingResponse = ctx
|
||||
@@ -74,15 +67,8 @@ async fn bucket_tags_s3() {
|
||||
assert_eq!(resp.region(), DEFAULT_REGION);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn bucket_tags_s3express() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
if !ctx.client.is_minio_express().await {
|
||||
println!("Skipping test because it is NOT running in MinIO Express mode");
|
||||
return;
|
||||
}
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
|
||||
#[minio_macros::test(skip_if_not_express)]
|
||||
async fn bucket_tags_s3express(ctx: TestContext, bucket_name: String) {
|
||||
let tags = create_tags_example();
|
||||
|
||||
let resp: Result<PutBucketTaggingResponse, Error> = ctx
|
||||
|
||||
@@ -21,15 +21,8 @@ use minio::s3::response::{GetBucketVersioningResponse, PutBucketVersioningRespon
|
||||
use minio::s3::types::S3Api;
|
||||
use minio_common::test_context::TestContext;
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn bucket_versioning_s3() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
if ctx.client.is_minio_express().await {
|
||||
println!("Skipping test because it is running in MinIO Express mode");
|
||||
return;
|
||||
}
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
|
||||
#[minio_macros::test(skip_if_express)]
|
||||
async fn bucket_versioning_s3(ctx: TestContext, bucket_name: String) {
|
||||
let resp: PutBucketVersioningResponse = ctx
|
||||
.client
|
||||
.put_bucket_versioning(&bucket_name)
|
||||
@@ -71,15 +64,8 @@ async fn bucket_versioning_s3() {
|
||||
assert_eq!(resp.region(), DEFAULT_REGION);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn bucket_versioning_s3express() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
if !ctx.client.is_minio_express().await {
|
||||
println!("Skipping test because it is NOT running in MinIO Express mode");
|
||||
return;
|
||||
}
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
|
||||
#[minio_macros::test(skip_if_not_express)]
|
||||
async fn bucket_versioning_s3express(ctx: TestContext, bucket_name: String) {
|
||||
let resp: Result<PutBucketVersioningResponse, Error> = ctx
|
||||
.client
|
||||
.put_bucket_versioning(&bucket_name)
|
||||
|
||||
@@ -20,10 +20,8 @@ use minio::s3::types::S3Api;
|
||||
use minio_common::test_context::TestContext;
|
||||
use minio_common::utils::rand_object_name;
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn get_object() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
#[minio_macros::test]
|
||||
async fn get_object(ctx: TestContext, bucket_name: String) {
|
||||
let object_name = rand_object_name();
|
||||
|
||||
let data: Bytes = Bytes::from("hello, world".to_string().into_bytes());
|
||||
|
||||
@@ -19,11 +19,8 @@ use minio::s3::response::GetPresignedObjectUrlResponse;
|
||||
use minio_common::test_context::TestContext;
|
||||
use minio_common::utils::rand_object_name;
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn get_presigned_object_url() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
|
||||
#[minio_macros::test]
|
||||
async fn get_presigned_object_url(ctx: TestContext, bucket_name: String) {
|
||||
let object_name = rand_object_name();
|
||||
let resp: GetPresignedObjectUrlResponse = ctx
|
||||
.client
|
||||
|
||||
@@ -19,10 +19,8 @@ use minio_common::test_context::TestContext;
|
||||
use minio_common::utils::rand_object_name;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn get_presigned_post_form_data() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
#[minio_macros::test]
|
||||
async fn get_presigned_post_form_data(ctx: TestContext, bucket_name: String) {
|
||||
let object_name = rand_object_name();
|
||||
|
||||
let policy: PostPolicy = create_post_policy_example(&bucket_name, &object_name);
|
||||
|
||||
@@ -18,10 +18,9 @@ use minio::s3::types::S3Api;
|
||||
use minio_common::cleanup_guard::CleanupGuard;
|
||||
use minio_common::test_context::TestContext;
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn list_buckets() {
|
||||
#[minio_macros::test(no_bucket)]
|
||||
async fn list_buckets(ctx: TestContext) {
|
||||
const N_BUCKETS: usize = 3;
|
||||
let ctx = TestContext::new_from_env();
|
||||
|
||||
let mut names: Vec<String> = Vec::new();
|
||||
let mut guards: Vec<CleanupGuard> = Vec::new();
|
||||
@@ -48,4 +47,7 @@ async fn list_buckets() {
|
||||
}
|
||||
assert_eq!(guards.len(), N_BUCKETS);
|
||||
assert_eq!(count, N_BUCKETS);
|
||||
for guard in guards {
|
||||
guard.cleanup().await;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ async fn list_objects(
|
||||
express: bool,
|
||||
n_prefixes: usize,
|
||||
n_objects: usize,
|
||||
ctx: TestContext,
|
||||
bucket_name: String,
|
||||
) {
|
||||
if express {
|
||||
if use_api_v1 {
|
||||
@@ -36,7 +38,6 @@ async fn list_objects(
|
||||
panic!("S3-Express does not support versioning");
|
||||
}
|
||||
}
|
||||
let ctx = TestContext::new_from_env();
|
||||
|
||||
let is_express = ctx.client.is_minio_express().await;
|
||||
if is_express && !express {
|
||||
@@ -47,8 +48,6 @@ async fn list_objects(
|
||||
return;
|
||||
}
|
||||
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
|
||||
let mut names_set_before: HashSet<String> = HashSet::new();
|
||||
let mut names_vec_after: Vec<String> = Vec::with_capacity(n_prefixes * n_objects);
|
||||
|
||||
@@ -98,29 +97,29 @@ async fn list_objects(
|
||||
assert_eq!(names_set_after, names_set_before);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn list_objects_v1_no_versions() {
|
||||
list_objects(true, false, false, 5, 5).await;
|
||||
#[minio_macros::test]
|
||||
async fn list_objects_v1_no_versions(ctx: TestContext, bucket_name: String) {
|
||||
list_objects(true, false, false, 5, 5, ctx, bucket_name).await;
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn list_objects_v1_with_versions() {
|
||||
list_objects(true, true, false, 5, 5).await;
|
||||
#[minio_macros::test]
|
||||
async fn list_objects_v1_with_versions(ctx: TestContext, bucket_name: String) {
|
||||
list_objects(true, true, false, 5, 5, ctx, bucket_name).await;
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn list_objects_v2_no_versions() {
|
||||
list_objects(false, false, false, 5, 5).await;
|
||||
#[minio_macros::test]
|
||||
async fn list_objects_v2_no_versions(ctx: TestContext, bucket_name: String) {
|
||||
list_objects(false, false, false, 5, 5, ctx, bucket_name).await;
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn list_objects_v2_with_versions() {
|
||||
list_objects(false, true, false, 5, 5).await;
|
||||
#[minio_macros::test]
|
||||
async fn list_objects_v2_with_versions(ctx: TestContext, bucket_name: String) {
|
||||
list_objects(false, true, false, 5, 5, ctx, bucket_name).await;
|
||||
}
|
||||
|
||||
/// Test for S3-Express: List objects with S3-Express are only supported with V2 API, without
|
||||
/// versions, and yield unsorted results.
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn list_objects_express() {
|
||||
list_objects(false, false, true, 5, 5).await;
|
||||
#[minio_macros::test]
|
||||
async fn list_objects_express(ctx: TestContext, bucket_name: String) {
|
||||
list_objects(false, false, true, 5, 5, ctx, bucket_name).await;
|
||||
}
|
||||
|
||||
@@ -24,10 +24,8 @@ use minio_common::test_context::TestContext;
|
||||
use minio_common::utils::rand_object_name;
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn listen_bucket_notification() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
#[minio_macros::test(flavor = "multi_thread", worker_threads = 10)]
|
||||
async fn listen_bucket_notification(ctx: TestContext, bucket_name: String) {
|
||||
let object_name = rand_object_name();
|
||||
|
||||
type MessageType = u32;
|
||||
@@ -57,7 +55,7 @@ async fn listen_bucket_notification() {
|
||||
|
||||
if let Some(record) = record {
|
||||
let key: &str = &record.s3.object.key;
|
||||
if key == &object_name2 {
|
||||
if key == object_name2 {
|
||||
// Do something with the record, check if you received an event triggered
|
||||
// by the put_object that will happen in a few ms.
|
||||
assert_eq!(record.event_name, "s3:ObjectCreated:Put");
|
||||
|
||||
@@ -21,10 +21,8 @@ use minio_common::rand_src::RandSrc;
|
||||
use minio_common::test_context::TestContext;
|
||||
use minio_common::utils::rand_object_name;
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn compose_object() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
#[minio_macros::test]
|
||||
async fn compose_object(ctx: TestContext, bucket_name: String) {
|
||||
let object_name_src: String = rand_object_name();
|
||||
let object_name_dst: String = rand_object_name();
|
||||
|
||||
|
||||
@@ -21,15 +21,8 @@ use minio_common::rand_src::RandSrc;
|
||||
use minio_common::test_context::TestContext;
|
||||
use minio_common::utils::rand_object_name;
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn copy_object() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
if ctx.client.is_minio_express().await {
|
||||
println!("Skipping test because it is running in MinIO Express mode");
|
||||
return;
|
||||
}
|
||||
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
#[minio_macros::test(skip_if_express)]
|
||||
async fn copy_object(ctx: TestContext, bucket_name: String) {
|
||||
let object_name_src: String = rand_object_name();
|
||||
let object_name_dst: String = rand_object_name();
|
||||
|
||||
|
||||
@@ -18,30 +18,14 @@ use bytes::Bytes;
|
||||
use minio::s3::client::DEFAULT_REGION;
|
||||
use minio::s3::response::a_response_traits::{HasBucket, HasObject, HasRegion, HasVersion};
|
||||
use minio::s3::response::{
|
||||
CreateBucketResponse, GetObjectLegalHoldResponse, PutObjectContentResponse,
|
||||
PutObjectLegalHoldResponse,
|
||||
GetObjectLegalHoldResponse, PutObjectContentResponse, PutObjectLegalHoldResponse,
|
||||
};
|
||||
use minio::s3::types::S3Api;
|
||||
use minio_common::cleanup_guard::CleanupGuard;
|
||||
use minio_common::test_context::TestContext;
|
||||
use minio_common::utils::{rand_bucket_name, rand_object_name};
|
||||
use minio_common::utils::rand_object_name;
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn object_legal_hold_s3() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
if ctx.client.is_minio_express().await {
|
||||
println!("Skipping test because it is running in MinIO Express mode");
|
||||
return;
|
||||
}
|
||||
let bucket_name: String = rand_bucket_name();
|
||||
let _resp: CreateBucketResponse = ctx
|
||||
.client
|
||||
.create_bucket(&bucket_name)
|
||||
.object_lock(true)
|
||||
.send()
|
||||
.await
|
||||
.unwrap();
|
||||
let _cleanup = CleanupGuard::new(ctx.client.clone(), &bucket_name);
|
||||
#[minio_macros::test(skip_if_express, object_lock)]
|
||||
async fn object_legal_hold_s3(ctx: TestContext, bucket_name: String) {
|
||||
let object_name = rand_object_name();
|
||||
|
||||
let data = Bytes::from("hello, world".to_string().into_bytes());
|
||||
|
||||
@@ -19,27 +19,10 @@ use minio::s3::response::{
|
||||
DeleteObjectLockConfigResponse, GetObjectLockConfigResponse, PutObjectLockConfigResponse,
|
||||
};
|
||||
use minio::s3::types::{ObjectLockConfig, RetentionMode, S3Api};
|
||||
use minio_common::cleanup_guard::CleanupGuard;
|
||||
use minio_common::test_context::TestContext;
|
||||
use minio_common::utils::rand_bucket_name;
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn object_lock_config() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
if ctx.client.is_minio_express().await {
|
||||
println!("Skipping test because it is running in MinIO Express mode");
|
||||
return;
|
||||
}
|
||||
|
||||
let bucket_name: String = rand_bucket_name();
|
||||
ctx.client
|
||||
.create_bucket(&bucket_name)
|
||||
.object_lock(true)
|
||||
.send()
|
||||
.await
|
||||
.unwrap();
|
||||
let _cleanup = CleanupGuard::new(ctx.client.clone(), &bucket_name);
|
||||
|
||||
#[minio_macros::test(skip_if_express, object_lock)]
|
||||
async fn object_lock_config(ctx: TestContext, bucket_name: String) {
|
||||
const DURATION_DAYS: i32 = 7;
|
||||
let config =
|
||||
ObjectLockConfig::new(RetentionMode::GOVERNANCE, Some(DURATION_DAYS), None).unwrap();
|
||||
|
||||
@@ -26,10 +26,8 @@ use minio_common::test_context::TestContext;
|
||||
use minio_common::utils::rand_object_name;
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn put_object() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
#[minio_macros::test]
|
||||
async fn put_object(ctx: TestContext, bucket_name: String) {
|
||||
let object_name: String = rand_object_name();
|
||||
|
||||
let size = 16_u64;
|
||||
@@ -64,7 +62,7 @@ async fn put_object() {
|
||||
.send()
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(!resp.version_id().is_some());
|
||||
assert!(resp.version_id().is_none());
|
||||
|
||||
// Validate delete succeeded.
|
||||
let resp: Result<StatObjectResponse, Error> = ctx
|
||||
@@ -81,11 +79,9 @@ async fn put_object() {
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn put_object_multipart() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
let object_name = rand_object_name();
|
||||
#[minio_macros::test]
|
||||
async fn put_object_multipart(ctx: TestContext, bucket_name: String) {
|
||||
let object_name: String = rand_object_name();
|
||||
|
||||
let size: u64 = 16 + MIN_PART_SIZE;
|
||||
|
||||
@@ -122,10 +118,8 @@ async fn put_object_multipart() {
|
||||
assert_eq!(resp.version_id(), None);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn put_object_content_1() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
#[minio_macros::test]
|
||||
async fn put_object_content_1(ctx: TestContext, bucket_name: String) {
|
||||
let object_name = rand_object_name();
|
||||
let sizes = [16_u64, MIN_PART_SIZE, 16 + MIN_PART_SIZE];
|
||||
|
||||
@@ -168,10 +162,8 @@ async fn put_object_content_1() {
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 10)]
|
||||
async fn put_object_content_2() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
#[minio_macros::test]
|
||||
async fn put_object_content_2(ctx: TestContext, bucket_name: String) {
|
||||
let object_name = rand_object_name();
|
||||
let sizes = [16_u64, MIN_PART_SIZE, 16 + MIN_PART_SIZE];
|
||||
|
||||
@@ -212,10 +204,8 @@ async fn put_object_content_2() {
|
||||
}
|
||||
|
||||
/// Test sending PutObject across async tasks.
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn put_object_content_3() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
#[minio_macros::test]
|
||||
async fn put_object_content_3(ctx: TestContext, bucket_name: String) {
|
||||
let object_name = rand_object_name();
|
||||
let sizes = vec![16_u64, MIN_PART_SIZE, 16 + MIN_PART_SIZE];
|
||||
|
||||
|
||||
@@ -21,11 +21,8 @@ use minio::s3::types::ToStream;
|
||||
use minio_common::test_context::TestContext;
|
||||
use minio_common::utils::rand_object_name;
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn remove_objects() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
|
||||
#[minio_macros::test]
|
||||
async fn remove_objects(ctx: TestContext, bucket_name: String) {
|
||||
let mut names: Vec<String> = Vec::new();
|
||||
for _ in 1..=3 {
|
||||
let object_name = rand_object_name();
|
||||
|
||||
@@ -17,34 +17,16 @@ use minio::s3::builders::ObjectContent;
|
||||
use minio::s3::client::DEFAULT_REGION;
|
||||
use minio::s3::response::a_response_traits::{HasBucket, HasObject, HasRegion, HasVersion};
|
||||
use minio::s3::response::{
|
||||
CreateBucketResponse, GetObjectRetentionResponse, PutObjectContentResponse,
|
||||
PutObjectRetentionResponse,
|
||||
GetObjectRetentionResponse, PutObjectContentResponse, PutObjectRetentionResponse,
|
||||
};
|
||||
use minio::s3::types::{RetentionMode, S3Api};
|
||||
use minio::s3::utils::{to_iso8601utc, utc_now};
|
||||
use minio_common::cleanup_guard::CleanupGuard;
|
||||
use minio_common::rand_src::RandSrc;
|
||||
use minio_common::test_context::TestContext;
|
||||
use minio_common::utils::{rand_bucket_name, rand_object_name};
|
||||
use minio_common::utils::rand_object_name;
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn object_retention() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
if ctx.client.is_minio_express().await {
|
||||
println!("Skipping test because it is running in MinIO Express mode");
|
||||
return;
|
||||
}
|
||||
|
||||
let bucket_name: String = rand_bucket_name();
|
||||
let resp: CreateBucketResponse = ctx
|
||||
.client
|
||||
.create_bucket(&bucket_name)
|
||||
.object_lock(true)
|
||||
.send()
|
||||
.await
|
||||
.unwrap();
|
||||
let _cleanup = CleanupGuard::new(ctx.client.clone(), &bucket_name);
|
||||
assert_eq!(resp.bucket(), bucket_name);
|
||||
#[minio_macros::test(skip_if_express, object_lock)]
|
||||
async fn object_retention(ctx: TestContext, bucket_name: String) {
|
||||
let object_name = rand_object_name();
|
||||
|
||||
let size = 16_u64;
|
||||
|
||||
@@ -28,15 +28,8 @@ use minio_common::test_context::TestContext;
|
||||
use minio_common::utils::rand_object_name;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn object_tags() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
if ctx.client.is_minio_express().await {
|
||||
println!("Skipping test because it is running in MinIO Express mode");
|
||||
return;
|
||||
}
|
||||
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
#[minio_macros::test(skip_if_express)]
|
||||
async fn object_tags(ctx: TestContext, bucket_name: String) {
|
||||
let object_name = rand_object_name();
|
||||
|
||||
let size = 16_u64;
|
||||
|
||||
@@ -21,15 +21,8 @@ use minio_common::example::{create_select_content_data, create_select_content_re
|
||||
use minio_common::test_context::TestContext;
|
||||
use minio_common::utils::rand_object_name;
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn select_object_content_s3() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
if ctx.client.is_minio_express().await {
|
||||
println!("Skipping test because it is running in MinIO Express mode");
|
||||
return;
|
||||
}
|
||||
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
#[minio_macros::test(skip_if_express)]
|
||||
async fn select_object_content_s3(ctx: TestContext, bucket_name: String) {
|
||||
let object_name: String = rand_object_name();
|
||||
let (select_body, select_data) = create_select_content_data();
|
||||
|
||||
@@ -62,15 +55,8 @@ async fn select_object_content_s3() {
|
||||
assert_eq!(got, select_data);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn select_object_content_express() {
|
||||
let ctx = TestContext::new_from_env();
|
||||
if !ctx.client.is_minio_express().await {
|
||||
println!("Skipping test because it is NOT running in MinIO Express mode");
|
||||
return;
|
||||
}
|
||||
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
#[minio_macros::test(skip_if_not_express)]
|
||||
async fn select_object_content_express(ctx: TestContext, bucket_name: String) {
|
||||
let object_name = rand_object_name();
|
||||
let (select_body, _) = create_select_content_data();
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use async_std::io::ReadExt;
|
||||
use hex::ToHex;
|
||||
use minio::s3::builders::ObjectContent;
|
||||
use minio::s3::response::a_response_traits::{HasBucket, HasObject};
|
||||
@@ -25,38 +26,38 @@ use minio_common::utils::rand_object_name;
|
||||
use ring::digest::{Context, SHA256};
|
||||
#[cfg(not(feature = "ring"))]
|
||||
use sha2::{Digest, Sha256};
|
||||
#[cfg(feature = "ring")]
|
||||
use std::io::Read;
|
||||
use std::path::PathBuf;
|
||||
use std::{fs, io};
|
||||
|
||||
fn get_hash(filename: &String) -> String {
|
||||
async fn get_hash(filename: &String) -> String {
|
||||
#[cfg(feature = "ring")]
|
||||
{
|
||||
let mut context = Context::new(&SHA256);
|
||||
let mut file = fs::File::open(filename).unwrap();
|
||||
let mut file = async_std::fs::File::open(filename).await.unwrap();
|
||||
let mut buf = Vec::new();
|
||||
file.read_to_end(&mut buf).unwrap();
|
||||
file.read_to_end(&mut buf).await.unwrap();
|
||||
context.update(&buf);
|
||||
context.finish().encode_hex()
|
||||
}
|
||||
#[cfg(not(feature = "ring"))]
|
||||
{
|
||||
let mut hasher = Sha256::new();
|
||||
let mut file = fs::File::open(filename).unwrap();
|
||||
io::copy(&mut file, &mut hasher).unwrap();
|
||||
let mut file = async_std::fs::File::open(filename).await.unwrap();
|
||||
let mut buf = Vec::new();
|
||||
file.read_to_end(&mut buf).await.unwrap();
|
||||
hasher.update(&buf);
|
||||
hasher.finalize().encode_hex()
|
||||
}
|
||||
}
|
||||
|
||||
async fn upload_download_object(size: u64) {
|
||||
let ctx = TestContext::new_from_env();
|
||||
let (bucket_name, _cleanup) = ctx.create_bucket_helper().await;
|
||||
async fn upload_download_object(size: u64, ctx: TestContext, bucket_name: String) {
|
||||
let object_name: String = rand_object_name();
|
||||
let mut file = async_std::fs::File::create(&object_name).await.unwrap();
|
||||
|
||||
let mut file = fs::File::create(&object_name).unwrap();
|
||||
io::copy(&mut RandReader::new(size), &mut file).unwrap();
|
||||
file.sync_all().unwrap();
|
||||
async_std::io::copy(&mut RandReader::new(size), &mut file)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
file.sync_all().await.unwrap();
|
||||
|
||||
let obj: ObjectContent = PathBuf::from(&object_name).as_path().into();
|
||||
|
||||
@@ -86,18 +87,18 @@ async fn upload_download_object(size: u64) {
|
||||
.to_file(PathBuf::from(&filename).as_path())
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(get_hash(&object_name), get_hash(&filename));
|
||||
assert_eq!(get_hash(&object_name).await, get_hash(&filename).await);
|
||||
|
||||
fs::remove_file(&object_name).unwrap();
|
||||
fs::remove_file(&filename).unwrap();
|
||||
async_std::fs::remove_file(&object_name).await.unwrap();
|
||||
async_std::fs::remove_file(&filename).await.unwrap();
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn upload_download_object_1() {
|
||||
upload_download_object(16).await;
|
||||
#[minio_macros::test]
|
||||
async fn upload_download_object_1(ctx: TestContext, bucket_name: String) {
|
||||
upload_download_object(16, ctx, bucket_name).await;
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn upload_download_object_2() {
|
||||
upload_download_object(16 + 5 * 1024 * 1024).await;
|
||||
#[minio_macros::test]
|
||||
async fn upload_download_object_2(ctx: TestContext, bucket_name: String) {
|
||||
upload_download_object(16 + 5 * 1024 * 1024, ctx, bucket_name).await;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user