ops-scenario is hook-tool-complete!

Hi there! Just a quick party-worthy notice for you charm testers: ops-scenario 5.5 is hook-tool-complete!

This means that all the hook tools that a charm can invoke through ops are mocked by scenario and wrapped by its State construct. You can now declaratively build a State consisting of storage, containers (with their filesystems, pebble layers, exec return codes etc…), relations, networks, juju config, app and unit status, deferred events, stored state, and so on, and use that as backdrop to simulate a charm run (or a juju-cli-initiated action run).

Starting now, the only things you should need to magicmock your way out of will be:

  • system calls (Popen…)
  • pebble signals (that is still on the todo list)
  • substrate API calls (e.g. lightkube calls)

The rest of what a charm can do should, in principle, be wrapped by Scenario.

This doesn’t mean you should never mock anything that is covered by Scenario’s State: sometimes it is wise to still do that, in order to reduce the test surface and make sure you’re not testing ‘too much’ code.

Also, here’s a neat new diagram explaining what model of a charm’s runtime Scenario captures: image


1 Like