~rogpeppe/juju-core/039-firewaller-close-port-test

« back to all changes in this revision

Viewing changes to worker/firewaller/firewaller_test.go

  • Committer: Roger Peppe
  • Date: 2012-08-28 13:02:59 UTC
  • Revision ID: roger.peppe@canonical.com-20120828130259-hwtnvliihaxnqr28
worker/firewaller: add failing test

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
                        return
35
35
                }
36
36
                if time.Since(start) > 5000*time.Millisecond {
37
 
                        c.Fatalf("timed out: expected %q; got %q", expected, got)
 
37
                        c.Fatalf("timed out: expected %v; got %v", expected, got)
38
38
                        return
39
39
                }
40
40
                time.Sleep(50 * time.Millisecond)
223
223
 
224
224
        // Starting the firewaller, no open ports.
225
225
        fw := firewaller.NewFirewaller(s.State)
226
 
        defer func() { c.Assert(fw.Stop(), IsNil) }()
 
226
        defer func() {
 
227
                if fw != nil {
 
228
                        c.Assert(fw.Stop(), IsNil)
 
229
                }
 
230
        }()
227
231
 
228
232
        assertPorts(c, inst, m.Id(), nil)
229
233
 
234
238
        c.Assert(err, IsNil)
235
239
        err = u.OpenPort("tcp", 80)
236
240
        c.Assert(err, IsNil)
237
 
 
238
 
        assertPorts(c, inst, m.Id(), []state.Port{{"tcp", 80}})
 
241
        err = u.OpenPort("tcp", 81)
 
242
        c.Assert(err, IsNil)
 
243
 
 
244
        assertPorts(c, inst, m.Id(), []state.Port{{"tcp", 80}, {"tcp", 81}})
 
245
 
 
246
        err = fw.Stop()
 
247
        fw = nil
 
248
        c.Assert(err, IsNil)
 
249
 
 
250
        // Close a port while the firewaller is down.
 
251
        err = u.ClosePort("tcp", 80)
 
252
        c.Assert(err, IsNil)
 
253
 
 
254
        fw = firewaller.NewFirewaller(s.State)
 
255
 
 
256
        err = u.OpenPort("tcp", 82)
 
257
        c.Assert(err, IsNil)
 
258
 
 
259
        assertPorts(c, inst, m.Id(), []state.Port{{"tcp", 81}, {"tcp", 82}})
239
260
}
240
261
 
241
262
func (s *FirewallerSuite) TestSetClearExposedService(c *C) {