Skip to content

Commit

Permalink
Remove createBucket retry mechanism for Azure.
Browse files Browse the repository at this point in the history
The test is applicable only to minio server and that can be tested
without creating the bucket again. This allows us to remove the retry
creation of bucket on failure for about 30s.
  • Loading branch information
Krishnan Parthasarathi committed Oct 19, 2017
1 parent e4d16b2 commit 4454078
Showing 1 changed file with 20 additions and 30 deletions.
50 changes: 20 additions & 30 deletions run/core/aws-sdk-php/quick-tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -863,31 +863,17 @@ function testBucketPolicy($s3Client, $params) {
throw new Exception('deleteBucket API failed for ' .
$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);
}
try {
$s3Client->getBucketPolicy(['Bucket' => $bucket]);
} catch (AWSException $e) {
switch ($e->getAwsErrorCode()) {
case 'NoSuchBucket':
break;
}
}

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

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

$status = "NA";
$message = "Not Implemented";
} catch (Exception $e) {
// This exception handler handles high-level custom exceptions.
$status = "FAIL";
$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 4454078

Please sign in to comment.