Skip to content

Commit

Permalink
agent/scenarios/bulk-calls: Setup scenario for CI
Browse files Browse the repository at this point in the history
Change-Id: I06a7f8da672946b20c353e4b5d3a3aaa499203fb
  • Loading branch information
Olivier Dion authored and Sébastien Blin committed Jun 17, 2022
1 parent 1546029 commit fb7d9b4
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 50 deletions.
6 changes: 4 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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]))

Expand Down
1 change: 0 additions & 1 deletion test/agent/scenarios/bulk-calls/agent.scm

This file was deleted.

1 change: 0 additions & 1 deletion test/agent/scenarios/bulk-calls/jami

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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")

Expand All @@ -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=$!

Expand All @@ -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

Expand Down
61 changes: 31 additions & 30 deletions test/agent/scenarios/bulk-calls/scenario.scm
100755 → 100644
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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))

(let loop ([cnt 1])
(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))

;; 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)
Expand All @@ -88,17 +89,17 @@
(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))
sync?)))


;; 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
Expand All @@ -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")

Expand Down
14 changes: 0 additions & 14 deletions test/agent/scenarios/peer-monitor/run-scenario

This file was deleted.

0 comments on commit fb7d9b4

Please sign in to comment.