Merge lp:~chipaca/ubuntu-push/session-refactor-001 into lp:ubuntu-push/automatic

Proposed by John Lenton
Status: Work in progress
Proposed branch: lp:~chipaca/ubuntu-push/session-refactor-001
Merge into: lp:ubuntu-push/automatic
Diff against target: 1093 lines (+207/-161)
4 files modified
client/client.go (+4/-4)
client/client_test.go (+15/-11)
client/session/session.go (+80/-38)
client/session/session_test.go (+108/-108)
To merge this branch: bzr merge lp:~chipaca/ubuntu-push/session-refactor-001
Reviewer Review Type Date Requested Status
Ubuntu Push Hackers Pending
Review via email: mp+249493@code.launchpad.net
To post a comment you must log in.

Unmerged revisions

366. By John Lenton

protect the chs with a lock. any lock will do.

365. By John Lenton

added SetChForTesting, for testing

364. By John Lenton

first step

363. By John Lenton

Merged explicit-check-for-oversize-webcheck-response-bodies into session-refactor.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'client/client.go'
2--- client/client.go 2015-01-26 21:00:27 +0000
3+++ client/client.go 2015-02-12 14:33:25 +0000
4@@ -116,7 +116,7 @@
5 systemImageInfo *systemimage.InfoResult
6 connCh chan bool
7 hasConnectivity bool
8- session *session.ClientSession
9+ session session.ClientSession
10 sessionConnectedCh chan uint32
11 pushService PushService
12 postalService PostalService
13@@ -483,11 +483,11 @@
14 accountshandler()
15 case state := <-client.connCh:
16 connhandler(state)
17- case bcast := <-client.session.BroadcastCh:
18+ case bcast := <-client.session.GetBroadcastCh():
19 bcasthandler(bcast)
20- case aucast := <-client.session.NotificationsCh:
21+ case aucast := <-client.session.GetNotificationsCh():
22 ucasthandler(aucast)
23- case err := <-client.session.ErrCh:
24+ case err := <-client.session.GetErrCh():
25 errhandler(err)
26 case count := <-client.sessionConnectedCh:
27 client.log.Debugf("session connected after %d attempts", count)
28
29=== modified file 'client/client_test.go'
30--- client/client_test.go 2015-02-06 13:09:16 +0000
31+++ client/client_test.go 2015-02-12 14:33:25 +0000
32@@ -528,7 +528,7 @@
33 func (cs *clientSuite) TestDerivePollerSetup(c *C) {
34 cs.writeTestConfig(map[string]interface{}{})
35 cli := NewPushClient(cs.configPath, cs.leveldbPath)
36- cli.session = new(session.ClientSession)
37+ cli.session = new(session.ConcreteSession)
38 err := cli.configure()
39 c.Assert(err, IsNil)
40 expected := &poller.PollerSetup{
41@@ -1031,8 +1031,9 @@
42 cli.log = cs.log
43 cli.systemImageInfo = siInfoRes
44 c.Assert(cli.initSessionAndPoller(), IsNil)
45- cli.session.BroadcastCh = make(chan *session.BroadcastNotification, 1)
46- cli.session.BroadcastCh <- &session.BroadcastNotification{}
47+ bcastCh := make(chan *session.BroadcastNotification, 1)
48+ cli.session.SetChForTesting(bcastCh, nil, nil)
49+ bcastCh <- &session.BroadcastNotification{}
50
51 ch := make(chan bool, 1)
52 go cli.doLoop(nopConn, func(_ *session.BroadcastNotification) error { ch <- true; return nil }, nopUcast, nopError, nopUnregister, nopAcct)
53@@ -1044,8 +1045,9 @@
54 cli.log = cs.log
55 cli.systemImageInfo = siInfoRes
56 c.Assert(cli.initSessionAndPoller(), IsNil)
57- cli.session.NotificationsCh = make(chan session.AddressedNotification, 1)
58- cli.session.NotificationsCh <- session.AddressedNotification{}
59+ notifCh := make(chan session.AddressedNotification, 1)
60+ cli.session.SetChForTesting(nil, notifCh, nil)
61+ notifCh <- session.AddressedNotification{}
62
63 ch := make(chan bool, 1)
64 go cli.doLoop(nopConn, nopBcast, func(session.AddressedNotification) error { ch <- true; return nil }, nopError, nopUnregister, nopAcct)
65@@ -1057,8 +1059,9 @@
66 cli.log = cs.log
67 cli.systemImageInfo = siInfoRes
68 c.Assert(cli.initSessionAndPoller(), IsNil)
69- cli.session.ErrCh = make(chan error, 1)
70- cli.session.ErrCh <- nil
71+ errCh := make(chan error, 1)
72+ cli.session.SetChForTesting(nil, nil, errCh)
73+ errCh <- nil
74
75 ch := make(chan bool, 1)
76 go cli.doLoop(nopConn, nopBcast, nopUcast, func(error) { ch <- true }, nopUnregister, nopAcct)
77@@ -1137,8 +1140,9 @@
78
79 c.Assert(cli.initSessionAndPoller(), IsNil)
80
81- cli.session.BroadcastCh = make(chan *session.BroadcastNotification)
82- cli.session.ErrCh = make(chan error)
83+ bcastCh := make(chan *session.BroadcastNotification)
84+ errCh := make(chan error)
85+ cli.session.SetChForTesting(bcastCh, nil, errCh)
86
87 // we use tick() to make sure things have been through the
88 // event loop at least once before looking at things;
89@@ -1165,12 +1169,12 @@
90
91 // * session.BroadcastCh to the notifications handler
92 c.Check(d.bcastCount, Equals, 0)
93- cli.session.BroadcastCh <- positiveBroadcastNotification
94+ bcastCh <- positiveBroadcastNotification
95 tick()
96 c.Check(d.bcastCount, Equals, 1)
97
98 // * session.ErrCh to the error handler
99- cli.session.ErrCh <- nil
100+ errCh <- nil
101 tick()
102 c.Check(cs.log.Captured(), Matches, "(?ms).*session exited.*")
103 }
104
105=== modified file 'client/session/session.go'
106--- client/session/session.go 2015-01-22 11:05:37 +0000
107+++ client/session/session.go 2015-02-12 14:33:25 +0000
108@@ -120,8 +120,20 @@
109 AddresseeChecker AddresseeChecking
110 }
111
112-// ClientSession holds a client<->server session and its configuration.
113-type ClientSession struct {
114+type ClientSession interface {
115+ State() ClientSessionState
116+ Close()
117+ AutoRedial(done chan uint32)
118+ ClearCookie()
119+ Dial() error
120+ GetBroadcastCh() chan *BroadcastNotification
121+ GetNotificationsCh() chan AddressedNotification
122+ GetErrCh() chan error
123+ SetChForTesting(chan *BroadcastNotification, chan AddressedNotification, chan error)
124+}
125+
126+// ConcreteSession holds a client<->server session and its configuration.
127+type ConcreteSession struct {
128 // configuration
129 DeviceId string
130 ClientSessionConfig
131@@ -157,13 +169,13 @@
132 // autoredial knobs
133 shouldDelayP *uint32
134 lastAutoRedial time.Time
135- redialDelay func(*ClientSession) time.Duration
136+ redialDelay func(*ConcreteSession) time.Duration
137 redialJitter func(time.Duration) time.Duration
138 redialDelays []time.Duration
139 redialDelaysIdx int
140 }
141
142-func redialDelay(sess *ClientSession) time.Duration {
143+func redialDelay(sess *ConcreteSession) time.Duration {
144 if sess.ShouldDelay() {
145 t := sess.redialDelays[sess.redialDelaysIdx]
146 if len(sess.redialDelays) > sess.redialDelaysIdx+1 {
147@@ -178,7 +190,13 @@
148
149 func NewSession(serverAddrSpec string, conf ClientSessionConfig,
150 deviceId string, seenStateFactory func() (seenstate.SeenState, error),
151- log logger.Logger) (*ClientSession, error) {
152+ log logger.Logger) (ClientSession, error) {
153+ return newSession(serverAddrSpec, conf, deviceId, seenStateFactory, log)
154+}
155+
156+func newSession(serverAddrSpec string, conf ClientSessionConfig,
157+ deviceId string, seenStateFactory func() (seenstate.SeenState, error),
158+ log logger.Logger) (*ConcreteSession, error) {
159 state := uint32(Disconnected)
160 seenState, err := seenStateFactory()
161 if err != nil {
162@@ -191,7 +209,7 @@
163 getHost = gethosts.New(deviceId, hostsEndpoint, conf.ExchangeTimeout)
164 }
165 var shouldDelay uint32 = 0
166- sess := &ClientSession{
167+ sess := &ConcreteSession{
168 ClientSessionConfig: conf,
169 getHost: getHost,
170 fallbackHosts: fallbackHosts,
171@@ -218,59 +236,83 @@
172 return sess, nil
173 }
174
175-func (sess *ClientSession) ShouldDelay() bool {
176+func (sess *ConcreteSession) GetBroadcastCh() chan *BroadcastNotification {
177+ return sess.BroadcastCh
178+}
179+func (sess *ConcreteSession) GetNotificationsCh() chan AddressedNotification {
180+ return sess.NotificationsCh
181+}
182+func (sess *ConcreteSession) GetErrCh() chan error {
183+ return sess.ErrCh
184+}
185+func (sess *ConcreteSession) SetChForTesting(bch chan *BroadcastNotification, nch chan AddressedNotification, ech chan error) {
186+ // abusing connLock a bit
187+ sess.connLock.Lock()
188+ defer sess.connLock.Unlock()
189+ if bch != nil {
190+ sess.BroadcastCh = bch
191+ }
192+ if nch != nil {
193+ sess.NotificationsCh = nch
194+ }
195+ if ech != nil {
196+ sess.ErrCh = ech
197+ }
198+}
199+
200+func (sess *ConcreteSession) ShouldDelay() bool {
201 return atomic.LoadUint32(sess.shouldDelayP) != 0
202 }
203
204-func (sess *ClientSession) setShouldDelay() {
205+func (sess *ConcreteSession) setShouldDelay() {
206 atomic.StoreUint32(sess.shouldDelayP, uint32(1))
207 }
208
209-func (sess *ClientSession) clearShouldDelay() {
210+func (sess *ConcreteSession) clearShouldDelay() {
211 atomic.StoreUint32(sess.shouldDelayP, uint32(0))
212 }
213
214-func (sess *ClientSession) State() ClientSessionState {
215+func (sess *ConcreteSession) State() ClientSessionState {
216 return ClientSessionState(atomic.LoadUint32(sess.stateP))
217 }
218
219-func (sess *ClientSession) setState(state ClientSessionState) {
220+func (sess *ConcreteSession) setState(state ClientSessionState) {
221 sess.Log.Debugf("session.setState: %s -> %s", ClientSessionState(atomic.LoadUint32(sess.stateP)), state)
222 atomic.StoreUint32(sess.stateP, uint32(state))
223 }
224
225-func (sess *ClientSession) setConnection(conn net.Conn) {
226+func (sess *ConcreteSession) setConnection(conn net.Conn) {
227 sess.connLock.Lock()
228 defer sess.connLock.Unlock()
229 sess.Connection = conn
230 }
231
232-func (sess *ClientSession) getConnection() net.Conn {
233+func (sess *ConcreteSession) getConnection() net.Conn {
234 sess.connLock.RLock()
235 defer sess.connLock.RUnlock()
236 return sess.Connection
237 }
238
239-func (sess *ClientSession) setCookie(cookie string) {
240+func (sess *ConcreteSession) setCookie(cookie string) {
241 sess.connLock.Lock()
242 defer sess.connLock.Unlock()
243 sess.cookie = cookie
244 }
245
246-func (sess *ClientSession) getCookie() string {
247+func (sess *ConcreteSession) getCookie() string {
248 sess.connLock.RLock()
249 defer sess.connLock.RUnlock()
250 return sess.cookie
251 }
252
253-func (sess *ClientSession) ClearCookie() {
254+func (sess *ConcreteSession) ClearCookie() {
255 sess.connLock.Lock()
256 defer sess.connLock.Unlock()
257 sess.cookie = ""
258 }
259
260 // getHosts sets deliveryHosts possibly querying a remote endpoint
261-func (sess *ClientSession) getHosts() error {
262+func (sess *ConcreteSession) getHosts() error {
263 if sess.getHost != nil {
264 if sess.deliveryHosts != nil && sess.timeSince(sess.deliveryHostsTimestamp) < sess.HostsCachingExpiryTime {
265 return nil
266@@ -294,7 +336,7 @@
267
268 // addAuthorization gets the authorization blob to send to the server
269 // and adds it to the session.
270-func (sess *ClientSession) addAuthorization() error {
271+func (sess *ConcreteSession) addAuthorization() error {
272 if sess.AuthGetter != nil {
273 sess.Log.Debugf("adding authorization")
274 sess.auth = sess.AuthGetter(sess.AuthURL)
275@@ -302,13 +344,13 @@
276 return nil
277 }
278
279-func (sess *ClientSession) resetHosts() {
280+func (sess *ConcreteSession) resetHosts() {
281 sess.deliveryHosts = nil
282 }
283
284 // startConnectionAttempt/nextHostToTry help connect iterating over candidate hosts
285
286-func (sess *ClientSession) startConnectionAttempt() {
287+func (sess *ConcreteSession) startConnectionAttempt() {
288 if sess.timeSince(sess.lastAttemptTimestamp) > sess.ExpectAllRepairedTime {
289 sess.tryHost = 0
290 }
291@@ -319,7 +361,7 @@
292 sess.lastAttemptTimestamp = time.Now()
293 }
294
295-func (sess *ClientSession) nextHostToTry() string {
296+func (sess *ConcreteSession) nextHostToTry() string {
297 if sess.leftToTry == 0 {
298 return ""
299 }
300@@ -331,7 +373,7 @@
301
302 // we reached the Started state, we can retry with the same host if we
303 // have to retry again
304-func (sess *ClientSession) started() {
305+func (sess *ConcreteSession) started() {
306 sess.tryHost--
307 if sess.tryHost == -1 {
308 sess.tryHost = len(sess.deliveryHosts) - 1
309@@ -341,7 +383,7 @@
310
311 // connect to a server using the configuration in the ClientSession
312 // and set up the connection.
313-func (sess *ClientSession) connect() error {
314+func (sess *ConcreteSession) connect() error {
315 sess.setShouldDelay()
316 sess.startConnectionAttempt()
317 var err error
318@@ -363,7 +405,7 @@
319 return nil
320 }
321
322-func (sess *ClientSession) stopRedial() {
323+func (sess *ConcreteSession) stopRedial() {
324 sess.retrierLock.Lock()
325 defer sess.retrierLock.Unlock()
326 if sess.retrier != nil {
327@@ -372,7 +414,7 @@
328 }
329 }
330
331-func (sess *ClientSession) AutoRedial(doneCh chan uint32) {
332+func (sess *ConcreteSession) AutoRedial(doneCh chan uint32) {
333 sess.stopRedial()
334 if time.Since(sess.lastAutoRedial) < 2*time.Second {
335 sess.setShouldDelay()
336@@ -398,12 +440,12 @@
337 }()
338 }
339
340-func (sess *ClientSession) Close() {
341+func (sess *ConcreteSession) Close() {
342 sess.stopRedial()
343 sess.doClose()
344 }
345
346-func (sess *ClientSession) doClose() {
347+func (sess *ConcreteSession) doClose() {
348 sess.connLock.Lock()
349 defer sess.connLock.Unlock()
350 if sess.Connection != nil {
351@@ -417,7 +459,7 @@
352 }
353
354 // handle "ping" messages
355-func (sess *ClientSession) handlePing() error {
356+func (sess *ConcreteSession) handlePing() error {
357 err := sess.proto.WriteMessage(protocol.PingPongMsg{Type: "pong"})
358 if err == nil {
359 sess.Log.Debugf("ping.")
360@@ -429,7 +471,7 @@
361 return err
362 }
363
364-func (sess *ClientSession) decodeBroadcast(bcast *serverMsg) *BroadcastNotification {
365+func (sess *ConcreteSession) decodeBroadcast(bcast *serverMsg) *BroadcastNotification {
366 decoded := make([]map[string]interface{}, 0)
367 for _, p := range bcast.Payloads {
368 var v map[string]interface{}
369@@ -447,7 +489,7 @@
370 }
371
372 // handle "broadcast" messages
373-func (sess *ClientSession) handleBroadcast(bcast *serverMsg) error {
374+func (sess *ConcreteSession) handleBroadcast(bcast *serverMsg) error {
375 err := sess.SeenState.SetLevel(bcast.ChanId, bcast.TopLevel)
376 if err != nil {
377 sess.setState(Error)
378@@ -478,7 +520,7 @@
379 }
380
381 // handle "notifications" messages
382-func (sess *ClientSession) handleNotifications(ucast *serverMsg) error {
383+func (sess *ConcreteSession) handleNotifications(ucast *serverMsg) error {
384 notifs, err := sess.SeenState.FilterBySeen(ucast.Notifications)
385 if err != nil {
386 sess.setState(Error)
387@@ -512,7 +554,7 @@
388 }
389
390 // handle "connbroken" messages
391-func (sess *ClientSession) handleConnBroken(connBroken *serverMsg) error {
392+func (sess *ConcreteSession) handleConnBroken(connBroken *serverMsg) error {
393 sess.setState(Error)
394 reason := connBroken.Reason
395 err := fmt.Errorf("server broke connection: %s", reason)
396@@ -525,7 +567,7 @@
397 }
398
399 // handle "setparams" messages
400-func (sess *ClientSession) handleSetParams(setParams *serverMsg) error {
401+func (sess *ConcreteSession) handleSetParams(setParams *serverMsg) error {
402 if setParams.SetCookie != "" {
403 sess.setCookie(setParams.SetCookie)
404 }
405@@ -533,7 +575,7 @@
406 }
407
408 // loop runs the session with the server, emits a stream of events.
409-func (sess *ClientSession) loop() error {
410+func (sess *ConcreteSession) loop() error {
411 var err error
412 var recv serverMsg
413 sess.setState(Running)
414@@ -571,7 +613,7 @@
415 }
416
417 // Call this when you've connected and want to start looping.
418-func (sess *ClientSession) start() error {
419+func (sess *ConcreteSession) start() error {
420 conn := sess.getConnection()
421 err := conn.SetDeadline(time.Now().Add(sess.ExchangeTimeout))
422 if err != nil {
423@@ -634,7 +676,7 @@
424
425 // run calls connect, and if it works it calls start, and if it works
426 // it runs loop in a goroutine, and ships its return value over ErrCh.
427-func (sess *ClientSession) run(closer func(), authChecker, hostGetter, connecter, starter, looper func() error) error {
428+func (sess *ConcreteSession) run(closer func(), authChecker, hostGetter, connecter, starter, looper func() error) error {
429 closer()
430 if err := authChecker(); err != nil {
431 return err
432@@ -656,7 +698,7 @@
433 }
434
435 // This Jitter returns a random time.Duration somewhere in [-spread, spread].
436-func (sess *ClientSession) Jitter(spread time.Duration) time.Duration {
437+func (sess *ConcreteSession) Jitter(spread time.Duration) time.Duration {
438 if spread < 0 {
439 panic("spread must be non-negative")
440 }
441@@ -666,7 +708,7 @@
442
443 // Dial takes the session from newly created (or newly disconnected)
444 // to running the main loop.
445-func (sess *ClientSession) Dial() error {
446+func (sess *ConcreteSession) Dial() error {
447 if sess.Protocolator == nil {
448 // a missing protocolator means you've willfully overridden
449 // it; returning an error here would prompt AutoRedial to just
450
451=== modified file 'client/session/session_test.go'
452--- client/session/session_test.go 2015-02-02 16:49:46 +0000
453+++ client/session/session_test.go 2015-02-12 14:33:25 +0000
454@@ -169,20 +169,20 @@
455
456 /////
457
458-type clientSessionSuite struct {
459+type ConcreteSessionSuite struct {
460 log *helpers.TestLogger
461 lvls func() (seenstate.SeenState, error)
462 }
463
464-func (cs *clientSessionSuite) SetUpTest(c *C) {
465+func (cs *ConcreteSessionSuite) SetUpTest(c *C) {
466 cs.log = helpers.NewTestLogger(c, "debug")
467 }
468
469 // in-memory level map testing
470-var _ = Suite(&clientSessionSuite{lvls: seenstate.NewSeenState})
471+var _ = Suite(&ConcreteSessionSuite{lvls: seenstate.NewSeenState})
472
473 // sqlite level map testing
474-type clientSqlevelsSessionSuite struct{ clientSessionSuite }
475+type clientSqlevelsSessionSuite struct{ ConcreteSessionSuite }
476
477 var _ = Suite(&clientSqlevelsSessionSuite{})
478
479@@ -194,7 +194,7 @@
480 parseServerAddrSpec() tests
481 ****************************************************************/
482
483-func (cs *clientSessionSuite) TestParseServerAddrSpec(c *C) {
484+func (cs *ConcreteSessionSuite) TestParseServerAddrSpec(c *C) {
485 hEp, fallbackHosts := parseServerAddrSpec("http://foo/hosts")
486 c.Check(hEp, Equals, "http://foo/hosts")
487 c.Check(fallbackHosts, IsNil)
488@@ -209,13 +209,13 @@
489 }
490
491 /****************************************************************
492- NewSession() tests
493+ newSession() tests
494 ****************************************************************/
495
496 var dummyConf = ClientSessionConfig{}
497
498-func (cs *clientSessionSuite) TestNewSessionPlainWorks(c *C) {
499- sess, err := NewSession("foo:443", dummyConf, "", cs.lvls, cs.log)
500+func (cs *ConcreteSessionSuite) TestnewSessionPlainWorks(c *C) {
501+ sess, err := newSession("foo:443", dummyConf, "", cs.lvls, cs.log)
502 c.Check(sess, NotNil)
503 c.Check(err, IsNil)
504 c.Check(sess.fallbackHosts, DeepEquals, []string{"foo:443"})
505@@ -228,8 +228,8 @@
506 c.Check(sess.State(), Equals, Disconnected)
507 }
508
509-func (cs *clientSessionSuite) TestNewSessionHostEndpointWorks(c *C) {
510- sess, err := NewSession("http://foo/hosts", dummyConf, "wah", cs.lvls, cs.log)
511+func (cs *ConcreteSessionSuite) TestnewSessionHostEndpointWorks(c *C) {
512+ sess, err := newSession("http://foo/hosts", dummyConf, "wah", cs.lvls, cs.log)
513 c.Assert(err, IsNil)
514 c.Check(sess.getHost, NotNil)
515 }
516@@ -237,25 +237,25 @@
517 var certfile string = helpers.SourceRelative("../../server/acceptance/ssl/testing.cert")
518 var pem, _ = ioutil.ReadFile(certfile)
519
520-func (cs *clientSessionSuite) TestNewSessionPEMWorks(c *C) {
521+func (cs *ConcreteSessionSuite) TestnewSessionPEMWorks(c *C) {
522 conf := ClientSessionConfig{PEM: pem}
523- sess, err := NewSession("", conf, "wah", cs.lvls, cs.log)
524+ sess, err := newSession("", conf, "wah", cs.lvls, cs.log)
525 c.Check(sess, NotNil)
526 c.Assert(err, IsNil)
527 c.Check(sess.TLS.RootCAs, NotNil)
528 }
529
530-func (cs *clientSessionSuite) TestNewSessionBadPEMFileContentFails(c *C) {
531+func (cs *ConcreteSessionSuite) TestnewSessionBadPEMFileContentFails(c *C) {
532 badpem := []byte("This is not the PEM you're looking for.")
533 conf := ClientSessionConfig{PEM: badpem}
534- sess, err := NewSession("", conf, "wah", cs.lvls, cs.log)
535+ sess, err := newSession("", conf, "wah", cs.lvls, cs.log)
536 c.Check(sess, IsNil)
537 c.Check(err, NotNil)
538 }
539
540-func (cs *clientSessionSuite) TestNewSessionBadSeenStateFails(c *C) {
541+func (cs *ConcreteSessionSuite) TestnewSessionBadSeenStateFails(c *C) {
542 ferr := func() (seenstate.SeenState, error) { return nil, errors.New("Busted.") }
543- sess, err := NewSession("", dummyConf, "wah", ferr, cs.log)
544+ sess, err := newSession("", dummyConf, "wah", ferr, cs.log)
545 c.Check(sess, IsNil)
546 c.Assert(err, NotNil)
547 }
548@@ -264,9 +264,9 @@
549 getHosts() tests
550 ****************************************************************/
551
552-func (cs *clientSessionSuite) TestGetHostsFallback(c *C) {
553+func (cs *ConcreteSessionSuite) TestGetHostsFallback(c *C) {
554 fallback := []string{"foo:443", "bar:443"}
555- sess := &ClientSession{fallbackHosts: fallback}
556+ sess := &ConcreteSession{fallbackHosts: fallback}
557 err := sess.getHosts()
558 c.Assert(err, IsNil)
559 c.Check(sess.deliveryHosts, DeepEquals, fallback)
560@@ -282,16 +282,16 @@
561 return &gethosts.Host{thg.domain, thg.hosts}, thg.err
562 }
563
564-func (cs *clientSessionSuite) TestGetHostsRemote(c *C) {
565+func (cs *ConcreteSessionSuite) TestGetHostsRemote(c *C) {
566 hostGetter := &testHostGetter{"example.com", []string{"foo:443", "bar:443"}, nil}
567- sess := &ClientSession{getHost: hostGetter, timeSince: time.Since}
568+ sess := &ConcreteSession{getHost: hostGetter, timeSince: time.Since}
569 err := sess.getHosts()
570 c.Assert(err, IsNil)
571 c.Check(sess.deliveryHosts, DeepEquals, []string{"foo:443", "bar:443"})
572 }
573
574-func (cs *clientSessionSuite) TestGetHostsRemoteError(c *C) {
575- sess, err := NewSession("", dummyConf, "", cs.lvls, cs.log)
576+func (cs *ConcreteSessionSuite) TestGetHostsRemoteError(c *C) {
577+ sess, err := newSession("", dummyConf, "", cs.lvls, cs.log)
578 c.Assert(err, IsNil)
579 hostsErr := errors.New("failed")
580 hostGetter := &testHostGetter{"", nil, hostsErr}
581@@ -302,9 +302,9 @@
582 c.Check(sess.State(), Equals, Error)
583 }
584
585-func (cs *clientSessionSuite) TestGetHostsRemoteCaching(c *C) {
586+func (cs *ConcreteSessionSuite) TestGetHostsRemoteCaching(c *C) {
587 hostGetter := &testHostGetter{"example.com", []string{"foo:443", "bar:443"}, nil}
588- sess := &ClientSession{
589+ sess := &ConcreteSession{
590 getHost: hostGetter,
591 ClientSessionConfig: ClientSessionConfig{
592 HostsCachingExpiryTime: 2 * time.Hour,
593@@ -327,9 +327,9 @@
594 c.Check(sess.deliveryHosts, DeepEquals, []string{"baz:443"})
595 }
596
597-func (cs *clientSessionSuite) TestGetHostsRemoteCachingReset(c *C) {
598+func (cs *ConcreteSessionSuite) TestGetHostsRemoteCachingReset(c *C) {
599 hostGetter := &testHostGetter{"example.com", []string{"foo:443", "bar:443"}, nil}
600- sess := &ClientSession{
601+ sess := &ConcreteSession{
602 getHost: hostGetter,
603 ClientSessionConfig: ClientSessionConfig{
604 HostsCachingExpiryTime: 2 * time.Hour,
605@@ -354,9 +354,9 @@
606 addAuthorization() tests
607 ****************************************************************/
608
609-func (cs *clientSessionSuite) TestAddAuthorizationAddsAuthorization(c *C) {
610+func (cs *ConcreteSessionSuite) TestAddAuthorizationAddsAuthorization(c *C) {
611 url := "xyzzy://"
612- sess := &ClientSession{Log: cs.log}
613+ sess := &ConcreteSession{Log: cs.log}
614 sess.AuthGetter = func(url string) string { return url + " auth'ed" }
615 sess.AuthURL = url
616 c.Assert(sess.auth, Equals, "")
617@@ -365,8 +365,8 @@
618 c.Check(sess.auth, Equals, "xyzzy:// auth'ed")
619 }
620
621-func (cs *clientSessionSuite) TestAddAuthorizationSkipsIfUnset(c *C) {
622- sess := &ClientSession{Log: cs.log}
623+func (cs *ConcreteSessionSuite) TestAddAuthorizationSkipsIfUnset(c *C) {
624+ sess := &ConcreteSession{Log: cs.log}
625 sess.AuthGetter = nil
626 c.Assert(sess.auth, Equals, "")
627 err := sess.addAuthorization()
628@@ -378,9 +378,9 @@
629 startConnectionAttempt()/nextHostToTry()/started tests
630 ****************************************************************/
631
632-func (cs *clientSessionSuite) TestStartConnectionAttempt(c *C) {
633+func (cs *ConcreteSessionSuite) TestStartConnectionAttempt(c *C) {
634 since := time.Since(time.Time{})
635- sess := &ClientSession{
636+ sess := &ConcreteSession{
637 ClientSessionConfig: ClientSessionConfig{
638 ExpectAllRepairedTime: 10 * time.Second,
639 },
640@@ -402,9 +402,9 @@
641 sess.tryHost = 2
642 }
643
644-func (cs *clientSessionSuite) TestStartConnectionAttemptNoHostsPanic(c *C) {
645+func (cs *ConcreteSessionSuite) TestStartConnectionAttemptNoHostsPanic(c *C) {
646 since := time.Since(time.Time{})
647- sess := &ClientSession{
648+ sess := &ConcreteSession{
649 ClientSessionConfig: ClientSessionConfig{
650 ExpectAllRepairedTime: 10 * time.Second,
651 },
652@@ -415,8 +415,8 @@
653 c.Check(sess.startConnectionAttempt, PanicMatches, "should have got hosts from config or remote at this point")
654 }
655
656-func (cs *clientSessionSuite) TestNextHostToTry(c *C) {
657- sess := &ClientSession{
658+func (cs *ConcreteSessionSuite) TestNextHostToTry(c *C) {
659+ sess := &ConcreteSession{
660 deliveryHosts: []string{"foo:443", "bar:443", "baz:443"},
661 tryHost: 0,
662 leftToTry: 3,
663@@ -438,8 +438,8 @@
664 c.Check(sess.tryHost, Equals, 1)
665 }
666
667-func (cs *clientSessionSuite) TestStarted(c *C) {
668- sess, err := NewSession("", dummyConf, "", cs.lvls, cs.log)
669+func (cs *ConcreteSessionSuite) TestStarted(c *C) {
670+ sess, err := newSession("", dummyConf, "", cs.lvls, cs.log)
671 c.Assert(err, IsNil)
672
673 sess.deliveryHosts = []string{"foo:443", "bar:443", "baz:443"}
674@@ -457,8 +457,8 @@
675 connect() tests
676 ****************************************************************/
677
678-func (cs *clientSessionSuite) TestConnectFailsWithNoAddress(c *C) {
679- sess, err := NewSession("", dummyConf, "wah", cs.lvls, cs.log)
680+func (cs *ConcreteSessionSuite) TestConnectFailsWithNoAddress(c *C) {
681+ sess, err := newSession("", dummyConf, "wah", cs.lvls, cs.log)
682 c.Assert(err, IsNil)
683 sess.deliveryHosts = []string{"nowhere"}
684 sess.clearShouldDelay()
685@@ -468,11 +468,11 @@
686 c.Check(sess.State(), Equals, Error)
687 }
688
689-func (cs *clientSessionSuite) TestConnectConnects(c *C) {
690+func (cs *ConcreteSessionSuite) TestConnectConnects(c *C) {
691 srv, err := net.Listen("tcp", "localhost:0")
692 c.Assert(err, IsNil)
693 defer srv.Close()
694- sess, err := NewSession("", dummyConf, "wah", cs.lvls, cs.log)
695+ sess, err := newSession("", dummyConf, "wah", cs.lvls, cs.log)
696 c.Assert(err, IsNil)
697 sess.deliveryHosts = []string{srv.Addr().String()}
698 sess.clearShouldDelay()
699@@ -483,11 +483,11 @@
700 c.Check(sess.State(), Equals, Connected)
701 }
702
703-func (cs *clientSessionSuite) TestConnectSecondConnects(c *C) {
704+func (cs *ConcreteSessionSuite) TestConnectSecondConnects(c *C) {
705 srv, err := net.Listen("tcp", "localhost:0")
706 c.Assert(err, IsNil)
707 defer srv.Close()
708- sess, err := NewSession("", dummyConf, "wah", cs.lvls, cs.log)
709+ sess, err := newSession("", dummyConf, "wah", cs.lvls, cs.log)
710 c.Assert(err, IsNil)
711 sess.deliveryHosts = []string{"nowhere", srv.Addr().String()}
712 sess.clearShouldDelay()
713@@ -499,10 +499,10 @@
714 c.Check(sess.tryHost, Equals, 0)
715 }
716
717-func (cs *clientSessionSuite) TestConnectConnectFail(c *C) {
718+func (cs *ConcreteSessionSuite) TestConnectConnectFail(c *C) {
719 srv, err := net.Listen("tcp", "localhost:0")
720 c.Assert(err, IsNil)
721- sess, err := NewSession(srv.Addr().String(), dummyConf, "wah", cs.lvls, cs.log)
722+ sess, err := newSession(srv.Addr().String(), dummyConf, "wah", cs.lvls, cs.log)
723 srv.Close()
724 c.Assert(err, IsNil)
725 sess.deliveryHosts = []string{srv.Addr().String()}
726@@ -517,8 +517,8 @@
727 Close() tests
728 ****************************************************************/
729
730-func (cs *clientSessionSuite) TestClose(c *C) {
731- sess, err := NewSession("", dummyConf, "wah", cs.lvls, cs.log)
732+func (cs *ConcreteSessionSuite) TestClose(c *C) {
733+ sess, err := newSession("", dummyConf, "wah", cs.lvls, cs.log)
734 c.Assert(err, IsNil)
735 sess.Connection = &testConn{Name: "TestClose"}
736 sess.Close()
737@@ -526,8 +526,8 @@
738 c.Check(sess.State(), Equals, Disconnected)
739 }
740
741-func (cs *clientSessionSuite) TestCloseTwice(c *C) {
742- sess, err := NewSession("", dummyConf, "wah", cs.lvls, cs.log)
743+func (cs *ConcreteSessionSuite) TestCloseTwice(c *C) {
744+ sess, err := newSession("", dummyConf, "wah", cs.lvls, cs.log)
745 c.Assert(err, IsNil)
746 sess.Connection = &testConn{Name: "TestCloseTwice"}
747 sess.Close()
748@@ -537,8 +537,8 @@
749 c.Check(sess.State(), Equals, Disconnected)
750 }
751
752-func (cs *clientSessionSuite) TestCloseFails(c *C) {
753- sess, err := NewSession("", dummyConf, "wah", cs.lvls, cs.log)
754+func (cs *ConcreteSessionSuite) TestCloseFails(c *C) {
755+ sess, err := newSession("", dummyConf, "wah", cs.lvls, cs.log)
756 c.Assert(err, IsNil)
757 sess.Connection = &testConn{Name: "TestCloseFails", CloseCondition: condition.Work(false)}
758 sess.Close()
759@@ -551,8 +551,8 @@
760 func (*derp) Redial() uint32 { return 0 }
761 func (d *derp) Stop() { d.stopped = true }
762
763-func (cs *clientSessionSuite) TestCloseStopsRetrier(c *C) {
764- sess, err := NewSession("", dummyConf, "wah", cs.lvls, cs.log)
765+func (cs *ConcreteSessionSuite) TestCloseStopsRetrier(c *C) {
766+ sess, err := newSession("", dummyConf, "wah", cs.lvls, cs.log)
767 c.Assert(err, IsNil)
768 ar := new(derp)
769 sess.retrier = ar
770@@ -567,9 +567,9 @@
771 AutoRedial() tests
772 ****************************************************************/
773
774-func (cs *clientSessionSuite) TestAutoRedialWorks(c *C) {
775+func (cs *ConcreteSessionSuite) TestAutoRedialWorks(c *C) {
776 // checks that AutoRedial sets up a retrier and tries redialing it
777- sess, err := NewSession("", dummyConf, "wah", cs.lvls, cs.log)
778+ sess, err := newSession("", dummyConf, "wah", cs.lvls, cs.log)
779 c.Assert(err, IsNil)
780 ar := new(derp)
781 sess.retrier = ar
782@@ -578,9 +578,9 @@
783 c.Check(ar.stopped, Equals, true)
784 }
785
786-func (cs *clientSessionSuite) TestAutoRedialStopsRetrier(c *C) {
787+func (cs *ConcreteSessionSuite) TestAutoRedialStopsRetrier(c *C) {
788 // checks that AutoRedial stops the previous retrier
789- sess, err := NewSession("", dummyConf, "wah", cs.lvls, cs.log)
790+ sess, err := newSession("", dummyConf, "wah", cs.lvls, cs.log)
791 c.Assert(err, IsNil)
792 ch := make(chan uint32)
793 c.Check(sess.retrier, IsNil)
794@@ -590,19 +590,19 @@
795 c.Check(<-ch, Not(Equals), 0)
796 }
797
798-func (cs *clientSessionSuite) TestAutoRedialCallsRedialDelay(c *C) {
799- sess, err := NewSession("", dummyConf, "wah", cs.lvls, cs.log)
800+func (cs *ConcreteSessionSuite) TestAutoRedialCallsRedialDelay(c *C) {
801+ sess, err := newSession("", dummyConf, "wah", cs.lvls, cs.log)
802 c.Assert(err, IsNil)
803 flag := false
804- sess.redialDelay = func(sess *ClientSession) time.Duration { flag = true; return 0 }
805+ sess.redialDelay = func(sess *ConcreteSession) time.Duration { flag = true; return 0 }
806 sess.AutoRedial(nil)
807 c.Check(flag, Equals, true)
808 }
809
810-func (cs *clientSessionSuite) TestAutoRedialSetsRedialDelayIfTooQuick(c *C) {
811- sess, err := NewSession("", dummyConf, "wah", cs.lvls, cs.log)
812+func (cs *ConcreteSessionSuite) TestAutoRedialSetsRedialDelayIfTooQuick(c *C) {
813+ sess, err := newSession("", dummyConf, "wah", cs.lvls, cs.log)
814 c.Assert(err, IsNil)
815- sess.redialDelay = func(sess *ClientSession) time.Duration { return 0 }
816+ sess.redialDelay = func(sess *ConcreteSession) time.Duration { return 0 }
817 sess.AutoRedial(nil)
818 c.Check(sess.ShouldDelay(), Equals, false)
819 sess.stopRedial()
820@@ -616,7 +616,7 @@
821 ****************************************************************/
822
823 type msgSuite struct {
824- sess *ClientSession
825+ sess *ConcreteSession
826 upCh chan interface{}
827 downCh chan interface{}
828 errCh chan error
829@@ -629,7 +629,7 @@
830 conf := ClientSessionConfig{
831 ExchangeTimeout: time.Millisecond,
832 }
833- s.sess, err = NewSession("", conf, "wah", seenstate.NewSeenState, helpers.NewTestLogger(c, "debug"))
834+ s.sess, err = newSession("", conf, "wah", seenstate.NewSeenState, helpers.NewTestLogger(c, "debug"))
835 c.Assert(err, IsNil)
836 s.sess.Connection = &testConn{Name: "TestHandle*"}
837 s.errCh = make(chan error, 1)
838@@ -1167,8 +1167,8 @@
839 /****************************************************************
840 start() tests
841 ****************************************************************/
842-func (cs *clientSessionSuite) TestStartFailsIfSetDeadlineFails(c *C) {
843- sess, err := NewSession("", dummyConf, "wah", cs.lvls, cs.log)
844+func (cs *ConcreteSessionSuite) TestStartFailsIfSetDeadlineFails(c *C) {
845+ sess, err := newSession("", dummyConf, "wah", cs.lvls, cs.log)
846 c.Assert(err, IsNil)
847 sess.Connection = &testConn{Name: "TestStartFailsIfSetDeadlineFails",
848 DeadlineCondition: condition.Work(false)} // setdeadline will fail
849@@ -1177,8 +1177,8 @@
850 c.Check(sess.State(), Equals, Error)
851 }
852
853-func (cs *clientSessionSuite) TestStartFailsIfWriteFails(c *C) {
854- sess, err := NewSession("", dummyConf, "wah", cs.lvls, cs.log)
855+func (cs *ConcreteSessionSuite) TestStartFailsIfWriteFails(c *C) {
856+ sess, err := newSession("", dummyConf, "wah", cs.lvls, cs.log)
857 c.Assert(err, IsNil)
858 sess.Connection = &testConn{Name: "TestStartFailsIfWriteFails",
859 WriteCondition: condition.Work(false)} // write will fail
860@@ -1187,8 +1187,8 @@
861 c.Check(sess.State(), Equals, Error)
862 }
863
864-func (cs *clientSessionSuite) TestStartFailsIfGetLevelsFails(c *C) {
865- sess, err := NewSession("", dummyConf, "wah", cs.lvls, cs.log)
866+func (cs *ConcreteSessionSuite) TestStartFailsIfGetLevelsFails(c *C) {
867+ sess, err := newSession("", dummyConf, "wah", cs.lvls, cs.log)
868 c.Assert(err, IsNil)
869 sess.SeenState = &brokenSeenState{}
870 sess.Connection = &testConn{Name: "TestStartConnectMessageFails"}
871@@ -1207,8 +1207,8 @@
872 c.Check(err, ErrorMatches, "broken.")
873 }
874
875-func (cs *clientSessionSuite) TestStartConnectMessageFails(c *C) {
876- sess, err := NewSession("", dummyConf, "wah", cs.lvls, cs.log)
877+func (cs *ConcreteSessionSuite) TestStartConnectMessageFails(c *C) {
878+ sess, err := newSession("", dummyConf, "wah", cs.lvls, cs.log)
879 c.Assert(err, IsNil)
880 sess.Connection = &testConn{Name: "TestStartConnectMessageFails"}
881 errCh := make(chan error, 1)
882@@ -1234,8 +1234,8 @@
883 c.Check(sess.State(), Equals, Error)
884 }
885
886-func (cs *clientSessionSuite) TestStartConnackReadError(c *C) {
887- sess, err := NewSession("", dummyConf, "wah", cs.lvls, cs.log)
888+func (cs *ConcreteSessionSuite) TestStartConnackReadError(c *C) {
889+ sess, err := newSession("", dummyConf, "wah", cs.lvls, cs.log)
890 c.Assert(err, IsNil)
891 sess.Connection = &testConn{Name: "TestStartConnackReadError"}
892 errCh := make(chan error, 1)
893@@ -1258,8 +1258,8 @@
894 c.Check(sess.State(), Equals, Error)
895 }
896
897-func (cs *clientSessionSuite) TestStartBadConnack(c *C) {
898- sess, err := NewSession("", dummyConf, "wah", cs.lvls, cs.log)
899+func (cs *ConcreteSessionSuite) TestStartBadConnack(c *C) {
900+ sess, err := newSession("", dummyConf, "wah", cs.lvls, cs.log)
901 c.Assert(err, IsNil)
902 sess.Connection = &testConn{Name: "TestStartBadConnack"}
903 errCh := make(chan error, 1)
904@@ -1282,8 +1282,8 @@
905 c.Check(sess.State(), Equals, Error)
906 }
907
908-func (cs *clientSessionSuite) TestStartNotConnack(c *C) {
909- sess, err := NewSession("", dummyConf, "wah", cs.lvls, cs.log)
910+func (cs *ConcreteSessionSuite) TestStartNotConnack(c *C) {
911+ sess, err := newSession("", dummyConf, "wah", cs.lvls, cs.log)
912 c.Assert(err, IsNil)
913 sess.Connection = &testConn{Name: "TestStartBadConnack"}
914 errCh := make(chan error, 1)
915@@ -1306,7 +1306,7 @@
916 c.Check(sess.State(), Equals, Error)
917 }
918
919-func (cs *clientSessionSuite) TestStartWorks(c *C) {
920+func (cs *ConcreteSessionSuite) TestStartWorks(c *C) {
921 info := map[string]interface{}{
922 "foo": 1,
923 "bar": "baz",
924@@ -1314,7 +1314,7 @@
925 conf := ClientSessionConfig{
926 Info: info,
927 }
928- sess, err := NewSession("", conf, "wah", cs.lvls, cs.log)
929+ sess, err := newSession("", conf, "wah", cs.lvls, cs.log)
930 c.Assert(err, IsNil)
931 sess.Connection = &testConn{Name: "TestStartWorks"}
932 sess.setCookie("COOKIE")
933@@ -1350,8 +1350,8 @@
934 run() tests
935 ****************************************************************/
936
937-func (cs *clientSessionSuite) TestRunBailsIfAuthCheckFails(c *C) {
938- sess, err := NewSession("", dummyConf, "wah", cs.lvls, cs.log)
939+func (cs *ConcreteSessionSuite) TestRunBailsIfAuthCheckFails(c *C) {
940+ sess, err := newSession("", dummyConf, "wah", cs.lvls, cs.log)
941 c.Assert(err, IsNil)
942 failure := errors.New("TestRunBailsIfAuthCheckFails")
943 has_closed := false
944@@ -1366,8 +1366,8 @@
945 c.Check(has_closed, Equals, true)
946 }
947
948-func (cs *clientSessionSuite) TestRunBailsIfHostGetterFails(c *C) {
949- sess, err := NewSession("", dummyConf, "wah", cs.lvls, cs.log)
950+func (cs *ConcreteSessionSuite) TestRunBailsIfHostGetterFails(c *C) {
951+ sess, err := newSession("", dummyConf, "wah", cs.lvls, cs.log)
952 c.Assert(err, IsNil)
953 failure := errors.New("TestRunBailsIfHostGetterFails")
954 has_closed := false
955@@ -1382,8 +1382,8 @@
956 c.Check(has_closed, Equals, true)
957 }
958
959-func (cs *clientSessionSuite) TestRunBailsIfConnectFails(c *C) {
960- sess, err := NewSession("", dummyConf, "wah", cs.lvls, cs.log)
961+func (cs *ConcreteSessionSuite) TestRunBailsIfConnectFails(c *C) {
962+ sess, err := newSession("", dummyConf, "wah", cs.lvls, cs.log)
963 c.Assert(err, IsNil)
964 failure := errors.New("TestRunBailsIfConnectFails")
965 err = sess.run(
966@@ -1396,8 +1396,8 @@
967 c.Check(err, Equals, failure)
968 }
969
970-func (cs *clientSessionSuite) TestRunBailsIfStartFails(c *C) {
971- sess, err := NewSession("", dummyConf, "wah", cs.lvls, cs.log)
972+func (cs *ConcreteSessionSuite) TestRunBailsIfStartFails(c *C) {
973+ sess, err := newSession("", dummyConf, "wah", cs.lvls, cs.log)
974 c.Assert(err, IsNil)
975 failure := errors.New("TestRunBailsIfStartFails")
976 err = sess.run(
977@@ -1410,8 +1410,8 @@
978 c.Check(err, Equals, failure)
979 }
980
981-func (cs *clientSessionSuite) TestRunRunsEvenIfLoopFails(c *C) {
982- sess, err := NewSession("", dummyConf, "wah", cs.lvls, cs.log)
983+func (cs *ConcreteSessionSuite) TestRunRunsEvenIfLoopFails(c *C) {
984+ sess, err := newSession("", dummyConf, "wah", cs.lvls, cs.log)
985 c.Assert(err, IsNil)
986 // just to make a point: until here we haven't set ErrCh & BroadcastCh (no
987 // biggie if this stops being true)
988@@ -1441,8 +1441,8 @@
989 Jitter() tests
990 ****************************************************************/
991
992-func (cs *clientSessionSuite) TestJitter(c *C) {
993- sess, err := NewSession("", dummyConf, "wah", cs.lvls, cs.log)
994+func (cs *ConcreteSessionSuite) TestJitter(c *C) {
995+ sess, err := newSession("", dummyConf, "wah", cs.lvls, cs.log)
996 c.Assert(err, IsNil)
997 num_tries := 20 // should do the math
998 spread := time.Second //
999@@ -1472,9 +1472,9 @@
1000 Dial() tests
1001 ****************************************************************/
1002
1003-func (cs *clientSessionSuite) TestDialPanics(c *C) {
1004+func (cs *ConcreteSessionSuite) TestDialPanics(c *C) {
1005 // one last unhappy test
1006- sess, err := NewSession("", dummyConf, "wah", cs.lvls, cs.log)
1007+ sess, err := newSession("", dummyConf, "wah", cs.lvls, cs.log)
1008 c.Assert(err, IsNil)
1009 sess.Protocolator = nil
1010 c.Check(sess.Dial, PanicMatches, ".*protocol constructor.")
1011@@ -1488,7 +1488,7 @@
1012 }
1013 )
1014
1015-func (cs *clientSessionSuite) TestDialBadServerName(c *C) {
1016+func (cs *ConcreteSessionSuite) TestDialBadServerName(c *C) {
1017 // a borked server name
1018 lst, err := tls.Listen("tcp", "localhost:0", helpers.TestTLSServerConfig)
1019 c.Assert(err, IsNil)
1020@@ -1506,7 +1506,7 @@
1021 }))
1022 defer ts.Close()
1023
1024- sess, err := NewSession(ts.URL, dialTestConf, "wah", cs.lvls, cs.log)
1025+ sess, err := newSession(ts.URL, dialTestConf, "wah", cs.lvls, cs.log)
1026 c.Assert(err, IsNil)
1027 tconn := &testConn{}
1028 sess.Connection = tconn
1029@@ -1533,7 +1533,7 @@
1030 c.Check(sess.State(), Equals, Error)
1031 }
1032
1033-func (cs *clientSessionSuite) TestDialWorks(c *C) {
1034+func (cs *ConcreteSessionSuite) TestDialWorks(c *C) {
1035 // happy path thoughts
1036 lst, err := tls.Listen("tcp", "localhost:0", helpers.TestTLSServerConfig)
1037 c.Assert(err, IsNil)
1038@@ -1551,7 +1551,7 @@
1039 }))
1040 defer ts.Close()
1041
1042- sess, err := NewSession(ts.URL, dialTestConf, "wah", cs.lvls, cs.log)
1043+ sess, err := newSession(ts.URL, dialTestConf, "wah", cs.lvls, cs.log)
1044 c.Assert(err, IsNil)
1045 tconn := &testConn{CloseCondition: condition.Fail2Work(10)}
1046 sess.Connection = tconn
1047@@ -1634,11 +1634,11 @@
1048 c.Check(<-sess.ErrCh, Equals, failure)
1049 }
1050
1051-func (cs *clientSessionSuite) TestDialWorksDirect(c *C) {
1052+func (cs *ConcreteSessionSuite) TestDialWorksDirect(c *C) {
1053 // happy path thoughts
1054 lst, err := tls.Listen("tcp", "localhost:0", helpers.TestTLSServerConfig)
1055 c.Assert(err, IsNil)
1056- sess, err := NewSession(lst.Addr().String(), dialTestConf, "wah", cs.lvls, cs.log)
1057+ sess, err := newSession(lst.Addr().String(), dialTestConf, "wah", cs.lvls, cs.log)
1058 c.Assert(err, IsNil)
1059 defer sess.Close()
1060
1061@@ -1658,8 +1658,8 @@
1062 redialDelay() tests
1063 ****************************************************************/
1064
1065-func (cs *clientSessionSuite) TestShouldDelay(c *C) {
1066- sess, err := NewSession("foo:443", dummyConf, "", cs.lvls, cs.log)
1067+func (cs *ConcreteSessionSuite) TestShouldDelay(c *C) {
1068+ sess, err := newSession("foo:443", dummyConf, "", cs.lvls, cs.log)
1069 c.Assert(err, IsNil)
1070 c.Check(sess.ShouldDelay(), Equals, false)
1071 sess.setShouldDelay()
1072@@ -1668,8 +1668,8 @@
1073 c.Check(sess.ShouldDelay(), Equals, false)
1074 }
1075
1076-func (cs *clientSessionSuite) TestRedialDelay(c *C) {
1077- sess, err := NewSession("foo:443", dummyConf, "", cs.lvls, cs.log)
1078+func (cs *ConcreteSessionSuite) TestRedialDelay(c *C) {
1079+ sess, err := newSession("foo:443", dummyConf, "", cs.lvls, cs.log)
1080 c.Assert(err, IsNil)
1081 sess.redialDelays = []time.Duration{17, 42}
1082 n := 0
1083@@ -1693,8 +1693,8 @@
1084 ClearCookie() tests
1085 ****************************************************************/
1086
1087-func (cs *clientSessionSuite) TestClearCookie(c *C) {
1088- sess, err := NewSession("foo:443", dummyConf, "", cs.lvls, cs.log)
1089+func (cs *ConcreteSessionSuite) TestClearCookie(c *C) {
1090+ sess, err := newSession("foo:443", dummyConf, "", cs.lvls, cs.log)
1091 c.Assert(err, IsNil)
1092 c.Check(sess.getCookie(), Equals, "")
1093 sess.setCookie("COOKIE")

Subscribers

People subscribed via source and target branches