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

Delta Between Two Patch Sets: state/unit_test.go

Issue 7950044: state/api/params: add CharmURL to ServiceInfo
Left Patch Set: Created 12 years ago
Right Patch Set: state/api/params: add CharmURL to ServiceInfo Created 12 years 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:
Right: Side by side diff | Download
« no previous file with change/comment | « state/state_test.go ('k') | worker/firewaller/firewaller_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 package state_test 1 package state_test
2 2
3 import ( 3 import (
4 . "launchpad.net/gocheck" 4 . "launchpad.net/gocheck"
5 "launchpad.net/juju-core/charm" 5 "launchpad.net/juju-core/charm"
6 "launchpad.net/juju-core/state" 6 "launchpad.net/juju-core/state"
7 "sort" 7 "sort"
8 "strconv" 8 "strconv"
9 "time" 9 "time"
10 ) 10 )
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 rel, err := s.State.AddRelation(eps...) 214 rel, err := s.State.AddRelation(eps...)
215 c.Assert(err, IsNil) 215 c.Assert(err, IsNil)
216 ru, err := rel.Unit(s.unit) 216 ru, err := rel.Unit(s.unit)
217 c.Assert(err, IsNil) 217 c.Assert(err, IsNil)
218 err = ru.EnterScope(nil) 218 err = ru.EnterScope(nil)
219 c.Assert(err, IsNil) 219 c.Assert(err, IsNil)
220 subUnit, err := s.State.Unit("logging/0") 220 subUnit, err := s.State.Unit("logging/0")
221 c.Assert(err, IsNil) 221 c.Assert(err, IsNil)
222 222
223 info := state.TestingStateInfo() 223 info := state.TestingStateInfo()
224 » st, err := state.Open(info) 224 » st, err := state.Open(info, state.TestingDialTimeout)
225 c.Assert(err, IsNil) 225 c.Assert(err, IsNil)
226 defer st.Close() 226 defer st.Close()
227 // Turn on fully-authenticated mode. 227 // Turn on fully-authenticated mode.
228 err = st.SetAdminMongoPassword("admin-secret") 228 err = st.SetAdminMongoPassword("admin-secret")
229 c.Assert(err, IsNil) 229 c.Assert(err, IsNil)
230 230
231 // Add a new machine, assign the units to it 231 // Add a new machine, assign the units to it
232 // and set its password. 232 // and set its password.
233 m, err := st.AddMachine("series", state.JobHostUnits) 233 m, err := st.AddMachine("series", state.JobHostUnits)
234 c.Assert(err, IsNil) 234 c.Assert(err, IsNil)
235 unit, err := st.Unit(s.unit.Name()) 235 unit, err := st.Unit(s.unit.Name())
236 c.Assert(err, IsNil) 236 c.Assert(err, IsNil)
237 subUnit, err = st.Unit(subUnit.Name()) 237 subUnit, err = st.Unit(subUnit.Name())
238 c.Assert(err, IsNil) 238 c.Assert(err, IsNil)
239 err = unit.AssignToMachine(m) 239 err = unit.AssignToMachine(m)
240 c.Assert(err, IsNil) 240 c.Assert(err, IsNil)
241 err = m.SetMongoPassword("foo") 241 err = m.SetMongoPassword("foo")
242 c.Assert(err, IsNil) 242 c.Assert(err, IsNil)
243 243
244 // Sanity check that we cannot connect with the wrong 244 // Sanity check that we cannot connect with the wrong
245 // password 245 // password
246 info.EntityName = m.EntityName() 246 info.EntityName = m.EntityName()
247 info.Password = "foo1" 247 info.Password = "foo1"
248 err = tryOpenState(info) 248 err = tryOpenState(info)
249 c.Assert(state.IsUnauthorizedError(err), Equals, true) 249 c.Assert(state.IsUnauthorizedError(err), Equals, true)
250 250
251 // Connect as the machine entity. 251 // Connect as the machine entity.
252 info.EntityName = m.EntityName() 252 info.EntityName = m.EntityName()
253 info.Password = "foo" 253 info.Password = "foo"
254 » st1, err := state.Open(info) 254 » st1, err := state.Open(info, state.TestingDialTimeout)
255 c.Assert(err, IsNil) 255 c.Assert(err, IsNil)
256 defer st1.Close() 256 defer st1.Close()
257 257
258 // Change the password for a unit derived from 258 // Change the password for a unit derived from
259 // the machine entity's state. 259 // the machine entity's state.
260 unit, err = st1.Unit(s.unit.Name()) 260 unit, err = st1.Unit(s.unit.Name())
261 c.Assert(err, IsNil) 261 c.Assert(err, IsNil)
262 err = unit.SetMongoPassword("bar") 262 err = unit.SetMongoPassword("bar")
263 c.Assert(err, IsNil) 263 c.Assert(err, IsNil)
264 264
265 // Now connect as the unit entity and, as that 265 // Now connect as the unit entity and, as that
266 // that entity, change the password for a new unit. 266 // that entity, change the password for a new unit.
267 info.EntityName = unit.EntityName() 267 info.EntityName = unit.EntityName()
268 info.Password = "bar" 268 info.Password = "bar"
269 » st2, err := state.Open(info) 269 » st2, err := state.Open(info, state.TestingDialTimeout)
270 c.Assert(err, IsNil) 270 c.Assert(err, IsNil)
271 defer st2.Close() 271 defer st2.Close()
272 272
273 // Check that we can set its password. 273 // Check that we can set its password.
274 unit, err = st2.Unit(subUnit.Name()) 274 unit, err = st2.Unit(subUnit.Name())
275 c.Assert(err, IsNil) 275 c.Assert(err, IsNil)
276 err = unit.SetMongoPassword("bar2") 276 err = unit.SetMongoPassword("bar2")
277 c.Assert(err, IsNil) 277 c.Assert(err, IsNil)
278 278
279 // Clear the admin password, so tests can reset the db. 279 // Clear the admin password, so tests can reset the db.
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 err := s.unit.SetAnnotations(annotations) 732 err := s.unit.SetAnnotations(annotations)
733 c.Assert(err, IsNil) 733 c.Assert(err, IsNil)
734 err = s.unit.EnsureDead() 734 err = s.unit.EnsureDead()
735 c.Assert(err, IsNil) 735 c.Assert(err, IsNil)
736 err = s.unit.Remove() 736 err = s.unit.Remove()
737 c.Assert(err, IsNil) 737 c.Assert(err, IsNil)
738 ann, err := s.unit.Annotations() 738 ann, err := s.unit.Annotations()
739 c.Assert(err, IsNil) 739 c.Assert(err, IsNil)
740 c.Assert(ann, DeepEquals, make(map[string]string)) 740 c.Assert(ann, DeepEquals, make(map[string]string))
741 } 741 }
LEFTRIGHT

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