-
Notifications
You must be signed in to change notification settings - Fork 9
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
Support for container pebble layer defined externally #152
Comments
Can't you provide the plan as a layer in the container? Like: container = Container("gubernator", layers={"rock": pebble.Layer(...)}) The rockcraft approach is perhaps an argument that |
That may just work, let me wrap up a prototype to share here. |
Thank you, I can surely instantiate container with pebble layers. Here's what I have so far: TL;DR:
|
Yeah, that's where #34 comes in. Right now, the Scenario testing Pebble client doesn't initialise the service status dict so even though the methods are inherited they won't work, if I recall correctly. So the most straightforward solution is to just mock the restart and assert that it's called. If you really want to avoid mocks then you could do it all with the ops class, I think - before running the event do mgr.charm.unit.containers['...'].stop('...') then run it and then do mgr.charm.unit.containers['...'].get_service('...') and assert on the result. However, I'm not sure that will actually run with Scenario not initialising the internal dict. So it may be that it's Harness or mocking. |
Ugh, I had a silly bug... It turns out that I can in fact read back the container status: |
For what it's worth, if this "use the rock plan" approach is documented as a way people should make charms, then I do think |
I have this setup:
rockcraft.yaml
When juju starts a container with the image built from this rock, pebble gets this plan, and is started on hold, then charm does does:
Meanwhile in unit tests,
scenario.mocking._MockPebbleClient
has a concept of containers, but is not instantiated with the layer data.Which makes it kinda hard to test things, apart from happy path.
I wonder how to best represent this.
The text was updated successfully, but these errors were encountered: