teardown:

  - do:
      cluster.put_settings:
        body:
          persistent:
            xpack.ml.max_model_memory_limit: null

---
"Test ml info":
  - do:
      ml.info: {}
  - match: { defaults.anomaly_detectors.categorization_analyzer.tokenizer: "ml_standard" }
  - match: { defaults.anomaly_detectors.model_memory_limit: "1gb" }
  - match: { defaults.anomaly_detectors.categorization_examples_limit: 4 }
  - match: { defaults.anomaly_detectors.model_snapshot_retention_days: 10 }
  - match: { defaults.anomaly_detectors.daily_model_snapshot_retention_after_days: 1 }
  - match: { defaults.datafeeds.scroll_size: 1000 }
  - is_false: limits.max_model_memory_limit
  # We cannot assert an exact value for the next two as they will vary depending on the test machine
  - match: { limits.effective_max_model_memory_limit: "/\\d+[kmg]?b/" }
  - match: { limits.total_ml_memory: "/\\d+mb/" }
  - match: { upgrade_mode: false }

  - do:
      cluster.put_settings:
        body:
          persistent:
            xpack.ml.max_model_memory_limit: "512mb"

  - do:
      ml.info: {}
  - match: { defaults.anomaly_detectors.categorization_analyzer.tokenizer: "ml_standard" }
  - match: { defaults.anomaly_detectors.model_memory_limit: "512mb" }
  - match: { defaults.anomaly_detectors.categorization_examples_limit: 4 }
  - match: { defaults.anomaly_detectors.model_snapshot_retention_days: 10 }
  - match: { defaults.anomaly_detectors.daily_model_snapshot_retention_after_days: 1 }
  - match: { defaults.datafeeds.scroll_size: 1000 }
  - match: { limits.max_model_memory_limit: "512mb" }
  # We cannot assert an exact value for the next two as they will vary depending on the test machine
  - match: { limits.effective_max_model_memory_limit: "/\\d+[kmg]?b/" }
  - match: { limits.total_ml_memory: "/\\d+mb/" }
  - match: { upgrade_mode: false }

  - do:
      cluster.put_settings:
        body:
          persistent:
            xpack.ml.max_model_memory_limit: "6gb"

  - do:
      ml.info: {}
  - match: { defaults.anomaly_detectors.categorization_analyzer.tokenizer: "ml_standard" }
  - match: { defaults.anomaly_detectors.model_memory_limit: "1gb" }
  - match: { defaults.anomaly_detectors.categorization_examples_limit: 4 }
  - match: { defaults.anomaly_detectors.model_snapshot_retention_days: 10 }
  - match: { defaults.anomaly_detectors.daily_model_snapshot_retention_after_days: 1 }
  - match: { defaults.datafeeds.scroll_size: 1000 }
  - match: { limits.max_model_memory_limit: "6gb" }
  # We cannot assert an exact value for the next two as they will vary depending on the test machine
  - match: { limits.effective_max_model_memory_limit: "/\\d+[kmg]?b/" }
  - match: { limits.total_ml_memory: "/\\d+mb/" }
  - match: { upgrade_mode: false }

  - do:
      cluster.put_settings:
        body:
          persistent:
            xpack.ml.max_model_memory_limit: "6gb"

  - do:
      ml.info: {}
  - match: { defaults.anomaly_detectors.categorization_analyzer.tokenizer: "ml_standard" }
  - match: { defaults.anomaly_detectors.model_memory_limit: "1gb" }
  - match: { defaults.anomaly_detectors.categorization_examples_limit: 4 }
  - match: { defaults.anomaly_detectors.model_snapshot_retention_days: 10 }
  - match: { defaults.anomaly_detectors.daily_model_snapshot_retention_after_days: 1 }
  - match: { defaults.datafeeds.scroll_size: 1000 }
  - match: { limits.max_model_memory_limit: "6gb" }
  # We cannot assert an exact value for the next two as they will vary depending on the test machine
  - match: { limits.effective_max_model_memory_limit: "/\\d+[kmg]?b/" }
  - match: { limits.total_ml_memory: "/\\d+mb/" }
  - match: { upgrade_mode: false }

  - do:
      cluster.put_settings:
        body:
          persistent:
            xpack.ml.max_model_memory_limit: "1mb"

  - do:
      ml.info: {}
  - match: { defaults.anomaly_detectors.categorization_analyzer.tokenizer: "ml_standard" }
  - match: { defaults.anomaly_detectors.model_memory_limit: "1mb" }
  - match: { defaults.anomaly_detectors.categorization_examples_limit: 4 }
  - match: { defaults.anomaly_detectors.model_snapshot_retention_days: 10 }
  - match: { defaults.anomaly_detectors.daily_model_snapshot_retention_after_days: 1 }
  - match: { defaults.datafeeds.scroll_size: 1000 }
  - match: { limits.max_model_memory_limit: "1mb" }
  # This time we can assert an exact value for the next one because the hard limit is so low
  - match: { limits.effective_max_model_memory_limit: "1mb" }
  - match: { limits.total_ml_memory: "/\\d+mb/" }
  - match: { upgrade_mode: false }
