122 lines
4.7 KiB
Bash
Executable file
122 lines
4.7 KiB
Bash
Executable file
#!/bin/bash
|
|
#Script to mimic Gitlab-CI configuration of flexisip-flexisip_tester
|
|
#execute it with sh -x [script] to see variables values and command launched
|
|
|
|
FLEXISIP_LOCATION=~/flexisip
|
|
|
|
#GCI script variables
|
|
REBUILD_FLEXISIP_IMAGE_FROM_RPM=false
|
|
REBUILD_FLEXISIP_AUXILIARIES=true
|
|
REBUILD_SDK=false
|
|
SDK_VERSION=4.3
|
|
SDK_BRANCH=release/$SDK_VERSION
|
|
PARALLEL_TEST_MODE=false
|
|
DOCKER_BUILD_OPTIONS="--no-cache --force-rm -t gitlab.linphone.org:4567/bc/public/flexisip/flexisip:latest -f docker/flex-from-src --build-arg=njobs=12"
|
|
liblinphone_tester="gitlab.linphone.org:4567/bc/public/linphone-sdk/liblinphone_tester:$SDK_VERSION"
|
|
sourcedir=$FLEXISIP_LOCATION/linphone-sdk-docker
|
|
workspace=$FLEXISIP_LOCATION/liblinphone_tester_workspace
|
|
#docker compose network is default one (it is docker_default ???)
|
|
docker_run_options="--volume=$FLEXISIP_LOCATION/liblinphone_tester_workspace:/home/bc/linphone-sdk-build/linphone-sdk/desktop/work --network=docker_default --device=/dev/snd --user 1000:29"
|
|
COMPOSE_PROJECT_NAME=$RANDOM
|
|
|
|
#new variables for flexisip_tester
|
|
|
|
export FLEXISIP_DOCKER_IMAGE="gitlab.linphone.org:4567/bc/public/flexisip/flexisip"
|
|
export FLEXISIP_DOCKER_TAG="latest"
|
|
|
|
#new variables for liblinphone_tester in docker-compose
|
|
export LIBLINPHONE_DOCKER_IMAGE="gitlab.linphone.org:4567/bc/public/linphone-sdk/liblinphone_tester"
|
|
export LIBLINPHONE_DOCKER_TAG=$SDK_VERSION
|
|
|
|
if [ -z $workspace ]; then
|
|
echo "Error, $workspace should be set. Aborting to avoid unwanted rm"
|
|
exit 1
|
|
fi
|
|
|
|
mkdir -p $workspace
|
|
|
|
sudo rm -rf $workspace
|
|
|
|
mkdir -p $workspace/{bin,ext,lime-server-apache}
|
|
|
|
ls $workspace
|
|
#workaround for logs writing
|
|
sudo chown apache:apache $workspace
|
|
sudo chmod -R 777 $workspace
|
|
|
|
if [ "$REBUILD_FLEXISIP_IMAGE_FROM_RPM" = "true" ]; then
|
|
docker build $DOCKER_BUILD_OPTIONS .
|
|
fi
|
|
|
|
#--no-cache --force-rm
|
|
if [ "$REBUILD_SDK" = "true" ]; then
|
|
docker build --no-cache --force-rm -t gitlab.linphone.org:4567/bc/public/linphone-sdk/liblinphone_tester:$SDK_VERSION --build-arg="branch=$SDK_BRANCH" --build-arg="njobs=8" -f "$sourcedir/docker-files/liblinphone-tester" $sourcedir/docker-files/
|
|
fi
|
|
|
|
#Handle multiple runs
|
|
docker_compose_options=''
|
|
|
|
#Overriding docker-compose.yaml values with docker-compose-standalone.yaml in the ways specified with docker docs (either OR or AND, depending on key)
|
|
for name in 'docker-compose.yaml' 'docker-compose-standalone.yaml'; do
|
|
docker_compose_options="$docker_compose_options -f $FLEXISIP_LOCATION/flexisip-tester/docker/$name"
|
|
done
|
|
|
|
#liblinphone_tester_options='--dns-hosts none --log-file liblinphone_tester.log --xml --verbose --show-account-manager-logs'
|
|
liblinphone_tester_options="--suite Register --test \"Simple register\" --dns-hosts none --log-file liblinphone_tester.log --xml --verbose --show-account-manager-logs"
|
|
|
|
if [ "$PARALLEL_TEST_MODE" = "true" ]; then
|
|
liblinphone_tester_options="$liblinphone_tester_options --parallel"
|
|
fi
|
|
|
|
export FLEXISIP_LOGS="$workspace"
|
|
|
|
cd $workspace
|
|
|
|
docker-compose $docker_compose_options down
|
|
|
|
if [ "$REBUILD_FLEXISIP_AUXILIARIES" = "true" ]; then
|
|
docker-compose $docker_compose_options build
|
|
fi
|
|
|
|
# --exit-code-from liblinphone_tester
|
|
docker-compose $docker_compose_options up --exit-code-from liblinphone_tester |& tee logs_all | grep 'liblinphone_tester_1' || EXIT=$?
|
|
|
|
grep 'file-transfer-server_1' logs_all > file-transfer-server.log
|
|
|
|
grep 'lime-server_1' logs_all > lime-server_stdout.log
|
|
|
|
grep 'dbserver_1' logs_all > dbserver_stdout.log
|
|
|
|
grep 'account-manager_1' logs_all > account-manager_stdout.log
|
|
|
|
grep 'http-proxy_1' logs_all > http-proxy_stdout.log
|
|
|
|
grep 'redis-server_1' logs_all > redis-server_stdout.log
|
|
|
|
#docker-compose $docker_compose_options exec liblinphone_tester bash
|
|
|
|
#sleep 60
|
|
|
|
|
|
|
|
#docker run $(echo $docker_run_options) $liblinphone_tester $liblinphone_tester_options || EXIT=$? && echo 'Tests have failed'
|
|
|
|
docker-compose $docker_compose_options stop
|
|
|
|
#after script (coredump management)
|
|
|
|
|
|
# we specify commands to launch for each coredump of liblinphone_tester
|
|
echo "set debug-file-directory ../lib64" | tee gdb_options
|
|
echo "thread apply all bt" | tee -a gdb_options
|
|
|
|
# searching for core files and if there are some, launch gdb on all of it
|
|
# xargs -L1 means that the command in argument will be executed for each
|
|
# line (core dump) found in find output
|
|
# The docker syntax is error proning : to override the entrypoint with
|
|
# args, we enter the entrypoint first, then the name of the image, then the
|
|
# args to the entrypoint command.
|
|
# "true ||" is used here to continue the script even if the find fails
|
|
if [[ -n $(find . -type f -name "core*") ]]; then find . -type f -name "core*" | xargs -L1 docker run $(echo $docker_run_options) --entrypoint gdb $liblinphone_tester ../bin/liblinphone_tester -x gdb_options; fi || true
|
|
|
|
echo $EXIT
|