From 621f4f20b03a01267c3691f1c5ca1176508d381a Mon Sep 17 00:00:00 2001 From: Dimitrios Athanasiou Date: Fri, 26 Jan 2018 15:39:21 +0000 Subject: [PATCH] [ML][TEST] Add BWC tests for rules syntax change Original commit: elastic/x-pack-elasticsearch@805d390417055e700a426d7729916ae3661d1c45 --- .../test/mixed_cluster/30_ml_jobs_crud.yml | 8 ++ .../test/old_cluster/30_ml_jobs_crud.yml | 74 +++++++++++++++++++ .../test/upgraded_cluster/30_ml_jobs_crud.yml | 24 ++++++ 3 files changed, 106 insertions(+) diff --git a/qa/rolling-upgrade/src/test/resources/rest-api-spec/test/mixed_cluster/30_ml_jobs_crud.yml b/qa/rolling-upgrade/src/test/resources/rest-api-spec/test/mixed_cluster/30_ml_jobs_crud.yml index 91936351369..e9003a79644 100644 --- a/qa/rolling-upgrade/src/test/resources/rest-api-spec/test/mixed_cluster/30_ml_jobs_crud.yml +++ b/qa/rolling-upgrade/src/test/resources/rest-api-spec/test/mixed_cluster/30_ml_jobs_crud.yml @@ -94,3 +94,11 @@ setup: - do: xpack.ml.close_job: job_id: mixed-cluster-job + +--- +"Test get job with rules": + + - do: + xpack.ml.get_jobs: + job_id: old-cluster-job-with-rules + - match: { count: 1 } diff --git a/qa/rolling-upgrade/src/test/resources/rest-api-spec/test/old_cluster/30_ml_jobs_crud.yml b/qa/rolling-upgrade/src/test/resources/rest-api-spec/test/old_cluster/30_ml_jobs_crud.yml index a8acecfead9..fc48514e582 100644 --- a/qa/rolling-upgrade/src/test/resources/rest-api-spec/test/old_cluster/30_ml_jobs_crud.yml +++ b/qa/rolling-upgrade/src/test/resources/rest-api-spec/test/old_cluster/30_ml_jobs_crud.yml @@ -121,3 +121,77 @@ "time_format":"epoch" } } + +--- +"Test job with pre 6.2 rules": + + - skip: + version: "6.2.0 - " + reason: "Rules fields were renamed on 6.2.0" + + - do: + xpack.ml.put_job: + job_id: old-cluster-job-with-rules + body: > + { + "analysis_config": { + "detectors": [ + { + "function": "count", + "by_field_name": "country", + "detector_rules": [ + { + "rule_action": "filter_results", + "rule_conditions": [ + { + "condition_type":"numerical_actual", + "field_name":"country", + "field_value": "uk", + "condition": {"operator":"lt","value":"33.3"} + }, + {"type":"categorical", "field_name":"country", "value_filter": "foo"} + ] + } + ] + } + ] + }, + "data_description" : {} + } + +--- +"Test job with post 6.2 rules": + + - skip: + version: " - 6.1.99" + reason: "Rules fields were renamed on 6.2.0" + + - do: + xpack.ml.put_job: + job_id: old-cluster-job-with-rules + body: > + { + "analysis_config": { + "detectors": [ + { + "function": "count", + "by_field_name": "country", + "rules": [ + { + "actions": ["filter_results"], + "conditions": [ + { + "type":"numerical_actual", + "field_name":"country", + "field_value": "uk", + "condition": {"operator":"lt","value":"33.3"} + }, + {"type":"categorical", "field_name":"country", "filter_id": "foo"} + ] + } + ] + } + ] + }, + "data_description" : {} + } diff --git a/qa/rolling-upgrade/src/test/resources/rest-api-spec/test/upgraded_cluster/30_ml_jobs_crud.yml b/qa/rolling-upgrade/src/test/resources/rest-api-spec/test/upgraded_cluster/30_ml_jobs_crud.yml index 1acfad77b26..b9fd3cda86e 100644 --- a/qa/rolling-upgrade/src/test/resources/rest-api-spec/test/upgraded_cluster/30_ml_jobs_crud.yml +++ b/qa/rolling-upgrade/src/test/resources/rest-api-spec/test/upgraded_cluster/30_ml_jobs_crud.yml @@ -97,3 +97,27 @@ setup: job_id: no-model-memory-limit-job - match: { acknowledged: true } +--- +"Test get job with rules": + + - do: + xpack.ml.get_jobs: + job_id: old-cluster-job-with-rules + - match: { count: 1 } + - match: { + jobs.0.analysis_config.detectors.0.rules: [ + { + "actions": ["filter_results"], + "conditions_connective": "or", + "conditions": [ + { + "type":"numerical_actual", + "field_name":"country", + "field_value": "uk", + "condition": {"operator":"lt","value":"33.3"} + }, + {"type":"categorical", "field_name":"country", "filter_id": "foo"} + ] + } + ] + }