krb5 commit: Verify iprop test results more thoroughly

Greg Hudson ghudson at MIT.EDU
Tue Jan 22 22:35:26 EST 2013


https://github.com/krb5/krb5/commit/c865516764c0bc39e8c8e703db1a218a15a65ba4
commit c865516764c0bc39e8c8e703db1a218a15a65ba4
Author: Greg Hudson <ghudson at mit.edu>
Date:   Tue Jan 22 22:12:51 2013 -0500

    Verify iprop test results more thoroughly
    
    In k5test.py, allow run_kadminl to take an environment argument.  In
    t_iprop.py, perform some queries on the slaves after each propagation
    to spot-check that it got modifications from master.  Use a helper
    function to check serial numbers for conciseness.

 src/tests/t_iprop.py |   80 ++++++++++++++++++++++----------------------------
 src/util/k5test.py   |    4 +-
 2 files changed, 37 insertions(+), 47 deletions(-)

diff --git a/src/tests/t_iprop.py b/src/tests/t_iprop.py
index 08d3872..f61279f 100644
--- a/src/tests/t_iprop.py
+++ b/src/tests/t_iprop.py
@@ -45,6 +45,15 @@ def wait_for_prop(kpropd, full_expected):
         if 'invalid return' in line:
             fail('kadmind returned invalid result')
 
+
+# Verify the iprop log last serial number against an expected value,
+# on either the master or slave.
+def check_serial(realm, expected, env=None):
+    out = realm.run([kproplog, '-h'], env=env)
+    if 'Last serial # : ' not in out:
+        fail('Unexpected serial number')
+
+
 conf = {
     'realms': {'$realm': {
             'iprop_enable': 'true',
@@ -86,9 +95,7 @@ realm.addprinc('w')
 realm.run_kadminl('modprinc -allow_tix w')
 realm.run_kadminl('modprinc +allow_tix w')
 
-out = realm.run([kproplog, '-h'])
-if 'Last serial # : 7' not in out:
-    fail('Update log on master has incorrect last serial number')
+check_serial(realm, '7')
 
 # Set up the kpropd acl file.
 acl_file = os.path.join(realm.testdir, 'kpropd-acl')
@@ -99,71 +106,54 @@ acl.close()
 # Start kpropd and get a full dump from master.
 kpropd = realm.start_kpropd(slave, ['-d'])
 wait_for_prop(kpropd, True)
+out = realm.run_kadminl('listprincs', slave)
+if longname not in out or 'wakawaka' not in out or 'w@' not in out:
+    fail('Slave does not have all principals from master')
 
+# Make a change and check that it propagates incrementally.
 realm.run_kadminl('modprinc -allow_tix w')
-out = realm.run([kproplog, '-h'])
-if 'Last serial # : 8' not in out:
-    fail('Update log on master has incorrect last serial number')
-
-# Get an incremental update and check that it happened.
+check_serial(realm, '8')
 kpropd.send_signal(signal.SIGUSR1)
 wait_for_prop(kpropd, False)
-out = realm.run([kproplog, '-h'], slave)
-if 'Last serial # : 8' not in out:
-    fail('Update log on slave has incorrect last serial number')
+check_serial(realm, '8', slave)
+out = realm.run_kadminl('getprinc w', slave)
+if 'Attributes: DISALLOW_ALL_TIX' not in out:
+    fail('Slave does not have modification from master')
 
-# Make another change.
+# Make another change and check that it propagates incrementally.
 realm.run_kadminl('modprinc +allow_tix w')
-out = realm.run([kproplog, '-h'])
-if 'Last serial # : 9' not in out:
-    fail('Update log on master has incorrect last serial number')
-
-# Get an update and check that we're at sno 9 on the slave side too.
+check_serial(realm, '9')
 kpropd.send_signal(signal.SIGUSR1)
 wait_for_prop(kpropd, False)
-out = realm.run([kproplog, '-h'], slave)
-if 'Last serial # : 9' not in out:
-    fail('Update log on slave has incorrect last serial number')
+check_serial(realm, '9', slave)
+out = realm.run_kadminl('getprinc w', slave)
+if 'Attributes:\n' not in out:
+    fail('Slave does not have modification from master')
 
 # Reset the ulog on the slave side to force a full resync to the slave.
 realm.run([kproplog, '-R'], slave)
-out = realm.run([kproplog, '-h'], slave)
-if 'Last serial # : None' not in out:
-    fail('Reset of update log on slave failed')
-
-# Get a full resync and check the result.
+check_serial(realm, 'None', slave)
 kpropd.send_signal(signal.SIGUSR1)
 wait_for_prop(kpropd, True)
-out = realm.run([kproplog, '-h'], slave)
-if 'Last serial # : 9' not in out:
-    fail('Update log on slave has incorrect last serial number')
+check_serial(realm, '9', slave)
 
-# Make another change.
+# Make another change and check that it propagates incrementally.
 realm.run_kadminl('modprinc +allow_tix w')
-out = realm.run([kproplog, '-h'])
-if 'Last serial # : 10' not in out:
-    fail('Update log on master has incorrect last serial number')
-
-# Get and check an incremental update.
+check_serial(realm, '10')
 kpropd.send_signal(signal.SIGUSR1)
 wait_for_prop(kpropd, False)
-out = realm.run([kproplog, '-h'], slave)
-if 'Last serial # : 10' not in out:
-    fail('Update log on slave has incorrect last serial number')
+check_serial(realm, '10', slave)
+out = realm.run_kadminl('getprinc w', slave)
+if 'Attributes:\n' not in out:
+    fail('Slave has different state from master')
 
 # Reset the ulog on the master side to force a full resync to all slaves.
 # XXX Note that we only have one slave in this test, so we can't really
 # test this.
 realm.run([kproplog, '-R'])
-out = realm.run([kproplog, '-h'])
-if 'Last serial # : None' not in out:
-    fail('Reset of update log on master failed')
-
-# Get and check a full resync.
+check_serial(realm, 'None')
 kpropd.send_signal(signal.SIGUSR1)
 wait_for_prop(kpropd, True)
-out = realm.run([kproplog, '-h'], slave)
-if 'Last serial # : None' not in out:
-    fail('Update log on slave has incorrect last serial number')
+check_serial(realm, 'None', slave)
 
 success('iprop tests')
diff --git a/src/util/k5test.py b/src/util/k5test.py
index 3a5f069..961ed79 100644
--- a/src/util/k5test.py
+++ b/src/util/k5test.py
@@ -939,9 +939,9 @@ class K5Realm(object):
             princ not in output):
             fail('Unexpected klist output.')
 
-    def run_kadminl(self, query):
+    def run_kadminl(self, query, env=None):
         global kadmin_local
-        return self.run([kadmin_local, '-q', query])
+        return self.run([kadmin_local, '-q', query], env=env)
 
     def prep_kadmin(self, princname=None, pw=None, flags=[]):
         if princname is None:


More information about the cvs-krb5 mailing list