Skip to content

Files

Latest commit

697ef11 · Jan 14, 2021

History

History
This branch is 3 commits ahead of, 1566 commits behind lttng/lttng-tools:master.

tests

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Nov 27, 2020
Nov 27, 2020
Jan 14, 2021
Aug 11, 2020
Jan 12, 2021
Jan 13, 2021
Jan 31, 2020
Nov 26, 2014
Jan 14, 2020
Feb 28, 2020
Nov 10, 2016
Mar 15, 2016
Oct 23, 2019
Jan 31, 2020
Jan 14, 2016
* Test Anti-Patterns

OK, there are a few patterns that have been found over and over in the
testing code base which makes the tests flaky. Here is an incomplete
list. Don't do that.

1) Using pidof to wait for a background application (by name) to
   disappear.

   Why is it flaky ?

   The application may be delayed after being forked, but not executed
   yet. Therefore, pidof will not find it. Use "wait" instead.

2) Using sleep as delay-based optimistic synchronization technique.

   Why is it flaky ?

   Everything that needs to happen before/after other things need to
   be explicitly synchronized using e.g. a file (used as a flag).
   Sleep is just an indicator of a minimum arbitrary delay, but
   machine load and scheduling can actually mess up the real delay
   between applications. Use explicit synchronization points. Never
   sleep.

3) Using killall on a background application.

   Why is it flaky ?

   Similarly to pidof, killall may run before the background application
   executes, thus failing to find it. Store the application PID after it
   it launched in background into a temporary variable for later use
   by kill and wait.

4) Using wait ${!} to wait for completion of many background
   applications.

   Why is it flaky ?

   It just waits for the last application put in background. Use
   "wait" to wait for all background applications.

5) Forgetting wait at the end (or error return path) of a test phase
   that has background applications.

   Why is it flaky ?

   Those application may interact with the following testing phases,
   thus skewing the results.

6) Not grepping into the entire code base for similar patterns.

   When you find a problematic coding pattern, chances are it appears
   elsewhere in the testing code base. Please fix it everywhere!

7) Introducing a utility abstraction without changing all open coded
   similar code path.

   When an abstraction for e.g. starting and stopping the session daemon
   is introduced as a utility (e.g. utils.sh), future changes will
   assume that all the testing code base is using this abstraction.
   Leaving a few custom open-coded sites of duplicated code around is a
   good way to make it a pain to update the abstraction in the future.