Skip to content

Commit

Permalink
Merge pull request #373 from influxdata/nc-issue#362
Browse files Browse the repository at this point in the history
Fix #362, join+batches+tolerance did not work
  • Loading branch information
Nathaniel Cook committed Mar 22, 2016
2 parents dccf220 + ed01d71 commit 97ac4ed
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ For example:
- [#333](https://github.com/influxdata/kapacitor/issues/333): Fixes hang when replaying with .stats node. Fixes issues with batch and stats.
- [#340](https://github.com/influxdata/kapacitor/issues/340): BREAKING: Decouples global setting for alert handlers from the state changes only setting.
- [#348](https://github.com/influxdata/kapacitor/issues/348): config.go: refactor to simplify structure and fix support for array elements
- [#362](https://github.com/influxdata/kapacitor/issues/362): Fix bug with join tolerance and batches.

## v0.10.1 [2016-02-08]

Expand Down
50 changes: 50 additions & 0 deletions integrations/batcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,56 @@ cpu0.join(cpu1)
testBatcherWithOutput(t, "TestBatch_Join", script, 30*time.Second, er)
}

func TestBatch_JoinTolerance(t *testing.T) {

var script = `
var cpu0 = batch
.query('''
SELECT mean("value")
FROM "telegraf"."default".cpu_usage_idle
WHERE "cpu" = 'cpu0'
''')
.period(10s)
.every(10s)
.groupBy(time(2s))
var cpu1 = batch
.query('''
SELECT mean("value")
FROM "telegraf"."default".cpu_usage_idle
WHERE "cpu" = 'cpu1'
''')
.period(10s)
.every(10s)
.groupBy(time(2s))
cpu0.join(cpu1)
.as('cpu0', 'cpu1')
.tolerance(1s)
.count('cpu0.mean')
.window()
.period(20s)
.every(20s)
.sum('count')
.httpOut('TestBatch_JoinTolerance')
`

er := kapacitor.Result{
Series: imodels.Rows{
{
Name: "cpu_usage_idle",
Columns: []string{"time", "sum"},
Values: [][]interface{}{[]interface{}{
time.Date(1971, 1, 1, 0, 0, 28, 0, time.UTC),
10.0,
}},
},
},
}

testBatcherWithOutput(t, "TestBatch_JoinTolerance", script, 30*time.Second, er)
}

// Helper test function for batcher
func testBatcher(t *testing.T, name, script string) (clock.Setter, *kapacitor.ExecutingTask, <-chan error, *kapacitor.TaskMaster) {
if testing.Verbose() {
Expand Down
3 changes: 3 additions & 0 deletions integrations/data/TestBatch_JoinTolerance.0.brpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{"name":"cpu_usage_idle","points":[{"fields":{"mean":83.56930693069836},"time":"2015-10-30T17:14:12.1Z"},{"fields":{"mean":79.12871287128638},"time":"2015-10-30T17:14:14.1Z"},{"fields":{"mean":88.99559823928229},"time":"2015-10-30T17:14:16.1Z"},{"fields":{"mean":85.50000000000182},"time":"2015-10-30T17:14:18.1Z"},{"fields":{"mean":86.02860286029956},"time":"2015-10-30T17:14:20.1Z"}]}
{"name":"cpu_usage_idle","points":[{"fields":{"mean":81.72501716191164},"time":"2015-10-30T17:14:22.3Z"},{"fields":{"mean":81.03810381037587},"time":"2015-10-30T17:14:24.3Z"},{"fields":{"mean":85.93434343435388},"time":"2015-10-30T17:14:26.3Z"},{"fields":{"mean":85.36734693878043},"time":"2015-10-30T17:14:28.3Z"},{"fields":{"mean":83.01320528210614},"time":"2015-10-30T17:14:30.3Z"}]}
{"name":"cpu_usage_idle","points":[{"fields":{"mean":85.08910891088406},"time":"2015-10-30T17:14:32.5Z"},{"fields":{"mean":78.00000000002001},"time":"2015-10-30T17:14:34.5Z"},{"fields":{"mean":84.23607066586464},"time":"2015-10-30T17:14:36.5Z"},{"fields":{"mean":80.85858585861834},"time":"2015-10-30T17:14:38.5Z"},{"fields":{"mean":80.61224489791657},"time":"2015-10-30T17:14:40.5Z"}]}
3 changes: 3 additions & 0 deletions integrations/data/TestBatch_JoinTolerance.1.brpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{"name":"cpu_usage_idle","points":[{"fields":{"mean":93.49999999999409},"time":"2015-10-30T17:14:12.2Z"},{"fields":{"mean":91.44444444443974},"time":"2015-10-30T17:14:14.2Z"},{"fields":{"mean":93.44897959187637},"time":"2015-10-30T17:14:16.2Z"},{"fields":{"mean":95.99999999995998},"time":"2015-10-30T17:14:18.2Z"},{"fields":{"mean":97.00970097012197},"time":"2015-10-30T17:14:20.2Z"}]}
{"name":"cpu_usage_idle","points":[{"fields":{"mean":95.98484848485191},"time":"2015-10-30T17:14:22.4Z"},{"fields":{"mean":92.09803921569600},"time":"2015-10-30T17:14:24.4Z"},{"fields":{"mean":92.99999999998363},"time":"2015-10-30T17:14:26.4Z"},{"fields":{"mean":86.54015887023496},"time":"2015-10-30T17:14:28.4Z"},{"fields":{"mean":95.48979591840603},"time":"2015-10-30T17:14:30.4Z"}]}
{"name":"cpu_usage_idle","points":[{"fields":{"mean":96.49999999996908},"time":"2015-10-30T17:14:32.6Z"},{"fields":{"mean":93.46464646468584},"time":"2015-10-30T17:14:34.6Z"},{"fields":{"mean":95.00950095007724},"time":"2015-10-30T17:14:36.6Z"},{"fields":{"mean":92.99999999998636},"time":"2015-10-30T17:14:38.6Z"},{"fields":{"mean":90.99999999998545},"time":"2015-10-30T17:14:40.6Z"}]}
1 change: 1 addition & 0 deletions join.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ func newJoinset(
values: make([]models.PointInterface, expected),
first: expected,
time: time,
tolerance: tolerance,
logger: l,
}
}
Expand Down

0 comments on commit 97ac4ed

Please sign in to comment.