Merge ~adam-collard/maas:config-snap-debug into maas:master

Proposed by Adam Collard
Status: Merged
Approved by: Adam Collard
Approved revision: 767aafc605420afd237ec71c0d81049c5e84e026
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~adam-collard/maas:config-snap-debug
Merge into: maas:master
Diff against target: 56 lines (+32/-5)
2 files modified
src/maascli/snappy.py (+0/-5)
src/maascli/tests/test_snappy.py (+32/-0)
Reviewer Review Type Date Requested Status
MAAS Lander Approve
Alberto Donato (community) Approve
Review via email: mp+396761@code.launchpad.net

Commit message

Fix error when enabling debug in the snap

To post a comment you must log in.
Revision history for this message
Alberto Donato (ack) wrote :

+1

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b config-snap-debug lp:~adam-collard/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 767aafc605420afd237ec71c0d81049c5e84e026

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/maascli/snappy.py b/src/maascli/snappy.py
2index e58b8ee..48fc267 100644
3--- a/src/maascli/snappy.py
4+++ b/src/maascli/snappy.py
5@@ -819,11 +819,6 @@ class cmd_config(SnappyCommand):
6 # Validate the mode and flags.
7 self._validate_flags(options, running_mode)
8
9- if options.mode != running_mode:
10- render_supervisord(options.mode)
11- set_current_mode(options.mode)
12- restart_required = True
13-
14 current_config = config_manager.get()
15 # Only update the passed settings.
16 for flag in self.setting_flags:
17diff --git a/src/maascli/tests/test_snappy.py b/src/maascli/tests/test_snappy.py
18index 95458f7..8ef6f5b 100644
19--- a/src/maascli/tests/test_snappy.py
20+++ b/src/maascli/tests/test_snappy.py
21@@ -592,3 +592,35 @@ class TestCmdConfig(MAASTestCase):
22 options = self.parser.parse_args([])
23 self.assertIsNone(self.cmd(options))
24 self.assertEqual(stdout.getvalue(), "Mode: none\n")
25+
26+ def test_enable_debugging(self):
27+ mock_maas_configuration = self.patch(snappy, "MAASConfiguration")
28+ mock_sighup_supervisord = self.patch(snappy, "sighup_supervisord")
29+ options = self.parser.parse_args(["--enable-debug"])
30+ stdout = io.StringIO()
31+ self.patch(sys, "stdout", stdout)
32+
33+ self.cmd(options)
34+ mock_maas_configuration().update.assert_called_once_with(
35+ {"debug": True}
36+ )
37+ # After config is changed, services are restarted
38+ self.assertEqual(stdout.getvalue(), "Stopping services\n")
39+ mock_sighup_supervisord.assert_called_once_with()
40+
41+ def test_reenable_debugging(self):
42+ mock_maas_configuration = self.patch(snappy, "MAASConfiguration")
43+ config_manager = mock_maas_configuration()
44+ mock_sighup_supervisord = self.patch(snappy, "sighup_supervisord")
45+ options = self.parser.parse_args(["--enable-debug"])
46+ stdout = io.StringIO()
47+ self.patch(sys, "stdout", stdout)
48+
49+ # Simulate the value already being enabled
50+ current_config = config_manager.get()
51+ current_config.get.side_effect = {"debug": True}.__getitem__
52+
53+ self.cmd(options)
54+ config_manager.update.assert_not_called()
55+ self.assertEqual(stdout.getvalue(), "")
56+ mock_sighup_supervisord.assert_not_called()

Subscribers

People subscribed via source and target branches