Skip to content

Commit

Permalink
Verify iprop test results more thoroughly
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
greghudson committed Jan 23, 2013
1 parent 7665c06 commit c865516
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 47 deletions.
80 changes: 35 additions & 45 deletions src/tests/t_iprop.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -86,9 +95,7 @@ def wait_for_prop(kpropd, full_expected):
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')
Expand All @@ -99,71 +106,54 @@ def wait_for_prop(kpropd, full_expected):
# 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')
4 changes: 2 additions & 2 deletions src/util/k5test.py
Original file line number Diff line number Diff line change
Expand Up @@ -939,9 +939,9 @@ def klist_keytab(self, princ, keytab=None, **keywords):
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:
Expand Down

0 comments on commit c865516

Please sign in to comment.