Merge lp:~pedronis/ubuntu-push/fix-tweak-tests into lp:ubuntu-push

Proposed by Samuele Pedroni
Status: Merged
Approved by: Samuele Pedroni
Approved revision: 64
Merged at revision: 60
Proposed branch: lp:~pedronis/ubuntu-push/fix-tweak-tests
Merge into: lp:ubuntu-push
Diff against target: 162 lines (+30/-31)
2 files modified
server/acceptance/acceptance_test.go (+20/-20)
server/session/session_test.go (+10/-11)
To merge this branch: bzr merge lp:~pedronis/ubuntu-push/fix-tweak-tests
Reviewer Review Type Date Requested Status
Samuele Pedroni Approve
Review via email: mp+205670@code.launchpad.net

Commit message

[trivial] use Assert in place of Check to sanity check api http reqs in acceptance; use a longer ping in TestSessionLoopExchangeNextPing

To post a comment you must log in.
64. By Samuele Pedroni

use a longer ping here

Revision history for this message
Samuele Pedroni (pedronis) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'server/acceptance/acceptance_test.go'
2--- server/acceptance/acceptance_test.go 2014-02-10 23:19:08 +0000
3+++ server/acceptance/acceptance_test.go 2014-02-10 23:41:29 +0000
4@@ -354,8 +354,8 @@
5 Channel: "system",
6 Data: json.RawMessage(`{"n": 42}`),
7 })
8- c.Check(err, IsNil)
9- c.Check(got, Matches, ".*ok.*")
10+ c.Assert(err, IsNil)
11+ c.Assert(got, Matches, ".*ok.*")
12 c.Check(nextEvent(events, errCh), Equals, `broadcast chan:0 app: topLevel:1 payloads:[{"n":42}]`)
13 clientShutdown <- true
14 c.Assert(nextEvent(s.serverEvents, nil), Matches, `.* ended with:.*EOF`)
15@@ -368,8 +368,8 @@
16 Channel: "system",
17 Data: json.RawMessage(`{"b": 1}`),
18 })
19- c.Check(err, IsNil)
20- c.Check(got, Matches, ".*ok.*")
21+ c.Assert(err, IsNil)
22+ c.Assert(got, Matches, ".*ok.*")
23
24 clientShutdown := make(chan bool, 1) // abused as an atomic flag
25 intercept := func(ic *interceptingConn, op string, b []byte) (bool, int, error) {
26@@ -396,8 +396,8 @@
27 Channel: "system",
28 Data: json.RawMessage(fmt.Sprintf(payloadFmt, i)),
29 })
30- c.Check(err, IsNil)
31- c.Check(got, Matches, ".*ok.*")
32+ c.Assert(err, IsNil)
33+ c.Assert(got, Matches, ".*ok.*")
34 }
35
36 clientShutdown := make(chan bool, 1) // abused as an atomic flag
37@@ -437,8 +437,8 @@
38 Channel: "system",
39 Data: json.RawMessage(`{"n": 42}`),
40 })
41- c.Check(err, IsNil)
42- c.Check(got, Matches, ".*ok.*")
43+ c.Assert(err, IsNil)
44+ c.Assert(got, Matches, ".*ok.*")
45 c.Check(nextEvent(events1, errCh1), Equals, `broadcast chan:0 app: topLevel:1 payloads:[{"n":42}]`)
46 c.Check(nextEvent(events2, errCh2), Equals, `broadcast chan:0 app: topLevel:1 payloads:[{"n":42}]`)
47 clientShutdown <- true
48@@ -463,8 +463,8 @@
49 Channel: "system",
50 Data: json.RawMessage(`{"b": 1}`),
51 })
52- c.Check(err, IsNil)
53- c.Check(got, Matches, ".*ok.*")
54+ c.Assert(err, IsNil)
55+ c.Assert(got, Matches, ".*ok.*")
56 c.Check(nextEvent(events, errCh), Equals, `broadcast chan:0 app: topLevel:1 payloads:[{"b":1}]`)
57 clientShutdown <- true
58 c.Assert(nextEvent(s.serverEvents, nil), Matches, `.* ended with:.*EOF`)
59@@ -474,8 +474,8 @@
60 Channel: "system",
61 Data: json.RawMessage(`{"b": 2}`),
62 })
63- c.Check(err, IsNil)
64- c.Check(got, Matches, ".*ok.*")
65+ c.Assert(err, IsNil)
66+ c.Assert(got, Matches, ".*ok.*")
67 // reconnect, provide levels, get only later notification
68 <-clientShutdown // reset
69 events, errCh = s.startClient(c, "DEVD", intercept, map[string]int64{
70@@ -493,14 +493,14 @@
71 Channel: "system",
72 Data: json.RawMessage(`{"b": 1}`),
73 })
74- c.Check(err, IsNil)
75- c.Check(got, Matches, ".*ok.*")
76+ c.Assert(err, IsNil)
77+ c.Assert(got, Matches, ".*ok.*")
78 got, err = s.postRequest("/broadcast", &api.Broadcast{
79 Channel: "system",
80 Data: json.RawMessage(`{"b": 2}`),
81 })
82- c.Check(err, IsNil)
83- c.Check(got, Matches, ".*ok.*")
84+ c.Assert(err, IsNil)
85+ c.Assert(got, Matches, ".*ok.*")
86
87 clientShutdown := make(chan bool, 1) // abused as an atomic flag
88 intercept := func(ic *interceptingConn, op string, b []byte) (bool, int, error) {
89@@ -548,14 +548,14 @@
90 Channel: "system",
91 Data: json.RawMessage(`{"b": 1}`),
92 })
93- c.Check(err, IsNil)
94- c.Check(got, Matches, ".*ok.*")
95+ c.Assert(err, IsNil)
96+ c.Assert(got, Matches, ".*ok.*")
97 got, err = s.postRequest("/broadcast", &api.Broadcast{
98 Channel: "system",
99 Data: json.RawMessage(`{"b": 2}`),
100 })
101- c.Check(err, IsNil)
102- c.Check(got, Matches, ".*ok.*")
103+ c.Assert(err, IsNil)
104+ c.Assert(got, Matches, ".*ok.*")
105
106 clientShutdown := make(chan bool, 1) // abused as an atomic flag
107 intercept := func(ic *interceptingConn, op string, b []byte) (bool, int, error) {
108
109=== modified file 'server/session/session_test.go'
110--- server/session/session_test.go 2014-02-10 23:19:08 +0000
111+++ server/session/session_test.go 2014-02-10 23:41:29 +0000
112@@ -443,6 +443,11 @@
113 trk.interval <- interval
114 }
115
116+var cfg50msPingInterval = &testSessionConfig{
117+ pingInterval: 50 * time.Millisecond,
118+ exchangeTimeout: 10 * time.Millisecond,
119+}
120+
121 func (s *sessionSuite) TestSessionLoopExchangeNextPing(c *C) {
122 track := &testTracker{NewTracker(s.testlog), make(chan interface{}, 1)}
123 errCh := make(chan error, 1)
124@@ -450,20 +455,20 @@
125 down := make(chan interface{}, 5)
126 tp := &testProtocol{up, down}
127 exchanges := make(chan broker.Exchange, 1)
128- exchanges <- &testExchange{finSleep: 6 * time.Millisecond}
129+ exchanges <- &testExchange{finSleep: 15 * time.Millisecond}
130 sess := &testing.TestBrokerSession{Exchanges: exchanges}
131 go func() {
132- errCh <- sessionLoop(tp, sess, cfg10msPingInterval5msExchangeTout, track)
133+ errCh <- sessionLoop(tp, sess, cfg50msPingInterval, track)
134 }()
135- c.Check(takeNext(down), Equals, "deadline 5ms")
136+ c.Check(takeNext(down), Equals, "deadline 10ms")
137 c.Check(takeNext(down), DeepEquals, testMsg{Type: "msg"})
138 up <- nil // no write error
139 up <- testMsg{Type: "ack"}
140 // next ping interval starts around here
141 interval := takeNext(track.interval).(time.Duration)
142- c.Check(takeNext(down), Equals, "deadline 5ms")
143+ c.Check(takeNext(down), Equals, "deadline 10ms")
144 c.Check(takeNext(down), DeepEquals, protocol.PingPongMsg{Type: "ping"})
145- effectiveOfPing := float64(interval) / float64(10*time.Millisecond)
146+ effectiveOfPing := float64(interval) / float64(50*time.Millisecond)
147 comment := Commentf("effectiveOfPing=%f", effectiveOfPing)
148 c.Check(effectiveOfPing > 0.95, Equals, true, comment)
149 c.Check(effectiveOfPing < 1.15, Equals, true, comment)
150@@ -508,12 +513,6 @@
151 c.deadlineKind = append(c.deadlineKind, "write")
152 return c.Conn.SetDeadline(t)
153 }
154-
155-var cfg50msPingInterval = &testSessionConfig{
156- pingInterval: 50 * time.Millisecond,
157- exchangeTimeout: 10 * time.Millisecond,
158-}
159-
160 func (s *sessionSuite) TestSessionWire(c *C) {
161 track := NewTracker(s.testlog)
162 errCh := make(chan error, 1)

Subscribers

People subscribed via source and target branches