review jenkins scripts

Change-Id: I420910bd2d30e96605ecf3acb779ce726c75d912
This commit is contained in:
Neels Hofmeyr 2017-04-08 15:56:31 +02:00
parent 3531a192ae
commit d46ea13d48
12 changed files with 243 additions and 275 deletions

View File

@ -1,142 +0,0 @@
set -e -x
prefix_base="`pwd`"
prefix_dirname="inst-openbsc"
prefix="$prefix_base/$prefix_dirname"
reposes="
libosmocore
libosmo-abis
libosmo-netif
openggsn
libsmpp34
libosmo-sccp
openbsc/openbsc
"
osmo_gsm_tester_host=root@10.9.1.190
osmo_gsm_tester_dir="/var/tmp/osmo-gsm-tester"
tmp_dir="/var/tmp/prep-osmo-gsm-tester"
arch="x86_64"
archive_name="openbsc.$arch-build-$BUILD_NUMBER"
archive="$archive_name.tgz"
manifest="checksums.md5"
test_report="test-report.xml"
test_timeout_sec=120
rm -rf $prefix
mkdir -p $prefix
opt_prefix=""
if [ -n "$prefix" ]; then
export LD_LIBRARY_PATH="$prefix"/lib
export PKG_CONFIG_PATH="$prefix"/lib/pkgconfig
opt_prefix="--prefix=$prefix"
fi
for r in $reposes; do
make -C "$r" clean || true
done
for r in $reposes; do
cd "$r"
echo "$(git rev-parse HEAD) $r" >> "$prefix/openbsc_git_hashes.txt"
autoreconf -fi
opt_enable=""
if [ "$r" = 'openbsc/openbsc' ]; then
opt_enable="--enable-smpp --enable-osmo-bsc --enable-nat"
fi
./configure "$opt_prefix" $opt_enable
make -j || make || make
if [ "$r" != asn1c ]; then
if [ "$r" = 'libosmo-netif' ]; then
# skip clock dependent test in libosmo-netif
make check TESTSUITEFLAGS='-k !osmux_test'
else
make check
fi
fi
make install
cd ..
done
# create test session directory, archive and manifest
cd $prefix_base
ts_name="$NODE_NAME-$BUILD_TAG"
local_ts_base="./compose_ts"
local_ts_dir="$local_ts_base/$ts_name"
rm -rf "$local_ts_base" || true
mkdir -p "$local_ts_dir"
# create archive of openbsc build
cd "$prefix_dirname"
tar czf "../$local_ts_dir/$archive" *
cd ..
# move archived bts builds into test session directory
mv $WORKSPACE/osmo-bts-*.tgz "$local_ts_dir"
cd "$local_ts_dir"
md5sum *.tgz > $manifest
cd -
# transfer test session directory to temporary dir on osmo-gsm-tester host
# when transfer is complete, move the directory to its final location (where
# the osmo-gsm-tester will recognize the session directory and start the session
ssh $osmo_gsm_tester_host "mkdir -p $tmp_dir"
scp -r "$local_ts_dir" $osmo_gsm_tester_host:$tmp_dir/
ssh $osmo_gsm_tester_host "mv $tmp_dir/$ts_name $osmo_gsm_tester_dir"
# poll for test status
ts_dir="$osmo_gsm_tester_dir/$ts_name"
set +x
ts_log=$ts_dir/test-session.log
echo "Waiting for test session log to be created"
while /bin/true; do
if ssh $osmo_gsm_tester_host "test -e $ts_log"; then
break
fi
sleep 1
done
echo "Following test session log"
# NOTE this will leave dead ssh session with tail running
ssh $osmo_gsm_tester_host "tail -f $ts_log" &
echo "Waiting for test session to complete"
while /bin/true; do
# if [ "$test_timeout_sec" = "0" ]; then
# echo "TIMEOUT test execution timeout ($test_timeout_sec seconds) exceeded!"
# exit 1
# fi
if ssh $osmo_gsm_tester_host "test -e $ts_dir/$test_report"; then
break
fi
sleep 1
# test_timeout_sec="$(($test_timeout_sec - 1))"
done
set -x
# use pgrep to terminate the ssh/tail (if it still exists)
remote_tail_pid=`ssh $osmo_gsm_tester_host "pgrep -fx 'tail -f $ts_log'"`
echo "remote_tail_pid = $remote_tail_pid"
ssh $osmo_gsm_tester_host "kill $remote_tail_pid"
# copy contents of test session directory back and remove it from the osmo-gsm-tester host
rsync -av -e ssh --exclude='inst-*' --exclude='tmp*' $osmo_gsm_tester_host:$ts_dir/ "$local_ts_dir/"
ssh $osmo_gsm_tester_host "/usr/local/src/osmo-gsm-tester/contrib/ts-dir-cleanup.sh"
# touch test-report.xml (to make up for clock drift between jenkins and build slave)
touch "$local_ts_dir/$test_report"

View File

@ -1,94 +1,65 @@
#!/bin/sh
set -x -e
set -e
base="$PWD"
prefix="$base/inst-osmo-bts-octphy"
OPTION_DO_CLONE=0
OPTION_DO_CLEAN=0
OPTION_DO_TEST=1
rm -f "$base/osmo-bts-octphy*.tgz"
PREFIX=`pwd`/inst-osmo-bts-octphy
# NOTE Make sure either 'octphy-2g-headers' (prefered) or
# 'octsdr-2g' is listed among the repositories
octbts_repos="libosmocore
deps="
libosmocore
libosmo-abis
openbsc/openbsc
octphy-2g-headers
osmo-bts"
osmo-bts
"
clone_repos() {
repos="$1"
for repo in $repos; do
if [ -e $repo ]; then
continue
fi
if [ "$repo" = "libosmocore" ]; then
url="git://git.osmocom.org/libosmocore.git"
elif [ "$repo" = "libosmo-abis" ]; then
url="git://git.osmocom.org/libosmo-abis.git"
elif [ "$repo" = "libosmo-netif" ]; then
url="git://git.osmocom.org/libosmo-netif.git"
elif [ "$repo" = "openbsc/openbsc" ]; then
url="git://git.osmocom.org/openbsc"
elif [ "$repo" = "octphy-2g-headers" ]; then
url="git://git.osmocom.org/octphy-2g-headers"
elif [ "$repo" = "octsdr-2g" ]; then
# NOTE acutally we only need the headers from the octphy-2g-headers
# repository but this (private) repository contains more recent versions
url="ssh://git@git.admin.sysmocom.de/octasic/octsdr-2g"
elif [ "$repo" = "osmo-bts" ]; then
url="git://git.osmocom.org/osmo-bts.git"
else
exit 2
fi
git clone $url
done
have_repo() {
repo="$1"
cd "$base"
if [ ! -e "$repo" ]; then
set +x
echo "MISSING REPOSITORY: $repo"
echo "should be provided by the jenkins workspace"
exit 1
fi
cd "$repo"
git clean -dxf
cd "$base"
}
main() {
repos="$1"
if [ $OPTION_DO_CLONE -eq 1 ]; then clone_repos "$repos"; fi
rm -rf $PREFIX
mkdir -p $PREFIX
for repo in $repos; do
if [ "$repo" = "openbsc/openbsc" ]; then
continue
fi
if [ "$repo" = "octphy-2g-headers" ]; then
OCTPHY_INCDIR=`pwd`/octphy-2g-headers
continue
fi
if [ "$repo" = "octsdr-2g" ]; then
cd $repo
git checkout 5c7166bab0a0f2d8a9664213d18642ae305e7004
cd -
OCTPHY_INCDIR=`pwd`/octsdr-2g/software/include
continue
fi
cd $repo
if [ $OPTION_DO_CLEAN -eq 1 ]; then git clean -dxf; fi
echo "$(git rev-parse HEAD) $repo" >> "$PREFIX/osmo-bts-octphy_git_hashes.txt"
autoreconf -fi
if [ "$repo" != "libosmocore" ]; then
export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig
export LD_LIBRARY_PATH=$PREFIX/lib:/usr/local/lib
fi
config_opts=""
case "$repo" in
'osmo-bts') config_opts="$config_opts --enable-octphy --with-octsdr-2g=$OCTPHY_INCDIR"
esac
./configure --prefix=$PREFIX $config_opts
make -j8
if [ $OPTION_DO_TEST -eq 1 ]; then make check; fi
make install
cd ..
done
}
# for gsm_data_shared.*
have_repo openbsc
set -x
main "$octbts_repos"
# octphy headers
have_repo octphy-2g-headers
# build the archive that is going to be copied to the tester and then to the BTS
rm -f $WORKSPACE/osmo-bts-octphy*.tgz
tar czf $WORKSPACE/osmo-bts-octphy.build-$BUILD_NUMBER.tgz inst-osmo-bts-octphy
rm -rf "$prefix"
mkdir -p "$prefix"
export PKG_CONFIG_PATH="$prefix/lib/pkgconfig"
export LD_LIBRARY_PATH="$prefix/lib"
for dep in $deps; do
have_repo "$dep"
cd "$dep"
rm -rf *
git checkout .
echo "$(git rev-parse HEAD) $dep" >> "$prefix/osmo-bts-octphy_git_hashes.txt"
autoreconf -fi
config_opts=""
case "$repo" in
'osmo-bts') config_opts="$config_opts --enable-octphy --with-octsdr-2g=$base/octphy-2g-headers" ;;
esac
./configure --prefix="$prefix" $config_opts
make -j8
make install
done
# build the archive that is going to be copied to the tester
cd "$prefix"
tar czf "$base/osmo-bts-octphy.build-${BUILD_NUMBER}.tgz" *

View File

@ -1,3 +1,4 @@
#!/bin/sh
set -e -x
deps="
@ -7,6 +8,7 @@ osmo-bts
"
base="$PWD"
rm -f "$base/osmo-bts-sysmo.*.tgz"
have_repo() {
repo="$1"
@ -31,6 +33,7 @@ have_repo openbsc
. /opt/poky/1.5.4/environment-setup-armv5te-poky-linux-gnueabi
# Cross-compilation: all installations need to be put in the sysmo SDK sysroot
export DESTDIR=/opt/poky/1.5.4/sysroots/armv5te-poky-linux-gnueabi
prefix_base="/usr/local/jenkins-build"
@ -42,24 +45,25 @@ prefix_real="$DESTDIR$prefix"
mkdir -p "$prefix_real"
for dep in $deps; do
cd "$base/$dep"
cd "$base/$dep"
rm -rf *
git checkout .
echo "$(git rev-parse HEAD) $dep" >> "$prefix_real/osmo-bts-sysmo_git_hashes.txt"
echo "$(git rev-parse HEAD) $dep" >> "$prefix_real/osmo-bts-sysmo_git_hashes.txt"
autoreconf -fi
autoreconf -fi
config_opts=""
case "$dep" in
'libosmocore') config_opts="--disable-pcsc" ;;
'osmo-bts') config_opts="--enable-sysmocom-bts --with-openbsc=$base/openbsc/openbsc/include" ;;
esac
config_opts=""
case "$dep" in
'libosmocore') config_opts="--disable-pcsc" ;;
'osmo-bts') config_opts="--enable-sysmocom-bts --with-openbsc=$base/openbsc/openbsc/include" ;;
esac
./configure --prefix="$prefix" $CONFIGURE_FLAGS $config_opts
make -j8
make install
./configure --prefix="$prefix" $CONFIGURE_FLAGS $config_opts
make -j8
make install
done
# build the archive that is going to be copied to the tester and then to the BTS
rm -f "$base/osmo-bts-sysmo.*.tgz"
cd "$prefix_base_real"
cd "$prefix_real"
tar cvzf "$base/osmo-bts-sysmo.build-${BUILD_NUMBER}.tgz" *

View File

@ -1,8 +1,10 @@
#!/bin/sh
set -x -e
base="$PWD"
inst="inst-osmo-bts-trx"
prefix="$base/$inst"
prefix="$base/inst-osmo-bts-trx"
rm -f "$base/osmo-bts-trx*.tgz"
deps="
libosmocore
@ -38,6 +40,8 @@ export LD_LIBRARY_PATH="$prefix/lib"
for dep in $deps; do
have_repo "$dep"
cd "$dep"
rm -rf *
git checkout .
echo "$(git rev-parse HEAD) $dep" >> "$prefix/osmo-bts-trx_osmo-trx_git_hashes.txt"
@ -56,6 +60,5 @@ for dep in $deps; do
done
# build the archive that is going to be copied to the tester
rm -f "$base/osmo-bts-trx*.tgz"
cd "$base"
tar czf "osmo-bts-trx.build-${BUILD_NUMBER}.tgz" "$inst"
cd "$prefix"
tar czf "$base/osmo-bts-trx.build-${BUILD_NUMBER}.tgz" *

63
contrib/jenkins-osmo-nitb.sh Executable file
View File

@ -0,0 +1,63 @@
set -e -x
base="$PWD"
prefix="$base/inst-osmo-nitb"
rm -f "$base/osmo-nitb*.tgz"
deps="
libosmocore
libosmo-abis
libosmo-netif
openggsn
libsmpp34
libosmo-sccp
openbsc
"
have_repo() {
repo="$1"
cd "$base"
if [ ! -e "$repo" ]; then
set +x
echo "MISSING REPOSITORY: $repo"
echo "should be provided by the jenkins workspace"
exit 1
fi
cd "$repo"
git clean -dxf
cd "$base"
}
rm -rf "$prefix"
mkdir -p "$prefix"
export PKG_CONFIG_PATH="$prefix/lib/pkgconfig"
export LD_LIBRARY_PATH="$prefix/lib"
for dep in $deps; do
have_repo "$dep"
cd "$dep"
rm -rf *
git checkout .
echo "$(git rev-parse HEAD) $dep" >> "$prefix/osmo-nitb_git_hashes.txt"
config_opts=""
case "$dep" in
'openbsc')
config_opts="$config_opts --enable-smpp --enable-osmo-bsc --enable-nat"
cd openbsc/
;;
esac
autoreconf -fi
./configure --prefix="$prefix" $config_opts
make -j8 || make # libsmpp34 can't build in parallel
make install
done
# build the archive that is going to be copied to the tester
cd "$prefix"
tar czf "$base/osmo-nitb.build-${BUILD_NUMBER}.tgz" *

View File

@ -0,0 +1,24 @@
#!/bin/sh
set -e -x
if [ -z "$OSMO_GSM_TESTER_REMOTE_MAIN_UNIT" ]; then
echo "To run the tests from jenkins, a main unit host must be defined."
echo "e.g. OSMO_GSM_TESTER_REMOTE_MAIN_UNIT=\"user@10.9.8.7\""
fi
osmo_gsm_tester_host="$OSMO_GSM_TESTER_REMOTE_MAIN_UNIT"
osmo_gsm_tester_src="${OSMO_GSM_TESTER_REMOTE_SRC:-/usr/local/src/osmo-gsm-tester}"
if ssh "$osmo_gsm_tester_host" "test -d \"$osmo_gsm_tester_src\"" ; then
# exists
status="$(ssh "$osmo_gsm_tester_host" "git -C \"$osmo_gsm_tester_src\" status --porcelain")"
if [ "x$status" != "x" ]; then
echo "Remote osmo-gsm-tester is not clean: $osmo_gsm_tester_host:$osmo_gsm_tester_src"
echo "$status"
exit 1
fi
ssh "$osmo_gsm_tester_host" "cd \"$osmo_gsm_tester_src\"; git clean -fdx; git pull"
else
osmo_gsm_tester_src_dirname="$(dirname "$osmo_gsm_tester_src")"
ssh "$osmo_gsm_tester_host" "git clone git://git.osmocom.org/osmo-gsm-tester.git \"$osmo_gsm_tester_src\""
fi

36
contrib/jenkins-run.sh Executable file
View File

@ -0,0 +1,36 @@
#!/bin/sh
set -e -x
if [ -z "$OSMO_GSM_TESTER_REMOTE_MAIN_UNIT" ]; then
echo "To run the tests from jenkins, a main unit host must be defined."
echo "e.g. OSMO_GSM_TESTER_REMOTE_MAIN_UNIT=\"user@10.9.8.7\""
fi
osmo_gsm_tester_host="$OSMO_GSM_TESTER_REMOTE_MAIN_UNIT"
osmo_gsm_tester_src="${OSMO_GSM_TESTER_REMOTE_SRC:-/usr/local/src/osmo-gsm-tester}"
osmo_gsm_tester_dir="/var/tmp/osmo-gsm-tester"
tmp_dir="/var/tmp/prep-osmo-gsm-tester"
trial_name="$NODE_NAME-$BUILD_TAG"
local_trial_base="./compose_trial"
local_trial_dir="$local_trial_base/$trial_name"
rm -rf "$local_trial_base" || true
mkdir -p "$local_trial_dir"
# Add archives from other jenkins builds.
# This jenkins job must be configured to copy *.tgz artifacts to the
# workspace from the various jenkins*bts*.sh runs.
mv $WORKSPACE/*.tgz "$local_trial_dir"
cd "$local_trial_dir"
md5sum *.tgz > checksums.md5
cd -
ssh "$osmo_gsm_tester_host" "$osmo_gsm_tester_src/contrib/trials-cleanup.sh"
ssh "$osmo_gsm_tester_host" "mkdir -p $tmp_dir"
scp -r "$local_trial_dir" $osmo_gsm_tester_host:$tmp_dir/
ssh "$osmo_gsm_tester_host" "mv $tmp_dir/$trial_name $osmo_gsm_tester_dir"
trial_dir="$osmo_gsm_tester_dir/$trial_name"
ssh "$osmo_gsm_tester_host" "$osmo_gsm_tester_src/src/osmo-gsm-tester.py $trial_dir"

30
contrib/trials-cleanup.sh Executable file
View File

@ -0,0 +1,30 @@
#!/bin/sh
# Remove all but the N newest test run dirs (that have been started)
trial_rx_dir="$1"
trial_prep_dir="$2"
if [ -z "$trial_rx_dir" ]; then
trial_rx_dir="/var/tmp/osmo-gsm-tester"
fi
if [ -z "$trial_prep_dir" ]; then
trial_prep_dir="/var/tmp/prep-osmo-gsm-tester"
fi
mkdir -p "$trial_prep_dir"
rm_trial() {
trial_dir="$1"
trial_name="$(basename "$trial_dir")"
echo "Removing: $(ls -ld "$trial_dir")"
# ensure atomic removal, so that the gsm-tester doesn't take it as a
# newly added dir (can happen when the 'SEEN' marker is removed first).
mv "$trial_dir" "$trial_prep_dir/"
rm -rf "$trial_prep_dir/$trial_name"
}
# keep the N newest test session dirs that have been started: find all that
# have been started sorted by time, then discard all but the N newest ones.
for seen in $(ls -1t "$trial_rx_dir"/*/SEEN | tail -n +31); do
rm_trial "$(dirname "$seen")"
done

View File

@ -1,30 +0,0 @@
#!/bin/sh
# Remove all but the N newest test run dirs (that have been started)
ts_rx_dir="$1"
ts_prep_dir="$2"
if [ -z "$ts_rx_dir" ]; then
ts_rx_dir="/var/tmp/osmo-gsm-tester"
fi
if [ -z "$ts_prep_dir" ]; then
ts_prep_dir="/var/tmp/prep-osmo-gsm-tester"
fi
mkdir -p "$ts_prep_dir"
rm_ts() {
ts_dir="$1"
ts_name="$(basename "$ts_dir")"
echo "Removing: $(ls -ld "$ts_dir")"
# ensure atomic removal, so that the gsm-tester doesn't take it as a
# newly added dir (can happen when the 'SEEN' marker is removed first).
mv "$ts_dir" "$ts_prep_dir/"
rm -rf "$ts_prep_dir/$ts_name"
}
# keep the N newest test session dirs that have been started: find all that
# have been started sorted by time, then discard all but the N newest ones.
for seen in $(ls -1t "$ts_rx_dir"/*/SEEN | tail -n +31); do
rm_ts "$(dirname "$seen")"
done

View File

@ -0,0 +1 @@
- sms:trx

View File

@ -66,7 +66,8 @@ package's directory: Upon launch, a 'test_package/run.<date>' directory will be
created, which will collect logs and reports.
'''
from osmo_gsm_tester import trial, suite, log, __version__
from osmo_gsm_tester import __version__
from osmo_gsm_tester import trial, suite, log, config
if __name__ == '__main__':
import argparse
@ -109,6 +110,12 @@ if __name__ == '__main__':
# for series in args.series:
# combination_strs.extend(config.get_series(series))
if not combination_strs:
combination_strs = config.read_config_file(config.DEFAULT_SUITES_CONF, if_missing_return=[])
if combination_strs:
print('Running default suites:\n ' + ('\n '.join(combination_strs)))
if not combination_strs:
raise RuntimeError('Need at least one suite:scenario or series to run')

View File

@ -67,6 +67,7 @@ DEFAULT_CONFIG_LOCATIONS = [
]
PATHS_CONF = 'paths.conf'
DEFAULT_SUITES_CONF = 'default-suites.conf'
PATH_STATE_DIR = 'state_dir'
PATH_SUITES_DIR = 'suites_dir'
PATH_SCENARIOS_DIR = 'scenarios_dir'