From 97cb96b4d1944e99ecf98a5b5bf60bc66b501609 Mon Sep 17 00:00:00 2001 From: Greg Hudson Date: Fri, 12 Oct 2012 16:12:48 -0400 Subject: Make t_iprop.py faster and more robust Catch SIGUSR1 in iprop-mode kpropd so that we can use it to interrupt sleeps and make kpropd do an iprop request immediately. In k5test.py, add prod_kpropd and read_from_kpropd methods to allow test scripts to send a SIGUSR1 to kpropd and to read its stdout/stderr output; also allow the test script to specify additional arguments when starting kpropd. In t_iprop.py, start kpropd with -d and, instead of sleeping, read kpropd output until we see an indication that kpropd is in sync with the master. To avoid delays, prod kpropd before waiting for sync and after a completed full prop. --- src/util/k5test.py | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'src/util/k5test.py') diff --git a/src/util/k5test.py b/src/util/k5test.py index 4fd8cf7526..3400154ca8 100644 --- a/src/util/k5test.py +++ b/src/util/k5test.py @@ -251,14 +251,26 @@ Scripts may use the following realm methods and attributes: * realm.start_kadmind(): Start a kadmind with the realm's master KDC environment. Errors if a kadmind is already running. -* realm.start_kpropd(): Start a kpropd with the realm's slave KDC - environment. Errors if a kpropd is already running. - * realm.stop_kadmind(): Stop the kadmind process. Errors if no kadmind is running. -* realm.stop(): Stop any KDC and kadmind processes running on behalf - of the realm. +* realm.start_kpropd(args=[]): Start a kpropd with the realm's slave + KDC environment. Errors if a kpropd is already running. If args is + given, it contains a list of additional kpropd arguments. + +* realm.stop_kpropd(): Stop the kpropd process. Errors if no kpropd + is running. + +* realm.read_from_kpropd(): Read a line from the stdout or stderr of + the kpropd process. Most useful if kpropd is started with the -d + option. + +* realm.prod_kpropd(): Send a USR1 signal to a kpropd to make it stop + sleeping and perform an iprop request. kpropd must be running in + iprop mode or a USR1 will simply terminate it. + +* realm.stop(): Stop any daemon processes running on behalf of the + realm. * realm.addprinc(princname, password=None): Using kadmin.local, create a principle in the KDB named princname, with either a random or @@ -910,7 +922,7 @@ class K5Realm(object): stop_daemon(self._kadmind_proc) self._kadmind_proc = None - def start_kpropd(self): + def start_kpropd(self, args=[]): global krb5kdc assert(self._kpropd_proc is None) slavedump_path = os.path.join(self.testdir, 'incoming-slave-datatrans') @@ -919,7 +931,7 @@ class K5Realm(object): str(self.portbase + 3), '-f', slavedump_path, '-p', kdb5_util, - '-a', kpropdacl_path], + '-a', kpropdacl_path] + args, self.env_slave, 'ready') def stop_kpropd(self): @@ -927,6 +939,14 @@ class K5Realm(object): stop_daemon(self._kpropd_proc) self._kpropd_proc = None + def read_from_kpropd(self): + assert(self._kpropd_proc is not None) + return self._kpropd_proc.stdout.readline() + + def prod_kpropd(self): + assert(self._kpropd_proc is not None) + self._kpropd_proc.send_signal(signal.SIGUSR1) + def stop(self): if self._kdc_proc: self.stop_kdc() -- cgit