Blob Blame History Raw
From 4f72c02d0f432519f9d5606bd99007fd685482a7 Mon Sep 17 00:00:00 2001
From: Nalin Dahyabhai <nalin@redhat.com>
Date: Wed, 29 Jun 2016 17:37:09 -0400
Subject: [PATCH] Fix a flakiness in the 028-dbus test

When walking all of the exposed APIs from python, we were calling the
'resubmit' method on a certificate, and not waiting for the churn in
state that doing so would create to settle down before continuing.

This meant that the test script might have exited before the certmonger
process that was waiting on it finished saving the new certificate that
it obtained from resubmitting the rquest, so the process wouldn't
reliably log that it had obtained a new certificate.

Spotted by Jan Cholasta.
---
 tests/028-dbus/expected.out | 1 +
 tests/028-dbus/walk.py      | 8 ++++++++
 2 files changed, 9 insertions(+)

diff --git a/tests/028-dbus/expected.out b/tests/028-dbus/expected.out
index b2660317b3102373f2a5a877a7224f727929412c..93cc4d184524c4b1aeba02a650c94d832462c236 100644
--- a/tests/028-dbus/expected.out
+++ b/tests/028-dbus/expected.out
@@ -1,4 +1,5 @@
 Certificate in file "${tmpdir}/test.crt" issued by CA and saved.
+Certificate in file "${tmpdir}/test.crt" issued by CA and saved.
 [[ getcert ]]
 State MONITORING, stuck: no.
 Number of certificates and requests being tracked: 1.
diff --git a/tests/028-dbus/walk.py b/tests/028-dbus/walk.py
index 0bf54b477220aef901340c1d24100391348226a7..f60ca934fd934e21cec027bad5c53e0f12ccb36d 100644
--- a/tests/028-dbus/walk.py
+++ b/tests/028-dbus/walk.py
@@ -3,6 +3,7 @@ import dbus
 import xml.etree.ElementTree
 import os
 import sys
+import time
 
 bus = dbus.SessionBus()
 
@@ -110,6 +111,13 @@ def examine_method(objpath, interface, method, idata):
 		# We're in FIXME territory.
 		print('FIXME: need support for "%s"' % method)
 		return False
+	# If we caused things to start churning, wait for them to settle.
+        if method == 'resubmit':
+            props = dbus.Interface(o, 'org.freedesktop.DBus.Properties')
+            prop = props.Get(interface, 'status')
+            while prop != 'MONITORING':
+                time.sleep(1)
+                prop = props.Get(interface, 'status')
 	return True
 
 def iget(child, proxy, interface, prop):
-- 
2.7.4