-
Notifications
You must be signed in to change notification settings - Fork 50
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
Conversation
There was a problem hiding this 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
Current output:
|
run/core/aws-sdk-php/quick-tests.php
Outdated
"duration" => sprintf("%dms", ($end_time - $start_time) * 1000), // elapsed time in ms | ||
"status" => $status, | ||
]; | ||
if ($error !== "") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be ($error != "")
?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 !== "") { |
There was a problem hiding this comment.
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
.
run/core/aws-sdk-php/quick-tests.php
Outdated
@@ -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. |
There was a problem hiding this comment.
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.
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');
run/core/aws-sdk-php/quick-tests.php
Outdated
runTestFunction('testBucketPolicy', $s3Client, $emptyBucket); | ||
$testParams = ['Bucket' => $firstBucket, 'Object' => $firstObject]; | ||
runTestFunction($s3Client, 'testGetBucketLocation', "getBucketLocation ( array \$params = [] )", ['Bucket' => $firstBucket]); | ||
runTestFunction($s3Client, 'testListBuckets', "listBuckets ( array \$params = [] )", []); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 } ```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Based on the following spec,
Fixes #112