<commit_before>---
setup:
  - do:
      indices.create:
          index: test
          body:
           settings:
             index:
               # initializing replicas maintain the translog causing the test to fail.
               # remove once https://github.com/elastic/elasticsearch/issues/25623 is fixed.
               number_of_replicas: 0

---
"Translog retention":
  - skip:
      version: " - 5.99.0"
      reason: translog retention was added in 6.0.0
  - do:
      indices.stats:
        metric: [ translog ]
  - set: { indices.test.primaries.translog.size_in_bytes: creation_size }

  - do:
      index:
        index: test
        type:  bar
        id:    1
        body:  { "foo": "bar" }

  - do:
      indices.stats:
        metric: [ translog ]
  - gt: { indices.test.primaries.translog.size_in_bytes: $creation_size }
  - match: { indices.test.primaries.translog.operations: 1 }
# we can't check this yet as creation size will contain two empty translog generations. A single
# non empty generation with one op may be smaller or larger than that.
#  - gt: { indices.test.primaries.translog.uncommitted_size_in_bytes: $creation_size }
  - match: { indices.test.primaries.translog.uncommitted_operations: 1 }

  - do:
      indices.flush:
        index: test

  - do:
      indices.stats:
        metric: [ translog ]
  - gt: { indices.test.primaries.translog.size_in_bytes: $creation_size }
  - match: { indices.test.primaries.translog.operations: 1 }
  ## creation translog size has some overhead due to an initial empty generation that will be trimmed later
  - lt: { indices.test.primaries.translog.uncommitted_size_in_bytes: $creation_size }
  - match: { indices.test.primaries.translog.uncommitted_operations: 0 }

  - do:
      indices.put_settings:
        index: test
        body:
          index.translog.retention.size: -1
          index.translog.retention.age: -1

  - do:
      indices.flush:
        index: test
        force: true # force flush as we don't have pending ops

  - do:
      indices.stats:
        metric: [ translog ]
  ## creation translog size has some overhead due to an initial empty generation that will be trimmed later<commit_msg>TEST: loosen translog  uncommitted size rest test<commit_after>---
setup:
  - do:
      indices.create:
          index: test
          body:
           settings:
             index:
               # initializing replicas maintain the translog causing the test to fail.
               # remove once https://github.com/elastic/elasticsearch/issues/25623 is fixed.
               number_of_replicas: 0

---
"Translog retention":
  - skip:
      version: " - 5.99.0"
      reason: translog retention was added in 6.0.0
  - do:
      indices.stats:
        metric: [ translog ]
  - set: { indices.test.primaries.translog.size_in_bytes: creation_size }

  - do:
      index:
        index: test
        type:  bar
        id:    1
        body:  { "foo": "bar" }

  - do:
      indices.stats:
        metric: [ translog ]
  - gt: { indices.test.primaries.translog.size_in_bytes: $creation_size }
  - match: { indices.test.primaries.translog.operations: 1 }
# we can't check this yet as creation size will contain two empty translog generations. A single
# non empty generation with one op may be smaller or larger than that.
#  - gt: { indices.test.primaries.translog.uncommitted_size_in_bytes: $creation_size }
  - match: { indices.test.primaries.translog.uncommitted_operations: 1 }

  - do:
      indices.flush:
        index: test

  - do:
      indices.stats:
        metric: [ translog ]
  - gt: { indices.test.primaries.translog.size_in_bytes: $creation_size }
  - match: { indices.test.primaries.translog.operations: 1 }
  ## creation translog size has some overhead due to an initial empty generation that will be trimmed later
  - lte: { indices.test.primaries.translog.uncommitted_size_in_bytes: $creation_size }
  - match: { indices.test.primaries.translog.uncommitted_operations: 0 }

  - do:
      indices.put_settings:
        index: test
        body:
          index.translog.retention.size: -1
          index.translog.retention.age: -1

  - do:
      indices.flush:
        index: test
        force: true # force flush as we don't have pending ops

  - do:
      indices.stats:
        metric: [ translog ]
  ## creation translog size has some overhead due to an initial empty generation that will be trimmed later
{'fraction_non_alphanumeric': 0.09567971047274372, 'fraction_numerical': 0.009047726758651889, 'mean_word_length': 2.304932735426009, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2408315', 'n_tokens_mistral': 1387, 'n_tokens_neox': 1327, 'n_words': 369}