Skip to content

Commit 232622a

Browse files
authored
Tweak LogsdbIndexingRollingUpgradeIT and TsdbIndexingRollingUpgradeIT (#115785)
to fix following test bugs: * Deal with trail already started error. * Ensure k8s.pod.name field is mapped as keyword Closes #115755, #115756, #115757, #115758, #115758
1 parent 2b1dc5a commit 232622a

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/LogsdbIndexingRollingUpgradeIT.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import org.elasticsearch.client.Request;
1515
import org.elasticsearch.client.Response;
16+
import org.elasticsearch.client.ResponseException;
1617
import org.elasticsearch.common.network.NetworkAddress;
1718
import org.elasticsearch.common.xcontent.XContentHelper;
1819
import org.elasticsearch.test.rest.ObjectPath;
@@ -21,6 +22,7 @@
2122
import java.io.IOException;
2223
import java.io.InputStream;
2324
import java.time.Instant;
25+
import java.util.Locale;
2426
import java.util.Map;
2527

2628
import static org.elasticsearch.upgrades.LogsIndexModeRollingUpgradeIT.enableLogsdbByDefault;
@@ -73,7 +75,7 @@ public void testIndexing() throws Exception {
7375
if (isOldCluster()) {
7476
startTrial();
7577
enableLogsdbByDefault();
76-
createTemplate(dataStreamName, "3", TEMPLATE);
78+
createTemplate(dataStreamName, getClass().getSimpleName().toLowerCase(Locale.ROOT), TEMPLATE);
7779

7880
Instant startTime = Instant.now().minusSeconds(60 * 60);
7981
bulkIndex(dataStreamName, 4, 1024, startTime);
@@ -233,7 +235,13 @@ void query(String dataStreamName) throws Exception {
233235
protected static void startTrial() throws IOException {
234236
Request startTrial = new Request("POST", "/_license/start_trial");
235237
startTrial.addParameter("acknowledge", "true");
236-
assertOK(client().performRequest(startTrial));
238+
try {
239+
assertOK(client().performRequest(startTrial));
240+
} catch (ResponseException e) {
241+
var responseBody = entityAsMap(e.getResponse());
242+
String error = ObjectPath.evaluate(responseBody, "error_message");
243+
assertThat(error, equalTo("Trial was already activated."));
244+
}
237245
}
238246

239247
static Map<String, Object> getIndexSettingsWithDefaults(String index) throws IOException {

qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/TsdbIndexingRollingUpgradeIT.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@
1616
import org.elasticsearch.test.rest.ObjectPath;
1717

1818
import java.time.Instant;
19+
import java.util.Locale;
1920
import java.util.Map;
2021

2122
import static org.elasticsearch.upgrades.LogsIndexModeRollingUpgradeIT.getWriteBackingIndex;
22-
import static org.elasticsearch.upgrades.LogsdbIndexingRollingUpgradeIT.*;
23+
import static org.elasticsearch.upgrades.LogsdbIndexingRollingUpgradeIT.createTemplate;
24+
import static org.elasticsearch.upgrades.LogsdbIndexingRollingUpgradeIT.getIndexSettingsWithDefaults;
25+
import static org.elasticsearch.upgrades.LogsdbIndexingRollingUpgradeIT.startTrial;
2326
import static org.elasticsearch.upgrades.TsdbIT.TEMPLATE;
2427
import static org.elasticsearch.upgrades.TsdbIT.formatInstant;
2528
import static org.hamcrest.Matchers.equalTo;
@@ -42,7 +45,7 @@ public void testIndexing() throws Exception {
4245
String dataStreamName = "k9s";
4346
if (isOldCluster()) {
4447
startTrial();
45-
createTemplate(dataStreamName, "2", TEMPLATE);
48+
createTemplate(dataStreamName, getClass().getSimpleName().toLowerCase(Locale.ROOT), TEMPLATE);
4649

4750
Instant startTime = Instant.now().minusSeconds(60 * 60);
4851
bulkIndex(dataStreamName, 4, 1024, startTime);
@@ -52,6 +55,13 @@ public void testIndexing() throws Exception {
5255
assertThat(((Map<?, ?>) settings.get("settings")).get("index.mode"), equalTo("time_series"));
5356
assertThat(((Map<?, ?>) settings.get("defaults")).get("index.mapping.source.mode"), equalTo("SYNTHETIC"));
5457

58+
var mapping = getIndexMappingAsMap(firstBackingIndex);
59+
assertThat(
60+
"incorrect k8s.pod.name field in mapping:" + mapping,
61+
"keyword",
62+
equalTo(ObjectPath.evaluate(mapping, "properties.k8s.properties.pod.properties.name.type"))
63+
);
64+
5565
ensureGreen(dataStreamName);
5666
search(dataStreamName);
5767
query(dataStreamName);

0 commit comments

Comments
 (0)