Left: | ||
Right: |
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 state_test | 4 package state_test |
5 | 5 |
6 import ( | 6 import ( |
7 "fmt" | 7 "fmt" |
8 "sort" | 8 "sort" |
9 "strconv" | 9 "strconv" |
10 "time" | 10 "time" |
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
784 c.Assert(m, gc.IsNil) | 784 c.Assert(m, gc.IsNil) |
785 c.Assert(err, gc.ErrorMatches, eligibleMachinesInUse) | 785 c.Assert(err, gc.ErrorMatches, eligibleMachinesInUse) |
786 | 786 |
787 // Add a non-unit-hosting machine and check it is not chosen. | 787 // Add a non-unit-hosting machine and check it is not chosen. |
788 m, err = s.State.AddMachine("quantal", state.JobManageEnviron) | 788 m, err = s.State.AddMachine("quantal", state.JobManageEnviron) |
789 c.Assert(err, gc.IsNil) | 789 c.Assert(err, gc.IsNil) |
790 m, err = s.assignUnit(unit) | 790 m, err = s.assignUnit(unit) |
791 c.Assert(m, gc.IsNil) | 791 c.Assert(m, gc.IsNil) |
792 c.Assert(err, gc.ErrorMatches, eligibleMachinesInUse) | 792 c.Assert(err, gc.ErrorMatches, eligibleMachinesInUse) |
793 | 793 |
794 // Add a state management machine which can host units and check it is n ot chosen. | |
dimitern
2014/01/24 13:31:38
Why remove this, rather than just change JobManage
rog
2014/01/24 13:34:42
Because it would then be exactly the same as the f
| |
795 m, err = s.State.AddMachine("quantal", state.JobManageState, state.JobHo stUnits) | |
796 c.Assert(err, gc.IsNil) | |
797 m, err = s.assignUnit(unit) | |
798 c.Assert(m, gc.IsNil) | |
799 c.Assert(err, gc.ErrorMatches, eligibleMachinesInUse) | |
800 | |
801 // Add a environ management machine which can host units and check it is not chosen. | 794 // Add a environ management machine which can host units and check it is not chosen. |
802 m, err = s.State.AddMachine("quantal", state.JobManageEnviron, state.Job HostUnits) | 795 m, err = s.State.AddMachine("quantal", state.JobManageEnviron, state.Job HostUnits) |
803 c.Assert(err, gc.IsNil) | 796 c.Assert(err, gc.IsNil) |
804 m, err = s.assignUnit(unit) | 797 m, err = s.assignUnit(unit) |
805 c.Assert(m, gc.IsNil) | 798 c.Assert(m, gc.IsNil) |
806 c.Assert(err, gc.ErrorMatches, eligibleMachinesInUse) | 799 c.Assert(err, gc.ErrorMatches, eligibleMachinesInUse) |
807 | 800 |
808 // Add a machine with the wrong series and check it is not chosen. | 801 // Add a machine with the wrong series and check it is not chosen. |
809 m, err = s.State.AddMachine("anotherseries", state.JobHostUnits) | 802 m, err = s.State.AddMachine("anotherseries", state.JobHostUnits) |
810 c.Assert(err, gc.IsNil) | 803 c.Assert(err, gc.IsNil) |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1157 c.Assert(err, gc.IsNil) | 1150 c.Assert(err, gc.IsNil) |
1158 assignments[id] = append(assignments[id], r.u) | 1151 assignments[id] = append(assignments[id], r.u) |
1159 } | 1152 } |
1160 for id, us := range assignments { | 1153 for id, us := range assignments { |
1161 if len(us) != 1 { | 1154 if len(us) != 1 { |
1162 c.Errorf("machine %s expected one unit, got %q", id, us) | 1155 c.Errorf("machine %s expected one unit, got %q", id, us) |
1163 } | 1156 } |
1164 } | 1157 } |
1165 c.Assert(assignments, gc.HasLen, len(us)) | 1158 c.Assert(assignments, gc.HasLen, len(us)) |
1166 } | 1159 } |
OLD | NEW |