]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[Unit-tests] Improve test stability testend 1771/head
authorAndrey Volk <andywolk@gmail.com>
Wed, 24 Aug 2022 14:19:20 +0000 (17:19 +0300)
committerAndrey Volk <andywolk@gmail.com>
Sat, 27 Aug 2022 21:58:11 +0000 (00:58 +0300)
src/mod/applications/mod_test/test/test_tts.c
src/mod/endpoints/mod_sofia/test/conf-sipp/freeswitch.xml
src/mod/endpoints/mod_sofia/test/sipp-based-tests.c
src/mod/endpoints/mod_sofia/test/sipp-scenarios/uac_digest_leak.xml
tests/unit/switch_hold.c
tests/unit/switch_ivr_originate.c
tests/unit/switch_sip.c

index e5ec1aa25458bd5a5d25d14c0cdfacc28a3f0b08..83369212d161dd462db0ac8d9407705c924a3ec6 100644 (file)
@@ -146,7 +146,7 @@ FST_TEST_BEGIN(tts_time)
     } while (status == SWITCH_STATUS_SUCCESS);
 
     fst_check(read = sample_rate / interval * 3); // samples of 3 second
-    fst_check_duration(3000, 750);
+    fst_check_duration(3000, 1000);
     switch_core_speech_close(&sh, &flags);
 }
 FST_TEST_END()
index d20625f77f1409bc6a05c4038bb7e7b3ae78dc13..a4d02bc60b6cda2e51dc8fef39a570090d71a1a8 100644 (file)
                <condition>
                   <action application="info"/>
                   <action application="answer" />
-                  <action application="voicemail" data="default $${domain} 1001"/>
+                  <!--action application="voicemail" data="default $${domain} 1001"/-->
        </condition>
     </extension>
 
index 60a7b61a3aa8dda3ff4a3df996d864e8f851f5c3..153a0b5def62a6813c6fbf3c3f74d66edef1ce6f 100644 (file)
@@ -128,7 +128,7 @@ static void unregister_gw()
 
 static int start_sipp_uac(const char *ip, int remote_port, const char *dialed_number, const char *scenario_uac, const char *extra)
 {
-       char *cmd = switch_mprintf("sipp %s:%d -nr -p 5062 -m 1 -s %s -recv_timeout 10000 -timeout 10s -sf %s -bg %s", ip, remote_port, dialed_number, scenario_uac, extra);
+       char *cmd = switch_mprintf("sipp %s:%d -nr -p 5062 -m 1 -s %s -recv_timeout 30000 -timeout 30s -sf %s -bg %s", ip, remote_port, dialed_number, scenario_uac, extra);
        int sys_ret = switch_system(cmd, SWITCH_TRUE);
 
        printf("%s\n", cmd);
@@ -140,7 +140,7 @@ static int start_sipp_uac(const char *ip, int remote_port, const char *dialed_nu
 
 static int start_sipp_uas(const char *ip, int listen_port, const char *scenario_uas, const char *extra)
 {
-       char *cmd = switch_mprintf("sipp %s -p %d -nr -m 1 -s 1001 -recv_timeout 10000 -timeout 10s -sf %s -bg %s", ip, listen_port, scenario_uas, extra);
+       char *cmd = switch_mprintf("sipp %s -p %d -nr -m 1 -s 1001 -recv_timeout 30000 -timeout 30s -sf %s -bg %s", ip, listen_port, scenario_uas, extra);
        int sys_ret = switch_system(cmd, SWITCH_TRUE);
 
        printf("%s\n", cmd);
@@ -151,7 +151,7 @@ static int start_sipp_uas(const char *ip, int listen_port, const char *scenario_
 }
 static int run_sipp(const char *ip, int remote_port, int listen_port, const char *dialed_number, const char *scenario_uac, const char *auth_password, const char *extra)
 {
-       char *cmd = switch_mprintf("sipp %s:%d -nr -p %d -m 1 -s %s -recv_timeout 10000 -timeout 10s -sf %s -au %s -ap %s -bg %s", ip, remote_port, listen_port, dialed_number, scenario_uac, dialed_number, auth_password, extra);
+       char *cmd = switch_mprintf("sipp %s:%d -nr -p %d -m 1 -s %s -recv_timeout 30000 -timeout 30s -sf %s -au %s -ap %s -bg %s", ip, remote_port, listen_port, dialed_number, scenario_uac, dialed_number, auth_password, extra);
        int sys_ret = switch_system(cmd, SWITCH_TRUE);
 
        printf("%s\n", cmd);
@@ -216,6 +216,8 @@ static void event_handler_reg_fail(switch_event_t *event)
        show_event(event);
 }
 
+switch_interval_time_t delay_start_ms = 5000;
+
 FST_CORE_EX_BEGIN("./conf-sipp", SCF_VG | SCF_USE_SQL)
 {
        FST_MODULE_BEGIN(mod_sofia, uac-uas)
@@ -224,6 +226,13 @@ FST_CORE_EX_BEGIN("./conf-sipp", SCF_VG | SCF_USE_SQL)
                {
                        switch_stream_handle_t stream = { 0 };
                        SWITCH_STANDARD_STREAM(stream);
+
+                       /* Give mod_sofia time to spinup profile threads */
+                       if (delay_start_ms) {
+                               switch_sleep(delay_start_ms * 1000);
+                               delay_start_ms = 0;
+                       }
+
                        switch_api_execute("sofia", "global siptrace on", NULL, &stream);
                        if (test_sofia_debug) {
                                switch_api_execute("sofia", "loglevel all 9", NULL, &stream);
@@ -366,10 +375,10 @@ FST_CORE_EX_BEGIN("./conf-sipp", SCF_VG | SCF_USE_SQL)
 
                FST_TEST_BEGIN(uac_digest_leak_udp)
                {
-                       switch_core_session_t *session;
+                       switch_core_session_t *session = NULL;
                        switch_call_cause_t cause;
                        switch_status_t status;
-                       switch_channel_t *channel;
+                       switch_channel_t *channel = NULL;
                        const char *local_ip_v4 = switch_core_get_variable("local_ip_v4");
                        int sipp_ret;
 
@@ -397,30 +406,25 @@ FST_CORE_EX_BEGIN("./conf-sipp", SCF_VG | SCF_USE_SQL)
                                                }
                                        }
 
-                                       switch_sleep(5000 * 1000);
-
-                                       switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
-
-                                       switch_core_session_rwunlock(session);
-                                       switch_sleep(1000 * 1000);
-
-                                       switch_event_unbind_callback(event_handler);
                                        /* sipp should timeout, attempt kill, just in case.*/
                                        kill_sipp();
                                        fst_check(test_success);
                                }
                        }
 
+                       if (channel) switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
+                       if (session) switch_core_session_rwunlock(session);
+                       switch_event_unbind_callback(event_handler);
                        test_success = 0;
                }
                FST_TEST_END()
 
                FST_TEST_BEGIN(uac_digest_leak_tcp)
                {
-                       switch_core_session_t *session;
+                       switch_core_session_t *session = NULL;
                        switch_call_cause_t cause;
                        switch_status_t status;
-                       switch_channel_t *channel;
+                       switch_channel_t *channel = NULL;
                        const char *local_ip_v4 = switch_core_get_variable("local_ip_v4");
                        int sipp_ret;
 
@@ -448,29 +452,24 @@ FST_CORE_EX_BEGIN("./conf-sipp", SCF_VG | SCF_USE_SQL)
                                        }
                                }
 
-                               switch_sleep(5000 * 1000);
-
-                               switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
-
-                               switch_core_session_rwunlock(session);
-                               switch_sleep(1000 * 1000);
-
-                               switch_event_unbind_callback(event_handler);
                                /* sipp should timeout, attempt kill, just in case.*/
                                kill_sipp();
                                fst_check(test_success);
                        }
 
+                       if (channel) switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
+                       if (session) switch_core_session_rwunlock(session);
+                       switch_event_unbind_callback(event_handler);
                        test_success = 0;
                }
                FST_TEST_END()
 
                FST_TEST_BEGIN(uac_digest_leak_udp_ipv6)
                {
-                       switch_core_session_t *session;
+                       switch_core_session_t *session = NULL;
                        switch_call_cause_t cause;
                        switch_status_t status;
-                       switch_channel_t *channel;
+                       switch_channel_t *channel = NULL;
                        const char *local_ip_v6 = switch_core_get_variable("local_ip_v6");
                        int sipp_ret;
                        char *ipv6 = NULL;
@@ -511,20 +510,15 @@ FST_CORE_EX_BEGIN("./conf-sipp", SCF_VG | SCF_USE_SQL)
                                        }
                                }
 
-                               switch_sleep(5000 * 1000);
-
-                               switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
-
-                               switch_core_session_rwunlock(session);
-                               switch_sleep(1000 * 1000);
-
-                               switch_event_unbind_callback(event_handler);
                                /* sipp should timeout, attempt kill, just in case.*/
                                kill_sipp();
                                switch_safe_free(ipv6);
                                fst_check(test_success);
                        }
 skiptest:
+                       if (channel) switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
+                       if (session) switch_core_session_rwunlock(session);
+                       switch_event_unbind_callback(event_handler);
                        test_success = 0;
                }
                FST_TEST_END()
@@ -546,12 +540,12 @@ skiptest:
 
                                switch_sleep(5000 * 1000);
 
-                               switch_event_unbind_callback(event_handler_reg_ok);
                                /* sipp should timeout, attempt kill, just in case.*/
                                kill_sipp();
                                fst_check(test_success);
                        }
 
+                       switch_event_unbind_callback(event_handler_reg_ok);
                        test_success = 0;
                }
                FST_TEST_END()
@@ -571,14 +565,13 @@ skiptest:
 
                                register_gw();
 
-                               switch_sleep(5000 * 1000);
+                               switch_sleep(10000 * 1000);
 
-                               switch_event_unbind_callback(event_handler_reg_fail);
                                /* sipp should timeout, attempt kill, just in case.*/
                                kill_sipp();
                                fst_check(test_success);
                        }
-
+                       switch_event_unbind_callback(event_handler_reg_fail);
                        test_success = 0;
                }
                FST_TEST_END()
@@ -651,13 +644,12 @@ skiptest:
 
                                switch_sleep(1000 * 1000);
 
-                               switch_event_unbind_callback(event_handler_reg_ok);
-
                                /* sipp should timeout, attempt kill, just in case.*/
                                kill_sipp();
                                fst_check(test_success);
                        }
 
+                       switch_event_unbind_callback(event_handler_reg_ok);
                        test_success = 0;
                }
                FST_TEST_END()
index 7c1e9ebd6286dd79ba510660169076255a2d1bc0..93ce32bd6081806ee0162cba83bd665f99695b19 100644 (file)
@@ -77,7 +77,7 @@
   <!-- Test with SIP hardware phone: must use WWW-Authenticate instead of Proxy-Authenticate.\r
        You could also try with SIP/2.0 401 Unauthorized. -->\r
 \r
-  <send>\r
+  <send retrans="500">\r
     <![CDATA[\r
 \r
       SIP/2.0 407 Proxy Authentication Required\r
index e48865155bee0781aed141a594011ab1ba8c7d3f..50156e5efe0373051790d1c51ea710ae9da02208 100644 (file)
@@ -1,12 +1,21 @@
 #include <switch.h>
 #include <test/switch_test.h>
 
+int timeout_sec = 10;
+switch_interval_time_t delay_start_ms = 5000;
+
 FST_CORE_DB_BEGIN("./conf_test")
 {
 FST_SUITE_BEGIN(switch_hold)
 {
        FST_SETUP_BEGIN()
        {
+               /* Give mod_sofia time to spinup profile threads */
+               if (delay_start_ms) {
+                       switch_sleep(delay_start_ms * 1000);
+                       delay_start_ms = 0;
+               }
+
                fst_requires_module("mod_sofia");
                fst_requires_module("mod_commands");
        }
@@ -23,7 +32,7 @@ FST_SUITE_BEGIN(switch_hold)
                switch_status_t status;
                switch_call_cause_t cause;
 
-               status = switch_ivr_originate(NULL, &session, &cause, "{ignore_early_media=true}sofia/gateway/test_gateway/+15553332900", 2, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL, NULL);
+               status = switch_ivr_originate(NULL, &session, &cause, "{ignore_early_media=true}sofia/gateway/test_gateway/+15553332900", timeout_sec, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL, NULL);
                fst_requires(session);
                fst_check(status == SWITCH_STATUS_SUCCESS);
 
index 4cf969527523bc8446a38c8f2a31b8ca47801542..5603e18f0ecfe0f049ba640f0d3b4a39c2fe73ad 100644 (file)
@@ -482,7 +482,7 @@ FST_CORE_BEGIN("./conf")
 
                        switch_dial_handle_destroy(&dh);
 
-                       fst_check_duration(3000, 500);
+                       fst_check_duration(3000, 600);
                }
                FST_TEST_END()
 
@@ -513,7 +513,7 @@ FST_CORE_BEGIN("./conf")
 
                        switch_dial_handle_destroy(&dh);
 
-                       fst_check_duration(3000, 500);
+                       fst_check_duration(3000, 600);
                }
                FST_TEST_END()
 
index bcb00eac2b6319f3ec16cd4bd18598d9865d4b84..b535823e121339b8145d57bc396fa6d081fcf7f6 100644 (file)
@@ -1,12 +1,21 @@
 #include <switch.h>
 #include <test/switch_test.h>
 
+int timeout_sec = 10;
+switch_interval_time_t delay_start_ms = 5000;
+
 FST_CORE_DB_BEGIN("./conf_sip")
 {
 FST_SUITE_BEGIN(switch_sip)
 {
        FST_SETUP_BEGIN()
        {
+               /* Give mod_sofia time to spinup profile threads */
+               if (delay_start_ms) {
+                       switch_sleep(delay_start_ms * 1000);
+                       delay_start_ms = 0;
+               }
+
                fst_requires_module("mod_sofia");
                fst_requires_module("mod_hash");
        }
@@ -24,7 +33,7 @@ FST_SUITE_BEGIN(switch_sip)
                const char *data = "eyJhbGciOiJFUzI1NiIsInBwdCI6InNoYWtlbiI;info=<https://cert.sticr.att.net:8443/certs/att/a937bb15-38b9-45f1-aac0-8cd3f8fe0648>";
                char *originate_str = switch_mprintf("{sip_h_Identity=%s}sofia/gateway/test_gateway/+15553332901", data);
 
-               switch_ivr_originate(NULL, &session, &cause, originate_str, 2, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL, NULL);
+               switch_ivr_originate(NULL, &session, &cause, originate_str, timeout_sec, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL, NULL);
                switch_safe_free(originate_str);
                fst_requires(session);
 
@@ -60,7 +69,7 @@ FST_SUITE_BEGIN(switch_sip)
                const char *data = "eyJhbGciOiJFUzI1NiIsInBwdCI6InNoYWtlbiI;info=<https://cert.sticr.att.net:8443/certs/att/a937bb15-38b9-45f1-aac0-8cd3f8fe0648>;alg=ES256;ppt=shaken";
                char *originate_str = switch_mprintf("{sip_h_Identity=%s}sofia/gateway/test_gateway/+15553332901", data);
 
-               switch_ivr_originate(NULL, &session, &cause, originate_str, 2, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL, NULL);
+               switch_ivr_originate(NULL, &session, &cause, originate_str, timeout_sec, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL, NULL);
                switch_safe_free(originate_str);
                fst_requires(session);