[tracker/sam/functional-tests-quiet] funcional-tests: Terminate Tracker processes before the message bus
- From: Sam Thursfield <sthursfield src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/sam/functional-tests-quiet] funcional-tests: Terminate Tracker processes before the message bus
- Date: Tue, 10 Sep 2019 10:15:59 +0000 (UTC)
commit 1d90a920352bd7c42259a3493633bd6c9514dbbd
Author: Sam Thursfield <sam afuera me uk>
Date: Tue Sep 10 12:14:35 2019 +0200
funcional-tests: Terminate Tracker processes before the message bus
This reduces the volume of criticals like this that we see in the log
output:
(tracker-miner-fs:14955): GLib-GIO-CRITICAL **: 11:38:40.386: Error while sending AddMatch() message:
The connection is closed
I did still see one test that output a bunch of similar criticals from
tracker-extract.
utils/trackertestutils/dbusdaemon.py | 24 ++++++++++++++++++++++++
utils/trackertestutils/helpers.py | 20 ++++++++++++++++++++
2 files changed, 44 insertions(+)
---
diff --git a/utils/trackertestutils/dbusdaemon.py b/utils/trackertestutils/dbusdaemon.py
index e937cd05b..4633fa176 100644
--- a/utils/trackertestutils/dbusdaemon.py
+++ b/utils/trackertestutils/dbusdaemon.py
@@ -17,6 +17,7 @@
from gi.repository import Gio
+from gi.repository import GLib
import logging
import os
@@ -192,6 +193,29 @@ class DBusDaemon:
self.stop()
def ping_sync(self):
+ """Call the daemon Ping() method to check that it is alive."""
self._gdbus_connection.call_sync(
'org.freedesktop.DBus', '/', 'org.freedesktop.DBus', 'GetId',
None, None, Gio.DBusCallFlags.NONE, 10000, None)
+
+ def list_names_sync(self):
+ """Get the name of every client connected to the bus."""
+ conn = self.get_connection()
+ result = conn.call_sync('org.freedesktop.DBus',
+ '/org/freedesktop/DBus',
+ 'org.freedesktop.DBus', 'ListNames', None,
+ GLib.VariantType('(as)'),
+ Gio.DBusCallFlags.NONE, -1, None)
+ return result[0]
+
+ def get_connection_unix_process_id_sync(self, name):
+ """Get the process ID for one of the names connected to the bus."""
+ conn = self.get_connection()
+ result = conn.call_sync('org.freedesktop.DBus',
+ '/org/freedesktop/DBus',
+ 'org.freedesktop.DBus',
+ 'GetConnectionUnixProcessID',
+ GLib.Variant('(s)', [name]),
+ GLib.VariantType('(u)'),
+ Gio.DBusCallFlags.NONE, -1, None)
+ return result[0]
diff --git a/utils/trackertestutils/helpers.py b/utils/trackertestutils/helpers.py
index 45fa67242..7b374efbd 100644
--- a/utils/trackertestutils/helpers.py
+++ b/utils/trackertestutils/helpers.py
@@ -24,6 +24,7 @@ from gi.repository import GLib
import atexit
import logging
import os
+import psutil
from . import dbusdaemon
from . import mainloop
@@ -463,6 +464,25 @@ class TrackerDBusSandbox:
self.daemon.start_if_needed(self.dbus_daemon_config_file, env=env)
def stop(self):
+ tracker_processes = []
+
+ log.info("Looking for active Tracker processes on the bus")
+ for busname in self.daemon.list_names_sync():
+ if busname.startswith('org.freedesktop.Tracker1'):
+ pid = self.daemon.get_connection_unix_process_id_sync(busname)
+ tracker_processes.append(psutil.Process(pid))
+
+ log.info("Stopping %i Tracker processes", len(tracker_processes))
+ for p in tracker_processes:
+ p.terminate()
+ psutil.wait_procs(tracker_processes)
+
+ # We need to wait until Tracker processes have stopped before we
+ # terminate the D-Bus daemon, otherwise lots of criticals like this
+ # appear in the log output:
+ #
+ # (tracker-miner-fs:14955): GLib-GIO-CRITICAL **: 11:38:40.386: Error while sending AddMatch()
message: The connection is closed
+
log.info("Stopping D-Bus daemon for sandbox.")
self.daemon.stop()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]