Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log test results one json object per test #123

Merged
merged 1 commit into from
Aug 26, 2017
Merged

Conversation

krisis
Copy link
Member

@krisis krisis commented Aug 25, 2017

Based on the following spec,


{
  "name":"mc",                                                     // SDK Name
  "function":"makeBucket(String bucketName)",                      // API name
  "args":"",                                                       // key value map, varName:value. Only arguements that devs may be interested in
  "duration":"15",                                                 // duration of the whole test in milli seconds
  "status":"PASS",                                                 // can be PASS, FAIL, NA
  "alert":"Information like whether this is a Blocker/ Gateway, Server etc can go here",
  "message":" descriptive error message"                           // error related, human readable  message. Should be taken care of if present
  "error":"stack-trace/exception message(only in case of failure)" // actual low level exception/error thrown by the program
}

Fixes #112

@nitisht nitisht added this to the Current milestone Aug 25, 2017
Copy link
Contributor

@nitisht nitisht left a comment

Choose a reason for hiding this comment

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

Tested locally, LGTM with one small comment

@nitisht
Copy link
Contributor

nitisht commented Aug 25, 2017

ms can be removed from the duration section, unit is implicit.

Current output:

{
  "name": "aws-sdk-php",
  "function": "getBucketLocation ( array $params = [] )",
  "args": {
    "Bucket": "aws-sdk-php-bucket-20413"
  },
  "duration": "5ms",
  "status": "PASS"
}
{
  "name": "aws-sdk-php",
  "function": "listBuckets ( array $params = [] )",
  "args": [],
  "duration": "8ms",
  "status": "PASS"
}
{
  "name": "aws-sdk-php",
  "function": "listObjects ( array $params = [] )",
  "args": {
    "Bucket": "aws-sdk-php-bucket-20413",
    "Object": "obj1"
  },
  "duration": "47ms",
  "status": "PASS"
}
{
  "name": "aws-sdk-php",
  "function": "listMultipartUploads ( array $params = [] )",
  "args": {
    "Bucket": "aws-sdk-php-bucket-20413",
    "Object": "obj1"
  },
  "duration": "159ms",
  "status": "PASS"
}
{
  "name": "aws-sdk-php",
  "function": "headBucket ( array $params = [] )",
  "args": [
    "aws-sdk-php-bucket-20413",
    "aws-sdk-php-bucket-10432"
  ],
  "duration": "11ms",
  "status": "PASS"
}
{
  "name": "aws-sdk-php",
  "function": "headObject ( array $params = [] )",
  "args": {
    "aws-sdk-php-bucket-20413": "obj1",
    "aws-sdk-php-bucket-10432": "obj2"
  },
  "duration": "5ms",
  "status": "PASS"
}
{
  "name": "aws-sdk-php",
  "function": "getObject ( array $params = [] )",
  "args": {
    "Bucket": "aws-sdk-php-bucket-20413",
    "Object": "obj1"
  },
  "duration": "11ms",
  "status": "PASS"
}
{
  "name": "aws-sdk-php",
  "function": "copyObject ( array $params = [] )",
  "args": {
    "Bucket": "aws-sdk-php-bucket-20413",
    "Object": "obj1"
  },
  "duration": "13ms",
  "status": "PASS"
}
{
  "name": "aws-sdk-php",
  "function": "deleteObjects (array $params = [] )",
  "args": {
    "Bucket": "aws-sdk-php-bucket-20413",
    "Object": "obj1"
  },
  "duration": "23ms",
  "status": "PASS"
}
{
  "name": "aws-sdk-php",
  "function": "anonDeleteObjects ( array $params = [] )",
  "args": {
    "Bucket": "aws-sdk-php-bucket-20413",
    "Object": "obj1"
  },
  "duration": "34ms",
  "status": "PASS"
}
{
  "name": "aws-sdk-php",
  "function": "createMultipartUpload ( array $params = [] )",
  "args": {
    "Bucket": "aws-sdk-php-bucket-20413",
    "Object": "obj1"
  },
  "duration": "259ms",
  "status": "PASS"
}
{
  "name": "aws-sdk-php",
  "function": "uploadPart ( array $params = [] )",
  "args": {
    "Bucket": "aws-sdk-php-bucket-20413",
    "Object": "obj1"
  },
  "duration": "154ms",
  "status": "PASS"
}
{
  "name": "aws-sdk-php",
  "function": "abortMultipartupload ( array $params = [] )",
  "args": {
    "Bucket": "aws-sdk-php-bucket-20413",
    "Object": "obj1"
  },
  "duration": "32ms",
  "status": "PASS"
}
{
  "name": "aws-sdk-php",
  "function": "getBucketPolicy ( array $params = [] )",
  "args": {
    "Bucket": "aws-sdk-php-bucket-42310"
  },
  "duration": "57ms",
  "status": "PASS"
}

"duration" => sprintf("%dms", ($end_time - $start_time) * 1000), // elapsed time in ms
"status" => $status,
];
if ($error !== "") {
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be ($error != "") ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I preferred !== over != for the following reason.

Example | Name | Result
$a !== $b | Not identical | TRUE if $a is not equal to $b, or they are not of the same type.

Ref: https://secure.php.net/manual/en/language.operators.comparison.php

Copy link
Contributor

Choose a reason for hiding this comment

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

got it. 👍

"duration" => sprintf("%d", ($end_time - $start_time) * 1000), // elapsed time in ms
"status" => $status,
];
if ($error !== "") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I have a single comment and request for a change.
Although it may not be that intuitive, the decision made for the spec dictates...
"error" field is for low level error information like stack trace info etc., and the "message" filed is for error messages.

Spec:

  :
  :
  :
  "alert":"Information like whether this is a Blocker/ Gateway, Server etc can go here",
  "message":" descriptive error message"                           // error related, human readable  message. Should be taken care of if present
  "error":"stack-trace/exception message(only in case of failure)" // actual low level exception/error thrown by the program

Please replace error for message.

@@ -143,7 +143,8 @@ function runExceptionalTests($s3Client, $apiCall, $exceptionMatcher, $exceptionP
function testListBuckets(S3Client $s3Client) {
$buckets = $s3Client->listBuckets();
foreach ($buckets['Buckets'] as $bucket){
echo $bucket['Name']."\n";
// Uncomment the following line during debugging.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it would be better to define a debug mode, that can be turned on and off, in the code to eliminate manually commenting out all the debug print out/echo lines one by one when done testing and the opposite when debugging.

https://stackoverflow.com/questions/10397454/php-turn-on-off-able-function-to-print-debugging-messages

Here is one way to achieve it:

$debugmode = true;

interface Debugger {
    public function out($data);
}

class EchoDebugger implements Debugger {
    public function out($data) {
        echo $data;
    }
}

class NullDebugger implements Debugger {
    public function out($data) {
        // Do nothing
    }
}

if($debugmode)
    $debugger = new EchoDebugger();
else
    $debugger = new NullDebugger();

$debugger->out('This will be output if $debugmode is true');

runTestFunction('testBucketPolicy', $s3Client, $emptyBucket);
$testParams = ['Bucket' => $firstBucket, 'Object' => $firstObject];
runTestFunction($s3Client, 'testGetBucketLocation', "getBucketLocation ( array \$params = [] )", ['Bucket' => $firstBucket]);
runTestFunction($s3Client, 'testListBuckets', "listBuckets ( array \$params = [] )", []);
Copy link
Collaborator

@ebozduman ebozduman Aug 25, 2017

Choose a reason for hiding this comment

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

PHP function definition supports default parameter values.
So, defining runtestFunction as:
function runTestFunction($s3Client, $myfunc, $fnSignature, $args) {
=>
function runTestFunction($s3Client, $myfunc, $fnSignature, $args = []) {

enables us not to specify a value for args, when there is nothing to provide during the function call.
runTestFunction($s3Client, 'testListBuckets', "listBuckets ( array \$params = [] )", []);
=>
runTestFunction($s3Client, 'testListBuckets', "listBuckets ( array \$params = [] )");

* @param args parameters to be passed to test function
*
* @return void
*/
function runTestFunction($myfunc, ...$args) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor comment in naming the function runTestFunction.
No need to have Function in the name.
runTest sounds better and good enough to me.

Based on the following spec,
```

{
  "name":"mc",                                                     // SDK Name
  "function":"makeBucket(String bucketName)",                      // API name
  "args":"",                                                       // key value map, varName:value. Only arguements that devs may be interested in
  "duration":"15",                                                 // duration of the whole test in milli seconds
  "status":"PASS",                                                 // can be PASS, FAIL, NA
  "alert":"Information like whether this is a Blocker/ Gateway, Server etc can go here",
  "message":" descriptive error message"                           // error related, human readable  message. Should be taken care of if present
  "error":"stack-trace/exception message(only in case of failure)" // actual low level exception/error thrown by the program
}

```
Copy link
Collaborator

@ebozduman ebozduman left a comment

Choose a reason for hiding this comment

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

LGTM

@nitisht nitisht merged commit 921ffae into minio:master Aug 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants