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
23 class UpgradeDnsLmdbTestCase(SambaToolCmdTest
):
25 Tests for dns upgrade on a lmdb backend
30 self
.tempsambadir
= os
.path
.join(self
.tempdir
, "samba")
31 os
.mkdir(self
.tempsambadir
)
35 # returns the tuple (ret, stdout, stderr)
40 "--realm=foo.example.com "
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
):
53 "--dns-backend=BIND9_DLZ "
54 "--configfile %s/etc/smb.conf" % self
.tempsambadir
)
55 return self
.run_command(command
)
59 shutil
.rmtree(self
.tempsambadir
)
61 def test_lmdb_lock_files_linked_on_upgrade_to_bind9_dlz(self
):
63 Ensure that links are created for the lock files as well as the
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
))
73 os
.path
.isfile(lock_file
),
74 msg
=("Lock file %s/%s-lock for %s, does not exist" %
75 (directory
, filename
, filename
)))