public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Michael Goldish <mgoldish@redhat.com>
Cc: kvm@vger.kernel.org, David Huff <dhuff@redhat.com>
Subject: Re: [PATCH][KVM_AUTOTEST] Added functionality to the preprocessor to run scripts
Date: Wed, 03 Jun 2009 21:17:09 +0300	[thread overview]
Message-ID: <4A26BE25.1060509@redhat.com> (raw)
In-Reply-To: <597666885.1130601244052338415.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com>

Michael Goldish wrote:
>> I think it's very rare to want to let the test continue even if some 
>> command fails.
>>
>> Can you give examples?
>>     
>
> Some commands are not critical, like one that converts the screendumps
> from PPM to PNG format. We don't want to fail the test if you don't have
> ImageMagick installed.
>   

I think you don't want to run the test at all in that case.  But if you 
do, you shouldn't invoke ImageMagick if you don't have it installed.  
Otherwise you can't distinguish between failure due to a corrupted 
source image, out of disk space, or ImageMagick not installed.

Ignoring errors is usually a bug.

> A similar function used for remote commands is sometimes used for checking
> if a file exists on the guest and getting its size at the same time,
> using ls. If the file doesn't exist we should SCP it into the guest, not
> fail the test.
>   

Again it doesn't distinguish between real errors and 'file does not 
exist'.  Use something like 'if test -f file; then ls -l file; else echo 
missing; fi'.

You can use rsync to implement 'copy unless exists'.

>>
>>   try:
>>      code
>>      code
>>      code
>>   except e:
>>      raise ChainedException('exception while running migration test',
>> e)
>>
>> Instead of checking each code line, you provide a wrapper for the
>> entire test.
>>     
>
> It's not informative to add it for the entire test, because we already know
> what test failed -- we don't need the exception string for that.
>
> Instead, we'd have to wrap small sections of the test separately and provide
> a different exception string for each. The migration test may be split to
> four sections: setup, pre-migration, the migration itself and post-migration.
> This may not be so bad, but do you still think it's a good solution?
>   

You can have a 'stage' variable and assign it your current stage, and 
use it when reporting errors.

Anything is better than a maze of ifs.

> There's also another issue: the utility functions that should raise exceptions
> don't know what they're being used for, so there can be exception string
> collisions. For example, both run_bg(), used for local processes, and
> kvm_spawn.get_command_status_output(), used for SSH commands, would say
> something like "command %s failed". It would be incorrect to hardcode a more
> specific message into any of them (in my opinion).
>
>   

The message should explain what happened, no more, no less.

>> The caller has to test for three possible outcomes.  Success, failure,
>> and 'command is running in the background'.  If your callsites don't 
>> check for all three, something's wrong.
>>     
>
> When we want the command to succeed on time, we just test for status == 0.
> If it's a nonzero integer or None, something went wrong, and we should kill
> the process just in case it's still running.
>   

But if it's nonzero it has exited already!

However, I feel I'm not making any progress, so I'll stop.  I just wish 
I could use exceptions in the code I write.

-- 
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.


  reply	other threads:[~2009-06-03 18:17 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1680667705.1130361244052268822.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com>
2009-06-03 18:05 ` [PATCH][KVM_AUTOTEST] Added functionality to the preprocessor to run scripts Michael Goldish
2009-06-03 18:17   ` Avi Kivity [this message]
     [not found] <837206814.1138871244056506696.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com>
2009-06-03 19:15 ` Michael Goldish
     [not found] <1788153169.1063471244013561944.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com>
2009-06-03  7:21 ` Michael Goldish
2009-06-03  8:13   ` Avi Kivity
     [not found] <91999434.1061671244009504146.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com>
2009-06-03  6:14 ` Michael Goldish
2009-06-03  6:45   ` Avi Kivity
2009-06-03 23:31   ` Lucas Meneghel Rodrigues
     [not found] <1222268607.226581242993156722.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com>
2009-05-22 11:58 ` [PATCH] [KVM_Autotest] " Michael Goldish
2009-05-26 16:07   ` David Huff
2009-05-26 21:08     ` [PATCH][KVM_AUTOTEST] " David Huff
2009-05-31 11:23       ` Avi Kivity
2009-05-27 17:13     ` [PATCH] [KVM_Autotest] " sudhir kumar
2009-05-21 20:22 David Huff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A26BE25.1060509@redhat.com \
    --to=avi@redhat.com \
    --cc=dhuff@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mgoldish@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox