2013-02-08 09:03:26 -08:00
|
|
|
// Copyright 2013 Prometheus Team
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package metric
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2013-03-13 16:27:14 -07:00
|
|
|
func TestGetValuesAtTimeOp(t *testing.T) {
|
|
|
|
var scenarios = []struct {
|
|
|
|
op getValuesAtTimeOp
|
2013-06-25 05:02:27 -07:00
|
|
|
in Values
|
|
|
|
out Values
|
2013-03-13 16:27:14 -07:00
|
|
|
}{
|
|
|
|
// No values.
|
|
|
|
{
|
|
|
|
op: getValuesAtTimeOp{
|
Remove the multi-op-per-fingerprint capability.
Currently, rendering a view is capable of handling multiple ops for
the same fingerprint efficiently. However, this capability requires a
lot of complexity in the code, which we are not using at all because
the way we assemble a viewRequest will never have more than one
operation per fingerprint.
This commit weeds out the said capability, along with all the code
needed for it. It is still possible to have more than one operation
for the same fingerprint, it will just be handled in a less efficient
way (as proven by the unit tests).
As a result, scanjob.go could be removed entirely.
This commit also contains a few related refactorings and removals of
dead code in operation.go, view,go, and freelist.go. Also, the
docstrings received some love.
Change-Id: I032b976e0880151c3f3fdb3234fb65e484f0e2e5
2014-02-27 11:09:00 -08:00
|
|
|
baseOp: baseOp{current: testInstant},
|
2013-03-13 16:27:14 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
// Operator time before single value.
|
|
|
|
{
|
|
|
|
op: getValuesAtTimeOp{
|
Remove the multi-op-per-fingerprint capability.
Currently, rendering a view is capable of handling multiple ops for
the same fingerprint efficiently. However, this capability requires a
lot of complexity in the code, which we are not using at all because
the way we assemble a viewRequest will never have more than one
operation per fingerprint.
This commit weeds out the said capability, along with all the code
needed for it. It is still possible to have more than one operation
for the same fingerprint, it will just be handled in a less efficient
way (as proven by the unit tests).
As a result, scanjob.go could be removed entirely.
This commit also contains a few related refactorings and removals of
dead code in operation.go, view,go, and freelist.go. Also, the
docstrings received some love.
Change-Id: I032b976e0880151c3f3fdb3234fb65e484f0e2e5
2014-02-27 11:09:00 -08:00
|
|
|
baseOp: baseOp{current: testInstant},
|
2013-03-13 16:27:14 -07:00
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
in: Values{
|
2013-03-13 16:27:14 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(1 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
out: Values{
|
2013-03-13 16:27:14 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(1 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// Operator time exactly at single value.
|
|
|
|
{
|
|
|
|
op: getValuesAtTimeOp{
|
Remove the multi-op-per-fingerprint capability.
Currently, rendering a view is capable of handling multiple ops for
the same fingerprint efficiently. However, this capability requires a
lot of complexity in the code, which we are not using at all because
the way we assemble a viewRequest will never have more than one
operation per fingerprint.
This commit weeds out the said capability, along with all the code
needed for it. It is still possible to have more than one operation
for the same fingerprint, it will just be handled in a less efficient
way (as proven by the unit tests).
As a result, scanjob.go could be removed entirely.
This commit also contains a few related refactorings and removals of
dead code in operation.go, view,go, and freelist.go. Also, the
docstrings received some love.
Change-Id: I032b976e0880151c3f3fdb3234fb65e484f0e2e5
2014-02-27 11:09:00 -08:00
|
|
|
baseOp: baseOp{current: testInstant.Add(1 * time.Minute)},
|
2013-03-13 16:27:14 -07:00
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
in: Values{
|
2013-03-13 16:27:14 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(1 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
out: Values{
|
2013-03-13 16:27:14 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(1 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// Operator time after single value.
|
|
|
|
{
|
|
|
|
op: getValuesAtTimeOp{
|
Remove the multi-op-per-fingerprint capability.
Currently, rendering a view is capable of handling multiple ops for
the same fingerprint efficiently. However, this capability requires a
lot of complexity in the code, which we are not using at all because
the way we assemble a viewRequest will never have more than one
operation per fingerprint.
This commit weeds out the said capability, along with all the code
needed for it. It is still possible to have more than one operation
for the same fingerprint, it will just be handled in a less efficient
way (as proven by the unit tests).
As a result, scanjob.go could be removed entirely.
This commit also contains a few related refactorings and removals of
dead code in operation.go, view,go, and freelist.go. Also, the
docstrings received some love.
Change-Id: I032b976e0880151c3f3fdb3234fb65e484f0e2e5
2014-02-27 11:09:00 -08:00
|
|
|
baseOp: baseOp{current: testInstant.Add(2 * time.Minute)},
|
2013-03-13 16:27:14 -07:00
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
in: Values{
|
2013-03-13 16:27:14 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(1 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
out: Values{
|
2013-03-13 16:27:14 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(1 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// Operator time before two values.
|
|
|
|
{
|
|
|
|
op: getValuesAtTimeOp{
|
Remove the multi-op-per-fingerprint capability.
Currently, rendering a view is capable of handling multiple ops for
the same fingerprint efficiently. However, this capability requires a
lot of complexity in the code, which we are not using at all because
the way we assemble a viewRequest will never have more than one
operation per fingerprint.
This commit weeds out the said capability, along with all the code
needed for it. It is still possible to have more than one operation
for the same fingerprint, it will just be handled in a less efficient
way (as proven by the unit tests).
As a result, scanjob.go could be removed entirely.
This commit also contains a few related refactorings and removals of
dead code in operation.go, view,go, and freelist.go. Also, the
docstrings received some love.
Change-Id: I032b976e0880151c3f3fdb3234fb65e484f0e2e5
2014-02-27 11:09:00 -08:00
|
|
|
baseOp: baseOp{current: testInstant},
|
2013-03-13 16:27:14 -07:00
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
in: Values{
|
2013-03-13 16:27:14 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(1 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(2 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
out: Values{
|
2013-03-13 16:27:14 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(1 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// Operator time at first of two values.
|
|
|
|
{
|
|
|
|
op: getValuesAtTimeOp{
|
Remove the multi-op-per-fingerprint capability.
Currently, rendering a view is capable of handling multiple ops for
the same fingerprint efficiently. However, this capability requires a
lot of complexity in the code, which we are not using at all because
the way we assemble a viewRequest will never have more than one
operation per fingerprint.
This commit weeds out the said capability, along with all the code
needed for it. It is still possible to have more than one operation
for the same fingerprint, it will just be handled in a less efficient
way (as proven by the unit tests).
As a result, scanjob.go could be removed entirely.
This commit also contains a few related refactorings and removals of
dead code in operation.go, view,go, and freelist.go. Also, the
docstrings received some love.
Change-Id: I032b976e0880151c3f3fdb3234fb65e484f0e2e5
2014-02-27 11:09:00 -08:00
|
|
|
baseOp: baseOp{current: testInstant.Add(1 * time.Minute)},
|
2013-03-13 16:27:14 -07:00
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
in: Values{
|
2013-03-13 16:27:14 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(1 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(2 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
out: Values{
|
2013-03-13 16:27:14 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(1 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// Operator time between first and second of two values.
|
|
|
|
{
|
|
|
|
op: getValuesAtTimeOp{
|
Remove the multi-op-per-fingerprint capability.
Currently, rendering a view is capable of handling multiple ops for
the same fingerprint efficiently. However, this capability requires a
lot of complexity in the code, which we are not using at all because
the way we assemble a viewRequest will never have more than one
operation per fingerprint.
This commit weeds out the said capability, along with all the code
needed for it. It is still possible to have more than one operation
for the same fingerprint, it will just be handled in a less efficient
way (as proven by the unit tests).
As a result, scanjob.go could be removed entirely.
This commit also contains a few related refactorings and removals of
dead code in operation.go, view,go, and freelist.go. Also, the
docstrings received some love.
Change-Id: I032b976e0880151c3f3fdb3234fb65e484f0e2e5
2014-02-27 11:09:00 -08:00
|
|
|
baseOp: baseOp{current: testInstant.Add(90 * time.Second)},
|
2013-03-13 16:27:14 -07:00
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
in: Values{
|
2013-03-13 16:27:14 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(1 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(2 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
out: Values{
|
2013-03-13 16:27:14 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(1 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(2 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// Operator time at second of two values.
|
|
|
|
{
|
|
|
|
op: getValuesAtTimeOp{
|
Remove the multi-op-per-fingerprint capability.
Currently, rendering a view is capable of handling multiple ops for
the same fingerprint efficiently. However, this capability requires a
lot of complexity in the code, which we are not using at all because
the way we assemble a viewRequest will never have more than one
operation per fingerprint.
This commit weeds out the said capability, along with all the code
needed for it. It is still possible to have more than one operation
for the same fingerprint, it will just be handled in a less efficient
way (as proven by the unit tests).
As a result, scanjob.go could be removed entirely.
This commit also contains a few related refactorings and removals of
dead code in operation.go, view,go, and freelist.go. Also, the
docstrings received some love.
Change-Id: I032b976e0880151c3f3fdb3234fb65e484f0e2e5
2014-02-27 11:09:00 -08:00
|
|
|
baseOp: baseOp{current: testInstant.Add(2 * time.Minute)},
|
2013-03-13 16:27:14 -07:00
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
in: Values{
|
2013-03-13 16:27:14 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(1 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(2 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
out: Values{
|
2013-03-13 16:27:14 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(1 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(2 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// Operator time after second of two values.
|
|
|
|
{
|
|
|
|
op: getValuesAtTimeOp{
|
Remove the multi-op-per-fingerprint capability.
Currently, rendering a view is capable of handling multiple ops for
the same fingerprint efficiently. However, this capability requires a
lot of complexity in the code, which we are not using at all because
the way we assemble a viewRequest will never have more than one
operation per fingerprint.
This commit weeds out the said capability, along with all the code
needed for it. It is still possible to have more than one operation
for the same fingerprint, it will just be handled in a less efficient
way (as proven by the unit tests).
As a result, scanjob.go could be removed entirely.
This commit also contains a few related refactorings and removals of
dead code in operation.go, view,go, and freelist.go. Also, the
docstrings received some love.
Change-Id: I032b976e0880151c3f3fdb3234fb65e484f0e2e5
2014-02-27 11:09:00 -08:00
|
|
|
baseOp: baseOp{current: testInstant.Add(3 * time.Minute)},
|
2013-03-13 16:27:14 -07:00
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
in: Values{
|
2013-03-13 16:27:14 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(1 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(2 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
out: Values{
|
2013-03-13 16:27:14 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(2 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2013-06-25 05:02:27 -07:00
|
|
|
|
2013-03-13 16:27:14 -07:00
|
|
|
for i, scenario := range scenarios {
|
|
|
|
actual := scenario.op.ExtractSamples(scenario.in)
|
|
|
|
if len(actual) != len(scenario.out) {
|
|
|
|
t.Fatalf("%d. expected length %d, got %d: %v", i, len(scenario.out), len(actual), scenario.op)
|
|
|
|
t.Fatalf("%d. expected length %d, got %d", i, len(scenario.out), len(actual))
|
|
|
|
}
|
|
|
|
for j, out := range scenario.out {
|
2014-03-10 09:55:17 -07:00
|
|
|
if !out.Equal(&actual[j]) {
|
2013-03-14 14:51:29 -07:00
|
|
|
t.Fatalf("%d. expected output %v, got %v", i, scenario.out, actual)
|
2013-03-13 16:27:14 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestGetValuesAtIntervalOp(t *testing.T) {
|
|
|
|
var scenarios = []struct {
|
|
|
|
op getValuesAtIntervalOp
|
2013-06-25 05:02:27 -07:00
|
|
|
in Values
|
|
|
|
out Values
|
2013-03-13 16:27:14 -07:00
|
|
|
}{
|
|
|
|
// No values.
|
|
|
|
{
|
|
|
|
op: getValuesAtIntervalOp{
|
2014-03-10 07:04:42 -07:00
|
|
|
getValuesAlongRangeOp: getValuesAlongRangeOp{
|
|
|
|
baseOp: baseOp{current: testInstant},
|
|
|
|
through: testInstant.Add(1 * time.Minute),
|
|
|
|
},
|
2013-03-13 16:27:14 -07:00
|
|
|
interval: 30 * time.Second,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// Entire operator range before first value.
|
|
|
|
{
|
|
|
|
op: getValuesAtIntervalOp{
|
2014-03-10 07:04:42 -07:00
|
|
|
getValuesAlongRangeOp: getValuesAlongRangeOp{
|
|
|
|
baseOp: baseOp{current: testInstant},
|
|
|
|
through: testInstant.Add(1 * time.Minute),
|
|
|
|
},
|
2013-03-13 16:27:14 -07:00
|
|
|
interval: 30 * time.Second,
|
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
in: Values{
|
2013-03-13 16:27:14 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(2 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(3 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
out: Values{
|
2013-03-13 16:27:14 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(2 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// Operator range starts before first value, ends within available values.
|
|
|
|
{
|
|
|
|
op: getValuesAtIntervalOp{
|
2014-03-10 07:04:42 -07:00
|
|
|
getValuesAlongRangeOp: getValuesAlongRangeOp{
|
|
|
|
baseOp: baseOp{current: testInstant},
|
|
|
|
through: testInstant.Add(2 * time.Minute),
|
|
|
|
},
|
2013-03-13 16:27:14 -07:00
|
|
|
interval: 30 * time.Second,
|
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
in: Values{
|
2013-03-13 16:27:14 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(1 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(3 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
out: Values{
|
2013-03-13 16:27:14 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(1 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(3 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// Entire operator range is within available values.
|
|
|
|
{
|
|
|
|
op: getValuesAtIntervalOp{
|
2014-03-10 07:04:42 -07:00
|
|
|
getValuesAlongRangeOp: getValuesAlongRangeOp{
|
|
|
|
baseOp: baseOp{current: testInstant.Add(1 * time.Minute)},
|
|
|
|
through: testInstant.Add(2 * time.Minute),
|
|
|
|
},
|
2013-03-13 16:27:14 -07:00
|
|
|
interval: 30 * time.Second,
|
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
in: Values{
|
2013-03-13 16:27:14 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant,
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(1 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(3 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
out: Values{
|
2013-03-13 16:27:14 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(1 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(3 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// Operator range begins before first value, ends after last.
|
|
|
|
{
|
|
|
|
op: getValuesAtIntervalOp{
|
2014-03-10 07:04:42 -07:00
|
|
|
getValuesAlongRangeOp: getValuesAlongRangeOp{
|
|
|
|
baseOp: baseOp{current: testInstant},
|
|
|
|
through: testInstant.Add(3 * time.Minute),
|
|
|
|
},
|
2013-03-13 16:27:14 -07:00
|
|
|
interval: 30 * time.Second,
|
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
in: Values{
|
2013-03-13 16:27:14 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(1 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(2 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
out: Values{
|
2013-03-13 16:27:14 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(1 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(2 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// Operator range begins within available values, ends after the last value.
|
|
|
|
{
|
|
|
|
op: getValuesAtIntervalOp{
|
2014-03-10 07:04:42 -07:00
|
|
|
getValuesAlongRangeOp: getValuesAlongRangeOp{
|
|
|
|
baseOp: baseOp{current: testInstant.Add(2 * time.Minute)},
|
|
|
|
through: testInstant.Add(4 * time.Minute),
|
|
|
|
},
|
2013-03-13 16:27:14 -07:00
|
|
|
interval: 30 * time.Second,
|
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
in: Values{
|
2013-03-13 16:27:14 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant,
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(1 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(2 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(3 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
out: Values{
|
2013-03-13 16:27:14 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(2 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(3 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// Entire operator range after the last available value.
|
|
|
|
{
|
|
|
|
op: getValuesAtIntervalOp{
|
2014-03-10 07:04:42 -07:00
|
|
|
getValuesAlongRangeOp: getValuesAlongRangeOp{
|
|
|
|
baseOp: baseOp{current: testInstant.Add(2 * time.Minute)},
|
|
|
|
through: testInstant.Add(3 * time.Minute),
|
|
|
|
},
|
2013-03-13 16:27:14 -07:00
|
|
|
interval: 30 * time.Second,
|
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
in: Values{
|
2013-03-13 16:27:14 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant,
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(1 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
out: Values{
|
2013-03-13 16:27:14 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(1 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2013-05-13 09:14:14 -07:00
|
|
|
// Operator interval skips over several values and ends past the last
|
|
|
|
// available value. This is to verify that we still include the last value
|
|
|
|
// of a series even if we target a time past it and haven't extracted that
|
|
|
|
// value yet as part of a previous interval step (thus the necessity to
|
|
|
|
// skip over values for the test).
|
|
|
|
{
|
|
|
|
op: getValuesAtIntervalOp{
|
2014-03-10 07:04:42 -07:00
|
|
|
getValuesAlongRangeOp: getValuesAlongRangeOp{
|
|
|
|
baseOp: baseOp{current: testInstant.Add(30 * time.Second)},
|
|
|
|
through: testInstant.Add(4 * time.Minute),
|
|
|
|
},
|
2013-05-13 09:14:14 -07:00
|
|
|
interval: 3 * time.Minute,
|
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
in: Values{
|
2013-05-13 09:14:14 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant,
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(1 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(2 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(3 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
out: Values{
|
2013-05-13 09:14:14 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant,
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(1 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(3 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2013-03-13 16:27:14 -07:00
|
|
|
}
|
|
|
|
for i, scenario := range scenarios {
|
|
|
|
actual := scenario.op.ExtractSamples(scenario.in)
|
|
|
|
if len(actual) != len(scenario.out) {
|
2013-05-07 05:25:01 -07:00
|
|
|
t.Fatalf("%d. expected length %d, got %d: %v", i, len(scenario.out), len(actual), actual)
|
2013-03-13 16:27:14 -07:00
|
|
|
}
|
2013-05-21 15:53:25 -07:00
|
|
|
|
|
|
|
if len(scenario.in) < 1 {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
lastExtractedTime := scenario.out[len(scenario.out)-1].Timestamp
|
2013-05-07 05:25:01 -07:00
|
|
|
if !scenario.op.Consumed() && scenario.op.CurrentTime().Before(lastExtractedTime) {
|
|
|
|
t.Fatalf("%d. expected op to be consumed or with CurrentTime() after current chunk, %v, %v", i, scenario.op.CurrentTime(), scenario.out)
|
2013-05-21 15:53:25 -07:00
|
|
|
}
|
|
|
|
|
2013-03-13 16:27:14 -07:00
|
|
|
for j, out := range scenario.out {
|
2014-03-10 09:55:17 -07:00
|
|
|
if !out.Equal(&actual[j]) {
|
2013-03-14 14:51:29 -07:00
|
|
|
t.Fatalf("%d. expected output %v, got %v", i, scenario.out, actual)
|
2013-03-13 16:27:14 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-03-13 23:22:59 -07:00
|
|
|
|
|
|
|
func TestGetValuesAlongRangeOp(t *testing.T) {
|
|
|
|
var scenarios = []struct {
|
|
|
|
op getValuesAlongRangeOp
|
2013-06-25 05:02:27 -07:00
|
|
|
in Values
|
|
|
|
out Values
|
2013-03-13 23:22:59 -07:00
|
|
|
}{
|
|
|
|
// No values.
|
|
|
|
{
|
|
|
|
op: getValuesAlongRangeOp{
|
Remove the multi-op-per-fingerprint capability.
Currently, rendering a view is capable of handling multiple ops for
the same fingerprint efficiently. However, this capability requires a
lot of complexity in the code, which we are not using at all because
the way we assemble a viewRequest will never have more than one
operation per fingerprint.
This commit weeds out the said capability, along with all the code
needed for it. It is still possible to have more than one operation
for the same fingerprint, it will just be handled in a less efficient
way (as proven by the unit tests).
As a result, scanjob.go could be removed entirely.
This commit also contains a few related refactorings and removals of
dead code in operation.go, view,go, and freelist.go. Also, the
docstrings received some love.
Change-Id: I032b976e0880151c3f3fdb3234fb65e484f0e2e5
2014-02-27 11:09:00 -08:00
|
|
|
baseOp: baseOp{current: testInstant},
|
2013-03-14 14:27:51 -07:00
|
|
|
through: testInstant.Add(1 * time.Minute),
|
2013-03-13 23:22:59 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
// Entire operator range before first value.
|
|
|
|
{
|
|
|
|
op: getValuesAlongRangeOp{
|
Remove the multi-op-per-fingerprint capability.
Currently, rendering a view is capable of handling multiple ops for
the same fingerprint efficiently. However, this capability requires a
lot of complexity in the code, which we are not using at all because
the way we assemble a viewRequest will never have more than one
operation per fingerprint.
This commit weeds out the said capability, along with all the code
needed for it. It is still possible to have more than one operation
for the same fingerprint, it will just be handled in a less efficient
way (as proven by the unit tests).
As a result, scanjob.go could be removed entirely.
This commit also contains a few related refactorings and removals of
dead code in operation.go, view,go, and freelist.go. Also, the
docstrings received some love.
Change-Id: I032b976e0880151c3f3fdb3234fb65e484f0e2e5
2014-02-27 11:09:00 -08:00
|
|
|
baseOp: baseOp{current: testInstant},
|
2013-03-14 14:27:51 -07:00
|
|
|
through: testInstant.Add(1 * time.Minute),
|
2013-03-13 23:22:59 -07:00
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
in: Values{
|
2013-03-13 23:22:59 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(2 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(3 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
out: Values{},
|
2013-03-13 23:22:59 -07:00
|
|
|
},
|
|
|
|
// Operator range starts before first value, ends within available values.
|
|
|
|
{
|
|
|
|
op: getValuesAlongRangeOp{
|
Remove the multi-op-per-fingerprint capability.
Currently, rendering a view is capable of handling multiple ops for
the same fingerprint efficiently. However, this capability requires a
lot of complexity in the code, which we are not using at all because
the way we assemble a viewRequest will never have more than one
operation per fingerprint.
This commit weeds out the said capability, along with all the code
needed for it. It is still possible to have more than one operation
for the same fingerprint, it will just be handled in a less efficient
way (as proven by the unit tests).
As a result, scanjob.go could be removed entirely.
This commit also contains a few related refactorings and removals of
dead code in operation.go, view,go, and freelist.go. Also, the
docstrings received some love.
Change-Id: I032b976e0880151c3f3fdb3234fb65e484f0e2e5
2014-02-27 11:09:00 -08:00
|
|
|
baseOp: baseOp{current: testInstant},
|
2013-03-14 14:27:51 -07:00
|
|
|
through: testInstant.Add(2 * time.Minute),
|
2013-03-13 23:22:59 -07:00
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
in: Values{
|
2013-03-13 23:22:59 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(1 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(3 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
out: Values{
|
2013-03-13 23:22:59 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(1 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// Entire operator range is within available values.
|
|
|
|
{
|
|
|
|
op: getValuesAlongRangeOp{
|
Remove the multi-op-per-fingerprint capability.
Currently, rendering a view is capable of handling multiple ops for
the same fingerprint efficiently. However, this capability requires a
lot of complexity in the code, which we are not using at all because
the way we assemble a viewRequest will never have more than one
operation per fingerprint.
This commit weeds out the said capability, along with all the code
needed for it. It is still possible to have more than one operation
for the same fingerprint, it will just be handled in a less efficient
way (as proven by the unit tests).
As a result, scanjob.go could be removed entirely.
This commit also contains a few related refactorings and removals of
dead code in operation.go, view,go, and freelist.go. Also, the
docstrings received some love.
Change-Id: I032b976e0880151c3f3fdb3234fb65e484f0e2e5
2014-02-27 11:09:00 -08:00
|
|
|
baseOp: baseOp{current: testInstant.Add(1 * time.Minute)},
|
2013-03-14 14:27:51 -07:00
|
|
|
through: testInstant.Add(2 * time.Minute),
|
2013-03-13 23:22:59 -07:00
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
in: Values{
|
2013-03-13 23:22:59 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant,
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(1 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(3 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
out: Values{
|
2013-03-13 23:22:59 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(1 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// Operator range begins before first value, ends after last.
|
|
|
|
{
|
|
|
|
op: getValuesAlongRangeOp{
|
Remove the multi-op-per-fingerprint capability.
Currently, rendering a view is capable of handling multiple ops for
the same fingerprint efficiently. However, this capability requires a
lot of complexity in the code, which we are not using at all because
the way we assemble a viewRequest will never have more than one
operation per fingerprint.
This commit weeds out the said capability, along with all the code
needed for it. It is still possible to have more than one operation
for the same fingerprint, it will just be handled in a less efficient
way (as proven by the unit tests).
As a result, scanjob.go could be removed entirely.
This commit also contains a few related refactorings and removals of
dead code in operation.go, view,go, and freelist.go. Also, the
docstrings received some love.
Change-Id: I032b976e0880151c3f3fdb3234fb65e484f0e2e5
2014-02-27 11:09:00 -08:00
|
|
|
baseOp: baseOp{current: testInstant},
|
2013-03-14 14:27:51 -07:00
|
|
|
through: testInstant.Add(3 * time.Minute),
|
2013-03-13 23:22:59 -07:00
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
in: Values{
|
2013-03-13 23:22:59 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(1 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(2 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
out: Values{
|
2013-03-13 23:22:59 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(1 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(2 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// Operator range begins within available values, ends after the last value.
|
|
|
|
{
|
|
|
|
op: getValuesAlongRangeOp{
|
Remove the multi-op-per-fingerprint capability.
Currently, rendering a view is capable of handling multiple ops for
the same fingerprint efficiently. However, this capability requires a
lot of complexity in the code, which we are not using at all because
the way we assemble a viewRequest will never have more than one
operation per fingerprint.
This commit weeds out the said capability, along with all the code
needed for it. It is still possible to have more than one operation
for the same fingerprint, it will just be handled in a less efficient
way (as proven by the unit tests).
As a result, scanjob.go could be removed entirely.
This commit also contains a few related refactorings and removals of
dead code in operation.go, view,go, and freelist.go. Also, the
docstrings received some love.
Change-Id: I032b976e0880151c3f3fdb3234fb65e484f0e2e5
2014-02-27 11:09:00 -08:00
|
|
|
baseOp: baseOp{current: testInstant.Add(2 * time.Minute)},
|
2013-03-14 14:27:51 -07:00
|
|
|
through: testInstant.Add(4 * time.Minute),
|
2013-03-13 23:22:59 -07:00
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
in: Values{
|
2013-03-13 23:22:59 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant,
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(1 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(2 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(3 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
out: Values{
|
2013-03-13 23:22:59 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(2 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(3 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// Entire operator range after the last available value.
|
|
|
|
{
|
|
|
|
op: getValuesAlongRangeOp{
|
Remove the multi-op-per-fingerprint capability.
Currently, rendering a view is capable of handling multiple ops for
the same fingerprint efficiently. However, this capability requires a
lot of complexity in the code, which we are not using at all because
the way we assemble a viewRequest will never have more than one
operation per fingerprint.
This commit weeds out the said capability, along with all the code
needed for it. It is still possible to have more than one operation
for the same fingerprint, it will just be handled in a less efficient
way (as proven by the unit tests).
As a result, scanjob.go could be removed entirely.
This commit also contains a few related refactorings and removals of
dead code in operation.go, view,go, and freelist.go. Also, the
docstrings received some love.
Change-Id: I032b976e0880151c3f3fdb3234fb65e484f0e2e5
2014-02-27 11:09:00 -08:00
|
|
|
baseOp: baseOp{current: testInstant.Add(2 * time.Minute)},
|
2013-03-14 14:27:51 -07:00
|
|
|
through: testInstant.Add(3 * time.Minute),
|
2013-03-13 23:22:59 -07:00
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
in: Values{
|
2013-03-13 23:22:59 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant,
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(1 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
},
|
2013-06-25 05:02:27 -07:00
|
|
|
out: Values{},
|
2013-03-13 23:22:59 -07:00
|
|
|
},
|
|
|
|
}
|
|
|
|
for i, scenario := range scenarios {
|
|
|
|
actual := scenario.op.ExtractSamples(scenario.in)
|
|
|
|
if len(actual) != len(scenario.out) {
|
2013-05-07 05:25:01 -07:00
|
|
|
t.Fatalf("%d. expected length %d, got %d: %v", i, len(scenario.out), len(actual), actual)
|
|
|
|
}
|
|
|
|
for j, out := range scenario.out {
|
2014-03-10 09:55:17 -07:00
|
|
|
if !out.Equal(&actual[j]) {
|
2013-05-07 05:25:01 -07:00
|
|
|
t.Fatalf("%d. expected output %v, got %v", i, scenario.out, actual)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestGetValueRangeAtIntervalOp(t *testing.T) {
|
|
|
|
testOp := getValueRangeAtIntervalOp{
|
2014-03-10 07:04:42 -07:00
|
|
|
getValuesAtIntervalOp: getValuesAtIntervalOp{
|
|
|
|
getValuesAlongRangeOp: getValuesAlongRangeOp{
|
|
|
|
baseOp: baseOp{current: testInstant.Add(-2 * time.Minute)},
|
|
|
|
through: testInstant.Add(20 * time.Minute),
|
|
|
|
},
|
|
|
|
interval: 10 * time.Minute,
|
|
|
|
},
|
2013-05-07 05:25:01 -07:00
|
|
|
rangeThrough: testInstant,
|
|
|
|
rangeDuration: 2 * time.Minute,
|
|
|
|
}
|
|
|
|
|
|
|
|
var scenarios = []struct {
|
|
|
|
op getValueRangeAtIntervalOp
|
2013-07-15 06:11:41 -07:00
|
|
|
in Values
|
|
|
|
out Values
|
2013-05-07 05:25:01 -07:00
|
|
|
}{
|
|
|
|
// All values before the first range.
|
|
|
|
{
|
|
|
|
op: testOp,
|
2013-07-15 06:11:41 -07:00
|
|
|
in: Values{
|
2013-05-07 05:25:01 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(-4 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(-3 * time.Minute),
|
|
|
|
Value: 2,
|
|
|
|
},
|
|
|
|
},
|
2013-07-15 06:11:41 -07:00
|
|
|
out: Values{},
|
2013-05-07 05:25:01 -07:00
|
|
|
},
|
|
|
|
// Values starting before first range, ending after last.
|
|
|
|
{
|
|
|
|
op: testOp,
|
2013-07-15 06:11:41 -07:00
|
|
|
in: Values{
|
2013-05-07 05:25:01 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(-4 * time.Minute),
|
|
|
|
Value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(-3 * time.Minute),
|
|
|
|
Value: 2,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(-2 * time.Minute),
|
|
|
|
Value: 3,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(-1 * time.Minute),
|
|
|
|
Value: 4,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(0 * time.Minute),
|
|
|
|
Value: 5,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(5 * time.Minute),
|
|
|
|
Value: 6,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(8 * time.Minute),
|
|
|
|
Value: 7,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(9 * time.Minute),
|
|
|
|
Value: 8,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(10 * time.Minute),
|
|
|
|
Value: 9,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(15 * time.Minute),
|
|
|
|
Value: 10,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(18 * time.Minute),
|
|
|
|
Value: 11,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(19 * time.Minute),
|
|
|
|
Value: 12,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(20 * time.Minute),
|
|
|
|
Value: 13,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(21 * time.Minute),
|
|
|
|
Value: 14,
|
|
|
|
},
|
|
|
|
},
|
2013-07-15 06:11:41 -07:00
|
|
|
out: Values{
|
2013-05-07 05:25:01 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(-2 * time.Minute),
|
|
|
|
Value: 3,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(-1 * time.Minute),
|
|
|
|
Value: 4,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(0 * time.Minute),
|
|
|
|
Value: 5,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(8 * time.Minute),
|
|
|
|
Value: 7,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(9 * time.Minute),
|
|
|
|
Value: 8,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(10 * time.Minute),
|
|
|
|
Value: 9,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(18 * time.Minute),
|
|
|
|
Value: 11,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(19 * time.Minute),
|
|
|
|
Value: 12,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(20 * time.Minute),
|
|
|
|
Value: 13,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// Values starting after last range.
|
|
|
|
{
|
|
|
|
op: testOp,
|
2013-07-15 06:11:41 -07:00
|
|
|
in: Values{
|
2013-05-07 05:25:01 -07:00
|
|
|
{
|
|
|
|
Timestamp: testInstant.Add(21 * time.Minute),
|
|
|
|
Value: 14,
|
|
|
|
},
|
|
|
|
},
|
2013-07-15 06:11:41 -07:00
|
|
|
out: Values{},
|
2013-05-07 05:25:01 -07:00
|
|
|
},
|
|
|
|
}
|
|
|
|
for i, scenario := range scenarios {
|
2013-07-15 06:11:41 -07:00
|
|
|
actual := Values{}
|
2013-05-07 05:25:01 -07:00
|
|
|
for !scenario.op.Consumed() {
|
|
|
|
actual = append(actual, scenario.op.ExtractSamples(scenario.in)...)
|
|
|
|
}
|
|
|
|
if len(actual) != len(scenario.out) {
|
|
|
|
t.Fatalf("%d. expected length %d, got %d: %v", i, len(scenario.out), len(actual), actual)
|
2013-03-13 23:22:59 -07:00
|
|
|
}
|
|
|
|
for j, out := range scenario.out {
|
2014-03-10 09:55:17 -07:00
|
|
|
if !out.Equal(&actual[j]) {
|
2013-03-14 14:51:29 -07:00
|
|
|
t.Fatalf("%d. expected output %v, got %v", i, scenario.out, actual)
|
2013-03-13 23:22:59 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|