ctdb-scripts: Improve update and listing code
[samba4-gss.git] / python / samba / tests / samba_upgradedns_lmdb.py
bloba2029a07d24eed9b852c13e3c4f74e90157d5916
1 # Unix SMB/CIFS implementation.
2 # Copyright (C) Catalyst IT Ltd. 2019
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 from samba.tests.samba_tool.base import SambaToolCmdTest
19 import os
20 import shutil
23 class UpgradeDnsLmdbTestCase(SambaToolCmdTest):
24 """
25 Tests for dns upgrade on a lmdb backend
26 """
28 def setUp(self):
29 super().setUp()
30 self.tempsambadir = os.path.join(self.tempdir, "samba")
31 os.mkdir(self.tempsambadir)
33 # provision a domain
35 # returns the tuple (ret, stdout, stderr)
36 def provision(self):
37 command = (
38 "samba-tool "
39 "domain provision "
40 "--realm=foo.example.com "
41 "--domain=FOO "
42 "--targetdir=%s "
43 "--backend-store=mdb "
44 "--use-ntvfs " % self.tempsambadir)
45 return self.run_command(command)
47 # upgrade a domains dns to BIND9
49 # returns the tuple (ret, stdout, stderr)
50 def upgrade_dns(self):
51 command = (
52 "samba_upgradedns "
53 "--dns-backend=BIND9_DLZ "
54 "--configfile %s/etc/smb.conf" % self.tempsambadir)
55 return self.run_command(command)
57 def tearDown(self):
58 super().tearDown()
59 shutil.rmtree(self.tempsambadir)
61 def test_lmdb_lock_files_linked_on_upgrade_to_bind9_dlz(self):
62 """
63 Ensure that links are created for the lock files as well as the
64 data files
65 """
66 self.provision()
67 self.upgrade_dns()
68 directory = ("%s/bind-dns/dns/sam.ldb.d" % self.tempsambadir)
69 for filename in os.listdir(directory):
70 if filename.endswith(".ldb") and "DNSZONES" in filename:
71 lock_file = ("%s/%s-lock" % (directory, filename))
72 self.assertTrue(
73 os.path.isfile(lock_file),
74 msg=("Lock file %s/%s-lock for %s, does not exist" %
75 (directory, filename, filename)))