Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for testing pebble services interaction #34

Closed
ghislainbourgeois opened this issue May 31, 2023 · 5 comments
Closed

Add support for testing pebble services interaction #34

ghislainbourgeois opened this issue May 31, 2023 · 5 comments
Labels
big brain issue that requires some (complex) spec/design work enhancement New feature or request good first issue Good for newcomers

Comments

@ghislainbourgeois
Copy link
Contributor

There is currently no way in ops-scenario 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
@PietroPasotti
Copy link
Collaborator

I'm hesitant to patch extra names into Container.services because at the moment scenario is using 'native' ops.pebble data structures internally, (Plan, ServiceInfo, etc...) so it'd be unexpected to have a different api in different contexts, when the objects are the same.
We could add something to Container:

assert state_out.containers[0].restarted('ausf')
assert state_out.containers[0].replanned
assert state_out.containers[0].sent_signals == ((9, "ausf", "foo"), ("SIGKILL", "bar-server"))

@benhoyt WDYT?

@PietroPasotti
Copy link
Collaborator

PS in light of #37, probably this kind of container-facing output mocks should end up in scenario.outputs as they are not quite persisted in the state.
Much like juju-log and action results.

@PietroPasotti PietroPasotti added enhancement New feature or request good first issue Good for newcomers big brain issue that requires some (complex) spec/design work labels Nov 9, 2023
@PietroPasotti
Copy link
Collaborator

@tonyandrewmeyer perhaps now we're using our own data structures instead of importing them from ops, this becomes more easy to implement in a clean way?
will draft something on top of v7 as soon as we release it

@dimaqq
Copy link
Collaborator

dimaqq commented Oct 2, 2024

You're thinking that the library would offer a ready mock that mirrors the live API, and has some recording functionality. Is that right?

@tonyandrewmeyer
Copy link
Collaborator

Moved to canonical/operator#1427

@tonyandrewmeyer tonyandrewmeyer closed this as not planned Won't fix, can't repro, duplicate, stale Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
big brain issue that requires some (complex) spec/design work enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants