functionalprep.sh: New test for ensuring that the prep works correctly
[kseeger/samba-autobuild/.git] / testprogs / blackbox / functionalprep.sh
1 #!/bin/sh
2
3 if [ $# -lt 1 ]; then
4 cat <<EOF
5 Usage: $0 PREFIX
6 EOF
7 exit 1;
8 fi
9
10 PREFIX_ABS="$1"
11 shift 1
12
13 . `dirname $0`/subunit.sh
14
15 RELEASE="release-4-8-0-pre1"
16 release_dir=`dirname $0`/../../source4/selftest/provisions/$RELEASE
17
18 cleanup_output_directories()
19 {
20     if [ -d $PREFIX_ABS/2012R2_schema ]; then
21         rm -fr $PREFIX_ABS/2012R2_schema
22     fi
23
24     if [ -d $PREFIX_ABS/$RELEASE ]; then
25         rm -fr $PREFIX_ABS/$RELEASE
26     fi
27 }
28
29 undump() {
30    if test -x $BINDIR/tdbrestore;
31    then
32        `dirname $0`/../../source4/selftest/provisions/undump.sh $release_dir $PREFIX_ABS/$RELEASE $BINDIR/tdbrestore
33    else
34        `dirname $0`/../../source4/selftest/provisions/undump.sh $release_dir $PREFIX_ABS/$RELEASE
35    fi
36 }
37
38 PROVISION_OPTS="--use-ntvfs --host-ip6=::1 --host-ip=127.0.0.1"
39
40 provision_2012r2() {
41     $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
42 }
43
44 ldapcmp_ignore() {
45     # At some point we will need to ignore, but right now, it should be perfect
46     IGNORE_ATTRS=$1
47     $PYTHON $BINDIR/samba-tool ldapcmp tdb://$PREFIX_ABS/$2/private/sam.ldb tdb://$PREFIX_ABS/$3/private/sam.ldb --two
48 }
49
50 ldapcmp() {
51     # Our functional prep doesn't set these values as they were not provided
52     # These are XML schema based enumerations which are used for claims
53     ldapcmp_ignore "msDS-ClaimPossibleValues" "$RELEASE"  "2012R2_schema"
54 }
55
56 functional_prep() {
57     $BINDIR/samba-tool domain functionalprep -H tdb://$PREFIX_ABS/2012R2_schema/private/sam.ldb --function-level=2012_R2
58 }
59
60 # double-check we cleaned up from the last test run
61 cleanup_output_directories
62
63 testit $RELEASE undump
64
65 # Provision a DC based on 2012R2 schema
66 testit "provision_2012R2_schema" provision_2012r2
67
68 # Perform functional prep up to 2012 R2 level
69 testit "functional_prep" functional_prep
70
71 # check that the databases are now the same
72 testit "check_databases_same" ldapcmp
73
74 cleanup_output_directories
75
76 exit $failed