diff options
author | Gary Lockyer <gary@catalyst.net.nz> | 2019-08-26 16:34:29 +1200 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2019-08-26 23:59:36 +0000 |
commit | 41aaeaf1fe921311f183d5c08ff121a9ccc4c5b4 (patch) | |
tree | 5bc4be35f9bf75a85cc0326c1e2a3ee3f79de9af | |
parent | 085e179dcb6a06f664d5447a2bee287f0a3698f4 (diff) | |
download | samba-41aaeaf1fe921311f183d5c08ff121a9ccc4c5b4.tar.gz |
ldb tests: Fix ldb_lmdb_size_test
Fix the lmdb size test which ensures that databases > 4GiB can be
written by the lmdb backend. This test is not run as part of the normal
CI run as it exhausts the available disk on the test runners.
It was broken by changes to LDB allowing the lmdb map size to be
specified, and requiring GUID indexing by default.
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
-rw-r--r-- | lib/ldb/tests/ldb_lmdb_size_test.c | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/lib/ldb/tests/ldb_lmdb_size_test.c b/lib/ldb/tests/ldb_lmdb_size_test.c index af015fa72b5..c0c4fe87204 100644 --- a/lib/ldb/tests/ldb_lmdb_size_test.c +++ b/lib/ldb/tests/ldb_lmdb_size_test.c @@ -133,12 +133,32 @@ static int ldbtest_setup(void **state) { struct ldbtest_ctx *test_ctx; int ret; + /* + * We need to to set GUID index mode as it's required now required + * by LDB + */ + struct ldb_ldif *ldif; + const char *index_ldif = + "dn: @INDEXLIST\n" + "@IDXGUID: objectUUID\n" + "@IDX_DN_GUID: GUID\n" + "\n"; + /* + * Set the lmdb map size to 8Gb + */ + const char *options[] = {"lmdb_env_size:8589934592", NULL}; ldbtest_noconn_setup((void **) &test_ctx); - ret = ldb_connect(test_ctx->ldb, test_ctx->dbpath, 0, NULL); + + ret = ldb_connect(test_ctx->ldb, test_ctx->dbpath, 0, options); assert_int_equal(ret, 0); + while ((ldif = ldb_ldif_read_string(test_ctx->ldb, &index_ldif))) { + ret = ldb_add(test_ctx->ldb, ldif->msg); + assert_int_equal(ret, LDB_SUCCESS); + } + *state = test_ctx; return 0; } @@ -171,13 +191,28 @@ static void test_db_size_gt_4GB(void **state) memset(blob, 'x', MB); + /* + * Write 6144 1Mb records to the database, this will require more than + * 4GiB of disk space + */ for (x = 0; x < 6144; x++) { + char uuid[24]; msg = ldb_msg_new(tmp_ctx); assert_non_null(msg); + /* + * Generate a unique dn for each record + */ msg->dn = ldb_dn_new_fmt(msg, test_ctx->ldb, "dc=test%d", x); assert_non_null(msg->dn); + /* + * Generate a unique uuid for each added record + */ + sprintf(uuid, "000000000000%04d", x); + ret = ldb_msg_add_string(msg, "objectUUID", uuid); + assert_int_equal(ret, 0); + ldb_transaction_start(test_ctx->ldb); ret = ldb_msg_add_string(msg, "blob", blob); assert_int_equal(ret, 0); @@ -193,6 +228,9 @@ static void test_db_size_gt_4GB(void **state) struct stat s; ret = stat(test_ctx->dbfile, &s); assert_int_equal(ret, 0); + /* + * There should have been at least 6GiB written to disk + */ assert_true(s.st_size > (6144LL * MB)); } } |