charmed-kubernetes / pytest-operator

Apache License 2.0
7 stars 13 forks source link

When model switch is used, reuse or create and keep that model #113

Closed addyess closed 1 year ago

addyess commented 1 year ago

In response to the feature requested

If the --model=<name> switch is used with this plugin,

This should prevent errors like this when --model=testing is specfiied

juju.errors.JujuConnectionError: Model not found: admin/testing
addyess commented 1 year ago

@juditnovak would you be able to try out this branch locally and see if it meets your needs.

juditnovak commented 1 year ago

Yes, indeed it seems working locally :-) :-) :-)

$ tox run -e charm-integration -- --model testing --cloud localhost
[..]
tests/integration/test_charm.py::test_build_and_deploy 
-------------------------------------------------------------------------------------------------- live log setup --------------------------------------------------------------------------------------------------
INFO     pytest_operator.plugin:plugin.py:647 Adding model opensearchctl:testing on cloud localhost

And the tests are running happily :-)

If I re-run the command, then it's indeed connecting to the existing model (saying on 'unspecified cloud', but I guess the existing model already has cloud information, so it's just a misleading message)

INFO     pytest_operator.plugin:plugin.py:675 Connecting to existing model opensearchctl:testing on unspecified cloud

(In fact, on a 2nd run --model seems enough, --cloud is not needed.)