-
Notifications
You must be signed in to change notification settings - Fork 455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[query] Fix graphite functions, aggregation bug #2549
Merged
Merged
Changes from 2 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
57c9985
[query] Fix graphite panic in movingMedian, re-enabled some tests
arnikola ed90f14
Merge branch 'master' into arnikola/moving-median
arnikola 1f16a8f
Merge branch 'master' into arnikola/moving-median
robskillington 4c26204
Import order
arnikola c340f1b
Merge branch 'arnikola/moving-median' of github.com:m3db/m3 into arni…
arnikola 218b671
Linting
arnikola fcc9c80
working state
arnikola 83aeabb
stuff
arnikola 33ed9b8
Cleanup
arnikola 31f5999
Cleanup, additional tests
arnikola ab97310
Cleanup
arnikola 2427b12
Merge branch 'master' into arnikola/moving-median
arnikola f7e8e2b
Minor cleanup
arnikola 0d658d5
Merge branch 'arnikola/moving-median' of github.com:m3db/m3 into arni…
arnikola 8923dca
Fix test
arnikola 70faf7e
Revert accidentally changed test value
arnikola efa6a97
PR response
arnikola 117bf9a
Fix to some tests
arnikola 62dfe0d
Test fix
arnikola 1093151
Fix test log
arnikola File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,12 +26,15 @@ import ( | |
"testing" | ||
"time" | ||
|
||
"github.com/golang/mock/gomock" | ||
"github.com/m3db/m3/src/query/block" | ||
"github.com/m3db/m3/src/query/graphite/common" | ||
"github.com/m3db/m3/src/query/graphite/context" | ||
xctx "github.com/m3db/m3/src/query/graphite/context" | ||
"github.com/m3db/m3/src/query/graphite/storage" | ||
xtest "github.com/m3db/m3/src/query/graphite/testing" | ||
"github.com/m3db/m3/src/query/graphite/ts" | ||
xgomock "github.com/m3db/m3/src/x/test" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: third party imports last? |
||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
|
@@ -2448,20 +2451,22 @@ func TestChanged(t *testing.T) { | |
expected, results.Values) | ||
} | ||
|
||
// TODO: re-enable | ||
// nolint | ||
func testMovingMedian(t *testing.T) { | ||
now := time.Now() | ||
engine := NewEngine( | ||
testStorage, | ||
) | ||
func TestMovingMedian(t *testing.T) { | ||
ctrl := xgomock.NewController(t) | ||
defer ctrl.Finish() | ||
|
||
store := storage.NewMockStorage(ctrl) | ||
now := time.Now().Truncate(time.Hour) | ||
engine := NewEngine(store) | ||
startTime := now.Add(-3 * time.Minute) | ||
endTime := now.Add(-time.Minute) | ||
ctx := common.NewContext(common.ContextOptions{Start: startTime, End: endTime, Engine: engine}) | ||
defer ctx.Close() | ||
|
||
stepSize := 60000 | ||
target := "movingMedian(foo.bar.q.zed, '1min')" | ||
store.EXPECT().FetchByQuery(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn( | ||
buildTestSeriesFn(stepSize, "foo.bar.q.zed")).Times(2) | ||
expr, err := engine.Compile(target) | ||
require.NoError(t, err) | ||
res, err := expr.Execute(ctx) | ||
|
@@ -2474,6 +2479,41 @@ func testMovingMedian(t *testing.T) { | |
[]common.TestSeries{expected}, res.Values) | ||
} | ||
|
||
func TestMovingMedianInvalidLimits(t *testing.T) { | ||
ctrl := xgomock.NewController(t) | ||
defer ctrl.Finish() | ||
|
||
store := storage.NewMockStorage(ctrl) | ||
now := time.Now().Truncate(time.Hour) | ||
engine := NewEngine(store) | ||
startTime := now.Add(-3 * time.Minute) | ||
endTime := now.Add(-time.Minute) | ||
ctx := common.NewContext(common.ContextOptions{Start: startTime, End: endTime, Engine: engine}) | ||
defer ctx.Close() | ||
|
||
stepSize := 60000 | ||
target := "movingMedian(foo.bar.q.zed, '1min')" | ||
store.EXPECT().FetchByQuery(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn( | ||
func(_ context.Context, q string, opts storage.FetchOptions) (*storage.FetchResult, error) { | ||
startTime := opts.StartTime | ||
ctx := context.New() | ||
numSteps := int(opts.EndTime.Sub(startTime)/time.Millisecond) / stepSize | ||
vals := ts.NewConstantValues(ctx, 0, numSteps, stepSize) | ||
series := ts.NewSeries(ctx, "foo.bar.q.zed", opts.EndTime, vals) | ||
return &storage.FetchResult{SeriesList: []*ts.Series{series}}, nil | ||
}).Times(2) | ||
expr, err := engine.Compile(target) | ||
require.NoError(t, err) | ||
res, err := expr.Execute(ctx) | ||
require.NoError(t, err) | ||
expected := common.TestSeries{ | ||
Name: "movingMedian(foo.bar.q.zed,\"1min\")", | ||
Data: []float64{0.0, 0.0}, | ||
} | ||
common.CompareOutputsAndExpected(t, stepSize, endTime, | ||
[]common.TestSeries{expected}, res.Values) | ||
} | ||
|
||
func TestLegendValue(t *testing.T) { | ||
ctx := common.NewTestContext() | ||
defer ctx.Close() | ||
|
@@ -2680,13 +2720,13 @@ func TestTimeFunction(t *testing.T) { | |
[]common.TestSeries{expected}, results.Values) | ||
} | ||
|
||
// TODO arnikola reenable | ||
// nolint | ||
func testTimeShift(t *testing.T) { | ||
now := time.Now() | ||
engine := NewEngine( | ||
testStorage, | ||
) | ||
func TestTimeShift(t *testing.T) { | ||
ctrl := xgomock.NewController(t) | ||
defer ctrl.Finish() | ||
|
||
store := storage.NewMockStorage(ctrl) | ||
now := time.Now().Truncate(time.Hour) | ||
engine := NewEngine(store) | ||
startTime := now.Add(-3 * time.Minute) | ||
endTime := now.Add(-time.Minute) | ||
ctx := common.NewContext(common.ContextOptions{ | ||
|
@@ -2698,6 +2738,10 @@ func testTimeShift(t *testing.T) { | |
|
||
stepSize := 60000 | ||
target := "timeShift(foo.bar.q.zed, '1min', false)" | ||
|
||
store.EXPECT().FetchByQuery(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn( | ||
buildTestSeriesFn(stepSize, "foo.bar.q.zed")) | ||
|
||
expr, err := engine.Compile(target) | ||
require.NoError(t, err) | ||
res, err := expr.Execute(ctx) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: third party imports last?