|
|
@@ -112,17 +112,17 @@ func TestAllocation_Add(t *testing.T) {
|
|
|
CPUCoreRequestAverage: 2.0,
|
|
|
CPUCoreUsageAverage: 1.0,
|
|
|
CPUCost: 2.0 * hrs1 * cpuPrice,
|
|
|
- CPUAdjustment: 3.0,
|
|
|
+ CPUCostAdjustment: 3.0,
|
|
|
GPUHours: 1.0 * hrs1,
|
|
|
GPUCost: 1.0 * hrs1 * gpuPrice,
|
|
|
- GPUAdjustment: 2.0,
|
|
|
+ GPUCostAdjustment: 2.0,
|
|
|
PVByteHours: 100.0 * gib * hrs1,
|
|
|
PVCost: 100.0 * hrs1 * pvPrice,
|
|
|
RAMByteHours: 8.0 * gib * hrs1,
|
|
|
RAMBytesRequestAverage: 8.0 * gib,
|
|
|
RAMBytesUsageAverage: 4.0 * gib,
|
|
|
RAMCost: 8.0 * hrs1 * ramPrice,
|
|
|
- RAMAdjustment: 1.0,
|
|
|
+ RAMCostAdjustment: 1.0,
|
|
|
SharedCost: 2.00,
|
|
|
ExternalCost: 1.00,
|
|
|
RawAllocationOnly: &RawAllocationOnlyData{},
|
|
|
@@ -176,20 +176,20 @@ func TestAllocation_Add(t *testing.T) {
|
|
|
if !util.IsApproximately(a1.CPUCost+a2.CPUCost, act.CPUCost) {
|
|
|
t.Fatalf("Allocation.Add: expected %f; actual %f", a1.CPUCost+a2.CPUCost, act.CPUCost)
|
|
|
}
|
|
|
- if !util.IsApproximately(a1.CPUAdjustment+a2.CPUAdjustment, act.CPUAdjustment) {
|
|
|
- t.Fatalf("Allocation.Add: expected %f; actual %f", a1.CPUAdjustment+a2.CPUAdjustment, act.CPUAdjustment)
|
|
|
+ if !util.IsApproximately(a1.CPUCostAdjustment+a2.CPUCostAdjustment, act.CPUCostAdjustment) {
|
|
|
+ t.Fatalf("Allocation.Add: expected %f; actual %f", a1.CPUCostAdjustment+a2.CPUCostAdjustment, act.CPUCostAdjustment)
|
|
|
}
|
|
|
if !util.IsApproximately(a1.GPUCost+a2.GPUCost, act.GPUCost) {
|
|
|
t.Fatalf("Allocation.Add: expected %f; actual %f", a1.GPUCost+a2.GPUCost, act.GPUCost)
|
|
|
}
|
|
|
- if !util.IsApproximately(a1.GPUAdjustment+a2.GPUAdjustment, act.GPUAdjustment) {
|
|
|
- t.Fatalf("Allocation.Add: expected %f; actual %f", a1.GPUAdjustment+a2.GPUAdjustment, act.GPUAdjustment)
|
|
|
+ if !util.IsApproximately(a1.GPUCostAdjustment+a2.GPUCostAdjustment, act.GPUCostAdjustment) {
|
|
|
+ t.Fatalf("Allocation.Add: expected %f; actual %f", a1.GPUCostAdjustment+a2.GPUCostAdjustment, act.GPUCostAdjustment)
|
|
|
}
|
|
|
if !util.IsApproximately(a1.RAMCost+a2.RAMCost, act.RAMCost) {
|
|
|
t.Fatalf("Allocation.Add: expected %f; actual %f", a1.RAMCost+a2.RAMCost, act.RAMCost)
|
|
|
}
|
|
|
- if !util.IsApproximately(a1.RAMAdjustment+a2.RAMAdjustment, act.RAMAdjustment) {
|
|
|
- t.Fatalf("Allocation.Add: expected %f; actual %f", a1.RAMAdjustment+a2.RAMAdjustment, act.RAMAdjustment)
|
|
|
+ if !util.IsApproximately(a1.RAMCostAdjustment+a2.RAMCostAdjustment, act.RAMCostAdjustment) {
|
|
|
+ t.Fatalf("Allocation.Add: expected %f; actual %f", a1.RAMCostAdjustment+a2.RAMCostAdjustment, act.RAMCostAdjustment)
|
|
|
}
|
|
|
if !util.IsApproximately(a1.PVCost+a2.PVCost, act.PVCost) {
|
|
|
t.Fatalf("Allocation.Add: expected %f; actual %f", a1.PVCost+a2.PVCost, act.PVCost)
|
|
|
@@ -281,17 +281,17 @@ func TestAllocation_Share(t *testing.T) {
|
|
|
CPUCoreRequestAverage: 2.0,
|
|
|
CPUCoreUsageAverage: 1.0,
|
|
|
CPUCost: 2.0 * hrs1 * cpuPrice,
|
|
|
- CPUAdjustment: 3.0,
|
|
|
+ CPUCostAdjustment: 3.0,
|
|
|
GPUHours: 1.0 * hrs1,
|
|
|
GPUCost: 1.0 * hrs1 * gpuPrice,
|
|
|
- GPUAdjustment: 2.0,
|
|
|
+ GPUCostAdjustment: 2.0,
|
|
|
PVByteHours: 100.0 * gib * hrs1,
|
|
|
PVCost: 100.0 * hrs1 * pvPrice,
|
|
|
RAMByteHours: 8.0 * gib * hrs1,
|
|
|
RAMBytesRequestAverage: 8.0 * gib,
|
|
|
RAMBytesUsageAverage: 4.0 * gib,
|
|
|
RAMCost: 8.0 * hrs1 * ramPrice,
|
|
|
- RAMAdjustment: 1.0,
|
|
|
+ RAMCostAdjustment: 1.0,
|
|
|
SharedCost: 2.00,
|
|
|
ExternalCost: 1.00,
|
|
|
}
|
|
|
@@ -440,10 +440,10 @@ func TestAllocation_MarshalJSON(t *testing.T) {
|
|
|
CPUCoreRequestAverage: 2.0,
|
|
|
CPUCoreUsageAverage: 1.0,
|
|
|
CPUCost: 2.0 * hrs * cpuPrice,
|
|
|
- CPUAdjustment: 3.0,
|
|
|
+ CPUCostAdjustment: 3.0,
|
|
|
GPUHours: 1.0 * hrs,
|
|
|
GPUCost: 1.0 * hrs * gpuPrice,
|
|
|
- GPUAdjustment: 2.0,
|
|
|
+ GPUCostAdjustment: 2.0,
|
|
|
NetworkCost: 0.05,
|
|
|
LoadBalancerCost: 0.02,
|
|
|
PVByteHours: 100.0 * gib * hrs,
|
|
|
@@ -452,7 +452,7 @@ func TestAllocation_MarshalJSON(t *testing.T) {
|
|
|
RAMBytesRequestAverage: 8.0 * gib,
|
|
|
RAMBytesUsageAverage: 4.0 * gib,
|
|
|
RAMCost: 8.0 * hrs * ramPrice,
|
|
|
- RAMAdjustment: 1.0,
|
|
|
+ RAMCostAdjustment: 1.0,
|
|
|
SharedCost: 2.00,
|
|
|
ExternalCost: 1.00,
|
|
|
RawAllocationOnly: &RawAllocationOnlyData{},
|
|
|
@@ -1771,9 +1771,9 @@ func TestAllocationSet_ReconcileAllocations(t *testing.T) {
|
|
|
// RAM | 44 | 6 | 11 | 1
|
|
|
// GPU | 11 | 24 | 1 | 1
|
|
|
"cluster1/namespace1/pod1/container1": {
|
|
|
- CPUAdjustment: 5.25,
|
|
|
- RAMAdjustment: -4.333333,
|
|
|
- GPUAdjustment: -0.583333,
|
|
|
+ CPUCostAdjustment: 5.25,
|
|
|
+ RAMCostAdjustment: -4.333333,
|
|
|
+ GPUCostAdjustment: -0.583333,
|
|
|
},
|
|
|
// ADJUSTMENT_RATE: 0.90909090909
|
|
|
// Type | NODE_COST | NODE_HOURs | ALLOC_COST | ALLOC_HOURS
|
|
|
@@ -1781,29 +1781,29 @@ func TestAllocationSet_ReconcileAllocations(t *testing.T) {
|
|
|
// RAM | 44 | 6 | 1 | 1
|
|
|
// GPU | 11 | 24 | 1 | 1
|
|
|
"cluster1/namespace1/pod-abc/container2": {
|
|
|
- CPUAdjustment: 5.25,
|
|
|
- RAMAdjustment: 5.666667,
|
|
|
- GPUAdjustment: -0.583333,
|
|
|
+ CPUCostAdjustment: 5.25,
|
|
|
+ RAMCostAdjustment: 5.666667,
|
|
|
+ GPUCostAdjustment: -0.583333,
|
|
|
},
|
|
|
"cluster1/namespace1/pod-def/container3": {
|
|
|
- CPUAdjustment: 5.25,
|
|
|
- RAMAdjustment: 5.666667,
|
|
|
- GPUAdjustment: -0.583333,
|
|
|
+ CPUCostAdjustment: 5.25,
|
|
|
+ RAMCostAdjustment: 5.666667,
|
|
|
+ GPUCostAdjustment: -0.583333,
|
|
|
},
|
|
|
"cluster1/namespace2/pod-ghi/container4": {
|
|
|
- CPUAdjustment: 5.25,
|
|
|
- RAMAdjustment: 5.666667,
|
|
|
- GPUAdjustment: -0.583333,
|
|
|
+ CPUCostAdjustment: 5.25,
|
|
|
+ RAMCostAdjustment: 5.666667,
|
|
|
+ GPUCostAdjustment: -0.583333,
|
|
|
},
|
|
|
"cluster1/namespace2/pod-ghi/container5": {
|
|
|
- CPUAdjustment: 5.25,
|
|
|
- RAMAdjustment: 5.666667,
|
|
|
- GPUAdjustment: -0.583333,
|
|
|
+ CPUCostAdjustment: 5.25,
|
|
|
+ RAMCostAdjustment: 5.666667,
|
|
|
+ GPUCostAdjustment: -0.583333,
|
|
|
},
|
|
|
"cluster1/namespace2/pod-jkl/container6": {
|
|
|
- CPUAdjustment: 5.25,
|
|
|
- RAMAdjustment: 5.666667,
|
|
|
- GPUAdjustment: -0.583333,
|
|
|
+ CPUCostAdjustment: 5.25,
|
|
|
+ RAMCostAdjustment: 5.666667,
|
|
|
+ GPUCostAdjustment: -0.583333,
|
|
|
},
|
|
|
// ADJUSTMENT_RATE: 1.0
|
|
|
// Type | NODE_COST | NODE_HOURs | ALLOC_COST | ALLOC_HOURS
|
|
|
@@ -1811,14 +1811,14 @@ func TestAllocationSet_ReconcileAllocations(t *testing.T) {
|
|
|
// RAM | 15 | 3 | 1 | 1
|
|
|
// GPU | 0 | 0 | 1 | 1
|
|
|
"cluster2/namespace2/pod-mno/container4": {
|
|
|
- CPUAdjustment: 4.0,
|
|
|
- RAMAdjustment: 4.0,
|
|
|
- GPUAdjustment: -1.0,
|
|
|
+ CPUCostAdjustment: 4.0,
|
|
|
+ RAMCostAdjustment: 4.0,
|
|
|
+ GPUCostAdjustment: -1.0,
|
|
|
},
|
|
|
"cluster2/namespace2/pod-mno/container5": {
|
|
|
- CPUAdjustment: 4.0,
|
|
|
- RAMAdjustment: 4.0,
|
|
|
- GPUAdjustment: -1.0,
|
|
|
+ CPUCostAdjustment: 4.0,
|
|
|
+ RAMCostAdjustment: 4.0,
|
|
|
+ GPUCostAdjustment: -1.0,
|
|
|
},
|
|
|
// ADJUSTMENT_RATE: 1.0
|
|
|
// Type | NODE_COST | NODE_HOURs | ALLOC_COST | ALLOC_HOURS
|
|
|
@@ -1826,14 +1826,14 @@ func TestAllocationSet_ReconcileAllocations(t *testing.T) {
|
|
|
// RAM | 15 | 2 | 1 | 1
|
|
|
// GPU | 0 | 0 | 1 | 1
|
|
|
"cluster2/namespace2/pod-pqr/container6": {
|
|
|
- CPUAdjustment: 5.666667,
|
|
|
- RAMAdjustment: 6.5,
|
|
|
- GPUAdjustment: -1.0,
|
|
|
+ CPUCostAdjustment: 5.666667,
|
|
|
+ RAMCostAdjustment: 6.5,
|
|
|
+ GPUCostAdjustment: -1.0,
|
|
|
},
|
|
|
"cluster2/namespace3/pod-stu/container7": {
|
|
|
- CPUAdjustment: 5.666667,
|
|
|
- RAMAdjustment: 6.5,
|
|
|
- GPUAdjustment: -1.0,
|
|
|
+ CPUCostAdjustment: 5.666667,
|
|
|
+ RAMCostAdjustment: 6.5,
|
|
|
+ GPUCostAdjustment: -1.0,
|
|
|
},
|
|
|
// ADJUSTMENT_RATE: 1.0
|
|
|
// Type | NODE_COST | NODE_HOURs | ALLOC_COST | ALLOC_HOURS
|
|
|
@@ -1841,14 +1841,14 @@ func TestAllocationSet_ReconcileAllocations(t *testing.T) {
|
|
|
// RAM | 10 | 2 | 1 | 1
|
|
|
// GPU | 10 | 24 | 1 | 1
|
|
|
"cluster2/namespace3/pod-vwx/container8": {
|
|
|
- CPUAdjustment: 4.0,
|
|
|
- RAMAdjustment: 4.0,
|
|
|
- GPUAdjustment: -0.583333,
|
|
|
+ CPUCostAdjustment: 4.0,
|
|
|
+ RAMCostAdjustment: 4.0,
|
|
|
+ GPUCostAdjustment: -0.583333,
|
|
|
},
|
|
|
"cluster2/namespace3/pod-vwx/container9": {
|
|
|
- CPUAdjustment: 4.0,
|
|
|
- RAMAdjustment: 4.0,
|
|
|
- GPUAdjustment: -0.583333,
|
|
|
+ CPUCostAdjustment: 4.0,
|
|
|
+ RAMCostAdjustment: 4.0,
|
|
|
+ GPUCostAdjustment: -0.583333,
|
|
|
},
|
|
|
},
|
|
|
},
|
|
|
@@ -1862,9 +1862,9 @@ func TestAllocationSet_ReconcileAllocations(t *testing.T) {
|
|
|
// RAM | 4 | 6 | 11 | 1
|
|
|
// GPU | 1 | 24 | 1 | 1
|
|
|
"cluster1/namespace1/pod1/container1": {
|
|
|
- CPUAdjustment: 5.25,
|
|
|
- RAMAdjustment: -4.333333,
|
|
|
- GPUAdjustment: -0.583333,
|
|
|
+ CPUCostAdjustment: 5.25,
|
|
|
+ RAMCostAdjustment: -4.333333,
|
|
|
+ GPUCostAdjustment: -0.583333,
|
|
|
},
|
|
|
// ADJUSTMENT_RATE: 10
|
|
|
// Type | NODE_COST | NODE_HOURs | ALLOC_COST | ALLOC_HOURS
|
|
|
@@ -1872,29 +1872,29 @@ func TestAllocationSet_ReconcileAllocations(t *testing.T) {
|
|
|
// RAM | 4 | 6 | 1 | 1
|
|
|
// GPU | 1 | 24 | 1 | 1
|
|
|
"cluster1/namespace1/pod-abc/container2": {
|
|
|
- CPUAdjustment: 5.25,
|
|
|
- RAMAdjustment: 5.6666667,
|
|
|
- GPUAdjustment: -0.583333,
|
|
|
+ CPUCostAdjustment: 5.25,
|
|
|
+ RAMCostAdjustment: 5.6666667,
|
|
|
+ GPUCostAdjustment: -0.583333,
|
|
|
},
|
|
|
"cluster1/namespace1/pod-def/container3": {
|
|
|
- CPUAdjustment: 5.25,
|
|
|
- RAMAdjustment: 5.6666667,
|
|
|
- GPUAdjustment: -0.583333,
|
|
|
+ CPUCostAdjustment: 5.25,
|
|
|
+ RAMCostAdjustment: 5.6666667,
|
|
|
+ GPUCostAdjustment: -0.583333,
|
|
|
},
|
|
|
"cluster1/namespace2/pod-ghi/container4": {
|
|
|
- CPUAdjustment: 5.25,
|
|
|
- RAMAdjustment: 5.6666667,
|
|
|
- GPUAdjustment: -0.583333,
|
|
|
+ CPUCostAdjustment: 5.25,
|
|
|
+ RAMCostAdjustment: 5.6666667,
|
|
|
+ GPUCostAdjustment: -0.583333,
|
|
|
},
|
|
|
"cluster1/namespace2/pod-ghi/container5": {
|
|
|
- CPUAdjustment: 5.25,
|
|
|
- RAMAdjustment: 5.6666667,
|
|
|
- GPUAdjustment: -0.583333,
|
|
|
+ CPUCostAdjustment: 5.25,
|
|
|
+ RAMCostAdjustment: 5.6666667,
|
|
|
+ GPUCostAdjustment: -0.583333,
|
|
|
},
|
|
|
"cluster1/namespace2/pod-jkl/container6": {
|
|
|
- CPUAdjustment: 5.25,
|
|
|
- RAMAdjustment: 5.6666667,
|
|
|
- GPUAdjustment: -0.583333,
|
|
|
+ CPUCostAdjustment: 5.25,
|
|
|
+ RAMCostAdjustment: 5.6666667,
|
|
|
+ GPUCostAdjustment: -0.583333,
|
|
|
},
|
|
|
// ADJUSTMENT_RATE: 1.0
|
|
|
// Type | NODE_COST | NODE_HOURs | ALLOC_COST | ALLOC_HOURS
|
|
|
@@ -1902,14 +1902,14 @@ func TestAllocationSet_ReconcileAllocations(t *testing.T) {
|
|
|
// RAM | 15 | 3 | 1 | 1
|
|
|
// GPU | 0 | 0 | 1 | 1
|
|
|
"cluster2/namespace2/pod-mno/container4": {
|
|
|
- CPUAdjustment: 4.0,
|
|
|
- RAMAdjustment: 4.0,
|
|
|
- GPUAdjustment: -1.0,
|
|
|
+ CPUCostAdjustment: 4.0,
|
|
|
+ RAMCostAdjustment: 4.0,
|
|
|
+ GPUCostAdjustment: -1.0,
|
|
|
},
|
|
|
"cluster2/namespace2/pod-mno/container5": {
|
|
|
- CPUAdjustment: 4.0,
|
|
|
- RAMAdjustment: 4.0,
|
|
|
- GPUAdjustment: -1.0,
|
|
|
+ CPUCostAdjustment: 4.0,
|
|
|
+ RAMCostAdjustment: 4.0,
|
|
|
+ GPUCostAdjustment: -1.0,
|
|
|
},
|
|
|
// ADJUSTMENT_RATE: 1.0
|
|
|
// Type | NODE_COST | NODE_HOURs | ALLOC_COST | ALLOC_HOURS
|
|
|
@@ -1917,14 +1917,14 @@ func TestAllocationSet_ReconcileAllocations(t *testing.T) {
|
|
|
// RAM | 15 | 2 | 1 | 1
|
|
|
// GPU | 0 | 0 | 1 | 1
|
|
|
"cluster2/namespace2/pod-pqr/container6": {
|
|
|
- CPUAdjustment: 5.666667,
|
|
|
- RAMAdjustment: 6.5,
|
|
|
- GPUAdjustment: -1.0,
|
|
|
+ CPUCostAdjustment: 5.666667,
|
|
|
+ RAMCostAdjustment: 6.5,
|
|
|
+ GPUCostAdjustment: -1.0,
|
|
|
},
|
|
|
"cluster2/namespace3/pod-stu/container7": {
|
|
|
- CPUAdjustment: 5.666667,
|
|
|
- RAMAdjustment: 6.5,
|
|
|
- GPUAdjustment: -1.0,
|
|
|
+ CPUCostAdjustment: 5.666667,
|
|
|
+ RAMCostAdjustment: 6.5,
|
|
|
+ GPUCostAdjustment: -1.0,
|
|
|
},
|
|
|
// ADJUSTMENT_RATE: 1.0
|
|
|
// Type | NODE_COST | NODE_HOURs | ALLOC_COST | ALLOC_HOURS
|
|
|
@@ -1932,14 +1932,14 @@ func TestAllocationSet_ReconcileAllocations(t *testing.T) {
|
|
|
// RAM | 10 | 2 | 1 | 1
|
|
|
// GPU | 10 | 24 | 1 | 1
|
|
|
"cluster2/namespace3/pod-vwx/container8": {
|
|
|
- CPUAdjustment: 4.0,
|
|
|
- RAMAdjustment: 4.0,
|
|
|
- GPUAdjustment: -0.583333,
|
|
|
+ CPUCostAdjustment: 4.0,
|
|
|
+ RAMCostAdjustment: 4.0,
|
|
|
+ GPUCostAdjustment: -0.583333,
|
|
|
},
|
|
|
"cluster2/namespace3/pod-vwx/container9": {
|
|
|
- CPUAdjustment: 4.0,
|
|
|
- RAMAdjustment: 4.0,
|
|
|
- GPUAdjustment: -0.583333,
|
|
|
+ CPUCostAdjustment: 4.0,
|
|
|
+ RAMCostAdjustment: 4.0,
|
|
|
+ GPUCostAdjustment: -0.583333,
|
|
|
},
|
|
|
},
|
|
|
},
|
|
|
@@ -1947,7 +1947,7 @@ func TestAllocationSet_ReconcileAllocations(t *testing.T) {
|
|
|
|
|
|
for name, testcase := range cases {
|
|
|
t.Run(name, func(t *testing.T) {
|
|
|
- err = as.ReconcileAllocations(testcase.assetSet)
|
|
|
+ err = as.Reconcile(testcase.assetSet)
|
|
|
reconAllocs := as.allocations
|
|
|
if err != nil {
|
|
|
t.Fatalf("unexpected error: %s", err)
|
|
|
@@ -1958,14 +1958,14 @@ func TestAllocationSet_ReconcileAllocations(t *testing.T) {
|
|
|
t.Fatalf("expected allocation %s", allocationName)
|
|
|
}
|
|
|
|
|
|
- if !util.IsApproximately(reconAllocs[allocationName].CPUAdjustment, testAlloc.CPUAdjustment) {
|
|
|
- t.Fatalf("expected CPU Adjustment for %s to be %f; got %f", allocationName, testAlloc.CPUAdjustment, reconAllocs[allocationName].CPUAdjustment)
|
|
|
+ if !util.IsApproximately(reconAllocs[allocationName].CPUCostAdjustment, testAlloc.CPUCostAdjustment) {
|
|
|
+ t.Fatalf("expected CPU Adjustment for %s to be %f; got %f", allocationName, testAlloc.CPUCostAdjustment, reconAllocs[allocationName].CPUCostAdjustment)
|
|
|
}
|
|
|
- if !util.IsApproximately(reconAllocs[allocationName].RAMAdjustment, testAlloc.RAMAdjustment) {
|
|
|
- t.Fatalf("expected RAM Adjustment for %s to be %f; got %f", allocationName, testAlloc.RAMAdjustment, reconAllocs[allocationName].RAMAdjustment)
|
|
|
+ if !util.IsApproximately(reconAllocs[allocationName].RAMCostAdjustment, testAlloc.RAMCostAdjustment) {
|
|
|
+ t.Fatalf("expected RAM Adjustment for %s to be %f; got %f", allocationName, testAlloc.RAMCostAdjustment, reconAllocs[allocationName].RAMCostAdjustment)
|
|
|
}
|
|
|
- if !util.IsApproximately(reconAllocs[allocationName].GPUAdjustment, testAlloc.GPUAdjustment) {
|
|
|
- t.Fatalf("expected GPU Adjustment for %s to be %f; got %f", allocationName, testAlloc.GPUAdjustment, reconAllocs[allocationName].GPUAdjustment)
|
|
|
+ if !util.IsApproximately(reconAllocs[allocationName].GPUCostAdjustment, testAlloc.GPUCostAdjustment) {
|
|
|
+ t.Fatalf("expected GPU Adjustment for %s to be %f; got %f", allocationName, testAlloc.GPUCostAdjustment, reconAllocs[allocationName].GPUCostAdjustment)
|
|
|
}
|
|
|
}
|
|
|
})
|