Left: | ||
Right: |
OLD | NEW |
---|---|
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 "launchpad.net/juju-core/state/api/params" | 7 "launchpad.net/juju-core/state/api/params" |
8 "sort" | 8 "sort" |
9 "strconv" | 9 "strconv" |
10 "time" | 10 "time" |
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
707 c.Assert(err, IsNil) | 707 c.Assert(err, IsNil) |
708 err = s.unit.Refresh() | 708 err = s.unit.Refresh() |
709 c.Assert(state.IsNotFound(err), Equals, true) | 709 c.Assert(state.IsNotFound(err), Equals, true) |
710 units, err := s.service.AllUnits() | 710 units, err := s.service.AllUnits() |
711 c.Assert(err, IsNil) | 711 c.Assert(err, IsNil) |
712 c.Assert(units, HasLen, 0) | 712 c.Assert(units, HasLen, 0) |
713 err = s.unit.Remove() | 713 err = s.unit.Remove() |
714 c.Assert(err, IsNil) | 714 c.Assert(err, IsNil) |
715 } | 715 } |
716 | 716 |
717 func (s *UnitSuite) TestRemovePathological(c *C) { | |
718 // Add a relation between wordpress and mysql... | |
719 wordpress := s.service | |
720 wordpress0 := s.unit | |
721 mysql, err := s.State.AddService("mysql", s.AddTestingCharm(c, "mysql")) | |
722 c.Assert(err, IsNil) | |
723 eps, err := s.State.InferEndpoints([]string{"wordpress", "mysql"}) | |
724 c.Assert(err, IsNil) | |
725 rel, err := s.State.AddRelation(eps...) | |
726 c.Assert(err, IsNil) | |
727 | |
728 // Enter scope with a unit of mysql, to keep the relation (and thus | |
729 // wordpress itself) from being removed. | |
730 mysql0, err := mysql.AddUnit() | |
731 c.Assert(err, IsNil) | |
732 mysql0ru, err := rel.Unit(mysql0) | |
733 c.Assert(err, IsNil) | |
734 err = mysql0ru.EnterScope(nil) | |
735 c.Assert(err, IsNil) | |
thumper
2013/04/15 23:03:24
It isn't obvious to me what these commands are her
fwereade
2013/04/16 00:56:04
I *think* that everything I could say here on top
| |
736 | |
737 // Destroy wordpress, and remove its last unit. | |
738 err = wordpress.Destroy() | |
739 c.Assert(err, IsNil) | |
740 err = wordpress0.EnsureDead() | |
741 c.Assert(err, IsNil) | |
742 err = wordpress0.Remove() | |
743 c.Assert(err, IsNil) | |
744 | |
745 // Check this didn't kill the service or relation yet... | |
746 err = wordpress.Refresh() | |
747 c.Assert(err, IsNil) | |
748 err = rel.Refresh() | |
749 c.Assert(err, IsNil) | |
750 | |
751 // ...but finally leaving relation scope on the other side does. | |
752 err = mysql0ru.LeaveScope() | |
753 c.Assert(err, IsNil) | |
754 err = wordpress.Refresh() | |
755 c.Assert(state.IsNotFound(err), Equals, true) | |
756 err = rel.Refresh() | |
757 c.Assert(state.IsNotFound(err), Equals, true) | |
758 } | |
759 | |
717 func (s *UnitSuite) TestWatchSubordinates(c *C) { | 760 func (s *UnitSuite) TestWatchSubordinates(c *C) { |
718 w := s.unit.WatchSubordinateUnits() | 761 w := s.unit.WatchSubordinateUnits() |
719 defer stop(c, w) | 762 defer stop(c, w) |
720 assertChange := func(units ...string) { | 763 assertChange := func(units ...string) { |
721 s.State.Sync() | 764 s.State.Sync() |
722 select { | 765 select { |
723 case ch, ok := <-w.Changes(): | 766 case ch, ok := <-w.Changes(): |
724 c.Assert(ok, Equals, true) | 767 c.Assert(ok, Equals, true) |
725 if len(units) > 0 { | 768 if len(units) > 0 { |
726 sort.Strings(ch) | 769 sort.Strings(ch) |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
907 err := s.unit.SetAnnotations(annotations) | 950 err := s.unit.SetAnnotations(annotations) |
908 c.Assert(err, IsNil) | 951 c.Assert(err, IsNil) |
909 err = s.unit.EnsureDead() | 952 err = s.unit.EnsureDead() |
910 c.Assert(err, IsNil) | 953 c.Assert(err, IsNil) |
911 err = s.unit.Remove() | 954 err = s.unit.Remove() |
912 c.Assert(err, IsNil) | 955 c.Assert(err, IsNil) |
913 ann, err := s.unit.Annotations() | 956 ann, err := s.unit.Annotations() |
914 c.Assert(err, IsNil) | 957 c.Assert(err, IsNil) |
915 c.Assert(ann, DeepEquals, make(map[string]string)) | 958 c.Assert(ann, DeepEquals, make(map[string]string)) |
916 } | 959 } |
OLD | NEW |