Merge ~rgildein/charm-telegraf:lp2009613 into charm-telegraf:master

Proposed by Robert Gildein
Status: Merged
Approved by: Eric Chen
Approved revision: 1ec40b3cb0e74ea1aff7ecec1332f56820eb83b6
Merged at revision: 0b467d14b7fe63a18eeaeb44b77f1f4409e7b482
Proposed branch: ~rgildein/charm-telegraf:lp2009613
Merge into: charm-telegraf:master
Diff against target: 156 lines (+13/-29)
4 files modified
charmcraft.yaml (+5/-3)
src/metadata.yaml (+2/-2)
src/reactive/telegraf.py (+0/-11)
src/tests/unit/test_telegraf.py (+6/-13)
Reviewer Review Type Date Requested Status
🤖 prod-jenkaas-bootstack (community) continuous-integration Approve
BootStack Reviewers Pending
BootStack Reviewers Pending
Review via email: mp+439163@code.launchpad.net

Commit message

functional test fix + dropped Xenial

Dropped the Xenial series and providing a small fix for bundles in
functional tests. Added some things from the bs templates to make
the func test smoother.

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
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Approve (continuous-integration)
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 0b467d14b7fe63a18eeaeb44b77f1f4409e7b482

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/charmcraft.yaml b/charmcraft.yaml
2index e814176..559f214 100644
3--- a/charmcraft.yaml
4+++ b/charmcraft.yaml
5@@ -10,9 +10,11 @@ parts:
6 charm:
7 source: src
8 plugin: reactive
9- build-snaps: [ charm/2.x/stable ] # charmcraft has incompatibility issue
10- # with the latest charm snap. Pining the
11- # version to 2.x/stable as a temporary fix
12+ # Using charm/3.x/stable will cause the charm unable to install on 18.04
13+ # with the following error: "pip requires Python '>=3.7' but the running
14+ # Python is 3.6.9". This is because charm/3.x/stable start using system
15+ # installation of python instead of a python snap.
16+ build-snaps: [charm/2.x/stable]
17
18 bases:
19 - build-on:
20diff --git a/src/metadata.yaml b/src/metadata.yaml
21index 0b9ad39..bbf02e7 100644
22--- a/src/metadata.yaml
23+++ b/src/metadata.yaml
24@@ -28,8 +28,8 @@ description: >
25 plugins are designed to be easy to contribute, we'll eagerly accept
26 pull requests and will manage the set of plugins that Telegraf supports.
27 See the contributing guide for instructions on writing new plugins.
28-# NOTE (rgildein): This is a temporary fix until the issue is resolved.
29-# https://github.com/juju/charm-tools/issues/615
30+# Series are needed here only because we use charm/2.x/stable, whose linter will fail
31+# if it doesn't find series here. Bases in charmcraft.yaml are used instead of series.
32 series: []
33 subordinate: true
34 requires:
35diff --git a/src/reactive/telegraf.py b/src/reactive/telegraf.py
36index b335f62..8f88df8 100644
37--- a/src/reactive/telegraf.py
38+++ b/src/reactive/telegraf.py
39@@ -1023,7 +1023,6 @@ def upgrade_charm():
40 clear_flag("telegraf.configured")
41 clear_flag("telegraf.apt.configured")
42 clear_flag("telegraf.snap.configured")
43- clear_flag("grafana.configured")
44
45
46 @when("config.changed")
47@@ -1075,7 +1074,6 @@ def handle_config_changes():
48 clear_flag("telegraf.apt.configured")
49 clear_flag("telegraf.snap.configured")
50 clear_flag("telegraf.nagios-setup.complete")
51- clear_flag("grafana.configured")
52
53
54 @when("telegraf.configured")
55@@ -1961,7 +1959,6 @@ def prometheus_client_departed():
56 "endpoint.dashboards.joined",
57 "leadership.is_leader",
58 )
59-@when_not("grafana.configured")
60 def register_grafana_dashboards():
61 grafana = endpoint_from_flag("endpoint.dashboards.joined")
62 grafana_dashboard_config = GRAFANA_DASHBOARD_CONFIG.copy()
63@@ -1996,8 +1993,6 @@ def register_grafana_dashboards():
64 grafana.register_dashboard(name=dashboard_name, dashboard=dashboard_dict)
65 hookenv.log('Grafana dashboard "{}" registered.'.format(dashboard_name))
66
67- set_flag("grafana.configured")
68-
69
70 def _load_grafana_dashboard(dashboard_data, dashboard_filter):
71 related_prometheus_app = None
72@@ -2044,11 +2039,6 @@ def render_custom(source, render_context, **parameters):
73 return template.render(render_context)
74
75
76-@when("endpoint.dashboards.departed", "grafana.configured")
77-def unregister_grafana_dashboard():
78- clear_flag("grafana.configured")
79-
80-
81 @when("endpoint.dashboards.failed", "leadership.is_leader")
82 def grafana_dashboard_import_failed():
83 grafana = endpoint_from_flag("endpoint.dashboards.failed")
84@@ -2059,7 +2049,6 @@ def grafana_dashboard_import_failed():
85 ),
86 level=hookenv.ERROR,
87 )
88- clear_flag("grafana.configured")
89
90
91 @when("telegraf.needs_reload")
92diff --git a/src/tests/unit/test_telegraf.py b/src/tests/unit/test_telegraf.py
93index 5f59a91..512f5c4 100644
94--- a/src/tests/unit/test_telegraf.py
95+++ b/src/tests/unit/test_telegraf.py
96@@ -1627,9 +1627,8 @@ def test_upgrade_charm(mocker):
97 clear_flag.assert_any_call("plugins.foo.configured")
98 clear_flag.assert_any_call("plugins.bar.configured")
99 clear_flag.assert_any_call("extra_plugins.configured")
100- clear_flag.assert_any_call("grafana.configured")
101 clear_flag.assert_any_call("prometheus-client.relation.configured")
102- assert clear_flag.call_count == 8
103+ assert clear_flag.call_count == 7
104
105
106 def test_upgrade_charm_prometheus_client(mocker, monkeypatch, config):
107@@ -1738,17 +1737,19 @@ class TestTelegrafNagios:
108
109
110 class TestGrafanaDashboard:
111+ @patch("reactive.telegraf.endpoint_from_flag")
112+ def test_register_grafana_dashboard_n(self, mock_endpoint_from_flag):
113+ ...
114+
115 @patch("reactive.telegraf.render_custom")
116 @patch("reactive.telegraf.endpoint_from_flag")
117 @patch("reactive.telegraf.hookenv")
118- @patch("reactive.telegraf.set_flag")
119 @patch("reactive.telegraf.json")
120 @patch("hashlib.md5")
121 def test_register_grafana_dashboard(
122 self,
123 mock_md5,
124 mock_json,
125- mock_set_flag,
126 mock_hookenv,
127 mock_endpoint_from_flag,
128 mock_render,
129@@ -1816,18 +1817,11 @@ class TestGrafanaDashboard:
130 mock_register_dashboards_calls, any_order=True
131 )
132 mock_render.assert_has_calls(mock_render_calls, any_order=True)
133- mock_set_flag.assert_called_once_with("grafana.configured")
134-
135- @patch("reactive.telegraf.clear_flag")
136- def test_unregister_grafana_dashboard(self, mock_clear_flag):
137- telegraf.unregister_grafana_dashboard()
138- mock_clear_flag.assert_called_with("grafana.configured")
139
140 @patch("reactive.telegraf.endpoint_from_flag")
141- @patch("reactive.telegraf.clear_flag")
142 @patch("reactive.telegraf.hookenv")
143 def test_grafana_dashboard_import_failed(
144- self, mock_hookenv, mock_clear_flag, mock_endpoint_from_flag
145+ self, mock_hookenv, mock_endpoint_from_flag
146 ):
147 test_failed_imports = [
148 MagicMock(name="import1", reason="some_reason1"),
149@@ -1841,7 +1835,6 @@ class TestGrafanaDashboard:
150 telegraf.grafana_dashboard_import_failed()
151
152 assert mock_hookenv.log.call_count == 2
153- mock_clear_flag.assert_called_once_with("grafana.configured")
154
155
156 @pytest.mark.parametrize("install_method", ["deb", "snap"])

Subscribers

People subscribed via source and target branches

to all changes: