MCPcopy
hub / github.com/dropbox/godropbox / TestHTTP

Method TestHTTP

net2/http2/simple_pool_test.go:24–60  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

22var _ = Suite(&SimplePoolSuite{})
23
24func (s *SimplePoolSuite) TestHTTP(c *C) {
25 server, addr := test_utils.SetupTestServer(false)
26 defer server.Close()
27
28 // do single request
29 params := ConnectionParams{
30 MaxIdle: 1,
31 }
32 var pool Pool = NewSimplePool(addr, params)
33
34 // do 10 requests concurrently
35 origMaxProcs := runtime.GOMAXPROCS(runtime.NumCPU())
36 defer func() { runtime.GOMAXPROCS(origMaxProcs) }()
37
38 const count = 10
39 finished := make(chan bool)
40 for i := 0; i < count; i++ {
41 go func() {
42 req, err := http.NewRequest("GET", "/", nil)
43 c.Assert(err, IsNil)
44
45 _, err = pool.Do(req)
46 c.Assert(err, IsNil)
47 finished <- true
48 }()
49 }
50
51 for i := 0; i < count; i++ {
52 select {
53 case <-finished:
54 // cool
55
56 case <-time.After(5 * time.Second):
57 c.FailNow()
58 }
59 }
60}
61
62func (s *SimplePoolSuite) TestConnectTimeout(c *C) {
63 server, addr := test_utils.SetupTestServer(false)

Callers

nothing calls this directly

Calls 5

DoMethod · 0.95
SetupTestServerFunction · 0.92
NewSimplePoolFunction · 0.85
CloseMethod · 0.65
AfterMethod · 0.65

Tested by

no test coverage detected