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 service state history #127

Closed
tonyandrewmeyer opened this issue May 24, 2024 · 2 comments
Closed

Add service state history #127

tonyandrewmeyer opened this issue May 24, 2024 · 2 comments

Comments

@tonyandrewmeyer
Copy link
Collaborator

It would be convenient to have a history of the service state, similar to the status history, so that you can do things like check for “running → restart → running”

  • Harness cannot do this either at the moment, so this would be adding another advantage to Scenario.
  • Status histories rightly belong to the context rather than the state, so this would as well.
  • Presumably, we’d want to offer some ability to control what happens in a replan or restart (and maybe other Pebble operations?) rather than just assuming that restart means “add a service state of inactive then add another one of running”.

Rough example of possible usage:

import ops
import scenario

class MyCharm(ops.CharmBase):
    def __init__(self, framework):
        super().__init__(framework)
        framework.observe(self.on.foo_pebble_ready, self._on_pebble)

    def _on_pebble(self, event):
        ...
        self.unit.get_container("foo").restart("srv")
        ...

ctx = scenario.Context(MyCharm)
container = scenario.Container(service_statuses={
    "srv": ops.pebble.ServiceStatus.ACTIVE,
})
state_in = scenario.State(containers={"foo": container})
state_out = ctx.run(ctx.on.foo_pebble_ready, state_in)
assert ctx.service_history["foo"]["srv"] == [
    ops.pebble.ServiceStatus.ACTIVE,
    ops.pebble.ServiceStatus.INACTIVE,
]
assert state_out.containers["foo"].service_status["srv"] == ops.pebble.ServiceStatus.ACTIVE
@tonyandrewmeyer
Copy link
Collaborator Author

Hmm, this might actually be a dupe of #34.

@tonyandrewmeyer
Copy link
Collaborator Author

Hmm, this might actually be a dupe of #34.

I think it's close enough that this doesn't need to stay open.

@tonyandrewmeyer tonyandrewmeyer closed this as not planned Won't fix, can't repro, duplicate, stale Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant