|
13 | 13 |
|
14 | 14 | import org.elasticsearch.client.Request; |
15 | 15 | import org.elasticsearch.client.Response; |
| 16 | +import org.elasticsearch.client.ResponseException; |
16 | 17 | import org.elasticsearch.common.network.NetworkAddress; |
17 | 18 | import org.elasticsearch.common.xcontent.XContentHelper; |
18 | 19 | import org.elasticsearch.test.rest.ObjectPath; |
|
21 | 22 | import java.io.IOException; |
22 | 23 | import java.io.InputStream; |
23 | 24 | import java.time.Instant; |
| 25 | +import java.util.Locale; |
24 | 26 | import java.util.Map; |
25 | 27 |
|
26 | 28 | import static org.elasticsearch.upgrades.LogsIndexModeRollingUpgradeIT.enableLogsdbByDefault; |
@@ -73,7 +75,7 @@ public void testIndexing() throws Exception { |
73 | 75 | if (isOldCluster()) { |
74 | 76 | startTrial(); |
75 | 77 | enableLogsdbByDefault(); |
76 | | - createTemplate(dataStreamName, "3", TEMPLATE); |
| 78 | + createTemplate(dataStreamName, getClass().getSimpleName().toLowerCase(Locale.ROOT), TEMPLATE); |
77 | 79 |
|
78 | 80 | Instant startTime = Instant.now().minusSeconds(60 * 60); |
79 | 81 | bulkIndex(dataStreamName, 4, 1024, startTime); |
@@ -233,7 +235,13 @@ void query(String dataStreamName) throws Exception { |
233 | 235 | protected static void startTrial() throws IOException { |
234 | 236 | Request startTrial = new Request("POST", "/_license/start_trial"); |
235 | 237 | 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 | + } |
237 | 245 | } |
238 | 246 |
|
239 | 247 | static Map<String, Object> getIndexSettingsWithDefaults(String index) throws IOException { |
|
0 commit comments