qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 3/4] iotests: Add @error to wait_until_completed


From: John Snow
Subject: Re: [Qemu-devel] [PATCH 3/4] iotests: Add @error to wait_until_completed
Date: Fri, 13 Sep 2019 18:53:32 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0


On 9/12/19 9:56 AM, Max Reitz wrote:
> Callers can use this new parameter to expect failure during the
> completion process.
> 
> Signed-off-by: Max Reitz <address@hidden>
> ---
>  tests/qemu-iotests/iotests.py | 18 ++++++++++++------
>  1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
> index b26271187c..300347c7c8 100644
> --- a/tests/qemu-iotests/iotests.py
> +++ b/tests/qemu-iotests/iotests.py
> @@ -745,15 +745,20 @@ class QMPTestCase(unittest.TestCase):
>          self.assert_no_active_block_jobs()
>          return result
>  
> -    def wait_until_completed(self, drive='drive0', check_offset=True, 
> wait=60.0):
> +    def wait_until_completed(self, drive='drive0', check_offset=True, 
> wait=60.0,
> +                             error=None):
>          '''Wait for a block job to finish, returning the event'''
>          while True:
>              for event in self.vm.get_qmp_events(wait=wait):
>                  if event['event'] == 'BLOCK_JOB_COMPLETED':
>                      self.assert_qmp(event, 'data/device', drive)
> -                    self.assert_qmp_absent(event, 'data/error')
> -                    if check_offset:
> -                        self.assert_qmp(event, 'data/offset', 
> event['data']['len'])
> +                    if error is None:
> +                        self.assert_qmp_absent(event, 'data/error')
> +                        if check_offset:
> +                            self.assert_qmp(event, 'data/offset',
> +                                            event['data']['len'])
> +                    else:
> +                        self.assert_qmp(event, 'data/error', error)
>                      self.assert_no_active_block_jobs()
>                      return event
>                  elif event['event'] == 'JOB_STATUS_CHANGE':
> @@ -771,7 +776,8 @@ class QMPTestCase(unittest.TestCase):
>          self.assert_qmp(event, 'data/type', 'mirror')
>          self.assert_qmp(event, 'data/offset', event['data']['len'])
>  
> -    def complete_and_wait(self, drive='drive0', wait_ready=True):
> +    def complete_and_wait(self, drive='drive0', wait_ready=True,
> +                          completion_error=None):
>          '''Complete a block job and wait for it to finish'''
>          if wait_ready:
>              self.wait_ready(drive=drive)
> @@ -779,7 +785,7 @@ class QMPTestCase(unittest.TestCase):
>          result = self.vm.qmp('block-job-complete', device=drive)
>          self.assert_qmp(result, 'return', {})
>  
> -        event = self.wait_until_completed(drive=drive)
> +        event = self.wait_until_completed(drive=drive, 
> error=completion_error)
>          self.assert_qmp(event, 'data/type', 'mirror')
>  
>      def pause_wait(self, job_id='job0'):
> 

toot toot more optional parameters. lay them at the altar of
noncommittal python design.

I completely forget what the difference between unittest.TestCase and
qtest.QEMUQtestMachine is and why they each have job management methods.

Well, OK: the VM one is a simple subclass of the general-purpose VM
machine to add some more useful stuff. the unittest one implements some
general-purpose behavior with asserts that only work in the unittest world.

Still,

It's a little fun that we've got run_job as well as cancel_and_wait,
wait_until_completed, wait_ready, wait_ready_and_cancel, pause_wait and
pause_job and they all seem to implement job run-state logic management
a little differently.

Probably no bugs there, I bet.

*cough* Not your fault, anyway, so please take this accolade:

Reviewed-by: John Snow <address@hidden>


(it's probably my fault)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]