--- /dev/null
+ceph 658 1 0 Jun08 ? 00:07:43 /usr/bin/ceph-mgr -f --cluster ceph --id host1 --setuser ceph --setgroup ceph
+ceph 1634 1 0 Jun08 ? 00:02:17 /usr/bin/ceph-mds -f --cluster ceph --id host1 --setuser ceph --setgroup ceph
+ceph 31555 1 0 Jun08 ? 01:13:50 /usr/bin/ceph-mon -f --cluster ceph --id host1 --setuser ceph --setgroup ceph
+ceph 31765 1 0 Jun08 ? 00:48:42 /usr/bin/radosgw -f --cluster ceph --name client.rgw.host1.rgw0 --setuser ceph --setgroup ceph
+ceph 97427 1 0 Jun17 ? 00:41:39 /usr/bin/ceph-osd -f --cluster ceph --id 0 --setuser ceph --setgroup ceph
\ No newline at end of file
--- /dev/null
+import argparse
+import os
+
+from logging import debug
+from teuthology import misc
+from teuthology.orchestra import cluster
+from teuthology.orchestra.run import quote
+from teuthology.orchestra.daemon.group import DaemonGroup
+import subprocess
+
+
+class FakeRemote(object):
+ pass
+
+
+def test_pid():
+ ctx = argparse.Namespace()
+ ctx.daemons = DaemonGroup(use_systemd=True)
+ remote = FakeRemote()
+
+ ps_ef_output_path = os.path.join(
+ os.path.dirname(__file__),
+ "files/daemon-systemdstate-pid-ps-ef.output"
+ )
+
+ # patching ps -ef command output using a file
+ def sh(args):
+ args[0:2] = ["cat", ps_ef_output_path]
+ debug(args)
+ return subprocess.getoutput(quote(args))
+
+ remote.sh = sh
+ remote.init_system = 'systemd'
+ remote.shortname = 'host1'
+
+ ctx.cluster = cluster.Cluster(
+ remotes=[
+ (remote, ['rgw.0', 'mon.a', 'mgr.a', 'mds.a', 'osd.0'])
+ ],
+ )
+
+ for remote, roles in ctx.cluster.remotes.items():
+ for role in roles:
+ _, rol, id_ = misc.split_role(role)
+ if any(rol.startswith(x) for x in ['mon', 'mgr', 'mds']):
+ ctx.daemons.register_daemon(remote, rol, remote.shortname)
+ else:
+ ctx.daemons.register_daemon(remote, rol, id_)
+
+ for _, daemons in ctx.daemons.daemons.items():
+ for daemon in daemons.values():
+ pid = daemon.pid
+ debug(pid)
+ assert pid