Skip to content

Commit

Permalink
Fix code for py3.5 and add a regression test
Browse files Browse the repository at this point in the history
* Added a regression test for the get_app_ips() function for
  associated error [1].
* Added third.yaml bundle with just ubuntu apps for public IP tests
* Add pins for py35 support (oslo.config and kubernetes)

[1]: #470
  • Loading branch information
ajkavanagh committed Jan 11, 2022
1 parent c510eb4 commit 5457dc3
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 7 deletions.
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pyparsing<3.0.0 # pin for aodhclient which is held for py35
aiounittest
async_generator
kubernetes<18.0.0; python_version < '3.6' # pined, as juju uses kubernetes
juju
juju_wait
PyYAML>=3.0
Expand All @@ -19,6 +20,7 @@ Jinja2>=2.6 # BSD License (3 clause)
six>=1.9.0
dnspython>=1.12.0
psutil>=1.1.1,<2.0.0
oslo.config<6.9.0;python_version < '3.6' # pin for py3.5 support
oslo.context<3.0.0;python_version < '3.6' # pin for py3.5 support
osprofiler<3.0.0;python_version < '3.6' # pin for py3.5 support
python-openstackclient>=3.14.0
Expand Down
5 changes: 5 additions & 0 deletions tests/bundles/third.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
applications:
ubuntu:
charm: cs:ubuntu
num_units: 10

1 change: 1 addition & 0 deletions tests/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ tests_options:
force_deploy:
first
second
third
8 changes: 6 additions & 2 deletions unit_tests/test_zaza_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,12 @@ def test_get_unit_from_name(self):

def test_get_app_ips(self):
self.patch_object(model, 'get_juju_model', return_value='mname')
self.patch_object(model, 'get_units')
self.get_units.return_value = self.units
self.patch_object(model, 'async_get_units')

async def mock_async_aget_units(*args, **kwargs):
return self.units

self.async_get_units.side_effect = mock_async_aget_units
self.assertEqual(model.get_app_ips('model', 'app'), ['ip1', 'ip2'])

def test_run_on_unit(self):
Expand Down
1 change: 0 additions & 1 deletion zaza/charm_tests/libjuju/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@
# limitations under the License.

"""Collection of regression tests checking zaza/libjuju integration."""

1 change: 0 additions & 1 deletion zaza/charm_tests/libjuju/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,3 @@ def test_get_app_ips(self):
ips = zaza.model.get_app_ips('ubuntu')
for ip in ips:
self.assertIsNotNone(ip)

7 changes: 4 additions & 3 deletions zaza/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,9 +696,10 @@ async def async_get_app_ips(application_name, model_name=None):
:returns: List of ip addresses
:rtype: [str, str,...]
"""
return [await u.get_public_address()
for u in await async_get_units(
application_name, model_name=model_name)]
addresses = []
for u in await async_get_units(application_name, model_name=model_name):
addresses.append(await u.get_public_address())
return addresses


get_app_ips = sync_wrapper(async_get_app_ips)
Expand Down

0 comments on commit 5457dc3

Please sign in to comment.