diff mbox

[KVM-AUTOTEST] KVM test: kvm_subprocess: fix a problem that arises with Python 2.6

Message ID 27af0a741350371856c3493994373435cf9f4c4d.1248444364.git.mgoldish@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michael Goldish July 24, 2009, 2:07 p.m. UTC
After launching the server the client waits for it to finish initializing.
This is done by waiting for a line of output from the server's STDOUT.
Currently, the client assumes that the first line of output coming from the
server indicates that it's done initializing.  With Python 2.4 this used to be
true, but Python 2.6 prints deprecation warnings for certain standard modules
as soon as they are imported.  This makes the client think the server is ready
when in fact it isn't.

This patch fixes the problem by waiting for a certain unique output line from
the server instead of just waiting for the first line.

Signed-off-by: Michael Goldish <mgoldish@redhat.com>
---
 client/tests/kvm/kvm_subprocess.py |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

Comments

Lucas Meneghel Rodrigues July 27, 2009, 1:36 p.m. UTC | #1
On Fri, Jul 24, 2009 at 11:07 AM, Michael Goldish<mgoldish@redhat.com> wrote:
> After launching the server the client waits for it to finish initializing.
> This is done by waiting for a line of output from the server's STDOUT.
> Currently, the client assumes that the first line of output coming from the
> server indicates that it's done initializing.  With Python 2.4 this used to be
> true, but Python 2.6 prints deprecation warnings for certain standard modules
> as soon as they are imported.  This makes the client think the server is ready
> when in fact it isn't.
>
> This patch fixes the problem by waiting for a certain unique output line from
> the server instead of just waiting for the first line.

Great! applied.

> Signed-off-by: Michael Goldish <mgoldish@redhat.com>
> ---
>  client/tests/kvm/kvm_subprocess.py |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/client/tests/kvm/kvm_subprocess.py b/client/tests/kvm/kvm_subprocess.py
> index 413bdaa..c15e779 100644
> --- a/client/tests/kvm/kvm_subprocess.py
> +++ b/client/tests/kvm/kvm_subprocess.py
> @@ -212,7 +212,8 @@ class kvm_spawn:
>             sub.stdin.write("%s\n" % ",".join(self.readers))
>             sub.stdin.write("%s\n" % command)
>             # Wait for the server to complete its initialization
> -            sub.stdout.readline()
> +            while not "Server %s ready" % self.id in sub.stdout.readline():
> +                pass
>
>         # Open the reading pipes
>         self.reader_fds = {}
> @@ -1081,7 +1082,7 @@ def _server_main():
>         file.close()
>
>         # Print something to stdout so the client can start working
> -        print "hello"
> +        print "Server %s ready" % id
>         sys.stdout.flush()
>
>         # Initialize buffers
> --
> 1.5.4.1
>
> _______________________________________________
> Autotest mailing list
> Autotest@test.kernel.org
> http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
>
diff mbox

Patch

diff --git a/client/tests/kvm/kvm_subprocess.py b/client/tests/kvm/kvm_subprocess.py
index 413bdaa..c15e779 100644
--- a/client/tests/kvm/kvm_subprocess.py
+++ b/client/tests/kvm/kvm_subprocess.py
@@ -212,7 +212,8 @@  class kvm_spawn:
             sub.stdin.write("%s\n" % ",".join(self.readers))
             sub.stdin.write("%s\n" % command)
             # Wait for the server to complete its initialization
-            sub.stdout.readline()
+            while not "Server %s ready" % self.id in sub.stdout.readline():
+                pass
 
         # Open the reading pipes
         self.reader_fds = {}
@@ -1081,7 +1082,7 @@  def _server_main():
         file.close()
 
         # Print something to stdout so the client can start working
-        print "hello"
+        print "Server %s ready" % id
         sys.stdout.flush()
 
         # Initialize buffers