agent/scenarios/bulk-calls: Setup scenario for CI

Change-Id: I06a7f8da672946b20c353e4b5d3a3aaa499203fb
This commit is contained in:
Olivier Dion
2022-05-20 16:03:44 -04:00
committed by Sébastien Blin
parent 15460298ab
commit fb7d9b4db6
6 changed files with 38 additions and 49 deletions

View File

@ -52,8 +52,10 @@ AC_ARG_ENABLE([agent],
AM_CONDITIONAL([ENABLE_AGENT], [test "x$enable_agent" = "xyes"])
AM_COND_IF([ENABLE_AGENT],
[AC_CONFIG_FILES([test/agent/Makefile
test/agent/pre-inst-env:test/agent/build-aux/pre-inst-env.in],
[chmod +x test/agent/pre-inst-env])])
test/agent/pre-inst-env:test/agent/build-aux/pre-inst-env.in
test/agent/scenarios/bulk-calls/run-scenario],
[chmod +x test/agent/pre-inst-env
chmod +x test/agent/scenarios/bulk-calls/run-scenario])])
AC_ARG_ENABLE([tracepoints], AS_HELP_STRING([--enable-tracepoints], [Enable tracepoints]))

View File

@ -1 +0,0 @@
../../agent.scm

View File

@ -1 +0,0 @@
../../jami/

View File

@ -1,5 +1,7 @@
#!/bin/sh
agent_dir="@abs_top_srcdir@/test/agent"
tmp_alice=$(mktemp --tmpdir --directory "jami-bulk-calls.XXXXXXXXXX")
tmp_bob=$(mktemp --tmpdir --directory "jami-bulk-calls.XXXXXXXXXX")
@ -13,7 +15,7 @@ export XDG_CACHE_HOME="$tmp_bob"
export XDG_DATA_HOME="$tmp_bob"
export JAMI_LOG_FILE="bob.log"
./scenario.scm "bob" > bob-guile.txt 2>&1 &
agent -e main -s $agent_dir/scenarios/bulk-calls/scenario.scm "bob" > bob-guile.txt 2>&1 &
bob_pid=$!
@ -23,7 +25,7 @@ export XDG_CONFIG_HOME="$tmp_alice"
export XDG_CACHE_HOME="$tmp_alice"
export XDG_DATA_HOME="$tmp_alice"
export JAMI_LOG_FILE="alice.log"
./scenario.scm "alice" "$bob_id" > alice-guile.txt 2>&1
agent -e main -s $agent_dir/scenarios/bulk-calls/scenario.scm "alice" "$bob_id" > alice-guile.txt 2>&1
wait $bob_pid

59
test/agent/scenarios/bulk-calls/scenario.scm Executable file → Normal file
View File

@ -1,6 +1,3 @@
#!/usr/bin/env -S ./agent.exe --no-auto-compile -e main -s
!#
;;; Commentary:
;;;
;;; This scenario tests calling a peer in a single registration.
@ -54,26 +51,30 @@
(make-exception
(make-exception-with-message "Can't make friend with bob"))))
;; Wait for Bob to install call handlers.
(sleep (* 2 GRACE-PERIOD))
(define (call-bob timeout)
(let ((this-call-id ""))
(jami:with-signal-sync
'state-changed
(lambda (account-id call-id state code)
(and (string= account-id (agent:account-id me))
(string= call-id this-call-id)
(string= state "CURRENT")))
timeout
(set! this-call-id (agent:call-friend me bob-id)))
this-call-id))
(let loop ([cnt 1])
;; Synchronize with bob a first time.
(jami:info "Alice sending call #~a" 1)
(call:hang-up (agent:account-id me)
(call-bob #f))
(let loop ((cnt 2))
(when (<= cnt CALL-COUNT)
(jami:info "Alice sending call #~a" cnt)
(let ([this-call-id ""])
(jami:with-signal-sync
'state-changed
(lambda (account-id call-id state code)
(and (string= account-id (agent:account-id me))
(string= call-id this-call-id)
(string= state "CURRENT")))
GRACE-PERIOD
(set! this-call-id (agent:call-friend me bob-id)))
(let ((call-id (call-bob GRACE-PERIOD)))
(sleep GRACE-PERIOD)
(call:hang-up (agent:account-id me) this-call-id)
(call:hang-up (agent:account-id me) call-id)
(sleep GRACE-PERIOD))
(loop (1+ cnt)))))
(define (bob)
@ -88,7 +89,7 @@
(jami:with-signal-sync
'incoming-trust-request
(lambda (account-id conversation-id peer-id payload received)
(let ([sync? (string= account-id (agent:account-id me))])
(let ((sync? (string= account-id (agent:account-id me))))
(when sync?
(jami:info "accepting trust request: ~a ~a" account-id peer-id)
(account:accept-trust-request account-id peer-id))
@ -96,9 +97,9 @@
;; Accept all incoming calls with media.
(let ([mtx (make-recursive-mutex)]
[cnd (make-condition-variable)]
[received 0])
(let ((mtx (make-recursive-mutex))
(cnd (make-condition-variable))
(received 0))
(with-mutex mtx
(jami:with-signal
'incoming-call/media
@ -110,21 +111,21 @@
(jami:info "Bob has received: ~a calls" received)
(when (= received CALL-COUNT)
(signal-condition-variable cnd)))))
(let ([success?
(let ((success?
(wait-condition-variable
cnd mtx (+ (current-time) (* 4 GRACE-PERIOD CALL-COUNT)))])
cnd mtx (+ (current-time) (* 4 GRACE-PERIOD CALL-COUNT)))))
(jami:info "Summary: ~a%" (* 100 (/ received CALL-COUNT)))
(exit success?))))))
(define (main args)
(match (cdr args)
[("alice" bob-id) (alice bob-id)]
[("bob") (bob)]
[_
(("alice" bob-id) (alice bob-id))
(("bob") (bob))
(_
(jami:error "Invalid arguments: ~a" args)
(jami:error "Usage: ~a alice|bob [ARG]\n" (car args))
(exit EXIT_FAILURE)])
(jami:error "Usage: ~a alice|bob (ARG)\n" (car args))
(exit EXIT_FAILURE)))
(jami:info "bye bye")

View File

@ -1,14 +0,0 @@
#!/bin/sh
tmp=$(mktemp --tmpdir --directory "jami-peer-monitor.XXXXXXXXXX")
export XDG_CONFIG_HOME="$tmp"
export XDG_CACHE_HOME="$tmp"
export XDG_DATA_HOME="$tmp"
export GUILE_AUTO_COMPILE=0
export JAMI_LOG_FILE="$1.log"
./scenario.scm $@
rm -rf "$tmp"