functionalprep.sh: New test for ensuring that the prep works correctly
authorGarming Sam <garming@catalyst.net.nz>
Fri, 15 Dec 2017 02:43:32 +0000 (15:43 +1300)
committerGarming Sam <garming@samba.org>
Wed, 20 Dec 2017 22:13:12 +0000 (23:13 +0100)
Signed-off-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
selftest/tests.py
testprogs/blackbox/functionalprep.sh [new file with mode: 0755]

index 713e9d3fbcd35d606975b764f24fa863a765579c..1966c286835de0c0361d504f90ae255b2a6b43a9 100644 (file)
@@ -136,6 +136,11 @@ plantestsuite(
     ["PYTHON=%s" % python,
      os.path.join(bbdir, "schemaupgrade.sh"),
      '$PREFIX_ABS/provision', configuration])
+plantestsuite(
+    "samba4.blackbox.functionalprep", "none",
+    ["PYTHON=%s" % python,
+     os.path.join(bbdir, "functionalprep.sh"),
+     '$PREFIX_ABS/provision', configuration])
 planpythontestsuite("none", "samba.tests.upgradeprovision")
 planpythontestsuite("none", "samba.tests.xattr", py3_compatible=True)
 planpythontestsuite("none", "samba.tests.ntacls")
diff --git a/testprogs/blackbox/functionalprep.sh b/testprogs/blackbox/functionalprep.sh
new file mode 100755 (executable)
index 0000000..8bc2d24
--- /dev/null
@@ -0,0 +1,76 @@
+#!/bin/sh
+
+if [ $# -lt 1 ]; then
+cat <<EOF
+Usage: $0 PREFIX
+EOF
+exit 1;
+fi
+
+PREFIX_ABS="$1"
+shift 1
+
+. `dirname $0`/subunit.sh
+
+RELEASE="release-4-8-0-pre1"
+release_dir=`dirname $0`/../../source4/selftest/provisions/$RELEASE
+
+cleanup_output_directories()
+{
+    if [ -d $PREFIX_ABS/2012R2_schema ]; then
+        rm -fr $PREFIX_ABS/2012R2_schema
+    fi
+
+    if [ -d $PREFIX_ABS/$RELEASE ]; then
+        rm -fr $PREFIX_ABS/$RELEASE
+    fi
+}
+
+undump() {
+   if test -x $BINDIR/tdbrestore;
+   then
+       `dirname $0`/../../source4/selftest/provisions/undump.sh $release_dir $PREFIX_ABS/$RELEASE $BINDIR/tdbrestore
+   else
+       `dirname $0`/../../source4/selftest/provisions/undump.sh $release_dir $PREFIX_ABS/$RELEASE
+   fi
+}
+
+PROVISION_OPTS="--use-ntvfs --host-ip6=::1 --host-ip=127.0.0.1"
+
+provision_2012r2() {
+    $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
+}
+
+ldapcmp_ignore() {
+    # At some point we will need to ignore, but right now, it should be perfect
+    IGNORE_ATTRS=$1
+    $PYTHON $BINDIR/samba-tool ldapcmp tdb://$PREFIX_ABS/$2/private/sam.ldb tdb://$PREFIX_ABS/$3/private/sam.ldb --two
+}
+
+ldapcmp() {
+    # Our functional prep doesn't set these values as they were not provided
+    # These are XML schema based enumerations which are used for claims
+    ldapcmp_ignore "msDS-ClaimPossibleValues" "$RELEASE"  "2012R2_schema"
+}
+
+functional_prep() {
+    $BINDIR/samba-tool domain functionalprep -H tdb://$PREFIX_ABS/2012R2_schema/private/sam.ldb --function-level=2012_R2
+}
+
+# double-check we cleaned up from the last test run
+cleanup_output_directories
+
+testit $RELEASE undump
+
+# Provision a DC based on 2012R2 schema
+testit "provision_2012R2_schema" provision_2012r2
+
+# Perform functional prep up to 2012 R2 level
+testit "functional_prep" functional_prep
+
+# check that the databases are now the same
+testit "check_databases_same" ldapcmp
+
+cleanup_output_directories
+
+exit $failed