traffic: new version of model with packet_rate, version number
[samba.git] / wintest / test-s4-howto.py
index 694f8c549e00afdec456a9ec6533c04ffae2e3b8..5102387124a5e98223d1a3da5bd900bef17e3c63 100755 (executable)
@@ -1,13 +1,19 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 '''automated testing of the steps of the Samba4 HOWTO'''
 
-import sys, os
-import wintest, pexpect, time, subprocess
+import sys
+import os
+import wintest
+import pexpect
+import time
+import subprocess
+
 
 def set_krb5_conf(t):
     t.putenv("KRB5_CONFIG", '${PREFIX}/private/krb5.conf')
 
+
 def build_s4(t):
     '''build samba4'''
     t.info('Building s4')
@@ -25,21 +31,21 @@ def provision_s4(t, func_level="2008"):
     t.chdir('${PREFIX}')
     t.del_files(["var", "private"])
     t.run_cmd("rm -f etc/smb.conf")
-    provision=['bin/samba-tool',
-               'domain',
-               'provision',
-               '--realm=${LCREALM}',
-               '--domain=${DOMAIN}',
-               '--adminpass=${PASSWORD1}',
-               '--server-role=domain controller',
-               '--function-level=%s' % func_level,
-               '-d${DEBUGLEVEL}',
-               '--option=interfaces=${INTERFACE}',
-               '--host-ip=${INTERFACE_IP}',
-               '--option=bind interfaces only=yes',
-               '--option=rndc command=${RNDC} -c${PREFIX}/etc/rndc.conf',
-               '--dns-backend=${NAMESERVER_BACKEND}',
-               '${DNS_FORWARDER}']
+    provision = ['bin/samba-tool',
+                 'domain',
+                 'provision',
+                 '--realm=${LCREALM}',
+                 '--domain=${DOMAIN}',
+                 '--adminpass=${PASSWORD1}',
+                 '--server-role=domain controller',
+                 '--function-level=%s' % func_level,
+                 '-d${DEBUGLEVEL}',
+                 '--option=interfaces=${INTERFACE}',
+                 '--host-ip=${INTERFACE_IP}',
+                 '--option=bind interfaces only=yes',
+                 '--option=rndc command=${RNDC} -c${PREFIX}/etc/rndc.conf',
+                 '--dns-backend=${NAMESERVER_BACKEND}',
+                 '${DNS_FORWARDER}']
     if t.getvar('USE_NTVFS'):
         provision.append('${USE_NTVFS}')
 
@@ -60,6 +66,7 @@ def start_s4(t):
                '--option', 'panic action=gnome-terminal -e "gdb --pid %d"', '--option', 'max protocol=nt1'])
     t.port_wait("${INTERFACE_IP}", 139)
 
+
 def test_smbclient(t):
     '''test smbclient against localhost'''
     t.info('Testing smbclient')
@@ -106,6 +113,7 @@ def test_dns(t):
     t.cmd_contains("host -t A ${HOSTNAME}.${LCREALM}",
                    ['${HOSTNAME}.${LCREALM} has address'])
 
+
 def test_kerberos(t):
     '''test that kerberos is OK'''
     t.info("Testing kerberos")
@@ -129,6 +137,7 @@ def run_winjoin(t, vm):
 
     t.run_winjoin(t, "${LCREALM}")
 
+
 def test_winjoin(t, vm):
     t.info("Checking the windows join is OK")
     smbclient = t.getvar("smbclient")
@@ -212,37 +221,37 @@ def test_dcpromo(t, vm):
 
     t.cmd_contains("bin/samba-tool drs showrepl ${HOSTNAME}.${LCREALM} -k yes",
                    ["INBOUND NEIGHBORS",
-                     "${BASEDN}",
-                     "Last attempt .* was successful",
-                     "CN=Configuration,${BASEDN}",
-                     "Last attempt .* was successful",
-                     "CN=Configuration,${BASEDN}", # cope with either order
-                     "Last attempt .* was successful",
-                     "OUTBOUND NEIGHBORS",
-                     "${BASEDN}",
-                     "Last success",
-                     "CN=Configuration,${BASEDN}",
-                     "Last success",
-                     "CN=Configuration,${BASEDN}",
-                     "Last success"],
+                    "${BASEDN}",
+                    "Last attempt .* was successful",
+                    "CN=Configuration,${BASEDN}",
+                    "Last attempt .* was successful",
+                    "CN=Configuration,${BASEDN}",  # cope with either order
+                    "Last attempt .* was successful",
+                    "OUTBOUND NEIGHBORS",
+                    "${BASEDN}",
+                    "Last success",
+                    "CN=Configuration,${BASEDN}",
+                    "Last success",
+                    "CN=Configuration,${BASEDN}",
+                    "Last success"],
                    ordered=True,
                    regex=True)
 
     t.cmd_contains("bin/samba-tool drs showrepl ${WIN_HOSTNAME}.${LCREALM} -k yes",
                    ["INBOUND NEIGHBORS",
-                     "${BASEDN}",
-                     "Last attempt .* was successful",
-                     "CN=Configuration,${BASEDN}",
-                     "Last attempt .* was successful",
-                     "CN=Configuration,${BASEDN}",
-                     "Last attempt .* was successful",
-                     "OUTBOUND NEIGHBORS",
-                     "${BASEDN}",
-                     "Last success",
-                     "CN=Configuration,${BASEDN}",
-                     "Last success",
-                     "CN=Configuration,${BASEDN}",
-                     "Last success"],
+                    "${BASEDN}",
+                    "Last attempt .* was successful",
+                    "CN=Configuration,${BASEDN}",
+                    "Last attempt .* was successful",
+                    "CN=Configuration,${BASEDN}",
+                    "Last attempt .* was successful",
+                    "OUTBOUND NEIGHBORS",
+                    "${BASEDN}",
+                    "Last success",
+                    "CN=Configuration,${BASEDN}",
+                    "Last success",
+                    "CN=Configuration,${BASEDN}",
+                    "Last success"],
                    ordered=True,
                    regex=True)
 
@@ -256,7 +265,7 @@ def test_dcpromo(t, vm):
         time.sleep(2)
         child.sendline("net use t: \\\\${HOSTNAME}.${LCREALM}\\test")
         i = child.expect(["The command completed successfully", "The network path was not found"])
-        retries -=1
+        retries -= 1
 
     t.run_net_time(child)
 
@@ -345,7 +354,6 @@ RebootOnCompletion=No
     t.wait_reboot()
 
 
-
 def test_dcpromo_rodc(t, vm):
     '''test the RODC dcpromo worked'''
     t.info("Checking the w2k8 RODC join is OK")
@@ -374,13 +382,13 @@ def test_dcpromo_rodc(t, vm):
 
     t.cmd_contains("bin/samba-tool drs showrepl ${HOSTNAME}.${LCREALM}",
                    ["INBOUND NEIGHBORS",
-                     "OUTBOUND NEIGHBORS",
-                     "${BASEDN}",
-                     "Last attempt.*was successful",
-                     "CN=Configuration,${BASEDN}",
-                     "Last attempt.*was successful",
-                     "CN=Configuration,${BASEDN}",
-                     "Last attempt.*was successful"],
+                    "OUTBOUND NEIGHBORS",
+                    "${BASEDN}",
+                    "Last attempt.*was successful",
+                    "CN=Configuration,${BASEDN}",
+                    "Last attempt.*was successful",
+                    "CN=Configuration,${BASEDN}",
+                    "Last attempt.*was successful"],
                    ordered=True,
                    regex=True)
 
@@ -406,6 +414,7 @@ def prep_join_as_dc(t, vm):
     child = t.open_telnet("${WIN_HOSTNAME}", "${WIN_DOMAIN}\\administrator", "${WIN_PASS}", set_time=True)
     t.get_ipconfig(child)
 
+
 def join_as_dc(t, vm):
     '''join a windows domain as a DC'''
     t.setwinvars(vm)
@@ -447,7 +456,7 @@ def test_join_as_dc(t, vm):
         child.expect("C:")
         if i == 1:
             time.sleep(2)
-        retries -=1
+        retries -= 1
 
     t.info("Checking if showrepl is happy")
     child.sendline("repadmin /showrepl")
@@ -520,7 +529,7 @@ def test_join_as_rodc(t, vm):
         child.expect("C:")
         if i == 1:
             time.sleep(2)
-        retries -=1
+        retries -= 1
 
     t.info("Checking if showrepl is happy")
     child.sendline("repadmin /showrepl")
@@ -528,13 +537,13 @@ def test_join_as_rodc(t, vm):
 
     t.cmd_contains("bin/samba-tool drs showrepl ${WIN_HOSTNAME}.${WIN_REALM} -k yes",
                    ["INBOUND NEIGHBORS",
-                     "OUTBOUND NEIGHBORS",
-                     "${WIN_BASEDN}",
-                     "Last attempt .* was successful",
-                     "CN=Configuration,${WIN_BASEDN}",
-                     "Last attempt .* was successful",
-                     "CN=Configuration,${WIN_BASEDN}",
-                     "Last attempt .* was successful"],
+                    "OUTBOUND NEIGHBORS",
+                    "${WIN_BASEDN}",
+                    "Last attempt .* was successful",
+                    "CN=Configuration,${WIN_BASEDN}",
+                    "Last attempt .* was successful",
+                    "CN=Configuration,${WIN_BASEDN}",
+                    "Last attempt .* was successful"],
                    ordered=True,
                    regex=True)