Răsfoiți Sursa

Include adjustment in idle cost: write failing test

Niko Kovacevic 5 ani în urmă
părinte
comite
cd88567a2c
2 a modificat fișierele cu 24 adăugiri și 24 ștergeri
  1. 24 23
      pkg/kubecost/allocation_test.go
  2. 0 1
      pkg/kubecost/asset_test.go

+ 24 - 23
pkg/kubecost/allocation_test.go

@@ -901,34 +901,35 @@ func TestAllocationSet_ComputeIdleAllocations(t *testing.T) {
 	// NOTE: we're re-using generateAllocationSet so this has to line up with
 	// the allocated node costs from that function. See table above.
 
-	// | Hierarchy                               | Cost |  CPU |  RAM |  GPU |
-	// +-----------------------------------------+------+------+------+------+
+	// | Hierarchy                               | Cost |  CPU |  RAM |  GPU | Adjustment |
+	// +-----------------------------------------+------+------+------+------+------------+
 	//   cluster1:
-	//     nodes                                  100.00  50.00  40.00  10.00
-	// +-----------------------------------------+------+------+------+------+
-	//   cluster1 subtotal                        100.00  50.00  40.00  10.00
-	// +-----------------------------------------+------+------+------+------+
-	//   cluster1 allocated                        48.00   6.00  16.00   6.00
-	// +-----------------------------------------+------+------+------+------+
-	//   cluster1 idle                             72.00  44.00  24.00   4.00
-	// +-----------------------------------------+------+------+------+------+
+	//     nodes                                  100.00  55.00  44.00  11.00      -10.00
+	// +-----------------------------------------+------+------+------+------+------------+
+	//   cluster1 subtotal                        100.00  50.00  40.00  10.00      -10.00
+	// +-----------------------------------------+------+------+------+------+------------+
+	//   cluster1 allocated                        48.00   6.00  16.00   6.00        0.00
+	// +-----------------------------------------+------+------+------+------+------------+
+	//   cluster1 idle                             72.00  44.00  24.00   4.00        0.00
+	// +-----------------------------------------+------+------+------+------+------------+
 	//   cluster2:
-	//     node1                                   35.00  20.00  15.00   0.00
-	//     node2                                   35.00  20.00  15.00   0.00
-	//     node3                                   30.00  10.00  10.00  10.00
+	//     node1                                   35.00  20.00  15.00   0.00        0.00
+	//     node2                                   35.00  20.00  15.00   0.00        0.00
+	//     node3                                   30.00  10.00  10.00  10.00        0.00
 	//     (disks should not matter for idle)
-	// +-----------------------------------------+------+------+------+------+
-	//   cluster2 subtotal                        100.00  50.00  40.00  10.00
-	// +-----------------------------------------+------+------+------+------+
-	//   cluster2 allocated                        28.00   6.00   6.00   6.00
-	// +-----------------------------------------+------+------+------+------+
-	//   cluster2 idle                             82.00  44.00  34.00   4.00
-	// +-----------------------------------------+------+------+------+------+
+	// +-----------------------------------------+------+------+------+------+------------+
+	//   cluster2 subtotal                        100.00  50.00  40.00  10.00        0.00
+	// +-----------------------------------------+------+------+------+------+------------+
+	//   cluster2 allocated                        28.00   6.00   6.00   6.00        0.00
+	// +-----------------------------------------+------+------+------+------+------------+
+	//   cluster2 idle                             82.00  44.00  34.00   4.00        0.00
+	// +-----------------------------------------+------+------+------+------+------------+
 
 	cluster1Nodes := NewNode("", "cluster1", "", start, end, NewWindow(&start, &end))
-	cluster1Nodes.CPUCost = 50.0
-	cluster1Nodes.RAMCost = 40.0
-	cluster1Nodes.GPUCost = 10.0
+	cluster1Nodes.CPUCost = 55.0
+	cluster1Nodes.RAMCost = 44.0
+	cluster1Nodes.GPUCost = 11.0
+	cluster1Nodes.adjustment = -10.00
 
 	cluster2Node1 := NewNode("node1", "cluster2", "node1", start, end, NewWindow(&start, &end))
 	cluster2Node1.CPUCost = 20.0

+ 0 - 1
pkg/kubecost/asset_test.go

@@ -837,7 +837,6 @@ func TestAssetSet_AggregateBy(t *testing.T) {
 	if err != nil {
 		t.Fatalf("AssetSet.AggregateBy: unexpected error: %s", err)
 	}
-	fmt.Println(as.assets)
 	assertAssetSet(t, as, "1e", window, map[string]float64{
 		"__undefined__": 53.00,
 		"test=test":     7.00,