LEFT | RIGHT |
(no file at all) | |
1 package ec2_test | 1 package ec2_test |
2 | 2 |
3 import ( | 3 import ( |
4 "fmt" | 4 "fmt" |
5 "launchpad.net/goamz/aws" | 5 "launchpad.net/goamz/aws" |
6 amzec2 "launchpad.net/goamz/ec2" | 6 amzec2 "launchpad.net/goamz/ec2" |
7 "launchpad.net/goamz/ec2/ec2test" | 7 "launchpad.net/goamz/ec2/ec2test" |
8 "launchpad.net/goamz/s3" | 8 "launchpad.net/goamz/s3" |
9 "launchpad.net/goamz/s3/s3test" | 9 "launchpad.net/goamz/s3/s3test" |
10 . "launchpad.net/gocheck" | 10 . "launchpad.net/gocheck" |
11 "launchpad.net/goyaml" | 11 "launchpad.net/goyaml" |
12 "launchpad.net/juju-core/environs" | 12 "launchpad.net/juju-core/environs" |
13 "launchpad.net/juju-core/environs/ec2" | 13 "launchpad.net/juju-core/environs/ec2" |
14 "launchpad.net/juju-core/environs/jujutest" | 14 "launchpad.net/juju-core/environs/jujutest" |
15 "launchpad.net/juju-core/state" | 15 "launchpad.net/juju-core/state" |
16 » "launchpad.net/juju-core/testing" | 16 » "launchpad.net/juju-core/state/testing" |
| 17 » coretesting "launchpad.net/juju-core/testing" |
17 "launchpad.net/juju-core/version" | 18 "launchpad.net/juju-core/version" |
18 "strings" | 19 "strings" |
19 ) | 20 ) |
20 | 21 |
21 // you need to make sure the region you use here | 22 // you need to make sure the region you use here |
22 // has entries in the images/query txt files. | 23 // has entries in the images/query txt files. |
23 var functionalConfig = []byte(` | 24 var functionalConfig = []byte(` |
24 environments: | 25 environments: |
25 sample: | 26 sample: |
26 type: ec2 | 27 type: ec2 |
(...skipping 27 matching lines...) Expand all Loading... |
54 Name: name, | 55 Name: name, |
55 }, | 56 }, |
56 }, | 57 }, |
57 }) | 58 }) |
58 } | 59 } |
59 } | 60 } |
60 | 61 |
61 // localLiveSuite runs tests from LiveTests using a fake | 62 // localLiveSuite runs tests from LiveTests using a fake |
62 // EC2 server that runs within the test process itself. | 63 // EC2 server that runs within the test process itself. |
63 type localLiveSuite struct { | 64 type localLiveSuite struct { |
64 » testing.LoggingSuite | 65 » coretesting.LoggingSuite |
| 66 » testing.StateSuite |
65 LiveTests | 67 LiveTests |
66 srv localServer | 68 srv localServer |
67 env environs.Environ | 69 env environs.Environ |
68 } | 70 } |
69 | 71 |
70 func (t *localLiveSuite) SetUpSuite(c *C) { | 72 func (t *localLiveSuite) SetUpSuite(c *C) { |
71 ec2.UseTestImageData(true) | 73 ec2.UseTestImageData(true) |
72 t.srv.startServer(c) | 74 t.srv.startServer(c) |
73 t.LiveTests.SetUpSuite(c) | 75 t.LiveTests.SetUpSuite(c) |
74 t.env = t.LiveTests.Env | 76 t.env = t.LiveTests.Env |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 125 |
124 // putFakeTools sets up a bucket containing something | 126 // putFakeTools sets up a bucket containing something |
125 // that looks like a tools archive so test methods | 127 // that looks like a tools archive so test methods |
126 // that start an instance can succeed even though they | 128 // that start an instance can succeed even though they |
127 // do not upload tools. | 129 // do not upload tools. |
128 func putFakeTools(c *C, s environs.StorageWriter) { | 130 func putFakeTools(c *C, s environs.StorageWriter) { |
129 path := environs.ToolsPath(version.Current, environs.CurrentSeries, envi
rons.CurrentArch) | 131 path := environs.ToolsPath(version.Current, environs.CurrentSeries, envi
rons.CurrentArch) |
130 c.Logf("putting fake tools at %v", path) | 132 c.Logf("putting fake tools at %v", path) |
131 toolsContents := "tools archive, honest guv" | 133 toolsContents := "tools archive, honest guv" |
132 err := s.Put(path, strings.NewReader(toolsContents), int64(len(toolsCont
ents))) | 134 err := s.Put(path, strings.NewReader(toolsContents), int64(len(toolsCont
ents))) |
133 » if err != nil { | 135 » c.Assert(err, IsNil) |
134 » » c.Fatal(err) | |
135 » } | |
136 } | 136 } |
137 | 137 |
138 // addSpice adds some "spice" to the local server | 138 // addSpice adds some "spice" to the local server |
139 // by adding state that may cause tests to fail. | 139 // by adding state that may cause tests to fail. |
140 func (srv *localServer) addSpice(c *C) { | 140 func (srv *localServer) addSpice(c *C) { |
141 states := []amzec2.InstanceState{ | 141 states := []amzec2.InstanceState{ |
142 ec2test.ShuttingDown, | 142 ec2test.ShuttingDown, |
143 ec2test.Terminated, | 143 ec2test.Terminated, |
144 ec2test.Stopped, | 144 ec2test.Stopped, |
145 } | 145 } |
(...skipping 10 matching lines...) Expand all Loading... |
156 delete(aws.Regions, "test") | 156 delete(aws.Regions, "test") |
157 } | 157 } |
158 | 158 |
159 // localServerSuite contains tests that run against a fake EC2 server | 159 // localServerSuite contains tests that run against a fake EC2 server |
160 // running within the test process itself. These tests can test things that | 160 // running within the test process itself. These tests can test things that |
161 // would be unreasonably slow or expensive to test on a live Amazon server. | 161 // would be unreasonably slow or expensive to test on a live Amazon server. |
162 // It starts a new local ec2test server for each test. The server is | 162 // It starts a new local ec2test server for each test. The server is |
163 // accessed by using the "test" region, which is changed to point to the | 163 // accessed by using the "test" region, which is changed to point to the |
164 // network address of the local server. | 164 // network address of the local server. |
165 type localServerSuite struct { | 165 type localServerSuite struct { |
166 » testing.LoggingSuite | 166 » coretesting.LoggingSuite |
| 167 » testing.StateSuite |
167 jujutest.Tests | 168 jujutest.Tests |
168 srv localServer | 169 srv localServer |
169 env environs.Environ | 170 env environs.Environ |
170 } | 171 } |
171 | 172 |
172 func (t *localServerSuite) SetUpSuite(c *C) { | 173 func (t *localServerSuite) SetUpSuite(c *C) { |
173 ec2.UseTestImageData(true) | 174 ec2.UseTestImageData(true) |
174 t.Tests.SetUpSuite(c) | 175 t.Tests.SetUpSuite(c) |
175 ec2.ShortTimeouts(true) | 176 ec2.ShortTimeouts(true) |
176 } | 177 } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 // TODO check for machine agent | 252 // TODO check for machine agent |
252 ec2.CheckScripts(c, x, fmt.Sprintf("JUJU_ZOOKEEPER='%s%s'", bootstrapDNS
, ec2.ZkPortSuffix), true) | 253 ec2.CheckScripts(c, x, fmt.Sprintf("JUJU_ZOOKEEPER='%s%s'", bootstrapDNS
, ec2.ZkPortSuffix), true) |
253 ec2.CheckScripts(c, x, fmt.Sprintf("JUJU_MACHINE_ID=1"), true) | 254 ec2.CheckScripts(c, x, fmt.Sprintf("JUJU_MACHINE_ID=1"), true) |
254 | 255 |
255 err = t.env.Destroy(append(insts, inst1)) | 256 err = t.env.Destroy(append(insts, inst1)) |
256 c.Assert(err, IsNil) | 257 c.Assert(err, IsNil) |
257 | 258 |
258 _, err = ec2.LoadState(t.env) | 259 _, err = ec2.LoadState(t.env) |
259 c.Assert(err, NotNil) | 260 c.Assert(err, NotNil) |
260 } | 261 } |
LEFT | RIGHT |