diff --git a/storage/influxdb/influxdb.go b/storage/influxdb/influxdb.go index cb25a20e..1fcb170f 100644 --- a/storage/influxdb/influxdb.go +++ b/storage/influxdb/influxdb.go @@ -420,7 +420,7 @@ func (self *influxdbStorage) Percentiles( if err != nil { return nil, fmt.Errorf("invalid max memory usage: %v", err) } - retrievedCpuPercentiles := point[2:] + retrievedCpuPercentiles := point[2 : 2+len(cpuUsagePercentiles)] for i, p := range cpuUsagePercentiles { v, err := convertToUint64(retrievedCpuPercentiles[i]) if err != nil { diff --git a/storage/influxdb/influxdb_test.go b/storage/influxdb/influxdb_test.go index fb8a8b42..c5770d35 100644 --- a/storage/influxdb/influxdb_test.go +++ b/storage/influxdb/influxdb_test.go @@ -62,7 +62,7 @@ func runStorageTest(f func(storage.StorageDriver, *testing.T), t *testing.T) { t.Fatal(err) } // delete all data by the end of the call - // defer client.Query(deleteAll) + defer client.Query(deleteAll) driver, err := New(machineName, tablename, diff --git a/storage/test/storagetests.go b/storage/test/storagetests.go index c18ceede..99912032 100644 --- a/storage/test/storagetests.go +++ b/storage/test/storagetests.go @@ -59,7 +59,7 @@ func timeEq(t1, t2 time.Time, tolerance time.Duration) bool { t1, t2 = t2, t1 } diff := t2.Sub(t1) - if diff < tolerance { + if diff <= tolerance { return true } return false @@ -70,7 +70,7 @@ func durationEq(a, b time.Duration, tolerance time.Duration) bool { a, b = b, a } diff := a - b - if diff < tolerance { + if diff <= tolerance { return true } return false @@ -78,7 +78,7 @@ func durationEq(a, b time.Duration, tolerance time.Duration) bool { const ( // 10ms, i.e. 0.01s - timePrecision time.Duration = 10000000 + timePrecision time.Duration = 10 * time.Millisecond ) // This function is useful because we do not require precise time