ttcn3-bts-test: add env var to not run all configs

Make it possible to e.g. run only one of the generic/oml/hopping
configurations.

I made a version of this patch a few weeks ago for testing OS#6375,
and I'm submitting it now so I can add multiple configurations for
ttcn3-ggsn-test in the next patch with the same logic.

Change-Id: I1dce5e6aa4b5d67f9f8c96ced611ab2875c353c8
This commit is contained in:
Oliver Smith 2024-02-27 15:35:54 +01:00
parent 97b719db53
commit aad045f5b6
3 changed files with 128 additions and 45 deletions

View File

@ -28,15 +28,29 @@ Environment variables:
containers (see "caching" below)
* `DOCKER_ARGS`: pass extra arguments to docker, e.g. to mount local sources
for building as done in osmo-dev.git/ttcn3/ttcn3.sh
* `TEST_CONFIGS`: for tests that can run with multiple config sets (e.g.
`ttcn3-bts-test`), run only some of them. See `TEST_CONFIGS_ALL` in the
`jenkins.sh` for possible values.
### Run only one test
Run only `TC_gsup_sai` in `ttcn3-hlr-test`:
```
$ cd ttcn3-hlr-test
$ export DOCKER_ARGS="-e TEST_NAME=TC_gsup_sai"
$ ./jenkins.sh
```
Run only `TC_est_dchan` in `ttcn3-bts-test`, with the `generic` configuration:
```
$ cd ttcn3-bts-test
$ export DOCKER_ARGS="-e TEST_NAME=TC_est_dchan"
$ export TEST_CONFIGS="generic"
$ ./jenkins.sh
```
### Using nightly packages from a different date
Pick a date from [here](https://downloads.osmocom.org/obs-mirror/) and use it:

View File

@ -569,6 +569,43 @@ write_mp_osmo_repo() {
"$config"
}
# Output the name of the test config and check if it is enabled. Use this
# function in jenkins.sh, after setting TEST_CONFIGS_ALL, e.g.:
# TEST_CONFIGS_ALL="generic oml hopping"
# The user can then set TEST_CONFIGS to only run one of the test
# configurations.
# $1: one of TEST_CONFIGS_ALL, e.g. "classic"
test_config_enabled() {
local config="$1"
local i
local valid=0
for i in $TEST_CONFIGS_ALL; do
if [ "$config" = "$i" ]; then
valid=1
break
fi
done
if [ "$valid" != "1" ]; then
set +x
echo "ERROR: config name '$config' is not one of '$TEST_CONFIGS_ALL'"
exit 1
fi
if [ -z "$TEST_CONFIGS" ]; then
return 0
fi
for i in $TEST_CONFIGS; do
if [ "$config" = "$i" ]; then
return 0
fi
done
return 1
}
set -x
# non-jenkins execution: assume local user name

View File

@ -1,4 +1,6 @@
#!/bin/sh
TEST_CONFIGS_ALL="generic virtphy oml hopping"
TEST_CONFIGS="${TEST_CONFIGS:-"generic oml hopping"}"
. ../jenkins-common.sh
IMAGE_SUFFIX="${IMAGE_SUFFIX:-master}"
@ -13,12 +15,14 @@ set_clean_up_trap
set -e
clean_up() {
# append ':hopping' to the classnames,
# e.g. "classname='BTS_Tests'" => "classname='BTS_Tests:hopping'"
# e.g. "classname='BTS_Tests_SMSCB'" => "classname='BTS_Tests_SMSCB:hopping'"
# so the hopping test cases would not interfere with non-hopping ones in Jenkins
sed -i "s/classname='\([^']\+\)'/classname='\1:hopping'/g" \
$VOL_BASE_DIR/bts-tester-hopping/junit-xml-hopping-*.log
if test_config_enabled "hopping"; then
# append ':hopping' to the classnames,
# e.g. "classname='BTS_Tests'" => "classname='BTS_Tests:hopping'"
# e.g. "classname='BTS_Tests_SMSCB'" => "classname='BTS_Tests_SMSCB:hopping'"
# so the hopping test cases would not interfere with non-hopping ones in Jenkins
sed -i "s/classname='\([^']\+\)'/classname='\1:hopping'/g" \
$VOL_BASE_DIR/bts-tester-hopping/junit-xml-hopping-*.log
fi
}
start_bsc() {
@ -167,49 +171,77 @@ mkdir $VOL_BASE_DIR/trxcon
mkdir $VOL_BASE_DIR/virtphy
# 1) classic test suite with BSC for OML and trxcon+fake_trx
network_replace_subnet_in_configs
start_bsc
start_bts trx 1
start_fake_trx
start_trxcon
start_testsuite generic
if test_config_enabled "generic"; then
network_replace_subnet_in_configs
start_bsc
start_bts trx 1
start_fake_trx
start_trxcon
start_testsuite generic
docker_kill_wait ${BUILD_TAG}-trxcon
docker_kill_wait ${BUILD_TAG}-fake_trx
docker_kill_wait ${BUILD_TAG}-bts
docker_kill_wait ${BUILD_TAG}-bsc
fi
# 2) some GPRS tests require virt_phy
echo "Changing to virtphy configuration"
# switch from osmo-bts-trx + trxcon + faketrx to virtphy + osmo-bts-virtual
docker_kill_wait ${BUILD_TAG}-trxcon
docker_kill_wait ${BUILD_TAG}-fake_trx
docker_kill_wait ${BUILD_TAG}-bts
cp virtphy/osmo-bts.gen.cfg $VOL_BASE_DIR/bts/
network_replace_subnet_in_configs
# FIXME: multicast to/from a docker bridge network is currently not possible.
# See https://github.com/moby/libnetwork/issues/2397.
echo "XXX: not running the virtphy configuration"
#start_bts virtual 0
#start_virtphy
# ... and execute the testsuite again with different cfg
#start_testsuite virtphy
if test_config_enabled "virtphy"; then
# FIXME: multicast to/from a docker bridge network is currently not possible.
# See https://github.com/moby/libnetwork/issues/2397.
set +x
echo "ERROR: not running the virtphy configuration"
exit 1
cp virtphy/osmo-bts.gen.cfg $VOL_BASE_DIR/bts/
network_replace_subnet_in_configs
start_bsc
start_bts virtual 0
start_virtphy
start_testsuite virtphy
docker_kill_wait ${BUILD_TAG}-virtphy
docker_kill_wait ${BUILD_TAG}-bts
docker_kill_wait ${BUILD_TAG}-bsc
fi
# 3) OML tests require us to run without BSC
docker_kill_wait ${BUILD_TAG}-bsc
# switch back from virtphy + osmo-bts-virtual to osmo-bts-trx
#docker_kill_wait ${BUILD_TAG}-virtphy
#docker_kill_wait ${BUILD_TAG}-bts
if test_config_enabled "oml"; then
cp oml/osmo-bts.gen.cfg $VOL_BASE_DIR/bts/
network_replace_subnet_in_configs
cp oml/osmo-bts.gen.cfg $VOL_BASE_DIR/bts/
network_replace_subnet_in_configs
start_bts trx 1
start_fake_trx
start_trxcon
# ... and execute the testsuite again with different cfg
start_testsuite oml
start_bsc
start_bts trx 1
start_fake_trx
start_trxcon
start_testsuite oml
docker_kill_wait ${BUILD_TAG}-trxcon
docker_kill_wait ${BUILD_TAG}-fake_trx
docker_kill_wait ${BUILD_TAG}-bts
docker_kill_wait ${BUILD_TAG}-bsc
fi
# 4) Frequency hopping tests require different configuration files
cp fh/osmo-bsc.gen.cfg $VOL_BASE_DIR/bsc/
cp generic/osmo-bts.gen.cfg $VOL_BASE_DIR/bts/
# restart the BSC/BTS and run the testsuite again
docker_kill_wait ${BUILD_TAG}-bts
network_replace_subnet_in_configs
start_bsc
start_bts trx 1
start_testsuite hopping
if test_config_enabled "hopping"; then
cp fh/osmo-bsc.gen.cfg $VOL_BASE_DIR/bsc/
cp generic/osmo-bts.gen.cfg $VOL_BASE_DIR/bts/
network_replace_subnet_in_configs
start_bsc
start_bts trx 1
start_fake_trx
start_trxcon
start_testsuite hopping
docker_kill_wait ${BUILD_TAG}-trxcon
docker_kill_wait ${BUILD_TAG}-fake_trx
docker_kill_wait ${BUILD_TAG}-bsc
docker_kill_wait ${BUILD_TAG}-bts
fi