~artmello/ubuntu-push/ubuntu-push-fix_1611848

« back to all changes in this revision

Viewing changes to poller/poller_test.go

  • Committer: CI Train Bot
  • Author(s): Ricardo Salveti de Araujo
  • Date: 2015-04-30 15:08:54 UTC
  • mfrom: (145.1.2 ubuntu-push)
  • Revision ID: ci-train-bot@canonical.com-20150430150854-2u38lu0oi8rtomo1
[ Samuele Pedroni ]
* switch poller to use killswitch state for WLAN instead of misleading NM property (LP: #1446584)
* don't have goroutines from a previous test overlap with the next, races gets detected otherwise
* have the TestDialWorksDirect* tests quickly timeout, go1.3 wants a ServerName set in the tls config for them to work
* fix flaky test
* support sha384/512 certs, some exercizing of that
* let send a build number with acceptanceclient
* add helper to get int out of ConnectMsg Info
Approved by: Samuele Pedroni

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
        . "launchpad.net/gocheck"
23
23
 
 
24
        "launchpad.net/ubuntu-push/bus/urfkill"
24
25
        "launchpad.net/ubuntu-push/client/session"
25
26
        helpers "launchpad.net/ubuntu-push/testing"
26
27
)
90
91
        s.myd = &myD{}
91
92
}
92
93
 
 
94
const (
 
95
        wlanOn  = urfkill.KillswitchStateUnblocked
 
96
        wlanOff = urfkill.KillswitchStateSoftBlocked
 
97
)
 
98
 
93
99
func (s *PrSuite) TestStep(c *C) {
94
100
        p := &poller{
95
101
                times:                Times{},
111
117
        ch := make(chan string)
112
118
        // now, run
113
119
        filteredWakeUpCh := make(chan bool)
114
 
        go p.control(wakeupCh, filteredWakeUpCh, false, nil, true, nil)
 
120
        go p.control(wakeupCh, filteredWakeUpCh, false, nil, wlanOn, nil)
115
121
        go func() { ch <- p.step(filteredWakeUpCh, doneCh, "old cookie") }()
116
122
        select {
117
123
        case s := <-ch:
138
144
        filteredWakeUpCh := make(chan bool)
139
145
        s.myd.watchWakeCh = make(chan bool, 1)
140
146
        flightModeCh := make(chan bool)
141
 
        wirelessModeCh := make(chan bool)
142
 
        go p.control(wakeUpCh, filteredWakeUpCh, false, flightModeCh, true, wirelessModeCh)
 
147
        wlanKillswitchStateCh := make(chan urfkill.KillswitchState)
 
148
        go p.control(wakeUpCh, filteredWakeUpCh, false, flightModeCh, wlanOn, wlanKillswitchStateCh)
143
149
 
144
150
        // works
145
151
        err := p.requestWakeup()
157
163
 
158
164
        // flight mode
159
165
        flightModeCh <- true
160
 
        wirelessModeCh <- false
 
166
        wlanKillswitchStateCh <- wlanOff
161
167
        err = p.requestWakeup()
162
168
        c.Assert(err, IsNil)
163
169
        c.Check(s.myd.watchWakeCh, HasLen, 0)
164
170
 
165
171
        // wireless on
166
 
        wirelessModeCh <- true
 
172
        wlanKillswitchStateCh <- wlanOn
167
173
        c.Check(<-s.myd.watchWakeCh, Equals, true)
168
174
 
169
175
        // wireless off
170
 
        wirelessModeCh <- false
 
176
        wlanKillswitchStateCh <- wlanOff
171
177
        // pending wakeup was cleared
172
178
        c.Check(<-s.myd.watchWakeCh, Equals, false)
173
179