mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-02-21 09:51:50 +00:00
Improve VOMP testing
This commit is contained in:
parent
bb677e50fd
commit
23cb4600e2
@ -346,6 +346,12 @@ SUB_STRUCT(mdp_iftypelist, iftype,)
|
||||
ATOM(bool_t, enable_inet, 0, boolean,, "If true, allow mdp clients to connect over loopback UDP")
|
||||
END_STRUCT
|
||||
|
||||
STRUCT(vomp)
|
||||
ATOM(int32_t, dial_timeout_ms, 15000, int32_nonneg,, "Timeout to establish a call when dialling")
|
||||
ATOM(int32_t, ring_timeout_ms, 30000, int32_nonneg,, "Timeout for the other user to answer")
|
||||
ATOM(int32_t, network_timeout_ms, 30000, int32_nonneg,, "Timeout for network activity until a call will end")
|
||||
END_STRUCT
|
||||
|
||||
STRUCT(olsr)
|
||||
ATOM(bool_t, enable, 0, boolean,, "If true, OLSR is used for mesh routing")
|
||||
ATOM(uint16_t, remote_port, 4130, uint16_nonzero,, "Remote port number")
|
||||
@ -494,6 +500,7 @@ SUB_STRUCT(server, server,)
|
||||
SUB_STRUCT(monitor, monitor,)
|
||||
SUB_STRUCT(mdp, mdp,)
|
||||
SUB_STRUCT(dna, dna,)
|
||||
SUB_STRUCT(vomp, vomp,)
|
||||
SUB_STRUCT(debug, debug,)
|
||||
SUB_STRUCT(rhizome, rhizome,)
|
||||
SUB_STRUCT(directory, directory,)
|
||||
|
@ -176,13 +176,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
#define CODEC_FLAGS_LENGTH 32
|
||||
|
||||
/* in milliseconds of inactivity */
|
||||
// 20 seconds to start ringing
|
||||
#define VOMP_CALL_DIAL_TIMEOUT 15000
|
||||
// 60 seconds to answer
|
||||
#define VOMP_CALL_RING_TIMEOUT 60000
|
||||
// 2 minutes of zero network traffic
|
||||
#define VOMP_CALL_NETWORK_TIMEOUT 120000
|
||||
// force state packet interval
|
||||
#define VOMP_CALL_STATUS_INTERVAL 1000
|
||||
|
||||
|
121
tests/vomp
121
tests/vomp
@ -21,6 +21,11 @@
|
||||
source "${0%/*}/../testframework.sh"
|
||||
source "${0%/*}/../testdefs.sh"
|
||||
|
||||
setup() {
|
||||
setup_servald
|
||||
assert_no_servald_processes
|
||||
start_servald_instances +A +B
|
||||
}
|
||||
teardown() {
|
||||
stop_all_servald_servers
|
||||
kill_all_servald_processes
|
||||
@ -35,42 +40,108 @@ configure_servald_server() {
|
||||
set debug.mdprequests on \
|
||||
set debug.monitor on \
|
||||
set debug.vomp on \
|
||||
set vomp.dial_timeout_ms 1000 \
|
||||
set vomp.ring_timeout_ms 5000 \
|
||||
set vomp.network_timeout_ms 5000 \
|
||||
set log.console.level DEBUG \
|
||||
set log.console.show_time on
|
||||
}
|
||||
|
||||
vomp_connect() {
|
||||
executeOk_servald console < <(sleep 1 && echo "call $1 $2 $3" && sleep 3 && echo "say hello" && sleep 3 && echo "hangup")
|
||||
tfw_cat --stdout --stderr
|
||||
assertStdoutGrep --stdout --matches=1 "^Dialling$"
|
||||
assertStdoutGrep --stdout --matches=1 "^Codec list"
|
||||
assertStdoutGrep --stdout --matches=1 "^Ringing$"
|
||||
assertStdoutGrep --stdout --matches=1 "^Picked up$"
|
||||
assertStdoutGrep --stdout --matches=1 "^hi there$"
|
||||
assertStdoutGrep --stdout --matches=1 "^Call ended$"
|
||||
vomp_console() {
|
||||
# Note, this might block and stall the test, but I need to predict where stdout is going to be
|
||||
# perhaps add an argument to execute?
|
||||
$servald console <&8 >"$1"
|
||||
}
|
||||
|
||||
vomp_answer() {
|
||||
executeOk_servald console < <(sleep 2 && echo "answer" && sleep 2 && echo "say hi there" && sleep 3 && echo "hangup")
|
||||
tfw_cat --stdout --stderr
|
||||
assertStdoutGrep --stdout --matches=1 "^Incoming call"
|
||||
assertStdoutGrep --stdout --matches=1 "^Codec list"
|
||||
assertStdoutGrep --stdout --matches=1 "^hello$"
|
||||
assertStdoutGrep --stdout --matches=1 "^Call ended$"
|
||||
send_cmd() {
|
||||
tfw_log "sending $1 to $2"
|
||||
# Note, this might block and stall the test...
|
||||
echo "$1" >> "$2"
|
||||
}
|
||||
|
||||
init_console() {
|
||||
eval ${instance_name}_IN="$PWD/${instance_name}_IN"
|
||||
eval ${instance_name}_OUT="$PWD/${instance_name}_OUT"
|
||||
mkfifo "$PWD/${instance_name}_IN"
|
||||
exec 8<>"$PWD/${instance_name}_IN"
|
||||
fork vomp_console "$PWD/${instance_name}_OUT"
|
||||
exec 8>&-
|
||||
}
|
||||
|
||||
doc_nophone="Attempt to dial a node with no phone"
|
||||
test_nophone() {
|
||||
set_instance +A
|
||||
init_console
|
||||
send_cmd "call $SIDB $DIDA $DIDB" "$A_IN"
|
||||
wait_until grep "^Call ended$" "$A_OUT"
|
||||
send_cmd "quit" "$A_IN"
|
||||
fork_wait_all
|
||||
tfw_cat "$A_OUT"
|
||||
}
|
||||
|
||||
doc_hangup="Hangup instead of answering"
|
||||
test_hangup() {
|
||||
foreach_instance +A +B init_console
|
||||
send_cmd "call $SIDA $DIDB $DIDA" "$B_IN"
|
||||
wait_until grep "^Dialling$" "$B_OUT"
|
||||
wait_until grep "^Incoming call" "$A_OUT"
|
||||
wait_until grep "^Codec list" "$A_OUT"
|
||||
wait_until grep "^Codec list" "$B_OUT"
|
||||
wait_until grep "^Ringing$" "$B_OUT"
|
||||
send_cmd "hangup" "$A_IN"
|
||||
wait_until grep "^Call ended$" "$A_OUT"
|
||||
wait_until grep "^Call ended$" "$B_OUT"
|
||||
send_cmd "quit" "$A_IN"
|
||||
send_cmd "quit" "$B_IN"
|
||||
fork_wait_all
|
||||
tfw_cat "$A_OUT" "$B_OUT"
|
||||
}
|
||||
|
||||
doc_timeout="Call timeout"
|
||||
test_timeout() {
|
||||
foreach_instance +A +B init_console
|
||||
send_cmd "call $SIDA $DIDB $DIDA" "$B_IN"
|
||||
wait_until grep "^Dialling$" "$B_OUT"
|
||||
wait_until grep "^Incoming call" "$A_OUT"
|
||||
wait_until grep "^Codec list" "$A_OUT"
|
||||
wait_until grep "^Codec list" "$B_OUT"
|
||||
wait_until grep "^Ringing$" "$B_OUT"
|
||||
send_cmd "answer" "$A_IN"
|
||||
wait_until grep "^Picked up$" "$B_OUT"
|
||||
send_cmd "say hello" "$A_IN"
|
||||
send_cmd "say hi there" "$B_IN"
|
||||
wait_until grep "^hello$" "$B_OUT"
|
||||
wait_until grep "^hi there$" "$A_OUT"
|
||||
stop_servald_server +B
|
||||
# B's console should just quit
|
||||
wait_until --timeout=20 grep "^Call ended$" "$A_OUT"
|
||||
send_cmd "quit" "$A_IN"
|
||||
fork_wait_all
|
||||
tfw_cat "$A_OUT" "$B_OUT"
|
||||
}
|
||||
|
||||
doc_call_lifecycle="Successful call lifecycle"
|
||||
setup_call_lifecycle() {
|
||||
setup_servald
|
||||
assert_no_servald_processes
|
||||
start_servald_instances +A +B
|
||||
}
|
||||
test_call_lifecycle() {
|
||||
set_instance +A
|
||||
fork vomp_answer
|
||||
set_instance +B
|
||||
fork vomp_connect $SIDA $DIDB $DIDA
|
||||
foreach_instance +A +B init_console
|
||||
send_cmd "call $SIDA $DIDB $DIDA" "$B_IN"
|
||||
wait_until grep "^Dialling$" "$B_OUT"
|
||||
wait_until grep "^Incoming call" "$A_OUT"
|
||||
wait_until grep "^Codec list" "$A_OUT"
|
||||
wait_until grep "^Codec list" "$B_OUT"
|
||||
wait_until grep "^Ringing$" "$B_OUT"
|
||||
send_cmd "answer" "$A_IN"
|
||||
wait_until grep "^Picked up$" "$B_OUT"
|
||||
send_cmd "say hello" "$A_IN"
|
||||
send_cmd "say hi there" "$B_IN"
|
||||
wait_until grep "^hello$" "$B_OUT"
|
||||
wait_until grep "^hi there$" "$A_OUT"
|
||||
send_cmd "hangup" "$B_IN"
|
||||
wait_until grep "^Call ended$" "$A_OUT"
|
||||
wait_until grep "^Call ended$" "$B_OUT"
|
||||
send_cmd "quit" "$A_IN"
|
||||
send_cmd "quit" "$B_IN"
|
||||
fork_wait_all
|
||||
tfw_cat "$A_OUT" "$B_OUT"
|
||||
}
|
||||
|
||||
runTests "$@"
|
||||
|
12
vomp.c
12
vomp.c
@ -1096,14 +1096,14 @@ static void vomp_process_tick(struct sched_ent *alarm)
|
||||
struct vomp_call_state *call = (struct vomp_call_state *)alarm;
|
||||
|
||||
/* See if any calls need to be expired.
|
||||
Allow VOMP_CALL_DIAL_TIMEOUT ms for the other party to ring / request ringing
|
||||
Allow VOMP_CALL_RING_TIMEOUT ms for the ringing party to answer
|
||||
Allow VOMP_CALL_NETWORK_TIMEOUT ms between received packets
|
||||
Allow vomp.dial_timeout_ms for the other party to ring / request ringing
|
||||
Allow vomp.ring_timeout_ms for the ringing party to answer
|
||||
Allow vomp.network_timeout_ms between received packets
|
||||
*/
|
||||
|
||||
if ((call->remote.state < VOMP_STATE_RINGINGOUT && call->create_time + VOMP_CALL_DIAL_TIMEOUT < now) ||
|
||||
(call->local.state < VOMP_STATE_INCALL && call->create_time + VOMP_CALL_RING_TIMEOUT < now) ||
|
||||
(call->last_activity+VOMP_CALL_NETWORK_TIMEOUT<now) ){
|
||||
if ((call->remote.state < VOMP_STATE_RINGINGOUT && call->create_time + config.vomp.dial_timeout_ms < now) ||
|
||||
(call->local.state < VOMP_STATE_INCALL && call->create_time + config.vomp.ring_timeout_ms < now) ||
|
||||
(call->last_activity+config.vomp.network_timeout_ms<now) ){
|
||||
|
||||
/* tell any local clients that call has died */
|
||||
call->rejection_reason=VOMP_REJECT_TIMEOUT;
|
||||
|
@ -70,6 +70,7 @@ static int console_answer(const struct cli_parsed *parsed, struct cli_context *c
|
||||
static int console_hangup(const struct cli_parsed *parsed, struct cli_context *context);
|
||||
static int console_audio(const struct cli_parsed *parsed, struct cli_context *context);
|
||||
static int console_usage(const struct cli_parsed *parsed, struct cli_context *context);
|
||||
static int console_quit(const struct cli_parsed *parsed, struct cli_context *context);
|
||||
static void console_command(char *line);
|
||||
static void monitor_read(struct sched_ent *alarm);
|
||||
|
||||
@ -79,6 +80,7 @@ struct cli_schema console_commands[]={
|
||||
{console_hangup,{"hangup",NULL},0,"Hangup the phone line"},
|
||||
{console_usage,{"help",NULL},0,"This usage message"},
|
||||
{console_audio,{"say","...",NULL},0,"Send a text string to the other party"},
|
||||
{console_quit,{"quit",NULL},0,"Exit process"},
|
||||
{NULL, {NULL, NULL, NULL}, 0, NULL},
|
||||
};
|
||||
|
||||
@ -272,6 +274,7 @@ static int console_dial(const struct cli_parsed *parsed, struct cli_context *UNU
|
||||
{
|
||||
if (call_token!=-1){
|
||||
printf("Already in a call\n");
|
||||
fflush(stdout);
|
||||
return 0;
|
||||
}
|
||||
const char *sid = parsed->args[1];
|
||||
@ -301,6 +304,18 @@ static int console_hangup(const struct cli_parsed *UNUSED(parsed), struct cli_co
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int console_quit(const struct cli_parsed *UNUSED(parsed), struct cli_context *UNUSED(context))
|
||||
{
|
||||
if (monitor_alarm.poll.fd!=-1){
|
||||
printf("Shutting down\n");
|
||||
fflush(stdout);
|
||||
unwatch(&monitor_alarm);
|
||||
monitor_client_close(monitor_alarm.poll.fd, monitor_state);
|
||||
monitor_alarm.poll.fd=-1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int console_audio(const struct cli_parsed *parsed, struct cli_context *UNUSED(context))
|
||||
{
|
||||
if (call_token==-1){
|
||||
|
Loading…
x
Reference in New Issue
Block a user