OLD | NEW |
1 // Copyright 2012, 2013 Canonical Ltd. | 1 // Copyright 2012, 2013 Canonical Ltd. |
2 // Licensed under the AGPLv3, see LICENCE file for details. | 2 // Licensed under the AGPLv3, see LICENCE file for details. |
3 | 3 |
4 package openstack_test | 4 package openstack_test |
5 | 5 |
6 import ( | 6 import ( |
7 "crypto/rand" | 7 "crypto/rand" |
8 "fmt" | 8 "fmt" |
9 "io" | 9 "io" |
10 "sort" | 10 "sort" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 c.Assert(err, gc.IsNil) | 91 c.Assert(err, gc.IsNil) |
92 containerURL, err := cl.MakeServiceURL("object-store", nil) | 92 containerURL, err := cl.MakeServiceURL("object-store", nil) |
93 c.Assert(err, gc.IsNil) | 93 c.Assert(err, gc.IsNil) |
94 t.TestConfig = t.TestConfig.Merge(coretesting.Attrs{ | 94 t.TestConfig = t.TestConfig.Merge(coretesting.Attrs{ |
95 "tools-url": containerURL + "/juju-dist-test/tools", | 95 "tools-url": containerURL + "/juju-dist-test/tools", |
96 "image-metadata-url": containerURL + "/juju-dist-test", | 96 "image-metadata-url": containerURL + "/juju-dist-test", |
97 "auth-url": t.cred.URL, | 97 "auth-url": t.cred.URL, |
98 }) | 98 }) |
99 t.LiveTests.SetUpSuite(c) | 99 t.LiveTests.SetUpSuite(c) |
100 // For testing, we create a storage instance to which is uploaded tools
and image metadata. | 100 // For testing, we create a storage instance to which is uploaded tools
and image metadata. |
| 101 t.PrepareOnce(c) |
101 t.metadataStorage = openstack.MetadataStorage(t.Env) | 102 t.metadataStorage = openstack.MetadataStorage(t.Env) |
102 // Put some fake tools metadata in place so that tests that are simply | 103 // Put some fake tools metadata in place so that tests that are simply |
103 // starting instances without any need to check if those instances | 104 // starting instances without any need to check if those instances |
104 // are running can find the metadata. | 105 // are running can find the metadata. |
105 envtesting.GenerateFakeToolsMetadata(c, t.metadataStorage) | 106 envtesting.GenerateFakeToolsMetadata(c, t.metadataStorage) |
106 } | 107 } |
107 | 108 |
108 func (t *LiveTests) TearDownSuite(c *gc.C) { | 109 func (t *LiveTests) TearDownSuite(c *gc.C) { |
109 if t.Env == nil { | 110 if t.Env == nil { |
110 // This can happen if SetUpSuite fails. | 111 // This can happen if SetUpSuite fails. |
(...skipping 10 matching lines...) Expand all Loading... |
121 t.LoggingSuite.SetUpTest(c) | 122 t.LoggingSuite.SetUpTest(c) |
122 t.LiveTests.SetUpTest(c) | 123 t.LiveTests.SetUpTest(c) |
123 } | 124 } |
124 | 125 |
125 func (t *LiveTests) TearDownTest(c *gc.C) { | 126 func (t *LiveTests) TearDownTest(c *gc.C) { |
126 t.LiveTests.TearDownTest(c) | 127 t.LiveTests.TearDownTest(c) |
127 t.LoggingSuite.TearDownTest(c) | 128 t.LoggingSuite.TearDownTest(c) |
128 } | 129 } |
129 | 130 |
130 func (t *LiveTests) TestEnsureGroupSetsGroupId(c *gc.C) { | 131 func (t *LiveTests) TestEnsureGroupSetsGroupId(c *gc.C) { |
| 132 t.PrepareOnce(c) |
131 rules := []nova.RuleInfo{ | 133 rules := []nova.RuleInfo{ |
132 { // First group explicitly asks for all services | 134 { // First group explicitly asks for all services |
133 IPProtocol: "tcp", | 135 IPProtocol: "tcp", |
134 FromPort: 22, | 136 FromPort: 22, |
135 ToPort: 22, | 137 ToPort: 22, |
136 Cidr: "0.0.0.0/0", | 138 Cidr: "0.0.0.0/0", |
137 }, | 139 }, |
138 { // Second group should only allow access from within the group | 140 { // Second group should only allow access from within the group |
139 IPProtocol: "tcp", | 141 IPProtocol: "tcp", |
140 FromPort: 1, | 142 FromPort: 1, |
(...skipping 18 matching lines...) Expand all Loading... |
159 c.Check(group.Rules[0].Group.TenantId, gc.Equals, "") | 161 c.Check(group.Rules[0].Group.TenantId, gc.Equals, "") |
160 c.Check(*group.Rules[1].IPProtocol, gc.Equals, "tcp") | 162 c.Check(*group.Rules[1].IPProtocol, gc.Equals, "tcp") |
161 c.Check(*group.Rules[1].FromPort, gc.Equals, 1) | 163 c.Check(*group.Rules[1].FromPort, gc.Equals, 1) |
162 c.Check(*group.Rules[1].ToPort, gc.Equals, 65535) | 164 c.Check(*group.Rules[1].ToPort, gc.Equals, 65535) |
163 c.Check(group.Rules[1].IPRange, gc.HasLen, 0) | 165 c.Check(group.Rules[1].IPRange, gc.HasLen, 0) |
164 c.Check(group.Rules[1].Group.Name, gc.Equals, groupName) | 166 c.Check(group.Rules[1].Group.Name, gc.Equals, groupName) |
165 c.Check(group.Rules[1].Group.TenantId, gc.Equals, group.TenantId) | 167 c.Check(group.Rules[1].Group.TenantId, gc.Equals, group.TenantId) |
166 } | 168 } |
167 | 169 |
168 func (t *LiveTests) TestSetupGlobalGroupExposesCorrectPorts(c *gc.C) { | 170 func (t *LiveTests) TestSetupGlobalGroupExposesCorrectPorts(c *gc.C) { |
| 171 t.PrepareOnce(c) |
169 groupName := "juju-test-group-" + randomName() | 172 groupName := "juju-test-group-" + randomName() |
170 // Make sure things are clean before we start, and will be clean when we
finish | 173 // Make sure things are clean before we start, and will be clean when we
finish |
171 cleanup := func() { | 174 cleanup := func() { |
172 c.Check(openstack.DiscardSecurityGroup(t.Env, groupName), gc.IsN
il) | 175 c.Check(openstack.DiscardSecurityGroup(t.Env, groupName), gc.IsN
il) |
173 } | 176 } |
174 cleanup() | 177 cleanup() |
175 defer cleanup() | 178 defer cleanup() |
176 statePort := 12345 // Default 37017 | 179 statePort := 12345 // Default 37017 |
177 apiPort := 34567 // Default 17070 | 180 apiPort := 34567 // Default 17070 |
178 group, err := openstack.SetUpGlobalGroup(t.Env, groupName, statePort, ap
iPort) | 181 group, err := openstack.SetUpGlobalGroup(t.Env, groupName, statePort, ap
iPort) |
(...skipping 22 matching lines...) Expand all Loading... |
201 fmt.Sprintf(`tcp %d %d "0.0.0.0/0" ""`, statePort, statePort), | 204 fmt.Sprintf(`tcp %d %d "0.0.0.0/0" ""`, statePort, statePort), |
202 fmt.Sprintf(`tcp %d %d "0.0.0.0/0" ""`, apiPort, apiPort), | 205 fmt.Sprintf(`tcp %d %d "0.0.0.0/0" ""`, apiPort, apiPort), |
203 fmt.Sprintf(`tcp 1 65535 "" "%s"`, groupName), | 206 fmt.Sprintf(`tcp 1 65535 "" "%s"`, groupName), |
204 fmt.Sprintf(`udp 1 65535 "" "%s"`, groupName), | 207 fmt.Sprintf(`udp 1 65535 "" "%s"`, groupName), |
205 fmt.Sprintf(`icmp -1 -1 "" "%s"`, groupName), | 208 fmt.Sprintf(`icmp -1 -1 "" "%s"`, groupName), |
206 } | 209 } |
207 sort.Strings(stringRules) | 210 sort.Strings(stringRules) |
208 sort.Strings(expectedRules) | 211 sort.Strings(expectedRules) |
209 c.Check(stringRules, gc.DeepEquals, expectedRules) | 212 c.Check(stringRules, gc.DeepEquals, expectedRules) |
210 } | 213 } |
OLD | NEW |