Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1111)

Side by Side Diff: environs/jujutest/tests.go

Issue 6221058: environs/ec2: fix amazon tests
Patch Set: environs/ec2: fix amazon tests Created 12 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « environs/ec2/live_test.go ('k') | state/ssh.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 package jujutest 1 package jujutest
2 2
3 import ( 3 import (
4 "bytes" 4 "bytes"
5 "io"
5 "io/ioutil" 6 "io/ioutil"
6 . "launchpad.net/gocheck" 7 . "launchpad.net/gocheck"
7 "launchpad.net/juju/go/environs" 8 "launchpad.net/juju/go/environs"
8 "net/http" 9 "net/http"
10 "time"
9 ) 11 )
10 12
11 func (t *Tests) TestStartStop(c *C) { 13 func (t *Tests) TestStartStop(c *C) {
12 e := t.Open(c) 14 e := t.Open(c)
13 15
14 insts, err := e.Instances(nil) 16 insts, err := e.Instances(nil)
15 c.Assert(err, IsNil) 17 c.Assert(err, IsNil)
16 c.Assert(insts, HasLen, 0) 18 c.Assert(insts, HasLen, 0)
17 19
18 inst0, err := e.StartInstance(0, InvalidStateInfo) 20 inst0, err := e.StartInstance(0, InvalidStateInfo)
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 func checkFileDoesNotExist(c *C, storage environs.StorageReader, name string) { 132 func checkFileDoesNotExist(c *C, storage environs.StorageReader, name string) {
131 // TODO eventual consistency 133 // TODO eventual consistency
132 r, err := storage.Get(name) 134 r, err := storage.Get(name)
133 c.Check(r, IsNil) 135 c.Check(r, IsNil)
134 c.Assert(err, NotNil) 136 c.Assert(err, NotNil)
135 var notFoundError *environs.NotFoundError 137 var notFoundError *environs.NotFoundError
136 c.Assert(err, FitsTypeOf, notFoundError) 138 c.Assert(err, FitsTypeOf, notFoundError)
137 } 139 }
138 140
139 func checkFileHasContents(c *C, storage environs.StorageReader, name string, con tents []byte) { 141 func checkFileHasContents(c *C, storage environs.StorageReader, name string, con tents []byte) {
140 » r, err := storage.Get(name) 142 » var r io.ReadCloser
143 » var err error
144
145 » for i := 0; i < 5; i++ {
146 » » r, err = storage.Get(name)
147 » » if err == nil {
148 » » » break
149 » » }
150 » » time.Sleep(1e9)
151 » }
141 c.Assert(err, IsNil) 152 c.Assert(err, IsNil)
142 c.Check(r, NotNil) 153 c.Check(r, NotNil)
154 defer r.Close()
143 155
144 data, err := ioutil.ReadAll(r) 156 data, err := ioutil.ReadAll(r)
145 c.Check(err, IsNil) 157 c.Check(err, IsNil)
146 c.Check(data, DeepEquals, contents) 158 c.Check(data, DeepEquals, contents)
147 159
148 url, err := storage.URL(name) 160 url, err := storage.URL(name)
149 c.Assert(err, IsNil) 161 c.Assert(err, IsNil)
150 162
151 » resp, err := http.Get(url) 163 » var resp *http.Response
164 » for i := 0; i < 5; i++ {
165 » » resp, err = http.Get(url)
166 » » c.Assert(err, IsNil)
167 » » if resp.StatusCode != 404 {
168 » » » break
169 » » }
170 » » c.Logf("get retrying after earlier get succeeded. *sigh*.")
171 » » time.Sleep(1e9)
172 » }
152 c.Assert(err, IsNil) 173 c.Assert(err, IsNil)
153 data, err = ioutil.ReadAll(resp.Body) 174 data, err = ioutil.ReadAll(resp.Body)
154 c.Assert(err, IsNil) 175 c.Assert(err, IsNil)
176 defer resp.Body.Close()
177 c.Assert(resp.StatusCode, Equals, 200, Commentf("error response: %s", da ta))
155 c.Check(data, DeepEquals, contents) 178 c.Check(data, DeepEquals, contents)
156 } 179 }
OLDNEW
« no previous file with comments | « environs/ec2/live_test.go ('k') | state/ssh.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b