---
setup:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
---
ML memory all nodes:
- skip:
    features:
    - "arbitrary_key"
- do:
    ml.get_memory_stats: {}
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- set:
    nodes._arbitrary_key_: "node_id"
- do:
    ml.get_memory_stats: {}
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- gte:
    _nodes.total: 1
- lte:
    _nodes.total: 3
- gte:
    _nodes.successful: 1
- lte:
    _nodes.successful: 3
- is_true: "cluster_name"
- is_true: "nodes.$node_id.name"
- is_true: "nodes.$node_id.ephemeral_id"
- is_true: "nodes.$node_id.transport_address"
- is_true: "nodes.$node_id.attributes"
- is_true: "nodes.$node_id.roles"
- gt:
    nodes.$node_id.mem.total_in_bytes: 0
- gt:
    nodes.$node_id.mem.adjusted_total_in_bytes: 0
- gte:
    nodes.$node_id.mem.ml.max_in_bytes: 0
- match:
    nodes.$node_id.mem.ml.native_code_overhead_in_bytes: 0
- match:
    nodes.$node_id.mem.ml.anomaly_detectors_in_bytes: 0
- match:
    nodes.$node_id.mem.ml.data_frame_analytics_in_bytes: 0
- match:
    nodes.$node_id.mem.ml.native_inference_in_bytes: 0
- gt:
    nodes.$node_id.jvm.heap_max_in_bytes: 0
- gt:
    nodes.$node_id.jvm.java_inference_max_in_bytes: 0
- gte:
    nodes.$node_id.jvm.java_inference_in_bytes: 0
---
ML memory for ML nodes:
- skip:
    features:
    - "arbitrary_key"
- do:
    ml.get_memory_stats:
      node_id: "ml:true"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- set:
    nodes._arbitrary_key_: "node_id"
- do:
    ml.get_memory_stats:
      node_id: "ml:true"
      master_timeout: "1m"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    _nodes.total: 1
- match:
    _nodes.successful: 1
- match:
    _nodes.failed: 0
- is_true: "cluster_name"
- is_true: "nodes.$node_id.name"
- is_true: "nodes.$node_id.ephemeral_id"
- is_true: "nodes.$node_id.transport_address"
- is_true: "nodes.$node_id.attributes"
- is_true: "nodes.$node_id.roles"
- gt:
    nodes.$node_id.mem.total_in_bytes: 0
- gt:
    nodes.$node_id.mem.adjusted_total_in_bytes: 0
- gt:
    nodes.$node_id.mem.ml.max_in_bytes: 0
- match:
    nodes.$node_id.mem.ml.native_code_overhead_in_bytes: 0
- match:
    nodes.$node_id.mem.ml.anomaly_detectors_in_bytes: 0
- match:
    nodes.$node_id.mem.ml.data_frame_analytics_in_bytes: 0
- match:
    nodes.$node_id.mem.ml.native_inference_in_bytes: 0
- gt:
    nodes.$node_id.jvm.heap_max_in_bytes: 0
- gt:
    nodes.$node_id.jvm.java_inference_max_in_bytes: 0
- gte:
    nodes.$node_id.jvm.java_inference_in_bytes: 0
---
ML memory for specific node:
- skip:
    features:
    - "arbitrary_key"
- do:
    ml.get_memory_stats: {}
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- set:
    nodes._arbitrary_key_: "node_id"
- do:
    ml.get_memory_stats:
      node_id: "$node_id"
      timeout: "29s"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    _nodes.total: 1
- match:
    _nodes.successful: 1
- match:
    _nodes.failed: 0
- is_true: "cluster_name"
- is_true: "nodes.$node_id.name"
- is_true: "nodes.$node_id.ephemeral_id"
- is_true: "nodes.$node_id.transport_address"
- is_true: "nodes.$node_id.attributes"
- is_true: "nodes.$node_id.roles"
- gt:
    nodes.$node_id.mem.total_in_bytes: 0
- gt:
    nodes.$node_id.mem.adjusted_total_in_bytes: 0
- gte:
    nodes.$node_id.mem.ml.max_in_bytes: 0
- match:
    nodes.$node_id.mem.ml.native_code_overhead_in_bytes: 0
- match:
    nodes.$node_id.mem.ml.anomaly_detectors_in_bytes: 0
- match:
    nodes.$node_id.mem.ml.data_frame_analytics_in_bytes: 0
- match:
    nodes.$node_id.mem.ml.native_inference_in_bytes: 0
- gt:
    nodes.$node_id.jvm.heap_max_in_bytes: 0
- gt:
    nodes.$node_id.jvm.java_inference_max_in_bytes: 0
- gte:
    nodes.$node_id.jvm.java_inference_in_bytes: 0
