s4:rpc_server: remove unused dcesrv_connection_context->private_date
[samba.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 OLD_RELEASE="release-4-1-0rc3"
19 old_release_dir=`dirname $0`/../../source4/selftest/provisions/$OLD_RELEASE
20
21 cleanup_output_directories()
22 {
23     if [ -d $PREFIX_ABS/2012R2_schema ]; then
24         rm -fr $PREFIX_ABS/2012R2_schema
25     fi
26
27     if [ -d $PREFIX_ABS/$RELEASE ]; then
28         rm -fr $PREFIX_ABS/$RELEASE
29     fi
30
31     if [ -d $PREFIX_ABS/$OLD_RELEASE ]; then
32         rm -fr $PREFIX_ABS/$OLD_RELEASE
33     fi
34 }
35
36 undump() {
37    if test -x $BINDIR/tdbrestore;
38    then
39        `dirname $0`/../../source4/selftest/provisions/undump.sh $release_dir $PREFIX_ABS/$RELEASE $BINDIR/tdbrestore
40    else
41        `dirname $0`/../../source4/selftest/provisions/undump.sh $release_dir $PREFIX_ABS/$RELEASE
42    fi
43 }
44
45 undump_old() {
46    if test -x $BINDIR/tdbrestore;
47    then
48        `dirname $0`/../../source4/selftest/provisions/undump.sh $old_release_dir $PREFIX_ABS/$OLD_RELEASE $BINDIR/tdbrestore
49    else
50        `dirname $0`/../../source4/selftest/provisions/undump.sh $old_release_dir $PREFIX_ABS/$OLD_RELEASE
51    fi
52 }
53
54
55 PROVISION_OPTS="--use-ntvfs --host-ip6=::1 --host-ip=127.0.0.1"
56
57 provision_2012r2() {
58     $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
59 }
60
61 ldapcmp_ignore() {
62     # At some point we will need to ignore, but right now, it should be perfect
63     IGNORE_ATTRS=$1
64     $PYTHON $BINDIR/samba-tool ldapcmp tdb://$PREFIX_ABS/$2/private/sam.ldb tdb://$PREFIX_ABS/$3/private/sam.ldb --two --skip-missing-dn
65 }
66
67 ldapcmp() {
68     # Our functional prep doesn't set these values as they were not provided
69     # These are XML schema based enumerations which are used for claims
70     ldapcmp_ignore "msDS-ClaimPossibleValues" "$RELEASE"  "2012R2_schema"
71 }
72
73 functional_prep() {
74     $PYTHON $BINDIR/samba-tool domain functionalprep -H tdb://$PREFIX_ABS/2012R2_schema/private/sam.ldb --function-level=2012_R2
75 }
76
77 functional_prep_old() {
78     $PYTHON $BINDIR/samba-tool domain functionalprep -H tdb://$PREFIX_ABS/$OLD_RELEASE/private/sam.ldb --function-level=2012_R2
79 }
80
81 steal_roles() {
82     # Must steal schema master and infrastructure roles first
83     $PYTHON $BINDIR/samba-tool fsmo seize --role=schema -H tdb://$PREFIX_ABS/$OLD_RELEASE/private/sam.ldb --force
84     $PYTHON $BINDIR/samba-tool fsmo seize --role=infrastructure -H tdb://$PREFIX_ABS/$OLD_RELEASE/private/sam.ldb --force
85 }
86
87 schema_upgrade() {
88     $PYTHON $BINDIR/samba-tool domain schemaupgrade -H tdb://$PREFIX_ABS/$OLD_RELEASE/private/sam.ldb --schema=2012_R2
89 }
90
91 # double-check we cleaned up from the last test run
92 cleanup_output_directories
93
94 testit $RELEASE undump
95
96 # Provision a DC based on 2012R2 schema
97 testit "provision_2012R2_schema" provision_2012r2
98
99 # Perform functional prep up to 2012 R2 level
100 testit "functional_prep" functional_prep
101
102 # check that the databases are now the same
103 testit "check_databases_same" ldapcmp
104
105 testit $OLD_RELEASE undump_old
106
107 testit "steal_roles" steal_roles
108
109 testit "schema_upgrade" schema_upgrade
110
111 testit "functional_prep_old" functional_prep_old
112
113 cleanup_output_directories
114
115 exit $failed