Merge lp:~ralsina/ubuntu-push/server-limits-doc into lp:ubuntu-push

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
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
=== modified file 'PACKAGE_DEPS'
--- PACKAGE_DEPS 2014-09-05 10:48:36 +0000
+++ PACKAGE_DEPS 2014-11-13 14:37:31 +0000
@@ -12,3 +12,4 @@
12libclick-0.4-dev12libclick-0.4-dev
13liburl-dispatcher1-dev13liburl-dispatcher1-dev
14libaccounts-glib-dev14libaccounts-glib-dev
15system-image-dbus
1516
=== modified file 'client/service/service.go'
--- client/service/service.go 2014-11-03 13:36:00 +0000
+++ client/service/service.go 2014-11-13 14:37:31 +0000
@@ -140,6 +140,8 @@
140 case resp.StatusCode >= http.StatusInternalServerError:140 case resp.StatusCode >= http.StatusInternalServerError:
141 // XXX retry on 503141 // XXX retry on 503
142 return nil, ErrBadServer142 return nil, ErrBadServer
143 case resp.StatusCode == http.StatusUnauthorized:
144 return nil, ErrBadAuth
143 default:145 default:
144 return nil, ErrBadRequest146 return nil, ErrBadRequest
145 }147 }
146148
=== modified file 'client/service/service_test.go'
--- client/service/service_test.go 2014-08-06 09:01:59 +0000
+++ client/service/service_test.go 2014-11-13 14:37:31 +0000
@@ -240,6 +240,23 @@
240 c.Check(err, ErrorMatches, "unable to request registration: .*")240 c.Check(err, ErrorMatches, "unable to request registration: .*")
241}241}
242242
243func (ss *serviceSuite) TestManageRegFailsOn401(c *C) {
244 ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
245 http.Error(w, "Unauthorized", 401)
246 }))
247 defer ts.Close()
248 setup := &PushServiceSetup{
249 DeviceId: "fake-device-id",
250 RegURL: helpers.ParseURL(ts.URL),
251 AuthGetter: func(string) string { return "tok" },
252 }
253 svc := NewPushService(setup, ss.log)
254 svc.Bus = ss.bus
255 reg, err := svc.register(aPackageOnBus, []interface{}{anAppId}, nil)
256 c.Check(err, Equals, ErrBadAuth)
257 c.Check(reg, IsNil)
258}
259
243func (ss *serviceSuite) TestManageRegFailsOn40x(c *C) {260func (ss *serviceSuite) TestManageRegFailsOn40x(c *C) {
244 ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {261 ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
245 http.Error(w, "I'm a teapot", 418)262 http.Error(w, "I'm a teapot", 418)
246263
=== modified file 'client/session/session.go'
--- client/session/session.go 2014-11-03 13:36:00 +0000
+++ client/session/session.go 2014-11-13 14:37:31 +0000
@@ -430,7 +430,7 @@
430 return err430 return err
431 }431 }
432 sess.clearShouldDelay()432 sess.clearShouldDelay()
433 sess.Log.Debugf("broadcast chan:%v app:%v topLevel:%d payloads:%s",433 sess.Log.Infof("broadcast chan:%v app:%v topLevel:%d payloads:%s",
434 bcast.ChanId, bcast.AppId, bcast.TopLevel, bcast.Payloads)434 bcast.ChanId, bcast.AppId, bcast.TopLevel, bcast.Payloads)
435 if bcast.ChanId == protocol.SystemChannelId {435 if bcast.ChanId == protocol.SystemChannelId {
436 // the system channel id, the only one we care about for now436 // the system channel id, the only one we care about for now
@@ -438,7 +438,7 @@
438 sess.BroadcastCh <- sess.decodeBroadcast(bcast)438 sess.BroadcastCh <- sess.decodeBroadcast(bcast)
439 sess.Log.Debugf("sent bcast over")439 sess.Log.Debugf("sent bcast over")
440 } else {440 } else {
441 sess.Log.Debugf("what is this weird channel, %#v?", bcast.ChanId)441 sess.Log.Errorf("what is this weird channel, %#v?", bcast.ChanId)
442 }442 }
443 return nil443 return nil
444}444}
@@ -468,7 +468,7 @@
468 if to == nil {468 if to == nil {
469 continue469 continue
470 }470 }
471 sess.Log.Debugf("unicast app:%v msg:%s payload:%s",471 sess.Log.Infof("unicast app:%v msg:%s payload:%s",
472 notif.AppId, notif.MsgId, notif.Payload)472 notif.AppId, notif.MsgId, notif.Payload)
473 sess.Log.Debugf("sending ucast over")473 sess.Log.Debugf("sending ucast over")
474 sess.NotificationsCh <- AddressedNotification{to, notif}474 sess.NotificationsCh <- AddressedNotification{to, notif}
475475
=== modified file 'debian/config.json'
--- debian/config.json 2014-08-21 10:47:12 +0000
+++ debian/config.json 2014-11-13 14:37:31 +0000
@@ -12,7 +12,7 @@
12 "recheck_timeout": "10m",12 "recheck_timeout": "10m",
13 "connectivity_check_url": "http://start.ubuntu.com/connectivity-check.html",13 "connectivity_check_url": "http://start.ubuntu.com/connectivity-check.html",
14 "connectivity_check_md5": "4589f42e1546aa47ca181e5d949d310b",14 "connectivity_check_md5": "4589f42e1546aa47ca181e5d949d310b",
15 "log_level": "debug",15 "log_level": "info",
16 "fallback_vibration": {"pattern": [100, 100], "repeat": 2},16 "fallback_vibration": {"pattern": [100, 100], "repeat": 2},
17 "fallback_sound": "sounds/ubuntu/notifications/Slick.ogg",17 "fallback_sound": "sounds/ubuntu/notifications/Slick.ogg",
18 "poll_interval": "5m",18 "poll_interval": "5m",
1919
=== modified file 'docs/_common.txt'
--- docs/_common.txt 2014-10-09 16:06:52 +0000
+++ docs/_common.txt 2014-11-13 14:37:31 +0000
@@ -185,3 +185,46 @@
185:clear_pending: Discards all previous pending notifications. Usually in response to getting a "too-many-pending" error.185:clear_pending: Discards all previous pending notifications. Usually in response to getting a "too-many-pending" error.
186:replace_tag: If there's a pending notification with the same tag, delete it before queuing this new one.186:replace_tag: If there's a pending notification with the same tag, delete it before queuing this new one.
187:data: A JSON object.187:data: A JSON object.
188
189Limitations of the Server API
190-----------------------------
191
192The push notification infrastructure is meant to help ensuring timely
193delivery of application notifications if the device is online or
194timely informing the device user about application notifications that
195were pending when the device comes back online. This in the face of
196applications not being allowed to be running all the time, and
197avoiding the resource cost of many applications all polling different services
198frequently.
199
200The push notification infrastructure is architected to guarantee at
201least best-effort with respect to these goals and beyond it, on the
202other end applications should not expect to be able to use and only
203rely on the push notification infrastructure to store application
204messages if they want ensure all their notification or messages are
205delivered, the infrastructure is not intended to be the only long term
206"inbox" storage for an application.
207
208To preserve overall throughput the infrastructure imposes some limits
209on applications:
210
211 * message data payload is limited to 2K
212
213 * when inserted all messages need to specify an expiration date after
214 which they can be dropped and not delivered
215
216 * an application is limited in the number of messages per token
217 (application/user/device combination) that can be undelivered/pending at the
218 same time (100 currently)
219
220replace_tag can be used to implement notifications for which the newest
221one replace the previous one if pending.
222
223clear_pending can be used to be deal with a pending message limit
224reached, possibly substituting the current undelivered messages with a
225more generic one.
226
227Applications using the push notification HTTP API should be robust
228against receiving 503 errors, retrying after waiting with increasing
229back-off. Later rate limits (signaled with the 429 status) may also come
230into play.
188231
=== modified file 'docs/example-client/main.qml'
--- docs/example-client/main.qml 2014-09-10 14:38:40 +0000
+++ docs/example-client/main.qml 2014-11-13 14:37:31 +0000
@@ -26,9 +26,42 @@
26 property alias nickEnabled: nickEdit.enabled26 property alias nickEnabled: nickEdit.enabled
27 }27 }
2828
29 states: [
30 State {
31 name: "no-push-token"
32 when: (pushClient.token == "")
33 PropertyChanges { target: nickEdit; readOnly: true}
34 PropertyChanges { target: nickEdit; focus: true}
35 PropertyChanges { target: messageEdit; enabled: false}
36 PropertyChanges { target: loginButton; enabled: false}
37 PropertyChanges { target: loginButton; text: "Login"}
38 },
39 State {
40 name: "push-token-not-registered"
41 when: ((pushClient.token != "") && (chatClient.registered == false))
42 PropertyChanges { target: nickEdit; readOnly: false}
43 PropertyChanges { target: nickEdit; text: ""}
44 PropertyChanges { target: nickEdit; focus: true}
45 PropertyChanges { target: messageEdit; enabled: false}
46 PropertyChanges { target: loginButton; enabled: true}
47 PropertyChanges { target: loginButton; text: "Login"}
48 },
49 State {
50 name: "registered"
51 when: ((pushClient.token != "") && (chatClient.registered == true))
52 PropertyChanges { target: nickEdit; readOnly: true}
53 PropertyChanges { target: nickEdit; text: "Your nick is " + chatClient.nick}
54 PropertyChanges { target: messageEdit; focus: true}
55 PropertyChanges { target: messageEdit; enabled: true}
56 PropertyChanges { target: loginButton; enabled: true}
57 PropertyChanges { target: loginButton; text: "Logout"}
58 }
59 ]
60
61 state: "no-push-token"
62
29 ChatClient {63 ChatClient {
30 id: chatClient64 id: chatClient
31 onRegisteredChanged: {nickEdit.registered()}
32 onError: {messageList.handle_error(msg)}65 onError: {messageList.handle_error(msg)}
33 token: pushClient.token66 token: pushClient.token
34 }67 }
@@ -44,7 +77,6 @@
4477
45 TextField {78 TextField {
46 id: nickEdit79 id: nickEdit
47 focus: true
48 placeholderText: "Your nickname"80 placeholderText: "Your nickname"
49 inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText | Qt.ImhPreferLowercase81 inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText | Qt.ImhPreferLowercase
50 anchors.left: parent.left82 anchors.left: parent.left
@@ -53,31 +85,17 @@
53 anchors.leftMargin: units.gu(.5)85 anchors.leftMargin: units.gu(.5)
54 anchors.rightMargin: units.gu(1)86 anchors.rightMargin: units.gu(1)
55 anchors.topMargin: units.gu(.5)87 anchors.topMargin: units.gu(.5)
56 function registered() {
57 readOnly = true
58 text = "Your nick is " + chatClient.nick
59 messageEdit.focus = true
60 messageEdit.enabled = true
61 loginButton.text = "Logout"
62 }
63 onAccepted: { loginButton.clicked() }88 onAccepted: { loginButton.clicked() }
64 }89 }
6590
66 Button {91 Button {
67 id: loginButton92 id: loginButton
68 text: chatClient.rgistered? "Logout": "Login"
69 anchors.top: nickEdit.top93 anchors.top: nickEdit.top
70 anchors.right: parent.right94 anchors.right: parent.right
71 anchors.rightMargin: units.gu(.5)95 anchors.rightMargin: units.gu(.5)
72 onClicked: {96 onClicked: {
73 if (chatClient.nick) { // logout97 if (chatClient.nick) { // logout
74 chatClient.nick = ""98 chatClient.nick = ""
75 text = "Login"
76 nickEdit.enabled = true
77 nickEdit.readOnly = false
78 nickEdit.text = ""
79 nickEdit.focus = true
80 messageEdit.enabled = false
81 } else { // login99 } else { // login
82 chatClient.nick = nickEdit.text100 chatClient.nick = nickEdit.text
83 }101 }
@@ -94,7 +112,6 @@
94 anchors.rightMargin: units.gu(.5)112 anchors.rightMargin: units.gu(.5)
95 anchors.leftMargin: units.gu(.5)113 anchors.leftMargin: units.gu(.5)
96 placeholderText: "Your message"114 placeholderText: "Your message"
97 enabled: false
98 onAccepted: {115 onAccepted: {
99 console.log("sending " + text)116 console.log("sending " + text)
100 var idx = text.indexOf(":")117 var idx = text.indexOf(":")
101118
=== modified file 'docs/example-client/manifest.json'
--- docs/example-client/manifest.json 2014-09-10 14:38:31 +0000
+++ docs/example-client/manifest.json 2014-11-13 14:37:31 +0000
@@ -15,5 +15,5 @@
15 "maintainer": "Roberto Alsina <roberto.alsina@canonical.com>",15 "maintainer": "Roberto Alsina <roberto.alsina@canonical.com>",
16 "name": "com.ubuntu.developer.ralsina.hello",16 "name": "com.ubuntu.developer.ralsina.hello",
17 "title": "Hello",17 "title": "Hello",
18 "version": "0.4.2"18 "version": "0.4.3"
19}19}
2020
=== modified file 'docs/lowlevel.txt'
--- docs/lowlevel.txt 2014-10-15 16:34:25 +0000
+++ docs/lowlevel.txt 2014-11-13 14:37:31 +0000
@@ -57,6 +57,8 @@
57The Register method takes as argument the APP_ID (in the example, com.ubuntu.music_music) and returns a token identifying the user57The Register method takes as argument the APP_ID (in the example, com.ubuntu.music_music) and returns a token identifying the user
58and device. For this to succeed the user **must** have an Ubuntu One account configured in the device.58and device. For this to succeed the user **must** have an Ubuntu One account configured in the device.
5959
60In the case the Register method returns a "bad auth" error, the application should inform the user to generate new Ubuntu One tokens.
61
60The APP_ID is as described in the `ApplicationId documentation <https://wiki.ubuntu.com/AppStore/Interfaces/ApplicationId>`__62The APP_ID is as described in the `ApplicationId documentation <https://wiki.ubuntu.com/AppStore/Interfaces/ApplicationId>`__
61except that the version is treated as optional. Therefore both ``com.ubuntu.music_music`` and ``com.ubuntu.music_music_1.3.496``63except that the version is treated as optional. Therefore both ``com.ubuntu.music_music`` and ``com.ubuntu.music_music_1.3.496``
62are valid. Keep in mind that while both versioned and unversioned APP_IDs are valid, they are still different and will affect64are valid. Keep in mind that while both versioned and unversioned APP_IDs are valid, they are still different and will affect
6365
=== modified file 'launch_helper/kindpool.go'
--- launch_helper/kindpool.go 2014-08-20 12:42:51 +0000
+++ launch_helper/kindpool.go 2014-11-13 14:37:31 +0000
@@ -294,12 +294,13 @@
294 }294 }
295 payload, err := ioutil.ReadFile(args.FileOut)295 payload, err := ioutil.ReadFile(args.FileOut)
296 if err != nil {296 if err != nil {
297 pool.log.Errorf("unable to read output from helper: %v", err)297 pool.log.Errorf("unable to read output from %v helper: %v", args.AppId, err)
298 } else {298 } else {
299 pool.log.Infof("%v helper output: %#v", args.AppId, payload)
299 res := &HelperResult{Input: args.Input}300 res := &HelperResult{Input: args.Input}
300 err = json.Unmarshal(payload, &res.HelperOutput)301 err = json.Unmarshal(payload, &res.HelperOutput)
301 if err != nil {302 if err != nil {
302 pool.log.Debugf("failed to parse HelperOutput from helper output: %v", err)303 pool.log.Errorf("failed to parse HelperOutput from %v helper output: %v", args.AppId, err)
303 } else {304 } else {
304 pool.chOut <- res305 pool.chOut <- res
305 }306 }
306307
=== modified file 'launch_helper/legacy/legacy.go'
--- launch_helper/legacy/legacy.go 2014-08-21 18:03:49 +0000
+++ launch_helper/legacy/legacy.go 2014-11-13 14:37:31 +0000
@@ -55,7 +55,7 @@
55 err error55 err error
56}56}
5757
58func (lhl *legacyHelperLauncher) Launch(_, progname, f1, f2 string) (string, error) {58func (lhl *legacyHelperLauncher) Launch(appId, progname, f1, f2 string) (string, error) {
59 comm := make(chan msg)59 comm := make(chan msg)
6060
61 go func() {61 go func() {
@@ -78,9 +78,8 @@
78 p_err := cmd.Wait()78 p_err := cmd.Wait()
79 if p_err != nil {79 if p_err != nil {
80 // Helper failed or got killed, log output/errors80 // Helper failed or got killed, log output/errors
81 lhl.log.Errorf("Legacy helper failed: %v", p_err)81 lhl.log.Errorf("Legacy helper failed: appId: %v, helper: %v, pid: %v, error: %v, stdout: %#v, stderr: %#v.",
82 lhl.log.Errorf("Legacy helper failed. Stdout: %s", stdout)82 appId, progname, id, p_err, stdout.String(), stderr.String())
83 lhl.log.Errorf("Legacy helper failed. Stderr: %s", stderr)
84 }83 }
85 lhl.done(id)84 lhl.done(id)
86 }()85 }()
8786
=== modified file 'server/acceptance/suites/helpers.go'
--- server/acceptance/suites/helpers.go 2014-07-08 15:08:52 +0000
+++ server/acceptance/suites/helpers.go 2014-11-13 14:37:31 +0000
@@ -127,6 +127,11 @@
127 c.Log(info)127 c.Log(info)
128 continue128 continue
129 }129 }
130 if strings.HasPrefix(info, "DEBUG ") && !strings.HasPrefix(info, "DEBUG session(") {
131 // skip non session DEBUG logs
132 c.Log(info)
133 continue
134 }
130 logs <- info135 logs <- info
131 }136 }
132 }()137 }()
@@ -136,16 +141,12 @@
136const (141const (
137 DevListeningOnPat = "INFO listening for devices on "142 DevListeningOnPat = "INFO listening for devices on "
138 HTTPListeningOnPat = "INFO listening for http on "143 HTTPListeningOnPat = "INFO listening for http on "
139 debugPrefix = "DEBUG "
140)144)
141145
142// ExtractListeningAddr goes over logs ignoring DEBUG lines146// ExtractListeningAddr goes over logs until a line starting with pat
143// until a line starting with pat and returns the rest of that line.147// and returns the rest of that line.
144func ExtractListeningAddr(c *C, logs <-chan string, pat string) string {148func ExtractListeningAddr(c *C, logs <-chan string, pat string) string {
145 for line := range logs {149 for line := range logs {
146 if strings.HasPrefix(line, debugPrefix) {
147 continue
148 }
149 if !strings.HasPrefix(line, pat) {150 if !strings.HasPrefix(line, pat) {
150 c.Fatalf("matching %v: %v", pat, line)151 c.Fatalf("matching %v: %v", pat, line)
151 }152 }
152153
=== modified file 'server/api/handlers.go'
--- server/api/handlers.go 2014-07-14 15:23:17 +0000
+++ server/api/handlers.go 2014-11-13 14:37:31 +0000
@@ -98,6 +98,12 @@
98 "Wrong request method, should be POST",98 "Wrong request method, should be POST",
99 nil,99 nil,
100 }100 }
101 ErrWrongRequestMethodGET = &APIError{
102 http.StatusMethodNotAllowed,
103 invalidRequest,
104 "Wrong request method, should be GET",
105 nil,
106 }
101 ErrMalformedJSONObject = &APIError{107 ErrMalformedJSONObject = &APIError{
102 http.StatusBadRequest,108 http.StatusBadRequest,
103 invalidRequest,109 invalidRequest,
@@ -452,14 +458,17 @@
452 if err != nil {458 if err != nil {
453 switch err {459 switch err {
454 case store.ErrUnknownToken:460 case store.ErrUnknownToken:
461 ctx.logger.Debugf("notify: %v %v unknown", ucast.AppId, ucast.Token)
455 return nil, ErrUnknownToken462 return nil, ErrUnknownToken
456 case store.ErrUnauthorized:463 case store.ErrUnauthorized:
464 ctx.logger.Debugf("notify: %v %v unauthorized", ucast.AppId, ucast.Token)
457 return nil, ErrUnauthorized465 return nil, ErrUnauthorized
458 default:466 default:
459 ctx.logger.Errorf("could not resolve token: %v", err)467 ctx.logger.Errorf("could not resolve token: %v", err)
460 return nil, ErrCouldNotResolveToken468 return nil, ErrCouldNotResolveToken
461 }469 }
462 }470 }
471 ctx.logger.Debugf("notify: %v %v -> %v", ucast.AppId, ucast.Token, chanId)
463472
464 _, notifs, meta, err := sto.GetChannelUnfiltered(chanId)473 _, notifs, meta, err := sto.GetChannelUnfiltered(chanId)
465 if err != nil {474 if err != nil {
@@ -491,6 +500,7 @@
491 if ucast.ClearPending {500 if ucast.ClearPending {
492 scrubCriteria = []string{ucast.AppId}501 scrubCriteria = []string{ucast.AppId}
493 } else if forApp >= ctx.storage.GetMaxNotificationsPerApplication() {502 } else if forApp >= ctx.storage.GetMaxNotificationsPerApplication() {
503 ctx.logger.Debugf("notify: %v %v too many pending", ucast.AppId, chanId)
494 return nil, apiErrorWithExtra(ErrTooManyPendingNotifications,504 return nil, apiErrorWithExtra(ErrTooManyPendingNotifications,
495 &last.Payload)505 &last.Payload)
496 } else if replaceable > 0 {506 } else if replaceable > 0 {
@@ -518,6 +528,8 @@
518 }528 }
519529
520 ctx.broker.Unicast(chanId)530 ctx.broker.Unicast(chanId)
531
532 ctx.logger.Debugf("notify: ok %v %v id:%v clear:%v replace:%v expired:%v", ucast.AppId, chanId, msgId, ucast.ClearPending, replaceable, expired)
521 return nil, nil533 return nil, nil
522}534}
523535
524536
=== modified file 'server/api/handlers_test.go'
--- server/api/handlers_test.go 2014-07-15 15:03:49 +0000
+++ server/api/handlers_test.go 2014-11-13 14:37:31 +0000
@@ -362,7 +362,7 @@
362 }362 }
363 sto := store.NewInMemoryPendingStore()363 sto := store.NewInMemoryPendingStore()
364 bsend := &checkBrokerSending{store: sto}364 bsend := &checkBrokerSending{store: sto}
365 ctx := &context{testStoreAccess(nil), bsend, nil}365 ctx := &context{testStoreAccess(nil), bsend, s.testlog}
366 payload := json.RawMessage(`{"a": 1}`)366 payload := json.RawMessage(`{"a": 1}`)
367 res, apiErr := doUnicast(ctx, sto, &Unicast{367 res, apiErr := doUnicast(ctx, sto, &Unicast{
368 UserId: "user1",368 UserId: "user1",
@@ -487,7 +487,7 @@
487 sto.AppendToUnicastChannel(chanId, "app1", n, "m4", expire)487 sto.AppendToUnicastChannel(chanId, "app1", n, "m4", expire)
488488
489 bsend := &checkBrokerSending{store: sto}489 bsend := &checkBrokerSending{store: sto}
490 ctx := &context{testStoreAccess(nil), bsend, nil}490 ctx := &context{testStoreAccess(nil), bsend, s.testlog}
491 payload := json.RawMessage(`{"a": 1}`)491 payload := json.RawMessage(`{"a": 1}`)
492 res, apiErr := doUnicast(ctx, sto, &Unicast{492 res, apiErr := doUnicast(ctx, sto, &Unicast{
493 UserId: "user1",493 UserId: "user1",
@@ -528,7 +528,7 @@
528 sto.AppendToUnicastChannel(chanId, "app1", n, "m1", expire)528 sto.AppendToUnicastChannel(chanId, "app1", n, "m1", expire)
529529
530 bsend := &checkBrokerSending{store: sto}530 bsend := &checkBrokerSending{store: sto}
531 ctx := &context{testStoreAccess(nil), bsend, nil}531 ctx := &context{testStoreAccess(nil), bsend, s.testlog}
532 payload := json.RawMessage(`{"a": 1}`)532 payload := json.RawMessage(`{"a": 1}`)
533 res, apiErr := doUnicast(ctx, sto, &Unicast{533 res, apiErr := doUnicast(ctx, sto, &Unicast{
534 UserId: "user1",534 UserId: "user1",
@@ -634,7 +634,7 @@
634 sto.AppendToUnicastChannel(chanId, "app1", n, "m4", expire)634 sto.AppendToUnicastChannel(chanId, "app1", n, "m4", expire)
635635
636 bsend := &checkBrokerSending{store: sto}636 bsend := &checkBrokerSending{store: sto}
637 ctx := &context{testStoreAccess(nil), bsend, nil}637 ctx := &context{testStoreAccess(nil), bsend, s.testlog}
638 payload := json.RawMessage(`{"a": 1}`)638 payload := json.RawMessage(`{"a": 1}`)
639 res, apiErr := doUnicast(ctx, sto, &Unicast{639 res, apiErr := doUnicast(ctx, sto, &Unicast{
640 UserId: "user1",640 UserId: "user1",
@@ -965,7 +965,7 @@
965 return sto, nil965 return sto, nil
966 })966 })
967 bsend := testBrokerSending{make(chan store.InternalChannelId, 1)}967 bsend := testBrokerSending{make(chan store.InternalChannelId, 1)}
968 testServer := httptest.NewServer(MakeHandlersMux(storage, bsend, nil))968 testServer := httptest.NewServer(MakeHandlersMux(storage, bsend, s.testlog))
969 defer testServer.Close()969 defer testServer.Close()
970970
971 payload := json.RawMessage(`{"foo":"bar"}`)971 payload := json.RawMessage(`{"foo":"bar"}`)
@@ -1049,7 +1049,7 @@
1049 return sto, nil1049 return sto, nil
1050 })1050 })
1051 bsend := testBrokerSending{make(chan store.InternalChannelId, 1)}1051 bsend := testBrokerSending{make(chan store.InternalChannelId, 1)}
1052 testServer := httptest.NewServer(MakeHandlersMux(storage, bsend, nil))1052 testServer := httptest.NewServer(MakeHandlersMux(storage, bsend, s.testlog))
1053 defer testServer.Close()1053 defer testServer.Close()
10541054
1055 request := newPostRequest("/register", &Registration{1055 request := newPostRequest("/register", &Registration{
10561056
=== modified file 'server/broker/testsuite/suite.go'
--- server/broker/testsuite/suite.go 2014-09-25 11:16:38 +0000
+++ server/broker/testsuite/suite.go 2014-11-13 14:37:31 +0000
@@ -66,12 +66,12 @@
6666
67func (s *CommonBrokerSuite) TestSanity(c *C) {67func (s *CommonBrokerSuite) TestSanity(c *C) {
68 sto := store.NewInMemoryPendingStore()68 sto := store.NewInMemoryPendingStore()
69 b := s.MakeBroker(sto, testBrokerConfig, nil)69 b := s.MakeBroker(sto, testBrokerConfig, s.testlog)
70 c.Check(s.RevealSession(b, "FOO"), IsNil)70 c.Check(s.RevealSession(b, "FOO"), IsNil)
71}71}
7272
73func (s *CommonBrokerSuite) TestStartStop(c *C) {73func (s *CommonBrokerSuite) TestStartStop(c *C) {
74 b := s.MakeBroker(nil, testBrokerConfig, nil)74 b := s.MakeBroker(nil, testBrokerConfig, s.testlog)
75 b.Start()75 b.Start()
76 c.Check(b.Running(), Equals, true)76 c.Check(b.Running(), Equals, true)
77 b.Start()77 b.Start()
@@ -82,7 +82,7 @@
8282
83func (s *CommonBrokerSuite) TestRegistration(c *C) {83func (s *CommonBrokerSuite) TestRegistration(c *C) {
84 sto := store.NewInMemoryPendingStore()84 sto := store.NewInMemoryPendingStore()
85 b := s.MakeBroker(sto, testBrokerConfig, nil)85 b := s.MakeBroker(sto, testBrokerConfig, s.testlog)
86 b.Start()86 b.Start()
87 defer b.Stop()87 defer b.Stop()
88 sess, err := b.Register(&protocol.ConnectMsg{88 sess, err := b.Register(&protocol.ConnectMsg{
@@ -112,7 +112,7 @@
112112
113func (s *CommonBrokerSuite) TestRegistrationBrokenLevels(c *C) {113func (s *CommonBrokerSuite) TestRegistrationBrokenLevels(c *C) {
114 sto := store.NewInMemoryPendingStore()114 sto := store.NewInMemoryPendingStore()
115 b := s.MakeBroker(sto, testBrokerConfig, nil)115 b := s.MakeBroker(sto, testBrokerConfig, s.testlog)
116 b.Start()116 b.Start()
117 defer b.Stop()117 defer b.Stop()
118 _, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev-1", Levels: map[string]int64{"z": 5}}, s.MakeTracker("s1"))118 _, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev-1", Levels: map[string]int64{"z": 5}}, s.MakeTracker("s1"))
@@ -121,7 +121,7 @@
121121
122func (s *CommonBrokerSuite) TestRegistrationInfoErrors(c *C) {122func (s *CommonBrokerSuite) TestRegistrationInfoErrors(c *C) {
123 sto := store.NewInMemoryPendingStore()123 sto := store.NewInMemoryPendingStore()
124 b := s.MakeBroker(sto, testBrokerConfig, nil)124 b := s.MakeBroker(sto, testBrokerConfig, s.testlog)
125 b.Start()125 b.Start()
126 defer b.Stop()126 defer b.Stop()
127 info := map[string]interface{}{127 info := map[string]interface{}{
@@ -140,7 +140,7 @@
140 notification1 := json.RawMessage(`{"m": "M"}`)140 notification1 := json.RawMessage(`{"m": "M"}`)
141 muchLater := time.Now().Add(10 * time.Minute)141 muchLater := time.Now().Add(10 * time.Minute)
142 sto.AppendToChannel(store.SystemInternalChannelId, notification1, muchLater)142 sto.AppendToChannel(store.SystemInternalChannelId, notification1, muchLater)
143 b := s.MakeBroker(sto, testBrokerConfig, nil)143 b := s.MakeBroker(sto, testBrokerConfig, s.testlog)
144 b.Start()144 b.Start()
145 defer b.Stop()145 defer b.Stop()
146 sess, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev-1"}, s.MakeTracker("s1"))146 sess, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev-1"}, s.MakeTracker("s1"))
@@ -166,7 +166,7 @@
166166
167func (s *CommonBrokerSuite) TestRegistrationLastWins(c *C) {167func (s *CommonBrokerSuite) TestRegistrationLastWins(c *C) {
168 sto := store.NewInMemoryPendingStore()168 sto := store.NewInMemoryPendingStore()
169 b := s.MakeBroker(sto, testBrokerConfig, nil)169 b := s.MakeBroker(sto, testBrokerConfig, s.testlog)
170 b.Start()170 b.Start()
171 defer b.Stop()171 defer b.Stop()
172 sess1, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev-1"}, s.MakeTracker("s1"))172 sess1, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev-1"}, s.MakeTracker("s1"))
@@ -197,7 +197,7 @@
197 sto := store.NewInMemoryPendingStore()197 sto := store.NewInMemoryPendingStore()
198 notification1 := json.RawMessage(`{"m": "M"}`)198 notification1 := json.RawMessage(`{"m": "M"}`)
199 decoded1 := map[string]interface{}{"m": "M"}199 decoded1 := map[string]interface{}{"m": "M"}
200 b := s.MakeBroker(sto, testBrokerConfig, nil)200 b := s.MakeBroker(sto, testBrokerConfig, s.testlog)
201 b.Start()201 b.Start()
202 defer b.Stop()202 defer b.Stop()
203 sess1, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev-1"}, s.MakeTracker("s1"))203 sess1, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev-1"}, s.MakeTracker("s1"))
@@ -278,7 +278,7 @@
278 notification2 := json.RawMessage(`{"m": "M2"}`)278 notification2 := json.RawMessage(`{"m": "M2"}`)
279 chanId1 := store.UnicastInternalChannelId("dev1", "dev1")279 chanId1 := store.UnicastInternalChannelId("dev1", "dev1")
280 chanId2 := store.UnicastInternalChannelId("dev2", "dev2")280 chanId2 := store.UnicastInternalChannelId("dev2", "dev2")
281 b := s.MakeBroker(sto, testBrokerConfig, nil)281 b := s.MakeBroker(sto, testBrokerConfig, s.testlog)
282 b.Start()282 b.Start()
283 defer b.Stop()283 defer b.Stop()
284 sess1, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev1"}, s.MakeTracker("s1"))284 sess1, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev1"}, s.MakeTracker("s1"))
@@ -312,7 +312,7 @@
312 sto := store.NewInMemoryPendingStore()312 sto := store.NewInMemoryPendingStore()
313 notification1 := json.RawMessage(`{"m": "M1"}`)313 notification1 := json.RawMessage(`{"m": "M1"}`)
314 chanId1 := store.UnicastInternalChannelId("dev3", "dev3")314 chanId1 := store.UnicastInternalChannelId("dev3", "dev3")
315 b := s.MakeBroker(sto, testBrokerConfig, nil)315 b := s.MakeBroker(sto, testBrokerConfig, s.testlog)
316 b.Start()316 b.Start()
317 defer b.Stop()317 defer b.Stop()
318 sess1, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev3"}, s.MakeTracker("s1"))318 sess1, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev3"}, s.MakeTracker("s1"))
@@ -354,7 +354,7 @@
354354
355func (s *CommonBrokerSuite) TestSessionFeed(c *C) {355func (s *CommonBrokerSuite) TestSessionFeed(c *C) {
356 sto := store.NewInMemoryPendingStore()356 sto := store.NewInMemoryPendingStore()
357 b := s.MakeBroker(sto, testBrokerConfig, nil)357 b := s.MakeBroker(sto, testBrokerConfig, s.testlog)
358 b.Start()358 b.Start()
359 defer b.Stop()359 defer b.Stop()
360 sess1, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev3"}, s.MakeTracker("s1"))360 sess1, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev3"}, s.MakeTracker("s1"))

Subscribers

People subscribed via source and target branches