Project

General

Profile

Titan TTCN3 Testsuites » History » Version 50

laforge, 07/25/2022 07:42 AM
gitea

1 1 laforge
h1. Osmocom Titan TTCN3 Testsuites
2 36 fixeria
3
{{>toc}}
4 1 laforge
5 14 osmith
In 2017, Osmocom started to create extensive tests suites for the Cellular Network Infrastructure elements.  Those suites are written in the [[TTCN-3]] programming language and use the compiler and executor of the [[Eclipse_TITAN]] project. There are special cases, but in general, the idea is to test one component (e.g. @osmo-mgw@) independently.
6 2 laforge
7 40 Hoernchen
h2. Development
8
9
See [[Titan_TTCN3_Notes]]
10
11 2 laforge
h2. Source Code / Patches
12
13
The source code of our test suites lives in the @osmo-ttcn3-hacks@ repository
14 50 laforge
* web interface: https://gitea.osmocom.org/ttcn3/osmo-ttcn3-hacks
15
* clone: @git clone https://gitea.osmocom.org/ttcn3/osmo-ttcn3-hacks@
16 2 laforge
* patch review: https://gerrit.osmocom.org/#/q/project:osmo-ttcn3-hacks
17
18
We're following the [[Gerrit]] process for patch review.
19
20 32 laforge
h2. Proprietary APER<->BER transcoding library for Iu tests
21
22 48 fixeria
As TITAN can only generate and parse ASN.1 BER encoding, but the Iu-CS, Iu-PS and Iuh interfaces are using APER encoding, sysmocom is providing a proprietary transcoding library called libfftranscode.  Debian9 amd64 packages are available from https://ftp.osmocom.org/binaries/libfftranscode/.  For Arch Linux users, there is an "AUR package":https://aur.archlinux.org/packages/libfftranscode/ that basically downloads the Debian package and extracts libfftranscode.so from it.
23 32 laforge
24
We don't like to depend on proprietary software, but given that there is no FOSS ASN.1 compiler that can parse all ASN.1 constructs of the RANAP/RUA/HNBAP specs *and* parse + generate both BER and APER, this is the lesser evil.  Note that the dependency to this proprietary library is only required for the TTCN3 test suite and not a runtime dependency of any of the Osmocom programs itself.
25
26 2 laforge
h2. Test Suites
27
28
|_.Implementation under Test|_.Testsuite|_.Jenkins|
29 41 daniel
|[[OsmoBSCNAT:]]|http://git.osmocom.org/osmo-ttcn3-hacks/tree/bsc-nat|https://jenkins.osmocom.org/jenkins/view/TTCN3/job/ttcn3-bscnat-test/|
30 2 laforge
|[[OsmoBSC:]]|http://git.osmocom.org/osmo-ttcn3-hacks/tree/bsc|https://jenkins.osmocom.org/jenkins/view/TTCN3/job/ttcn3-bsc-test/|
31
|[[OsmoBTS:]]|http://git.osmocom.org/osmo-ttcn3-hacks/tree/bts|https://jenkins.osmocom.org/jenkins/view/TTCN3/job/ttcn3-bts-test/|
32
|[[OpenGGSN:OsmoGGSN]]|http://git.osmocom.org/osmo-ttcn3-hacks/tree/ggsn_tests|https://jenkins.osmocom.org/jenkins/view/TTCN3/job/ttcn3-ggsn-test/|
33
|[[OsmoHLR:]]|http://git.osmocom.org/osmo-ttcn3-hacks/tree/hlr|https://jenkins.osmocom.org/jenkins/view/TTCN3/job/ttcn3-hlr-test/|
34
|[[OsmoMGW:]]|http://git.osmocom.org/osmo-ttcn3-hacks/tree/mgw|https://jenkins.osmocom.org/jenkins/view/TTCN3/job/ttcn3-mgw-test/|
35
|[[OsmoMSC:]]|http://git.osmocom.org/osmo-ttcn3-hacks/tree/msc|https://jenkins.osmocom.org/jenkins/view/TTCN3/job/ttcn3-msc-test/|
36 41 daniel
|[[OsmoPCU:]]|http://git.osmocom.org/osmo-ttcn3-hacks/tree/pcu|https://jenkins.osmocom.org/jenkins/view/TTCN3/job/ttcn3-pcu-test/, https://jenkins.osmocom.org/jenkins/view/TTCN3/job/ttcn3-pcu-test-sns/|
37 2 laforge
|[[OsmoSGSN:]]|http://git.osmocom.org/osmo-ttcn3-hacks/tree/sgsn|https://jenkins.osmocom.org/jenkins/view/TTCN3/job/ttcn3-sgsn-test/|
38
|[[osmo-sip-connector:]]|http://git.osmocom.org/osmo-ttcn3-hacks/tree/sip|https://jenkins.osmocom.org/jenkins/view/TTCN3/job/ttcn3-sip-test/|
39 42 pespin
|[[osmoSTP:]]|http://git.osmocom.org/osmo-ttcn3-hacks/tree/stp|https://jenkins.osmocom.org/jenkins/view/TTCN3/job/ttcn3-stp-test/|
40 2 laforge
41
h2. Running a testsuite
42
43
You have multiple options on how to execute a test suite.
44
45
h3. Running test suite in the dockerized environment
46 1 laforge
47 4 osmith
This is the much easier way to run the test suite.  No manual configuration of Osmocom programs or the test suite are required.  Both the Osmocom program (Implementation Under Test) as well as the test suite are packaged as docker containers, which are then executed next to each other using a docker network with the "right" addresses between IUT and testsuite.
48 2 laforge
49
Also, using this setup you will be guaranteed to run in the exact same environment as the automatically-executed tests on jenkins.osmocom.org, i.e. your results should be exactly identical, without any differences introduced by your runtime environment, whether specific library versions or intentional or inadvertent configuration differences.
50
51 10 osmith
h4. Installing docker
52 1 laforge
53 10 osmith
Make sure you have "*docker-ce*":https://docs.docker.com/install/#supported-platforms installed (not to be confused with the possibly outdated version that may be shipped in your distribution's repositories). Check that the version string contains <code>-ce</code> as follows:
54
55
<pre>
56
$ docker -v
57
Docker version 18.06.1-ce, build e68fc7a
58
</pre>
59
60
61 11 osmith
Next, add yourself to the <code>docker</code> group, log off and on again, and verify that you can use docker with your user:
62 10 osmith
63
<pre>
64
$ docker info
65
</pre>
66
67
h4. Cloning docker-playground
68
69 50 laforge
Osmocom related containers are stored in the "@docker-playground@":https://gitea.osmocom.org/osmocom/docker-playground git repository.
70 5 osmith
71
<pre>
72 50 laforge
$ git clone https://gitea.osmocom.org/osmocom/docker-playground
73 5 osmith
$ cd docker-playground
74 1 laforge
</pre>
75 6 osmith
76 44 osmith
h4. Running jenkins.sh
77 1 laforge
78 38 osmith
All testsuite directories start with @ttcn3@ or @nplab@. Run the following to build/update all required containers and start a specific testsuite:
79 24 osmith
80 1 laforge
<pre>
81 24 osmith
$ cd ttcn3-mgw-test
82
$ ./jenkins.sh
83 1 laforge
</pre>
84
85 33 osmith
The @jenkins.sh@ script will make sure to
86 24 osmith
* create the needed docker network(s)
87 6 osmith
* run all the required containers (IUT, helpers, testsuite)
88 24 osmith
* shut them down after test suite execution
89 6 osmith
* collect the log files after execution, @/tmp/logs@ will contain them
90 43 osmith
91 50 laforge
Control the behavior of <code>jenkins.sh</code> with environment variables as described in docker-playground's "README.md":https://gitea.osmocom.org/osmocom/docker-playground/src/branch/master/README.md. This file also explains advanced features, such as the kernel module tests.
92 6 osmith
93 2 laforge
h4. Running only a sub-set of the test cases
94
95 20 osmith
See running the testsuite outside of Docker for reference (below).
96
97 28 osmith
h3. Running it natively on your machine
98 2 laforge
99 46 fixeria
This is the most complicated bit to set-up, as you will have to run the respective Osmocom Program (Implementation Under Test) in the right configuration with all the IP addresses, port numbers, config file, etc. exactly like it's expected by the test suite. Even though the configuration files contained in osmo-ttcn3-hacks.git are expected to work 'as-is' when running tests natively, some of them may get out of sync with the respective files in docker-playground.git.
100 1 laforge
101 14 osmith
You will need a deeper understanding about how the test suite works, and what its requirement are. Oftentimes looking at how it's done in the Docker scripts is helpful.
102
103
h4. Preparation
104
105 34 Hoernchen
As stated [[Titan_TTCN3_Testsuites##Proprietary-APERBER-transcoding-library-for-Iu-tests|above]] certain parts of the testsuite require libfftranscode! If the build fails this might be the issue.
106 35 laforge
107 50 laforge
While you can try to use any version of Eclipse TITAN, for the best possible experience it's a good idea to use the same version as Osmocom uses in the dockerized environment.  As can be seen in the "Dockerfile":https://gitea.osmocom.org/osmocom/docker-playground/src/branch/master/debian-bullseye-titan/Dockerfile, this (currently) points to the eclipse-titan package from the [[Latest_Builds]] on Debian 11":.
108 35 laforge
109 14 osmith
<pre>
110
$ apt install eclipse-titan
111 50 laforge
$ git clone https://gitea.osmocom.org/ttcn3/osmo-ttcn3-hacks
112 14 osmith
$ cd osmo-ttc3-hacks/deps
113
$ make
114
</pre>
115
116
h4. Compile a testsuite
117
118
Let's compile the @mgw@ testsuite for example:
119
120
<pre>
121
$ cd mgw
122
$ ./gen_links.sh
123 26 msuraev
$ ./regen_makefile.sh
124 14 osmith
</pre>
125 1 laforge
126 23 osmith
The next command will transform the TTCN3 test data into C++ code. Do not use @-j@ here, that won't work (and it is pretty fast anyway).
127 14 osmith
<pre>
128
$ make compile
129
</pre>
130
131 27 msuraev
Note: if you observe errors during @make compile@, try running it from top-level as @make mgw@ which should trigger dependency update.
132
133 14 osmith
Finally compile the testsuite:
134
<pre>
135
$ make -j5
136
</pre>
137 27 msuraev
138 14 osmith
h4. Run a testsuite
139
140 50 laforge
In case you're using tmux, "osmo-dev":https://gitea.osmocom.org/osmocom/osmo-dev contains useful "scripts":https://gitea.osmocom.org/osmocom/osmo-dev/src/branch/master/ttcn3/tmux for starting some test suites in a dedicated tmux session. These scripts prepare the working environment by starting the IUT and its dependencies in separate windows/panes. This helps to save time a lot, e.g. for ttcn3-bsc-test one would need to run osmo-bsc, osmo-stp, and three instances of osmo-bts-omldummy. Just execute the respective script and you're ready to go. Below are the instructions for general (tmuxless) use case.
141 49 fixeria
142 50 laforge
Start the component that is about to get tested with the config that the testsuite expects. Again, with @mgw@ as example. A suitable config file should be in the same directory of osmo-ttcn3-hacks.git (otherwise one can use "the one from Jenkins":https://gitea.osmocom.org/osmocom/docker-playground/src/branch/master/ttcn3-mgw-test/osmo-mgw.cfg  and replace all IPs with @127.0.0.1@).
143 14 osmith
<pre>
144 21 osmith
$ osmo-mgw -c osmo-mgw.cfg
145 14 osmith
</pre>
146
147
Then run the testsuite:
148
<pre>
149
$ cd osmo-ttcn3-hacks/mgw
150
$ ../start-testsuite.sh ./MGCP_test MGCP_Test.cfg
151
</pre>
152
153
Afterwards you can merge and format the logs as follows:
154
<pre>
155
$ ttcn3_logmerge MGCP_test*.log > ./merged.log
156 1 laforge
$ ttcn3_logformat ./merged.log > ./result.log
157 30 msuraev
</pre>
158
or
159
<pre>
160 31 msuraev
$ ../log_merge.sh MGCP_test
161 1 laforge
</pre>
162 37 osmith
163 50 laforge
Depending on the component that you want to test, you may need to run multiple Osmocom programs. For OsmoMSC, you would run osmo-msc and osmo-stp for example. See the containers that "jenkins.sh":https://gitea.osmocom.org/osmocom/docker-playground/src/branch/master/ttcn3-msc-test/jenkins.sh is running for reference.
164 2 laforge
165
h4. Running only a sub-set of the test cases
166
167 50 laforge
Running whole testsuites may take a long time. If you only want to run one specific test, or a subset of tests, open up the @_*Test.cfg@ file in the directory of the testsuite and edit the @[EXECUTE]@ section. For example, in "@MGCP_Test.cfg@":https://gitea.osmocom.org/ttcn3/osmo-ttcn3-hacks/src/branch/master/mgw/MGCP_Test.cfg from the @mgw@ directory it looks like the following: 
168 16 osmith
169
<pre>
170 1 laforge
...
171 17 osmith
[EXECUTE]
172
MGCP_Test.control
173
#MGCP_Test.TC_selftest
174
#MGCP_Test.TC_crcx
175
#MGCP_Test.TC_crcx_noprefix
176
...
177
</pre>
178 1 laforge
179 17 osmith
The only line that is *not* commented out is @MGCP_Test.control@. This @*.control@ line will cause all tests to be executed. So comment this line out, and then activate one of the lines of which you would like to execute the tests (see the example below). Then execute the testsuite as usually, and it will skip all commented out tests.
180
181
<pre>
182
...
183
[EXECUTE]
184
#MGCP_Test.control
185
#MGCP_Test.TC_selftest
186
MGCP_Test.TC_crcx
187
MGCP_Test.TC_crcx_noprefix
188
...
189 16 osmith
</pre>
190 2 laforge
191 15 osmith
h2. Reading the logs
192
193
* @xfail@ means, that a test is known to fail, @FAIL@ are unexpected test failures
194
* search for @setverdict(@ to find the results of single tests. @-> fail@ should be the location where a test is failing.
195
196 2 laforge
h2. Further information
197
198 22 osmith
* April 2018 talk by Harald on "State of the Osmocom TTCN-3 Test Suites":https://media.ccc.de/v/UGHHW3
199 39 osmith
* "Patch for colormake to colorize the ttcn3 compiler output":https://github.com/osmith42/Colormake/tree/osmith/ttcn3
Add picture from clipboard (Maximum size: 48.8 MB)