bind-charmers team mailing list archive
-
bind-charmers team
-
Mailing list archive
-
Message #00116
[Merge] ~barryprice/charm-k8s-bind/+git/charm-k8s-bind:master into charm-k8s-bind:master
Barry Price has proposed merging ~barryprice/charm-k8s-bind/+git/charm-k8s-bind:master into charm-k8s-bind:master.
Commit message:
This takes us from 90% to 100% test coverage
Requested reviews:
Bind Charmers (bind-charmers)
For more details, see:
https://code.launchpad.net/~barryprice/charm-k8s-bind/+git/charm-k8s-bind/+merge/392823
--
Your team Bind Charmers is requested to review the proposed merge of ~barryprice/charm-k8s-bind/+git/charm-k8s-bind:master into charm-k8s-bind:master.
diff --git a/src/charm.py b/src/charm.py
index 0faf651..14198c7 100755
--- a/src/charm.py
+++ b/src/charm.py
@@ -135,5 +135,5 @@ class BindK8sCharm(CharmBase):
return spec
-if __name__ == "__main__":
+if __name__ == "__main__": # pragma: no cover
main(BindK8sCharm)
diff --git a/tests/unit/test_charm.py b/tests/unit/test_charm.py
index dc53ac0..0909de0 100644
--- a/tests/unit/test_charm.py
+++ b/tests/unit/test_charm.py
@@ -38,6 +38,16 @@ CONFIG_VALID = {
'https_proxy': '',
}
+CONFIG_VALID_WITH_CREDS = {
+ 'bind_image_path': 'secure.example.com/bind:v1',
+ 'bind_image_username': 'AzureDiamond',
+ 'bind_image_password': 'hunter2',
+ 'container_config': '',
+ 'container_secrets': '',
+ 'custom_config_repo': '',
+ 'https_proxy': '',
+}
+
CONFIG_VALID_WITH_CONTAINER_CONFIG = {
'bind_image_path': 'example.com/bind:v1',
'bind_image_username': '',
@@ -58,6 +68,16 @@ CONFIG_VALID_WITH_CONTAINER_CONFIG_AND_SECRETS = {
'https_proxy': '',
}
+CONFIG_VALID_WITH_CUSTOM_CONFIG_REPO_AND_PROXY = {
+ 'bind_image_path': 'example.com/bind:v1',
+ 'bind_image_username': '',
+ 'bind_image_password': '',
+ 'container_config': '',
+ 'container_secrets': '',
+ 'custom_config_repo': 'https://github.com/example/example-bind-config.git',
+ 'https_proxy': 'http://webproxy.example.com:3128/',
+}
+
class TestBindK8s(unittest.TestCase):
maxDiff = None
@@ -110,6 +130,30 @@ class TestBindK8s(unittest.TestCase):
}
self.assertEqual(self.harness.charm.make_pod_spec(), expected)
+ def test_make_pod_spec_with_creds(self):
+ """Confirm that we generate the expected pod spec from config containing credentials"""
+ self.harness.update_config(CONFIG_VALID_WITH_CREDS)
+ expected = {
+ 'version': 2,
+ 'containers': [
+ {
+ 'name': 'bind',
+ 'imageDetails': {
+ 'imagePath': 'secure.example.com/bind:v1',
+ 'username': 'AzureDiamond',
+ 'password': 'hunter2',
+ },
+ 'ports': [
+ {'containerPort': 53, 'name': 'domain-tcp', 'protocol': 'TCP'},
+ {'containerPort': 53, 'name': 'domain-udp', 'protocol': 'UDP'},
+ ],
+ 'config': {},
+ 'kubernetes': {'readinessProbe': {'exec': {'command': ['/usr/local/bin/dns-check.sh']}}},
+ }
+ ],
+ }
+ self.assertEqual(self.harness.charm.make_pod_spec(), expected)
+
def test_make_pod_spec_with_extra_config(self):
"""Confirm that we generate the expected pod spec from a more involved valid config."""
self.harness.update_config(CONFIG_VALID_WITH_CONTAINER_CONFIG)
@@ -150,6 +194,30 @@ class TestBindK8s(unittest.TestCase):
}
self.assertEqual(self.harness.charm.make_pod_spec(), expected)
+ def test_make_pod_spec_with_custom_config_repo(self):
+ """Confirm that we generate the expected pod spec from a config that includes a custom repo."""
+ self.harness.update_config(CONFIG_VALID_WITH_CUSTOM_CONFIG_REPO_AND_PROXY)
+ expected = {
+ 'version': 2,
+ 'containers': [
+ {
+ 'name': 'bind',
+ 'imageDetails': {'imagePath': 'example.com/bind:v1'},
+ 'ports': [
+ {'containerPort': 53, 'name': 'domain-tcp', 'protocol': 'TCP'},
+ {'containerPort': 53, 'name': 'domain-udp', 'protocol': 'UDP'},
+ ],
+ 'config': {
+ 'CUSTOM_CONFIG_REPO': 'https://github.com/example/example-bind-config.git',
+ 'http_proxy': 'http://webproxy.example.com:3128/',
+ 'https_proxy': 'http://webproxy.example.com:3128/',
+ },
+ 'kubernetes': {'readinessProbe': {'exec': {'command': ['/usr/local/bin/dns-check.sh']}}},
+ }
+ ],
+ }
+ self.assertEqual(self.harness.charm.make_pod_spec(), expected)
+
def test_configure_pod_as_leader(self):
"""Confirm that our status is set correctly when we're the leader."""
self.harness.enable_hooks()
Follow ups