|
@@ -607,10 +607,10 @@ func TestSummaryAllocationSet_CPUEfficiency(t *testing.T) {
|
|
|
|
|
|
|
|
func TestSummaryAllocationSet_TotalEfficiency(t *testing.T) {
|
|
func TestSummaryAllocationSet_TotalEfficiency(t *testing.T) {
|
|
|
// Generating 6 sample summary allocations for testing
|
|
// Generating 6 sample summary allocations for testing
|
|
|
- var sa1, sa2, sa3, sa4, sa5, sa6 *SummaryAllocation
|
|
|
|
|
|
|
+ var sa1, sa2, sa3, sa4, sa5, sa6, idlesa *SummaryAllocation
|
|
|
|
|
|
|
|
// Generating accumulated summary allocation sets for testing
|
|
// Generating accumulated summary allocation sets for testing
|
|
|
- var sas1, sas2, sas3 *SummaryAllocationSet
|
|
|
|
|
|
|
+ var sas1, sas2, sas3, sas4 *SummaryAllocationSet
|
|
|
|
|
|
|
|
window, _ := ParseWindowUTC("7d")
|
|
window, _ := ParseWindowUTC("7d")
|
|
|
|
|
|
|
@@ -726,6 +726,20 @@ func TestSummaryAllocationSet_TotalEfficiency(t *testing.T) {
|
|
|
RAMCost: 1.0,
|
|
RAMCost: 1.0,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ idlesa = &SummaryAllocation{
|
|
|
|
|
+ Name: IdleSuffix,
|
|
|
|
|
+ Properties: &AllocationProperties{
|
|
|
|
|
+ Cluster: "cluster1",
|
|
|
|
|
+ Namespace: "namespace1",
|
|
|
|
|
+ Pod: "pod1",
|
|
|
|
|
+ Container: "container7",
|
|
|
|
|
+ },
|
|
|
|
|
+ Start: saStart,
|
|
|
|
|
+ End: saEnd,
|
|
|
|
|
+ CPUCost: 1.0,
|
|
|
|
|
+ RAMCost: 1.0,
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
testcase1Map := map[string]*SummaryAllocation{
|
|
testcase1Map := map[string]*SummaryAllocation{
|
|
|
"cluster1/namespace1/pod1/container1": sa1,
|
|
"cluster1/namespace1/pod1/container1": sa1,
|
|
|
"cluster1/namespace1/pod1/container2": sa2,
|
|
"cluster1/namespace1/pod1/container2": sa2,
|
|
@@ -740,6 +754,12 @@ func TestSummaryAllocationSet_TotalEfficiency(t *testing.T) {
|
|
|
"cluster1/namespace1/pod1/container6": sa6,
|
|
"cluster1/namespace1/pod1/container6": sa6,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ testcase4Map := map[string]*SummaryAllocation{
|
|
|
|
|
+ "cluster1/namespace1/pod1/container5": sa5,
|
|
|
|
|
+ "cluster1/namespace1/pod1/container6": sa6,
|
|
|
|
|
+ "cluster1/__idle__": idlesa,
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
sas1 = &SummaryAllocationSet{
|
|
sas1 = &SummaryAllocationSet{
|
|
|
SummaryAllocations: testcase1Map,
|
|
SummaryAllocations: testcase1Map,
|
|
|
Window: window,
|
|
Window: window,
|
|
@@ -755,6 +775,11 @@ func TestSummaryAllocationSet_TotalEfficiency(t *testing.T) {
|
|
|
Window: window,
|
|
Window: window,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ sas4 = &SummaryAllocationSet{
|
|
|
|
|
+ SummaryAllocations: testcase4Map,
|
|
|
|
|
+ Window: window,
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
cases := []struct {
|
|
cases := []struct {
|
|
|
name string
|
|
name string
|
|
|
testsas *SummaryAllocationSet
|
|
testsas *SummaryAllocationSet
|
|
@@ -775,6 +800,11 @@ func TestSummaryAllocationSet_TotalEfficiency(t *testing.T) {
|
|
|
testsas: sas3,
|
|
testsas: sas3,
|
|
|
expectedEfficiency: 0.30,
|
|
expectedEfficiency: 0.30,
|
|
|
},
|
|
},
|
|
|
|
|
+ {
|
|
|
|
|
+ name: "Check TotalEfficiency with idle cost",
|
|
|
|
|
+ testsas: sas4,
|
|
|
|
|
+ expectedEfficiency: 0.20,
|
|
|
|
|
+ },
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
for _, c := range cases {
|
|
for _, c := range cases {
|