From f983b400bf4f6fb14a2174d6f58071e06e9ec832 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Thu, 21 Apr 2016 13:48:04 +0200 Subject: SYSDB: Open a timestamps cache for caching domains For all domain types, except the local domain, open a connection to a new ldb file located at /var/lib/sss/db names timestamps_$domain.ldb. Constructs the ldb file path manually in sysdb_check_upgrade_02() but that should be acceptable because nobody should be running such an old cache these days anyway. Reviewed-by: Sumit Bose --- src/tests/common_dom.c | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'src/tests') diff --git a/src/tests/common_dom.c b/src/tests/common_dom.c index cda1cfb0e..615b613c8 100644 --- a/src/tests/common_dom.c +++ b/src/tests/common_dom.c @@ -24,6 +24,8 @@ #include #include +/* Including private header makes sure we can initialize test domains. */ +#include "db/sysdb_private.h" #include "tests/common.h" static errno_t @@ -192,6 +194,10 @@ mock_domain(TALLOC_CTX *mem_ctx, /* reset ldb error if any */ ldb_reset_err_string(sysdb_ctx_get_ldb(domain->sysdb)); + if (domain->sysdb->ldb_ts != NULL) { + ldb_reset_err_string(domain->sysdb->ldb_ts); + } + /* init with an AD-style regex to be able to test flat name */ ret = sss_names_init_from_args(domain, "(((?P[^\\\\]+)\\\\(?P.+$))|" \ @@ -303,6 +309,7 @@ void test_multidom_suite_cleanup(const char *tests_path, TALLOC_CTX *tmp_ctx = NULL; char *cdb_path = NULL; char *sysdb_path = NULL; + char *sysdb_ts_path = NULL; errno_t ret; int i; @@ -332,11 +339,20 @@ void test_multidom_suite_cleanup(const char *tests_path, for (i = 0; domains[i] != NULL; i++) { if (strcmp(domains[i], LOCAL_SYSDB_FILE) == 0) { /* local domain */ - sysdb_path = talloc_asprintf(tmp_ctx, "%s/%s", - tests_path, domains[i]); + ret = sysdb_get_db_file(tmp_ctx, "local", domains[i], tests_path, + &sysdb_path, &sysdb_ts_path); + if (ret != EOK) { + goto done; + } } else { - sysdb_path = talloc_asprintf(tmp_ctx, "%s/cache_%s.ldb", - tests_path, domains[i]); + /* The mocked database doesn't really care about its provider type, just + * distinguishes between a local and non-local databases + */ + ret = sysdb_get_db_file(tmp_ctx, "fake_nonlocal", domains[i], tests_path, + &sysdb_path, &sysdb_ts_path); + if (ret != EOK) { + goto done; + } } if (sysdb_path == NULL) { DEBUG(SSSDBG_CRIT_FAILURE, "Could not construct sysdb path\n"); @@ -351,6 +367,16 @@ void test_multidom_suite_cleanup(const char *tests_path, "ldb file [%d]: (%s)\n", ret, sss_strerror(ret)); } + if (sysdb_ts_path) { + errno = 0; + ret = unlink(sysdb_ts_path); + if (ret != 0 && errno != ENOENT) { + ret = errno; + DEBUG(SSSDBG_CRIT_FAILURE, "Could not delete the test domain " + "ldb timestamp file [%d]: (%s)\n", ret, sss_strerror(ret)); + } + } + talloc_zfree(sysdb_path); } } -- cgit