canonical / canonical/operator
Add support for testing pebble services interaction
- Dominant language
- Python
- Stars
- 267
- Forks
- 136
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 28
Description
There is currently no way in ops-testing to test a charm interaction with a pebble service, like restarting it for example: `self._container.restart(self._service_name)`.
The only way to accomplish this is to mock `ops.model.Container.restart`.
It would be nice to have a better way to do this, maybe as an automatic mock in the output state?
```
...
state_out = self.ctx.run(container.pebble_ready_event, state_in)
assert state_out.containers[0].services["ausf"].restarted
```
Moved from https://github.com/canonical/ops-scenario/issues/34
Contributor guide
Research direction
Start by reading the ops-testing container state handling and the interaction with ops.model.Container.restart. Trace the pebble_ready_event flow through state_in and state_out, then determine how a service restart should be represented, such as the proposed services["ausf"].restarted value. Done means charm tests can observe a restart without mocking Container.restart.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100