@@ -59,7 +59,11 @@ func TestAccResourceAnomalyDetectorJob(t *testing.T) {
5959 resource .TestCheckResourceAttr ("elasticstack_elasticsearch_ml_anomaly_detector.test" , "model_plot_config.enabled" , "true" ),
6060 // Other settings checks
6161 resource .TestCheckResourceAttr ("elasticstack_elasticsearch_ml_anomaly_detector.test" , "allow_lazy_open" , "true" ),
62+ resource .TestCheckResourceAttr ("elasticstack_elasticsearch_ml_anomaly_detector.test" , "background_persist_interval" , "1h" ),
63+ resource .TestCheckResourceAttr ("elasticstack_elasticsearch_ml_anomaly_detector.test" , "custom_settings" , "{\" custom_key\" : \" custom_value\" }" ),
64+ resource .TestCheckResourceAttr ("elasticstack_elasticsearch_ml_anomaly_detector.test" , "daily_model_snapshot_retention_after_days" , "3" ),
6265 resource .TestCheckResourceAttr ("elasticstack_elasticsearch_ml_anomaly_detector.test" , "model_snapshot_retention_days" , "7" ),
66+ resource .TestCheckResourceAttr ("elasticstack_elasticsearch_ml_anomaly_detector.test" , "renormalization_window_days" , "14" ),
6367 resource .TestCheckResourceAttr ("elasticstack_elasticsearch_ml_anomaly_detector.test" , "results_retention_days" , "30" ),
6468 // Computed fields
6569 resource .TestCheckResourceAttrSet ("elasticstack_elasticsearch_ml_anomaly_detector.test" , "create_time" ),
@@ -73,6 +77,17 @@ func TestAccResourceAnomalyDetectorJob(t *testing.T) {
7377 resource .TestCheckResourceAttr ("elasticstack_elasticsearch_ml_anomaly_detector.test" , "job_id" , jobID ),
7478 resource .TestCheckResourceAttr ("elasticstack_elasticsearch_ml_anomaly_detector.test" , "description" , "Updated test anomaly detection job" ),
7579 resource .TestCheckResourceAttr ("elasticstack_elasticsearch_ml_anomaly_detector.test" , "groups.#" , "1" ),
80+ resource .TestCheckResourceAttr ("elasticstack_elasticsearch_ml_anomaly_detector.test" , "groups.0" , "test-group" ),
81+ // Verify that updatable fields were actually updated
82+ resource .TestCheckResourceAttr ("elasticstack_elasticsearch_ml_anomaly_detector.test" , "analysis_limits.model_memory_limit" , "200mb" ),
83+ resource .TestCheckResourceAttr ("elasticstack_elasticsearch_ml_anomaly_detector.test" , "model_plot_config.enabled" , "false" ),
84+ resource .TestCheckResourceAttr ("elasticstack_elasticsearch_ml_anomaly_detector.test" , "allow_lazy_open" , "false" ),
85+ resource .TestCheckResourceAttr ("elasticstack_elasticsearch_ml_anomaly_detector.test" , "background_persist_interval" , "2h" ),
86+ resource .TestCheckResourceAttr ("elasticstack_elasticsearch_ml_anomaly_detector.test" , "custom_settings" , "{\" updated_key\" : \" updated_value\" }" ),
87+ resource .TestCheckResourceAttr ("elasticstack_elasticsearch_ml_anomaly_detector.test" , "daily_model_snapshot_retention_after_days" , "5" ),
88+ resource .TestCheckResourceAttr ("elasticstack_elasticsearch_ml_anomaly_detector.test" , "model_snapshot_retention_days" , "14" ),
89+ resource .TestCheckResourceAttr ("elasticstack_elasticsearch_ml_anomaly_detector.test" , "renormalization_window_days" , "30" ),
90+ resource .TestCheckResourceAttr ("elasticstack_elasticsearch_ml_anomaly_detector.test" , "results_retention_days" , "60" ),
7691 ),
7792 },
7893 },
@@ -159,7 +174,11 @@ resource "elasticstack_elasticsearch_ml_anomaly_detector" "test" {
159174 }
160175
161176 allow_lazy_open = true
177+ background_persist_interval = "1h"
178+ custom_settings = "{\"custom_key\": \"custom_value\"}"
179+ daily_model_snapshot_retention_after_days = 3
162180 model_snapshot_retention_days = 7
181+ renormalization_window_days = 14
163182 results_retention_days = 30
164183}
165184` , jobID , jobID )
@@ -191,6 +210,23 @@ resource "elasticstack_elasticsearch_ml_anomaly_detector" "test" {
191210 }
192211
193212 groups = ["test-group"]
213+
214+ # Test updating some of the other updatable fields
215+ analysis_limits = {
216+ model_memory_limit = "200mb"
217+ }
218+
219+ model_plot_config = {
220+ enabled = false
221+ }
222+
223+ allow_lazy_open = false
224+ background_persist_interval = "2h"
225+ custom_settings = "{\"updated_key\": \"updated_value\"}"
226+ daily_model_snapshot_retention_after_days = 5
227+ model_snapshot_retention_days = 14
228+ renormalization_window_days = 30
229+ results_retention_days = 60
194230}
195231` , jobID )
196232}
0 commit comments