Merge ~ltrager/maas:lp1822173 into maas:master
- Git
- lp:~ltrager/maas
- lp1822173
- Merge into master
Status: | Merged |
---|---|
Approved by: | Lee Trager |
Approved revision: | 5cf138a9538bcba384684b6940cacdaa526481c4 |
Merge reported by: | MAAS Lander |
Merged at revision: | not available |
Proposed branch: | ~ltrager/maas:lp1822173 |
Merge into: | maas:master |
Diff against target: |
179 lines (+51/-50) 2 files modified
src/maasserver/node_action.py (+8/-1) src/maasserver/tests/test_node_action.py (+43/-49) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Andres Rodriguez (community) | Needs Fixing | ||
Alberto Donato (community) | Approve | ||
Review via email: mp+366158@code.launchpad.net |
Commit message
LP: #1822173 - Set osystem and distro series to default when none given over the websocket.
Description of the change
MAAS Lander (maas-lander) wrote : | # |
LANDING
-b lp1822173 lp:~ltrager/maas/+git/maas into -b master lp:~maas-committers/maas
STATUS: FAILED BUILD
LOG: http://
Andres Rodriguez (andreserl) wrote : | # |
=======
ERROR: maasserver.
-------
Traceback (most recent call last):
testtools.
Twisted logs
Traceback (most recent call last):
File "/run/build/
self.
File "/run/build/
raise ValidationError('%s has no kernels available.' % distro_series)
django.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/run/build/
result = function(*args, **kwargs)
File "/home/
return self._get_
File "/run/build/
Deploy(node, user, request).execute()
File "/run/build/
self.
File "/run/build/
raise NodeActionError(e)
maasserver.
=======
ERROR: maasserver.
-------
Traceback (most recent call last):
testtools.
Twisted logs
Traceback (most recent call last):
File "/run/build/
self.
File "/run/build/
raise ValidationError('%s has no kernels available.' % distro_series)
django.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/run/build/
result = function(*args, **kwargs)
File "/home/
return self._get_
File "/run/build/
action.
File "/run/build/
self.
File "/run/build/
raise NodeActionError(e)
maasserver.
-------
maas.node: info: ...
MAAS Lander (maas-lander) wrote : | # |
LANDING
-b lp1822173 lp:~ltrager/maas/+git/maas into -b master lp:~maas-committers/maas
STATUS: FAILED BUILD
LOG: http://
- 5cf138a... by Lee Trager
-
Fix broken tests
Preview Diff
1 | diff --git a/src/maasserver/node_action.py b/src/maasserver/node_action.py | |||
2 | index 5402ea2..e969138 100644 | |||
3 | --- a/src/maasserver/node_action.py | |||
4 | +++ b/src/maasserver/node_action.py | |||
5 | @@ -1,4 +1,4 @@ | |||
7 | 1 | # Copyright 2012-2018 Canonical Ltd. This software is licensed under the | 1 | # Copyright 2012-2019 Canonical Ltd. This software is licensed under the |
8 | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). |
9 | 3 | 3 | ||
10 | 4 | """Node actions. | 4 | """Node actions. |
11 | @@ -44,6 +44,7 @@ from maasserver.exceptions import ( | |||
12 | 44 | StaticIPAddressExhaustion, | 44 | StaticIPAddressExhaustion, |
13 | 45 | ) | 45 | ) |
14 | 46 | from maasserver.models import ( | 46 | from maasserver.models import ( |
15 | 47 | Config, | ||
16 | 47 | ResourcePool, | 48 | ResourcePool, |
17 | 48 | Tag, | 49 | Tag, |
18 | 49 | Zone, | 50 | Zone, |
19 | @@ -476,6 +477,12 @@ class Deploy(NodeAction): | |||
20 | 476 | self.node.save() | 477 | self.node.save() |
21 | 477 | except ValidationError as e: | 478 | except ValidationError as e: |
22 | 478 | raise NodeActionError(e) | 479 | raise NodeActionError(e) |
23 | 480 | else: | ||
24 | 481 | configs = Config.objects.get_configs( | ||
25 | 482 | ['default_osystem', 'default_distro_series']) | ||
26 | 483 | self.node.osystem = configs['default_osystem'] | ||
27 | 484 | self.node.distro_series = configs['default_distro_series'] | ||
28 | 485 | self.node.save() | ||
29 | 479 | try: | 486 | try: |
30 | 480 | self.node.hwe_kernel = validate_hwe_kernel( | 487 | self.node.hwe_kernel = validate_hwe_kernel( |
31 | 481 | hwe_kernel, self.node.min_hwe_kernel, | 488 | hwe_kernel, self.node.min_hwe_kernel, |
32 | diff --git a/src/maasserver/tests/test_node_action.py b/src/maasserver/tests/test_node_action.py | |||
33 | index 56ace53..8365260 100644 | |||
34 | --- a/src/maasserver/tests/test_node_action.py | |||
35 | +++ b/src/maasserver/tests/test_node_action.py | |||
36 | @@ -1,4 +1,4 @@ | |||
38 | 1 | # Copyright 2012-2018 Canonical Ltd. This software is licensed under the | 1 | # Copyright 2012-2019 Canonical Ltd. This software is licensed under the |
39 | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). |
40 | 3 | 3 | ||
41 | 4 | """Tests for node actions.""" | 4 | """Tests for node actions.""" |
42 | @@ -26,6 +26,7 @@ from maasserver.enum import ( | |||
43 | 26 | ) | 26 | ) |
44 | 27 | from maasserver.exceptions import NodeActionError | 27 | from maasserver.exceptions import NodeActionError |
45 | 28 | from maasserver.models import ( | 28 | from maasserver.models import ( |
46 | 29 | Config, | ||
47 | 29 | Event, | 30 | Event, |
48 | 30 | signals, | 31 | signals, |
49 | 31 | StaticIPAddress, | 32 | StaticIPAddress, |
50 | @@ -65,10 +66,7 @@ from maasserver.node_status import ( | |||
51 | 65 | ) | 66 | ) |
52 | 66 | from maasserver.permissions import NodePermission | 67 | from maasserver.permissions import NodePermission |
53 | 67 | from maasserver.testing.factory import factory | 68 | from maasserver.testing.factory import factory |
58 | 68 | from maasserver.testing.osystems import ( | 69 | from maasserver.testing.osystems import make_usable_osystem |
55 | 69 | make_osystem_with_releases, | ||
56 | 70 | make_usable_osystem, | ||
57 | 71 | ) | ||
59 | 72 | from maasserver.testing.testcase import ( | 70 | from maasserver.testing.testcase import ( |
60 | 73 | MAASServerTestCase, | 71 | MAASServerTestCase, |
61 | 74 | MAASTransactionServerTestCase, | 72 | MAASTransactionServerTestCase, |
62 | @@ -598,6 +596,11 @@ class TestDeployAction(MAASServerTestCase): | |||
63 | 598 | mock_get_curtin_config = self.patch( | 596 | mock_get_curtin_config = self.patch( |
64 | 599 | node_action_module, 'get_curtin_config') | 597 | node_action_module, 'get_curtin_config') |
65 | 600 | mock_node_start = self.patch(node, 'start') | 598 | mock_node_start = self.patch(node, 'start') |
66 | 599 | osystem = make_usable_osystem(self) | ||
67 | 600 | os_name = osystem["name"] | ||
68 | 601 | release_name = osystem["releases"][0]["name"] | ||
69 | 602 | Config.objects.set_config('default_osystem', os_name) | ||
70 | 603 | Config.objects.set_config('default_distro_series', release_name) | ||
71 | 601 | Deploy(node, user, request).execute() | 604 | Deploy(node, user, request).execute() |
72 | 602 | self.expectThat( | 605 | self.expectThat( |
73 | 603 | mock_get_curtin_config, MockCalledOnceWith(ANY, node)) | 606 | mock_get_curtin_config, MockCalledOnceWith(ANY, node)) |
74 | @@ -617,6 +620,11 @@ class TestDeployAction(MAASServerTestCase): | |||
75 | 617 | mock_get_curtin_config = self.patch( | 620 | mock_get_curtin_config = self.patch( |
76 | 618 | node_action_module, 'get_curtin_config') | 621 | node_action_module, 'get_curtin_config') |
77 | 619 | mock_get_curtin_config.side_effect = NodeActionError('error') | 622 | mock_get_curtin_config.side_effect = NodeActionError('error') |
78 | 623 | osystem = make_usable_osystem(self) | ||
79 | 624 | os_name = osystem["name"] | ||
80 | 625 | release_name = osystem["releases"][0]["name"] | ||
81 | 626 | Config.objects.set_config('default_osystem', os_name) | ||
82 | 627 | Config.objects.set_config('default_distro_series', release_name) | ||
83 | 620 | error = self.assertRaises( | 628 | error = self.assertRaises( |
84 | 621 | NodeActionError, Deploy(node, user, request).execute) | 629 | NodeActionError, Deploy(node, user, request).execute) |
85 | 622 | self.assertEqual( | 630 | self.assertEqual( |
86 | @@ -668,6 +676,31 @@ class TestDeployAction(MAASServerTestCase): | |||
87 | 668 | self.expectThat( | 676 | self.expectThat( |
88 | 669 | node.distro_series, Equals(release_name)) | 677 | node.distro_series, Equals(release_name)) |
89 | 670 | 678 | ||
90 | 679 | def test_Deploy_sets_osystem_and_series_to_default(self): | ||
91 | 680 | # Regression test for LP:1822173 | ||
92 | 681 | user = factory.make_User() | ||
93 | 682 | request = factory.make_fake_request('/') | ||
94 | 683 | request.user = user | ||
95 | 684 | node = factory.make_Node( | ||
96 | 685 | interface=True, status=NODE_STATUS.ALLOCATED, | ||
97 | 686 | power_type='manual', owner=user) | ||
98 | 687 | mock_get_curtin_config = self.patch( | ||
99 | 688 | node_action_module, 'get_curtin_config') | ||
100 | 689 | mock_node_start = self.patch(node, 'start') | ||
101 | 690 | osystem = make_usable_osystem(self) | ||
102 | 691 | os_name = osystem["name"] | ||
103 | 692 | release_name = osystem["releases"][0]["name"] | ||
104 | 693 | Config.objects.set_config('default_osystem', os_name) | ||
105 | 694 | Config.objects.set_config('default_distro_series', release_name) | ||
106 | 695 | Deploy(node, user, request).execute() | ||
107 | 696 | self.expectThat( | ||
108 | 697 | mock_get_curtin_config, MockCalledOnceWith(ANY, node)) | ||
109 | 698 | self.expectThat( | ||
110 | 699 | mock_node_start, MockCalledOnceWith(user)) | ||
111 | 700 | self.expectThat(node.osystem, Equals(os_name)) | ||
112 | 701 | self.expectThat( | ||
113 | 702 | node.distro_series, Equals(release_name)) | ||
114 | 703 | |||
115 | 671 | def test_Deploy_sets_install_kvm_and_osystem_series_if_specified(self): | 704 | def test_Deploy_sets_install_kvm_and_osystem_series_if_specified(self): |
116 | 672 | user = factory.make_admin() | 705 | user = factory.make_admin() |
117 | 673 | request = factory.make_fake_request('/') | 706 | request = factory.make_fake_request('/') |
118 | @@ -754,50 +787,6 @@ class TestDeployAction(MAASServerTestCase): | |||
119 | 754 | self.expectThat( | 787 | self.expectThat( |
120 | 755 | node.distro_series, Equals(release_name)) | 788 | node.distro_series, Equals(release_name)) |
121 | 756 | 789 | ||
122 | 757 | def test_Deploy_doesnt_set_osystem_and_series_if_os_missing(self): | ||
123 | 758 | user = factory.make_User() | ||
124 | 759 | request = factory.make_fake_request('/') | ||
125 | 760 | request.user = user | ||
126 | 761 | node = factory.make_Node( | ||
127 | 762 | interface=True, status=NODE_STATUS.ALLOCATED, | ||
128 | 763 | power_type='manual', owner=user) | ||
129 | 764 | mock_get_curtin_config = self.patch( | ||
130 | 765 | node_action_module, 'get_curtin_config') | ||
131 | 766 | mock_node_start = self.patch(node, 'start') | ||
132 | 767 | osystem = make_osystem_with_releases(self) | ||
133 | 768 | extra = { | ||
134 | 769 | "distro_series": osystem["releases"][0]["name"], | ||
135 | 770 | } | ||
136 | 771 | Deploy(node, user, request).execute(**extra) | ||
137 | 772 | self.expectThat( | ||
138 | 773 | mock_get_curtin_config, MockCalledOnceWith(ANY, node)) | ||
139 | 774 | self.expectThat( | ||
140 | 775 | mock_node_start, MockCalledOnceWith(user)) | ||
141 | 776 | self.expectThat(node.osystem, Equals("")) | ||
142 | 777 | self.expectThat(node.distro_series, Equals("")) | ||
143 | 778 | |||
144 | 779 | def test_Deploy_doesnt_set_osystem_and_series_if_series_missing(self): | ||
145 | 780 | user = factory.make_User() | ||
146 | 781 | request = factory.make_fake_request('/') | ||
147 | 782 | request.user = user | ||
148 | 783 | node = factory.make_Node( | ||
149 | 784 | interface=True, status=NODE_STATUS.ALLOCATED, | ||
150 | 785 | power_type='manual', owner=user) | ||
151 | 786 | mock_get_curtin_config = self.patch( | ||
152 | 787 | node_action_module, 'get_curtin_config') | ||
153 | 788 | mock_node_start = self.patch(node, 'start') | ||
154 | 789 | osystem = make_osystem_with_releases(self) | ||
155 | 790 | extra = { | ||
156 | 791 | "osystem": osystem["name"], | ||
157 | 792 | } | ||
158 | 793 | Deploy(node, user, request).execute(**extra) | ||
159 | 794 | self.expectThat( | ||
160 | 795 | mock_get_curtin_config, MockCalledOnceWith(ANY, node)) | ||
161 | 796 | self.expectThat( | ||
162 | 797 | mock_node_start, MockCalledOnceWith(user)) | ||
163 | 798 | self.expectThat(node.osystem, Equals("")) | ||
164 | 799 | self.expectThat(node.distro_series, Equals("")) | ||
165 | 800 | |||
166 | 801 | def test_Deploy_allocates_node_if_node_not_already_allocated(self): | 790 | def test_Deploy_allocates_node_if_node_not_already_allocated(self): |
167 | 802 | user = factory.make_User() | 791 | user = factory.make_User() |
168 | 803 | request = factory.make_fake_request('/') | 792 | request = factory.make_fake_request('/') |
169 | @@ -806,6 +795,11 @@ class TestDeployAction(MAASServerTestCase): | |||
170 | 806 | mock_get_curtin_config = self.patch( | 795 | mock_get_curtin_config = self.patch( |
171 | 807 | node_action_module, 'get_curtin_config') | 796 | node_action_module, 'get_curtin_config') |
172 | 808 | mock_node_start = self.patch(node, 'start') | 797 | mock_node_start = self.patch(node, 'start') |
173 | 798 | osystem = make_usable_osystem(self) | ||
174 | 799 | os_name = osystem["name"] | ||
175 | 800 | release_name = osystem["releases"][0]["name"] | ||
176 | 801 | Config.objects.set_config('default_osystem', os_name) | ||
177 | 802 | Config.objects.set_config('default_distro_series', release_name) | ||
178 | 809 | action = Deploy(node, user, request) | 803 | action = Deploy(node, user, request) |
179 | 810 | action.execute() | 804 | action.execute() |
180 | 811 | 805 |
LGTM, +1