mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-02-07 14:18:25 +00:00
Quality reporting: add unit tests
This commit is contained in:
parent
424d75b265
commit
929fbffe1a
3 changed files with 114 additions and 18 deletions
|
|
@ -46,8 +46,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
// à voir ++ :
|
||||
// video : que se passe t-il si on arrete / resume la vidéo (new stream)
|
||||
// valeurs instanannées : moyenne ? valeur extreme ?
|
||||
// only if this is a linphone account?
|
||||
// rlq: il faut un algo
|
||||
// #define PRINTF printf
|
||||
#define PRINTF(...)
|
||||
/***************************************************************************
|
||||
* END OF TODO / REMINDER LIST
|
||||
****************************************************************************/
|
||||
|
|
@ -108,7 +109,7 @@ static void append_to_buffer(char **buff, size_t *buff_size, size_t *offset, con
|
|||
#define APPEND_IF(buffer, size, offset, fmt, arg, cond) if (cond) append_to_buffer(buffer, size, offset, fmt, arg)
|
||||
#define IF_NUM_IN_RANGE(num, inf, sup, statement) if (inf <= num && num <= sup) statement
|
||||
|
||||
static void append_metrics_to_buffer(char ** buffer, size_t * size, size_t * offset, reporting_content_metrics_t rm) {
|
||||
static void append_metrics_to_buffer(char ** buffer, size_t * size, size_t * offset, const reporting_content_metrics_t rm) {
|
||||
char * timestamps_start_str = NULL;
|
||||
char * timestamps_stop_str = NULL;
|
||||
char * network_packet_loss_rate_str = NULL;
|
||||
|
|
@ -200,10 +201,11 @@ static void append_metrics_to_buffer(char ** buffer, size_t * size, size_t * off
|
|||
ms_free(moscq_str);
|
||||
}
|
||||
|
||||
static void reporting_publish(LinphoneCall* call, reporting_session_report_t * report) {
|
||||
static void reporting_publish(const LinphoneCall* call, const reporting_session_report_t * report) {
|
||||
PRINTF("static reporting_publish\n");
|
||||
|
||||
LinphoneContent content = {0};
|
||||
LinphoneAddress *addr;
|
||||
const char * addr_str;
|
||||
int expires = -1;
|
||||
size_t offset = 0;
|
||||
size_t size = 2048;
|
||||
|
|
@ -238,24 +240,21 @@ static void reporting_publish(LinphoneCall* call, reporting_session_report_t * r
|
|||
content.size = strlen((char*)content.data);
|
||||
|
||||
|
||||
|
||||
|
||||
addr_str = call->dest_proxy->reg_statistics_collector;
|
||||
if (addr_str != NULL) {
|
||||
addr = linphone_address_new(addr_str);
|
||||
addr = linphone_address_new(call->dest_proxy->reg_statistics_collector);
|
||||
if (addr != NULL) {
|
||||
linphone_core_publish(call->core, addr, "vq-rtcpxr", expires, &content);
|
||||
linphone_address_destroy(addr);
|
||||
|
||||
// for debug purpose only
|
||||
printf("%s\n", (char*) content.data);
|
||||
PRINTF("%s\n", (char*) content.data);
|
||||
} else {
|
||||
ms_warning("Asked to submit reporting statistics but no collector address found");
|
||||
PRINTF("Asked to submit reporting statistics but no collector address found\n");
|
||||
}
|
||||
|
||||
linphone_content_uninit(&content);
|
||||
}
|
||||
|
||||
|
||||
static const SalStreamDescription * get_media_stream_for_desc(const SalMediaDescription * remote_smd, SalStreamType sal_stream_type) {
|
||||
if (remote_smd != NULL) {
|
||||
int count;
|
||||
|
|
@ -298,7 +297,7 @@ static void reporting_update_ip(LinphoneCall * call, int stats_type) {
|
|||
}
|
||||
}
|
||||
|
||||
static bool_t reporting_enabled(LinphoneCall * call) {
|
||||
static bool_t reporting_enabled(const LinphoneCall * call) {
|
||||
return (call->dest_proxy != NULL && linphone_proxy_config_send_statistics_enabled(call->dest_proxy));
|
||||
}
|
||||
|
||||
|
|
@ -307,7 +306,7 @@ void linphone_reporting_update_ip(LinphoneCall * call) {
|
|||
// - 1) at start when call is starting, remote ip/port info might be the proxy ones to which callee is registered
|
||||
// - 2) later, if we found a direct route between caller and callee with ICE/Stun, ip/port are updated for the direct route access
|
||||
|
||||
printf("linphone_reporting_update_remote_ip\n");
|
||||
PRINTF("linphone_reporting_update_remote_ip\n");
|
||||
|
||||
if (! reporting_enabled(call))
|
||||
return;
|
||||
|
|
@ -326,7 +325,7 @@ void linphone_reporting_update(LinphoneCall * call, int stats_type) {
|
|||
const PayloadType * remote_payload = NULL;
|
||||
const LinphoneCallParams * current_params = linphone_call_get_current_params(call);
|
||||
|
||||
printf("linphone_reporting_call_stats_updated type=%d\n", stats_type);
|
||||
PRINTF("linphone_reporting_call_stats_updated type=%d\n", stats_type);
|
||||
|
||||
if (! reporting_enabled(call))
|
||||
return;
|
||||
|
|
@ -432,11 +431,12 @@ void linphone_reporting_call_stats_updated(LinphoneCall *call, int stats_type) {
|
|||
}
|
||||
|
||||
void linphone_reporting_publish(LinphoneCall* call) {
|
||||
printf("linphone_reporting_publish\n");
|
||||
PRINTF("linphone_reporting_publish\n");
|
||||
|
||||
if (! reporting_enabled(call))
|
||||
if (! reporting_enabled(call))
|
||||
return;
|
||||
|
||||
|
||||
if (call->log->reports[LINPHONE_CALL_STATS_AUDIO] != NULL) {
|
||||
reporting_publish(call, call->log->reports[LINPHONE_CALL_STATS_AUDIO]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1877,6 +1877,98 @@ static void call_rejected_without_403_because_wrong_credentials_no_auth_req_cb()
|
|||
call_rejected_because_wrong_credentials_with_params("tester-no-403",FALSE);
|
||||
}
|
||||
|
||||
void create_call_for_statistics_tests(
|
||||
LinphoneCoreManager* marie,
|
||||
LinphoneCoreManager* pauline,
|
||||
LinphoneCall** call_marie,
|
||||
LinphoneCall** call_pauline) {
|
||||
CU_ASSERT_TRUE(call(pauline,marie));
|
||||
*call_marie = linphone_core_get_current_call(marie->lc);
|
||||
*call_pauline = linphone_core_get_current_call(pauline->lc);
|
||||
CU_ASSERT_PTR_NOT_NULL(*call_marie);
|
||||
CU_ASSERT_PTR_NOT_NULL(*call_pauline);
|
||||
}
|
||||
|
||||
static void statistics_not_used_without_config() {
|
||||
LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
|
||||
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc");
|
||||
LinphoneCall* call_marie = NULL;
|
||||
LinphoneCall* call_pauline = NULL;
|
||||
|
||||
create_call_for_statistics_tests(marie, pauline, &call_marie, &call_pauline);
|
||||
|
||||
// marie has stats collection enabled since pauline has not
|
||||
CU_ASSERT_TRUE(linphone_proxy_config_send_statistics_enabled(call_marie->dest_proxy));
|
||||
CU_ASSERT_FALSE(linphone_proxy_config_send_statistics_enabled(call_pauline->dest_proxy));
|
||||
|
||||
CU_ASSERT_EQUAL(strcmp("sip:collector@sip.linphone.org",
|
||||
linphone_proxy_config_get_statistics_collector(call_marie->dest_proxy)), 0);
|
||||
|
||||
// this field should be already filled
|
||||
CU_ASSERT_PTR_NOT_NULL(call_marie->log->reports[0]->info.local_addr.ip);
|
||||
CU_ASSERT_PTR_NULL(call_pauline->log->reports[0]->info.local_addr.ip);
|
||||
|
||||
// but not this one since it is updated at the end of call
|
||||
CU_ASSERT_PTR_NULL(call_marie->log->reports[0]->dialog_id);
|
||||
|
||||
linphone_core_manager_destroy(marie);
|
||||
linphone_core_manager_destroy(pauline);
|
||||
}
|
||||
static void statistics_not_sent_if_call_not_started() {
|
||||
LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
|
||||
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc");
|
||||
LinphoneCallLog* out_call_log;
|
||||
LinphoneCall* out_call;
|
||||
|
||||
linphone_core_set_max_calls(pauline->lc,0);
|
||||
out_call = linphone_core_invite(marie->lc,"pauline");
|
||||
linphone_call_ref(out_call);
|
||||
|
||||
CU_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallError,1));
|
||||
CU_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallError,1);
|
||||
|
||||
if (ms_list_size(linphone_core_get_call_logs(marie->lc))>0) {
|
||||
CU_ASSERT_PTR_NOT_NULL(out_call_log=(LinphoneCallLog*)(linphone_core_get_call_logs(marie->lc)->data));
|
||||
CU_ASSERT_EQUAL(linphone_call_log_get_status(out_call_log),LinphoneCallAborted);
|
||||
}
|
||||
linphone_call_unref(out_call);
|
||||
|
||||
// wait a few time...
|
||||
wait_for(marie->lc,NULL,NULL,0);
|
||||
// since the callee was busy, there shouldn't be no publish to do
|
||||
CU_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishProgress,0);
|
||||
CU_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk,0);
|
||||
|
||||
linphone_core_manager_destroy(marie);
|
||||
linphone_core_manager_destroy(pauline);
|
||||
}
|
||||
static void statistics_sent_at_call_termination() {
|
||||
// int return_code = -1;
|
||||
LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
|
||||
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc");
|
||||
LinphoneCall* call_marie = NULL;
|
||||
LinphoneCall* call_pauline = NULL;
|
||||
|
||||
create_call_for_statistics_tests(marie, pauline, &call_marie, &call_pauline);
|
||||
|
||||
linphone_core_terminate_all_calls(marie->lc);
|
||||
CU_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallReleased,1));
|
||||
CU_ASSERT_TRUE(wait_for(pauline->lc,NULL,&pauline->stat.number_of_LinphoneCallReleased,1));
|
||||
|
||||
CU_ASSERT_PTR_NULL(linphone_core_get_current_call(marie->lc));
|
||||
CU_ASSERT_PTR_NULL(linphone_core_get_current_call(pauline->lc));
|
||||
|
||||
// now dialog id should be filled
|
||||
CU_ASSERT_PTR_NOT_NULL(call_marie->log->reports[0]->dialog_id);
|
||||
|
||||
// PUBLISH submission to the collector should be ok
|
||||
CU_ASSERT_TRUE(wait_for(marie->lc,NULL,&marie->stat.number_of_LinphonePublishProgress,1));
|
||||
CU_ASSERT_TRUE(wait_for(marie->lc,NULL,&marie->stat.number_of_LinphonePublishOk,1)); // failing since server side is not implemented
|
||||
|
||||
linphone_core_manager_destroy(marie);
|
||||
linphone_core_manager_destroy(pauline);
|
||||
}
|
||||
|
||||
#ifdef VIDEO_ENABLED
|
||||
#endif
|
||||
|
||||
|
|
@ -1931,7 +2023,10 @@ test_t call_tests[] = {
|
|||
{ "Call established with rejected RE-INVITE",call_established_with_rejected_reinvite},
|
||||
{ "Call established with rejected incoming RE-INVITE", call_established_with_rejected_incoming_reinvite },
|
||||
{ "Call established with rejected RE-INVITE in error", call_established_with_rejected_reinvite_with_error},
|
||||
{ "Call redirected by callee", call_redirect}
|
||||
{ "Call redirected by callee", call_redirect},
|
||||
{ "Call statistics not used if no config", statistics_not_used_without_config},
|
||||
{ "Call statistics not sent if call did not start", statistics_not_sent_if_call_not_started},
|
||||
{ "Call statistics sent if call ended normally", statistics_sent_at_call_termination},
|
||||
};
|
||||
|
||||
test_suite_t call_test_suite = {
|
||||
|
|
@ -1941,4 +2036,3 @@ test_suite_t call_test_suite = {
|
|||
sizeof(call_tests) / sizeof(call_tests[0]),
|
||||
call_tests
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ reg_expires=3600
|
|||
reg_sendregister=1
|
||||
publish=0
|
||||
dial_escape_plus=0
|
||||
reg_statistics_collector=sip:collector@sip.linphone.org
|
||||
send_statistics=1
|
||||
|
||||
[friend_0]
|
||||
url="Paupoche" <sip:pauline@sip.example.org>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue