Skip to content

Commit 3271c5a

Browse files
authored
Fix LogsdbIndexingRollingUpgradeIT (#133562)
The template that this test suite creates was never used during the test. This is because it uses default priority, and the builtin `logs@template` which also matches with the data stream name has a higher priority. This change addresses this problem by setting the priority to 200 for the template that this test suite creates. Additionally, an extra check is added the verifying that the created template is actually used by the data stream that this test suite creates. This change results in this test suite to fail if #133493 isn't applied.
1 parent f2b364c commit 3271c5a

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

x-pack/plugin/logsdb/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/LogsdbIndexingRollingUpgradeIT.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import static org.hamcrest.Matchers.equalTo;
3535
import static org.hamcrest.Matchers.greaterThan;
3636
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
37+
import static org.hamcrest.Matchers.hasSize;
3738
import static org.hamcrest.Matchers.notNullValue;
3839

3940
public class LogsdbIndexingRollingUpgradeIT extends AbstractRollingUpgradeWithSecurityTestCase {
@@ -78,7 +79,8 @@ public void testIndexing() throws Exception {
7879
if (isOldCluster()) {
7980
startTrial();
8081
enableLogsdbByDefault();
81-
createTemplate(dataStreamName, getClass().getSimpleName().toLowerCase(Locale.ROOT), TEMPLATE);
82+
String templateId = getClass().getSimpleName().toLowerCase(Locale.ROOT);
83+
createTemplate(dataStreamName, templateId, TEMPLATE);
8284

8385
Instant startTime = Instant.now().minusSeconds(60 * 60);
8486
bulkIndex(dataStreamName, 4, 1024, startTime);
@@ -88,6 +90,8 @@ public void testIndexing() throws Exception {
8890
assertThat(((Map<?, ?>) settings.get("settings")).get("index.mode"), equalTo("logsdb"));
8991
assertThat(((Map<?, ?>) settings.get("defaults")).get("index.mapping.source.mode"), equalTo("SYNTHETIC"));
9092

93+
// check prior to rollover
94+
assertDataStream(dataStreamName, templateId);
9195
ensureGreen(dataStreamName);
9296
search(dataStreamName);
9397
query(dataStreamName);
@@ -115,9 +119,20 @@ public void testIndexing() throws Exception {
115119
}
116120
}
117121

122+
static void assertDataStream(String dataStreamName, String templateId) throws IOException {
123+
var getDataStreamsRequest = new Request("GET", "/_data_stream/" + dataStreamName);
124+
var getDataStreamResponse = client().performRequest(getDataStreamsRequest);
125+
assertOK(getDataStreamResponse);
126+
var dataStreams = entityAsMap(getDataStreamResponse);
127+
assertThat(ObjectPath.evaluate(dataStreams, "data_streams.0.name"), equalTo(dataStreamName));
128+
assertThat(ObjectPath.evaluate(dataStreams, "data_streams.0.indices"), hasSize(1));
129+
assertThat(ObjectPath.evaluate(dataStreams, "data_streams.0.template"), equalTo(templateId));
130+
}
131+
118132
static void createTemplate(String dataStreamName, String id, String template) throws IOException {
119133
final String INDEX_TEMPLATE = """
120134
{
135+
"priority": 200,
121136
"index_patterns": ["$DATASTREAM"],
122137
"template": $TEMPLATE,
123138
"data_stream": {

0 commit comments

Comments
 (0)