summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wintest/conf/abartlet.conf3
-rw-r--r--wintest/conf/tridge.conf10
-rwxr-xr-xwintest/test-s4-howto.py53
-rw-r--r--wintest/wintest.py16
4 files changed, 62 insertions, 20 deletions
diff --git a/wintest/conf/abartlet.conf b/wintest/conf/abartlet.conf
index ea8a5cfa67..fb0a5909bf 100644
--- a/wintest/conf/abartlet.conf
+++ b/wintest/conf/abartlet.conf
@@ -15,6 +15,9 @@ VM_RESTORE : virsh snapshot-revert ${VMNAME} ${SNAPSHOT}
# interfaces to create
INTERFACE : virbr0:0
+
+# this is an additional IP that will be used for named to listen
+# on. It should not be the primary IP of the interface
INTERFACE_IP : 192.168.122.2
INTERFACE_NET : 192.168.122.0/24
diff --git a/wintest/conf/tridge.conf b/wintest/conf/tridge.conf
index 12885264f2..f5081ed4eb 100644
--- a/wintest/conf/tridge.conf
+++ b/wintest/conf/tridge.conf
@@ -14,11 +14,17 @@ VM_POWEROFF : su tridge -c "VBoxManage controlvm ${VMNAME} poweroff"
VM_RESTORE : su tridge -c "VBoxManage snapshot ${VMNAME} restore ${SNAPSHOT} && VBoxManage startvm ${VMNAME}"
# interfaces to listen on
-INTERFACES : virbr0
+INTERFACE : virbr0:0
+
+# this is an additional IP that will be used for named to listen
+# on. It should not be the primary IP of the interface
+INTERFACE_IP : 10.0.0.2
+INTERFACE_NET : 10.0.0.0/24
# how to run bind9
-BIND9 : /usr/sbin/named -u bind
+BIND9 : /usr/sbin/named
RNDC : /usr/sbin/rndc
+BIND_USER : bind
# provision information
REALM : HOWTO.TRIDGELL.NET
diff --git a/wintest/test-s4-howto.py b/wintest/test-s4-howto.py
index b28370af18..ec96581e81 100755
--- a/wintest/test-s4-howto.py
+++ b/wintest/test-s4-howto.py
@@ -14,6 +14,7 @@ def check_prerequesites(t):
t.putenv("KRB5_CONFIG", '${PREFIX}/private/krb5.conf')
t.run_cmd('ifconfig ${INTERFACE} ${INTERFACE_IP} up')
+
def build_s4(t):
'''build samba4'''
t.info('Building s4')
@@ -24,6 +25,7 @@ def build_s4(t):
t.run_cmd('rm -rf ${PREFIX}')
t.run_cmd('make -j install')
+
def provision_s4(t, func_level="2008", interface=None):
'''provision s4 as a DC'''
t.info('Provisioning s4')
@@ -38,7 +40,9 @@ def provision_s4(t, func_level="2008", interface=None):
t.run_cmd('bin/samba-tool newuser testdenied ${PASSWORD1}')
t.run_cmd('bin/samba-tool group addmembers "Allowed RODC Password Replication Group" testallowed')
+
def start_s4(t, interface=None):
+ '''startup samba4'''
t.info('Starting Samba4')
t.chdir("${PREFIX}")
t.run_cmd('killall -9 -q samba smbd nmbd winbindd', checkfail=False)
@@ -47,7 +51,9 @@ def start_s4(t, interface=None):
'--option', 'interfaces=%s' % interface])
t.port_wait("localhost", 139)
+
def test_smbclient(t):
+ '''test smbclient'''
t.info('Testing smbclient')
t.chdir('${PREFIX}')
t.cmd_contains("bin/smbclient --version", ["Version 4.0"])
@@ -63,7 +69,9 @@ def test_smbclient(t):
child.sendline("cd ..")
child.sendline("rmdir testdir")
+
def create_shares(t):
+ '''create some test shares'''
t.info("Adding test shares")
t.chdir('${PREFIX}')
t.write_file("etc/smb.conf", '''
@@ -80,6 +88,7 @@ def create_shares(t):
def restart_bind(t):
+ '''restart the test environment version of bind'''
t.info("Restarting bind9")
t.putenv('KEYTAB_FILE', '${PREFIX}/private/dns.keytab')
t.putenv('KRB5_KTNAME', '${PREFIX}/private/dns.keytab')
@@ -88,7 +97,7 @@ def restart_bind(t):
t.run_cmd("chown -R ${BIND_USER} var/named")
nameserver = t.get_nameserver()
- if nameserver == t.vars['INTERFACE_IP']:
+ if nameserver == t.getvar('INTERFACE_IP'):
raise RuntimeError("old /etc/resolv.conf must not contain %s as a nameserver, this will create loops with the generated dns configuration")
t.setvar('DNSSERVER', nameserver)
@@ -138,10 +147,10 @@ options {
default-port 953;
};
''')
-
+
t.run_cmd("${RNDC} -c ${PREFIX}/etc/rndc.conf stop", checkfail=False)
t.port_wait("${INTERFACE_IP}", 53, wait_for_fail=True)
- t.bind_child = t.run_child("${BIND9} -u ${BIND_USER} -c ${PREFIX}/etc/named.conf -g")
+ t.bind_child = t.run_child("${BIND9} -u ${BIND_USER} -n 1 -c ${PREFIX}/etc/named.conf -g")
t.run_cmd("mv -f /etc/resolv.conf /etc/resolv.conf.wintest-bak")
t.write_file("/etc/resolv.conf", '''
@@ -162,11 +171,15 @@ nameserver ${INTERFACE_IP}
t.run_cmd("${RNDC} -c ${PREFIX}/etc/rndc.conf freeze")
t.run_cmd("${RNDC} -c ${PREFIX}/etc/rndc.conf thaw")
+
def restore_resolv_conf(t):
+ '''restore the /etc/resolv.conf after testing is complete'''
if getattr(t, 'resolv_conf_backup', False):
t.run_cmd("mv -f %s /etc/resolv.conf" % t.resolv_conf_backup)
+
def test_dns(t):
+ '''test that DNS is OK'''
t.info("Testing DNS")
t.cmd_contains("host -t SRV _ldap._tcp.${LCREALM}.",
['_ldap._tcp.${LCREALM} has SRV record 0 100 389 ${HOSTNAME}.${LCREALM}'])
@@ -176,6 +189,7 @@ def test_dns(t):
['${HOSTNAME}.${LCREALM} has address'])
def test_kerberos(t):
+ '''test that kerberos is OK'''
t.info("Testing kerberos")
t.run_cmd("kdestroy")
t.kinit("administrator@${REALM}", "${PASSWORD1}")
@@ -183,12 +197,14 @@ def test_kerberos(t):
def test_dyndns(t):
+ '''test that dynamic DNS is working'''
t.chdir('${PREFIX}')
t.run_cmd("sbin/samba_dnsupdate --fail-immediately")
t.run_cmd("${RNDC} -c ${PREFIX}/etc/rndc.conf flush")
def run_winjoin(t, vm):
+ '''join a windows box to our domain'''
t.setwinvars(vm)
t.info("Joining a windows box to the domain")
@@ -264,6 +280,7 @@ SafeModeAdminPassword=${PASSWORD1}
def test_dcpromo(t, vm):
+ '''test that dcpromo worked'''
t.setwinvars(vm)
t.info("Checking the dcpromo join is OK")
t.chdir('${PREFIX}')
@@ -361,6 +378,7 @@ def test_dcpromo(t, vm):
def run_dcpromo_rodc(t, vm):
+ '''run a RODC dcpromo to join a windows DC to the samba domain'''
t.setwinvars(vm)
t.info("Joining a w2k8 box to the domain as a RODC")
t.vm_poweroff("${WIN_VM}", checkfail=False)
@@ -405,6 +423,7 @@ RebootOnCompletion=No
def test_dcpromo_rodc(t, vm):
+ '''test the RODC dcpromo worked'''
t.setwinvars(vm)
t.info("Checking the w2k8 RODC join is OK")
t.chdir('${PREFIX}')
@@ -427,14 +446,18 @@ def test_dcpromo_rodc(t, vm):
t.info("Checking if new users are available on windows")
t.run_cmd('bin/samba-tool newuser test2 ${PASSWORD2}')
- t.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME} -Utest2%${PASSWORD2} -k no", ['Sharename', 'Remote IPC'])
t.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME} -Utest2%${PASSWORD2} -k yes", ['Sharename', 'Remote IPC'])
+ t.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME} -Utest2%${PASSWORD2} -k no", ['LOGON_FAILURE'])
+ t.retry_cmd("bin/samba-tool drs replicate ${WIN_HOSTNAME} ${HOSTNAME} ${BASEDN} -k yes", ["was successful"])
+ t.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME} -Utest2%${PASSWORD2} -k no", ['Sharename', 'Remote IPC'])
t.run_cmd('bin/samba-tool user delete test2 -Uadministrator@${LCREALM}%${PASSWORD1}')
- t.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME} -Utest2%${PASSWORD2}", ['LOGON_FAILURE'])
+ t.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME} -Utest2%${PASSWORD2} -k yes", ['LOGON_FAILURE'])
+ t.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME} -Utest2%${PASSWORD2} -k no", ['LOGON_FAILURE'])
t.vm_poweroff("${WIN_VM}")
def join_as_dc(t, vm):
+ '''join a windows domain as a DC'''
t.setwinvars(vm)
t.info("Joining ${WIN_VM} as a second DC using samba-tool join DC")
t.chdir('${PREFIX}')
@@ -450,6 +473,7 @@ def join_as_dc(t, vm):
def test_join_as_dc(t, vm):
+ '''test the join of a windows domain as a DC'''
t.setwinvars(vm)
t.info("Checking the DC join is OK")
t.chdir('${PREFIX}')
@@ -502,6 +526,7 @@ def test_join_as_dc(t, vm):
def join_as_rodc(t, vm):
+ '''join a windows domain as a RODC'''
t.setwinvars(vm)
t.info("Joining ${WIN_VM} as a RODC using samba-tool join DC")
t.chdir('${PREFIX}')
@@ -517,6 +542,7 @@ def join_as_rodc(t, vm):
def test_join_as_rodc(t, vm):
+ '''test a windows domain RODC join'''
t.setwinvars(vm)
t.info("Checking the RODC join is OK")
t.chdir('${PREFIX}')
@@ -661,6 +687,13 @@ def test_howto(t):
t.info("Howto test: All OK")
+def test_cleanup(t):
+ '''cleanup after tests'''
+ restore_resolv_conf(t)
+ if getattr(t, 'bind_child', False):
+ t.bind_child.kill()
+
+
if __name__ == '__main__':
parser = optparse.OptionParser("test-howto.py")
parser.add_option("--conf", type='string', default='', help='config file')
@@ -670,6 +703,7 @@ if __name__ == '__main__':
parser.add_option("--clean", action='store_true', default=False, help='clean the tree')
parser.add_option("--prefix", type='string', default=None, help='override install prefix')
parser.add_option("--sourcetree", type='string', default=None, help='override sourcetree location')
+ parser.add_option("--nocleanup", action='store_true', default=False, help='disable cleanup code')
opts, args = parser.parse_args()
@@ -703,7 +737,10 @@ if __name__ == '__main__':
try:
test_howto(t)
except Exception, str:
- restore_resolv_conf(t)
- if getattr(t, 'bind_child', False):
- t.bind_child.kill()
+ if not opts.nocleanup:
+ test_cleanup(t)
raise
+
+ if not opts.nocleanup:
+ test_cleanup(t)
+ t.info("S4 howto test: All OK")
diff --git a/wintest/wintest.py b/wintest/wintest.py
index 4c93017f3b..d7ca5fe067 100644
--- a/wintest/wintest.py
+++ b/wintest/wintest.py
@@ -17,6 +17,10 @@ class wintest():
'''set a substitution variable'''
self.vars[varname] = value
+ def getvar(self, varname):
+ '''return a substitution variable'''
+ return self.vars[varname]
+
def setwinvars(self, vm, prefix='WIN'):
'''setup WIN_XX vars based on a vm name'''
for v in ['VM', 'HOSTNAME', 'USER', 'PASS', 'SNAPSHOT', 'BASEDN', 'REALM', 'DOMAIN']:
@@ -282,12 +286,6 @@ class wintest():
child.expect('Ethernet adapter ')
child.expect("[\w\s]+")
self.setvar("WIN_NIC", child.after)
- child.expect(['DHCP Enabled', 'Dhcp Enabled'])
- i = child.expect(['Yes', 'No'])
- if i == 0:
- self.setvar("WIN_DHCP", True)
- else:
- self.setvar("WIN_DHCP", False)
child.expect(['IPv4 Address', 'IP Address'])
child.expect('\d+.\d+.\d+.\d+')
self.setvar('WIN_IPV4_ADDRESS', child.after)
@@ -324,12 +322,10 @@ class wintest():
return False
def set_ip(self, child):
- '''fix the IP address to the same value it had when we
+ """fix the IP address to the same value it had when we
connected, but don't use DHCP, and force the DNS server to our
- DNS server. This allows DNS updates to run'''
+ DNS server. This allows DNS updates to run"""
self.get_ipconfig(child)
- if self.vars['WIN_DHCP'] is False:
- return False
child.sendline('netsh')
child.expect('netsh>')
child.sendline('offline')