diff options
author | Tim Beale <timbeale@catalyst.net.nz> | 2018-06-11 11:02:11 +1200 |
---|---|---|
committer | Douglas Bagnall <dbagnall@samba.org> | 2018-07-05 04:01:26 +0200 |
commit | 20568e00e68631cf7b514024ba2926fd8c73c8e1 (patch) | |
tree | 1fec765bd33588169fd1466dfb920b3f4056b528 /selftest | |
parent | 6681f904aaf0cd9d757572a4f41376bd2e1c01fd (diff) | |
download | samba-20568e00e68631cf7b514024ba2926fd8c73c8e1.tar.gz |
selftest: Add dedicated RENAMEDC testenv for 'backup rename'
Add a new testenv that's similar to the existing restoredc, except we
use 'backup rename' to rename the domain as we back it up.
Restoring this backup then proves that a valid DC can be started from a
renamed backup.
Run the same sub-set of RESTOREDC tests to prove that the new testenv is
sound.
Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'selftest')
-rw-r--r-- | selftest/target/Samba.pm | 1 | ||||
-rwxr-xr-x | selftest/target/Samba4.pm | 45 |
2 files changed, 46 insertions, 0 deletions
diff --git a/selftest/target/Samba.pm b/selftest/target/Samba.pm index 9c79345797f..349856716b3 100644 --- a/selftest/target/Samba.pm +++ b/selftest/target/Samba.pm @@ -409,6 +409,7 @@ sub get_interface($) $interfaces{"vampire2000dc"} = 39; $interfaces{"backupfromdc"} = 40; $interfaces{"restoredc"} = 41; + $interfaces{"renamedc"} = 42; # update lib/socket_wrapper/socket_wrapper.c # #define MAX_WRAPPED_INTERFACES 64 diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm index 58fbe27e6fe..4c03ad2537d 100755 --- a/selftest/target/Samba4.pm +++ b/selftest/target/Samba4.pm @@ -2161,6 +2161,7 @@ sub check_env($$) s4member => ["ad_dc_ntvfs"], restoredc => ["backupfromdc"], + renamedc => ["backupfromdc"], none => [], ); @@ -2790,6 +2791,50 @@ sub setup_restoredc return $env; } +# Set up a DC testenv solely by using the 'samba-tool domain backup rename' and +# restore commands. This proves that we can backup and rename an online DC +# ('backupfromdc') and use the backup file to create a valid, working samba DC. +sub setup_renamedc +{ + # note: dcvars contains the env info for the dependent testenv ('backupfromdc') + my ($self, $prefix, $dcvars) = @_; + print "Preparing RENAME DC...\n"; + + my $env = $self->prepare_dc_testenv($prefix, "renamedc", + "RENAMEDOMAIN", "renamedom.samba.example.com", + $dcvars->{PASSWORD}); + + # create a backup of the 'backupfromdc' which renames the domain + my $backupdir = File::Temp->newdir(); + my $backup_args = "rename $env->{DOMAIN} $env->{REALM}"; + my $backup_file = $self->create_backup($env, $dcvars, $backupdir, + $backup_args); + unless($backup_file) { + return undef; + } + + # restore the backup file to populate the rename-DC testenv + my $restore_dir = abs_path($prefix); + my $restore_opts = "--newservername=$env->{SERVER} --host-ip=$env->{SERVER_IP}"; + my $ret = $self->restore_backup_file($backup_file, $restore_opts, + $restore_dir, $env->{SERVERCONFFILE}); + unless ($ret == 0) { + return undef; + } + + # start samba for the restored DC + if (not defined($self->check_or_start($env, "standard"))) { + return undef; + } + + my $upn_array = ["$env->{REALM}.upn"]; + my $spn_array = ["$env->{REALM}.spn"]; + + $self->setup_namespaces($env, $upn_array, $spn_array); + + return $env; +} + sub setup_none { my ($self, $path) = @_; |