LEFT | RIGHT |
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 24 matching lines...) Expand all Loading... |
99 ec2srv *ec2test.Server | 101 ec2srv *ec2test.Server |
100 s3srv *s3test.Server | 102 s3srv *s3test.Server |
101 } | 103 } |
102 | 104 |
103 func (srv *localServer) startServer(c *C) { | 105 func (srv *localServer) startServer(c *C) { |
104 var err error | 106 var err error |
105 srv.ec2srv, err = ec2test.NewServer() | 107 srv.ec2srv, err = ec2test.NewServer() |
106 if err != nil { | 108 if err != nil { |
107 c.Fatalf("cannot start ec2 test server: %v", err) | 109 c.Fatalf("cannot start ec2 test server: %v", err) |
108 } | 110 } |
109 » srv.s3srv, err = s3test.NewServer(true) | 111 » srv.s3srv, err = s3test.NewServer() |
110 if err != nil { | 112 if err != nil { |
111 c.Fatalf("cannot start s3 test server: %v", err) | 113 c.Fatalf("cannot start s3 test server: %v", err) |
112 } | 114 } |
113 aws.Regions["test"] = aws.Region{ | 115 aws.Regions["test"] = aws.Region{ |
114 » » Name: "test", | 116 » » Name: "test", |
115 » » EC2Endpoint: srv.ec2srv.URL(), | 117 » » EC2Endpoint: srv.ec2srv.URL(), |
116 » » S3Endpoint: srv.s3srv.URL(), | 118 » » S3Endpoint: srv.s3srv.URL(), |
| 119 » » S3LocationConstraint: true, |
117 } | 120 } |
118 s3inst := s3.New(aws.Auth{}, aws.Regions["test"]) | 121 s3inst := s3.New(aws.Auth{}, aws.Regions["test"]) |
119 putFakeTools(c, ec2.BucketStorage(s3inst.Bucket("public-tools"))) | 122 putFakeTools(c, ec2.BucketStorage(s3inst.Bucket("public-tools"))) |
120 srv.addSpice(c) | 123 srv.addSpice(c) |
121 } | 124 } |
122 | 125 |
123 // putFakeTools sets up a bucket containing something | 126 // putFakeTools sets up a bucket containing something |
124 // that looks like a tools archive so test methods | 127 // that looks like a tools archive so test methods |
125 // that start an instance can succeed even though they | 128 // that start an instance can succeed even though they |
126 // do not upload tools. | 129 // do not upload tools. |
(...skipping 26 matching lines...) Expand all Loading... |
153 delete(aws.Regions, "test") | 156 delete(aws.Regions, "test") |
154 } | 157 } |
155 | 158 |
156 // localServerSuite contains tests that run against a fake EC2 server | 159 // localServerSuite contains tests that run against a fake EC2 server |
157 // 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 |
158 // 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. |
159 // 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 |
160 // 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 |
161 // network address of the local server. | 164 // network address of the local server. |
162 type localServerSuite struct { | 165 type localServerSuite struct { |
163 » testing.LoggingSuite | 166 » coretesting.LoggingSuite |
| 167 » testing.StateSuite |
164 jujutest.Tests | 168 jujutest.Tests |
165 srv localServer | 169 srv localServer |
166 env environs.Environ | 170 env environs.Environ |
167 } | 171 } |
168 | 172 |
169 func (t *localServerSuite) SetUpSuite(c *C) { | 173 func (t *localServerSuite) SetUpSuite(c *C) { |
170 ec2.UseTestImageData(true) | 174 ec2.UseTestImageData(true) |
171 t.Tests.SetUpSuite(c) | 175 t.Tests.SetUpSuite(c) |
172 ec2.ShortTimeouts(true) | 176 ec2.ShortTimeouts(true) |
173 } | 177 } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 // TODO check for machine agent | 252 // TODO check for machine agent |
249 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) |
250 ec2.CheckScripts(c, x, fmt.Sprintf("JUJU_MACHINE_ID=1"), true) | 254 ec2.CheckScripts(c, x, fmt.Sprintf("JUJU_MACHINE_ID=1"), true) |
251 | 255 |
252 err = t.env.Destroy(append(insts, inst1)) | 256 err = t.env.Destroy(append(insts, inst1)) |
253 c.Assert(err, IsNil) | 257 c.Assert(err, IsNil) |
254 | 258 |
255 _, err = ec2.LoadState(t.env) | 259 _, err = ec2.LoadState(t.env) |
256 c.Assert(err, NotNil) | 260 c.Assert(err, NotNil) |
257 } | 261 } |
LEFT | RIGHT |