pespin has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/docker-playground/+/36492?usp=email )


Change subject: Introduce ttcn3-asterisk-ims-ue-test
......................................................................

Introduce ttcn3-asterisk-ims-ue-test

This dockerized setup allows running the Asterisk_Tests ttcn3 testsuite
against Asterisk from the asterisk-master docker image, in order to test
the IMS UE feature which will be developed soon.

Related: SYS#6782
Depends: osmo-ttcn3-hacks.git Change-Id 
I66f776d5df6fb5dc488d9e589b84a6b2385406e8
Change-Id: Idd262b9224ea879a6e941792944fe0b0db3e68ba
---
A ttcn3-asterisk-ims-ue-test/Asterisk_Tests.cfg
A ttcn3-asterisk-ims-ue-test/Dockerfile
A ttcn3-asterisk-ims-ue-test/Makefile
A ttcn3-asterisk-ims-ue-test/asterisk/asterisk.conf
A ttcn3-asterisk-ims-ue-test/asterisk/asterisk.sh
A ttcn3-asterisk-ims-ue-test/asterisk/extensions.conf
A ttcn3-asterisk-ims-ue-test/asterisk/pjsip.conf
A ttcn3-asterisk-ims-ue-test/jenkins.sh
8 files changed, 361 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/docker-playground 
refs/changes/92/36492/1

diff --git a/ttcn3-asterisk-ims-ue-test/Asterisk_Tests.cfg 
b/ttcn3-asterisk-ims-ue-test/Asterisk_Tests.cfg
new file mode 100644
index 0000000..c8744bb
--- /dev/null
+++ b/ttcn3-asterisk-ims-ue-test/Asterisk_Tests.cfg
@@ -0,0 +1,22 @@
+[ORDERED_INCLUDE]
+"/osmo-ttcn3-hacks/Common.cfg"
+"/osmo-ttcn3-hacks/asterisk/Asterisk_Tests.default"
+
+[LOGGING]
+
+[TESTPORT_PARAMETERS]
+*.SIP.default_local_address := "172.18.11.103"
+*.SIP.local_sip_port := "5060"
+*.SIP.default_dest_address := "172.18.11.10"
+*.SIP.default_dest_port := "5094"
+
+[MODULE_PARAMETERS]
+Asterisk_Tests.mp_local_sip_host := "172.18.11.103"
+Asterisk_Tests.mp_remote_sip_host := "172.18.11.10"
+Asterisk_Tests.mp_local_sip_port := 5060
+Asterisk_Tests.mp_remote_sip_port := 5094
+
+[MAIN_CONTROLLER]
+
+[EXECUTE]
+Asterisk_Tests.control
diff --git a/ttcn3-asterisk-ims-ue-test/Dockerfile 
b/ttcn3-asterisk-ims-ue-test/Dockerfile
new file mode 100644
index 0000000..1a2f8aa
--- /dev/null
+++ b/ttcn3-asterisk-ims-ue-test/Dockerfile
@@ -0,0 +1,13 @@
+ARG    REGISTRY
+ARG    USER
+FROM   $REGISTRY/$USER/debian-bookworm-titan
+ARG    OSMO_TTCN3_BRANCH="master"
+
+ADD    
https://gerrit.osmocom.org/plugins/gitiles/osmo-ttcn3-hacks/+/$OSMO_TTCN3_BRANCH?format=TEXT
 /tmp/commit
+RUN    ttcn3-docker-prepare "$OSMO_TTCN3_BRANCH" asterisk
+
+VOLUME /data
+
+COPY   Asterisk_Tests.cfg /data/Asterisk_Tests.cfg
+
+CMD    ttcn3-docker-run asterisk Asterisk_Tests
diff --git a/ttcn3-asterisk-ims-ue-test/Makefile 
b/ttcn3-asterisk-ims-ue-test/Makefile
new file mode 100644
index 0000000..8d0e10b
--- /dev/null
+++ b/ttcn3-asterisk-ims-ue-test/Makefile
@@ -0,0 +1 @@
+include ../make/Makefile
diff --git a/ttcn3-asterisk-ims-ue-test/asterisk/asterisk.conf 
b/ttcn3-asterisk-ims-ue-test/asterisk/asterisk.conf
new file mode 100644
index 0000000..a17d606
--- /dev/null
+++ b/ttcn3-asterisk-ims-ue-test/asterisk/asterisk.conf
@@ -0,0 +1,142 @@
+[directories](!)
+astcachedir => /var/cache/asterisk
+astetcdir => /etc/asterisk
+astmoddir => /usr/lib/asterisk/modules
+astvarlibdir => /var/lib/asterisk
+astdbdir => /var/lib/asterisk
+astkeydir => /var/lib/asterisk
+astdatadir => /var/lib/asterisk
+astagidir => /var/lib/asterisk/agi-bin
+astspooldir => /var/spool/asterisk
+astrundir => /var/run/asterisk
+astlogdir => /data
+astsbindir => /usr/sbin
+
+[options]
+;verbose = 3
+;debug = 3
+;trace = 0              ; Set the trace level.
+;refdebug = yes                ; Enable reference count debug logging.
+;alwaysfork = yes              ; Same as -F at startup.
+;nofork = yes                          ; Same as -f at startup.
+;quiet = yes                           ; Same as -q at startup.
+;timestamp = yes               ; Same as -T at startup.
+;execincludes = yes            ; Support #exec in config files.
+;console = yes                         ; Run as console (same as -c at 
startup).
+;highpriority = yes            ; Run realtime priority (same as -p at
+                                       ; startup).
+;initcrypto = yes              ; Initialize crypto keys (same as -i at
+                                       ; startup).
+;nocolor = yes                         ; Disable console colors.
+;dontwarn = yes                ; Disable some warnings.
+;dumpcore = yes                ; Dump core on crash (same as -g at startup).
+;languageprefix = yes          ; Use the new sound prefix path syntax.
+;systemname = my_system_name   ; Prefix uniqueid with a system name for
+                                       ; Global uniqueness issues.
+;autosystemname = yes          ; Automatically set systemname to hostname,
+                                       ; uses 'localhost' on failure, or 
systemname if
+                                       ; set.
+;mindtmfduration = 80          ; Set minimum DTMF duration in ms (default 80 
ms)
+                                       ; If we get shorter DTMF messages, 
these will be
+                                       ; changed to the minimum duration
+;maxcalls = 10                         ; Maximum amount of calls allowed.
+;maxload = 0.9                         ; Asterisk stops accepting new calls if 
the
+                                       ; load average exceed this limit.
+;maxfiles = 1000               ; Maximum amount of openfiles.
+;minmemfree = 1                ; In MBs, Asterisk stops accepting new calls if
+                                       ; the amount of free memory falls below 
this
+                                       ; watermark.
+;cache_media_frames = yes      ; Cache media frames for performance
+                                       ; Disable this option to help track 
down media frame
+                                       ; mismanagement when using valgrind or 
MALLOC_DEBUG.
+                                       ; The cache gets in the way of 
determining if the
+                                       ; frame is used after being freed and 
who freed it.
+                                       ; NOTE: This option has no effect when 
Asterisk is
+                                       ; compiled with the LOW_MEMORY compile 
time option
+                                       ; enabled because the cache code does 
not exist.
+                                       ; Default yes
+;cache_record_files = yes      ; Cache recorded sound files to another
+                                       ; directory during recording.
+;record_cache_dir = /tmp       ; Specify cache directory (used in conjunction
+                                       ; with cache_record_files).
+;transmit_silence = yes        ; Transmit silence while a channel is in a
+                                       ; waiting state, a recording only 
state, or
+                                       ; when DTMF is being generated.  Note 
that the
+                                       ; silence internally is generated in 
raw signed
+                                       ; linear format. This means that it 
must be
+                                       ; transcoded into the native format of 
the
+                                       ; channel before it can be sent to the 
device.
+                                       ; It is for this reason that this is 
optional,
+                                       ; as it may result in requiring a 
temporary
+                                       ; codec translation path for a channel 
that may
+                                       ; not otherwise require one.
+;transcode_via_sln = yes       ; Build transcode paths via SLINEAR, instead of
+                                       ; directly.
+;runuser = asterisk            ; The user to run as.
+;rungroup = asterisk           ; The group to run as.
+;lightbackground = yes         ; If your terminal is set for a light-colored
+                                       ; background.
+;forceblackbackground = yes     ; Force the background of the terminal to be
+                                ; black, in order for terminal colors to show
+                                ; up properly.
+;defaultlanguage = en           ; Default language
+documentation_language = en_US ; Set the language you want documentation
+                                       ; displayed in. Value is in the same 
format as
+                                       ; locale names.
+;hideconnect = yes             ; Hide messages displayed when a remote console
+                                       ; connects and disconnects.
+;lockconfdir = no              ; Protect the directory containing the
+                                       ; configuration files (/etc/asterisk) 
with a
+                                       ; lock.
+;stdexten = gosub              ; How to invoke the extensions.conf stdexten.
+                                       ; macro - Invoke the stdexten using a 
macro as
+                                       ;         done by legacy Asterisk 
versions.
+                                       ; gosub - Invoke the stdexten using a 
gosub as
+                                       ;         documented in 
extensions.conf.sample.
+                                       ; Default gosub.
+;live_dangerously = no         ; Enable the execution of 'dangerous' dialplan
+                                       ; functions and configuration file 
access from
+                                       ; external sources (AMI, etc.) These 
functions
+                                       ; (such as SHELL) are considered 
dangerous
+                                       ; because they can allow privilege 
escalation.
+                                       ; Configuration files are considered 
dangerous
+                                       ; if they exist outside of the Asterisk
+                                       ; configuration directory.
+                                       ; Default no
+;entityid=00:11:22:33:44:55    ; Entity ID.
+                                       ; This is in the form of a MAC address.
+                                       ; It should be universally unique.
+                                       ; It must be unique between servers 
communicating
+                                       ; with a protocol that uses this value.
+                                       ; This is currently is used by DUNDi and
+                                       ; Exchanging Device and Mailbox State
+                                       ; using protocols: XMPP, Corosync and 
PJSIP.
+;rtp_use_dynamic = yes          ; When set to "yes" RTP dynamic payload types
+                                ; are assigned dynamically per RTP instance vs.
+                                ; allowing Asterisk to globally initialize them
+                                ; to pre-designated numbers (defaults to 
"yes").
+;rtp_pt_dynamic = 35           ; Normally the Dynamic RTP Payload Type numbers
+                                       ; are 96-127, which allow just 32 
formats. The
+                                       ; starting point 35 enables the range 
35-63 and
+                                       ; allows 29 additional formats. When 
you use
+                                       ; more than 32 formats in the dynamic 
range and
+                                       ; calls are not accepted by a remote
+                                       ; implementation, please report this 
and go
+                                       ; back to value 96.
+;hide_messaging_ami_events = no;  This option, if enabled, will
+                ; suppress all of the Message/ast_msg_queue channel's
+                ; housekeeping AMI and ARI channel events.  This can
+                ; reduce the load on the manager and ARI applications
+                ; when the Digium Phone Module for Asterisk is in use.
+;sounds_search_custom_dir = no;  This option, if enabled, will
+                ; cause Asterisk to search for sounds files in
+                ; AST_DATA_DIR/sounds/custom before searching the
+                ; normal directories like AST_DATA_DIR/sounds/<lang>.
+
+; Changing the following lines may compromise your security.
+;[files]
+;astctlpermissions = 0660
+;astctlowner = root
+;astctlgroup = apache
+;astctl = asterisk.ctl
+
diff --git a/ttcn3-asterisk-ims-ue-test/asterisk/asterisk.sh 
b/ttcn3-asterisk-ims-ue-test/asterisk/asterisk.sh
new file mode 100755
index 0000000..24a20db
--- /dev/null
+++ b/ttcn3-asterisk-ims-ue-test/asterisk/asterisk.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+set +e
+set -x
+
+ASTERISK_CFG_PATH="/etc/asterisk"
+
+#rm -rf "${ASTERISK_CFG_PATH}"
+#mkdir -p "${ASTERISK_CFG_PATH}"
+
+#cp -r /etc/asterisk/* "${ASTERISK_CFG_PATH}/"
+cp /data/asterisk.conf "${ASTERISK_CFG_PATH}/"
+#sed -i "s#/etc/asterisk#${ASTERISK_CFG_PATH}#" 
"${ASTERISK_CFG_PATH}/asterisk.conf"
+cp /data/pjsip.conf "${ASTERISK_CFG_PATH}/"
+cat /data/extensions.conf >>"${ASTERISK_CFG_PATH}/extensions.conf"
+
+/usr/sbin/asterisk -C "${ASTERISK_CFG_PATH}/asterisk.conf" -f -g -vvvvv -ddddd
diff --git a/ttcn3-asterisk-ims-ue-test/asterisk/extensions.conf 
b/ttcn3-asterisk-ims-ue-test/asterisk/extensions.conf
new file mode 100644
index 0000000..3c78a2d
--- /dev/null
+++ b/ttcn3-asterisk-ims-ue-test/asterisk/extensions.conf
@@ -0,0 +1,37 @@
+[get-valid-endpoints]
+
+exten => s,1,Verbose(5, Entering get-valid-endpoints gosub.)
+    ; usage: no arguments, returns DIALGROUP object of registered and valid 
050x endpoints
+ same => n,Set(ENDPOINT_1_STATE=${DEVICE_STATE(PJSIP/0501)})
+ same => n,Set(ENDPOINT_2_STATE=${DEVICE_STATE(PJSIP/0502)})
+ same => n,Set(ENDPOINT_3_STATE=${DEVICE_STATE(PJSIP/0503)})
+ same => n,Set(ENDPOINT_4_STATE=${DEVICE_STATE(PJSIP/0504)})
+ same => n,Set(ENDPOINT_1_EXPR=$[$["${ENDPOINT_1_STATE}" = "UNAVAILABLE"] | 
$["${ENDPOINT_1_STATE}" = "UNKNOWN"] | $["${ENDPOINT_1_STATE}" = "INVALID"]])
+ same => n,Set(ENDPOINT_2_EXPR=$[$["${ENDPOINT_2_STATE}" = "UNAVAILABLE"] | 
$["${ENDPOINT_2_STATE}" = "UNKNOWN"] | $["${ENDPOINT_2_STATE}" = "INVALID"]])
+ same => n,Set(ENDPOINT_3_EXPR=$[$["${ENDPOINT_3_STATE}" = "UNAVAILABLE"] | 
$["${ENDPOINT_3_STATE}" = "UNKNOWN"] | $["${ENDPOINT_3_STATE}" = "INVALID"]])
+ same => n,Set(ENDPOINT_4_EXPR=$[$["${ENDPOINT_4_STATE}" = "UNAVAILABLE"] | 
$["${ENDPOINT_4_STATE}" = "UNKNOWN"] | $["${ENDPOINT_4_STATE}" = "INVALID"]])
+ same => n,Set(DIALGROUP(CALL_VALID_LIST)=) ; clear list
+ same => n,ExecIf($[${ENDPOINT_1_EXPR} = 
0]?Set(DIALGROUP(CALL_VALID_LIST,add)=PJSIP/0501))
+ same => n,ExecIf($[${ENDPOINT_2_EXPR} = 
0]?Set(DIALGROUP(CALL_VALID_LIST,add)=PJSIP/0502))
+ same => n,ExecIf($[${ENDPOINT_3_EXPR} = 
0]?Set(DIALGROUP(CALL_VALID_LIST,add)=PJSIP/0503))
+ same => n,ExecIf($[${ENDPOINT_4_EXPR} = 
0]?Set(DIALGROUP(CALL_VALID_LIST,add)=PJSIP/0504))
+ same => n,Return(${DIALGROUP(CALL_VALID_LIST)})
+
+[from-phone]
+
+exten => 0500,1,Verbose(5,${EXTEN}: Call all registered pjsips from 
${CALLERID(num)})
+ same => n,Gosub(get-valid-endpoints,s,1())
+ same => n,Set(DIALGROUP(CALL_EVERYONE_LIST)=${GOSUB_RETVAL})
+ same => n,Set(DIALGROUP(CALL_EVERYONE_LIST,del)=PJSIP/${CALLERID(num)})  ; 
remove the caller
+ same => n,Dial(${DIALGROUP(CALL_EVERYONE_LIST)})
+ same => n,Hangup(16)
+
+exten => _050X,1,Verbose(5,${EXTEN}: Call pjsip endpoint from ${CALLERID(num)})
+ same => n,Dial(PJSIP/${EXTEN})
+ same => n,Hangup(16)
+
+exten => _X,1,Verbose(5,${EXTEN}: Call external number from ${CALLERID(num)})
+ same => n,Dial(PJSIP/${EXTEN}@973171)
+ same => n,Hangup(16)
+
+
diff --git a/ttcn3-asterisk-ims-ue-test/asterisk/pjsip.conf 
b/ttcn3-asterisk-ims-ue-test/asterisk/pjsip.conf
new file mode 100644
index 0000000..39cf9bb
--- /dev/null
+++ b/ttcn3-asterisk-ims-ue-test/asterisk/pjsip.conf
@@ -0,0 +1,71 @@
+
+[transport-udp]
+type=transport
+protocol=udp
+bind=172.18.11.10:5094
+local_net=172.18.11.0/24
+;external_media_address=[obfuscated]
+;external_signaling_address=[obfuscated]
+
+
+[endpoint_phone_template]
+type=endpoint
+transport=transport-udp
+context=from-phone
+disallow=all
+allow=alaw
+allow=ulaw
+
+[auth_phone_template]
+type=auth
+auth_type=userpass
+
+[aor_phone_template]
+type=aor
+max_contacts=1
+remove_existing=yes
+
+[0501](endpoint_phone_template)
+auth=0501
+aors=0501
+callerid=0501
+
+[0501](auth_phone_template)
+username=0501
+password=secret
+
+[0501](aor_phone_template)
+
+[0502](endpoint_phone_template)
+auth=0502
+aors=0502
+callerid=0502
+
+[0502](auth_phone_template)
+username=0502
+password=secret
+
+[0502](aor_phone_template)
+
+[0503](endpoint_phone_template)
+auth=0503
+aors=0503
+callerid=0503
+
+[0503](auth_phone_template)
+username=0503
+password=secret
+
+[0503](aor_phone_template)
+
+[0504](endpoint_phone_template)
+auth=0504
+aors=0504
+callerid=0504
+
+[0504](auth_phone_template)
+username=0504
+password=secret
+
+[0504](aor_phone_template)
+
diff --git a/ttcn3-asterisk-ims-ue-test/jenkins.sh 
b/ttcn3-asterisk-ims-ue-test/jenkins.sh
new file mode 100755
index 0000000..7e5361d
--- /dev/null
+++ b/ttcn3-asterisk-ims-ue-test/jenkins.sh
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+. ../jenkins-common.sh
+IMAGE_SUFFIX="${IMAGE_SUFFIX:-master}"
+docker_images_require \
+       "asterisk-$IMAGE_SUFFIX" \
+       "ttcn3-asterisk-ims-ue-test"
+
+set_clean_up_trap
+set -e
+
+mkdir $VOL_BASE_DIR/asterisk-ims-ue-tester
+mkdir $VOL_BASE_DIR/asterisk-ims-ue-tester/unix
+cp Asterisk_Tests.cfg $VOL_BASE_DIR/asterisk-ims-ue-tester/
+write_mp_osmo_repo "$VOL_BASE_DIR/asterisk-ims-ue-tester/Asterisk_Tests.cfg"
+
+mkdir $VOL_BASE_DIR/asterisk
+cp asterisk/* $VOL_BASE_DIR/asterisk/
+
+network_create
+network_replace_subnet_in_configs
+
+echo Starting container with Asterisk
+docker run     --rm \
+               $(docker_network_params $SUBNET 10) \
+               --ulimit core=-1 \
+               -v $VOL_BASE_DIR/asterisk:/data \
+               --name ${BUILD_TAG}-asterisk -d \
+               $DOCKER_ARGS \
+               $REPO_USER/asterisk-$IMAGE_SUFFIX \
+               /bin/sh -c "/data/asterisk.sh >/data/asterisk.console.log 2>&1"
+
+# Leave some time for asterisk to start:
+sleep 3
+
+echo Starting container with Asterisk testsuite
+docker run     --rm \
+               $(docker_network_params $SUBNET 103) \
+               --ulimit core=-1 \
+               -e "TTCN3_PCAP_PATH=/data" \
+               -v $VOL_BASE_DIR/asterisk-ims-ue-tester:/data \
+               --name ${BUILD_TAG}-ttcn3-asterisk-ims-ue-test \
+               $DOCKER_ARGS \
+               $REPO_USER/ttcn3-asterisk-ims-ue-test

--
To view, visit https://gerrit.osmocom.org/c/docker-playground/+/36492?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: docker-playground
Gerrit-Branch: master
Gerrit-Change-Id: Idd262b9224ea879a6e941792944fe0b0db3e68ba
Gerrit-Change-Number: 36492
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pes...@sysmocom.de>
Gerrit-MessageType: newchange

Reply via email to