1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

selftest: add a test ignored spotlight/elasticsearch mapping failures

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
This commit is contained in:
Ralph Boehme 2021-10-09 16:44:25 +02:00 committed by Noel Power
parent 8ab0238abd
commit 232146775b
3 changed files with 61 additions and 0 deletions

View File

@ -0,0 +1 @@
^samba.unittests.mdsparser_es_failures.test_mdsparser_es\(none\)$

View File

@ -435,6 +435,12 @@ plantestsuite("samba.unittests.test_oLschema2ldif", "none",
if with_elasticsearch_backend:
plantestsuite("samba.unittests.mdsparser_es", "none",
[os.path.join(bindir(), "default/source3/test_mdsparser_es")] + [configuration])
plantestsuite("samba.unittests.mdsparser_es_failures", "none",
[os.path.join(bindir(), "default/source3/test_mdsparser_es"),
" --option=elasticsearch:testmappingfailures=yes",
" --option=elasticsearch:ignoreunknownattribute=yes",
" --option=elasticsearch:ignoreunknowntype=yes"] +
[configuration])
plantestsuite("samba.unittests.credentials", "none",
[os.path.join(bindir(), "default/auth/credentials/test_creds")])
plantestsuite("samba.unittests.tsocket_bsd_addr", "none",

View File

@ -161,6 +161,40 @@ static struct {
}
};
static struct {
const char *mds;
const char *es;
} map_ignore_failures[] = {
{
"*==\"Samba\"||foo==\"bar\"",
"(Samba)" PATH_QUERY_SUBEXPR
}, {
"*==\"Samba\"&&foo==\"bar\"",
"(Samba)" PATH_QUERY_SUBEXPR
}, {
"*==\"Samba\"||kMDItemContentType==\"666\"",
"(Samba)" PATH_QUERY_SUBEXPR
}, {
"*==\"Samba\"&&kMDItemContentType==\"666\"",
"(Samba)" PATH_QUERY_SUBEXPR
}, {
"*==\"Samba\"||foo==\"bar\"||kMDItemContentType==\"666\"",
"(Samba)" PATH_QUERY_SUBEXPR
}, {
"*==\"Samba\"&&foo==\"bar\"&&kMDItemContentType==\"666\"",
"(Samba)" PATH_QUERY_SUBEXPR
}, {
"foo==\"bar\"||kMDItemContentType==\"666\"||*==\"Samba\"||x!=\"6\"",
"(Samba)" PATH_QUERY_SUBEXPR
}, {
"*==\"Samba\"||InRange(foo,1,2)",
"(Samba)" PATH_QUERY_SUBEXPR
}, {
"*==\"Samba\"||foo==$time.iso(2018-10-01T10:00:00Z)",
"(Samba)" PATH_QUERY_SUBEXPR
}
};
static void test_mdsparser_es(void **state)
{
TALLOC_CTX *frame = talloc_stackframe();
@ -192,6 +226,26 @@ static void test_mdsparser_es(void **state)
assert_string_equal(es_query, map[i].es);
}
if (!lp_parm_bool(GLOBAL_SECTION_SNUM,
"elasticsearch",
"test mapping failures",
false))
{
goto done;
}
for (i = 0; i < ARRAY_SIZE(map_ignore_failures); i++) {
DBG_DEBUG("Mapping: %s\n", map_ignore_failures[i].mds);
ok = map_spotlight_to_es_query(frame,
mappings,
path_scope,
map_ignore_failures[i].mds,
&es_query);
assert_true(ok);
assert_string_equal(es_query, map_ignore_failures[i].es);
}
done:
json_decref(mappings);
TALLOC_FREE(frame);
}