Merge lp:~rharding/juju-gui/bundle-sandbox-noop into lp:juju-gui/experimental

Proposed by Richard Harding
Status: Merged
Merged at revision: 1206
Proposed branch: lp:~rharding/juju-gui/bundle-sandbox-noop
Merge into: lp:juju-gui/experimental
Diff against target: 284 lines (+137/-15)
8 files modified
app/assets/javascripts/bundle-import-helpers.js (+2/-2)
app/store/env/fakebackend.js (+38/-0)
app/store/env/go.js (+8/-8)
app/store/env/sandbox.js (+27/-0)
test/test_bundle_import_helpers.js (+3/-3)
test/test_env_go.js (+1/-1)
test/test_fakebackend.js (+22/-0)
test/test_sandbox_go.js (+36/-1)
To merge this branch: bzr merge lp:~rharding/juju-gui/bundle-sandbox-noop
Reviewer Review Type Date Requested Status
Juju GUI Hackers Pending
Review via email: mp+196000@code.launchpad.net

Description of the change

fakebackend/sandbox no op deployer watches

- The fakebackend and the sandbox need to just ignore calls to watch deployer
status. It's too fast and we don't want to flood the users with a bunch of
notices all at once.
- Had to rename the WatchUpdate to deployerNext since the fakebackend auto
builds the names of the handle methods based off the actual call. So it needed
to be deployerNext though I hate it's no longer worded to tie to 'watch'.

QA:

Simply deploy a bundle in sandbox mode.

- Drag/drop a yaml file into the canvas
- Deploy from the deploy button from bundle details

Note: Dragging/dropping a bundle token is not working. This is also true on
coming soon. This is due to the recent bundle.id tracking code and will be
done in a follow up.

https://codereview.appspot.com/29860044/

To post a comment you must log in.
Revision history for this message
Richard Harding (rharding) wrote :

Reviewers: mp+196000_code.launchpad.net,

Message:
Please take a look.

Description:
fakebackend/sandbox no op deployer watches

- The fakebackend and the sandbox need to just ignore calls to watch
deployer
status. It's too fast and we don't want to flood the users with a bunch
of
notices all at once.
- Had to rename the WatchUpdate to deployerNext since the fakebackend
auto
builds the names of the handle methods based off the actual call. So it
needed
to be deployerNext though I hate it's no longer worded to tie to
'watch'.
- Drive by fix for deploying a bundle via drag-n-drop.

QA:

Simply deploy a bundle in sandbox mode.

- Drag/drop a yaml file into the canvas
- Deploy from the deploy button from bundle details
-

Note: Dragging/dropping a bundle token is not working. This is also true
on
coming soon. This is due to the recent bundle.id tracking code and will
be
done in a follow up.

https://code.launchpad.net/~rharding/juju-gui/bundle-sandbox-noop/+merge/196000

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/29860044/

Affected files (+139, -15 lines):
   A [revision details]
   M app/assets/javascripts/bundle-import-helpers.js
   M app/store/env/fakebackend.js
   M app/store/env/go.js
   M app/store/env/sandbox.js
   M test/test_bundle_import_helpers.js
   M test/test_env_go.js
   M test/test_fakebackend.js
   M test/test_sandbox_go.js

Revision history for this message
Brad Crittenden (bac) wrote :

LGTM with some crazy nit-picking mess.

https://codereview.appspot.com/29860044/diff/20001/app/store/env/fakebackend.js
File app/store/env/fakebackend.js (right):

https://codereview.appspot.com/29860044/diff/20001/app/store/env/fakebackend.js#newcode1592
app/store/env/fakebackend.js:1592: This method is a noop in the
fakebackend. We've already sent the user a
noon looks too much like noob.

Pick one of 'no op' or 'no-op' throughout.

https://codereview.appspot.com/29860044/diff/20001/test/test_fakebackend.js
File test/test_fakebackend.js (right):

https://codereview.appspot.com/29860044/diff/20001/test/test_fakebackend.js#newcode740
test/test_fakebackend.js:740: // This is no op'd in the fakebackend
since it doens't make sense to
typo: doesn't

https://codereview.appspot.com/29860044/diff/20001/test/test_fakebackend.js#newcode741
test/test_fakebackend.js:741: // provide a watch status as things happen
near instantly.
grammar-o: nearly

https://codereview.appspot.com/29860044/diff/20001/test/test_fakebackend.js#newcode744
test/test_fakebackend.js:744: assert.fail('The watcher callback shoould
never be called.');
shoooooooould

https://codereview.appspot.com/29860044/diff/20001/test/test_fakebackend.js#newcode751
test/test_fakebackend.js:751: // This is no op'd in the fakebackend
since it doens't make sense to
Dang, on a roll!

https://codereview.appspot.com/29860044/diff/20001/test/test_fakebackend.js#newcode752
test/test_fakebackend.js:752: // provide a watch status as things happen
near instantly.
ditto

https://codereview.appspot.com/29860044/diff/20001/test/test_fakebackend.js#newcode755
test/test_fakebackend.js:755: assert.fail('The watcher update callback
shoould never be called.');
and again

https://codereview.appspot.com/29860044/

Revision history for this message
Richard Harding (rharding) wrote :
1205. By Richard Harding

Fix all the engrish

Revision history for this message
Richard Harding (rharding) wrote :

*** Submitted:

fakebackend/sandbox no op deployer watches

- The fakebackend and the sandbox need to just ignore calls to watch
deployer
status. It's too fast and we don't want to flood the users with a bunch
of
notices all at once.
- Had to rename the WatchUpdate to deployerNext since the fakebackend
auto
builds the names of the handle methods based off the actual call. So it
needed
to be deployerNext though I hate it's no longer worded to tie to
'watch'.

QA:

Simply deploy a bundle in sandbox mode.

- Drag/drop a yaml file into the canvas
- Deploy from the deploy button from bundle details

Note: Dragging/dropping a bundle token is not working. This is also true
on
coming soon. This is due to the recent bundle.id tracking code and will
be
done in a follow up.

R=bac
CC=
https://codereview.appspot.com/29860044

https://codereview.appspot.com/29860044/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/assets/javascripts/bundle-import-helpers.js'
2--- app/assets/javascripts/bundle-import-helpers.js 2013-11-19 16:54:54 +0000
3+++ app/assets/javascripts/bundle-import-helpers.js 2013-11-20 19:38:27 +0000
4@@ -234,14 +234,14 @@
5 // There's nothing else to see here.
6 return;
7 } else {
8- env.deployerWatchUpdate(watchId, processUpdate);
9+ env.deployerNext(watchId, processUpdate);
10 }
11 }
12 };
13
14 // Make the first call to the env and the processUpdate callback will
15 // handle re-calling on each update.
16- env.deployerWatchUpdate(watchId, processUpdate);
17+ env.deployerNext(watchId, processUpdate);
18 }
19
20 };
21
22=== modified file 'app/store/env/fakebackend.js'
23--- app/store/env/fakebackend.js 2013-11-08 18:57:35 +0000
24+++ app/store/env/fakebackend.js 2013-11-20 19:38:27 +0000
25@@ -1584,6 +1584,44 @@
26 return callback(UNAUTHENTICATED_ERROR);
27 }
28 callback({LastChanges: this._importChanges});
29+ },
30+
31+ /**
32+ *no op* Create a watcher for the deployment specified.
33+
34+ This method is a no op in the fakebackend. We've already sent the user a
35+ notification that things are complete in the normal deployer call.
36+ There's no time to get a watcher and send/sync the watch update down
37+ the road.
38+
39+ @method deployerWatch
40+ @param {Integer} deploymentId The id of the deployment the watch is
41+ for.
42+ @param {Function} callback The callback to send the watcherId to.
43+
44+ */
45+ deployerWatch: function(deploymentId, callback) {
46+ // No op in the fakebackend. Just return and ignore the callback.
47+ return;
48+ },
49+
50+ /**
51+ *no op* Perform a check for updates of a given deployment watcher.
52+
53+ This should never be called and is provided just to aid in grep-ability
54+ of the codebase. Typically this is called via the callback in the
55+ deployerWatch function.
56+
57+
58+ @method deployerNext
59+ @param {Integer} watcherId The id of the watcher from deployerWatch
60+ @param {Function} callback The callback to handle the update response
61+ from the deployer information.
62+
63+ */
64+ deployerNext: function(watcherId, callback) {
65+ // No op in the fakebackend. Just return and ignore the callback.
66+ return;
67 }
68
69 });
70
71=== modified file 'app/store/env/go.js'
72--- app/store/env/go.js 2013-11-18 18:25:08 +0000
73+++ app/store/env/go.js 2013-11-20 19:38:27 +0000
74@@ -554,15 +554,15 @@
75 The callback will receive an {Object} An object with err, and the
76 list of Changes.
77
78- @method deployerWatchUpdate
79+ @method deployerNext
80 @param {Integer} watchId The ID of the watcher created in depployWatch.
81 @param {Function} callback The caller's callback function to process
82 the response.
83 */
84- deployerWatchUpdate: function(watchId, callback) {
85+ deployerNext: function(watchId, callback) {
86 var intermediateCallback;
87 if (callback) {
88- intermediateCallback = Y.bind(this.handleDeployerWatchUpdate,
89+ intermediateCallback = Y.bind(this.handleDeployerNext,
90 this, callback);
91 }
92
93@@ -576,15 +576,15 @@
94 },
95
96 /**
97- Wrapper for the deployerWatchUpdate call.
98+ Wrapper for the deployerNext call.
99
100- @method handleDeployerWatchUpdate
101+ @method handleDeployerNext
102 @param {Function} userCallback The original callback to the
103- deployerWatchUpdate function.
104- @param {Object} data The servers response to the deployerWatchUpdate
105+ deployerNext function.
106+ @param {Object} data The servers response to the deployerNext
107 call.
108 */
109- handleDeployerWatchUpdate: function(userCallback, data) {
110+ handleDeployerNext: function(userCallback, data) {
111 var transformedData = {
112 err: data.Error,
113 Changes: data.Response.Changes
114
115=== modified file 'app/store/env/sandbox.js'
116--- app/store/env/sandbox.js 2013-11-19 22:30:18 +0000
117+++ app/store/env/sandbox.js 2013-11-20 19:38:27 +0000
118@@ -1347,7 +1347,34 @@
119 state.statusDeployer(Y.bind(callback, this));
120 },
121
122+ /**
123+ * *no op* Handle the response from a deployerWatch call from the backend.
124+ *
125+ * @method handleDeployerWatch
126+ * @param {Object} data The contents of the API arguments.
127+ * @param {Object} client The active ClientConnection.
128+ * @param {Object} state An instance of FakeBackend.
129+ * @return {undefined} Side effects only.
130+ *
131+ */
132+ handleDeployerWatch: function(data, client, state) {
133+ return;
134+ },
135
136+ /**
137+ * *no op* Handle the response from a deployerNext call from the
138+ * backend.
139+ *
140+ * @method handleDeployerNext
141+ * @param {Object} data The contents of the API arguments.
142+ * @param {Object} client The active ClientConnection.
143+ * @param {Object} state An instance of FakeBackend.
144+ * @return {undefined} Side effects only.
145+ *
146+ */
147+ handleDeployerNext: function(data, client, state) {
148+ return;
149+ },
150
151 /**
152 Handle SetAnnotations messages
153
154=== modified file 'test/test_bundle_import_helpers.js'
155--- test/test_bundle_import_helpers.js 2013-11-19 16:54:54 +0000
156+++ test/test_bundle_import_helpers.js 2013-11-20 19:38:27 +0000
157@@ -139,7 +139,7 @@
158 };
159
160 var called = false;
161- env.deployerWatchUpdate = function(watchId, callback) {
162+ env.deployerNext = function(watchId, callback) {
163 if (!called) {
164 called = true;
165 callback({
166@@ -192,7 +192,7 @@
167 done();
168 };
169
170- env.deployerWatchUpdate = function(watchId, callback) {
171+ env.deployerNext = function(watchId, callback) {
172 callback({
173 err: undefined,
174 Changes: [
175@@ -239,7 +239,7 @@
176 };
177
178 var updated = false;
179- env.deployerWatchUpdate = function(watchId, callback) {
180+ env.deployerNext = function(watchId, callback) {
181 if (!updated) {
182 updated = true;
183 callback({
184
185=== modified file 'test/test_env_go.js'
186--- test/test_env_go.js 2013-11-13 21:56:04 +0000
187+++ test/test_env_go.js 2013-11-20 19:38:27 +0000
188@@ -368,7 +368,7 @@
189 });
190
191 it('builds a proper watch next request', function() {
192- env.deployerWatchUpdate(5);
193+ env.deployerNext(5);
194 var last_message = conn.last_message();
195 var expected = {
196 Type: 'Deployer',
197
198=== modified file 'test/test_fakebackend.js'
199--- test/test_fakebackend.js 2013-11-08 18:57:35 +0000
200+++ test/test_fakebackend.js 2013-11-20 19:38:27 +0000
201@@ -735,6 +735,28 @@
202 done();
203 }).then(undefined, done);
204 });
205+
206+ it('should ignore calls to the deployer watcher', function(done) {
207+ // This is no op'd in the fakebackend since it doesn't make sense to
208+ // provide a watch status as things happen nearly instantly.
209+ fakebackend.deployerWatch(10, function(reply) {
210+ // Should never be called.
211+ assert.fail('The watcher callback should never be called.');
212+ });
213+
214+ done();
215+ });
216+
217+ it('should ignore calls to the watcher updater', function(done) {
218+ // This is no op'd in the fakebackend since it doens't make sense to
219+ // provide a watch status as things happen nearly instantly.
220+ fakebackend.deployerWatch(10, function(reply) {
221+ // Should never be called.
222+ assert.fail('The watcher update callback should never be called.');
223+ });
224+ done();
225+ });
226+
227 });
228
229 describe('FakeBackend.uniformOperations', function() {
230
231=== modified file 'test/test_sandbox_go.js'
232--- test/test_sandbox_go.js 2013-10-31 18:40:57 +0000
233+++ test/test_sandbox_go.js 2013-11-20 19:38:27 +0000
234@@ -1242,7 +1242,6 @@
235 env.deployerImport(fixture, null, callback);
236 });
237
238-
239 it('should support deployer status without imports', function(done) {
240 var data = {
241 Type: 'Deployer',
242@@ -1261,6 +1260,42 @@
243 client.send(Y.JSON.stringify(data));
244 });
245
246+ it('should not deal with deployer watches', function(done) {
247+ var data = {
248+ Type: 'Deployer',
249+ Request: 'Watch',
250+ Params: {
251+ DeploymentId: 10
252+ },
253+ RequestId: 42
254+ };
255+ client.onmessage = function(received) {
256+ assert.fail('Should never get a response.');
257+ };
258+ client.open();
259+ client.send(Y.JSON.stringify(data));
260+
261+ done();
262+ });
263+
264+ it('should not deal with watch updates', function(done) {
265+ var data = {
266+ Type: 'Deployer',
267+ Request: 'Next',
268+ Params: {
269+ WatcherId: 11
270+ },
271+ RequestId: 42
272+ };
273+ client.onmessage = function(received) {
274+ assert.fail('Should never get a response.');
275+ };
276+ client.open();
277+ client.send(Y.JSON.stringify(data));
278+
279+ done();
280+ });
281+
282 });
283
284 })();

Subscribers

People subscribed via source and target branches