Testing: In IP allocation simulation count total number of events.
authorMartin Schwenke <martin@meltin.net>
Sun, 1 Aug 2010 01:39:30 +0000 (11:39 +1000)
committerMartin Schwenke <martin@meltin.net>
Sun, 1 Aug 2010 01:39:30 +0000 (11:39 +1000)
This starts at -1 because we always have to do the initial allocation.

No longer print event number for each event by default, only when
verbose is enabled.

Signed-off-by: Martin Schwenke <martin@meltin.net>
(This used to be ctdb commit c9a761726d141bcaa8ba7851150f71a8130b473a)

ctdb/tests/takeover/ctdb_takeover.py

index a25ecee5678b5b9ec55205420ee01907236d16bf..3c5a69da52bb9204f28b2d662b3cc0bc8e6d6ba9 100755 (executable)
@@ -119,6 +119,7 @@ class Cluster(object):
         self.ip_moves = []
         self.grat_ip_moves = []
         self.imbalance = []
+        self.events = -1
 
     def __str__(self):
         return "\n".join(["%2d %s %s" %
@@ -130,6 +131,7 @@ class Cluster(object):
 
     def print_statistics(self):
         print_begin("STATISTICS")
+        print "Events:              %6d" % self.events
         print "Total IP moves:      %6d" % sum(self.ip_moves)
         print "Gratuitous IP moves: %6d" % sum(self.grat_ip_moves)
         print "Max imbalance:       %6d" % max(self.imbalance)
@@ -197,8 +199,8 @@ class Cluster(object):
     def random_iterations(self):
         i = 1
         while i <= options.iterations:
-            print_begin("EVENT %d" % i)
-            print_end()
+            verbose_begin("EVENT %d" % i)
+            verbose_end()
             self.do_something_random()
             if self.recover() and options.exit > 0:
                 break
@@ -340,6 +342,8 @@ class Cluster(object):
 
         global options
 
+        self.events += 1
+
         # Don't bother with the num_healthy stuff.  It is an
         # irrelevant detail.