selftest: Export DC conf path for special cases
authorTim Beale <timbeale@catalyst.net.nz>
Mon, 11 Feb 2019 04:15:22 +0000 (17:15 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 18 Feb 2019 04:42:09 +0000 (05:42 +0100)
In a few rare cases, a test needs to assert aspects both client-side and
server-side aspects. A typical example would be the audit logging, which
is exercising client-side behaviour, but also asserting the server-side
logging.

Usually this has involved a kludge in tests.py to either use
socket-wrapper explicitly, or hardcode in the server smb.conf path.

This patch exposes the existing SERVERCONFFILE env variable to the
tests. DC_SERVERCONFFILE has been added for 2 DC testenvs, where we need
the PDC's smb.conf.

The benefit of doing this way is the filepath/testenv-dependency logic
is all self-contained with the Perl code, and it doesn't bleed out into
tests.py as well.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
selftest/selftest.pl
selftest/target/Samba4.pm

index 3ee266c4d0ac9e94c74d132d4c12e5c5b620696e..b7fb2d841ac43e1c730a12348c8cf2795016f2fb 100755 (executable)
@@ -885,6 +885,13 @@ my @exported_envvars = (
        "NETBIOSALIAS",
        "SAMSID",
 
+       # only use these 2 as a last resort. Some tests need to test both client-
+       # side and server-side. In this case, run as default client, ans access
+       # server's smb.conf as needed, typically using:
+       #  param.LoadParm(filename_for_non_global_lp=os.environ['SERVERCONFFILE'])
+       "SERVERCONFFILE",
+       "DC_SERVERCONFFILE",
+
        # user stuff
        "USERNAME",
        "USERID",
index af438f5b62ab105378f7c8bec27a8edadba0ea08..d73ac1eab1a66bdd9cef488e0949ffd36cc3cf38 100755 (executable)
@@ -1329,6 +1329,7 @@ rpc_server:tcpip = no
        $ret->{DC_SERVER} = $dcvars->{DC_SERVER};
        $ret->{DC_SERVER_IP} = $dcvars->{DC_SERVER_IP};
        $ret->{DC_SERVER_IPV6} = $dcvars->{DC_SERVER_IPV6};
+       $ret->{DC_SERVERCONFFILE} = $dcvars->{SERVERCONFFILE};
        $ret->{DC_NETBIOSNAME} = $dcvars->{DC_NETBIOSNAME};
        $ret->{DC_USERNAME} = $dcvars->{DC_USERNAME};
        $ret->{DC_PASSWORD} = $dcvars->{DC_PASSWORD};
@@ -1432,6 +1433,7 @@ sub provision_rpc_proxy($$$)
        $ret->{DC_SERVER} = $dcvars->{DC_SERVER};
        $ret->{DC_SERVER_IP} = $dcvars->{DC_SERVER_IP};
        $ret->{DC_SERVER_IPV6} = $dcvars->{DC_SERVER_IPV6};
+       $ret->{DC_SERVERCONFFILE} = $dcvars->{SERVERCONFFILE};
        $ret->{DC_NETBIOSNAME} = $dcvars->{DC_NETBIOSNAME};
        $ret->{DC_USERNAME} = $dcvars->{DC_USERNAME};
        $ret->{DC_PASSWORD} = $dcvars->{DC_PASSWORD};
@@ -1508,6 +1510,7 @@ sub provision_promoted_dc($$$)
        $ret->{DC_SERVER} = $dcvars->{DC_SERVER};
        $ret->{DC_SERVER_IP} = $dcvars->{DC_SERVER_IP};
        $ret->{DC_SERVER_IPV6} = $dcvars->{DC_SERVER_IPV6};
+       $ret->{DC_SERVERCONFFILE} = $dcvars->{SERVERCONFFILE};
        $ret->{DC_NETBIOSNAME} = $dcvars->{DC_NETBIOSNAME};
        $ret->{DC_USERNAME} = $dcvars->{DC_USERNAME};
        $ret->{DC_PASSWORD} = $dcvars->{DC_PASSWORD};
@@ -1590,6 +1593,7 @@ sub provision_vampire_dc($$$)
        $ret->{DC_SERVER} = $dcvars->{DC_SERVER};
        $ret->{DC_SERVER_IP} = $dcvars->{DC_SERVER_IP};
        $ret->{DC_SERVER_IPV6} = $dcvars->{DC_SERVER_IPV6};
+       $ret->{DC_SERVERCONFFILE} = $dcvars->{SERVERCONFFILE};
        $ret->{DC_NETBIOSNAME} = $dcvars->{DC_NETBIOSNAME};
        $ret->{DC_USERNAME} = $dcvars->{DC_USERNAME};
        $ret->{DC_PASSWORD} = $dcvars->{DC_PASSWORD};
@@ -1658,6 +1662,7 @@ sub provision_subdom_dc($$$)
        $ret->{DC_SERVER} = $dcvars->{DC_SERVER};
        $ret->{DC_SERVER_IP} = $dcvars->{DC_SERVER_IP};
        $ret->{DC_SERVER_IPV6} = $dcvars->{DC_SERVER_IPV6};
+       $ret->{DC_SERVERCONFFILE} = $dcvars->{SERVERCONFFILE};
        $ret->{DC_NETBIOSNAME} = $dcvars->{DC_NETBIOSNAME};
        $ret->{DC_USERNAME} = $dcvars->{DC_USERNAME};
        $ret->{DC_PASSWORD} = $dcvars->{DC_PASSWORD};
@@ -1958,6 +1963,7 @@ sub provision_rodc($$$)
        $ret->{DC_SERVER} = $dcvars->{DC_SERVER};
        $ret->{DC_SERVER_IP} = $dcvars->{DC_SERVER_IP};
        $ret->{DC_SERVER_IPV6} = $dcvars->{DC_SERVER_IPV6};
+       $ret->{DC_SERVERCONFFILE} = $dcvars->{SERVERCONFFILE};
        $ret->{DC_NETBIOSNAME} = $dcvars->{DC_NETBIOSNAME};
        $ret->{DC_USERNAME} = $dcvars->{DC_USERNAME};
        $ret->{DC_PASSWORD} = $dcvars->{DC_PASSWORD};