Просмотр исходного кода

improve accumulateBy tests; use asr.window() with no lock

Alejandro 4 лет назад
Родитель
Сommit
deed98f249
2 измененных файлов с 232 добавлено и 181 удалено
  1. 15 7
      pkg/kubecost/allocation.go
  2. 217 174
      pkg/kubecost/allocation_test.go

+ 15 - 7
pkg/kubecost/allocation.go

@@ -2263,20 +2263,20 @@ func (asr *AllocationSetRange) Accumulate() (*AllocationSet, error) {
 func (asr *AllocationSetRange) AccumulateBy(resolution time.Duration) (*AllocationSetRange, error) {
 func (asr *AllocationSetRange) AccumulateBy(resolution time.Duration) (*AllocationSetRange, error) {
 	allocSetRange := &AllocationSetRange{allocations: []*AllocationSet{}}
 	allocSetRange := &AllocationSetRange{allocations: []*AllocationSet{}}
 	var allocSet *AllocationSet
 	var allocSet *AllocationSet
+	var currAccumulatedSum time.Duration
 	var err error
 	var err error
 
 
-	//This uses a lock and can't be called after locking asr
-	asrWindow := asr.Window()
-
 	asr.Lock()
 	asr.Lock()
 	defer asr.Unlock()
 	defer asr.Unlock()
 
 
-	if asrWindow.IsEmpty() {
+	// // use window() with no lock
+	if asr.window().IsEmpty() {
 		return asr, nil
 		return asr, nil
 	}
 	}
 
 
+	asrWindow := asr.window()
+
 	// check as.window and accumulate sets until sum of window durations == time.duration wanted -> add accumulated set to allocSetRange
 	// check as.window and accumulate sets until sum of window durations == time.duration wanted -> add accumulated set to allocSetRange
-	var currAccumulatedSum time.Duration
 	for _, as := range asr.allocations {
 	for _, as := range asr.allocations {
 		allocSet, err = allocSet.accumulate(as)
 		allocSet, err = allocSet.accumulate(as)
 		if err != nil {
 		if err != nil {
@@ -2466,12 +2466,20 @@ func (asr *AllocationSetRange) UTCOffset() time.Duration {
 // Window returns the full window that the AllocationSetRange spans, from the
 // Window returns the full window that the AllocationSetRange spans, from the
 // start of the first AllocationSet to the end of the last one.
 // start of the first AllocationSet to the end of the last one.
 func (asr *AllocationSetRange) Window() Window {
 func (asr *AllocationSetRange) Window() Window {
-	if asr == nil || asr.Length() == 0 {
+	asr.Lock()
+	defer asr.Unlock()
+	return asr.window()
+}
+
+// (*AllocationSetRange).window() is not safe for concurrent use as it does not acquire a lock.
+// For the safe method please use (*AllocationSetRange).Window()
+func (asr *AllocationSetRange) window() Window {
+	if asr == nil || len(asr.allocations) == 0 {
 		return NewWindow(nil, nil)
 		return NewWindow(nil, nil)
 	}
 	}
 
 
 	start := asr.allocations[0].Start()
 	start := asr.allocations[0].Start()
-	end := asr.allocations[asr.Length()-1].End()
+	end := asr.allocations[len(asr.allocations)-1].End()
 
 
 	return NewWindow(&start, &end)
 	return NewWindow(&start, &end)
 }
 }

+ 217 - 174
pkg/kubecost/allocation_test.go

@@ -2067,71 +2067,121 @@ func TestAllocationSetRange_Accumulate(t *testing.T) {
 		t.Fatalf("accumulating AllocationSetRange: expected %f minutes; actual %f", 2880.0, alloc.Minutes())
 		t.Fatalf("accumulating AllocationSetRange: expected %f minutes; actual %f", 2880.0, alloc.Minutes())
 	}
 	}
 }
 }
+func TestAllocationSetRange_AccumulateBy_Nils(t *testing.T) {
+	var err error
+	var result *AllocationSetRange
 
 
-func TestAllocationSetRange_AccumulateBy(t *testing.T) {
-	ago3d := time.Now().UTC().Truncate(day).Add(-3 * day)
 	ago2d := time.Now().UTC().Truncate(day).Add(-2 * day)
 	ago2d := time.Now().UTC().Truncate(day).Add(-2 * day)
 	yesterday := time.Now().UTC().Truncate(day).Add(-day)
 	yesterday := time.Now().UTC().Truncate(day).Add(-day)
 	today := time.Now().UTC().Truncate(day)
 	today := time.Now().UTC().Truncate(day)
 	tomorrow := time.Now().UTC().Truncate(day).Add(day)
 	tomorrow := time.Now().UTC().Truncate(day).Add(day)
-	duration2Days := time.Hour * 24 * 2
 
 
-	// Accumulating any combination of nil and/or empty set should result in empty set
-	// test 1 nil set
-	result, err := NewAllocationSetRange(nil).AccumulateBy(duration2Days)
-	for _, as := range result.allocations {
-		if err != nil {
-			t.Fatalf("unexpected error accumulating nil AllocationSetRange: %s", err)
-		}
-		if !as.IsEmpty() {
-			t.Fatalf("accumulating nil AllocationSetRange: expected empty; actual %s", result)
-		}
+	// Test nil & empty sets
+	nilEmptycases := []struct {
+		asr        *AllocationSetRange
+		resolution time.Duration
+
+		testId string
+	}{
+		{
+			asr:        NewAllocationSetRange(nil),
+			resolution: time.Hour * 24 * 2,
+
+			testId: "AccumulateBy_Nils Empty Test 1",
+		},
+		{
+			asr:        NewAllocationSetRange(nil, nil),
+			resolution: time.Hour * 1,
+
+			testId: "AccumulateBy_Nils Empty Test 2",
+		},
+		{
+			asr:        NewAllocationSetRange(nil, NewAllocationSet(ago2d, yesterday), nil, NewAllocationSet(today, tomorrow)),
+			resolution: time.Hour * 24 * 7,
+
+			testId: "AccumulateBy_Nils Empty Test 3",
+		},
 	}
 	}
 
 
-	// test 2 nil sets
-	result, err = NewAllocationSetRange(nil, nil).AccumulateBy(duration2Days)
-	for _, as := range result.allocations {
-		if err != nil {
-			t.Fatalf("unexpected error accumulating nil AllocationSetRange: %s", err)
-		}
-		if !as.IsEmpty() {
-			t.Fatalf("accumulating nil AllocationSetRange: expected empty; actual %s", result)
+	for _, c := range nilEmptycases {
+		result, err = c.asr.AccumulateBy(c.resolution)
+		for _, as := range result.allocations {
+			if !as.IsEmpty() {
+				t.Errorf("accumulating nil AllocationSetRange: expected empty; actual %s; TestId: %s", result, c.testId)
+			}
 		}
 		}
 	}
 	}
+	if err != nil {
+		t.Errorf("unexpected error accumulating nil AllocationSetRange: %s", err)
+	}
 
 
-	// test 1 set 2d long
-	result, err = NewAllocationSetRange(NewAllocationSet(yesterday, today)).AccumulateBy(duration2Days)
-	for _, as := range result.allocations {
-		if err != nil {
-			t.Fatalf("unexpected error accumulating nil AllocationSetRange: %s", err)
-		}
-		if !as.IsEmpty() {
-			t.Fatalf("accumulating nil AllocationSetRange: expected empty; actual %s", result)
-		}
+	yesterdayAS := NewAllocationSet(yesterday, today)
+	yesterdayAS.Set(NewMockUnitAllocation("a", yesterday, day, nil))
+	todayAS := NewAllocationSet(today, tomorrow)
+	todayAS.Set(NewMockUnitAllocation("b", today, day, nil))
+
+	nilAndNonEmptyCases := []struct {
+		asr        *AllocationSetRange
+		resolution time.Duration
+
+		expected float64
+		testId   string
+	}{
+		{
+			asr:        NewAllocationSetRange(nil, todayAS),
+			resolution: time.Hour * 2,
+
+			expected: 6.0,
+			testId:   "AccumulateBy_Nils NonEmpty Test 1",
+		},
+		{
+			asr:        NewAllocationSetRange(todayAS, nil),
+			resolution: time.Hour * 24,
+
+			expected: 6.0,
+			testId:   "AccumulateBy_Nils NonEmpty Test 2",
+		},
+		{
+			asr:        NewAllocationSetRange(yesterdayAS, nil, todayAS, nil),
+			resolution: time.Hour * 24 * 2,
+
+			expected: 12.0,
+			testId:   "AccumulateBy_Nils NonEmpty Test 3",
+		},
 	}
 	}
 
 
-	// test 2 nil sets 2 1d sets
-	result, err = NewAllocationSetRange(nil, NewAllocationSet(ago2d, yesterday), nil, NewAllocationSet(today, tomorrow), nil).AccumulateBy(duration2Days)
-	for _, as := range result.allocations {
-		if err != nil {
-			t.Fatalf("unexpected error accumulating nil AllocationSetRange: %s", err)
-		}
-		if !as.IsEmpty() {
-			t.Fatalf("accumulating nil AllocationSetRange: expected empty; actual %s", result)
+	for _, c := range nilAndNonEmptyCases {
+		result, err = c.asr.AccumulateBy(c.resolution)
+		sumCost := 0.0
+
+		if result == nil {
+			t.Errorf("accumulating AllocationSetRange: expected AllocationSet; actual %s; TestId: %s", result, c.testId)
 		}
 		}
-	}
 
 
-	// test 2 nil sets 2 1d sets
-	result, err = NewAllocationSetRange(nil, NewAllocationSet(ago2d, yesterday), nil, NewAllocationSet(today, tomorrow), nil).AccumulateBy(duration2Days)
-	for _, as := range result.allocations {
-		if err != nil {
-			t.Fatalf("unexpected error accumulating nil AllocationSetRange: %s", err)
+		for _, as := range result.allocations {
+			sumCost += as.TotalCost()
 		}
 		}
-		if !as.IsEmpty() {
-			t.Fatalf("accumulating nil AllocationSetRange: expected empty; actual %s", result)
+
+		if sumCost != c.expected {
+			t.Errorf("accumulating AllocationSetRange: expected total cost %f; actual %f; TestId: %s", c.expected, sumCost, c.testId)
 		}
 		}
 	}
 	}
 
 
+	if err != nil {
+		t.Errorf("unexpected error accumulating nil AllocationSetRange: %s", err)
+	}
+}
+
+func TestAllocationSetRange_AccumulateBy(t *testing.T) {
+	var err error
+	var result *AllocationSetRange
+
+	ago3d := time.Now().UTC().Truncate(day).Add(-3 * day)
+	ago2d := time.Now().UTC().Truncate(day).Add(-2 * day)
+	yesterday := time.Now().UTC().Truncate(day).Add(-day)
+	today := time.Now().UTC().Truncate(day)
+	tomorrow := time.Now().UTC().Truncate(day).Add(day)
+
 	ago3dAS := NewAllocationSet(ago3d, ago2d)
 	ago3dAS := NewAllocationSet(ago3d, ago2d)
 	ago3dAS.Set(NewMockUnitAllocation("a", ago3d, day, nil))
 	ago3dAS.Set(NewMockUnitAllocation("a", ago3d, day, nil))
 	ago2dAS := NewAllocationSet(ago2d, yesterday)
 	ago2dAS := NewAllocationSet(ago2d, yesterday)
@@ -2140,140 +2190,133 @@ func TestAllocationSetRange_AccumulateBy(t *testing.T) {
 	yesterdayAS.Set(NewMockUnitAllocation("", yesterday, day, nil))
 	yesterdayAS.Set(NewMockUnitAllocation("", yesterday, day, nil))
 	todayAS := NewAllocationSet(today, tomorrow)
 	todayAS := NewAllocationSet(today, tomorrow)
 	todayAS.Set(NewMockUnitAllocation("", today, day, nil))
 	todayAS.Set(NewMockUnitAllocation("", today, day, nil))
+
+	yesterHour := time.Now().UTC().Truncate(time.Hour).Add(-1 * time.Hour)
+	currentHour := time.Now().UTC().Truncate(time.Hour)
+	nextHour := time.Now().UTC().Truncate(time.Hour).Add(time.Hour)
+
+	yesterHourAS := NewAllocationSet(yesterHour, currentHour)
+	yesterHourAS.Set(NewMockUnitAllocation("123", yesterHour, time.Hour, nil))
+	currentHourAS := NewAllocationSet(currentHour, nextHour)
+	currentHourAS.Set(NewMockUnitAllocation("456", currentHour, time.Hour, nil))
+
 	sumCost := 0.0
 	sumCost := 0.0
 
 
-	// test 2 1d sets
-	result, err = NewAllocationSetRange(ago2dAS, yesterdayAS).AccumulateBy(duration2Days)
-	if err != nil {
-		t.Fatalf("unexpected error accumulating nil AllocationSetRange: %s", err)
-	}
-	if result == nil {
-		t.Fatalf("accumulating AllocationSetRange: expected AllocationSet; actual %s", result)
-	}
+	// Test nil & empty sets
+	cases := []struct {
+		asr        *AllocationSetRange
+		resolution time.Duration
 
 
-	for _, as := range result.allocations {
-		sumCost += as.TotalCost()
-	}
-	if sumCost != 12.0 {
-		t.Fatalf("accumulating AllocationSetRange: expected total cost 12.0; actual %f", sumCost)
-	}
+		expectedCost float64
+		expectedSets int
 
 
-	// test 3 1d sets
-	sumCost = 0.0
-	result, err = NewAllocationSetRange(ago2dAS, yesterdayAS, todayAS).AccumulateBy(duration2Days)
-	if err != nil {
-		t.Fatalf("unexpected error accumulating nil AllocationSetRange: %s", err)
-	}
-	if result == nil {
-		t.Fatalf("accumulating AllocationSetRange: expected AllocationSet; actual %s", result)
-	}
+		testId string
+	}{
+		{
+			asr:        NewAllocationSetRange(yesterdayAS, todayAS),
+			resolution: time.Hour * 24 * 2,
 
 
-	for _, as := range result.allocations {
-		sumCost += as.TotalCost()
-	}
-	if sumCost != 18.0 {
-		t.Fatalf("accumulating AllocationSetRange: expected total cost 18.0; actual %f", sumCost)
-	}
-	if result.allocations[0].Resolution() != duration2Days {
-		t.Fatalf("accumulating AllocationSetRange: expected first allocationSet window duration2Days to be %v; actual %v", duration2Days, result.allocations[0].Resolution())
-	}
-	if result.allocations[1].Resolution() != duration2Days/2 {
-		t.Fatalf("accumulating AllocationSetRange: expected second allocationSet window duration to be %v; actual %v", duration2Days, result.allocations[1].Resolution())
-	}
+			expectedCost: 12.0,
+			expectedSets: 1,
 
 
-	// test 3 1d sets - duration is larger than asr.window
-	sumCost = 0.0
-	result, err = NewAllocationSetRange(ago2dAS, yesterdayAS, todayAS).AccumulateBy(duration2Days * 2)
-	if err != nil {
-		t.Fatalf("unexpected error accumulating nil AllocationSetRange: %s", err)
-	}
-	if result == nil {
-		t.Fatalf("accumulating AllocationSetRange: expected AllocationSet; actual %s", result)
-	}
+			testId: "AccumulateBy Test 1",
+		},
+		{
+			asr:        NewAllocationSetRange(ago3dAS, ago2dAS),
+			resolution: time.Hour * 24,
 
 
-	for _, as := range result.allocations {
-		sumCost += as.TotalCost()
-	}
-	if sumCost != 18.0 {
-		t.Fatalf("accumulating AllocationSetRange: expected total cost 18.0; actual %f", sumCost)
-	}
+			expectedCost: 12.0,
+			expectedSets: 2,
 
 
-	// test 4 1d sets
-	sumCost = 0.0
-	result, err = NewAllocationSetRange(ago3dAS, ago2dAS, yesterdayAS, todayAS).AccumulateBy(duration2Days)
-	if err != nil {
-		t.Fatalf("unexpected error accumulating nil AllocationSetRange: %s", err)
-	}
-	if result == nil {
-		t.Fatalf("accumulating AllocationSetRange: expected AllocationSet; actual %s", result)
-	}
+			testId: "AccumulateBy Test 2",
+		},
+		{
+			asr:        NewAllocationSetRange(ago2dAS, yesterdayAS, todayAS),
+			resolution: time.Hour * 13,
 
 
-	for _, as := range result.allocations {
-		sumCost += as.TotalCost()
-	}
-	if sumCost != 24.0 {
-		t.Fatalf("accumulating AllocationSetRange: expected total cost 24.0; actual %f", sumCost)
-	}
-	if result.allocations[0].Resolution() != duration2Days {
-		t.Fatalf("accumulating AllocationSetRange: expected first allocationSet window duration2Days to be %v; actual %v", duration2Days, result.allocations[0].Resolution())
+			expectedCost: 18.0,
+			expectedSets: 3,
 
 
-	}
-	if result.allocations[1].Resolution() != duration2Days {
-		t.Fatalf("accumulating AllocationSetRange: expected first allocationSet window duration2Days to be %v; actual %v", duration2Days, result.allocations[1].Resolution())
-	}
+			testId: "AccumulateBy Test 3",
+		},
+		{
+			asr:        NewAllocationSetRange(ago2dAS, yesterdayAS, todayAS),
+			resolution: time.Hour * 24 * 7,
 
 
-	// Accumulate non-nil with nil should result in copy of non-nil, regardless of order
-	result, err = NewAllocationSetRange(nil, todayAS).AccumulateBy(duration2Days)
-	if err != nil {
-		t.Fatalf("unexpected error accumulating AllocationSetRange of length 1: %s", err)
-	}
-	if result == nil {
-		t.Fatalf("accumulating AllocationSetRange: expected AllocationSet; actual %s", result)
+			expectedCost: 18.0,
+			expectedSets: 1,
+
+			testId: "AccumulateBy Test 4",
+		},
+		{
+			asr:        NewAllocationSetRange(yesterHourAS, currentHourAS),
+			resolution: time.Hour * 2,
+
+			//Due to how mock Allocation Sets are generated, hourly sets are still 6.0 cost per set
+			expectedCost: 12.0,
+			expectedSets: 1,
+
+			testId: "AccumulateBy Test 5",
+		},
+		{
+			asr:        NewAllocationSetRange(yesterHourAS, currentHourAS),
+			resolution: time.Hour,
+
+			expectedCost: 12.0,
+			expectedSets: 2,
+
+			testId: "AccumulateBy Test 6",
+		},
+		{
+			asr:        NewAllocationSetRange(yesterHourAS, currentHourAS),
+			resolution: time.Minute * 11,
+
+			expectedCost: 12.0,
+			expectedSets: 2,
+
+			testId: "AccumulateBy Test 7",
+		},
+		{
+			asr:        NewAllocationSetRange(yesterHourAS, currentHourAS),
+			resolution: time.Hour * 3,
+
+			expectedCost: 12.0,
+			expectedSets: 1,
+
+			testId: "AccumulateBy Test 8",
+		},
 	}
 	}
 
 
-	for _, as := range result.allocations {
-		if as.TotalCost() != 6.0 {
-			t.Fatalf("accumulating AllocationSetRange: expected total cost 6.0; actual %f", as.TotalCost())
+	for _, c := range cases {
+		result, err = c.asr.AccumulateBy(c.resolution)
+		sumCost := 0.0
+
+		if result == nil {
+			t.Errorf("accumulating AllocationSetRange: expected AllocationSet; actual %s; TestId: %s", result, c.testId)
+		}
+		if result.Length() != c.expectedSets {
+			t.Errorf("accumulating AllocationSetRange: expected %v number of allocation sets; actual %v; TestId: %s", c.expectedSets, result.Length(), c.testId)
 		}
 		}
-	}
 
 
-	result, err = NewAllocationSetRange(todayAS, nil).AccumulateBy(duration2Days)
-	if err != nil {
-		t.Fatalf("unexpected error accumulating AllocationSetRange of length 1: %s", err)
-	}
-	if result == nil {
-		t.Fatalf("accumulating AllocationSetRange: expected AllocationSet; actual %s", result)
-	}
-	sumCost = 0.0
-	for _, as := range result.allocations {
-		sumCost += as.TotalCost()
-	}
-	if sumCost != 6.0 {
-		t.Fatalf("accumulating AllocationSetRange: expected total cost 6.0; actual %f", sumCost)
+		for _, as := range result.allocations {
+			sumCost += as.TotalCost()
+		}
+		if sumCost != c.expectedCost {
+			t.Errorf("accumulating AllocationSetRange: expected total cost %f; actual %f; TestId: %s", c.expectedCost, sumCost, c.testId)
+		}
 	}
 	}
 
 
-	result, err = NewAllocationSetRange(nil, todayAS, nil).AccumulateBy(duration2Days)
 	if err != nil {
 	if err != nil {
-		t.Fatalf("unexpected error accumulating AllocationSetRange of length 1: %s", err)
-	}
-	if result == nil {
-		t.Fatalf("accumulating AllocationSetRange: expected AllocationSet; actual %s", result)
-	}
-	sumCost = 0.0
-	for _, as := range result.allocations {
-		sumCost += as.TotalCost()
-	}
-	if sumCost != 6.0 {
-		t.Fatalf("accumulating AllocationSetRange: expected total cost 6.0; actual %f", sumCost)
+		t.Errorf("unexpected error accumulating nil AllocationSetRange: %s", err)
 	}
 	}
 
 
 	// // Accumulate three non-nil should result in sum of both with appropriate start, end
 	// // Accumulate three non-nil should result in sum of both with appropriate start, end
-	result, err = NewAllocationSetRange(ago2dAS, yesterdayAS, todayAS).AccumulateBy(duration2Days)
+	result, err = NewAllocationSetRange(ago2dAS, yesterdayAS, todayAS).AccumulateBy(time.Hour * 24 * 2)
 	if err != nil {
 	if err != nil {
-		t.Fatalf("unexpected error accumulating AllocationSetRange of length 1: %s", err)
+		t.Errorf("unexpected error accumulating AllocationSetRange of length 1: %s", err)
 	}
 	}
 	if result == nil {
 	if result == nil {
-		t.Fatalf("accumulating AllocationSetRange: expected AllocationSet; actual %s", result)
+		t.Errorf("accumulating AllocationSetRange: expected AllocationSet; actual %s", result)
 	}
 	}
 
 
 	sumCost = 0.0
 	sumCost = 0.0
@@ -2283,62 +2326,62 @@ func TestAllocationSetRange_AccumulateBy(t *testing.T) {
 
 
 	allocMap := result.allocations[0].Map()
 	allocMap := result.allocations[0].Map()
 	if len(allocMap) != 1 {
 	if len(allocMap) != 1 {
-		t.Fatalf("accumulating AllocationSetRange: expected length 1; actual length %d", len(allocMap))
+		t.Errorf("accumulating AllocationSetRange: expected length 1; actual length %d", len(allocMap))
 	}
 	}
 	alloc := allocMap["cluster1/namespace1/pod1/container1"]
 	alloc := allocMap["cluster1/namespace1/pod1/container1"]
 	if alloc == nil {
 	if alloc == nil {
 		t.Fatalf("accumulating AllocationSetRange: expected allocation 'cluster1/namespace1/pod1/container1'")
 		t.Fatalf("accumulating AllocationSetRange: expected allocation 'cluster1/namespace1/pod1/container1'")
 	}
 	}
 	if alloc.CPUCoreHours != 2.0 {
 	if alloc.CPUCoreHours != 2.0 {
-		t.Fatalf("accumulating AllocationSetRange: expected 2.0; actual %f", sumCost)
+		t.Errorf("accumulating AllocationSetRange: expected 2.0; actual %f", sumCost)
 	}
 	}
 	if alloc.CPUCost != 2.0 {
 	if alloc.CPUCost != 2.0 {
-		t.Fatalf("accumulating AllocationSetRange: expected 2.0; actual %f", alloc.CPUCost)
+		t.Errorf("accumulating AllocationSetRange: expected 2.0; actual %f", alloc.CPUCost)
 	}
 	}
 	if alloc.CPUEfficiency() != 1.0 {
 	if alloc.CPUEfficiency() != 1.0 {
-		t.Fatalf("accumulating AllocationSetRange: expected 1.0; actual %f", alloc.CPUEfficiency())
+		t.Errorf("accumulating AllocationSetRange: expected 1.0; actual %f", alloc.CPUEfficiency())
 	}
 	}
 	if alloc.GPUHours != 2.0 {
 	if alloc.GPUHours != 2.0 {
-		t.Fatalf("accumulating AllocationSetRange: expected 2.0; actual %f", alloc.GPUHours)
+		t.Errorf("accumulating AllocationSetRange: expected 2.0; actual %f", alloc.GPUHours)
 	}
 	}
 	if alloc.GPUCost != 2.0 {
 	if alloc.GPUCost != 2.0 {
-		t.Fatalf("accumulating AllocationSetRange: expected 2.0; actual %f", alloc.GPUCost)
+		t.Errorf("accumulating AllocationSetRange: expected 2.0; actual %f", alloc.GPUCost)
 	}
 	}
 	if alloc.NetworkCost != 2.0 {
 	if alloc.NetworkCost != 2.0 {
-		t.Fatalf("accumulating AllocationSetRange: expected 2.0; actual %f", alloc.NetworkCost)
+		t.Errorf("accumulating AllocationSetRange: expected 2.0; actual %f", alloc.NetworkCost)
 	}
 	}
 	if alloc.LoadBalancerCost != 2.0 {
 	if alloc.LoadBalancerCost != 2.0 {
-		t.Fatalf("accumulating AllocationSetRange: expected 2.0; actual %f", alloc.LoadBalancerCost)
+		t.Errorf("accumulating AllocationSetRange: expected 2.0; actual %f", alloc.LoadBalancerCost)
 	}
 	}
 	if alloc.PVByteHours() != 2.0 {
 	if alloc.PVByteHours() != 2.0 {
-		t.Fatalf("accumulating AllocationSetRange: expected 2.0; actual %f", alloc.PVByteHours())
+		t.Errorf("accumulating AllocationSetRange: expected 2.0; actual %f", alloc.PVByteHours())
 	}
 	}
 	if alloc.PVCost() != 2.0 {
 	if alloc.PVCost() != 2.0 {
-		t.Fatalf("accumulating AllocationSetRange: expected 2.0; actual %f", alloc.PVCost())
+		t.Errorf("accumulating AllocationSetRange: expected 2.0; actual %f", alloc.PVCost())
 	}
 	}
 	if alloc.RAMByteHours != 2.0 {
 	if alloc.RAMByteHours != 2.0 {
-		t.Fatalf("accumulating AllocationSetRange: expected 2.0; actual %f", alloc.RAMByteHours)
+		t.Errorf("accumulating AllocationSetRange: expected 2.0; actual %f", alloc.RAMByteHours)
 	}
 	}
 	if alloc.RAMCost != 2.0 {
 	if alloc.RAMCost != 2.0 {
-		t.Fatalf("accumulating AllocationSetRange: expected 2.0; actual %f", alloc.RAMCost)
+		t.Errorf("accumulating AllocationSetRange: expected 2.0; actual %f", alloc.RAMCost)
 	}
 	}
 	if alloc.RAMEfficiency() != 1.0 {
 	if alloc.RAMEfficiency() != 1.0 {
-		t.Fatalf("accumulating AllocationSetRange: expected 1.0; actual %f", alloc.RAMEfficiency())
+		t.Errorf("accumulating AllocationSetRange: expected 1.0; actual %f", alloc.RAMEfficiency())
 	}
 	}
 	if alloc.TotalCost() != 12.0 {
 	if alloc.TotalCost() != 12.0 {
-		t.Fatalf("accumulating AllocationSetRange: expected 12.0; actual %f", alloc.TotalCost())
+		t.Errorf("accumulating AllocationSetRange: expected 12.0; actual %f", alloc.TotalCost())
 	}
 	}
 	if alloc.TotalEfficiency() != 1.0 {
 	if alloc.TotalEfficiency() != 1.0 {
-		t.Fatalf("accumulating AllocationSetRange: expected 1.0; actual %f", alloc.TotalEfficiency())
+		t.Errorf("accumulating AllocationSetRange: expected 1.0; actual %f", alloc.TotalEfficiency())
 	}
 	}
 	if !alloc.Start.Equal(ago2d) {
 	if !alloc.Start.Equal(ago2d) {
-		t.Fatalf("accumulating AllocationSetRange: expected to start %s; actual %s", ago2d, alloc.Start)
+		t.Errorf("accumulating AllocationSetRange: expected to start %s; actual %s", ago2d, alloc.Start)
 	}
 	}
 	if !alloc.End.Equal(today) {
 	if !alloc.End.Equal(today) {
-		t.Fatalf("accumulating AllocationSetRange: expected to end %s; actual %s", today, alloc.End)
+		t.Errorf("accumulating AllocationSetRange: expected to end %s; actual %s", today, alloc.End)
 	}
 	}
 	if alloc.Minutes() != 2880.0 {
 	if alloc.Minutes() != 2880.0 {
-		t.Fatalf("accumulating AllocationSetRange: expected %f minutes; actual %f", 2880.0, alloc.Minutes())
+		t.Errorf("accumulating AllocationSetRange: expected %f minutes; actual %f", 2880.0, alloc.Minutes())
 	}
 	}
 }
 }