aboutsummaryrefslogtreecommitdiffstats
path: root/tests
AgeCommit message (Collapse)AuthorFilesLines
2019-11-27db v4: add column last_lu_seen_psNeels Hofmeyr1-8/+10
Location Updating procedures from both CS and PS overwrite the same last_lu_seen field of a subscriber. For upcoming D-GSM it will be important to distinguish those, because only CS attaches qualify for MSISDN lookup. Add column last_lu_seen_ps, and upon PS LU, do not overwrite last_lu_seen, so that last_lu_seen now only reflects CS LU. In the VTY, dump both LU dates distinctively. Change-Id: Id7fc50567211a0870ac0524f6dee94d4513781ba
2019-11-25test_nodes.vty: tweak: add some '?' checksNeels Hofmeyr1-3/+47
I added these "by accident" when implementing D-GSM related VTY tests, now submitting them separately. Change-Id: I92a4245cae806270b00330403cc114017ab7af53
2019-11-25remove gsup_testNeels Hofmeyr6-144/+0
The test doesn't do much: it encodes an Insert Subscriber Data request for the sole purpose to ensure the msgb is allocated large enough. A bug like that is easily avoided statically. Also, the lu functions will get refactored soon, it doesn't make sense to me to drag this test along. Change-Id: I42e1c72bf4cce8034f968cd4392773bf2b643c1b
2019-11-25Makefile convenience: add VTY_TEST var to run only one testNeels Hofmeyr1-3/+3
VTY transcript tests run all *.vty test scripts, and it is not so trivial to figure out the test-db creation and cmdline to run only one of them when debugging. Add VTY_TEST var, useful to pick one test on the cmdline: cd tests make vty-test VTY_TEST=test_nodes.vty Not all VTY tests leave files behind that match hlr_vty_test.db-*, so make sure that make does not fail it they can't be deleted (rm -f). Change-Id: I4ad7ddb31b2bfb668b3540cfef658417dd442375
2019-11-25db upgrade: remove some code dupNeels Hofmeyr1-0/+2
Instead of a switch() for each version number with identical switch cases except for the function name, use an array of function pointers and loop. Also print a success message after each individual version upgrade, instead of only one in the end (see change in db_upgrade_test.ok). Change-Id: I1736af3d9a3f02e29db836966ac15ce49f94737b
2019-11-25fix upgrade test in presence of ~/.sqlitercNeels Hofmeyr1-6/+6
db_upgrade_test.sh: - If an ~/.sqliterc file exists, it causes output of '-- Loading resources from ~/.sqliterc'. Use -batch option to omit that. - To make sure that column headers are off when required, add -noheaders in some places. Change-Id: I279a39984563594a4a3914b2ce3d803ad9468fe8
2019-11-20move headers to include/osmocom/hlrNeels Hofmeyr9-14/+14
Apply the same headers structure that we keep in most Osmocom source trees: Keep noinst_HEADERS in include/osmocom/hlr and include them using #include <osmocom/hlr/*.h> The only header kept in src/ is db_bootstrap.h, because it is generated during build time. If it was built in include/osmocom/hlr, we would need db.o to depend on db_bootstrap.h in a different subdir, which automake can't do well. Change-Id: Ic912fe27f545b85443c5fb713d8c3c8aac23c9ad
2019-11-12hlr db schema 3: hlr_number -> msc_numberNeels Hofmeyr1-10/+10
The osmo-hlr DB schema indicates a hlr_number column and references it as 3GPP TS 23.008 chapter 2.4.6. However, chapter 2.4.6 refers to the "MSC number", while the "HLR number" is chapter 2.4.7. Taking a closer look, 2.4.6 says "The MSC number is [...] stored in the HLR", while 2.4.7 says "The HLR number may be stored in the VLR". As quite obvious, the HLR does not store the HLR number. This was a typo from the start. The osmo-hlr code base so far does not use the hlr_number column at all, so we get away with renaming the column without any effects on the code base. However, let's rather make this a new schema version to be safe. Change-Id: I527e8627b24b79f3e9eec32675c7f5a3a6d25440
2019-11-12tests/db_upgrade: disable for old sqlite versionsOliver Smith1-0/+3
Skip the test if the installed sqlite version is older than 3.16.2 (current version of debian 9). This prevents test failures caused by the way we dump tables in the test, which does not work with older versions. This patch is a middle ground between reverting the db upgrade patch, and spending lots of time to replace the table dumping code with something that works with old sqlite versions to fix current build failures in OBS. Usually version checking is done in configure.ac, however I could not find a good way to pass the result to testsuite.at. So I decided to use pkg-config to do the test there. Fixes: 5b65461d686327ead0cb2a6d8493dfa9173d376c ("add db_upgrade test") Related: https://lists.osmocom.org/pipermail/openbsc/2019-November/013063.html Change-Id: I348c133003a95badbd6807d1519aa669115872fb
2019-10-31add db_upgrade testNeels Hofmeyr10-0/+416
We have a database schema upgrade path, but so far nothing that verifies that we don't break it. It almost seems like the user data weren't important to us!? Add a db upgrade test: - Create a db with an .sql dump taken from a db created with an old osmo-hlr, producing DB schema version 0. - Run osmo-hlr --db-upgrade --db-check - Verify that the upgrade exited successfully. - Verify that restarting with the upgraded DB works. If python tests are enabled, also: - create a new database using the new osmo-hlr (just built). - replay a VTY transcript to create subscribers as in the old snapshot. - replay some sql modifications as done in the old snapshot. - Get a list of sorted table names, - a list of their sorted columns with all their properties, - and dump the table contents in a column- and value-sorted way. - Compare the resulting dumps and error if there are any diffs. (This is how I found the difference in the imei column that was fixed in I68a00014a3d603fcba8781470bc5285f78b538d0) Change-Id: I0961bab0e17cfde5b030576c5bc243c2b51d9dc4
2019-10-08tests/test_nodes.vty: check less libosmocore cmdsOliver Smith1-24/+4
Use three dots to avoid checking for exact commands between help and exit, which originate from libosmocore. This avoids test failues when we slightly change the commands, like the change from "write file" to "write file [PATH]" in [1] that is currently causing the vty tests to fail. [1] libosmocore I38edcf902a08b6bd0ebb9aa6fc1a7041421af525 Change-Id: I4a964b86195141e5a50705425206f3602f908999
2019-08-13tests: Fix db_test err file to expect error code name instead of valuePau Espin Pedrol1-1/+1
Previous commit changed db_test to output code names to fix issues on some platforms (I guess due to different error code values), but somehow this log line was not updated. Fixes: 8b860e54be3dbb6587611a9d61f6d28b4c825697 Change-Id: I598de6f83a86d528174d3d188596314572f5d70d
2019-08-12Fix test for return codes on mipsel and alpha archsRuben Undheim2-17/+27
Change-Id: Ia64f1d9f39fe2b1fb704f7b6c4d9cce93ab708cd
2019-07-30src/db.c: integrate SQLite3 with talloc allocatorVadim Yanitskiy1-0/+4
This change introduces an optional feature that allows to make SQLite3 use talloc for all internal allocations. This would facilitate finding memleaks. OsmoHLR needs to be configured with '--enable-sqlite-talloc'. full talloc report on 'OsmoHLR' (total 292168 bytes in 449 blocks) struct osmo_gsup_server contains 162 bytes in 3 blocks (ref 0) ... struct db_context contains 288407 bytes in 420 blocks (ref 0) hlr.db contains 7 bytes in 1 blocks (ref 0) SQLite3 contains 288192 bytes in 418 blocks (ref 0) db.c:95 contains 48 bytes in 1 blocks (ref 0) db.c:95 contains 2 bytes in 1 blocks (ref 0) ... Unfortunately, old SQLite3 versions (such as 3.8.2) run out of memory when trying to initialize a new database: DDB ERROR db.c:88 (7) statement aborts at 3: [] DDB ERROR db.c:420 Unable to set Write-Ahead Logging: out of memory DDB ERROR db.c:88 (7) statement aborts at 3: [] DDB ERROR db.c:238 Unable to prepare SQL statement 'SELECT name FROM sqlite_master WHERE type='table' AND name=?' ... I've noticed a huge difference in heap usage footprint compared to generic malloc. At the same time, the recent versions (at least 3.24.0), work just fine. Change-Id: Icfe67ed0f063b63e6794f9516da3003d01cf20a7
2019-07-30tests/db_test: close the database when test is finishedVadim Yanitskiy1-0/+1
Change-Id: I96fedf9181e89e4d68815b04f494a9c2ecc0e057
2019-07-30build: fix mess with 'db_test_SOURCES' and 'db_test_LDADD'Vadim Yanitskiy1-4/+4
Somehow both 'db_test_SOURCES' and 'db_test_LDADD' ended up in 'src/Makefile.am'. This causes automake / autoconf to complain. Let's get rid of both useless declarations. Furthermore, the actual 'db_test_LDADD' in 'tests/Makefile.am' contained references to the source files from '$(top_srcdir)'. Most likely, the original intention was to depend on the object files in '$(top_builddir)'. Let's also fix this. Change-Id: Ib2e436ed91d9b7551dc5b205329d468c2b0ced04
2019-07-25db_auc.c: verify hex key sizes read from DBOliver Smith2-0/+161
Replace commented out size check for Ki with a real check, and use it consistently for Ki, K, OP and OPC. Add a test that sets all keys to the wrong size and tries to read them. Related: OS#2565 Change-Id: Ib8e8e9394fb65c6e7932ce9f8bebc321b99f7696
2019-07-15VTY: add subscriber update network-access-modeOliver Smith1-4/+38
Allow updating the NAM (Network Access Mode) of subscribers with the VTY. This is important for the subscriber create on demand use case where subscribers get created without access to PS and CS NAM by default. Regenerate hlr_vty_reference.xml. Related: OS#2542 Change-Id: I231e03219355ebe6467d62ae2e40bef9d8303e3b
2019-06-04db_hlr: zero-initialize "struct tm"Oliver Smith1-3/+1
The last LU time gets read from the database as string, parsed with strptime to "struct tm", and then gets converted to time_t with mktime. A recent behavior change in glibc's mktime implementation unconvered, that we don't have tm.tm_isdst (daylight saving time) set properly. As "struct tm" was not initialized, and strptime did not write to tm_isdst, it was set to a random value. When it was not 0, db_test failed on UTC systems with a more recent glibc (e.g. Ubuntu 19.04). Fix this by zero-initializing "struct tm" and remove the previous workaround that made db_test pass on UTC systems. Related: OS#4026 Change-Id: Iebbbe42fc5cd43324206d9433ede67b39251389c
2019-06-03db_test: set timezone to work around mktime bugOliver Smith1-1/+3
Apply workaround for db_test failure on ubuntu 19.04 in OBS. When the timezone is set to UTC (default in OBS), and the glibc version is 2.29, the test case is failing sometimes (not always) with the following errors in the test log: DAUC Cannot convert LU timestamp '2019-05-26 03:05:03' to time_t: Value too large for defined Force the timezone to be CET when running the test, so it passes again. I found this workaround in a Fedora bugreport [1], and tested with an ubuntu 19.04 system running in docker, that setting the environment variable like this makes the test pass 25 times in a row. Without it, it fails every two or three times. Then I verified in my OBS namespace, that the test also passes in OBS again. [1] https://bugzilla.redhat.com/show_bug.cgi?id=1653340 Related: OS#4026 Change-Id: Ic8080ba1914bb364169ab0c563b132a4ab9a9aab
2019-05-19Create subscribers on demandOliver Smith2-0/+45
Add a new vty option and allow to optionally generate a random msisdn, as well as setting the default NAM: subscriber-create-on-demand (no-msisdn|<3-15>) (none|cs|ps|both) Thanks to Vadim for the random MSISDN patch [1], which was squashed into this one. [1] Change-Id: I475c71f9902950fa7498855a616e1ec231fad6ac Depends on: Idc74f4d94ad44b9fc1b6d43178f5f33d551ebfb1 (libosmocore) Change-Id: I0c9fe93f5c24b5e9fefb513c4d049fb7ebd47ecd Related: OS#2542
2019-05-13db_hlr.c: add db_subscr_exists_by_msisdn()Vadim Yanitskiy2-0/+12
Check if a subscriber exists without generating an error log entry if it does not. This is cheaper than db_subscr_get_by_msisdn(), as it does not fetch the subscriber entry. subscriber-create-on-demand will use this function to generate a random unique MSISDN for new subscribers. Related: OS#2542 Change-Id: Ibfbc408c966197682ba2b12d166ade4bfeb7abc2
2019-05-13db_hlr.c: add db_subscr_exists_by_imsi()Oliver Smith2-0/+11
Check if a subscriber exists without generating an error log entry if it does not. This is cheaper than db_subscr_get_by_imsi(), as it does not fetch the subscriber entry. subscriber-create-on-demand will use this function. Related: OS#2542 Change-Id: I63818c0dd4fd22b41dadeeba2a07a651b5454c54
2019-05-13db_hlr.c: db_subscr_create(): add flags argumentOliver Smith2-32/+86
Allow creating new subscribers without giving them access to CS or PS. This will be used by the create-subscriber-on-demand feature. Related: OS#2542 Change-Id: I1a6dd85387723dab5487c53b33d2d9ec6d05d006
2019-05-08osmo-hlr: allow configuring db path from cfg fileNeels Hofmeyr1-0/+2
So far, the cmdline argument was the only way to set a database config file. Add a similar config to VTY as 'hlr' / 'database'. The cmdline arg is stronger than the 'database' cfg item. DB is not reloaded from VTY command. Change-Id: I87b8673324e1e6225afb758fb4963ff3279ea3d8
2019-03-19tests: use -no-install libtool flag to avoid ./lt-* scriptsOliver Smith4-0/+7
This ensures that the rpath of the generated binaries is set to use only the just-compiled so-files and not any system-wide installed libraries while avoiding the ugly shell script wrapper. Change-Id: I927561289b17b313d52fb5c1da55e237fc1d33be
2019-02-18Enable statsd supportMax1-0/+4
Change-Id: I00b8aa4e59028a4c1098a3bae034e8d8ddfbe681
2019-01-24VTY: integrate IMEIOliver Smith3-13/+79
Display the IMEI in "subscriber ... show", allow showing and modifying subscribers by their IMEI with: "subscriber imei ...". For debug purposes (and to have proper VTY tests), make it possible to change the IMEI with "subscriber ... update imei". IMEIs are saved in the database without the 15th checksum number. When the checksum gets passed, verify it and cut it off. Related: OS#2541 Depends: I02b54cf01a674a1911c5c897fbec02240f88b521 (libosmocore) Change-Id: I1af7b573ca2a1cb22497052665012d9c1acf3b30
2019-01-24VTY tests: fill DB before running testOliver Smith3-60/+65
Create a test_subscriber.vty.sql file with a dummy entry that has the ID 100. All entries created in test_subscriber.vty have an ID > 100 now. This will be used in follow-up commit [1] to create a database entry with an invalid IMEI value to test the related error handling code path (that entry could not be created through the VTY). [1]: change-id I1af7b573ca2a1cb22497052665012d9c1acf3b30 "VTY: integrate IMEI" Related: OS#3733 Change-Id: I48a3a503d7ca96798e2d5f70429b5fc36393420e
2019-01-24Optionally store IMEI in subscriber tableOliver Smith1-0/+4
Add VTY config option "store-imei". When it is set, store the IMEI sent from the VLR with CHECK-IMEI in the database. Related: OS#2541 Change-Id: I09274ecbed64224f7ae305e09ede773931da2a57
2019-01-24Add IMEI column to subscriber tableOliver Smith2-0/+66
Extend the database scheme, add imei to the hlr_subscriber struct and create db_subscr_update_imei_by_imsi() and db_subscr_get_by_imei(). The new functions are used in db_test, and in follow-up commits [1], [2]. Upgrade DB schema to version 2. SQLite can only insert new columns at the end of the table, so this happens when upgrading the database. In new databases, the column is placed after the IMEISV column (where it makes more sense in my opinion). This should not have any effect, as we never rely on the order of the columns in the tables. Follow-up commit [1] will make use of this column to save the IMEI as received from the MSC/VLR with the Check-IMEI Procedure. It was decided to use Check-IMEI instead of the recent Automatic Device Detection Procedure (which would send the IMEISV) in OS#3733, because with Check-IMEI we don't need to rely on very recent releases of the specification. [1] change-id I09274ecbed64224f7ae305e09ede773931da2a57 "Optionally store IMEI in subscriber table" [2] change-id I1af7b573ca2a1cb22497052665012d9c1acf3b30 "VTY: integrate IMEI" Depends: Id2d2a3a93b033bafc74c62e15297034bf4aafe61 (libosmocore) Related: OS#2541 Change-Id: If232c80bea35d5c6864b889ae92d477eeaa3f45d
2018-12-05SS/USSD: make NCSS session timeout configurableVadim Yanitskiy1-0/+1
It may happen that either the MS or an ESME would become unresponsive, e.g. due to a bug, or a dropped message. This is why we have SS session timeout, that prevents keeping 'stalled' sessions forever. Let's introduce a VTY option, which can be used to configure this timer (by default it's set to 30 seconds): hlr ... ! Use 0 to disable this timer ncss-guard-timeout 30 Change-Id: I971fc2cee6fd46d4d5d6dac6c634e0b22fff183d Related: OS#3717
2018-12-04add database schema versioning to the HLR databaseStefan Sperling1-1/+1
Make use of pragma user_version to store our database schema version. The present schema is now identitifed as 'version 0', which is also the default value for databases on which we never ran the statement 'pragma user_version' before. Only bootstrap the database if it hasn't been bootstrapped yet. Previously, bootstrap SQL statements ran every time osmo-hlr opened the database, and any errors were being ignored in SQL. Instead, we now first run a query which checks whether tables already exist, and only create them if necessary. This change will allow future schema updates to work properly. Prepare for future schema upgrades by adding a new command-line option which enables upgrades. This option defaults to 'false' in order to avoid accidental upgrades. Change-Id: I8aeaa9a404b622657cbc7138106f38aa6ad8d01b Related: OS#2838
2018-12-02implement removal of MSISDNNeels Hofmeyr1-1/+20
Add the first "official" way to remove the MSISDN from a subscriber entry, to go back to 'MSISDN: none' like just after 'subscriber create'. Add VTY command 'subscriber <ID> update msisdn none' to drop the MSISDN from the subscriber. (Like 'subscriber <ID> update aud3g none') Add DB_STMT_DELETE_MSISDN_BY_IMSI. In db_subscr_update_msisdn_by_imsi(), allow passing a NULL msisdn, and if NULL, call above delete SQL statement. Change-Id: I15419105ea461137776adb92d384d8985210c90e
2018-12-02add 'show subscriber' command, alias for 'subscriber ... show'Neels Hofmeyr2-0/+9
When I wrote the osmo-hlr subscriber command, I failed to heed the common 'show foo' scheme and instead created a 'subscriber [...] show' command. Relieve that weirdness by creating an alias that has 'show' at the start. Arrange string macros so that the 'show subscriber' cmd doesn't end in a space (the SUBSCR macro ends in a space ' ' to implicitly include the space to commands like 'create', 'show', 'update'). Add the new command to test_nodes.vty and test_subscriber.vty. Change-Id: I01ce9b0868302d40ed05c6a588316a194d6071e4
2018-09-26fix VTY tests to expect well-formed output of logging configurationHarald Welte1-4/+4
In libosmocore Change-Id Ia75c7067284ea225cffe13ca71bad05a7747ae66 we fixed the generation (saving) of logging configuration to use one level of indent, rather than the previous broken implementation with two levels of indent. This means we have to adjust the VTY test expectations here. Change-Id: I9282a59bbfad4cfc86e86c1212c74cccfe187ff8
2018-09-18make: always allow running python tests manuallyNeels Hofmeyr1-5/+4
Keep the rules to run the external-tests in tests/Makefile available for invocation, to allow conveniently launching the tests manualy without the need to pass --with-external-tests to ./configure first. Change-Id: Ic28dbeabddee6b41af12b977e3fe59e663ee51a1
2018-09-18tweak example configNeels Hofmeyr1-0/+1
Remove 'logging level all' setting. Tweak some more logging details (to my current favorite). Add USSD example for showing the IMSI. Change-Id: I8296832704d779df5f1b20a595b568c99780e64d
2018-09-13fix build: adjust test_nodes.vty to logging changeNeels Hofmeyr1-12/+1
Since libosmocore commit eb9284ba577d338f74653fcf09ebca0c397823eb Change-Id I36f17c131cc70ce5a1aef62fd9693097de230cd4 "logging vty: deprecate 'all', introduce 'force-all'" , 'logging level all' is replaced by 'force-all'. Adjust the test script to not expect 'logging level all'. While at it, remove some more expectations that aren't important. Change-Id: Ia170f8416ebb60c499d2536078f43f28b61d0554
2018-07-30tests/Makefile.am: also remove temporary sqlite filesVadim Yanitskiy1-0/+2
The osmo_verify_transcript_*.py do terminate the osmo-hlr process in some unusual way, so the database file is not closed properly. Let's remove temporary files after the tests execution. Change-Id: I9e4c98e86c1d6b627bfee1acb4fa116460687483
2018-07-30USSD: Add support for internal USSD handlersHarald Welte1-0/+6
There are some requests that are best served inside the HLR, as it has access to subscriber information such as MSISDN and IMSI. This unfortunately required quite some restructuring of the USSD related structures including the VTY syntax for adding routes. The default config file has been updated to replicate the *#100# built-in behavior of old OsmoNITB. Closes: OS#2566 Change-Id: I1d09fab810a6bb9ab02904de72dbc9e8a414f9f9
2018-07-30USSD: Add new "DSS" logging category and use it appropriatelyHarald Welte1-0/+1
Change-Id: I0ac198a49ba70ea40fea18464325f1925797a6e8
2018-07-30osmo-hlr.cfg: Don't enable DEBUG logging by defaultHarald Welte1-1/+1
This is not a setting that normal users should use in production. Change-Id: I6594fb083cad70ec596af872d85f805897b29644
2018-07-30USSD: Add Core USSD handling + VTY routing config to HLRHarald Welte1-0/+2
Change-Id: I3cfd7cd401ea32b7e92f1124d129099d9f7dc6e6
2018-06-24Add "show gsup-connections" VTY commandHarald Welte1-0/+1
This can help with debugging and give operational insight. Change-Id: I977b4b8cdb36dab42b3d736a28d8b5f17cff04cd
2018-05-18move creation of insert subscriber data messages to a common functionStefan Sperling1-1/+1
Move code to create an Insert Subscriber Data message into a common function which can be shared by hlr.c and luop.c. As a consequence, we always encode gsup.cn_domain in the corresponding msgb and must adjust expected output of the 'gsup' test accordingly. Change-Id: I6a92ca34cdaadca9eacc774bb1ca386c325ba865 Requested-by: neels Related: OS#2785
2018-05-04add gsup_test to catch OS#3231Neels Hofmeyr6-0/+143
Encode an Insert Subscr Data with is_ps == true to trigger the encoding bug described in OS#3231, i.e. show that it is fixed. Move osmo_gsup_addr_send() to a separate .c file, so that it can be overridden in the regression test to just dump the msgb instead. I used this test to reproduce issue OS#3231, and now that it's here we might as well keep it, and possibly expand on it in the future. Related: OS#3231 Change-Id: Id1453351758f3e1a9ff03bd99fefaf51886e77da
2018-04-17use osmo_init_logging2Pau Espin Pedrol3-3/+8
Change-Id: If4449cce1af46be22cc370abd3a6da8e22a31fa5
2018-02-14osmo-hlr: Add talloc context introspection via VTYHarald Welte1-0/+3
This requires libosmocore with Change-Id I43fc42880b22294d83c565ae600ac65e4f38b30d or later. Change-Id: Ibc2c333b83f85fa69a364e3e342f12f50dbc2f70
2018-02-09Fix expected test output after new 'logging print file 1' vty commandHarald Welte1-0/+1
Ever since libosmocore Change-Id I1c931bff1f1723aa82bead9dfe548e4cc5b685e0 was merged, the VTY tests were broken. Let's fix that by adjusting the expected test output. Change-Id: I929ca7f366220b5d1238d43eddc96fa9dde916b6