Skip to content

Commit

Permalink
Fix Flaky info modules Test (#2896)
Browse files Browse the repository at this point in the history
  • Loading branch information
Avital-Fine committed Jul 27, 2022
1 parent 7d28f76 commit a1d597f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/spec.c
Expand Up @@ -1187,7 +1187,6 @@ static void IndexSpec_FreeUnlinkedData(IndexSpec *spec) {
// Free fields data
if (spec->fields != NULL) {
for (size_t i = 0; i < spec->numFields; i++) {
FieldsGlobalStats_UpdateStats(spec->fields + i, -1);
if (spec->fields[i].name != spec->fields[i].path) {
rm_free(spec->fields[i].name);
}
Expand Down Expand Up @@ -1258,6 +1257,12 @@ void IndexSpec_FreeInternals(IndexSpec *spec) {
StopWordList_Unref(spec->stopwords);
spec->stopwords = NULL;
}
// Reset fields stats
if (spec->fields != NULL) {
for (size_t i = 0; i < spec->numFields; i++) {
FieldsGlobalStats_UpdateStats(spec->fields + i, -1);
}
}
// Free unlinked index spec on a second thread
if (RSGlobalConfig.freeResourcesThread == false) {
IndexSpec_FreeUnlinkedData(spec);
Expand Down
2 changes: 2 additions & 0 deletions tests/pytests/test_info_modules.py
Expand Up @@ -84,6 +84,7 @@ def testInfoModulesAlter(env):
# idx1Info = info['search_info_' + idx1]
# env.assertEqual(idx1Info['search_field_2'], 'identifier=n,attribute=n,type=NUMERIC,NOINDEX=ON')


def testInfoModulesDrop(env):
conn = env.getConnection()
idx1 = 'idx1'
Expand All @@ -106,6 +107,7 @@ def testInfoModulesDrop(env):
env.assertEqual(fieldsInfo['search_fields_text'], 'Text=2,Sortable=1')
env.assertFalse('search_fields_numeric' in fieldsInfo) # no numeric fields since we removed idx2


def testInfoModulesAfterReload(env):
conn = env.getConnection()
idx1 = 'idx1'
Expand Down

0 comments on commit a1d597f

Please sign in to comment.