@@ -102,10 +102,22 @@ func node2k() *Node {
102102 ID : 0 ,
103103 Grade : numalib .Performance ,
104104 BaseSpeed : 1000 ,
105+ Disable : false ,
105106 }, {
106107 ID : 1 ,
107108 Grade : numalib .Performance ,
108109 BaseSpeed : 1000 ,
110+ Disable : false ,
111+ }, {
112+ ID : 2 ,
113+ Grade : numalib .Performance ,
114+ BaseSpeed : 1000 ,
115+ Disable : true ,
116+ }, {
117+ ID : 3 ,
118+ Grade : numalib .Performance ,
119+ BaseSpeed : 1000 ,
120+ Disable : true ,
109121 }},
110122 OverrideWitholdCompute : 1000 , // set by client reserved field
111123 },
@@ -137,7 +149,8 @@ func node2k() *Node {
137149 },
138150 ReservedResources : & NodeReservedResources {
139151 Cpu : NodeReservedCpuResources {
140- CpuShares : 1000 ,
152+ CpuShares : 3000 , // set by fingerprinting callback
153+ ReservedCpuCores : []uint16 {2 , 3 },
141154 },
142155 Memory : NodeReservedMemoryResources {
143156 MemoryMB : 1024 ,
@@ -248,6 +261,38 @@ func TestAllocsFit(t *testing.T) {
248261 must .Eq (t , 1000 , used .Flattened .Cpu .CpuShares )
249262 must .Eq (t , []uint16 {0 }, used .Flattened .Cpu .ReservedCores )
250263 must .Eq (t , 1024 , used .Flattened .Memory .MemoryMB )
264+
265+ a3 := & Allocation {
266+ AllocatedResources : & AllocatedResources {
267+ Tasks : map [string ]* AllocatedTaskResources {
268+ "web" : {
269+ Cpu : AllocatedCpuResources {
270+ CpuShares : 1000 ,
271+ },
272+ Memory : AllocatedMemoryResources {
273+ MemoryMB : 512 ,
274+ },
275+ },
276+ },
277+ },
278+ }
279+
280+ // Should fit one allocation
281+ fit , dim , used , err = AllocsFit (n , []* Allocation {a3 }, nil , false )
282+ must .NoError (t , err )
283+ must .True (t , fit , must .Sprintf ("failed for dimension %q" , dim ))
284+ must .Eq (t , 1000 , used .Flattened .Cpu .CpuShares )
285+ must .Eq (t , []uint16 {}, used .Flattened .Cpu .ReservedCores )
286+ must .Eq (t , 512 , used .Flattened .Memory .MemoryMB )
287+
288+ // Should not fit second allocation
289+ fit , dim , used , err = AllocsFit (n , []* Allocation {a3 , a3 }, nil , false )
290+ must .NoError (t , err )
291+ must .False (t , fit )
292+ must .Eq (t , "cpu" , dim )
293+ must .Eq (t , 2000 , used .Flattened .Cpu .CpuShares )
294+ must .Eq (t , []uint16 {}, used .Flattened .Cpu .ReservedCores )
295+ must .Eq (t , 1024 , used .Flattened .Memory .MemoryMB )
251296}
252297
253298func TestAllocsFit_Cores (t * testing.T ) {
@@ -649,8 +694,23 @@ func TestScoreFitBinPack(t *testing.T) {
649694 Cores : []numalib.Core {{
650695 ID : 0 ,
651696 Grade : numalib .Performance ,
652- BaseSpeed : 4096 ,
697+ BaseSpeed : 2048 ,
698+ }, {
699+ ID : 1 ,
700+ Grade : numalib .Performance ,
701+ BaseSpeed : 2048 ,
702+ }, {
703+ ID : 2 ,
704+ Grade : numalib .Performance ,
705+ BaseSpeed : 2048 ,
706+ Disable : true ,
707+ }, {
708+ ID : 3 ,
709+ Grade : numalib .Performance ,
710+ BaseSpeed : 2048 ,
711+ Disable : true ,
653712 }},
713+ OverrideWitholdCompute : 2048 , // set by client reserved field
654714 },
655715 },
656716 Memory : NodeMemoryResources {
@@ -661,7 +721,8 @@ func TestScoreFitBinPack(t *testing.T) {
661721 node .NodeResources .Compatibility ()
662722 node .ReservedResources = & NodeReservedResources {
663723 Cpu : NodeReservedCpuResources {
664- CpuShares : 2048 ,
724+ CpuShares : 6144 , // set by fingerprinting callback
725+ ReservedCpuCores : []uint16 {2 , 3 },
665726 },
666727 Memory : NodeReservedMemoryResources {
667728 MemoryMB : 4096 ,
0 commit comments