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
Introduce check_shutdown for testapi #988
Introduce check_shutdown for testapi #988
Conversation
Codecov Report
@@ Coverage Diff @@
## master #988 +/- ##
===========================================
- Coverage 37.55% 26.01% -11.55%
===========================================
Files 34 34
Lines 4489 4494 +5
Branches 764 765 +1
===========================================
- Hits 1686 1169 -517
- Misses 2486 3126 +640
+ Partials 317 199 -118
Continue to review full report at Codecov.
|
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.
Overall looks good, but I think adding unit tests for it woudn't hurt
|
||
=cut | ||
|
||
sub assert_shutdown { | ||
sub check_shutdown { |
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.
You will need to use Test::MockModule, mock the query_isotovideo method from autotest to return the expected values. An example on how to do that can be seen in the testapi tests
|
||
Returns C<undef> on success, throws exception on timeout. | ||
Returns true on success and false if C<$timeout> timeout is hit. Default timeout is 60s. |
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.
An update to the pod wouldn't hurt :)
e1e251a
to
5efa53f
Compare
Looks good now that you've added tests.
|
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.
Looks pretty good so far, except for that -1
is(assert_shutdown, undef, 'assert_shutdown should return "undef" if shutdown finished before timeout is hit'); | ||
$mod->mock( | ||
read_json => sub { | ||
return {ret => -1}; |
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.
why -1 specifically?
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.
It is because I just wanted to cover the following part in check_shutdown
function:
if ($is_shutdown < 0) {
bmwqemu::diag("Backend does not implement is_shutdown - just sleeping");
sleep($timeout);
}
The check_shutdown function is added to have ability to decide on further actions in case of shutdown failure, instead of marking a test as failed immediately. In tests it might be used to make soft failure checks. Related ticket: [poo#35215](https://progress.opensuse.org/issues/35215)
5efa53f
to
112775d
Compare
@@ -9,6 +9,7 @@ use Test::Fatal; | |||
use Test::Mock::Time; | |||
use Test::Warnings; | |||
use File::Temp; | |||
use Test::Exception; |
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.
Please add this dependency to the cpanfile.
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.
Done.
112775d
to
0f4e3d6
Compare
0c3f540
to
d130cdc
Compare
d130cdc
to
59789e7
Compare
@foursixnine If the things you've mentioned are fixed now, we should merge this. |
The check_shutdown function is added to have ability to decide on further actions in case of shutdown failure, instead of marking a test as failed immediately.
In tests it might be used to make soft failure checks, for example.
Related ticket: poo#35215