Skip to content

Commit

Permalink
Eliminate races in t_iprop.py
Browse files Browse the repository at this point in the history
After we start kpropd, read about the initial full dump before making
changes on the master.  Avoid prodding kpropd for this read (by
shifting responsibility for the initial prod to the caller) since
kpropd doesn't sleep before its first request.

When waiting for sync, note whether we got a full propagation and
match that up with our expectations.

Use a long polling interval so kpropd doesn't wake up on its own and
confuse the test script with an extra incremental update.
  • Loading branch information
greghudson committed Oct 13, 2012
1 parent 4098aec commit da1810d
Showing 1 changed file with 31 additions and 15 deletions.
46 changes: 31 additions & 15 deletions src/tests/t_iprop.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

from k5test import *

def wait_for_prop(realm):
# Make kpropd go if it's sleeping.
realm.prod_kpropd()

# Read lines from kpropd output until we are synchronized.
# Read lines from kpropd output until we are synchronized. Error if
# full_expected is true and we didn't see a full propagation or vice
# versa.
def wait_for_prop(realm, full_expected):
output('*** Waiting for sync from kpropd\n')
full_seen = False
while True:
line = realm.read_from_kpropd()
if line == '':
Expand All @@ -19,9 +19,14 @@ def wait_for_prop(realm):

if 'KDC is synchronized' in line or 'Got incremental updates' in line:
output('*** Sync complete\n')
if full_expected and not full_seen:
fail('Expected full dump but saw only incremental')
if full_seen and not full_expected:
fail('Expected incremental prop but saw full dump')
return

if 'load process for full propagation completed' in line:
full_seen = True
# kpropd's child process has finished a DB load; make the parent
# do another iprop request. This will be unnecessary if kpropd
# is simplified to use a single process.
Expand All @@ -44,7 +49,7 @@ def wait_for_prop(realm):
'all' : { 'libdefaults' : { 'default_realm' : 'KRBTEST.COM'},
'realms' : { '$realm' : {
'iprop_enable' : 'true',
'iprop_slave_poll' : '1'
'iprop_slave_poll' : '600'
}}},
'master' : { 'realms' : { '$realm' : {
'iprop_logfile' : '$testdir/db.ulog'
Expand Down Expand Up @@ -93,14 +98,18 @@ def wait_for_prop(realm):
acl.write(realm.host_princ + '\n')
acl.close()

# Start kpropd and get a full dump from master.
realm.start_kpropd(['-d'])
wait_for_prop(realm, True)

realm.run_kadminl('modprinc -allow_tix w')
out = realm.run_as_master([kproplog, '-h'])
if 'Last serial # : 8' not in out:
fail('Update log on master has incorrect last serial number')

# Check that iprop happened.
wait_for_prop(realm)
# Get an incremental update and check that it happened.
realm.prod_kpropd()
wait_for_prop(realm, False)
out = realm.run_as_slave([kproplog, '-h'])
if 'Last serial # : 8' not in out:
fail('Update log on slave has incorrect last serial number')
Expand All @@ -111,8 +120,9 @@ def wait_for_prop(realm):
if 'Last serial # : 9' not in out:
fail('Update log on master has incorrect last serial number')

# Check that we're at sno 9 on the slave side too.
wait_for_prop(realm)
# Get an update and check that we're at sno 9 on the slave side too.
realm.prod_kpropd()
wait_for_prop(realm, False)
out = realm.run_as_slave([kproplog, '-h'])
if 'Last serial # : 9' not in out:
fail('Update log on slave has incorrect last serial number')
Expand All @@ -122,8 +132,10 @@ def wait_for_prop(realm):
out = realm.run_as_slave([kproplog, '-h'])
if 'Last serial # : None' not in out:
fail('Reset of update log on slave failed')
wait_for_prop(realm)
# Check that a full resync happened.

# Get a full resync and check the result.
realm.prod_kpropd()
wait_for_prop(realm, True)
out = realm.run_as_slave([kproplog, '-h'])
if 'Last serial # : 9' not in out:
fail('Update log on slave has incorrect last serial number')
Expand All @@ -134,7 +146,9 @@ def wait_for_prop(realm):
if 'Last serial # : 10' not in out:
fail('Update log on master has incorrect last serial number')

wait_for_prop(realm)
# Get and check an incremental update.
realm.prod_kpropd()
wait_for_prop(realm, False)
out = realm.run_as_slave([kproplog, '-h'])
if 'Last serial # : 10' not in out:
fail('Update log on slave has incorrect last serial number')
Expand All @@ -150,8 +164,10 @@ def wait_for_prop(realm):
out = realm.run_as_master([kproplog, '-h'])
if 'Last serial # : 1' not in out:
fail('Update log on master has incorrect last serial number')
wait_for_prop(realm)
# Check that a full resync happened.

# Get and check a full resync.
realm.prod_kpropd()
wait_for_prop(realm, True)
out = realm.run_as_slave([kproplog, '-h'])
if 'Last serial # : 1' not in out:
fail('Update log on slave has incorrect last serial number')
Expand Down

0 comments on commit da1810d

Please sign in to comment.