Merge "test_sorcery_memory_cache_thrash: Add unit tests for thrashing the memory cache."

This commit is contained in:
Matt Jordan
2015-06-05 18:04:24 -05:00
committed by Gerrit Code Review
2 changed files with 628 additions and 0 deletions

View File

@@ -418,6 +418,9 @@ static int remove_from_cache(struct sorcery_memory_cache *cache, const char *id,
if (!hash_object) {
return -1;
}
ast_assert(!strcmp(ast_sorcery_object_get_id(hash_object->object), id));
oldest_object = ast_heap_peek(cache->object_heap, 1);
heap_object = ast_heap_remove(cache->object_heap, hash_object);
@@ -537,6 +540,8 @@ static int mark_object_as_stale_in_cache(struct sorcery_memory_cache *cache, con
return -1;
}
ast_assert(!strcmp(ast_sorcery_object_get_id(cached->object), id));
object_stale_callback(cached, cache, 0);
ao2_ref(cached, -1);
@@ -718,6 +723,7 @@ static int sorcery_memory_cache_create(const struct ast_sorcery *sorcery, void *
ao2_unlock(cache->objects);
return -1;
}
ast_assert(ao2_container_count(cache->objects) != cache->maximum_objects);
}
if (add_to_cache(cache, cached)) {
ast_log(LOG_ERROR, "Unable to add object '%s' to the cache\n",
@@ -826,6 +832,8 @@ static void *sorcery_memory_cache_retrieve_id(const struct ast_sorcery *sorcery,
return NULL;
}
ast_assert(!strcmp(ast_sorcery_object_get_id(cached->object), id));
if (cache->object_lifetime_stale) {
struct timeval elapsed;