The branch, master has been updated
       via  7f625f9 ldb_mod_op_test: Make sure that closing the database frees 
locks
       via  87708c3 ldb_mod_op_test: Add new nested transactions test
       via  7b8f540 selftest: Change name to sam.ldb to align with new 
partition module assumptions
       via  0009a12 ldb: Remove python warning in tests/python/index.py
      from  4014499 ldb_tdb: Build a key value operation library

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 7f625f9b27b229f74a88dfe6d86fadd060c47160
Author: Gary Lockyer <g...@catalyst.net.nz>
Date:   Tue Jan 23 11:03:16 2018 +1300

    ldb_mod_op_test: Make sure that closing the database frees locks
    
    Without the destructor firing, this test used to pass, but now we show
    that we must be able to open a new ldb handle.
    
    Signed-off-by: Gary Lockyer <g...@catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>
    
    Autobuild-User(master): Andrew Bartlett <abart...@samba.org>
    Autobuild-Date(master): Wed Mar  7 04:38:02 CET 2018 on sn-devel-144

commit 87708c3f91fbcbe224d2a71119a420b59c6e950e
Author: Gary Lockyer <g...@catalyst.net.nz>
Date:   Fri Jan 19 09:28:14 2018 +1300

    ldb_mod_op_test: Add new nested transactions test
    
    Signed-off-by: Gary Lockyer <g...@catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>

commit 7b8f540b8d2132d9151fae4a3f2d6394fe8028ef
Author: Gary Lockyer <g...@catalyst.net.nz>
Date:   Thu Jan 11 14:27:40 2018 +1300

    selftest: Change name to sam.ldb to align with new partition module 
assumptions
    
    Signed-off-by: Gary Lockyer <g...@catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>

commit 0009a12b1f4798b4c83cd36efdede8db0ba7b790
Author: Gary Lockyer <g...@catalyst.net.nz>
Date:   Tue Mar 6 15:30:43 2018 +1300

    ldb: Remove python warning in tests/python/index.py
    
    Signed-off-by: Gary Lockyer <g...@catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>

-----------------------------------------------------------------------

Summary of changes:
 lib/ldb/tests/ldb_mod_op_test.c | 91 +++++++++++++++++++++++++++++++++++++++++
 lib/ldb/tests/python/index.py   |  2 +-
 python/samba/tests/samba3sam.py |  2 +-
 3 files changed, 93 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/ldb/tests/ldb_mod_op_test.c b/lib/ldb/tests/ldb_mod_op_test.c
index 5878143..b911302 100644
--- a/lib/ldb/tests/ldb_mod_op_test.c
+++ b/lib/ldb/tests/ldb_mod_op_test.c
@@ -626,6 +626,46 @@ static void test_transactions(void **state)
        assert_int_equal(res->count, 0);
 }
 
+static void test_nested_transactions(void **state)
+{
+       int ret;
+       struct ldbtest_ctx *test_ctx = talloc_get_type_abort(*state,
+                       struct ldbtest_ctx);
+       struct ldb_result *res;
+
+       /* start lev-0 transaction */
+       ret = ldb_transaction_start(test_ctx->ldb);
+       assert_int_equal(ret, 0);
+
+       add_keyval(test_ctx, "vegetable", "carrot");
+
+
+       /* start another lev-1 nested transaction */
+       ret = ldb_transaction_start(test_ctx->ldb);
+       assert_int_equal(ret, 0);
+
+       add_keyval(test_ctx, "fruit", "apple");
+
+       /* abort lev-1 nested transaction */
+       ret = ldb_transaction_cancel(test_ctx->ldb);
+       assert_int_equal(ret, 0);
+
+       /* commit lev-0 transaction */
+       ret = ldb_transaction_commit(test_ctx->ldb);
+       assert_int_equal(ret, 0);
+
+       res = get_keyval(test_ctx, "vegetable", "carrot");
+       assert_non_null(res);
+       assert_int_equal(res->count, 1);
+
+       /* This documents the current ldb behaviour,  i.e. nested
+        * transactions are not supported.  And the cancellation of the nested
+        * transaction has no effect.
+        */
+       res = get_keyval(test_ctx, "fruit", "apple");
+       assert_non_null(res);
+       assert_int_equal(res->count, 1);
+}
 struct ldb_mod_test_ctx {
        struct ldbtest_ctx *ldb_test_ctx;
        const char *entry_dn;
@@ -3609,6 +3649,50 @@ static void 
test_ldb_guid_index_duplicate_dn_logging(void **state)
        talloc_free(tmp_ctx);
 }
 
+static void test_ldb_talloc_destructor_transaction_cleanup(void **state)
+{
+       struct ldbtest_ctx *test_ctx = NULL;
+
+       test_ctx = talloc_get_type_abort(*state, struct ldbtest_ctx);
+       assert_non_null(test_ctx);
+
+       ldb_transaction_start(test_ctx->ldb);
+
+       /*
+        * Trigger the destructor
+        */
+       TALLOC_FREE(test_ctx->ldb);
+
+       /*
+        * Now ensure that a new connection can be opened
+        */
+       {
+               TALLOC_CTX *tctx = talloc_new(test_ctx);
+               struct ldbtest_ctx *ctx = talloc_zero(tctx, struct ldbtest_ctx);
+               struct ldb_dn *basedn;
+               struct ldb_result *result = NULL;
+               int ret;
+
+               ldbtest_setup((void *)&ctx);
+
+               basedn = ldb_dn_new_fmt(tctx, ctx->ldb, "dc=test");
+               assert_non_null(basedn);
+
+               ret = ldb_search(ctx->ldb,
+                                tctx,
+                                &result,
+                                basedn,
+                                LDB_SCOPE_BASE,
+                                NULL,
+                                NULL);
+               assert_int_equal(ret, 0);
+               assert_non_null(result);
+               assert_int_equal(result->count, 0);
+
+               ldbtest_teardown((void *)&ctx);
+       }
+}
+
 
 int main(int argc, const char **argv)
 {
@@ -3643,6 +3727,9 @@ int main(int argc, const char **argv)
                cmocka_unit_test_setup_teardown(test_transactions,
                                                ldbtest_setup,
                                                ldbtest_teardown),
+               cmocka_unit_test_setup_teardown(test_nested_transactions,
+                                               ldbtest_setup,
+                                               ldbtest_teardown),
                cmocka_unit_test_setup_teardown(test_ldb_modify_add_key,
                                                ldb_modify_test_setup,
                                                ldb_modify_test_teardown),
@@ -3765,6 +3852,10 @@ int main(int argc, const char **argv)
                        test_ldb_unique_index_duplicate_with_guid,
                        ldb_guid_index_test_setup,
                        ldb_guid_index_test_teardown),
+               cmocka_unit_test_setup_teardown(
+                       test_ldb_talloc_destructor_transaction_cleanup,
+                       ldbtest_setup,
+                       ldbtest_teardown),
        };
 
        return cmocka_run_group_tests(tests, NULL, NULL);
diff --git a/lib/ldb/tests/python/index.py b/lib/ldb/tests/python/index.py
index f7d55f6..239b2bf 100755
--- a/lib/ldb/tests/python/index.py
+++ b/lib/ldb/tests/python/index.py
@@ -1005,7 +1005,7 @@ class MaxIndexKeyLengthTests(TestCase):
         res = self.l.search(
             base="DC=SAMBA,DC=ORG",
             expression="(notUnique=" + aa_gt_max.decode("ascii") + ")")
-        self.assertEquals(2, len(res))
+        self.assertEqual(2, len(res))
         self.assertTrue(
             contains(res, "OU=01,OU=MODIFY_NON_UNIQUE,DC=SAMBA,DC=ORG"))
         self.assertTrue(
diff --git a/python/samba/tests/samba3sam.py b/python/samba/tests/samba3sam.py
index 929523b..bfc7932 100644
--- a/python/samba/tests/samba3sam.py
+++ b/python/samba/tests/samba3sam.py
@@ -73,7 +73,7 @@ class MapBaseTestCase(TestCaseInTempDir):
         def make_s4dn(basedn, rdn):
             return "%s,%s" % (rdn, basedn)
 
-        self.ldbfile = os.path.join(self.tempdir, "test.ldb")
+        self.ldbfile = os.path.join(self.tempdir, "sam.ldb")
         self.ldburl = "tdb://" + self.ldbfile
 
         tempdir = self.tempdir


-- 
Samba Shared Repository

Reply via email to