Skip to content

Should there a be a helper that checks the status of snap/pebble services? #120

Description

@sinapah

In some integration tests, charm authors find themselves writing helpers to fetch and assert on the status of snap services. An example would be https://github.com/canonical/opentelemetry-collector-operator/blob/9fa23d2d2dcd14e21966c3f3b784492cc9ae969d/tests/integration/helpers.py#L49-L60

I wonder if it makes sense to add two helper methods for checking the status of a snap or pebble service.

The first helper would have a signature roughly like this:

def check_snap_status(                                                                                                                                                          
         self,                                                                                                                                                                       
         app: str,                                                                                                                                                                   
         snap: str,                                                                                                                                                                  
         unit_num: int = 0,                                                                                                                                                          
     ) -> str:

Its usage would be something like:

import jubilant
...
assert jubilant.check_snap_status("otelcol", "opentelemetry-collector", 1) == "active"

Along the same lines, the second helper would have a signature roughly like this:

def check_snap_status(                                                                                                                                                          
         self,                                                                                                                                                                       
         app: str,                                                                                                                                                                   
         pebble_service: str,                                                                                                                                                                  
         unit_num: int = 0,
         containre_name: str,                                                                                                                                                          
     ) -> str:

Its usage would be something like:

import jubilant
...
assert jubilant.check_snap_status("otelcol", "otelcol", 1, "otelcol") == "active"

I'd be happy to contribute this if you think it'd make a valuable addition. My question is, since _juju.py is merely a wrapper around the Juju CLI, where should a helper like this go? In a dedicated _helpers.py file or should it be added to the existing _test_helpers.py file?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs designNeeds more thought or a spec

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions