Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
Sorcery Unit Tests. More...
#include "asterisk.h"
#include "asterisk/test.h"
#include "asterisk/module.h"
#include "asterisk/sorcery.h"
#include "asterisk/logger.h"
#include "asterisk/vector.h"
#include "asterisk/cli.h"
Go to the source code of this file.
Data Structures | |
struct | sorcery_memory_cache_thrash |
Structure for memory cache thrashing. More... | |
struct | sorcery_memory_cache_thrash_thread |
Structure for a memory cache thras thread. More... | |
struct | test_data |
Sorcery object created based on backend data. More... | |
Macros | |
#define | TEST_THRASH_RETRIEVERS 25 |
The number of threads to use for retrieving for applicable tests. More... | |
#define | TEST_THRASH_TIME 3 |
The default amount of time (in seconds) that thrash unit tests execute for. More... | |
#define | TEST_THRASH_UPDATERS 25 |
The number of threads to use for updating for applicable tests. More... | |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
AST_TEST_DEFINE (conflicting_expire_and_stale) | |
AST_TEST_DEFINE (high_object_count_without_expiration) | |
AST_TEST_DEFINE (low_unique_object_count_high_concurrent_updates) | |
AST_TEST_DEFINE (low_unique_object_count_immediately_expire) | |
AST_TEST_DEFINE (low_unique_object_count_immediately_stale) | |
AST_TEST_DEFINE (unique_objects_exceeding_maximum) | |
AST_TEST_DEFINE (unique_objects_exceeding_maximum_with_expire_and_stale) | |
static int | load_module (void) |
static void * | mock_retrieve_id (const struct ast_sorcery *sorcery, void *data, const char *type, const char *id) |
Callback for retrieving sorcery object by ID. More... | |
static int | mock_update (const struct ast_sorcery *sorcery, void *data, void *object) |
Callback for updating a sorcery object. More... | |
static enum ast_test_result_state | nominal_thrash (struct ast_test *test, const char *cache_configuration, unsigned int thrash_time, unsigned int unique_objects, unsigned int retrieve_threads, unsigned int update_threads) |
static char * | sorcery_memory_cache_cli_thrash (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static struct sorcery_memory_cache_thrash * | sorcery_memory_cache_thrash_create (const char *cache_configuration, unsigned int update_threads, unsigned int retrieve_threads, unsigned int unique_objects) |
static void | sorcery_memory_cache_thrash_destroy (void *obj) |
static void * | sorcery_memory_cache_thrash_retrieve (void *data) |
static int | sorcery_memory_cache_thrash_start (struct sorcery_memory_cache_thrash *thrash) |
static void | sorcery_memory_cache_thrash_stop (struct sorcery_memory_cache_thrash *thrash) |
static void * | sorcery_memory_cache_thrash_update (void *data) |
static void * | test_data_alloc (const char *id) |
Allocation callback for test_data sorcery object. More... | |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Sorcery Cache Thrasing test module" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static struct ast_cli_entry | cli_memory_cache_thrash [] |
static struct ast_sorcery_wizard | mock_wizard |
A mock sorcery wizard used for the stale test. More... | |
Sorcery Unit Tests.
Definition in file test_sorcery_memory_cache_thrash.c.
#define TEST_THRASH_RETRIEVERS 25 |
The number of threads to use for retrieving for applicable tests.
Definition at line 45 of file test_sorcery_memory_cache_thrash.c.
#define TEST_THRASH_TIME 3 |
The default amount of time (in seconds) that thrash unit tests execute for.
Definition at line 42 of file test_sorcery_memory_cache_thrash.c.
#define TEST_THRASH_UPDATERS 25 |
The number of threads to use for updating for applicable tests.
Definition at line 48 of file test_sorcery_memory_cache_thrash.c.
|
static |
Definition at line 631 of file test_sorcery_memory_cache_thrash.c.
|
static |
Definition at line 631 of file test_sorcery_memory_cache_thrash.c.
struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 631 of file test_sorcery_memory_cache_thrash.c.
AST_TEST_DEFINE | ( | conflicting_expire_and_stale | ) |
Definition at line 566 of file test_sorcery_memory_cache_thrash.c.
References AST_TEST_NOT_RUN, sip_to_pjsip::info(), nominal_thrash(), TEST_EXECUTE, TEST_INIT, TEST_THRASH_RETRIEVERS, and TEST_THRASH_TIME.
AST_TEST_DEFINE | ( | high_object_count_without_expiration | ) |
Definition at line 585 of file test_sorcery_memory_cache_thrash.c.
References AST_TEST_NOT_RUN, sip_to_pjsip::info(), nominal_thrash(), TEST_EXECUTE, TEST_INIT, TEST_THRASH_RETRIEVERS, and TEST_THRASH_TIME.
AST_TEST_DEFINE | ( | low_unique_object_count_high_concurrent_updates | ) |
Definition at line 506 of file test_sorcery_memory_cache_thrash.c.
References AST_TEST_NOT_RUN, sip_to_pjsip::info(), nominal_thrash(), TEST_EXECUTE, TEST_INIT, TEST_THRASH_RETRIEVERS, TEST_THRASH_TIME, and TEST_THRASH_UPDATERS.
AST_TEST_DEFINE | ( | low_unique_object_count_immediately_expire | ) |
Definition at line 487 of file test_sorcery_memory_cache_thrash.c.
References AST_TEST_NOT_RUN, sip_to_pjsip::info(), nominal_thrash(), TEST_EXECUTE, TEST_INIT, TEST_THRASH_RETRIEVERS, and TEST_THRASH_TIME.
AST_TEST_DEFINE | ( | low_unique_object_count_immediately_stale | ) |
Definition at line 467 of file test_sorcery_memory_cache_thrash.c.
References AST_TEST_NOT_RUN, sip_to_pjsip::info(), nominal_thrash(), TEST_EXECUTE, TEST_INIT, TEST_THRASH_RETRIEVERS, and TEST_THRASH_TIME.
AST_TEST_DEFINE | ( | unique_objects_exceeding_maximum | ) |
Definition at line 525 of file test_sorcery_memory_cache_thrash.c.
References AST_TEST_NOT_RUN, sip_to_pjsip::info(), nominal_thrash(), TEST_EXECUTE, TEST_INIT, TEST_THRASH_RETRIEVERS, and TEST_THRASH_TIME.
AST_TEST_DEFINE | ( | unique_objects_exceeding_maximum_with_expire_and_stale | ) |
Definition at line 545 of file test_sorcery_memory_cache_thrash.c.
References AST_TEST_NOT_RUN, sip_to_pjsip::info(), nominal_thrash(), TEST_EXECUTE, TEST_INIT, TEST_THRASH_RETRIEVERS, and TEST_THRASH_TIME.
|
static |
Definition at line 617 of file test_sorcery_memory_cache_thrash.c.
References ARRAY_LEN, ast_cli_register_multiple, AST_MODULE_LOAD_SUCCESS, AST_TEST_REGISTER, and cli_memory_cache_thrash.
|
static |
Callback for retrieving sorcery object by ID.
sorcery | The sorcery instance |
data | Unused |
type | The object type. Will always be "test". |
id | The object id. Will always be "test". |
NULL | Backend data successfully allocated |
non-NULL | Backend data could not be successfully allocated |
Definition at line 106 of file test_sorcery_memory_cache_thrash.c.
References ast_sorcery_alloc(), sorcery, and type.
|
static |
Callback for updating a sorcery object.
sorcery | The sorcery instance |
data | Unused |
object | The object to update. |
Definition at line 120 of file test_sorcery_memory_cache_thrash.c.
|
static |
Definition at line 447 of file test_sorcery_memory_cache_thrash.c.
References ao2_ref, AST_TEST_FAIL, AST_TEST_PASS, sorcery_memory_cache_thrash::retrieve_threads, sorcery_memory_cache_thrash_create(), sorcery_memory_cache_thrash_start(), sorcery_memory_cache_thrash_stop(), and sorcery_memory_cache_thrash::update_threads.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 368 of file test_sorcery_memory_cache_thrash.c.
References a, ao2_ref, ast_cli(), sorcery_memory_cache_thrash::average_retrieve_execution_time, sorcery_memory_cache_thrash::average_update_execution_time, CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, NULL, sorcery_memory_cache_thrash::retrieve_threads, sorcery_memory_cache_thrash_create(), sorcery_memory_cache_thrash_start(), sorcery_memory_cache_thrash_stop(), sorcery_memory_cache_thrash::update_threads, and ast_cli_entry::usage.
|
static |
Definition at line 173 of file test_sorcery_memory_cache_thrash.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_ref, ast_calloc, ast_free, AST_PTHREADT_NULL, ast_sorcery_apply_wizard_mapping, ast_sorcery_internal_object_register, ast_sorcery_open, ast_sorcery_wizard_register, AST_VECTOR_APPEND, AST_VECTOR_INIT, AST_VECTOR_SIZE, mock_wizard, NULL, sorcery_memory_cache_thrash::retrieve_threads, sorcery_memory_cache_thrash::sorcery, sorcery_memory_cache_thrash_destroy(), test_data_alloc(), thread, sorcery_memory_cache_thrash::threads, sorcery_memory_cache_thrash_thread::unique_objects, and sorcery_memory_cache_thrash::update_threads.
Referenced by nominal_thrash(), and sorcery_memory_cache_cli_thrash().
|
static |
Definition at line 141 of file test_sorcery_memory_cache_thrash.c.
References ast_free, ast_sorcery_unref, ast_sorcery_wizard_unregister(), AST_VECTOR_FREE, AST_VECTOR_GET, AST_VECTOR_SIZE, mock_wizard, sorcery_memory_cache_thrash::sorcery, thread, and sorcery_memory_cache_thrash::threads.
Referenced by sorcery_memory_cache_thrash_create().
|
static |
Definition at line 267 of file test_sorcery_memory_cache_thrash.c.
References ao2_ref, ast_assert, ast_random(), ast_sorcery_retrieve_by_id(), ast_tvdiff_ms(), ast_tvnow(), AST_UUID_STR_LEN, NULL, and thread.
Referenced by sorcery_memory_cache_thrash_start().
|
static |
Definition at line 345 of file test_sorcery_memory_cache_thrash.c.
References ast_pthread_create, AST_VECTOR_GET, AST_VECTOR_SIZE, NULL, sorcery_memory_cache_thrash_retrieve(), sorcery_memory_cache_thrash_stop(), sorcery_memory_cache_thrash_update(), thread, and sorcery_memory_cache_thrash::threads.
Referenced by nominal_thrash(), and sorcery_memory_cache_cli_thrash().
|
static |
Definition at line 296 of file test_sorcery_memory_cache_thrash.c.
References AST_PTHREADT_NULL, AST_VECTOR_GET, AST_VECTOR_SIZE, sorcery_memory_cache_thrash::average_retrieve_execution_time, sorcery_memory_cache_thrash::average_update_execution_time, NULL, sorcery_memory_cache_thrash::retrieve_threads, thread, sorcery_memory_cache_thrash::threads, and sorcery_memory_cache_thrash::update_threads.
Referenced by nominal_thrash(), sorcery_memory_cache_cli_thrash(), and sorcery_memory_cache_thrash_start().
|
static |
Definition at line 237 of file test_sorcery_memory_cache_thrash.c.
References ao2_ref, ast_assert, ast_random(), ast_sorcery_alloc(), ast_sorcery_update(), ast_tvdiff_ms(), ast_tvnow(), AST_UUID_STR_LEN, NULL, and thread.
Referenced by sorcery_memory_cache_thrash_start().
|
static |
Allocation callback for test_data sorcery object.
Definition at line 90 of file test_sorcery_memory_cache_thrash.c.
References ast_sorcery_generic_alloc(), and NULL.
Referenced by sorcery_memory_cache_thrash_create().
|
static |
Definition at line 603 of file test_sorcery_memory_cache_thrash.c.
References ARRAY_LEN, ast_cli_unregister_multiple(), AST_TEST_UNREGISTER, and cli_memory_cache_thrash.
|
static |
Definition at line 631 of file test_sorcery_memory_cache_thrash.c.
|
static |
Definition at line 631 of file test_sorcery_memory_cache_thrash.c.
|
static |
Definition at line 429 of file test_sorcery_memory_cache_thrash.c.
Referenced by load_module(), and unload_module().
|
static |
A mock sorcery wizard used for the stale test.
Definition at line 129 of file test_sorcery_memory_cache_thrash.c.
Referenced by sorcery_memory_cache_thrash_create(), and sorcery_memory_cache_thrash_destroy().