Skip to content

Commit

Permalink
test: add movingAverage carbonapi func test
Browse files Browse the repository at this point in the history
  • Loading branch information
msaf1980 committed Nov 10, 2023
1 parent 52aeca6 commit a28ff7a
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions metric_source/local/local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,29 @@ func TestLocalSourceFetch(t *testing.T) {
})
})

// for update carbonapi to v0.16.2, check for nil pointers usage in carbonapi config
Convey("Test success evaluate target with movingAverage(1)", t, func() {
database.EXPECT().GetPatternMetrics(pattern1).Return([]string{metric}, nil)
database.EXPECT().GetMetricRetention(metric).Return(retention, nil)
database.EXPECT().GetMetricsValues([]string{metric}, retentionFrom, retentionUntil-1).Return(dataList, nil)
database.EXPECT().GetMetricsTTLSeconds().Return(metricsTTL)

result, err := localSource.Fetch("super.puper.pattern | movingAverage(1) | aliasByNode(5, 7)", from, until, true)

So(err, ShouldBeNil)
So(result, ShouldResemble, &FetchResult{
MetricsData: []metricSource.MetricData{{
Name: "super.puper.metric",
StartTime: retentionFrom,
StopTime: retentionUntil,
StepTime: retention,
Values: []float64{0, 1, 2, 3, 4},
}},
Metrics: []string{metric},
Patterns: []string{pattern1},
})
})

Convey("Test success evaluate target with aliasByTags('name')", t, func() {
database.EXPECT().GetPatternMetrics(pattern1).Return([]string{metric}, nil)
database.EXPECT().GetMetricRetention(metric).Return(retention, nil)
Expand Down

0 comments on commit a28ff7a

Please sign in to comment.