ctdb-failover: Split statd_callout add-client/del-client
[Samba.git] / testprogs / blackbox / functionalprep.sh
blob94099f46d122a1233133c8b153a0af428f054137
1 #!/bin/sh
3 if [ $# -lt 1 ]; then
4 cat <<EOF
5 Usage: $0 PREFIX
6 EOF
7 exit 1
8 fi
10 PREFIX_ABS="$1"
11 shift 1
13 failed=0
15 . $(dirname $0)/subunit.sh
16 . $(dirname $0)/common_test_fns.inc
18 RELEASE="release-4-8-0-pre1"
19 release_dir="$SRCDIR_ABS/source4/selftest/provisions/$RELEASE"
21 OLD_RELEASE="release-4-1-0rc3"
22 old_release_dir="$SRCDIR_ABS/source4/selftest/provisions/$OLD_RELEASE"
24 samba_tdbrestore=$(system_or_builddir_binary tdbrestore "${BINDIR}")
26 samba_undump="$SRCDIR_ABS/source4/selftest/provisions/undump.sh"
28 if [ ! -x $samba_undump ] || [ ! -d $release_dir ] || [ ! -d $old_release_dir ]; then
29 subunit_start_test $RELEASE
30 subunit_skip_test $RELEASE <<EOF
31 no test provision
32 EOF
34 subunit_start_test "functional_prep"
35 subunit_skip_test "functional_prep" <<EOF
36 no test provision
37 EOF
39 subunit_start_test "functional_prep_old"
40 subunit_skip_test "functional_prep_old" <<EOF
41 no test provision
42 EOF
44 exit 0
47 cleanup_output_directories()
49 remove_directory $PREFIX_ABS/2012R2_schema
50 remove_directory $PREFIX_ABS/2019_schema
51 remove_directory $PREFIX_ABS/$RELEASE
52 remove_directory $PREFIX_ABS/$OLD_RELEASE
55 undump()
57 $samba_undump $release_dir $PREFIX_ABS/$RELEASE $samba_tdbrestore
60 undump_old()
62 $samba_undump $old_release_dir $PREFIX_ABS/$OLD_RELEASE $samba_tdbrestore
65 PROVISION_OPTS="--use-ntvfs --host-ip6=::1 --host-ip=127.0.0.1"
67 provision_schema_2019_prep_skip()
69 $PYTHON $BINDIR/samba-tool domain provision $PROVISION_OPTS --domain=REALM --realm=REALM.COM --targetdir=$PREFIX_ABS/2019_schema --base-schema=2019 --adprep-level=SKIP --host-name=FLPREP
72 provision_2012r2()
74 $PYTHON $BINDIR/samba-tool domain provision $PROVISION_OPTS --domain=REALM --realm=REALM.COM --targetdir=$PREFIX_ABS/2012R2_schema --base-schema=2012_R2 --host-name=FLPREP
77 ldapcmp_ignore()
79 # At some point we will need to ignore, but right now, it should be perfect
80 IGNORE_ATTRS=$1
81 $PYTHON $BINDIR/samba-tool ldapcmp tdb://$PREFIX_ABS/$2/private/sam.ldb tdb://$PREFIX_ABS/$3/private/sam.ldb --two --skip-missing-dn --filter msDS-SupportedEncryptionTypes,servicePrincipalName
84 ldapcmp()
86 # Our functional prep doesn't set these values as they were not provided
87 # These are XML schema based enumerations which are used for claims
88 ldapcmp_ignore "msDS-ClaimPossibleValues" "$RELEASE" "2012R2_schema"
91 functional_prep_2016()
93 $PYTHON $BINDIR/samba-tool domain functionalprep -H tdb://$PREFIX_ABS/2019_schema/private/sam.ldb --function-level=2016
96 level_raise_2012R2()
98 $PYTHON $BINDIR/samba-tool domain level raise \
99 -H tdb://$PREFIX_ABS/2019_schema/private/sam.ldb \
100 --option="ad dc functional level = 2012_R2" \
101 --domain-level=2012_R2 --forest-level=2012_R2
104 level_raise_2016()
106 $PYTHON $BINDIR/samba-tool domain level raise \
107 -H tdb://$PREFIX_ABS/2019_schema/private/sam.ldb \
108 --option="ad dc functional level = 2016" \
109 --domain-level=2016 --forest-level=2016
112 functional_prep_2012R2()
114 $PYTHON $BINDIR/samba-tool domain functionalprep -H tdb://$PREFIX_ABS/2012R2_schema/private/sam.ldb --function-level=2012_R2
117 functional_prep_2012R2_old()
119 $PYTHON $BINDIR/samba-tool domain functionalprep -H tdb://$PREFIX_ABS/$OLD_RELEASE/private/sam.ldb --function-level=2012_R2
122 functional_prep_2016_old()
124 $PYTHON $BINDIR/samba-tool domain functionalprep -H tdb://$PREFIX_ABS/$OLD_RELEASE/private/sam.ldb --function-level=2016
127 steal_roles()
129 # Must steal schema master and infrastructure roles first
130 $PYTHON $BINDIR/samba-tool fsmo seize --role=schema -H tdb://$PREFIX_ABS/$OLD_RELEASE/private/sam.ldb --force
131 $PYTHON $BINDIR/samba-tool fsmo seize --role=infrastructure -H tdb://$PREFIX_ABS/$OLD_RELEASE/private/sam.ldb --force
134 schema_upgrade_2012R2_old()
136 $PYTHON $BINDIR/samba-tool domain schemaupgrade -H tdb://$PREFIX_ABS/$OLD_RELEASE/private/sam.ldb --schema=2012_R2
139 schema_upgrade_2019_old()
141 $PYTHON $BINDIR/samba-tool domain schemaupgrade -H tdb://$PREFIX_ABS/$OLD_RELEASE/private/sam.ldb --schema=2019
144 # double-check we cleaned up from the last test run
145 cleanup_output_directories
147 testit $RELEASE undump || failed=$(expr $failed + 1)
149 # Provision a DC based on 2012R2 schema
150 testit "provision_2012R2_schema" provision_2012r2 || failed=$(expr $failed + 1)
152 # Perform functional prep up to 2012 R2 level
153 testit "functional_prep_2012R2" functional_prep_2012R2 || failed=$(expr $failed + 1)
155 # check that the databases are now the same
156 testit "check_databases_same" ldapcmp || failed=$(expr $failed + 1)
158 testit $OLD_RELEASE undump_old || failed=$(expr $failed + 1)
160 testit "steal_roles" steal_roles || failed=$(expr $failed + 1)
162 testit "schema_upgrade_2012R2_old" schema_upgrade_2012R2_old || failed=$(expr $failed + 1)
163 testit "functional_prep_2012R2_old" functional_prep_2012R2_old || failed=$(expr $failed + 1)
165 testit "schema_upgrade_2019_old" schema_upgrade_2019_old || failed=$(expr $failed + 1)
166 testit "functional_prep_2016_old" functional_prep_2016_old || failed=$(expr $failed + 1)
168 cleanup_output_directories
170 # Provision a DC based on 2019 schema
171 testit "provision_schema_2019_prep_skip" provision_schema_2019_prep_skip || failed=$(expr $failed + 1)
173 # Perform functional prep up to 2016 level
174 testit "functional_prep_2016" functional_prep_2016 || failed=$(expr $failed + 1)
176 # raise the levels to 2012_R2
177 testit "level_raise_2012R2" level_raise_2012R2 || failed=$(expr $failed + 1)
178 # raise the levels to 2016
179 testit "level_raise_2016" level_raise_2016 || failed=$(expr $failed + 1)
181 cleanup_output_directories
183 exit $failed