Merge charm-juju-controller:bug/1922292 into charm-juju-controller:master

Proposed by Adam Dyess
Status: Merged
Approved by: Xav Paice
Approved revision: b440406a08f930c8fd55d2a0d92f4b26b75d3a16
Merged at revision: a49a21f0cba41f349c6a52ea1703a7c91cef90c5
Proposed branch: charm-juju-controller:bug/1922292
Merge into: charm-juju-controller:master
Diff against target: 60 lines (+20/-3)
2 files modified
src/lib/lib_juju_controller.py (+5/-1)
src/tests/unit/test_lib_juju_controller.py (+15/-2)
Reviewer Review Type Date Requested Status
Xav Paice (community) Approve
🤖 prod-jenkaas-bootstack (community) continuous-integration Approve
Paul Goins Approve
Review via email: mp+406258@code.launchpad.net

Commit message

Add Monitoring for juju-db installed by snap

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
Paul Goins (vultaire) wrote :

LGTM, +1

review: Approve
Revision history for this message
Xav Paice (xavpaice) wrote :

Fails lint, unfortunately. I've put the lint differences inline.

I'll work on getting this into CI shortly.

review: Needs Fixing
Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :

A CI job is currently in progress. A follow up comment will be added when it completes.

Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :

A CI job is currently in progress. A follow up comment will be added when it completes.

Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Approve (continuous-integration)
Revision history for this message
Xav Paice (xavpaice) wrote :

LGTM

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

Change successfully merged at revision a49a21f0cba41f349c6a52ea1703a7c91cef90c5

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/src/lib/lib_juju_controller.py b/src/lib/lib_juju_controller.py
index 6432c3c..08eb0b7 100644
--- a/src/lib/lib_juju_controller.py
+++ b/src/lib/lib_juju_controller.py
@@ -11,6 +11,7 @@ import yaml
11AGENTDIRGLOB = "/var/lib/juju/agents/machine-*"11AGENTDIRGLOB = "/var/lib/juju/agents/machine-*"
12CACERTPATH = "/run/juju-controller-ca.crt"12CACERTPATH = "/run/juju-controller-ca.crt"
13PUBAGENTCONFPATH = "/run/juju-controller-public-agent.conf"13PUBAGENTCONFPATH = "/run/juju-controller-public-agent.conf"
14SNAP_JUJU_DB_SVC = "/etc/systemd/system/snap.juju-db.daemon.service"
1415
1516
16class JujuControllerHelper:17class JujuControllerHelper:
@@ -55,7 +56,10 @@ class JujuControllerHelper:
55 @property56 @property
56 def services(self):57 def services(self):
57 """Return the list of juju services on this machine."""58 """Return the list of juju services on this machine."""
58 return ["juju-db", "jujud-machine-{}".format(self._machine_id())]59 return [
60 "snap.juju-db.daemon" if os.path.exists(SNAP_JUJU_DB_SVC) else "juju-db",
61 "jujud-machine-{}".format(self._machine_id()),
62 ]
5963
60 @property64 @property
61 def agent_conf_path(self):65 def agent_conf_path(self):
diff --git a/src/tests/unit/test_lib_juju_controller.py b/src/tests/unit/test_lib_juju_controller.py
index 03bae5b..a40ddd0 100644
--- a/src/tests/unit/test_lib_juju_controller.py
+++ b/src/tests/unit/test_lib_juju_controller.py
@@ -1,6 +1,8 @@
1#!/usr/bin/python31#!/usr/bin/python3
2"""Pytest test cases for lib_juju_controller.py."""2"""Pytest test cases for lib_juju_controller.py."""
33
4import mock
5
4EXPECTED = {6EXPECTED = {
5 "machine-id": "99",7 "machine-id": "99",
6 "services": ["juju-db", "jujud-machine-99"],8 "services": ["juju-db", "jujud-machine-99"],
@@ -44,9 +46,20 @@ class TestJujuControllerLib:
44 """Test parsing the machine id."""46 """Test parsing the machine id."""
45 assert jujucontroller._machine_id() == EXPECTED["machine-id"]47 assert jujucontroller._machine_id() == EXPECTED["machine-id"]
4648
47 def test_services(self, jujucontroller):49 def test_services_snap(self, jujucontroller):
50 """Test collecting all juju services."""
51 with mock.patch("os.path.exists", autospec=True) as path_exists:
52 path_exists.return_value = True
53 expected = list(EXPECTED["services"])
54 expected.remove("juju-db")
55 expected.insert(0, "snap.juju-db.daemon")
56 assert jujucontroller.services == expected
57
58 def test_services_apt(self, jujucontroller):
48 """Test collecting all juju services."""59 """Test collecting all juju services."""
49 assert jujucontroller.services == EXPECTED["services"]60 with mock.patch("os.path.exists", autospec=True) as path_exists:
61 path_exists.return_value = False
62 assert jujucontroller.services == EXPECTED["services"]
5063
51 def test_version(self, jujucontroller):64 def test_version(self, jujucontroller):
52 """Test reporting the controller version."""65 """Test reporting the controller version."""

Subscribers

No one subscribed via source and target branches