axcxl / overwatcher

Ultra-lightweight automated testing framework for CLIs.
MIT License
0 stars 0 forks source link

overwatcher

Ultra-lightweight automated testing framework for CLIs.

Design ideas:

Current state:

The future:

Anatomy of a test

The basic idea: the test defines a list of states (markers) and actions that have to be run. This list is walked on element by element: when a state is the next element, overwatcher waits for the marker that describes that state, when an action/modifier is the next element, it just runs that action/modifier. If overwatcher is looking for one state and a different one is seen, the test fails.

  1. TEST INFORMATION This "header" contains a full test description and it is dumped in the test log, so more stuff can be easily added. There are two mandatory fields: 'version' (which needs to be kept in a reverse order - only the first one is dumped in the log) and 'overwatcher revision required' (this is still WIP, but it should have the format in the example. If the framework revision does not match this field, there will be a warning when starting the test). The 'serial only' field can be added and will generate a warning when tests are run over telnet; if it is not present, it is assumed to be False.
  2. MARKERS These are text elements that overwatcher pays attention to. Can be used to trigger actions immediatly when seen (example: see User -> send username) or to define the actual test flow. Be careful when choosing a marker, as the test fails if the marker found does not match the one expected during the test run. There are two exceptions to this rule: markers that have only MODIFIERS in their triggers and prompts (see below). The first exception was introduced to be able to do some small tasks (ex: count a string that appears from time to time). Prompts are consumed by running actions.
  3. PROMPTS Thse are string that are expected after a command is sent to the device. Why? Because we might run into commands that take a while to run and the test should not keep pushing stuff to the device while it is blocked. For now, this is not blocking; if the prompt is not seen in a while, overwatcher tries to send a CR (only on serial); if the prompt still does not appear, it tries to continue the test (the timeout will stop it anyway if the device is blocked)
  4. TRIGGERS Triggers are automatic actions that are run when a marker is seen. These actions can include sending device commands or setting modifiers. Please note that these triggers do not take into account the test flow...if a marker appears, they are just run. Also triggers do not wait for prompts, the elements are sent with a small delay. NOTE: triggers can contain modifiers. There are critical modifiers which are run even if triggers are disabled (see below).
  5. ACTIONS Actions are commands that will be run during the test flow. Unlike triggers, they are not automatic, they need to be added to the test flow below to be run. After each element of the list of actions is run, overwatcher waits for a prompt before sending the next one. NOTE: actions can contain modifiers.
  6. INITIAL CONFIGURATION This is a sequence identical to the test, but it is only run once when starting the test. It can be used to do some initial sets. The recommanded way to start this is with a marker for a known state...the config blocks until it reaches that state (either via triggers or manually) and then it runs the configuration actions from a known state. There is a watchdog in effect while doing the config...if it take too long, the test fails. The timeout value is configurable.
  7. TEST This is a series of markers, actions and modifiers that are expected and run in the given order. The actual test can be single run (go through it and stop) or infinite (run forever). Take this into account and use the configuration sequence above for initial configuration. To further enhance the functionality you can use the modifiers below. The same watchdog is in effect while running the test. It is reset after passing to a new state. The timeout value is configurable.

Modifiers

These are a sort of "special actions" which control and change the test flow or run special actions (like couting stuff).

Configurable test options

These are just parameters that control the inner workings of the test: