Merge lp:~veebers/juju-ci-tools/update-omnibus-budget-commands into lp:juju-ci-tools

Proposed by Christopher Lee
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 2013
Merged at revision: 2010
Proposed branch: lp:~veebers/juju-ci-tools/update-omnibus-budget-commands
Merge into: lp:juju-ci-tools
Diff against target: 193 lines (+39/-25)
3 files modified
assess_budget.py (+15/-15)
tests/test_assess_budget.py (+5/-5)
tests/test_gotesttarfile.py (+19/-5)
To merge this branch: bzr merge lp:~veebers/juju-ci-tools/update-omnibus-budget-commands
Reviewer Review Type Date Requested Status
Nicholas Skaggs (community) Approve
Review via email: mp+323298@code.launchpad.net

Commit message

Update the commands used in assess_budget as per https://bugs.launchpad.net/juju/+bug/1675218.

Description of the change

Update the commands used in assess_budget as per https://bugs.launchpad.net/juju/+bug/1675218.

The terminology used in the test could be updated too, but for the sake of brevity and a sane diff I'll do this in a follow up MP.

To post a comment you must log in.
2013. By Christopher Lee

Fix name changes missed previously

Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Looks good, just make sure the tests tweaks are applied. Thanks!

review: Approve
2014. By Christopher Lee

Update tests.

2015. By Christopher Lee

Drive by fix for gotesttarfile test fixes.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'assess_budget.py'
2--- assess_budget.py 2017-02-16 21:50:30 +0000
3+++ assess_budget.py 2017-04-27 22:20:41 +0000
4@@ -42,13 +42,13 @@
5
6
7 def _get_budgets(client):
8- return json.loads(list_budgets(client))['budgets']
9+ return json.loads(list_budgets(client))['wallets']
10
11
12 def _set_budget_value_expectations(expected_budgets, name, value):
13 # Update our expectations accordingly
14 for budget in expected_budgets:
15- if budget['budget'] == name:
16+ if budget['wallet'] == name:
17 # For now, we assume we aren't spending down the budget
18 budget['limit'] = value
19 budget['unallocated'] = value
20@@ -64,8 +64,8 @@
21 output = [e.output, getattr(e, 'stderr', '')]
22 raise JujuAssertionError('Could not set budget {}'.format(output))
23
24- if 'budget limit updated' not in output:
25- raise JujuAssertionError('Error calling set-budget {}'.format(output))
26+ if 'wallet limit updated' not in output:
27+ raise JujuAssertionError('Error calling set-wallet {}'.format(output))
28
29
30 def _try_creating_budget(client, name, value):
31@@ -126,24 +126,24 @@
32
33 def create_budget(client, name, value):
34 """Create a budget"""
35- return client.get_juju_output('create-budget', name, value,
36+ return client.get_juju_output('create-wallet', name, value,
37 include_e=False)
38
39
40 def list_budgets(client):
41 """Return defined budgets as json."""
42- return client.get_juju_output('list-budgets', '--format', 'json',
43+ return client.get_juju_output('list-wallets', '--format', 'json',
44 include_e=False)
45
46
47 def set_budget(client, name, value):
48 """Change an existing budgets allocation."""
49- return client.get_juju_output('set-budget', name, value, include_e=False)
50+ return client.get_juju_output('set-wallet', name, value, include_e=False)
51
52
53 def show_budget(client, name):
54 """Return specified budget as json."""
55- return client.get_juju_output('show-budget', name, '--format', 'json',
56+ return client.get_juju_output('show-wallet', name, '--format', 'json',
57 include_e=False)
58
59
60@@ -151,7 +151,7 @@
61 # Since we can't remove budgets until lp:1663258
62 # is fixed, we avoid creating new random budgets and hardcode.
63 # We also, zero out the previous budget
64- budget_name = 'test'
65+ budget_name = 'personal'
66 _try_setting_budget(client, budget_name, '0')
67
68 budget_limit = _get_new_budget_limit(client)
69@@ -193,7 +193,7 @@
70
71
72 def assess_list_budgets(client, expected_budgets):
73- log.info('list-budgets testing expected values')
74+ log.info('list-wallets testing expected values')
75 # Since we can't remove budgets until lp:1663258
76 # is fixed, we don't modify the list contents or count
77 # Nonetheless, we assert on it for future use
78@@ -202,8 +202,8 @@
79
80
81 def assess_set_budget(client, budget_name, budget_value, budget_limit):
82- """Test set-budget command"""
83- log.info('set-budget "{}" with value {}, limit {}'.format(budget_name,
84+ """Test set-wallet command"""
85+ log.info('set-wallet "{}" with value {}, limit {}'.format(budget_name,
86 budget_value,
87 budget_limit))
88 _try_setting_budget(client, budget_name, budget_value)
89@@ -211,15 +211,15 @@
90 # Check some bounds
91 # Since budgetting is important, and the functional test is cheap,
92 # let's test some basic bounds
93- log.info('Trying set-budget with value greater than budget limit')
94+ log.info('Trying set-wallet with value greater than budget limit')
95 _try_greater_than_limit_budget(client, budget_name, budget_limit)
96
97- log.info('Trying set-budget with negative value')
98+ log.info('Trying set-wallet with negative value')
99 _try_negative_budget(client, budget_name)
100
101
102 def assess_show_budget(client, budget_name, budget_value):
103- log.info('show-budget "{}" with value {}'.format(budget_name,
104+ log.info('show-wallet "{}" with value {}'.format(budget_name,
105 budget_value))
106
107 budget = json.loads(show_budget(client, budget_name))
108
109=== modified file 'tests/test_assess_budget.py'
110--- tests/test_assess_budget.py 2017-02-16 21:50:30 +0000
111+++ tests/test_assess_budget.py 2017-04-27 22:20:41 +0000
112@@ -77,7 +77,7 @@
113 def setUp(self):
114 super(TestAssess, self).setUp()
115 self.fake_client = fake_juju_client()
116- self.budget_name = 'test'
117+ self.budget_name = 'personal'
118 self.budget_limit = randint(1000, 10000)
119 self.budget_value = str(randint(100, 900))
120
121@@ -179,12 +179,12 @@
122
123 def setUp(self):
124 super(TestAssessListBudgets, self).setUp()
125- snippet = '[{"budget": "test", "limit": "300"}]'
126- self.fake_budgets_json = json.loads('{"budgets":' + snippet + '}')
127+ snippet = '[{"wallet": "personal", "limit": "300"}]'
128+ self.fake_budgets_json = json.loads('{"wallets":' + snippet + '}')
129 self.fake_budget_json = json.loads(snippet)
130- unexpected_snippet = '[{"budget": "test", "limit": "100"}]'
131+ unexpected_snippet = '[{"wallet": "personal", "limit": "100"}]'
132 self.fake_unexpected_budgets_json = json.loads(
133- '{"budgets":' + unexpected_snippet + '}')
134+ '{"wallets":' + unexpected_snippet + '}')
135 self.fake_unexpected_budget_json = json.loads(unexpected_snippet)
136
137 def test_assess_list_budgets(self):
138
139=== modified file 'tests/test_gotesttarfile.py'
140--- tests/test_gotesttarfile.py 2016-07-15 17:38:07 +0000
141+++ tests/test_gotesttarfile.py 2017-04-27 22:20:41 +0000
142@@ -69,10 +69,14 @@
143 returncode = go_test_package(
144 'github.com/juju/juju', 'go', gopath)
145 self.assertEqual(0, returncode)
146- self.assertEqual(run_mock.call_count, 3)
147+ self.assertEqual(run_mock.call_count, 5)
148 args, kwargs = run_mock.call_args_list[0]
149+ self.assertEqual((['go', 'version'],), args)
150+ args, kwargs = run_mock.call_args_list[1]
151+ self.assertEqual((['go', 'env'],), args)
152+ args, kwargs = run_mock.call_args_list[2]
153 self.assertEqual((['go', 'test', '-i', './...'],), args)
154- args, kwargs = run_mock.call_args_list[1]
155+ args, kwargs = run_mock.call_args_list[3]
156 self.assertEqual(
157 (['go', 'test', '-timeout=1200s', './...'],), args)
158 self.assertEqual('amd64', kwargs['env'].get('GOARCH'))
159@@ -94,12 +98,18 @@
160 returncode = go_test_package(
161 'github.com/juju/juju', 'go', gopath)
162 self.assertEqual(0, returncode)
163- self.assertEqual(run_mock.call_count, 3)
164+ self.assertEqual(run_mock.call_count, 5)
165 args, kwargs = run_mock.call_args_list[0]
166 self.assertEqual(
167+ (['powershell.exe', '-Command', 'go', 'version'],),
168+ args)
169+ args, kwargs = run_mock.call_args_list[1]
170+ self.assertEqual((['powershell.exe', '-Command', 'go', 'env'],), args)
171+ args, kwargs = run_mock.call_args_list[2]
172+ self.assertEqual(
173 (['powershell.exe', '-Command', 'go', 'test', '-i', './...'], ),
174 args)
175- args, kwargs = run_mock.call_args_list[1]
176+ args, kwargs = run_mock.call_args_list[3]
177 self.assertEqual(
178 (['powershell.exe', '-Command', 'go', 'test',
179 '-timeout=1200s', './...'], ),
180@@ -124,8 +134,12 @@
181 returncode = go_test_package(
182 'github.com/juju/juju', 'go', gopath)
183 self.assertEqual(1, returncode)
184- self.assertEqual(run_mock.call_count, 1)
185+ self.assertEqual(run_mock.call_count, 3)
186 args, kwargs = run_mock.call_args_list[0]
187+ self.assertEqual((['go', 'version'],), args)
188+ args, kwargs = run_mock.call_args_list[1]
189+ self.assertEqual((['go', 'env'],), args)
190+ args, kwargs = run_mock.call_args_list[2]
191 self.assertEqual((['go', 'test', '-i', './...'],), args)
192
193 def test_parse_args(self):

Subscribers

People subscribed via source and target branches