[pkg-kolab] r1393 - pkg-kolab_testsuite

Mathieu Parent sathieu at alioth.debian.org
Sat Nov 14 18:44:28 UTC 2009


Author: sathieu
Date: 2009-11-14 18:44:28 +0000 (Sat, 14 Nov 2009)
New Revision: 1393

Modified:
   pkg-kolab_testsuite/testsuite
Log:
- testsuite structured in different steps
- included help
- Explicitely setting license to GPL2+



Modified: pkg-kolab_testsuite/testsuite
===================================================================
--- pkg-kolab_testsuite/testsuite	2009-11-14 17:58:46 UTC (rev 1392)
+++ pkg-kolab_testsuite/testsuite	2009-11-14 18:44:28 UTC (rev 1393)
@@ -1,21 +1,85 @@
 #!/usr/bin/perl
 
-# Script to test Debian native kolab packages using virtual machines.
-#
-# Usage: testsuite
+=head1 NAME
 
-# Written by Mathieu Parent <sathieu at debian.org>, 2009.
-#
-# This program is made available under the same license as the
-# kolabd package it applies to.
+testsuite - Script to test Debian native kolab packages using virtual machines.
 
+=head1 SYNOPSIS
+
+B<testsuite> [options] command [[options] command] ...
+
+=head1 ARGUMENTS
+
+=over 8
+
+=item I<bootstrap>
+
+Step 1: Bootstrap the domain
+
+=item I<preboot_install>
+
+Step 2: Install from chroot.
+
+=item I<boot>
+
+Step 3: Power on the domain
+
+=item I<install>
+
+Step 4: Install
+
+=item I<test>
+
+Step 5: Test
+
+=back
+
+=head1 OPTIONS
+
+=over 8
+
+=item B<--help>
+
+Print a brief help message and exits.
+
+=item B<--man>
+
+Prints the manual page and exits.
+
+=back
+
+=head1 COPYRIGHT AND AUTHORS
+
+Copyright (c) 2009 Mathieu Parent <math.parent at gmail.com>
+
+=head1 LICENSE
+
+This  program is free  software; you can redistribute  it and/or
+modify it  under the terms of the GNU  General Public License as
+published by the  Free Software Foundation; either version 2, or
+(at your option) any later version.
+
+This program is  distributed in the hope that it will be useful,
+but WITHOUT  ANY WARRANTY; without even the  implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You can view the  GNU General Public License, online, at the GNU
+Project's homepage; see <http://www.gnu.org/licenses/gpl.html>.
+
+=cut
+
 use strict;
 use warnings;
 
+use Getopt::Long;
+use Pod::Usage;
+
 use UUID;
 use Sys::Virt;
 
 my %config = (
+    'verbose' => '',
     'slave_count' => 1,
     'storagepooldir' => '/var/tmp/pkg-kolab_testsuite',
     
@@ -210,6 +274,7 @@
     print "* Starting:\n";
     $test_domains{$domid}->create();
 }
+
 #-------------------------------------------------------
 initial_check();
 $vmm = Sys::Virt->new(address => $config{'virt_uri'});
@@ -217,67 +282,87 @@
 while (my $dom = pop @domains) {
     push @domain_names, $dom->get_name();
 }
-#-------------------------------------------------------
 
 system("mkdir -p '".$config{'storagepooldir'}."'");
 
-#generate ssh key
-system("ssh-keygen -f '".$config{'storagepooldir'}."/key' -N ''");
+#-------------------------------------------------------
+my $o_help = 0;
+my $o_man = 0;
+my $result = GetOptions(
+    'help|?' => \$o_help,
+    'man' => \$o_man,
+    'verbose!' => $config{'verbose'},
+    '<>' => \&process,
+    ) or pod2usage(2);
 
-my $hosts = "127.0.0.1 localhost\n";
+pod2usage(-exitstatus => 0, -verbose => 2) if $o_man;
+pod2usage(-exitstatus => 0, -verbose => 1) if $o_help;
 
-for(my $domid = 0; $domid<=$config{'slave_count'}; $domid++) {
-    my $domname = "kolab_test_slave$domid";
-    $domname = "kolab_test_master" if $domid == 0;
-    print "Domain $domname:\n";
-    my $domip = domain_ip($domid, $domname);
-    $host .= "$domip    $domname.".$config{'storagepooldir'}." $domname\n"
-    #Cleaning:
-    if($domname ~~ @domain_names) {
-        print "* Domain already exists.\n";
-        my $dominfo = $vmm->get_domain_by_name($domname)->get_info();
-        if($dominfo->{'state'} == Sys::Virt::Domain::STATE_RUNNING) {
-            print "* Domain is running. Trying to shutdown";
-            $vmm->get_domain_by_name($domname)->shutdown();
-            print ".\n";
-        };
-        if($dominfo->{'state'} != Sys::Virt::Domain::STATE_SHUTOFF) {
-            print "* Domain is not shutoff, exiting.\n";
-            exit 1;
-        }
-        print "* Trying to undefine";
-        $vmm->get_domain_by_name($domname)->undefine();
-        print ".\n";
+#-------------------------------------------------------
+
+sub process
+{
+    my $action = shift;
+    
+    if ($action eq 'preboot_install') {
+        #generate common ssh key
+        system("ssh-keygen -f '".$config{'storagepooldir'}."/key' -N ''");
     }
-    domain_bootstrap($domid, $domname);
-    domain_preboot_install($domid, $domname);
-    domain_boot($domid, $domname);
-}
+    
+    my $hosts = "127.0.0.1 localhost\n";
 
-print "Phase 2:\n";
-for(my $domid = 0; $domid<=$config{'slave_count'}; $domid++) {
-    my $domname = "kolab_test_slave$domid";
-    $domname = "kolab_test_master" if $domid == 0;
-    print "Domain $domname:\n";
-    my $domip = domain_ip($domid, $domname);
-    #/etc/hosts file
-    system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip 'cat <<EOF >> /etc/hosts
+    for(my $domid = 0; $domid<=$config{'slave_count'}; $domid++) {
+        my $domname = "kolab_test_slave$domid";
+        $domname = "kolab_test_master" if $domid == 0;
+        print "Action $action for domain $domname:\n";
+        my $domip = domain_ip($domid, $domname);
+        $hosts .= "$domip    $domname.".$config{'storagepooldir'}." $domname\n";
+        if ($action eq 'bootstrap') {
+            #Cleaning:
+            if($domname ~~ @domain_names) {
+                print "* Domain already exists.\n";
+                my $dominfo = $vmm->get_domain_by_name($domname)->get_info();
+                if($dominfo->{'state'} == Sys::Virt::Domain::STATE_RUNNING) {
+                    print "* Domain is running. Trying to shutdown";
+                    $vmm->get_domain_by_name($domname)->shutdown();
+                    print ".\n";
+                };
+                if($dominfo->{'state'} != Sys::Virt::Domain::STATE_SHUTOFF) {
+                    print "* Domain is not shutoff, exiting.\n";
+                    exit 1;
+                }
+                print "* Trying to undefine";
+                $vmm->get_domain_by_name($domname)->undefine();
+                print ".\n";
+            }
+            domain_bootstrap($domid, $domname);
+        }
+        if ($action eq 'preboot_install') {
+            domain_preboot_install($domid, $domname);
+        }
+        if ($action eq 'boot') {
+            domain_boot($domid, $domname);
+        }
+        if ($action eq 'install') {
+            #/etc/hosts file
+            system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip 'cat <<EOF >> /etc/hosts
 $hosts
 EOF'");
-    #package repository
-    system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip 'cat <<EOF >> /etc/apt/sources.list
+            #package repository
+            system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip 'cat <<EOF >> /etc/apt/sources.list
 #kolab
 deb http://pkg-kolab.alioth.debian.org/packages kolab-snapshots/
 EOF'");
-    system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip 'apt-get update'");
-    
+            system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip 'apt-get update'");
+            print "Nothing to do yet\n";
+            # follow https://wiki.kolab.org/index.php/Debian_-_Administrators_-_Kolab_Installation
+        }
+        if ($action eq 'test') {
+            print "Nothing to do yet\n";
+            #apt-get install phpunit
+            #php /usr/share/php/tests/Kolab_Filter/Horde/Kolab/Filter/AllTests.php 
+            #php /usr/share/php/tests/Kolab_FreeBusy/Horde/Kolab/FreeBusy/AllTests.php 
+        }
+    }
 }
 
-#then, on each VM:
-# follow https://wiki.kolab.org/index.php/Debian_-_Administrators_-_Kolab_Installation
-
-#apt-get install phpunit
-#php /usr/share/php/tests/Kolab_Filter/Horde/Kolab/Filter/AllTests.php 
-#php /usr/share/php/tests/Kolab_FreeBusy/Horde/Kolab/FreeBusy/AllTests.php 
-
-




More information about the pkg-kolab-devel mailing list