Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 76 additions & 9 deletions run/core/aws-sdk-php/quick-tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,12 @@ function initSetup(S3Client $s3Client, $objects) {
$stream->close();
}
}

// Create an empty bucket for bucket policy + delete tests
$result = $s3Client->createBucket(['Bucket' => $GLOBALS['emptyBucket']]);
if (getStatusCode($result) != HTTP_OK)
throw new Exception("createBucket API failed for " . $bucket);

}


Expand Down Expand Up @@ -756,6 +762,63 @@ function testBucketPolicy($s3Client, $bucket) {

if ($result['Policy'] != $downloadPolicy)
throw new Exception('bucket policy we got is not we set');

// Delete the bucket, make the bucket (again) and check if policy is none
// Ref: https://github.com/minio/minio/issues/4714
$result = $s3Client->deleteBucket(['Bucket' => $bucket]);
if (getstatuscode($result) != HTTP_NOCONTENT)
throw new Exception('deleteBucket API failed for ' .
$bucket);

$result = $s3Client->createBucket(['Bucket' => $bucket]);
if (getstatuscode($result) != HTTP_OK)
throw new Exception('createBucket API failed for ' .
$bucket);

$params = [
'404' => ['Bucket' => $bucket]
];
runExceptionalTests($s3Client, 'getBucketPolicy', 'getStatusCode', $params);

try {
$MINT_DATA_DIR = $GLOBALS['MINT_DATA_DIR'];
// Create an object to test anonymous GET object
$object = 'test-anon';
if (!file_exists($MINT_DATA_DIR . '/' . FILE_10KB))
throw new Exception('File not found ' . $MINT_DATA_DIR . '/' . FILE_10KB);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we programmatically create some data if MINT_DATA_DIR variable is not specified ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess not for these . These are part of mint . It's applicable for our SDK tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@krisis, I ran your changes on docker minio/mint:latest image and the tests fail for completeMultipartUpload.
root@0bd36cddde66:/mint# cat log/aws-sdk-php/error.log
PHP Fatal error: Uncaught Exception: Expected completeMultipartUpload to fail with EntityTooSmall in /mint/run/core/aws-sdk-php/quick-tests.php:130
Stack trace:
#0 /mint/run/core/aws-sdk-php/quick-tests.php(508): runExceptionalTests(Object(Aws\S3\S3Client), 'completeMultipa...', 'getAwsErrorCode', Array)
#1 /mint/run/core/aws-sdk-php/quick-tests.php(868): testMultipartUploadFailure(Object(Aws\S3\S3Client), 'aws-sdk-php-buc...', 'obj1')
#2 /mint/run/core/aws-sdk-php/quick-tests.php(926): runTestFunction('testMultipartUp...', Object(Aws\S3\S3Client), 'aws-sdk-php-buc...', 'obj1')
#3 {main}
thrown in /mint/run/core/aws-sdk-php/quick-tests.php on line 130
root@0bd36cddde66:/mint#

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@poornas, which version of minio server did you run mint on? I tried it locally with minio commit id ec5293c and all tests passed. Previously, minio on FS mode didn't validate if parts uploaded where smaller than 5MB in a multipart upload. This was fixed recently - minio/minio#4642.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@krisis, ran this against play server, it is on Version : 2017-06-24T23:30:00Z.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@poornas minio/minio#4642 is fixed in version 2017-07-24T18-27-35Z. This explains why you are seeing the exception.


$stream = Psr7\stream_for(fopen($MINT_DATA_DIR . '/' . FILE_10KB, 'r'));
$result = $s3Client->putObject([
'Bucket' => $bucket,
'Key' => $object,
'Body' => $stream,
]);
if (getstatuscode($result) != HTTP_OK)
throw new Exception('createBucket API failed for ' .
$bucket);

$anonConfig = new ClientConfig("", "", $GLOBALS['endpoint'], $GLOBALS['secure']);
$anonymousClient = new S3Client([
'credentials' => false,
'endpoint' => $anonConfig->endpoint,
'use_path_style_endpoint' => true,
'region' => 'us-east-1',
'version' => '2006-03-01'
]);
runExceptionalTests($anonymousClient, 'getObject', 'getStatusCode', [
'403' => [
'Bucket' => $bucket,
'Key' => $object,
]
]);

} finally {
// close data file
if (!is_null($stream))
$stream->close();
$s3Client->deleteObject(['Bucket' => $bucket, 'Key' => $object]);
}

}

/**
Expand All @@ -774,8 +837,10 @@ function cleanupSetup($s3Client, $objects) {
$s3Client->deleteObject(['Bucket' => $bucket, 'Key' => $object]);
}

// Delete the buckets
foreach (array_keys($objects) as $bucket) {
// Delete the buckets incl. emptyBucket
$allBuckets = array_keys($objects);
array_push($allBuckets, $GLOBALS['emptyBucket']);
foreach ($allBuckets as $bucket) {
// Delete the bucket
$s3Client->deleteBucket(['Bucket' => $bucket]);

Expand Down Expand Up @@ -811,10 +876,10 @@ function runTestFunction($myfunc, ...$args) {
}

// Get client configuration from environment variables
$access_key = getenv("ACCESS_KEY");
$secret_key = getenv("SECRET_KEY");
$endpoint = getenv("SERVER_ENDPOINT");
$secure = getenv("ENABLE_HTTPS");
$GLOBALS['access_key'] = getenv("ACCESS_KEY");
$GLOBALS['secret_key'] = getenv("SECRET_KEY");
$GLOBALS['endpoint'] = getenv("SERVER_ENDPOINT");
$GLOBALS['secure'] = getenv("ENABLE_HTTPS");

/**
* @global string $GLOBALS['MINT_DATA_DIR']
Expand All @@ -825,8 +890,8 @@ function runTestFunction($myfunc, ...$args) {


// Create config object
$config = new ClientConfig($access_key, $secret_key, $endpoint, $secure);

$config = new ClientConfig($GLOBALS['access_key'], $GLOBALS['secret_key'],
$GLOBALS['endpoint'], $GLOBALS['secure']);

// Create a S3Client
$s3Client = new S3Client([
Expand All @@ -837,6 +902,8 @@ function runTestFunction($myfunc, ...$args) {
'version' => '2006-03-01'
]);

// Used by initSetup
$emptyBucket = randomName();
$objects = [
randomName() => 'obj1',
randomName() => 'obj2',
Expand All @@ -858,7 +925,7 @@ function runTestFunction($myfunc, ...$args) {
runTestFunction('testMultipartUpload', $s3Client, $firstBucket, $firstObject);
runTestFunction('testMultipartUploadFailure', $s3Client, $firstBucket, $firstObject);
runTestFunction('testAbortMultipartUpload', $s3Client, $firstBucket, $firstObject);
runTestFunction('testBucketPolicy', $s3Client, $firstBucket);
runTestFunction('testBucketPolicy', $s3Client, $emptyBucket);
}
finally {
cleanupSetup($s3Client, $objects);
Expand Down