Skip to content

Business intelligence made simple

Added test for anomaly checks [skip ci]

Andrew Kane89fa60b4cd4c
diff --git a/Gemfile b/Gemfile
index adfb9347..0abb2b38 100644
--- a/Gemfile
+++ b/Gemfile
@@ -8,7 +8,7 @@ gem "combustion"
gem "rails"
gem "pg"
gem "sprockets-rails"
-gem "prophet-rb" if ENV["TEST_FORECASTING"]
+gem "prophet-rb" if ENV["TEST_PROPHET"]
# data sources
gem "elasticsearch"
diff --git a/test/charts_test.rb b/test/charts_test.rb
index ce9670e1..37c2645b 100644
--- a/test/charts_test.rb
+++ b/test/charts_test.rb
@@ -53,9 +53,9 @@ class ChartsTest < ActionDispatch::IntegrationTest
end
def test_forecasting
- skip "Too slow" unless ENV["TEST_FORECASTING"]
+ skip "Too slow" unless ENV["TEST_PROPHET"]
- query = Blazer::Query.create!(statement: "SELECT current_date + n AS day, n FROM generate_series(1, 30) n", data_source: "main")
+ query = create_query(statement: "SELECT current_date + n AS day, n FROM generate_series(1, 30) n")
run_query query.statement, query_id: query.id, forecast: "t"
assert_match %{"name":"forecast"}, response.body
end
diff --git a/test/checks_test.rb b/test/checks_test.rb
index d83584e8..b331c33f 100644
--- a/test/checks_test.rb
+++ b/test/checks_test.rb
@@ -41,6 +41,23 @@ class ChecksTest < ActionDispatch::IntegrationTest
assert_equal "failing", check.state
end
+ def test_anomaly
+ skip "Too slow" unless ENV["TEST_PROPHET"]
+
+ query = create_query(statement: "SELECT current_date + n AS day, 1 FROM generate_series(1, 30) n")
+ check = create_check(query: query, check_type: "anomaly")
+
+ Blazer.run_checks(schedule: "5 minutes")
+ check.reload
+ assert_equal "passing", check.state
+
+ query.update!(statement: "SELECT current_date + n AS day, 1 FROM generate_series(1, 30) n UNION ALL SELECT current_date + 31, 2")
+
+ Blazer.run_checks(schedule: "5 minutes")
+ check.reload
+ assert_equal "failing", check.state
+ end
+
def test_emails
query = create_query
check = create_check(query: query, check_type: "bad_data", emails: "[email protected]")
diff --git a/test/internal/config/blazer.yml b/test/internal/config/blazer.yml
index fae61aff..a4573fe3 100644
--- a/test/internal/config/blazer.yml
+++ b/test/internal/config/blazer.yml
@@ -67,7 +67,7 @@ check_schedules:
# enable anomaly detection
# note: with trend, time series are sent to https://trendapi.org
-# anomaly_checks: prophet / trend / r
+anomaly_checks: prophet
# enable forecasting
# note: with trend, time series are sent to https://trendapi.org