Changeset 590

Show
Ignore:
Timestamp:
06/20/07 23:01:20 (1 year ago)
Author:
kindlund
Message:

Updated VM unit tests to support configurable user prompts.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • honeyclient/trunk/lib/HoneyClient/Manager/VM.pm

    r588 r590  
    355355=begin testing 
    356356 
     357# Make sure ExtUtils::MakeMaker loads. 
     358BEGIN { use_ok('ExtUtils::MakeMaker', qw(prompt)) or diag("Can't load ExtUtils::MakeMaker package.  Check to make sure the package library is correctly listed within the path."); } 
     359require_ok('ExtUtils::MakeMaker'); 
     360can_ok('ExtUtils::MakeMaker', 'prompt'); 
     361use ExtUtils::MakeMaker qw(prompt); 
     362 
    357363# Generate a notice, to clarify our assumptions. 
    358 diag("Note: These unit tests *expect* the VMware Server / GSX daemon to be operational on this system beforehand."); 
     364diag("About to run basic unit tests."); 
     365diag("Note: These tests *expect* VMware Server or VMware GSX to be installed and running on this system beforehand."); 
     366 
     367my $question; 
     368$question = prompt("# Do you want to run basic tests?", "yes"); 
     369if ($question !~ /^y.*/i) { 
     370    exit; 
     371
    359372 
    360373# Make sure Log::Log4perl loads 
     
    500513use Thread::Semaphore; 
    501514 
    502 # TODO: Remove this once unit testing should actually be used. 
    503 # Ideally, this should be handled programmatically, based upon user prompt. 
    504 #exit; 
    505  
     515diag("About to run extended tests."); 
    506516# Generate a notice, to inform the tester that these tests are not 
    507517# exactly quick. 
    508 diag("Note: These unit tests will take *significant* time to complete (10-30 minutes)."); 
     518diag("Note: These extended tests will take *significant* time to complete (10-30 minutes)."); 
     519 
     520my $question = prompt("# Do you want to run extended tests?", "no"); 
     521if ($question !~ /^y.*/i) { 
     522    exit; 
     523
    509524 
    510525=end testing 
  • honeyclient/trunk/lib/HoneyClient/Manager/VM/Clone.pm

    r589 r590  
    218218use VMware::VmPerl qw(VM_EXECUTION_STATE_ON VM_EXECUTION_STATE_OFF VM_EXECUTION_STATE_STUCK VM_EXECUTION_STATE_SUSPENDED); 
    219219 
    220 # XXX: FIX THIS 
    221220# Make sure the module loads properly, with the exportable 
    222221# functions shared. 
    223222BEGIN { use_ok('HoneyClient::Manager::VM::Clone') or diag("Can't load HoneyClient::Manager::VM::Clone package.  Check to make sure the package library is correctly listed within the path."); } 
    224223require_ok('HoneyClient::Manager::VM::Clone'); 
    225 can_ok('HoneyClient::Manager::VM::Clone', 'new'); 
    226 can_ok('HoneyClient::Manager::VM::Clone', 'drive'); 
    227 can_ok('HoneyClient::Manager::VM::Clone', 'isFinished'); 
    228 can_ok('HoneyClient::Manager::VM::Clone', 'next'); 
    229 can_ok('HoneyClient::Manager::VM::Clone', 'status'); 
    230224use HoneyClient::Manager::VM::Clone; 
    231225 
     
    424418Creates a new Clone object, which contains a hashtable 
    425419containing any of the supplied "param => value" arguments. 
    426 Upon creation, the Clone object clones the supplied master VM. 
    427420 
    428421I<Inputs>: 
     
    549542 
    550543    # Set the master VM. 
     544    $LOG->info("Setting VM (" . $self->{'master_vm_config'} . ") as master."); 
    551545    my $som = $self->{'_vm_handle'}->setMasterVM(config => $self->{'master_vm_config'}); 
    552546    if (!$som->result()) { 
     
    564558=pod 
    565559 
    566 =head2 $object->drive() 
     560=head2 $object->start() 
    567561 
    568562=over 4 
    569563 
    570 Drives the back-end application for one iteration, updating the 
    571 corresponding internal object state with information obtained 
    572 from driving this application for one iteration. 
    573  
    574 I<Output>: The updated Driver B<$object>, containing state information 
    575 from driving the application for one iteration.  Will croak if 
    576 operation fails. 
     564If not previously called, this method creates a new clone VM 
     565from the supplied master VM.  Furthermore, this method will power 
     566on the clone, and wait until the clone VM has fully booted and 
     567has an operational Agent daemon running on it. 
     568 
     569During this power on process, the name, MAC address, and  
     570IP address of the running clone are recorded in the object. 
     571 
     572I<Output>: The updated Clone B<$object>, containing state information 
     573from starting the clone VM.  Will croak if this operation fails. 
    577574 
    578575=back 
    579576 
     577# XXX: FINISH THIS 
    580578#=begin testing 
    581579# 
     
    588586=cut 
    589587 
    590 sub drive { 
    591     # Get the class name. 
    592     my $self = shift; 
     588sub start { 
     589    # Extract arguments. 
     590    my ($self, %args) = @_; 
     591 
     592    # Sanity check: Make sure we've been fed an object. 
     593    unless (ref($self)) { 
     594        $LOG->error("Error: Function must be called in reference to a " . 
     595                    __PACKAGE__ . "->new() object!"); 
     596        Carp::croak "Error: Function must be called in reference to a " . 
     597                    __PACKAGE__ . "->new() object!"; 
     598    } 
    593599     
    594     # Check to see if the class name is inherited or defined. 
    595     my $class = ref($self) || $self; 
    596  
    597     # Emit generic "not implemented" error message. 
    598     $LOG->error($class . "->drive() is not implemented!"); 
    599     Carp::croak "Error: " . $class . "->drive() is not implemented!\n"; 
     600    # Temporary variable to hold SOAP Object Message. 
     601    my $som = undef; 
     602 
     603    # Perform the quick clone operation. 
     604    $LOG->info("Quick cloning master VM (" . $self->{'master_vm_config'} . ")."); 
     605    $som = $self->{'_vm_handle'}->quickCloneVM(src_config => $self->{'master_vm_config'}); 
     606    if (!$som->result()) { 
     607        $LOG->fatal("Unable to quick clone master VM (" . $self->{'master_vm_config'} . ")."); 
     608        Carp::croak "Unable to quick clone master VM (" . $self->{'master_vm_config'} . ")."; 
     609    } 
    600610} 
    601611 
  • honeyclient/trunk/t/honeyclient_manager_vm.t

    r589 r590  
    99# =begin testing 
    1010{ 
     11# Make sure ExtUtils::MakeMaker loads. 
     12BEGIN { use_ok('ExtUtils::MakeMaker', qw(prompt)) or diag("Can't load ExtUtils::MakeMaker package.  Check to make sure the package library is correctly listed within the path."); } 
     13require_ok('ExtUtils::MakeMaker'); 
     14can_ok('ExtUtils::MakeMaker', 'prompt'); 
     15use ExtUtils::MakeMaker qw(prompt); 
     16 
    1117# Generate a notice, to clarify our assumptions. 
    12 diag("Note: These unit tests *expect* the VMware Server / GSX daemon to be operational on this system beforehand."); 
     18diag("About to run basic unit tests."); 
     19diag("Note: These tests *expect* VMware Server or VMware GSX to be installed and running on this system beforehand."); 
     20 
     21my $question; 
     22$question = prompt("# Do you want to run basic tests?", "yes"); 
     23if ($question !~ /^y.*/i) { 
     24    exit; 
     25
    1326 
    1427# Make sure Log::Log4perl loads 
     
    154167use Thread::Semaphore; 
    155168 
    156 # TODO: Remove this once unit testing should actually be used. 
    157 # Ideally, this should be handled programmatically, based upon user prompt. 
    158 #exit; 
    159  
     169diag("About to run extended tests."); 
    160170# Generate a notice, to inform the tester that these tests are not 
    161171# exactly quick. 
    162 diag("Note: These unit tests will take *significant* time to complete (10-30 minutes)."); 
     172diag("Note: These extended tests will take *significant* time to complete (10-30 minutes)."); 
     173 
     174my $question = prompt("# Do you want to run extended tests?", "no"); 
     175if ($question !~ /^y.*/i) { 
     176    exit; 
     177
    163178} 
    164179 
  • honeyclient/trunk/t/honeyclient_manager_vm_clone.t

    r589 r590  
    5959use VMware::VmPerl qw(VM_EXECUTION_STATE_ON VM_EXECUTION_STATE_OFF VM_EXECUTION_STATE_STUCK VM_EXECUTION_STATE_SUSPENDED); 
    6060 
    61 # XXX: FIX THIS 
    6261# Make sure the module loads properly, with the exportable 
    6362# functions shared. 
    6463BEGIN { use_ok('HoneyClient::Manager::VM::Clone') or diag("Can't load HoneyClient::Manager::VM::Clone package.  Check to make sure the package library is correctly listed within the path."); } 
    6564require_ok('HoneyClient::Manager::VM::Clone'); 
    66 can_ok('HoneyClient::Manager::VM::Clone', 'new'); 
    67 can_ok('HoneyClient::Manager::VM::Clone', 'drive'); 
    68 can_ok('HoneyClient::Manager::VM::Clone', 'isFinished'); 
    69 can_ok('HoneyClient::Manager::VM::Clone', 'next'); 
    70 can_ok('HoneyClient::Manager::VM::Clone', 'status'); 
    7165use HoneyClient::Manager::VM::Clone; 
    7266 
  • honeyclient/trunk/t/test_vm/winXPPro.vmx

    r276 r590  
    2525redoLogDir = "." 
    2626 
    27 uuid.location = "56 4d 47 6f 36 7b e1 31-d6 26 da 2e 4f a7 f0 c4
    28 uuid.bios = "56 4d 47 6f 36 7b e1 31-d6 26 da 2e 4f a7 f0 c4
     27uuid.location = "56 4d 63 26 ef 9e 06 a5-3e 05 81 73 13 e7 c2 0a
     28uuid.bios = "56 4d 63 26 ef 9e 06 a5-3e 05 81 73 13 e7 c2 0a
    2929 
    3030Ethernet0.present = "TRUE" 
    3131 
    3232Ethernet0.addressType = "generated" 
    33 ethernet0.generatedAddress = "00:0c:29:a7:f0:c4
     33ethernet0.generatedAddress = "00:0c:29:e7:c2:0a
    3434ethernet0.generatedAddressOffset = "0" 
    3535