2015-10-23 05:38:23 +03:00
#!/bin/sh
if [ $# -lt 1 ] ; then
2022-04-22 16:46:04 +03:00
cat <<EOF
2023-09-05 07:22:01 +03:00
Usage: demote-saveddb.sh PREFIX RELEASE
2015-10-23 05:38:23 +03:00
EOF
2022-04-22 16:46:04 +03:00
exit 1
2015-10-23 05:38:23 +03:00
fi
PREFIX_ABS = " $1 "
shift 1
2020-10-20 21:47:43 +03:00
failed = 0
2015-10-23 05:38:23 +03:00
2022-04-22 16:46:04 +03:00
. $( dirname $0 ) /subunit.sh
. $( dirname $0 ) /common_test_fns.inc
2015-10-23 05:38:23 +03:00
2020-10-20 21:47:43 +03:00
samba_tree_dir = " $SRCDIR_ABS /source4/selftest/provisions/multi-dc-samba-master-c596ac6 "
2015-10-23 05:38:23 +03:00
2022-12-22 15:04:25 +03:00
samba_tdbrestore = $( system_or_builddir_binary tdbrestore " ${ BINDIR } " )
2015-10-23 05:38:23 +03:00
2020-10-20 21:47:43 +03:00
# The undump script and the provision data is not part of release tarballs,
# skip the tests in this case!
samba_undump = " $SRCDIR_ABS /source4/selftest/provisions/undump.sh "
if [ ! -x $samba_undump ] || [ ! -d $samba_tree_dir ] ; then
2022-04-22 16:46:04 +03:00
subunit_start_test "undump"
subunit_skip_test "undump" <<EOF
2020-10-20 21:47:43 +03:00
EOF
2015-10-23 05:38:23 +03:00
2022-04-22 16:46:04 +03:00
subunit_start_test "undump"
subunit_skip_test "undump" <<EOF
2020-10-20 21:47:43 +03:00
Skipping tests - no provision!
2015-10-23 05:38:23 +03:00
EOF
2022-04-22 16:46:04 +03:00
subunit_start_test "demote-q-0-0"
subunit_skip_test "demote-q-0-0" <<EOF
2020-10-20 21:47:43 +03:00
Skipping tests - no provision!
2015-10-23 05:38:23 +03:00
EOF
2022-04-22 16:46:04 +03:00
subunit_start_test "demote-q-0-1"
subunit_skip_test "demote-q-0-1" <<EOF
2020-10-20 21:47:43 +03:00
Skipping tests - no provision!
2015-10-23 05:38:23 +03:00
EOF
2022-04-22 16:46:04 +03:00
subunit_start_test "demote-q-1-0"
subunit_skip_test "demote-q-1-0" <<EOF
2020-10-20 21:47:43 +03:00
Skipping tests - no provision!
2015-10-23 05:38:23 +03:00
EOF
2022-04-22 16:46:04 +03:00
subunit_start_test "demote-q-1-1"
subunit_skip_test "demote-q-1-1" <<EOF
2020-10-20 21:47:43 +03:00
Skipping tests - no provision!
2015-10-23 05:38:23 +03:00
EOF
2022-04-22 16:46:04 +03:00
exit 0
2015-10-23 05:38:23 +03:00
fi
2022-04-22 16:46:04 +03:00
undump( )
{
$SRCDIR_ABS /source4/selftest/provisions/undump.sh $samba_tree_dir $PREFIX_ABS $samba_tdbrestore
2020-10-20 21:47:43 +03:00
}
2022-04-22 16:46:04 +03:00
demote( )
{
$PYTHON $BINDIR /samba-tool domain demote -H tdb://$PREFIX_ABS /private/sam.ldb --remove-other-dead-server= $1
2020-10-20 21:47:43 +03:00
}
remove_directory $PREFIX_ABS
2022-04-22 16:46:04 +03:00
testit "undump" undump || failed = $( expr $failed + 1)
testit "demote-q-0-0" demote "q-0-0" || failed = $( expr $failed + 1)
2020-10-20 21:47:43 +03:00
# The database was copied of q-0-1 so this will fail
# as we can't remove our own name
2022-04-22 16:46:04 +03:00
testit_expect_failure "demote-q-0-1" demote "q-0-1" || failed = $( expr $failed + 1)
testit "demote-q-1-0" demote "q-1-0" || failed = $( expr $failed + 1)
testit "demote-q-1-1" demote "q-1-1" || failed = $( expr $failed + 1)
2020-10-20 21:47:43 +03:00
remove_directory $PREFIX_ABS
2015-10-23 05:38:23 +03:00
exit $failed