~juju-qa/ubuntu/xenial/juju/2.0-rc2

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/state/assign_test.go

  • Committer: Nicholas Skaggs
  • Date: 2016-09-30 14:39:30 UTC
  • mfrom: (1.8.1)
  • Revision ID: nicholas.skaggs@canonical.com-20160930143930-vwwhrefh6ftckccy
import upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
222
222
        scons := constraints.MustParse("mem=2G cpu-power=400")
223
223
        err := s.wordpress.SetConstraints(scons)
224
224
        c.Assert(err, jc.ErrorIsNil)
225
 
        econs := constraints.MustParse("mem=4G cpu-cores=2")
 
225
        econs := constraints.MustParse("mem=4G cores=2")
226
226
        err = s.State.SetModelConstraints(econs)
227
227
        c.Assert(err, jc.ErrorIsNil)
228
228
 
405
405
        scons := constraints.MustParse("mem=2G cpu-power=400")
406
406
        err := s.wordpress.SetConstraints(scons)
407
407
        c.Assert(err, jc.ErrorIsNil)
408
 
        econs := constraints.MustParse("mem=4G cpu-cores=2")
 
408
        econs := constraints.MustParse("mem=4G cores=2")
409
409
        err = s.State.SetModelConstraints(econs)
410
410
        c.Assert(err, jc.ErrorIsNil)
411
411
 
417
417
        scons = constraints.MustParse("mem=6G cpu-power=800")
418
418
        err = s.wordpress.SetConstraints(scons)
419
419
        c.Assert(err, jc.ErrorIsNil)
420
 
        econs = constraints.MustParse("cpu-cores=4")
 
420
        econs = constraints.MustParse("cores=4")
421
421
        err = s.State.SetModelConstraints(econs)
422
422
        c.Assert(err, jc.ErrorIsNil)
423
423
 
432
432
        c.Assert(err, jc.ErrorIsNil)
433
433
        mcons, err := machine.Constraints()
434
434
        c.Assert(err, jc.ErrorIsNil)
435
 
        expect := constraints.MustParse("mem=2G cpu-cores=2 cpu-power=400")
 
435
        expect := constraints.MustParse("mem=2G cores=2 cpu-power=400")
436
436
        c.Assert(mcons, gc.DeepEquals, expect)
437
437
}
438
438
 
852
852
                assignOk:                false,
853
853
        }, {
854
854
                unitConstraints:         "arch=amd64",
855
 
                hardwareCharacteristics: "cpu-cores=1",
 
855
                hardwareCharacteristics: "cores=1",
856
856
                assignOk:                false,
857
857
        }, {
858
858
                unitConstraints:         "arch=amd64",
868
868
                assignOk:                false,
869
869
        }, {
870
870
                unitConstraints:         "mem=4G",
871
 
                hardwareCharacteristics: "cpu-cores=1",
 
871
                hardwareCharacteristics: "cores=1",
872
872
                assignOk:                false,
873
873
        }, {
874
874
                unitConstraints:         "mem=4G",
879
879
                hardwareCharacteristics: "mem=2G",
880
880
                assignOk:                false,
881
881
        }, {
882
 
                unitConstraints:         "cpu-cores=2",
883
 
                hardwareCharacteristics: "cpu-cores=2",
 
882
                unitConstraints:         "cores=2",
 
883
                hardwareCharacteristics: "cores=2",
884
884
                assignOk:                true,
885
885
        }, {
886
 
                unitConstraints:         "cpu-cores=2",
887
 
                hardwareCharacteristics: "cpu-cores=1",
 
886
                unitConstraints:         "cores=2",
 
887
                hardwareCharacteristics: "cores=1",
888
888
                assignOk:                false,
889
889
        }, {
890
 
                unitConstraints:         "cpu-cores=2",
 
890
                unitConstraints:         "cores=2",
891
891
                hardwareCharacteristics: "mem=4G",
892
892
                assignOk:                false,
893
893
        }, {
915
915
                hardwareCharacteristics: "root-disk=8192",
916
916
                assignOk:                true,
917
917
        }, {
918
 
                unitConstraints:         "arch=amd64 mem=4G cpu-cores=2 root-disk=8192",
919
 
                hardwareCharacteristics: "arch=amd64 mem=8G cpu-cores=2 root-disk=8192 cpu-power=50",
 
918
                unitConstraints:         "arch=amd64 mem=4G cores=2 root-disk=8192",
 
919
                hardwareCharacteristics: "arch=amd64 mem=8G cores=2 root-disk=8192 cpu-power=50",
920
920
                assignOk:                true,
921
921
        }, {
922
 
                unitConstraints:         "arch=amd64 mem=4G cpu-cores=2 root-disk=8192",
923
 
                hardwareCharacteristics: "arch=amd64 mem=8G cpu-cores=1 root-disk=4096 cpu-power=50",
 
922
                unitConstraints:         "arch=amd64 mem=4G cores=2 root-disk=8192",
 
923
                hardwareCharacteristics: "arch=amd64 mem=8G cores=1 root-disk=4096 cpu-power=50",
924
924
                assignOk:                false,
925
925
        },
926
926
}
1252
1252
func (s *assignCleanSuite) TestAssignUnitPolicyConcurrently(c *gc.C) {
1253
1253
        _, err := s.State.AddMachine("quantal", state.JobManageModel) // bootstrap machine
1254
1254
        c.Assert(err, jc.ErrorIsNil)
1255
 
        us := make([]*state.Unit, 50)
 
1255
        unitCount := 50
 
1256
        if raceDetector {
 
1257
                unitCount = 10
 
1258
        }
 
1259
        us := make([]*state.Unit, unitCount)
1256
1260
        for i := range us {
1257
1261
                us[i], err = s.wordpress.AddUnit()
1258
1262
                c.Assert(err, jc.ErrorIsNil)