Skip to contentSkip to conversation

KVM test: Add new module kvm_test_utils.py

PATCH Michael Goldish 1 participant 1 message Sep 14, 2009 1 message not in the archive KVM

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 857145908.38101252917938768.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com

#1 lore raw
Quoted 38 lines · ----- "Uri Lublin
Quoted 2 lines · Yolkfull Chow
Quoted 1 line · Michael Goldish

This module is meant to reduce code size by performing common test

procedures.

Quoted 5 lines

Review

Quoted 5 lines

Generally, code here should look like test code.

(quoted diff) +3 -0
+def wait_for_login(vm, nic_index=0, timeout=240):
+    """
+    Try logging into a VM repeatedly.  Stop on success or when

timeout expires.

Quoted 8 lines

Review

Quoted 8 lines
(quoted diff) +8 -0
+
+    @param vm: VM object.
+    @param nic_index: Index of NIC to access in the VM.
+    @param timeout: Time to wait before giving up.
+    @return: A shell session object.
+    """
+    logging.info("Waiting for guest to be up...")
+    session = kvm_utils.wait_for(lambda:

vm.remote_login(nic_index=nic_index),

Quoted 6 lines

Review

Quoted 3 lines
(quoted diff) +3 -0
+                                 timeout, 0, 2)
+    if not session:
+        raise error.TestFail("Could not log into guest")

Hi Michael, I think we should also add a parameter 'vm_name' for wait_for_login(). On the assumption that we boot more than one VMs,

it's

Quoted 1 line

hard to know which guest failed to login according to message

above.

Quoted 2 lines

What do you think? :-)

The VM object ("vm" parameter) "knows" its own name.
It is a good idea to add that name to log/error messages, since we do want to
run different tests (VMs) in parallel (although the logs should be also saved in
different directories/files).

Quoted 2 lines

Regards,
Uri.

Currently it would be useful for tests that use multiple VMs, not for multiple tests running in parallel, because all tests call their main VM 'vm1'. That can be changed though. In any case I agree that it's a good idea.