You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While running tests on a MAAS juju cloud where the model is named admin/mymodel according to the <user>/<model> convention, the ops_test fixture does not work.
Steps to reproduce error
Models are named admin/mymodel and admin/controller.
Have a simple test that calls the ops_test fixture.
deftest_something(ops_test):
assertTrue
And run pytest path/to/test.py --model admin/mymodel to execute the tests.
Analysis
I was trying to reuse my existing model by providing --model admin/mymodel but this still tried to create a new model (and promptly failed since I wasn't the admin user on the cloud). Upon tracing the execution flow from the plugin.py -> ops_test -> _setup_model -> track_model -> _model_exists where the last method is used to set the value of the use_existing variable which was getting the wrong value (should be True, getting False).
This seemed to be due to the fact that the self._controller.list_models() returns the models but without prefixing the user name (without "admin" in this instance).
asyncdef_model_exists(self, model_name: str) ->bool:
""" returns True when the model_name exists in the model. """all_models=awaitself._controller.list_models()
returnmodel_nameinall_models# all_models had the value ['controller', 'mymodel'] but model_name is "admin/mymodel"
As seen above, the _model_exists method returns False when the self._controller.list_models() returns the wrong name for the current model.
While running tests on a MAAS juju cloud where the model is named
admin/mymodel
according to the<user>/<model>
convention, theops_test
fixture does not work.Steps to reproduce error
Models are named
admin/mymodel
andadmin/controller
.Have a simple test that calls the
ops_test
fixture.And run
pytest path/to/test.py --model admin/mymodel
to execute the tests.Analysis
I was trying to reuse my existing model by providing
--model admin/mymodel
but this still tried to create a new model (and promptly failed since I wasn't the admin user on the cloud). Upon tracing the execution flow from theplugin.py
->ops_test
->_setup_model
->track_model
->_model_exists
where the last method is used to set the value of theuse_existing
variable which was getting the wrong value (should be True, getting False).This seemed to be due to the fact that the
self._controller.list_models()
returns the models but without prefixing the user name (without "admin" in this instance).As seen above, the
_model_exists
method returns False when theself._controller.list_models()
returns the wrong name for the current model.Temporary workaround
Made changes here.
The text was updated successfully, but these errors were encountered: