Merge lp:~ralsina/ubuntu-push/server-limits-doc into lp:ubuntu-push
- server-limits-doc
- Merge into trunk
Proposed by
Roberto Alsina
Status: | Superseded |
---|---|
Proposed branch: | lp:~ralsina/ubuntu-push/server-limits-doc |
Merge into: | lp:ubuntu-push |
Diff against target: |
554 lines (+146/-51) 15 files modified
PACKAGE_DEPS (+1/-0) client/service/service.go (+2/-0) client/service/service_test.go (+17/-0) client/session/session.go (+3/-3) debian/config.json (+1/-1) docs/_common.txt (+43/-0) docs/example-client/main.qml (+34/-17) docs/example-client/manifest.json (+1/-1) docs/lowlevel.txt (+2/-0) launch_helper/kindpool.go (+3/-2) launch_helper/legacy/legacy.go (+3/-4) server/acceptance/suites/helpers.go (+7/-6) server/api/handlers.go (+12/-0) server/api/handlers_test.go (+6/-6) server/broker/testsuite/suite.go (+11/-11) |
To merge this branch: | bzr merge lp:~ralsina/ubuntu-push/server-limits-doc |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Samuele Pedroni | Pending | ||
Review via email: mp+241693@code.launchpad.net |
This proposal has been superseded by a proposal from 2014-11-17.
Commit message
Add section describing limitations of the server API
Description of the change
Add section describing limitations of the server API
To post a comment you must log in.
Unmerged revisions
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'PACKAGE_DEPS' |
2 | --- PACKAGE_DEPS 2014-09-05 10:48:36 +0000 |
3 | +++ PACKAGE_DEPS 2014-11-13 14:37:31 +0000 |
4 | @@ -12,3 +12,4 @@ |
5 | libclick-0.4-dev |
6 | liburl-dispatcher1-dev |
7 | libaccounts-glib-dev |
8 | +system-image-dbus |
9 | |
10 | === modified file 'client/service/service.go' |
11 | --- client/service/service.go 2014-11-03 13:36:00 +0000 |
12 | +++ client/service/service.go 2014-11-13 14:37:31 +0000 |
13 | @@ -140,6 +140,8 @@ |
14 | case resp.StatusCode >= http.StatusInternalServerError: |
15 | // XXX retry on 503 |
16 | return nil, ErrBadServer |
17 | + case resp.StatusCode == http.StatusUnauthorized: |
18 | + return nil, ErrBadAuth |
19 | default: |
20 | return nil, ErrBadRequest |
21 | } |
22 | |
23 | === modified file 'client/service/service_test.go' |
24 | --- client/service/service_test.go 2014-08-06 09:01:59 +0000 |
25 | +++ client/service/service_test.go 2014-11-13 14:37:31 +0000 |
26 | @@ -240,6 +240,23 @@ |
27 | c.Check(err, ErrorMatches, "unable to request registration: .*") |
28 | } |
29 | |
30 | +func (ss *serviceSuite) TestManageRegFailsOn401(c *C) { |
31 | + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
32 | + http.Error(w, "Unauthorized", 401) |
33 | + })) |
34 | + defer ts.Close() |
35 | + setup := &PushServiceSetup{ |
36 | + DeviceId: "fake-device-id", |
37 | + RegURL: helpers.ParseURL(ts.URL), |
38 | + AuthGetter: func(string) string { return "tok" }, |
39 | + } |
40 | + svc := NewPushService(setup, ss.log) |
41 | + svc.Bus = ss.bus |
42 | + reg, err := svc.register(aPackageOnBus, []interface{}{anAppId}, nil) |
43 | + c.Check(err, Equals, ErrBadAuth) |
44 | + c.Check(reg, IsNil) |
45 | +} |
46 | + |
47 | func (ss *serviceSuite) TestManageRegFailsOn40x(c *C) { |
48 | ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
49 | http.Error(w, "I'm a teapot", 418) |
50 | |
51 | === modified file 'client/session/session.go' |
52 | --- client/session/session.go 2014-11-03 13:36:00 +0000 |
53 | +++ client/session/session.go 2014-11-13 14:37:31 +0000 |
54 | @@ -430,7 +430,7 @@ |
55 | return err |
56 | } |
57 | sess.clearShouldDelay() |
58 | - sess.Log.Debugf("broadcast chan:%v app:%v topLevel:%d payloads:%s", |
59 | + sess.Log.Infof("broadcast chan:%v app:%v topLevel:%d payloads:%s", |
60 | bcast.ChanId, bcast.AppId, bcast.TopLevel, bcast.Payloads) |
61 | if bcast.ChanId == protocol.SystemChannelId { |
62 | // the system channel id, the only one we care about for now |
63 | @@ -438,7 +438,7 @@ |
64 | sess.BroadcastCh <- sess.decodeBroadcast(bcast) |
65 | sess.Log.Debugf("sent bcast over") |
66 | } else { |
67 | - sess.Log.Debugf("what is this weird channel, %#v?", bcast.ChanId) |
68 | + sess.Log.Errorf("what is this weird channel, %#v?", bcast.ChanId) |
69 | } |
70 | return nil |
71 | } |
72 | @@ -468,7 +468,7 @@ |
73 | if to == nil { |
74 | continue |
75 | } |
76 | - sess.Log.Debugf("unicast app:%v msg:%s payload:%s", |
77 | + sess.Log.Infof("unicast app:%v msg:%s payload:%s", |
78 | notif.AppId, notif.MsgId, notif.Payload) |
79 | sess.Log.Debugf("sending ucast over") |
80 | sess.NotificationsCh <- AddressedNotification{to, notif} |
81 | |
82 | === modified file 'debian/config.json' |
83 | --- debian/config.json 2014-08-21 10:47:12 +0000 |
84 | +++ debian/config.json 2014-11-13 14:37:31 +0000 |
85 | @@ -12,7 +12,7 @@ |
86 | "recheck_timeout": "10m", |
87 | "connectivity_check_url": "http://start.ubuntu.com/connectivity-check.html", |
88 | "connectivity_check_md5": "4589f42e1546aa47ca181e5d949d310b", |
89 | - "log_level": "debug", |
90 | + "log_level": "info", |
91 | "fallback_vibration": {"pattern": [100, 100], "repeat": 2}, |
92 | "fallback_sound": "sounds/ubuntu/notifications/Slick.ogg", |
93 | "poll_interval": "5m", |
94 | |
95 | === modified file 'docs/_common.txt' |
96 | --- docs/_common.txt 2014-10-09 16:06:52 +0000 |
97 | +++ docs/_common.txt 2014-11-13 14:37:31 +0000 |
98 | @@ -185,3 +185,46 @@ |
99 | :clear_pending: Discards all previous pending notifications. Usually in response to getting a "too-many-pending" error. |
100 | :replace_tag: If there's a pending notification with the same tag, delete it before queuing this new one. |
101 | :data: A JSON object. |
102 | + |
103 | +Limitations of the Server API |
104 | +----------------------------- |
105 | + |
106 | +The push notification infrastructure is meant to help ensuring timely |
107 | +delivery of application notifications if the device is online or |
108 | +timely informing the device user about application notifications that |
109 | +were pending when the device comes back online. This in the face of |
110 | +applications not being allowed to be running all the time, and |
111 | +avoiding the resource cost of many applications all polling different services |
112 | +frequently. |
113 | + |
114 | +The push notification infrastructure is architected to guarantee at |
115 | +least best-effort with respect to these goals and beyond it, on the |
116 | +other end applications should not expect to be able to use and only |
117 | +rely on the push notification infrastructure to store application |
118 | +messages if they want ensure all their notification or messages are |
119 | +delivered, the infrastructure is not intended to be the only long term |
120 | +"inbox" storage for an application. |
121 | + |
122 | +To preserve overall throughput the infrastructure imposes some limits |
123 | +on applications: |
124 | + |
125 | + * message data payload is limited to 2K |
126 | + |
127 | + * when inserted all messages need to specify an expiration date after |
128 | + which they can be dropped and not delivered |
129 | + |
130 | + * an application is limited in the number of messages per token |
131 | + (application/user/device combination) that can be undelivered/pending at the |
132 | + same time (100 currently) |
133 | + |
134 | +replace_tag can be used to implement notifications for which the newest |
135 | +one replace the previous one if pending. |
136 | + |
137 | +clear_pending can be used to be deal with a pending message limit |
138 | +reached, possibly substituting the current undelivered messages with a |
139 | +more generic one. |
140 | + |
141 | +Applications using the push notification HTTP API should be robust |
142 | +against receiving 503 errors, retrying after waiting with increasing |
143 | +back-off. Later rate limits (signaled with the 429 status) may also come |
144 | +into play. |
145 | |
146 | === modified file 'docs/example-client/main.qml' |
147 | --- docs/example-client/main.qml 2014-09-10 14:38:40 +0000 |
148 | +++ docs/example-client/main.qml 2014-11-13 14:37:31 +0000 |
149 | @@ -26,9 +26,42 @@ |
150 | property alias nickEnabled: nickEdit.enabled |
151 | } |
152 | |
153 | + states: [ |
154 | + State { |
155 | + name: "no-push-token" |
156 | + when: (pushClient.token == "") |
157 | + PropertyChanges { target: nickEdit; readOnly: true} |
158 | + PropertyChanges { target: nickEdit; focus: true} |
159 | + PropertyChanges { target: messageEdit; enabled: false} |
160 | + PropertyChanges { target: loginButton; enabled: false} |
161 | + PropertyChanges { target: loginButton; text: "Login"} |
162 | + }, |
163 | + State { |
164 | + name: "push-token-not-registered" |
165 | + when: ((pushClient.token != "") && (chatClient.registered == false)) |
166 | + PropertyChanges { target: nickEdit; readOnly: false} |
167 | + PropertyChanges { target: nickEdit; text: ""} |
168 | + PropertyChanges { target: nickEdit; focus: true} |
169 | + PropertyChanges { target: messageEdit; enabled: false} |
170 | + PropertyChanges { target: loginButton; enabled: true} |
171 | + PropertyChanges { target: loginButton; text: "Login"} |
172 | + }, |
173 | + State { |
174 | + name: "registered" |
175 | + when: ((pushClient.token != "") && (chatClient.registered == true)) |
176 | + PropertyChanges { target: nickEdit; readOnly: true} |
177 | + PropertyChanges { target: nickEdit; text: "Your nick is " + chatClient.nick} |
178 | + PropertyChanges { target: messageEdit; focus: true} |
179 | + PropertyChanges { target: messageEdit; enabled: true} |
180 | + PropertyChanges { target: loginButton; enabled: true} |
181 | + PropertyChanges { target: loginButton; text: "Logout"} |
182 | + } |
183 | + ] |
184 | + |
185 | + state: "no-push-token" |
186 | + |
187 | ChatClient { |
188 | id: chatClient |
189 | - onRegisteredChanged: {nickEdit.registered()} |
190 | onError: {messageList.handle_error(msg)} |
191 | token: pushClient.token |
192 | } |
193 | @@ -44,7 +77,6 @@ |
194 | |
195 | TextField { |
196 | id: nickEdit |
197 | - focus: true |
198 | placeholderText: "Your nickname" |
199 | inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText | Qt.ImhPreferLowercase |
200 | anchors.left: parent.left |
201 | @@ -53,31 +85,17 @@ |
202 | anchors.leftMargin: units.gu(.5) |
203 | anchors.rightMargin: units.gu(1) |
204 | anchors.topMargin: units.gu(.5) |
205 | - function registered() { |
206 | - readOnly = true |
207 | - text = "Your nick is " + chatClient.nick |
208 | - messageEdit.focus = true |
209 | - messageEdit.enabled = true |
210 | - loginButton.text = "Logout" |
211 | - } |
212 | onAccepted: { loginButton.clicked() } |
213 | } |
214 | |
215 | Button { |
216 | id: loginButton |
217 | - text: chatClient.rgistered? "Logout": "Login" |
218 | anchors.top: nickEdit.top |
219 | anchors.right: parent.right |
220 | anchors.rightMargin: units.gu(.5) |
221 | onClicked: { |
222 | if (chatClient.nick) { // logout |
223 | chatClient.nick = "" |
224 | - text = "Login" |
225 | - nickEdit.enabled = true |
226 | - nickEdit.readOnly = false |
227 | - nickEdit.text = "" |
228 | - nickEdit.focus = true |
229 | - messageEdit.enabled = false |
230 | } else { // login |
231 | chatClient.nick = nickEdit.text |
232 | } |
233 | @@ -94,7 +112,6 @@ |
234 | anchors.rightMargin: units.gu(.5) |
235 | anchors.leftMargin: units.gu(.5) |
236 | placeholderText: "Your message" |
237 | - enabled: false |
238 | onAccepted: { |
239 | console.log("sending " + text) |
240 | var idx = text.indexOf(":") |
241 | |
242 | === modified file 'docs/example-client/manifest.json' |
243 | --- docs/example-client/manifest.json 2014-09-10 14:38:31 +0000 |
244 | +++ docs/example-client/manifest.json 2014-11-13 14:37:31 +0000 |
245 | @@ -15,5 +15,5 @@ |
246 | "maintainer": "Roberto Alsina <roberto.alsina@canonical.com>", |
247 | "name": "com.ubuntu.developer.ralsina.hello", |
248 | "title": "Hello", |
249 | - "version": "0.4.2" |
250 | + "version": "0.4.3" |
251 | } |
252 | |
253 | === modified file 'docs/lowlevel.txt' |
254 | --- docs/lowlevel.txt 2014-10-15 16:34:25 +0000 |
255 | +++ docs/lowlevel.txt 2014-11-13 14:37:31 +0000 |
256 | @@ -57,6 +57,8 @@ |
257 | The Register method takes as argument the APP_ID (in the example, com.ubuntu.music_music) and returns a token identifying the user |
258 | and device. For this to succeed the user **must** have an Ubuntu One account configured in the device. |
259 | |
260 | +In the case the Register method returns a "bad auth" error, the application should inform the user to generate new Ubuntu One tokens. |
261 | + |
262 | The APP_ID is as described in the `ApplicationId documentation <https://wiki.ubuntu.com/AppStore/Interfaces/ApplicationId>`__ |
263 | except that the version is treated as optional. Therefore both ``com.ubuntu.music_music`` and ``com.ubuntu.music_music_1.3.496`` |
264 | are valid. Keep in mind that while both versioned and unversioned APP_IDs are valid, they are still different and will affect |
265 | |
266 | === modified file 'launch_helper/kindpool.go' |
267 | --- launch_helper/kindpool.go 2014-08-20 12:42:51 +0000 |
268 | +++ launch_helper/kindpool.go 2014-11-13 14:37:31 +0000 |
269 | @@ -294,12 +294,13 @@ |
270 | } |
271 | payload, err := ioutil.ReadFile(args.FileOut) |
272 | if err != nil { |
273 | - pool.log.Errorf("unable to read output from helper: %v", err) |
274 | + pool.log.Errorf("unable to read output from %v helper: %v", args.AppId, err) |
275 | } else { |
276 | + pool.log.Infof("%v helper output: %#v", args.AppId, payload) |
277 | res := &HelperResult{Input: args.Input} |
278 | err = json.Unmarshal(payload, &res.HelperOutput) |
279 | if err != nil { |
280 | - pool.log.Debugf("failed to parse HelperOutput from helper output: %v", err) |
281 | + pool.log.Errorf("failed to parse HelperOutput from %v helper output: %v", args.AppId, err) |
282 | } else { |
283 | pool.chOut <- res |
284 | } |
285 | |
286 | === modified file 'launch_helper/legacy/legacy.go' |
287 | --- launch_helper/legacy/legacy.go 2014-08-21 18:03:49 +0000 |
288 | +++ launch_helper/legacy/legacy.go 2014-11-13 14:37:31 +0000 |
289 | @@ -55,7 +55,7 @@ |
290 | err error |
291 | } |
292 | |
293 | -func (lhl *legacyHelperLauncher) Launch(_, progname, f1, f2 string) (string, error) { |
294 | +func (lhl *legacyHelperLauncher) Launch(appId, progname, f1, f2 string) (string, error) { |
295 | comm := make(chan msg) |
296 | |
297 | go func() { |
298 | @@ -78,9 +78,8 @@ |
299 | p_err := cmd.Wait() |
300 | if p_err != nil { |
301 | // Helper failed or got killed, log output/errors |
302 | - lhl.log.Errorf("Legacy helper failed: %v", p_err) |
303 | - lhl.log.Errorf("Legacy helper failed. Stdout: %s", stdout) |
304 | - lhl.log.Errorf("Legacy helper failed. Stderr: %s", stderr) |
305 | + lhl.log.Errorf("Legacy helper failed: appId: %v, helper: %v, pid: %v, error: %v, stdout: %#v, stderr: %#v.", |
306 | + appId, progname, id, p_err, stdout.String(), stderr.String()) |
307 | } |
308 | lhl.done(id) |
309 | }() |
310 | |
311 | === modified file 'server/acceptance/suites/helpers.go' |
312 | --- server/acceptance/suites/helpers.go 2014-07-08 15:08:52 +0000 |
313 | +++ server/acceptance/suites/helpers.go 2014-11-13 14:37:31 +0000 |
314 | @@ -127,6 +127,11 @@ |
315 | c.Log(info) |
316 | continue |
317 | } |
318 | + if strings.HasPrefix(info, "DEBUG ") && !strings.HasPrefix(info, "DEBUG session(") { |
319 | + // skip non session DEBUG logs |
320 | + c.Log(info) |
321 | + continue |
322 | + } |
323 | logs <- info |
324 | } |
325 | }() |
326 | @@ -136,16 +141,12 @@ |
327 | const ( |
328 | DevListeningOnPat = "INFO listening for devices on " |
329 | HTTPListeningOnPat = "INFO listening for http on " |
330 | - debugPrefix = "DEBUG " |
331 | ) |
332 | |
333 | -// ExtractListeningAddr goes over logs ignoring DEBUG lines |
334 | -// until a line starting with pat and returns the rest of that line. |
335 | +// ExtractListeningAddr goes over logs until a line starting with pat |
336 | +// and returns the rest of that line. |
337 | func ExtractListeningAddr(c *C, logs <-chan string, pat string) string { |
338 | for line := range logs { |
339 | - if strings.HasPrefix(line, debugPrefix) { |
340 | - continue |
341 | - } |
342 | if !strings.HasPrefix(line, pat) { |
343 | c.Fatalf("matching %v: %v", pat, line) |
344 | } |
345 | |
346 | === modified file 'server/api/handlers.go' |
347 | --- server/api/handlers.go 2014-07-14 15:23:17 +0000 |
348 | +++ server/api/handlers.go 2014-11-13 14:37:31 +0000 |
349 | @@ -98,6 +98,12 @@ |
350 | "Wrong request method, should be POST", |
351 | nil, |
352 | } |
353 | + ErrWrongRequestMethodGET = &APIError{ |
354 | + http.StatusMethodNotAllowed, |
355 | + invalidRequest, |
356 | + "Wrong request method, should be GET", |
357 | + nil, |
358 | + } |
359 | ErrMalformedJSONObject = &APIError{ |
360 | http.StatusBadRequest, |
361 | invalidRequest, |
362 | @@ -452,14 +458,17 @@ |
363 | if err != nil { |
364 | switch err { |
365 | case store.ErrUnknownToken: |
366 | + ctx.logger.Debugf("notify: %v %v unknown", ucast.AppId, ucast.Token) |
367 | return nil, ErrUnknownToken |
368 | case store.ErrUnauthorized: |
369 | + ctx.logger.Debugf("notify: %v %v unauthorized", ucast.AppId, ucast.Token) |
370 | return nil, ErrUnauthorized |
371 | default: |
372 | ctx.logger.Errorf("could not resolve token: %v", err) |
373 | return nil, ErrCouldNotResolveToken |
374 | } |
375 | } |
376 | + ctx.logger.Debugf("notify: %v %v -> %v", ucast.AppId, ucast.Token, chanId) |
377 | |
378 | _, notifs, meta, err := sto.GetChannelUnfiltered(chanId) |
379 | if err != nil { |
380 | @@ -491,6 +500,7 @@ |
381 | if ucast.ClearPending { |
382 | scrubCriteria = []string{ucast.AppId} |
383 | } else if forApp >= ctx.storage.GetMaxNotificationsPerApplication() { |
384 | + ctx.logger.Debugf("notify: %v %v too many pending", ucast.AppId, chanId) |
385 | return nil, apiErrorWithExtra(ErrTooManyPendingNotifications, |
386 | &last.Payload) |
387 | } else if replaceable > 0 { |
388 | @@ -518,6 +528,8 @@ |
389 | } |
390 | |
391 | ctx.broker.Unicast(chanId) |
392 | + |
393 | + ctx.logger.Debugf("notify: ok %v %v id:%v clear:%v replace:%v expired:%v", ucast.AppId, chanId, msgId, ucast.ClearPending, replaceable, expired) |
394 | return nil, nil |
395 | } |
396 | |
397 | |
398 | === modified file 'server/api/handlers_test.go' |
399 | --- server/api/handlers_test.go 2014-07-15 15:03:49 +0000 |
400 | +++ server/api/handlers_test.go 2014-11-13 14:37:31 +0000 |
401 | @@ -362,7 +362,7 @@ |
402 | } |
403 | sto := store.NewInMemoryPendingStore() |
404 | bsend := &checkBrokerSending{store: sto} |
405 | - ctx := &context{testStoreAccess(nil), bsend, nil} |
406 | + ctx := &context{testStoreAccess(nil), bsend, s.testlog} |
407 | payload := json.RawMessage(`{"a": 1}`) |
408 | res, apiErr := doUnicast(ctx, sto, &Unicast{ |
409 | UserId: "user1", |
410 | @@ -487,7 +487,7 @@ |
411 | sto.AppendToUnicastChannel(chanId, "app1", n, "m4", expire) |
412 | |
413 | bsend := &checkBrokerSending{store: sto} |
414 | - ctx := &context{testStoreAccess(nil), bsend, nil} |
415 | + ctx := &context{testStoreAccess(nil), bsend, s.testlog} |
416 | payload := json.RawMessage(`{"a": 1}`) |
417 | res, apiErr := doUnicast(ctx, sto, &Unicast{ |
418 | UserId: "user1", |
419 | @@ -528,7 +528,7 @@ |
420 | sto.AppendToUnicastChannel(chanId, "app1", n, "m1", expire) |
421 | |
422 | bsend := &checkBrokerSending{store: sto} |
423 | - ctx := &context{testStoreAccess(nil), bsend, nil} |
424 | + ctx := &context{testStoreAccess(nil), bsend, s.testlog} |
425 | payload := json.RawMessage(`{"a": 1}`) |
426 | res, apiErr := doUnicast(ctx, sto, &Unicast{ |
427 | UserId: "user1", |
428 | @@ -634,7 +634,7 @@ |
429 | sto.AppendToUnicastChannel(chanId, "app1", n, "m4", expire) |
430 | |
431 | bsend := &checkBrokerSending{store: sto} |
432 | - ctx := &context{testStoreAccess(nil), bsend, nil} |
433 | + ctx := &context{testStoreAccess(nil), bsend, s.testlog} |
434 | payload := json.RawMessage(`{"a": 1}`) |
435 | res, apiErr := doUnicast(ctx, sto, &Unicast{ |
436 | UserId: "user1", |
437 | @@ -965,7 +965,7 @@ |
438 | return sto, nil |
439 | }) |
440 | bsend := testBrokerSending{make(chan store.InternalChannelId, 1)} |
441 | - testServer := httptest.NewServer(MakeHandlersMux(storage, bsend, nil)) |
442 | + testServer := httptest.NewServer(MakeHandlersMux(storage, bsend, s.testlog)) |
443 | defer testServer.Close() |
444 | |
445 | payload := json.RawMessage(`{"foo":"bar"}`) |
446 | @@ -1049,7 +1049,7 @@ |
447 | return sto, nil |
448 | }) |
449 | bsend := testBrokerSending{make(chan store.InternalChannelId, 1)} |
450 | - testServer := httptest.NewServer(MakeHandlersMux(storage, bsend, nil)) |
451 | + testServer := httptest.NewServer(MakeHandlersMux(storage, bsend, s.testlog)) |
452 | defer testServer.Close() |
453 | |
454 | request := newPostRequest("/register", &Registration{ |
455 | |
456 | === modified file 'server/broker/testsuite/suite.go' |
457 | --- server/broker/testsuite/suite.go 2014-09-25 11:16:38 +0000 |
458 | +++ server/broker/testsuite/suite.go 2014-11-13 14:37:31 +0000 |
459 | @@ -66,12 +66,12 @@ |
460 | |
461 | func (s *CommonBrokerSuite) TestSanity(c *C) { |
462 | sto := store.NewInMemoryPendingStore() |
463 | - b := s.MakeBroker(sto, testBrokerConfig, nil) |
464 | + b := s.MakeBroker(sto, testBrokerConfig, s.testlog) |
465 | c.Check(s.RevealSession(b, "FOO"), IsNil) |
466 | } |
467 | |
468 | func (s *CommonBrokerSuite) TestStartStop(c *C) { |
469 | - b := s.MakeBroker(nil, testBrokerConfig, nil) |
470 | + b := s.MakeBroker(nil, testBrokerConfig, s.testlog) |
471 | b.Start() |
472 | c.Check(b.Running(), Equals, true) |
473 | b.Start() |
474 | @@ -82,7 +82,7 @@ |
475 | |
476 | func (s *CommonBrokerSuite) TestRegistration(c *C) { |
477 | sto := store.NewInMemoryPendingStore() |
478 | - b := s.MakeBroker(sto, testBrokerConfig, nil) |
479 | + b := s.MakeBroker(sto, testBrokerConfig, s.testlog) |
480 | b.Start() |
481 | defer b.Stop() |
482 | sess, err := b.Register(&protocol.ConnectMsg{ |
483 | @@ -112,7 +112,7 @@ |
484 | |
485 | func (s *CommonBrokerSuite) TestRegistrationBrokenLevels(c *C) { |
486 | sto := store.NewInMemoryPendingStore() |
487 | - b := s.MakeBroker(sto, testBrokerConfig, nil) |
488 | + b := s.MakeBroker(sto, testBrokerConfig, s.testlog) |
489 | b.Start() |
490 | defer b.Stop() |
491 | _, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev-1", Levels: map[string]int64{"z": 5}}, s.MakeTracker("s1")) |
492 | @@ -121,7 +121,7 @@ |
493 | |
494 | func (s *CommonBrokerSuite) TestRegistrationInfoErrors(c *C) { |
495 | sto := store.NewInMemoryPendingStore() |
496 | - b := s.MakeBroker(sto, testBrokerConfig, nil) |
497 | + b := s.MakeBroker(sto, testBrokerConfig, s.testlog) |
498 | b.Start() |
499 | defer b.Stop() |
500 | info := map[string]interface{}{ |
501 | @@ -140,7 +140,7 @@ |
502 | notification1 := json.RawMessage(`{"m": "M"}`) |
503 | muchLater := time.Now().Add(10 * time.Minute) |
504 | sto.AppendToChannel(store.SystemInternalChannelId, notification1, muchLater) |
505 | - b := s.MakeBroker(sto, testBrokerConfig, nil) |
506 | + b := s.MakeBroker(sto, testBrokerConfig, s.testlog) |
507 | b.Start() |
508 | defer b.Stop() |
509 | sess, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev-1"}, s.MakeTracker("s1")) |
510 | @@ -166,7 +166,7 @@ |
511 | |
512 | func (s *CommonBrokerSuite) TestRegistrationLastWins(c *C) { |
513 | sto := store.NewInMemoryPendingStore() |
514 | - b := s.MakeBroker(sto, testBrokerConfig, nil) |
515 | + b := s.MakeBroker(sto, testBrokerConfig, s.testlog) |
516 | b.Start() |
517 | defer b.Stop() |
518 | sess1, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev-1"}, s.MakeTracker("s1")) |
519 | @@ -197,7 +197,7 @@ |
520 | sto := store.NewInMemoryPendingStore() |
521 | notification1 := json.RawMessage(`{"m": "M"}`) |
522 | decoded1 := map[string]interface{}{"m": "M"} |
523 | - b := s.MakeBroker(sto, testBrokerConfig, nil) |
524 | + b := s.MakeBroker(sto, testBrokerConfig, s.testlog) |
525 | b.Start() |
526 | defer b.Stop() |
527 | sess1, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev-1"}, s.MakeTracker("s1")) |
528 | @@ -278,7 +278,7 @@ |
529 | notification2 := json.RawMessage(`{"m": "M2"}`) |
530 | chanId1 := store.UnicastInternalChannelId("dev1", "dev1") |
531 | chanId2 := store.UnicastInternalChannelId("dev2", "dev2") |
532 | - b := s.MakeBroker(sto, testBrokerConfig, nil) |
533 | + b := s.MakeBroker(sto, testBrokerConfig, s.testlog) |
534 | b.Start() |
535 | defer b.Stop() |
536 | sess1, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev1"}, s.MakeTracker("s1")) |
537 | @@ -312,7 +312,7 @@ |
538 | sto := store.NewInMemoryPendingStore() |
539 | notification1 := json.RawMessage(`{"m": "M1"}`) |
540 | chanId1 := store.UnicastInternalChannelId("dev3", "dev3") |
541 | - b := s.MakeBroker(sto, testBrokerConfig, nil) |
542 | + b := s.MakeBroker(sto, testBrokerConfig, s.testlog) |
543 | b.Start() |
544 | defer b.Stop() |
545 | sess1, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev3"}, s.MakeTracker("s1")) |
546 | @@ -354,7 +354,7 @@ |
547 | |
548 | func (s *CommonBrokerSuite) TestSessionFeed(c *C) { |
549 | sto := store.NewInMemoryPendingStore() |
550 | - b := s.MakeBroker(sto, testBrokerConfig, nil) |
551 | + b := s.MakeBroker(sto, testBrokerConfig, s.testlog) |
552 | b.Start() |
553 | defer b.Stop() |
554 | sess1, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev3"}, s.MakeTracker("s1")) |