diff options
author | Kinsey Moore <kmoore@digium.com> | 2013-03-08 16:00:14 +0000 |
---|---|---|
committer | Kinsey Moore <kmoore@digium.com> | 2013-03-08 16:00:14 +0000 |
commit | c6b06e40dc859125cf76bec4632bd76de42256bd (patch) | |
tree | f99d321c8621ce9285389c058d70dfb71ffe3809 /tests/test_stasis.c | |
parent | 4edd8be35cdef3b212355c48b68319f2304bc9f2 (diff) |
Add message dump capability to stasis cache layer
The cache dump mechanism allows the developer to retreive multiple
items of a given type (or of all types) from the cache residing in a
stasis caching topic in addition to the existing single-item cache
retreival mechanism. This also adds to the caching unit tests to
ensure that the new cache dump mechanism is functioning properly.
Review: https://reviewboard.asterisk.org/r/2367/
(issue ASTERISK-21097)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@382705 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'tests/test_stasis.c')
-rw-r--r-- | tests/test_stasis.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/test_stasis.c b/tests/test_stasis.c index b05264106..36822941e 100644 --- a/tests/test_stasis.c +++ b/tests/test_stasis.c @@ -564,6 +564,7 @@ AST_TEST_DEFINE(cache) RAII_VAR(struct stasis_message *, test_message1_clear, NULL, ao2_cleanup); int actual_len; struct stasis_cache_update *actual_update; + struct ao2_container *cache_dump; switch (cmd) { case TEST_INIT: @@ -599,6 +600,12 @@ AST_TEST_DEFINE(cache) actual_len = consumer_wait_for(consumer, 2); ast_test_validate(test, 2 == actual_len); + /* Dump the cache to ensure that it has the correct number of items in it */ + cache_dump = stasis_cache_dump(caching_topic, NULL); + ast_test_validate(test, 2 == ao2_container_count(cache_dump)); + ao2_ref(cache_dump, -1); + cache_dump = NULL; + /* Check for new snapshot messages */ ast_test_validate(test, stasis_cache_update() == stasis_message_type(consumer->messages_rxed[0])); actual_update = stasis_message_data(consumer->messages_rxed[0]); @@ -634,6 +641,12 @@ AST_TEST_DEFINE(cache) /* stasis_cache_get returned a ref, so unref test_message2_2 */ ao2_ref(test_message2_2, -1); + /* Dump the cache to ensure that it has the correct number of items in it */ + cache_dump = stasis_cache_dump(caching_topic, NULL); + ast_test_validate(test, 2 == ao2_container_count(cache_dump)); + ao2_ref(cache_dump, -1); + cache_dump = NULL; + /* Clear snapshot 1 */ test_message1_clear = stasis_cache_clear_create(cache_type, "1"); ast_test_validate(test, NULL != test_message1_clear); @@ -648,6 +661,18 @@ AST_TEST_DEFINE(cache) ast_test_validate(test, NULL == actual_update->new_snapshot); ast_test_validate(test, NULL == stasis_cache_get(caching_topic, cache_type, "1")); + /* Dump the cache to ensure that it has the correct number of items in it */ + cache_dump = stasis_cache_dump(caching_topic, NULL); + ast_test_validate(test, 1 == ao2_container_count(cache_dump)); + ao2_ref(cache_dump, -1); + cache_dump = NULL; + + /* Dump the cache to ensure that it has no subscription change items in it since those aren't cached */ + cache_dump = stasis_cache_dump(caching_topic, stasis_subscription_change()); + ast_test_validate(test, 0 == ao2_container_count(cache_dump)); + ao2_ref(cache_dump, -1); + cache_dump = NULL; + return AST_TEST_PASS; } |