Autobuild-User: Andrew Tridgell <tridge@samba.org>
Autobuild-Date: Tue Nov 23 13:01:10 CET 2010 on sn-devel-104
# interfaces to create
INTERFACE : virbr0:0
# 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
INTERFACE_IP : 192.168.122.2
INTERFACE_NET : 192.168.122.0/24
VM_RESTORE : su tridge -c "VBoxManage snapshot ${VMNAME} restore ${SNAPSHOT} && VBoxManage startvm ${VMNAME}"
# interfaces to listen on
VM_RESTORE : su tridge -c "VBoxManage snapshot ${VMNAME} restore ${SNAPSHOT} && VBoxManage startvm ${VMNAME}"
# interfaces to listen on
+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
-BIND9 : /usr/sbin/named -u bind
# provision information
REALM : HOWTO.TRIDGELL.NET
# provision information
REALM : HOWTO.TRIDGELL.NET
t.putenv("KRB5_CONFIG", '${PREFIX}/private/krb5.conf')
t.run_cmd('ifconfig ${INTERFACE} ${INTERFACE_IP} up')
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')
def build_s4(t):
'''build samba4'''
t.info('Building s4')
t.run_cmd('rm -rf ${PREFIX}')
t.run_cmd('make -j install')
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')
def provision_s4(t, func_level="2008", interface=None):
'''provision s4 as a DC'''
t.info('Provisioning s4')
t.run_cmd('bin/samba-tool newuser testdenied ${PASSWORD1}')
t.run_cmd('bin/samba-tool group addmembers "Allowed RODC Password Replication Group" testallowed')
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):
def start_s4(t, interface=None):
t.info('Starting Samba4')
t.chdir("${PREFIX}")
t.run_cmd('killall -9 -q samba smbd nmbd winbindd', checkfail=False)
t.info('Starting Samba4')
t.chdir("${PREFIX}")
t.run_cmd('killall -9 -q samba smbd nmbd winbindd', checkfail=False)
'--option', 'interfaces=%s' % interface])
t.port_wait("localhost", 139)
'--option', 'interfaces=%s' % interface])
t.port_wait("localhost", 139)
t.info('Testing smbclient')
t.chdir('${PREFIX}')
t.cmd_contains("bin/smbclient --version", ["Version 4.0"])
t.info('Testing smbclient')
t.chdir('${PREFIX}')
t.cmd_contains("bin/smbclient --version", ["Version 4.0"])
child.sendline("cd ..")
child.sendline("rmdir testdir")
child.sendline("cd ..")
child.sendline("rmdir testdir")
+ '''create some test shares'''
t.info("Adding test shares")
t.chdir('${PREFIX}')
t.write_file("etc/smb.conf", '''
t.info("Adding test shares")
t.chdir('${PREFIX}')
t.write_file("etc/smb.conf", '''
+ '''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')
t.info("Restarting bind9")
t.putenv('KEYTAB_FILE', '${PREFIX}/private/dns.keytab')
t.putenv('KRB5_KTNAME', '${PREFIX}/private/dns.keytab')
t.run_cmd("chown -R ${BIND_USER} var/named")
nameserver = t.get_nameserver()
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)
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)
default-port 953;
};
''')
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.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", '''
t.run_cmd("mv -f /etc/resolv.conf /etc/resolv.conf.wintest-bak")
t.write_file("/etc/resolv.conf", '''
t.run_cmd("${RNDC} -c ${PREFIX}/etc/rndc.conf freeze")
t.run_cmd("${RNDC} -c ${PREFIX}/etc/rndc.conf thaw")
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):
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)
if getattr(t, 'resolv_conf_backup', False):
t.run_cmd("mv -f %s /etc/resolv.conf" % t.resolv_conf_backup)
+ '''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}'])
t.info("Testing DNS")
t.cmd_contains("host -t SRV _ldap._tcp.${LCREALM}.",
['_ldap._tcp.${LCREALM} has SRV record 0 100 389 ${HOSTNAME}.${LCREALM}'])
['${HOSTNAME}.${LCREALM} has address'])
def test_kerberos(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}")
t.info("Testing kerberos")
t.run_cmd("kdestroy")
t.kinit("administrator@${REALM}", "${PASSWORD1}")
+ '''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):
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")
t.setwinvars(vm)
t.info("Joining a windows box to the domain")
+ '''test that dcpromo worked'''
t.setwinvars(vm)
t.info("Checking the dcpromo join is OK")
t.chdir('${PREFIX}')
t.setwinvars(vm)
t.info("Checking the dcpromo join is OK")
t.chdir('${PREFIX}')
def run_dcpromo_rodc(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)
t.setwinvars(vm)
t.info("Joining a w2k8 box to the domain as a RODC")
t.vm_poweroff("${WIN_VM}", checkfail=False)
def test_dcpromo_rodc(t, vm):
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}')
t.setwinvars(vm)
t.info("Checking the w2k8 RODC join is OK")
t.chdir('${PREFIX}')
t.info("Checking if new users are available on windows")
t.run_cmd('bin/samba-tool newuser test2 ${PASSWORD2}')
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 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.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):
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}')
t.setwinvars(vm)
t.info("Joining ${WIN_VM} as a second DC using samba-tool join DC")
t.chdir('${PREFIX}')
def test_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}')
t.setwinvars(vm)
t.info("Checking the DC join is OK")
t.chdir('${PREFIX}')
+ '''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}')
t.setwinvars(vm)
t.info("Joining ${WIN_VM} as a RODC using samba-tool join DC")
t.chdir('${PREFIX}')
def test_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}')
t.setwinvars(vm)
t.info("Checking the RODC join is OK")
t.chdir('${PREFIX}')
t.info("Howto test: All OK")
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')
if __name__ == '__main__':
parser = optparse.OptionParser("test-howto.py")
parser.add_option("--conf", type='string', default='', help='config file')
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("--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()
opts, args = parser.parse_args()
try:
test_howto(t)
except Exception, str:
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)
+
+ if not opts.nocleanup:
+ test_cleanup(t)
+ t.info("S4 howto test: All OK")
'''set a substitution variable'''
self.vars[varname] = value
'''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']:
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']:
child.expect('Ethernet adapter ')
child.expect("[\w\s]+")
self.setvar("WIN_NIC", child.after)
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)
child.expect(['IPv4 Address', 'IP Address'])
child.expect('\d+.\d+.\d+.\d+')
self.setvar('WIN_IPV4_ADDRESS', child.after)
return False
def set_ip(self, child):
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
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"""
- if self.vars['WIN_DHCP'] is False:
- return False
child.sendline('netsh')
child.expect('netsh>')
child.sendline('offline')
child.sendline('netsh')
child.expect('netsh>')
child.sendline('offline')