Commit Graph

32 Commits

Author SHA1 Message Date
Neels Hofmeyr 1e01a68846 add option osmo-gsm-tester.py --suites-file my-suites-listing.conf
For example, run with '-S handover-suites.conf' to just do the handover
tests.

Change-Id: If896ac84d02a275deda2f20a93c29312df128ebb
2020-12-11 00:41:17 +01:00
Pau Espin e972c9c524 config: Allow setting trial directory in main.conf
Change-Id: Ia4141001d084f690897dbdff5eae6c69ff2e521c
2020-05-12 16:27:33 +02:00
Pau Espin 6c6c0e8599 Cmdline arg -c sets main configuration file (old paths.conf) instead of dir containing it
It has been notified that current configuration system is difficult to
understand and to use, so it has been envisioned to refactor it a bit.
The idea is that the user passes a -c path/to/main.conf file, which in
turn contains whatever osmo-gsm-tester main settings supports (basically
what old paths.conf used to be, plus some files harcoded to the same -c
directory are now configurable through the main configuration file).

Change-Id: Ieca65b71b543c44cfcec8e83efd0fe053c432e55
2020-05-12 14:07:29 +02:00
Pau Espin 0bd048c620 osmo-gsm-tester.py: Update help description and remove old nope cmdline arg
Change-Id: I879a5c30c185905614c2c5a7d54eb33817c94c31
2020-05-07 19:38:37 +02:00
Pau Espin 06c82aee5c Deprecate envvar OSMO_GSM_TESTER_CONF and remove other ones
Environment variable OSMO_GSM_TESTER_CONF is marked as deprecated and an
error is logged each time it's used. Same feature is available through
"-c" command line parameters, so having the envvar only makes things
more complex for no good reason. It cannot yet be completely dropped
since some environemnt still make use of it. Give some time to users to
adapt their setups.
Other environment variables setting some config apths can be dropped
since they are not being really used in any setup.

Change-Id: I7eb69f870d0dcb5906d45ae067d6bed1aabf5862
2020-05-07 19:09:23 +02:00
Pau Espin 0dd4c0be10 osmo-gsm-tester.py: Fix import error when using default-suites.conf
Recent commit refactoring stuff introduced an import error only
triggered when default-suites.conf is used (no -s param).
This commit fixes the issue.

Fixes: ea8c3d4b12
Change-Id: I1534cfba55c69ed5c1354175f8b5df9b656b7d82
2020-05-06 14:04:24 +02:00
Pau Espin f574a46b37 Move trial.py and suite.py to core/
Change-Id: Ic9a4c90c190e9d8e1829fbef83a9243f3c6f655b
2020-05-05 12:23:37 +02:00
Pau Espin ea8c3d4b12 Generate schemas dynamically from pieces provided by each object class
This way we benefit from:
* knowing which attributes are used/required by each object class and
  subclass
* Having validation function definitions near the class going to use them

Change-Id: I8fd6773c51d19405a585977af4ed72cad2b21db1
2020-05-04 16:36:33 +02:00
Pau Espin e8bbcbf5b8 Create core directory to contain most of code not in object classes used by tests
Change-Id: I9aec6c55ccd71894182057d36e0025b69925d314
2020-04-11 19:15:53 +02:00
Neels Hofmeyr 42bebface8 add cmdline option -R to add src file log to stdout
Change-Id: I5b21ec30453dceb53e7d4cc972607971935ef10f
2017-06-22 06:43:04 +00:00
Neels Hofmeyr 6ccda11a98 refactor: fix error handling; fix log.Origin; only one trial
A bit of refactoring to fix logging and error reporting, and simplify the code.
This transmogrifies some of the things committed in
0ffb414406 "Add JUnit XML reports; refactor test
reporting", which did not fully match the code structuring ideas used in
osmo-gsm-tester. Also solve some problems present from the start of the code
base.

Though this is a bit of a code bomb, it would take a lot of time to separate
this into smaller bits: these changes are closely related and resulted
incrementally from testing error handling and logging details. I hope it's ok.

Things changed / problems fixed:

Allow only a single trial to be run per cmdline invocation: unbloat trial and
suite invocation in osmo-gsm-tester.py.

There is a SuiteDefinition, intended to be immutable, and a mutable SuiteRun.
SuiteDefinition had a list of tests, which was modified by the SuiteRun to
record test results. Instead, have only the test basenames in the
SuiteDefinition and create a new set of Test() instances for each SuiteRun, to
ensure that no state leaks between separate suite runs.

State leaking across runs can be seen in
http://jenkins.osmocom.org/jenkins/view/osmo-gsm-tester/job/osmo-gsm-tester_run/453/
where an earlier sms test for sysmo succeeds, but its state gets overwritten by
the later sms test for trx that fails. The end result is that both tests
failed, although the first run was successful.

Fix a problem with Origin: log.Origin allowed to be __enter__ed more than once,
skipping the second entry. The problem there is that we'd still __exit__ twice
or more, popping the Origin off the stack even though it should still remain.
We could count __enter__ recurrences, but instead, completely disallow entering
a second time.

A code path should have one 'with' statement per object, at pivotal points like
run_suites or run_tests. Individual utility functions should not do 'with' on a
central object. The structure needed is, in pseudo code:

  try:
    with trial:
      try:
        with suite_run:
	  try:
	    with test:
	      test_actions()

The 'with' needs to be inside the 'try', so that the exception can be handled
in __exit__ before it reaches the exception logging.

To clarify this, like test exceptions caught in Test.run(), also move suite
exception handling from Trial into SuiteRun.run_tests(). There are 'with self'
in Test.run() and SuiteRun.run_tests(), which are well placed, because these
are pivotal points in the main code path.

Log output: clearly separate logging of distinct suites and test scripts, by
adding more large_separator() calls at the start of each test. Place these
separator calls in more logical places. Add separator size and spacing args.

Log output: print tracebacks only once, for the test script where they happen.

Have less state that duplicates other state: drop SuiteRun.test_failed_ctr and
suite.test_skipped_ctr, instead add SuiteRun.count_test_results().

For test failure reporting, store the traceback text in a separate member var.

In the text report, apply above changes and unclutter to achieve a brief and
easy to read result overview: print less filler characters, drop the starting
times, drop the tracebacks. This can be found in the individual test logs.
Because the tracebacks are no longer in the text report, the suite_test.py can
just print the reports and expect that output instead of asserting individual
contents.

In the text report, print duration in precision of .1 seconds.

Add origin information and a traceback text to the junit XML result to give
more context when browsing the result XML. For 'AssertionError', add the source
line of where the assertion hit.

Drop the explicit Failure exception. We don't need one specific exception to
mark a failure, instead any arbitrary exception is treated as a failure. Use
the exception's class name as fail_type.

Though my original idea was to use raising exceptions as the only way to cause
a test failure, I'm keeping the set_fail() function as an alternative way,
because it allows test specific cleanup and may come in handy later. To have
both ways integrate seamlessly, shift some result setting into 'finally'
clauses and make sure higher levels (suite, trial) count the contained items'
stati.

Minor tweak: write the 'pass' and 'skip' reports in lower case so that the
'FAIL' stands out.

Minor tweak: pass the return code that the program exit should return further
outward, so that the exit(1) call does not cause a SystemExit exception to be
logged.

The aims of this patch are:
- Logs are readable so that it is clear which logging belongs to which test and
  suite.
- The logging origins are correct (vs. parents gone missing as previously)
- A single test error does not cause following tests or suites to be skipped.
- An exception "above" Exception, i.e. SystemExit and the like, *does*
  immediately abort all tests and suites, and the results for tests that were
  not run are reported as "unknown" (rather than skipped on purpose):
  - Raising a SystemExit aborts all.
  - Hitting ctrl-c aborts all.
- The resulting summary in the log is brief and readable.

Change-Id: Ibf0846d457cab26f54c25e6906a8bb304724e2d8
2017-06-09 00:35:20 +02:00
Neels Hofmeyr f15eaf95de add cmdline arg to set conf dir
Add -c cmdline option to do the same as / in addition to the
OSMO_GSM_TESTER_CONF var, because setting the var is cumbersome in daily
development.

Change-Id: I4c3b482f31f638047ab3f3d785d294b28d244b80
2017-06-06 20:00:43 +02:00
Harald Welte 2720534f27 Re-License under GPLv3-or-later instead of AGPLv3-or-later
The "Affero" nature makes sense for the Osmocom network components like
BSC, SGSN, etc. as they are typically operated to provide a network
service.

For testing, this doesn't make so much sense as it is difficult to
imagine people creating a business out of offering to run test cases on
an end-to-end Osmocom GSM network.  So let's drop the 'Affero' here.

All code is so far developed by sysmocom staff, so as Managing Director
of sysmocom I can effect such a license change unilaterally.

Change-Id: I8959c2d605854ffdc21cb29c0fe0e715685c4c05
2017-06-03 14:23:51 +00:00
Neels Hofmeyr 908faf8d1b fix log: print suite-run separator in proper place
error was introduced by 0ffb414406
'Add JUnit XML reports; refactor test reporting'

Change-Id: I9acf1a840277979a19a2019c69e4562ff7fe2ca0
2017-05-29 04:32:26 +02:00
Neels Hofmeyr 9576f5f9a5 log: change 'log_all_origins' from bool to a list of levels to apply to
The idea is to see the full origin list for log level ERR, while the rest
of the logging can be kept less verbose.

Change-Id: I0277782652548fa321f767da79b207d70678fad1
2017-05-28 22:26:23 +00:00
Pau Espin 98df394fc6 Exit with failure if not enough resources are found
Change-Id: I9e38435ff71416585a259c823053bd07c670d495
2017-05-24 12:01:07 +00:00
Pau Espin 469316fae0 Handle termination signals to exit gracefully and prevent resource leak
Make sure we free the reserved resources and kill launched subprocesses
before stopping. Before this patch it was not the case for instance if we
received a SIGTREM signal from kill.

Change-Id: I039e4d1908a04bf606b101ddc6a186ba67e6178e
2017-05-19 14:40:18 +02:00
Pau Espin 0ffb414406 Add JUnit XML reports; refactor test reporting
* Add Junit output file support
* Differentiate between an expected failure test and an error in the
test, as described in JUnit.
* In case of an error/exception during test, record and attach it to the
Test object and continue running the tests, and show it at the end
during the trial report.

Change-Id: Iedf6d912b3cce3333a187a4ac6d5c6b70fe9d5c5
2017-05-19 14:22:39 +02:00
Neels Hofmeyr e60df6961c fix name of local var, to not shadow 'suite' module
This caused "UnboundLocalError: local variable 'suite' referenced before
assignment".

Change-Id: Ic9aa383f5cdc9818c5a21b101fb6ddea4132d9fb
2017-05-15 12:23:57 +00:00
Neels Hofmeyr 2123541574 fix: exception outside of trial run should be logged and cause nonzero rc
From an earlier stage of the code, there was still an exception catcher that
makes no sense. Remove it.

Change-Id: I8085318c91b06a3e8f7d3f8cfdd15a99650666e2
2017-05-15 12:23:57 +00:00
Neels Hofmeyr 2296883fc3 log: tweak osmo-gsm-tester.py stdout: all_origins=False, src=False
Change-Id: I24a600f67f7a9f3d1235abfceb86f311ffa97746
2017-05-15 12:22:35 +00:00
Neels Hofmeyr cf0304ff26 cosmetic: cmdline help: add line breaks, fix typo
Fix typo 'patch' -> 'match'

Argparse has a peculiar way of treating the cmdline help strings. Include
explicit newlines in cmdline help, and place a comment explaining the details.

Change-Id: I34a2333c55719986b729b07386bc47314635ee04
2017-05-12 14:34:41 +02:00
Neels Hofmeyr 532126a725 log: make 32 the default origin_width.
Change-Id: I1159395251332f3b1af3b3a322e7191559105faa
2017-05-08 10:12:25 +00:00
Neels Hofmeyr f816688279 log.py: tweak LogTarget list, require explicit LogTarget
Rename log_sink to log_write_func to make it more clear.

Remember the list of log targets as static member LogTarget.all_targets.

Make each LogTarget instance register with the list of targets implicitly.

No longer create a default log target, rather create one explicitly in
osmo-gsm-tester.py.

Change-Id: I5844485eaed536cb34b44bfe23dc635fe1982dcd
2017-05-08 10:12:25 +00:00
Neels Hofmeyr f9de78fc58 improve doc and usability of osmo-gsm-tester.py -t option
Allow exact matches by prepending a '='.
Properly document the -t option.

Change-Id: I61bed7e05f0c1f08cf3de72f62d9ba6609d44aee
2017-05-08 10:12:10 +00:00
Neels Hofmeyr 930ac952aa fix osmo-gsm-tester.py -t option
Option to select test names had code rot. Use loaded suite definitions
properly.

Change-Id: I24f0a87a017f211f3a30fb98556a392f2a35be7b
2017-05-07 01:13:23 +00:00
Your Name 44af3415a5 fix octphy, fix conf, improve logging
Clearly separate the kinds of BTS hardware the GSM tester knows ('type') from
the NITB's bts/type config item ('osmobsc_bts_type' -- not 'osmonitb_...' to
stay in tune with future developments: it is the libbsc that needs this).

For BTS hardware kinds, use the full name of the binary for osmo driven models:
osmo-bts-sysmo, osmo-bts-trx, osmo-bts-octphy.

Change-Id: I1aa9b48e74013a93f9db1a34730f17717fb3b36c
2017-04-13 03:39:07 +02:00
Neels Hofmeyr e352844011 cosmetic: fix import for previous commit
Change-Id: I44eed9a449be8202cea08894bf1c428f52e2625d
2017-04-08 21:18:30 +02:00
Neels Hofmeyr 2ef9b00d51 cosmetic: flush stdout and stderr before printing summary
Change-Id: I9c7eec29c200ec90e9908457a07b79122014a0e9
2017-04-08 21:16:27 +02:00
Neels Hofmeyr ef42cb51fa osmo-gsm-tester.py: return error on failure
Change-Id: I1d2133b5a2eeaede1eb9b321aa17843ce4bd06d2
2017-04-08 19:38:58 +02:00
Your Name 3c6673aa8c various fixes from first test runs
Change-Id: Ifa5a780dc0123aa84273c57c726c8c1bea563495
2017-04-08 19:20:57 +02:00
Neels Hofmeyr d46ea13d48 review jenkins scripts
Change-Id: I420910bd2d30e96605ecf3acb779ce726c75d912
2017-04-08 18:36:13 +02:00