Skip to content

"Testing sagas" is not easy in Omicron, but it should be #1799

@smklein

Description

@smklein

Sagas are tricky to write in Nexus right now - writing them not only involves "doing all the operations you need to do", but also:

  • Ensuring that each saga action can be undone by a corresponding saga undo action
  • Ensuring that all the saga actions are idempotent
  • Ensuring that all the saga undo actions are idempotent

So, how do we test sagas today? Mostly through our integration tests, which poke at both the external Nexus API, and internally at the database. This is a pretty coarse-grained mechanism for testing -- it would be much nicer if we could (for example) inject errors directly into individually constructed sagas.

I tried pulling out some saga-constructing goop in the "disk create" saga. My goal was to create a test exercising sagas, and node failure, without requiring most of the rest of the control plane to be up-and-running. Basically, something more akin to a "unit test" than an full "nexus integration test".

The big problem? The SagaContext object we pass to all sagas in Nexus has a reference back to the Nexus struct itself. And initializing the Nexus structure requires bringing up a lot of other services, so we're in a big ball of coupled services.

It would be nice to create some better isolation between the SagaContext object and "all of Nexus" - looser coupling here would make it easier to create fine-grained tests to poke at more saga failure cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions