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
diff --git a/src/maascli/snappy.py b/src/maascli/snappy.py
index e58b8ee..48fc267 100644
--- a/src/maascli/snappy.py
+++ b/src/maascli/snappy.py
@@ -819,11 +819,6 @@ class cmd_config(SnappyCommand):
819 # Validate the mode and flags.819 # Validate the mode and flags.
820 self._validate_flags(options, running_mode)820 self._validate_flags(options, running_mode)
821821
822 if options.mode != running_mode:
823 render_supervisord(options.mode)
824 set_current_mode(options.mode)
825 restart_required = True
826
827 current_config = config_manager.get()822 current_config = config_manager.get()
828 # Only update the passed settings.823 # Only update the passed settings.
829 for flag in self.setting_flags:824 for flag in self.setting_flags:
diff --git a/src/maascli/tests/test_snappy.py b/src/maascli/tests/test_snappy.py
index 95458f7..8ef6f5b 100644
--- a/src/maascli/tests/test_snappy.py
+++ b/src/maascli/tests/test_snappy.py
@@ -592,3 +592,35 @@ class TestCmdConfig(MAASTestCase):
592 options = self.parser.parse_args([])592 options = self.parser.parse_args([])
593 self.assertIsNone(self.cmd(options))593 self.assertIsNone(self.cmd(options))
594 self.assertEqual(stdout.getvalue(), "Mode: none\n")594 self.assertEqual(stdout.getvalue(), "Mode: none\n")
595
596 def test_enable_debugging(self):
597 mock_maas_configuration = self.patch(snappy, "MAASConfiguration")
598 mock_sighup_supervisord = self.patch(snappy, "sighup_supervisord")
599 options = self.parser.parse_args(["--enable-debug"])
600 stdout = io.StringIO()
601 self.patch(sys, "stdout", stdout)
602
603 self.cmd(options)
604 mock_maas_configuration().update.assert_called_once_with(
605 {"debug": True}
606 )
607 # After config is changed, services are restarted
608 self.assertEqual(stdout.getvalue(), "Stopping services\n")
609 mock_sighup_supervisord.assert_called_once_with()
610
611 def test_reenable_debugging(self):
612 mock_maas_configuration = self.patch(snappy, "MAASConfiguration")
613 config_manager = mock_maas_configuration()
614 mock_sighup_supervisord = self.patch(snappy, "sighup_supervisord")
615 options = self.parser.parse_args(["--enable-debug"])
616 stdout = io.StringIO()
617 self.patch(sys, "stdout", stdout)
618
619 # Simulate the value already being enabled
620 current_config = config_manager.get()
621 current_config.get.side_effect = {"debug": True}.__getitem__
622
623 self.cmd(options)
624 config_manager.update.assert_not_called()
625 self.assertEqual(stdout.getvalue(), "")
626 mock_sighup_supervisord.assert_not_called()

Subscribers

People subscribed via source and target branches