From aae29019e33e990f382b3a17b700171c382358a0 Mon Sep 17 00:00:00 2001 From: Krishnan Parthasarathi Date: Mon, 2 Oct 2017 16:39:00 -0700 Subject: [PATCH] Use waitUntil to check if bucket is deleted --- run/core/aws-sdk-php/quick-tests.php | 47 ++++++++++------------------ 1 file changed, 17 insertions(+), 30 deletions(-) diff --git a/run/core/aws-sdk-php/quick-tests.php b/run/core/aws-sdk-php/quick-tests.php index 7530b1ff..cb2559a1 100644 --- a/run/core/aws-sdk-php/quick-tests.php +++ b/run/core/aws-sdk-php/quick-tests.php @@ -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] ]; @@ -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 = [