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

Bug/1828424 #156

Merged
merged 19 commits into from Feb 3, 2020
Merged

Bug/1828424 #156

merged 19 commits into from Feb 3, 2020

Conversation

addyess
Copy link
Contributor

@addyess addyess commented Jan 21, 2020

Port keystone-ldap basic tests to zaza

Copy link
Contributor

@ajkavanagh ajkavanagh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see inline comments.

zaza/openstack/charm_tests/keystone/tests.py Outdated Show resolved Hide resolved
zaza/openstack/charm_tests/keystone/tests.py Outdated Show resolved Hide resolved
zaza/openstack/charm_tests/keystone/tests.py Outdated Show resolved Hide resolved
zaza/openstack/charm_tests/keystone/tests.py Outdated Show resolved Hide resolved
zaza/openstack/charm_tests/keystone/tests.py Outdated Show resolved Hide resolved
zaza/openstack/charm_tests/keystone/tests.py Outdated Show resolved Hide resolved
zaza/openstack/charm_tests/keystone/tests.py Outdated Show resolved Hide resolved
zaza/openstack/charm_tests/keystone/tests.py Outdated Show resolved Hide resolved
)

with self.config_change(
self.config_current(application_name),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here's the use of a new method config_current

@@ -133,6 +133,29 @@ def setUpClass(cls, application_name=None, model_alias=None):
model_name=cls.model_name)
logging.debug('Leader unit is {}'.format(cls.lead_unit))

def config_current(self, application_name=None, keys=None):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new method here to get the current config from an application. You can supply keys if you only want certain items from the current config.

Copy link
Contributor

@ajkavanagh ajkavanagh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some really nice, clean, code in this patchset. There's just one minor change to a docstring and it's good to go.

zaza/openstack/charm_tests/test_utils.py Outdated Show resolved Hide resolved
@ajkavanagh
Copy link
Contributor

Hi Adam

I not sure, but it looks like you've switched all the docstring params/types to @something: from :something: .. the latter (:something:) is more correct. We used to use @param in Juju and older code, but we switched to the current form as it's more widespread/accepted by the Python community. I realise it's confusing! (particularly when you look at charm-helpers and see that both styles are in use!)

@addyess
Copy link
Contributor Author

addyess commented Jan 23, 2020

force of habit. I've been doing @param: for too long. Heck i may even have my editor set-up that way.

I'll fix that up

Copy link
Contributor

@ajkavanagh ajkavanagh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - thanks for doing the changes.

:rtype: Tuple[bool, Dict[str,str]]
"""
ldap_ips = zaza.model.get_app_ips("ldap-server")
self.assertTrue(ldap_ips, "Should be at least one ldap server")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ajkavanagh @thedac let's assert if the ldap-server isn't there.

Copy link
Contributor

@thedac thedac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of nits. And a need for more discussion.

I did not realize until I got to the end that you were just moving existing code to create the config_current method. I am not sure I love this in its original form, but I concede it exists that way already. I would really like a second opinion on this before landing.

)
states = {
'keystone': {
'workload-status': 'idle',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is another method for checking for idleness. workload-state should be active here. This is, however, the default, making the setting of states unecessary.
The best practice is to check the tests.yaml which allows future developers to change expectations:
test_config = lifecycle_utils.get_charm_config(fatal=False)
zaza.model.wait_for_application_states(
states=test_config.get("target_deploy_status", {}))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did this!

# convert the more elaborate config structure from libjuju to key-value
keys = keys or _app_config.keys()
# note that conversion to string for all values is due to
# attempting to set any config with other types lead to Traceback
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/lead/leads
Though the whole sentence could be clearer.

Beyond the comment, I am not sold on changing the types. I would be interested to see the traceback when you don't set things to a string.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if i remember rightly, the traceback was trying to cast a go native type into a python type? That may be why str(*) is used here. Ill see if i can reproduce.

Also, I think I remember that passing the config back with model.set_application_config fussed about the types?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah... here's the issue. You can 'get' the current config such that the types are preserved (aka -- not mapped through str) but when you play them back into the model.set_application_config -- it doesn't like anything that isn't str typed.

2020-01-24 12:40:44 [INFO]   File "/home/ubuntu/charms/layers/keystone-ldap/build/builds/keystone-ldap/.tox/func-smoke/lib/python3.7/site-packages/zaza/model.py", line 531, in async_set_application_config
2020-01-24 12:40:44 [INFO]     .set_config(configuration))
2020-01-24 12:40:44 [INFO]   File "/home/ubuntu/charms/layers/keystone-ldap/build/builds/keystone-ldap/.tox/func-smoke/lib/python3.7/site-packages/juju/application.py", line 383, in set_config
2020-01-24 12:40:44 [INFO]     return await app_facade.Set(application=self.name, options=config)
2020-01-24 12:40:44 [INFO]   File "/home/ubuntu/charms/layers/keystone-ldap/build/builds/keystone-ldap/.tox/func-smoke/lib/python3.7/site-packages/juju/client/facade.py", line 471, in wrapper
2020-01-24 12:40:44 [INFO]     reply = await f(*args, **kwargs)
2020-01-24 12:40:44 [INFO]   File "/home/ubuntu/charms/layers/keystone-ldap/build/builds/keystone-ldap/.tox/func-smoke/lib/python3.7/site-packages/juju/client/_client8.py", line 1124, in Set
2020-01-24 12:40:44 [INFO]     reply = await self.rpc(msg)
2020-01-24 12:40:44 [INFO]   File "/home/ubuntu/charms/layers/keystone-ldap/build/builds/keystone-ldap/.tox/func-smoke/lib/python3.7/site-packages/juju/client/facade.py", line 607, in rpc
2020-01-24 12:40:44 [INFO]     result = await self.connection.rpc(msg, encoder=TypeEncoder)
2020-01-24 12:40:44 [INFO]   File "/home/ubuntu/charms/layers/keystone-ldap/build/builds/keystone-ldap/.tox/func-smoke/lib/python3.7/site-packages/juju/client/connection.py", line 456, in rpc
2020-01-24 12:40:44 [INFO]     raise errors.JujuAPIError(result)
2020-01-24 12:40:44 [INFO] juju.errors.JujuAPIError: json: cannot unmarshal bool into Go struct field ApplicationSet.options of type string

Copy link
Contributor

@thedac thedac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great.

@thedac thedac merged commit be3ea8e into openstack-charmers:master Feb 3, 2020
@addyess addyess deleted the bug/1828424 branch February 3, 2020 21:25
openstack-gerrit pushed a commit to openstack/charm-keystone-ldap that referenced this pull request Feb 3, 2020
removing disco_stein as its EOL

func-test-pr: openstack-charmers/zaza-openstack-tests#156
Change-Id: Ice0ae709817db2fd9ffcff299ca403b70dd22721
Closes-Bug: #1828424
openstack-gerrit pushed a commit to openstack/openstack that referenced this pull request Feb 3, 2020
* Update charm-keystone-ldap from branch 'master'
  - Migrate keystone-ldap tests to zaza
    
    removing disco_stein as its EOL
    
    func-test-pr: openstack-charmers/zaza-openstack-tests#156
    Change-Id: Ice0ae709817db2fd9ffcff299ca403b70dd22721
    Closes-Bug: #1828424
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.

None yet

3 participants