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

test scenario itself against real juju #2

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

PietroPasotti
Copy link
Collaborator

This PR adds a new test suite aimed at validating the output of the simulated backend against the output of the real hook tools.

tests/consistency/conftest.py exposes a compare function to be used like:

compare("relation_list", "relation_name").

this will compare the _MockModelBackend result against the result of, essentially, running juju exec -u some-unit/0 -m some-model -- relation-list relation_name.

If the hook tool call returns an error code, wrapped by _ModelBackend in an ops.model.ModelError, compare() checks that _MockModelBackend raises a similar error.

If the hook tool call returns a value, compare() checks that _MockModelBackend returns the exact same value as _ModelBackend.

For now this works with a hardcoded model and unit name, and the State used by _MockModelBackend is also hardcoded.

Next steps:
create a testing charm (or bundle?) to pack and deploy using pytest-operator, and a corresponding State. Or pick a reference charm/bundle to deploy and test with. Probably best.

@PietroPasotti PietroPasotti changed the title consistency tests test scenario itself against real juju Mar 13, 2023
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

Successfully merging this pull request may close these issues.

1 participant