Merge ~mthaddon/charm-k8s-mattermost/+git/charm-k8s-mattermost:tests into charm-k8s-mattermost:master

Proposed by Tom Haddon
Status: Merged
Approved by: Tom Haddon
Approved revision: 8c23ef87c9c237f0d000f7601402b2393f559c1e
Merged at revision: cda8e5377822ee813691ec45405662f9b0214642
Proposed branch: ~mthaddon/charm-k8s-mattermost/+git/charm-k8s-mattermost:tests
Merge into: charm-k8s-mattermost:master
Diff against target: 62 lines (+38/-2)
2 files modified
src/charm.py (+1/-2)
tests/unit/test_charm.py (+37/-0)
Reviewer Review Type Date Requested Status
Paul Collins Approve
Haw Loeung +1 Approve
Review via email: mp+391372@code.launchpad.net

Commit message

Add some more tests for ingress conditions, remove conditional for annotations, which is always True in _update_pod_spec_for_k8s_ingress

Description of the change

Add some more tests for ingress conditions, remove conditional for annotations, which is always True in _update_pod_spec_for_k8s_ingress.

Takes overall test coverage from 60% to 61%...

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Haw Loeung (hloeung) wrote :

LGTM

review: Approve (+1)
Revision history for this message
Paul Collins (pjdc) wrote :

lgtm re annotations

review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision cda8e5377822ee813691ec45405662f9b0214642

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/src/charm.py b/src/charm.py
index 34f8922..c3f2eda 100755
--- a/src/charm.py
+++ b/src/charm.py
@@ -311,8 +311,7 @@ class MattermostK8sCharm(CharmBase):
311 if ingress_whitelist_source_range:311 if ingress_whitelist_source_range:
312 annotations['nginx.ingress.kubernetes.io/whitelist-source-range'] = ingress_whitelist_source_range312 annotations['nginx.ingress.kubernetes.io/whitelist-source-range'] = ingress_whitelist_source_range
313313
314 if annotations:314 ingress['annotations'] = annotations
315 ingress['annotations'] = annotations
316315
317 # Due to https://github.com/canonical/operator/issues/293 we316 # Due to https://github.com/canonical/operator/issues/293 we
318 # can't use pod.set_spec's k8s_resources argument.317 # can't use pod.set_spec's k8s_resources argument.
diff --git a/tests/unit/test_charm.py b/tests/unit/test_charm.py
index f1a5da1..5295dce 100644
--- a/tests/unit/test_charm.py
+++ b/tests/unit/test_charm.py
@@ -292,6 +292,43 @@ class TestMattermostK8sCharmHooksDisabled(unittest.TestCase):
292 pod_spec = {}292 pod_spec = {}
293 self.harness.charm._update_pod_spec_for_k8s_ingress(pod_spec)293 self.harness.charm._update_pod_spec_for_k8s_ingress(pod_spec)
294 self.assertEqual(pod_spec, expected)294 self.assertEqual(pod_spec, expected)
295 # And now test with an ingress_whitelist_source_range, and an http
296 # rather than https site_url to test a few more ingress conditions.
297 self.harness.update_config(
298 {'ingress_whitelist_source_range': '10.10.10.10/24', 'site_url': 'http://chat.example.com'}
299 )
300 expected = {
301 'kubernetesResources': {
302 'ingressResources': [
303 {
304 'name': ingress_name,
305 'spec': {
306 'rules': [
307 {
308 'host': 'chat.example.com',
309 'http': {
310 'paths': [
311 {
312 'path': '/',
313 'backend': {'serviceName': 'mattermost', 'servicePort': 8065},
314 }
315 ]
316 },
317 }
318 ],
319 },
320 'annotations': {
321 'nginx.ingress.kubernetes.io/proxy-body-size': '5m',
322 'nginx.ingress.kubernetes.io/ssl-redirect': 'false',
323 'nginx.ingress.kubernetes.io/whitelist-source-range': '10.10.10.10/24',
324 },
325 }
326 ]
327 }
328 }
329 pod_spec = {}
330 self.harness.charm._update_pod_spec_for_k8s_ingress(pod_spec)
331 self.assertEqual(pod_spec, expected)
295332
296 def test_update_pod_spec_for_performance_monitoring(self):333 def test_update_pod_spec_for_performance_monitoring(self):
297 """envConfig is updated, and pre-existing annotations are not clobbered."""334 """envConfig is updated, and pre-existing annotations are not clobbered."""

Subscribers

People subscribed via source and target branches