From 6d7a8d80cdc9ee996ff503d8834037001cf233d9 Mon Sep 17 00:00:00 2001 From: Gary Lockyer Date: Wed, 13 Sep 2017 11:21:02 +1200 Subject: [PATCH] tests: Add a blackbox test for smbcontrol Add tests to check that samba processes have started and that they can be pinged. Signed-off-by: Gary Lockyer Reviewed-by: Andrew Bartlett Reviewed-by: Garming Sam --- python/samba/tests/blackbox/smbcontrol.py | 50 +++++++++++++++++++++++++++++++ source4/selftest/tests.py | 7 +++++ 2 files changed, 57 insertions(+) create mode 100644 python/samba/tests/blackbox/smbcontrol.py diff --git a/python/samba/tests/blackbox/smbcontrol.py b/python/samba/tests/blackbox/smbcontrol.py new file mode 100644 index 00000000000..e1517614a47 --- /dev/null +++ b/python/samba/tests/blackbox/smbcontrol.py @@ -0,0 +1,50 @@ +# Blackbox tests for smbcontrol +# +# Copyright (C) Catalyst IT Ltd. 2017 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +from samba.tests import BlackboxTestCase +from samba.messaging import Messaging + +COMMAND = "bin/smbcontrol" +PING = "ping" +USAGE = "pool-usage" + + +class SmbcontrolBlockboxTests(BlackboxTestCase): + + def setUp(self): + super(SmbcontrolBlockboxTests, self).setUp() + lp_ctx = self.get_loadparm() + self.msg_ctx = Messaging(lp_ctx=lp_ctx) + + def test_expected_processes(self): + """ + Test that the expected samba processes are running, currently we only + check that at least one process is running + """ + processes = self.msg_ctx.irpc_all_servers() + if not processes: + self.fail("No samba processes returned") + + def test_ping(self): + """Test that all the samba processes can be pinged""" + + processes = self.msg_ctx.irpc_all_servers() + for p in processes: + for id in p.ids: + if p.name != "samba": + self.check_run("%s %d %s" % (COMMAND, id.pid, PING)) diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py index cdc62cd362b..7362ec78e54 100755 --- a/source4/selftest/tests.py +++ b/source4/selftest/tests.py @@ -703,6 +703,13 @@ planoldpythontestsuite("ad_dc_ntvfs", planoldpythontestsuite("ad_dc_ntvfs", "samba.tests.blackbox.traffic_summary", extra_args=['-U"$USERNAME%$PASSWORD"']) +# +# Want a selection of environments across the process models +# +for env in ["ad_dc_ntvfs:local", "ad_dc:local", + "fl2003dc:local", "fl2008rdc:local", + "promoted_dc:local"]: + planoldpythontestsuite(env, "samba.tests.blackbox.smbcontrol") plantestsuite_loadlist("samba4.ldap.python(ad_dc_ntvfs)", "ad_dc_ntvfs", [python, os.path.join(samba4srcdir, "dsdb/tests/python/ldap.py"), '$SERVER', '-U"$USERNAME%$PASSWORD"', '--workgroup=$DOMAIN', '$LOADLIST', '$LISTOPT']) plantestsuite_loadlist("samba4.tokengroups.krb5.python(ad_dc_ntvfs)", "ad_dc_ntvfs:local", [python, os.path.join(samba4srcdir, "dsdb/tests/python/token_group.py"), '$SERVER', '-U"$USERNAME%$PASSWORD"', '--workgroup=$DOMAIN', '-k', 'yes', '$LOADLIST', '$LISTOPT']) -- 2.11.4.GIT