[SCM] Samba Shared Repository - branch master updated
Douglas Bagnall
dbagnall at samba.org
Thu Jun 7 02:22:02 UTC 2018
The branch, master has been updated
via 0fb122a tests/demote: replace demote test bash script to python
via 00494a6 netcmd/domain: remove dns records after DC demote
via ab28a64 netcmd/domain: fix a typo in message
from d445704 ctdb-daemon: CID 1435732: Argument cannot be negative
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 0fb122af5094d568c56b0a7814696f3389813bbd
Author: Joe Guo <joeg at catalyst.net.nz>
Date: Wed Jun 6 15:01:28 2018 +1200
tests/demote: replace demote test bash script to python
Convert bash script to python and add demote and dns remove test on top.
Signed-off-by: Joe Guo <joeg at catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Garming Sam <garming at catalyst.net.nz>
Autobuild-User(master): Douglas Bagnall <dbagnall at samba.org>
Autobuild-Date(master): Thu Jun 7 04:21:17 CEST 2018 on sn-devel-144
commit 00494a65102de10880950e307731a7cbd8cb2827
Author: Joe Guo <joeg at catalyst.net.nz>
Date: Wed Jun 6 10:38:11 2018 +1200
netcmd/domain: remove dns records after DC demote
Call `remove_dc.remove_dns_references()` at the end of demote cmd.
Signed-off-by: Joe Guo <joeg at catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Garming Sam <garming at catalyst.net.nz>
commit ab28a64f5e7f8cd6114350f2577e7e6a768fb11c
Author: Joe Guo <joeg at catalyst.net.nz>
Date: Wed Jun 6 10:37:20 2018 +1200
netcmd/domain: fix a typo in message
Signed-off-by: Joe Guo <joeg at catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Garming Sam <garming at catalyst.net.nz>
-----------------------------------------------------------------------
Summary of changes:
python/samba/netcmd/domain.py | 6 +-
python/samba/tests/samba_tool/demote.py | 106 ++++++++++++++++++++++++++++++++
source4/selftest/tests.py | 10 ++-
source4/utils/tests/test_demote.sh | 38 ------------
4 files changed, 119 insertions(+), 41 deletions(-)
create mode 100644 python/samba/tests/samba_tool/demote.py
delete mode 100755 source4/utils/tests/test_demote.sh
Changeset truncated at 500 lines:
diff --git a/python/samba/netcmd/domain.py b/python/samba/netcmd/domain.py
index 5438537..3dbe2fb 100644
--- a/python/samba/netcmd/domain.py
+++ b/python/samba/netcmd/domain.py
@@ -798,7 +798,7 @@ class cmd_domain_demote(Command):
raise CommandError("Unable to search for servers")
if (len(res) == 1):
- raise CommandError("You are the latest server in the domain")
+ raise CommandError("You are the last server in the domain")
server = None
for e in res:
@@ -1028,6 +1028,10 @@ class cmd_domain_demote(Command):
except ldb.LdbError as l:
pass
+ # get dns host name for target server to demote, remove dns references
+ remove_dc.remove_dns_references(remote_samdb, logger, samdb.host_dns_name(),
+ ignore_no_name=True)
+
self.errf.write("Demote successful\n")
diff --git a/python/samba/tests/samba_tool/demote.py b/python/samba/tests/samba_tool/demote.py
new file mode 100644
index 0000000..0726d2b
--- /dev/null
+++ b/python/samba/tests/samba_tool/demote.py
@@ -0,0 +1,106 @@
+# Unix SMB/CIFS implementation.
+# Copyright (C) Andrew Bartlett <abartlet at samba.org> 2018
+# Written by Joe Guo <joeg at catalyst.net.nz>
+#
+# 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 <http://www.gnu.org/licenses/>.
+#
+
+import os
+from samba.tests.samba_tool.base import SambaToolCmdTest
+
+
+class DemoteCmdTestCase(SambaToolCmdTest):
+ """Test for samba-tool domain demote subcommand"""
+
+ def setUp(self):
+ super(DemoteCmdTestCase, self).setUp()
+ self.creds_string = "-U{}%{}".format(
+ os.environ["DC_USERNAME"], os.environ["DC_PASSWORD"])
+
+ self.dc_server = os.environ['DC_SERVER']
+ self.dburl = "ldap://%s" % os.environ["DC_SERVER"]
+ self.samdb = self.getSamDB("-H", self.dburl, self.creds_string)
+
+ def test_demote_and_remove_dns(self):
+ """
+ Test domain demote command will also remove dns references
+ """
+
+ server = os.environ['SERVER'] # the server to demote
+ zone = os.environ['REALM'].lower()
+
+ # make sure zone exist
+ result, out, err = self.runsubcmd(
+ "dns", "zoneinfo", server, zone, self.creds_string)
+ self.assertCmdSuccess(result, out, err)
+
+ # add a A record for the server to demote
+ result, out, err = self.runsubcmd(
+ "dns", "add", self.dc_server, zone,
+ server, "A", "192.168.0.193", self.creds_string)
+ self.assertCmdSuccess(result, out, err)
+
+ # make sure above A record exist
+ result, out, err = self.runsubcmd(
+ "dns", "query", self.dc_server, zone,
+ server, 'A', self.creds_string)
+ self.assertCmdSuccess(result, out, err)
+
+ # the above A record points to this host
+ dnshostname = '{}.{}'.format(server, zone)
+
+ # add a SRV record points to above host
+ srv_record = "{} 65530 65530 65530".format(dnshostname)
+ self.runsubcmd(
+ "dns", "add", self.dc_server, zone, 'testrecord', "SRV",
+ srv_record, self.creds_string)
+
+ # make sure above SRV record exist
+ result, out, err = self.runsubcmd(
+ "dns", "query", self.dc_server, zone,
+ "testrecord", 'SRV', self.creds_string)
+ self.assertCmdSuccess(result, out, err)
+
+ for type_ in ['CNAME', 'NS', 'PTR']:
+ # create record
+ self.runsubcmd(
+ "dns", "add", self.dc_server, zone,
+ 'testrecord', type_, dnshostname,
+ self.creds_string)
+ self.assertCmdSuccess(result, out, err)
+
+ # check exist
+ result, out, err = self.runsubcmd(
+ "dns", "query", self.dc_server, zone,
+ "testrecord", 'SRV', self.creds_string)
+ self.assertCmdSuccess(result, out, err)
+
+ # now demote
+ result, out, err = self.runsubcmd(
+ "domain", "demote",
+ "--server", self.dc_server,
+ "--configfile", os.environ["CONFIGFILE"],
+ "--workgroup", os.environ["DOMAIN"],
+ self.creds_string)
+ self.assertCmdSuccess(result, out, err)
+
+ result, out, err = self.runsubcmd(
+ "dns", "query", self.dc_server, zone,
+ server, 'ALL', self.creds_string)
+ self.assertCmdFail(result)
+
+ result, out, err = self.runsubcmd(
+ "dns", "query", self.dc_server, zone,
+ "testrecord", 'ALL', self.creds_string)
+ self.assertCmdFail(result)
diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py
index 5359316..069128b 100755
--- a/source4/selftest/tests.py
+++ b/source4/selftest/tests.py
@@ -1053,8 +1053,14 @@ for env in [ "ktest", "ad_member", "ad_dc_no_ntlm" ]:
# Demote the vampire DC, it must be the last test each DC, before the dbcheck
for env in ['vampire_dc', 'promoted_dc', 'rodc']:
- plantestsuite("samba4.blackbox.samba_tool_demote(%s)" % env, env, [os.path.join(samba4srcdir, "utils/tests/test_demote.sh"), '$SERVER', '$SERVER_IP', '$USERNAME', '$PASSWORD', '$DOMAIN', '$DC_SERVER', '$PREFIX/%s' % env, smbclient4])
-
+ planoldpythontestsuite(env, "samba.tests.samba_tool.demote",
+ name="samba.tests.samba_tool.demote",
+ environ={
+ 'CONFIGFILE': '$PREFIX/%s/etc/smb.conf' % env
+ },
+ extra_args=['-U"$USERNAME%$PASSWORD"'],
+ extra_path=[os.path.join(srcdir(), "samba/python")]
+ )
# TODO: Verifying the databases really should be a part of the
# environment teardown.
# check the databases are all OK. PLEASE LEAVE THIS AS THE LAST TEST
diff --git a/source4/utils/tests/test_demote.sh b/source4/utils/tests/test_demote.sh
deleted file mode 100755
index 0c2c03c..0000000
--- a/source4/utils/tests/test_demote.sh
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/sh
-# Blackbox tests for samba-tool
-
-SERVER=$1
-SERVER_IP=$2
-USERNAME=$3
-PASSWORD=$4
-DOMAIN=$5
-DC=$6
-PROV=$7
-smbclient=$8
-shift 8
-
-failed=0
-
-samba4bindir="$BINDIR"
-samba_tool="$samba4bindir/samba-tool"
-
-testit() {
- name="$1"
- shift
- cmdline="$*"
- echo "test: $name"
- $cmdline
- status=$?
- if [ x$status = x0 ]; then
- echo "success: $name"
- else
- echo "failure: $name"
- failed=`expr $failed + 1`
- fi
- return $status
-}
-
-
-testit "demote" $VALGRIND $samba_tool domain demote --server $DC -s $PROV/etc/smb.conf -W "$DOMAIN" -U"$USERNAME%$PASSWORD"
-
-exit $failed
--
Samba Shared Repository
More information about the samba-cvs
mailing list