Merge lp:~pedronis/ubuntu-push/broker-testing into lp:ubuntu-push

Proposed by Samuele Pedroni
Status: Merged
Approved by: Samuele Pedroni
Approved revision: 27
Merged at revision: 22
Proposed branch: lp:~pedronis/ubuntu-push/broker-testing
Merge into: lp:ubuntu-push
Prerequisite: lp:~pedronis/ubuntu-push/broker-testsuite
Diff against target: 634 lines (+166/-132)
11 files modified
server/broker/broker.go (+2/-2)
server/broker/broker_test.go (+0/-3)
server/broker/exchanges_test.go (+18/-56)
server/broker/exchg_impl_test.go (+47/-0)
server/broker/simple/simple.go (+1/-1)
server/broker/simple/simple_test.go (+7/-14)
server/broker/testing/impls.go (+60/-0)
server/broker/testsuite/suite.go (+13/-19)
server/session/session_test.go (+15/-35)
server/session/tracker.go (+1/-1)
server/session/tracker_test.go (+2/-1)
To merge this branch: bzr merge lp:~pedronis/ubuntu-push/broker-testing
Reviewer Review Type Date Requested Status
John Lenton (community) Approve
Review via email: mp+203003@code.launchpad.net

Commit message

introduce reusable TestBrokerConfig and TestBrokerSession

Description of the change

introduce reusable TestBrokerConfig and TestBrokerSession

To post a comment you must log in.
Revision history for this message
John Lenton (chipaca) wrote :

You know me, I like this kind of branch.
Only thing that would've made it sweeter would've been a testing/impls_test.go

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'server/broker/broker.go'
2--- server/broker/broker.go 2014-01-24 08:01:44 +0000
3+++ server/broker/broker.go 2014-01-24 08:01:44 +0000
4@@ -52,8 +52,8 @@
5 // SessionChannel returns the session control channel
6 // on which the session gets exchanges to perform.
7 SessionChannel() <-chan Exchange
8- // DeviceId returns the device id string.
9- DeviceId() string
10+ // DeviceIdentifier returns the device id string.
11+ DeviceIdentifier() string
12 // Levels returns the current channel levels for the session
13 Levels() LevelsMap
14 // ExchangeScratchArea returns the scratch area for exchanges.
15
16=== modified file 'server/broker/broker_test.go'
17--- server/broker/broker_test.go 2014-01-15 08:39:04 +0000
18+++ server/broker/broker_test.go 2014-01-24 08:01:44 +0000
19@@ -19,11 +19,8 @@
20 import (
21 "fmt"
22 . "launchpad.net/gocheck"
23- "testing"
24 )
25
26-func TestBroker(t *testing.T) { TestingT(t) }
27-
28 type brokerSuite struct{}
29
30 var _ = Suite(&brokerSuite{})
31
32=== modified file 'server/broker/exchanges_test.go'
33--- server/broker/exchanges_test.go 2014-01-24 08:01:44 +0000
34+++ server/broker/exchanges_test.go 2014-01-24 08:01:44 +0000
35@@ -14,47 +14,29 @@
36 with this program. If not, see <http://www.gnu.org/licenses/>.
37 */
38
39-package broker
40+package broker_test // use a package test to avoid cyclic imports
41
42 import (
43 "encoding/json"
44 . "launchpad.net/gocheck"
45+ "launchpad.net/ubuntu-push/server/broker"
46+ "launchpad.net/ubuntu-push/server/broker/testing"
47 "launchpad.net/ubuntu-push/server/store"
48 // "log"
49+ gotesting "testing"
50 )
51
52+func TestBroker(t *gotesting.T) { TestingT(t) }
53+
54 type exchangesSuite struct{}
55
56 var _ = Suite(&exchangesSuite{})
57
58-type testBrokerSession struct {
59- deviceId string
60- exchanges chan Exchange
61- levels LevelsMap
62- exchgScratch ExchangesScratchArea
63-}
64-
65-func (tbs *testBrokerSession) SessionChannel() <-chan Exchange {
66- return nil
67-}
68-
69-func (tbs *testBrokerSession) DeviceId() string {
70- return ""
71-}
72-
73-func (tbs *testBrokerSession) Levels() LevelsMap {
74- return tbs.levels
75-}
76-
77-func (tbs *testBrokerSession) ExchangeScratchArea() *ExchangesScratchArea {
78- return &tbs.exchgScratch
79-}
80-
81 func (s *exchangesSuite) TestBroadcastExchange(c *C) {
82- sess := &testBrokerSession{
83- levels: map[store.InternalChannelId]int64{},
84+ sess := &testing.TestBrokerSession{
85+ LevelsMap: broker.LevelsMap(map[store.InternalChannelId]int64{}),
86 }
87- exchg := &BroadcastExchange{
88+ exchg := &broker.BroadcastExchange{
89 ChanId: store.SystemInternalChannelId,
90 TopLevel: 3,
91 NotificationPayloads: []json.RawMessage{
92@@ -72,14 +54,14 @@
93 c.Assert(err, IsNil)
94 err = exchg.Acked(sess)
95 c.Assert(err, IsNil)
96- c.Check(sess.levels[store.SystemInternalChannelId], Equals, int64(3))
97+ c.Check(sess.LevelsMap[store.SystemInternalChannelId], Equals, int64(3))
98 }
99
100 func (s *exchangesSuite) TestBroadcastExchangeAckMismatch(c *C) {
101- sess := &testBrokerSession{
102- levels: map[store.InternalChannelId]int64{},
103+ sess := &testing.TestBrokerSession{
104+ LevelsMap: broker.LevelsMap(map[store.InternalChannelId]int64{}),
105 }
106- exchg := &BroadcastExchange{
107+ exchg := &broker.BroadcastExchange{
108 ChanId: store.SystemInternalChannelId,
109 TopLevel: 3,
110 NotificationPayloads: []json.RawMessage{
111@@ -96,36 +78,16 @@
112 c.Assert(err, IsNil)
113 err = exchg.Acked(sess)
114 c.Assert(err, Not(IsNil))
115- c.Check(sess.levels[store.SystemInternalChannelId], Equals, int64(0))
116-}
117-
118-func (s *exchangesSuite) TestFilterByLevel(c *C) {
119- payloads := []json.RawMessage{
120- json.RawMessage(`{"a": 3}`),
121- json.RawMessage(`{"a": 4}`),
122- json.RawMessage(`{"a": 5}`),
123- }
124- res := filterByLevel(5, 5, payloads)
125- c.Check(len(res), Equals, 0)
126- res = filterByLevel(4, 5, payloads)
127- c.Check(len(res), Equals, 1)
128- c.Check(res[0], DeepEquals, json.RawMessage(`{"a": 5}`))
129- res = filterByLevel(3, 5, payloads)
130- c.Check(len(res), Equals, 2)
131- c.Check(res[0], DeepEquals, json.RawMessage(`{"a": 4}`))
132- res = filterByLevel(2, 5, payloads)
133- c.Check(len(res), Equals, 3)
134- res = filterByLevel(1, 5, payloads)
135- c.Check(len(res), Equals, 3)
136+ c.Check(sess.LevelsMap[store.SystemInternalChannelId], Equals, int64(0))
137 }
138
139 func (s *exchangesSuite) TestBroadcastExchangeFilterByLevel(c *C) {
140- sess := &testBrokerSession{
141- levels: map[store.InternalChannelId]int64{
142+ sess := &testing.TestBrokerSession{
143+ LevelsMap: broker.LevelsMap(map[store.InternalChannelId]int64{
144 store.SystemInternalChannelId: 2,
145- },
146+ }),
147 }
148- exchg := &BroadcastExchange{
149+ exchg := &broker.BroadcastExchange{
150 ChanId: store.SystemInternalChannelId,
151 TopLevel: 3,
152 NotificationPayloads: []json.RawMessage{
153
154=== added file 'server/broker/exchg_impl_test.go'
155--- server/broker/exchg_impl_test.go 1970-01-01 00:00:00 +0000
156+++ server/broker/exchg_impl_test.go 2014-01-24 08:01:44 +0000
157@@ -0,0 +1,47 @@
158+/*
159+ Copyright 2013-2014 Canonical Ltd.
160+
161+ This program is free software: you can redistribute it and/or modify it
162+ under the terms of the GNU General Public License version 3, as published
163+ by the Free Software Foundation.
164+
165+ This program is distributed in the hope that it will be useful, but
166+ WITHOUT ANY WARRANTY; without even the implied warranties of
167+ MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
168+ PURPOSE. See the GNU General Public License for more details.
169+
170+ You should have received a copy of the GNU General Public License along
171+ with this program. If not, see <http://www.gnu.org/licenses/>.
172+*/
173+
174+package broker
175+
176+import (
177+ "encoding/json"
178+ . "launchpad.net/gocheck"
179+ // "log"
180+)
181+
182+type exchangesImplSuite struct{}
183+
184+var _ = Suite(&exchangesImplSuite{})
185+
186+func (s *exchangesImplSuite) TestFilterByLevel(c *C) {
187+ payloads := []json.RawMessage{
188+ json.RawMessage(`{"a": 3}`),
189+ json.RawMessage(`{"a": 4}`),
190+ json.RawMessage(`{"a": 5}`),
191+ }
192+ res := filterByLevel(5, 5, payloads)
193+ c.Check(len(res), Equals, 0)
194+ res = filterByLevel(4, 5, payloads)
195+ c.Check(len(res), Equals, 1)
196+ c.Check(res[0], DeepEquals, json.RawMessage(`{"a": 5}`))
197+ res = filterByLevel(3, 5, payloads)
198+ c.Check(len(res), Equals, 2)
199+ c.Check(res[0], DeepEquals, json.RawMessage(`{"a": 4}`))
200+ res = filterByLevel(2, 5, payloads)
201+ c.Check(len(res), Equals, 3)
202+ res = filterByLevel(1, 5, payloads)
203+ c.Check(len(res), Equals, 3)
204+}
205
206=== modified file 'server/broker/simple/simple.go'
207--- server/broker/simple/simple.go 2014-01-24 08:01:44 +0000
208+++ server/broker/simple/simple.go 2014-01-24 08:01:44 +0000
209@@ -70,7 +70,7 @@
210 return sess.exchanges
211 }
212
213-func (sess *simpleBrokerSession) DeviceId() string {
214+func (sess *simpleBrokerSession) DeviceIdentifier() string {
215 return sess.deviceId
216 }
217
218
219=== modified file 'server/broker/simple/simple_test.go'
220--- server/broker/simple/simple_test.go 2014-01-24 08:01:44 +0000
221+++ server/broker/simple/simple_test.go 2014-01-24 08:01:44 +0000
222@@ -20,30 +20,23 @@
223 "encoding/json"
224 . "launchpad.net/gocheck"
225 "launchpad.net/ubuntu-push/server/broker"
226+ "launchpad.net/ubuntu-push/server/broker/testing"
227 "launchpad.net/ubuntu-push/server/store"
228 // "log"
229- "testing"
230+ gotesting "testing"
231 )
232
233-func TestSimple(t *testing.T) { TestingT(t) }
234+func TestSimple(t *gotesting.T) { TestingT(t) }
235
236 type simpleSuite struct{}
237
238 var _ = Suite(&simpleSuite{})
239
240-type testBrokerConfig struct{}
241-
242-func (tbc *testBrokerConfig) SessionQueueSize() uint {
243- return 10
244-}
245-
246-func (tbc *testBrokerConfig) BrokerQueueSize() uint {
247- return 5
248-}
249+var testBrokerConfig = &testing.TestBrokerConfig{10, 5}
250
251 func (s *simpleSuite) TestNew(c *C) {
252 sto := store.NewInMemoryPendingStore()
253- b := NewSimpleBroker(sto, &testBrokerConfig{}, nil)
254+ b := NewSimpleBroker(sto, testBrokerConfig, nil)
255 c.Check(cap(b.sessionCh), Equals, 5)
256 c.Check(len(b.registry), Equals, 0)
257 c.Check(b.sto, Equals, sto)
258@@ -53,7 +46,7 @@
259 sto := store.NewInMemoryPendingStore()
260 notification1 := json.RawMessage(`{"m": "M"}`)
261 sto.AppendToChannel(store.SystemInternalChannelId, notification1)
262- b := NewSimpleBroker(sto, &testBrokerConfig{}, nil)
263+ b := NewSimpleBroker(sto, testBrokerConfig, nil)
264 sess := &simpleBrokerSession{
265 exchanges: make(chan broker.Exchange, 1),
266 }
267@@ -71,7 +64,7 @@
268 sto := store.NewInMemoryPendingStore()
269 notification1 := json.RawMessage(`{"m": "M"}`)
270 sto.AppendToChannel(store.SystemInternalChannelId, notification1)
271- b := NewSimpleBroker(sto, &testBrokerConfig{}, nil)
272+ b := NewSimpleBroker(sto, testBrokerConfig, nil)
273 sess := &simpleBrokerSession{
274 exchanges: make(chan broker.Exchange, 1),
275 levels: map[store.InternalChannelId]int64{
276
277=== added directory 'server/broker/testing'
278=== added file 'server/broker/testing/impls.go'
279--- server/broker/testing/impls.go 1970-01-01 00:00:00 +0000
280+++ server/broker/testing/impls.go 2014-01-24 08:01:44 +0000
281@@ -0,0 +1,60 @@
282+/*
283+ Copyright 2013-2014 Canonical Ltd.
284+
285+ This program is free software: you can redistribute it and/or modify it
286+ under the terms of the GNU General Public License version 3, as published
287+ by the Free Software Foundation.
288+
289+ This program is distributed in the hope that it will be useful, but
290+ WITHOUT ANY WARRANTY; without even the implied warranties of
291+ MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
292+ PURPOSE. See the GNU General Public License for more details.
293+
294+ You should have received a copy of the GNU General Public License along
295+ with this program. If not, see <http://www.gnu.org/licenses/>.
296+*/
297+
298+// Package testing contains simple test implementations of some broker interfaces.
299+package testing
300+
301+import (
302+ "launchpad.net/ubuntu-push/server/broker"
303+)
304+
305+// Test implementation of BrokerSession.
306+type TestBrokerSession struct {
307+ DeviceId string
308+ Exchanges chan broker.Exchange
309+ LevelsMap broker.LevelsMap
310+ exchgScratch broker.ExchangesScratchArea
311+}
312+
313+func (tbs *TestBrokerSession) DeviceIdentifier() string {
314+ return tbs.DeviceId
315+}
316+
317+func (tbs *TestBrokerSession) SessionChannel() <-chan broker.Exchange {
318+ return tbs.Exchanges
319+}
320+
321+func (tbs *TestBrokerSession) Levels() broker.LevelsMap {
322+ return tbs.LevelsMap
323+}
324+
325+func (tbs *TestBrokerSession) ExchangeScratchArea() *broker.ExchangesScratchArea {
326+ return &tbs.exchgScratch
327+}
328+
329+// Test implementation of BrokerConfig.
330+type TestBrokerConfig struct {
331+ ConfigSessionQueueSize uint
332+ ConfigBrokerQueueSize uint
333+}
334+
335+func (tbc *TestBrokerConfig) SessionQueueSize() uint {
336+ return tbc.ConfigSessionQueueSize
337+}
338+
339+func (tbc *TestBrokerConfig) BrokerQueueSize() uint {
340+ return tbc.ConfigBrokerQueueSize
341+}
342
343=== modified file 'server/broker/testsuite/suite.go'
344--- server/broker/testsuite/suite.go 2014-01-24 08:01:44 +0000
345+++ server/broker/testsuite/suite.go 2014-01-24 08:01:44 +0000
346@@ -24,6 +24,7 @@
347 "launchpad.net/ubuntu-push/logger"
348 "launchpad.net/ubuntu-push/protocol"
349 "launchpad.net/ubuntu-push/server/broker"
350+ "launchpad.net/ubuntu-push/server/broker/testing"
351 "launchpad.net/ubuntu-push/server/store"
352 helpers "launchpad.net/ubuntu-push/testing"
353 // "log"
354@@ -47,24 +48,16 @@
355 RevealSession func(broker.Broker, string) broker.BrokerSession
356 }
357
358-type testBrokerConfig struct{}
359-
360-func (tbc *testBrokerConfig) SessionQueueSize() uint {
361- return 10
362-}
363-
364-func (tbc *testBrokerConfig) BrokerQueueSize() uint {
365- return 5
366-}
367+var testBrokerConfig = &testing.TestBrokerConfig{10, 5}
368
369 func (s *CommonBrokerSuite) TestSanity(c *C) {
370 sto := store.NewInMemoryPendingStore()
371- b := s.MakeBroker(sto, &testBrokerConfig{}, nil)
372+ b := s.MakeBroker(sto, testBrokerConfig, nil)
373 c.Check(s.RevealSession(b, "FOO"), IsNil)
374 }
375
376 func (s *CommonBrokerSuite) TestStartStop(c *C) {
377- b := s.MakeBroker(nil, &testBrokerConfig{}, nil)
378+ b := s.MakeBroker(nil, testBrokerConfig, nil)
379 b.Start()
380 c.Check(b.Running(), Equals, true)
381 b.Start()
382@@ -75,13 +68,14 @@
383
384 func (s *CommonBrokerSuite) TestRegistration(c *C) {
385 sto := store.NewInMemoryPendingStore()
386- b := s.MakeBroker(sto, &testBrokerConfig{}, nil)
387+ b := s.MakeBroker(sto, testBrokerConfig, nil)
388 b.Start()
389 defer b.Stop()
390 sess, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev-1", Levels: map[string]int64{"0": 5}})
391 c.Assert(err, IsNil)
392 c.Assert(s.RevealSession(b, "dev-1"), Equals, sess)
393- c.Assert(sess.DeviceId(), Equals, "dev-1")
394+ c.Assert(sess.DeviceIdentifier(), Equals, "dev-1")
395+ c.Assert(sess.ExchangeScratchArea(), Not(IsNil))
396 c.Check(sess.Levels(), DeepEquals, broker.LevelsMap(map[store.InternalChannelId]int64{
397 store.SystemInternalChannelId: 5,
398 }))
399@@ -94,7 +88,7 @@
400
401 func (s *CommonBrokerSuite) TestRegistrationBrokenLevels(c *C) {
402 sto := store.NewInMemoryPendingStore()
403- b := s.MakeBroker(sto, &testBrokerConfig{}, nil)
404+ b := s.MakeBroker(sto, testBrokerConfig, nil)
405 b.Start()
406 defer b.Stop()
407 _, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev-1", Levels: map[string]int64{"z": 5}})
408@@ -105,7 +99,7 @@
409 sto := store.NewInMemoryPendingStore()
410 notification1 := json.RawMessage(`{"m": "M"}`)
411 sto.AppendToChannel(store.SystemInternalChannelId, notification1)
412- b := s.MakeBroker(sto, &testBrokerConfig{}, nil)
413+ b := s.MakeBroker(sto, testBrokerConfig, nil)
414 b.Start()
415 defer b.Stop()
416 sess, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev-1"})
417@@ -117,7 +111,7 @@
418 buf := &helpers.SyncedLogBuffer{}
419 logger := logger.NewSimpleLogger(buf, "error")
420 sto := &testFailingStore{}
421- b := s.MakeBroker(sto, &testBrokerConfig{}, logger)
422+ b := s.MakeBroker(sto, testBrokerConfig, logger)
423 b.Start()
424 defer b.Stop()
425 _, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev-1"})
426@@ -128,7 +122,7 @@
427
428 func (s *CommonBrokerSuite) TestRegistrationLastWins(c *C) {
429 sto := store.NewInMemoryPendingStore()
430- b := s.MakeBroker(sto, &testBrokerConfig{}, nil)
431+ b := s.MakeBroker(sto, testBrokerConfig, nil)
432 b.Start()
433 defer b.Stop()
434 sess1, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev-1"})
435@@ -146,7 +140,7 @@
436 func (s *CommonBrokerSuite) TestBroadcast(c *C) {
437 sto := store.NewInMemoryPendingStore()
438 notification1 := json.RawMessage(`{"m": "M"}`)
439- b := s.MakeBroker(sto, &testBrokerConfig{}, nil)
440+ b := s.MakeBroker(sto, testBrokerConfig, nil)
441 b.Start()
442 defer b.Stop()
443 sess1, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev-1"})
444@@ -195,7 +189,7 @@
445 buf := &helpers.SyncedLogBuffer{Written: make(chan bool, 1)}
446 logger := logger.NewSimpleLogger(buf, "error")
447 sto := &testFailingStore{countdownToFail: 1}
448- b := s.MakeBroker(sto, &testBrokerConfig{}, logger)
449+ b := s.MakeBroker(sto, testBrokerConfig, logger)
450 b.Start()
451 defer b.Stop()
452 _, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev-1"})
453
454=== modified file 'server/session/session_test.go'
455--- server/session/session_test.go 2014-01-24 08:01:44 +0000
456+++ server/session/session_test.go 2014-01-24 08:01:44 +0000
457@@ -28,13 +28,14 @@
458 "launchpad.net/ubuntu-push/logger"
459 "launchpad.net/ubuntu-push/protocol"
460 "launchpad.net/ubuntu-push/server/broker"
461+ "launchpad.net/ubuntu-push/server/broker/testing"
462 "net"
463 "reflect"
464- "testing"
465+ gotesting "testing"
466 "time"
467 )
468
469-func TestSession(t *testing.T) { TestingT(t) }
470+func TestSession(t *gotesting.T) { TestingT(t) }
471
472 type sessionSuite struct{}
473
474@@ -123,34 +124,13 @@
475 return &testBroker{registration: make(chan interface{}, 2)}
476 }
477
478-type testBrokerSession struct {
479- deviceId string
480- exchanges chan broker.Exchange
481-}
482-
483-func (tbs *testBrokerSession) SessionChannel() <-chan broker.Exchange {
484- return tbs.exchanges
485-}
486-
487-func (tbs *testBrokerSession) DeviceId() string {
488- return tbs.deviceId
489-}
490-
491-func (tbs *testBrokerSession) Levels() broker.LevelsMap {
492- return nil
493-}
494-
495-func (tbs *testBrokerSession) ExchangeScratchArea() *broker.ExchangesScratchArea {
496- return nil
497-}
498-
499 func (tb *testBroker) Register(connect *protocol.ConnectMsg) (broker.BrokerSession, error) {
500 tb.registration <- "register " + connect.DeviceId
501- return &testBrokerSession{connect.DeviceId, nil}, tb.err
502+ return &testing.TestBrokerSession{DeviceId: connect.DeviceId}, tb.err
503 }
504
505 func (tb *testBroker) Unregister(sess broker.BrokerSession) {
506- tb.registration <- "unregister " + sess.(*testBrokerSession).deviceId
507+ tb.registration <- "unregister " + sess.DeviceIdentifier()
508 }
509
510 func (s *sessionSuite) TestSessionStart(c *C) {
511@@ -176,7 +156,7 @@
512 err := <-errCh
513 c.Check(err, IsNil)
514 c.Check(takeNext(brkr.registration), Equals, "register dev-1")
515- c.Check(sess.(*testBrokerSession).deviceId, Equals, "dev-1")
516+ c.Check(sess.DeviceIdentifier(), Equals, "dev-1")
517 }
518
519 func (s *sessionSuite) TestSessionRegisterError(c *C) {
520@@ -242,7 +222,7 @@
521 up := make(chan interface{}, 5)
522 down := make(chan interface{}, 5)
523 tp := &testProtocol{up, down}
524- sess := &testBrokerSession{}
525+ sess := &testing.TestBrokerSession{}
526 go func() {
527 errCh <- sessionLoop(tp, sess, cfg5msPingInterval2msExchangeTout)
528 }()
529@@ -263,7 +243,7 @@
530 up := make(chan interface{}, 5)
531 down := make(chan interface{}, 5)
532 tp := &testProtocol{up, down}
533- sess := &testBrokerSession{}
534+ sess := &testing.TestBrokerSession{}
535 go func() {
536 errCh <- sessionLoop(tp, sess, cfg5msPingInterval2msExchangeTout)
537 }()
538@@ -279,7 +259,7 @@
539 up := make(chan interface{}, 5)
540 down := make(chan interface{}, 5)
541 tp := &testProtocol{up, down}
542- sess := &testBrokerSession{}
543+ sess := &testing.TestBrokerSession{}
544 go func() {
545 errCh <- sessionLoop(tp, sess, cfg5msPingInterval2msExchangeTout)
546 }()
547@@ -332,7 +312,7 @@
548 tp := &testProtocol{up, down}
549 exchanges := make(chan broker.Exchange, 1)
550 exchanges <- &testExchange{}
551- sess := &testBrokerSession{exchanges: exchanges}
552+ sess := &testing.TestBrokerSession{Exchanges: exchanges}
553 go func() {
554 errCh <- sessionLoop(tp, sess, cfg5msPingInterval2msExchangeTout)
555 }()
556@@ -355,7 +335,7 @@
557 tp := &testProtocol{up, down}
558 exchanges := make(chan broker.Exchange, 1)
559 exchanges <- &testExchange{nParts: 2}
560- sess := &testBrokerSession{exchanges: exchanges}
561+ sess := &testing.TestBrokerSession{Exchanges: exchanges}
562 go func() {
563 errCh <- sessionLoop(tp, sess, cfg5msPingInterval2msExchangeTout)
564 }()
565@@ -383,7 +363,7 @@
566 exchanges := make(chan broker.Exchange, 1)
567 prepErr := errors.New("prepare failure")
568 exchanges <- &testExchange{prepErr: prepErr}
569- sess := &testBrokerSession{exchanges: exchanges}
570+ sess := &testing.TestBrokerSession{Exchanges: exchanges}
571 go func() {
572 errCh <- sessionLoop(tp, sess, cfg5msPingInterval2msExchangeTout)
573 }()
574@@ -399,7 +379,7 @@
575 exchanges := make(chan broker.Exchange, 1)
576 finErr := errors.New("finish error")
577 exchanges <- &testExchange{finErr: finErr}
578- sess := &testBrokerSession{exchanges: exchanges}
579+ sess := &testing.TestBrokerSession{Exchanges: exchanges}
580 go func() {
581 errCh <- sessionLoop(tp, sess, cfg5msPingInterval2msExchangeTout)
582 }()
583@@ -418,7 +398,7 @@
584 tp := &testProtocol{up, down}
585 exchanges := make(chan broker.Exchange, 1)
586 exchanges <- &testExchange{}
587- sess := &testBrokerSession{exchanges: exchanges}
588+ sess := &testing.TestBrokerSession{Exchanges: exchanges}
589 go func() {
590 errCh <- sessionLoop(tp, sess, cfg5msPingInterval2msExchangeTout)
591 }()
592@@ -436,7 +416,7 @@
593 tp := &testProtocol{up, down}
594 exchanges := make(chan broker.Exchange, 1)
595 exchanges <- &testExchange{finSleep: 3 * time.Millisecond}
596- sess := &testBrokerSession{exchanges: exchanges}
597+ sess := &testing.TestBrokerSession{Exchanges: exchanges}
598 go func() {
599 errCh <- sessionLoop(tp, sess, cfg5msPingInterval2msExchangeTout)
600 }()
601
602=== modified file 'server/session/tracker.go'
603--- server/session/tracker.go 2014-01-15 08:55:54 +0000
604+++ server/session/tracker.go 2014-01-24 08:01:44 +0000
605@@ -57,7 +57,7 @@
606 }
607
608 func (trk *tracker) Registered(sess broker.BrokerSession) {
609- trk.Infof("session(%x) registered %v", trk.sessionId, sess.DeviceId())
610+ trk.Infof("session(%x) registered %v", trk.sessionId, sess.DeviceIdentifier())
611 }
612
613 func (trk *tracker) End(err error) error {
614
615=== modified file 'server/session/tracker_test.go'
616--- server/session/tracker_test.go 2014-01-15 08:55:54 +0000
617+++ server/session/tracker_test.go 2014-01-24 08:01:44 +0000
618@@ -22,6 +22,7 @@
619 . "launchpad.net/gocheck"
620 "launchpad.net/ubuntu-push/logger"
621 "launchpad.net/ubuntu-push/server/broker"
622+ "launchpad.net/ubuntu-push/server/broker/testing"
623 "net"
624 )
625
626@@ -50,7 +51,7 @@
627 logger := logger.NewSimpleLogger(buf, "debug")
628 track := NewTracker(logger)
629 track.Start(&testRemoteAddrable{})
630- track.Registered(&testBrokerSession{deviceId: "DEV-ID"})
631+ track.Registered(&testing.TestBrokerSession{DeviceId: "DEV-ID"})
632 regExpected := fmt.Sprintf(`.*connected.*\n.* INFO session\(%x\) registered DEV-ID\n`, track.(*tracker).sessionId)
633 c.Check(buf.String(), Matches, regExpected)
634 }

Subscribers

People subscribed via source and target branches