**Build scan:**
https://gradle-enterprise.elastic.co/s/bedwjax2otgfm/tests/:x-pack:plugin:deprecation:qa:rest:javaRestTest/org.elasticsearch.xpack.deprecation.DeprecationHttpIT/testDeprecationWarnMessagesCanBeIndexed
**Reproduction line:**
```
./gradlew ':x-pack:plugin:deprecation:qa:rest:javaRestTest' --tests "org.elasticsearch.xpack.deprecation.DeprecationHttpIT.testDeprecationWarnMessagesCanBeIndexed" -Dtests.seed=8E2773564F9BF415 -Dtests.locale=es-PY -Dtests.timezone=Asia/Kashgar -Druntime.java=20
```

**Applicable branches:**
main, 8.11

**Reproduces locally?:**
Didn't try

**Failure history:**
https://gradle-enterprise.elastic.co/scans/tests?tests.container=org.elasticsearch.xpack.deprecation.DeprecationHttpIT&tests.test=testDeprecationWarnMessagesCanBeIndexed


**Failure excerpt:**
```
java.lang.AssertionError: 
Expected: iterable with items [(map containing ["@timestamp"->ANYTHING] and map containing ["elasticsearch.cluster.name"->ANYTHING] and map containing ["elasticsearch.cluster.uuid"->ANYTHING] and map containing ["elasticsearch.http.request.x_opaque_id"->"xOpaqueId-testDeprecationWarnMessagesCanBeIndexed"] and map containing ["elasticsearch.event.category"->"settings"] and map containing ["elasticsearch.node.id"->ANYTHING] and map containing ["elasticsearch.node.name"->ANYTHING] and map containing ["data_stream.dataset"->"deprecation.elasticsearch"] and map containing ["data_stream.namespace"->"default"] and map containing ["data_stream.type"->"logs"] and map containing ["ecs.version"->ANYTHING] and map containing ["event.code"->"deprecated_warn_settings"] and map containing ["event.dataset"->"deprecation.elasticsearch"] and map containing ["log.level"->"WARN"] and map containing ["log.logger"->ANYTHING] and map containing ["message"->"[deprecated_warn_settings] usage is deprecated but won't be breaking in next version"]), (map containing ["@timestamp"->ANYTHING] and map containing ["elasticsearch.cluster.name"->ANYTHING] and map containing ["elasticsearch.cluster.uuid"->ANYTHING] and map containing ["elasticsearch.http.request.x_opaque_id"->"xOpaqueId-testDeprecationWarnMessagesCanBeIndexed"] and map containing ["elasticsearch.event.category"->"api"] and map containing ["elasticsearch.node.id"->ANYTHING] and map containing ["elasticsearch.node.name"->ANYTHING] and map containing ["data_stream.dataset"->"deprecation.elasticsearch"] and map containing ["data_stream.namespace"->"default"] and map containing ["data_stream.type"->"logs"] and map containing ["ecs.version"->ANYTHING] and map containing ["event.code"->"deprecated_route_GET_/_test_cluster/deprecated_settings"] and map containing ["event.dataset"->"deprecation.elasticsearch"] and map containing ["log.level"->"WARN"] and map containing ["log.logger"->ANYTHING] and map containing ["message"->"[/_test_cluster/deprecated_settings] exists for deprecated tests"])] in any order
     but: not matched: <{elasticsearch.cluster.name=javaRestTest, service.name=ES_ECS, elasticsearch.event.category=settings, data_stream.namespace=default, message=[test.setting.deprecated.true1] setting was deprecated in Elasticsearch and will be removed in a future release., data_stream.type=logs, log.logger=org.elasticsearch.deprecation.common.settings.Settings, @timestamp=2023-10-24T04:33:50.043Z, event.code=test.setting.deprecated.true1, elasticsearch.cluster.uuid=EX096D_-R1exFtELForjNg, elasticsearch.node.name=javaRestTest-0, ecs.version=1.2.0, data_stream.dataset=deprecation.elasticsearch, log.level=WARN, event.dataset=deprecation.elasticsearch, process.thread.name=elasticsearch[javaRestTest-0][masterService#updateTask][T#1], elasticsearch.node.id=oVMdhtHdTk60c3Ybh9a6xw}>

  at __randomizedtesting.SeedInfo.seed([8E2773564F9BF415:4BCBEBE1E8D8908]:0)
  at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:18)
  at org.junit.Assert.assertThat(Assert.java:956)
  at org.junit.Assert.assertThat(Assert.java:923)
  at org.elasticsearch.xpack.deprecation.DeprecationHttpIT.lambda$testDeprecationWarnMessagesCanBeIndexed$11(DeprecationHttpIT.java:517)
  at org.elasticsearch.test.ESTestCase.assertBusy(ESTestCase.java:1202)
  at org.elasticsearch.xpack.deprecation.DeprecationHttpIT.testDeprecationWarnMessagesCanBeIndexed(DeprecationHttpIT.java:512)
  at jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
  at java.lang.reflect.Method.invoke(Method.java:578)
  at com.carrotsearch.randomizedtesting.RandomizedRunner.invoke(RandomizedRunner.java:1758)
  at com.carrotsearch.randomizedtesting.RandomizedRunner$8.evaluate(RandomizedRunner.java:946)
  at com.carrotsearch.randomizedtesting.RandomizedRunner$9.evaluate(RandomizedRunner.java:982)
  at com.carrotsearch.randomizedtesting.RandomizedRunner$10.evaluate(RandomizedRunner.java:996)
  at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
  at org.apache.lucene.tests.util.TestRuleSetupTeardownChained$1.evaluate(TestRuleSetupTeardownChained.java:48)
  at org.apache.lucene.tests.util.AbstractBeforeAfterRule$1.evaluate(AbstractBeforeAfterRule.java:43)
  at org.apache.lucene.tests.util.TestRuleThreadAndTestName$1.evaluate(TestRuleThreadAndTestName.java:45)
  at org.apache.lucene.tests.util.TestRuleIgnoreAfterMaxFailures$1.evaluate(TestRuleIgnoreAfterMaxFailures.java:60)
  at org.apache.lucene.tests.util.TestRuleMarkFailure$1.evaluate(TestRuleMarkFailure.java:44)
  at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
  at com.carrotsearch.randomizedtesting.ThreadLeakControl$StatementRunner.run(ThreadLeakControl.java:390)
  at com.carrotsearch.randomizedtesting.ThreadLeakControl.forkTimeoutingTask(ThreadLeakControl.java:843)
  at com.carrotsearch.randomizedtesting.ThreadLeakControl$3.evaluate(ThreadLeakControl.java:490)
  at com.carrotsearch.randomizedtesting.RandomizedRunner.runSingleTest(RandomizedRunner.java:955)
  at com.carrotsearch.randomizedtesting.RandomizedRunner$5.evaluate(RandomizedRunner.java:840)
  at com.carrotsearch.randomizedtesting.RandomizedRunner$6.evaluate(RandomizedRunner.java:891)
  at com.carrotsearch.randomizedtesting.RandomizedRunner$7.evaluate(RandomizedRunner.java:902)
  at org.apache.lucene.tests.util.AbstractBeforeAfterRule$1.evaluate(AbstractBeforeAfterRule.java:43)
  at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
  at org.apache.lucene.tests.util.TestRuleStoreClassName$1.evaluate(TestRuleStoreClassName.java:38)
  at com.carrotsearch.randomizedtesting.rules.NoShadowingOrOverridesOnMethodsRule$1.evaluate(NoShadowingOrOverridesOnMethodsRule.java:40)
  at com.carrotsearch.randomizedtesting.rules.NoShadowingOrOverridesOnMethodsRule$1.evaluate(NoShadowingOrOverridesOnMethodsRule.java:40)
  at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
  at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
  at org.apache.lucene.tests.util.TestRuleAssertionsRequired$1.evaluate(TestRuleAssertionsRequired.java:53)
  at org.apache.lucene.tests.util.AbstractBeforeAfterRule$1.evaluate(AbstractBeforeAfterRule.java:43)
  at org.apache.lucene.tests.util.TestRuleMarkFailure$1.evaluate(TestRuleMarkFailure.java:44)
  at org.apache.lucene.tests.util.TestRuleIgnoreAfterMaxFailures$1.evaluate(TestRuleIgnoreAfterMaxFailures.java:60)
  at org.apache.lucene.tests.util.TestRuleIgnoreTestSuites$1.evaluate(TestRuleIgnoreTestSuites.java:47)
  at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
  at com.carrotsearch.randomizedtesting.ThreadLeakControl$StatementRunner.run(ThreadLeakControl.java:390)
  at com.carrotsearch.randomizedtesting.ThreadLeakControl.lambda$forkTimeoutingTask$0(ThreadLeakControl.java:850)
  at java.lang.Thread.run(Thread.java:1623)

```
x-pack/plugin/deprecation/qa/rest/src/javaRestTest/java/org/elasticsearch/xpack/deprecation/DeprecationHttpIT.java
@Before
    public void assertIndexingIsEnabled() throws Exception {
        
        Response response = client().performRequest(new Request("GET", "/_cluster/settings?include_defaults=true&flat_settings=true"));
        assertOK(response);
        ObjectMapper mapper = new ObjectMapper();
        final JsonNode jsonNode = mapper.readTree(response.getEntity().getContent());
        final boolean defaultValue = jsonNode.at("/defaults/cluster.deprecation_indexing.enabled").asBoolean();
        assertTrue(defaultValue);
        
        assertBusy(() -> {
            try {
                client().performRequest(new Request("GET", "/_data_stream/" + DeprecationTestUtils.DATA_STREAM_NAME));
            } catch (ResponseException e) {
                if (e.getResponse().getStatusLine().getStatusCode() == 404) {
                    return;
                }
            }
            List<Map<String, Object>> documents = DeprecationTestUtils.getIndexedDeprecations(client());
            logger.warn(documents);
            
            
            resetDeprecationIndexAndCache();
            fail("Index should be removed on startup");
        }, 30, TimeUnit.SECONDS);