Skip to content

Commit

Permalink
Use waitUntil to check if bucket is deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
Krishnan Parthasarathi committed Oct 5, 2017
1 parent be7c25c commit aae2901
Showing 1 changed file with 17 additions and 30 deletions.
47 changes: 17 additions & 30 deletions run/core/aws-sdk-php/quick-tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -864,30 +864,17 @@ function testBucketPolicy($s3Client, $params) {
$bucket);

// In Minio Gateway for Azure, a container delete will take at
// least 30s to be truly deleted. Ref: https://docs.microsoft.com/en-us/rest/api/storageservices/create-container
$retries = 5;
while ($retries > 0) {
try {
$result = $s3Client->createBucket(['Bucket' => $bucket]);
} catch (Exception $e) {
$errorCode = $e->getStatusCode();
switch($errorCode) {
case HTTP_INTERNAL_ERROR:
$retries--;
sleep(30);
break;

case "409":
case HTTP_OK:
$retries = 0;
break;

default:
throw new Exception('createBucket API failed for ' .
$bucket);
}
}
// least 30s to be truly deleted.
// Ref: https://docs.microsoft.com/en-us/rest/api/storageservices/create-container
try {
$s3Client->waitUntil('BucketNotExists', ['Bucket' => $bucket]);
} catch (Exception $e) {
throw new Exception("deleteBucket " . $bucket .
" has not taken effect even after 100s");
}

$s3Client->createBucket(['Bucket' => $bucket]);

$params = [
'404' => ['Bucket' => $bucket]
];
Expand Down Expand Up @@ -991,15 +978,15 @@ function runTest($s3Client, $myfunc, $fnSignature, $args = []) {
if ($errorCode != "NotImplemented") {
$status = "FAIL";
$error = $e->getMessage();
} else {
$status = "NA";
$error = $e->getMessage();
// $fnSignature holds the specific API that is being
// tested. It is possible that functions used to create the
// test setup may not be implemented.
$alert = sprintf("%s or a related API is NOT IMPLEMENTED, see \"error\" for exact details.", $fnSignature);
}

$status = "NA";
$message = "Not Implemented";
$error = $e->getMessage();
// $fnSignature holds the specific API that is being
// tested. It is possible that functions used to create the
// test setup may not be implemented.
$alert = sprintf("%s or a related API is not implemented, see \"error\" for exact details.", $fnSignature);
} finally {
$end_time = microtime(true);
$json_log = [
Expand Down

0 comments on commit aae2901

Please sign in to comment.