Skip to content

Commit 2dd5c37

Browse files
authored
Make OTLPMetricsIndexingRestIT.testIngestMetricDataViaMetricExporter more resilient (#134435)
1 parent be9d4e9 commit 2dd5c37

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -513,9 +513,6 @@ tests:
513513
- class: org.elasticsearch.xpack.logsdb.qa.BulkDynamicMappingChallengeRestIT
514514
method: testDateHistogramAggregation
515515
issue: https://github.com/elastic/elasticsearch/issues/134389
516-
- class: org.elasticsearch.xpack.oteldata.otlp.OTLPMetricsIndexingRestIT
517-
method: testIngestMetricDataViaMetricExporter
518-
issue: https://github.com/elastic/elasticsearch/issues/134426
519516

520517
# Examples:
521518
#

x-pack/plugin/otel-data/src/javaRestTest/java/org/elasticsearch/xpack/oteldata/otlp/OTLPMetricsIndexingRestIT.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ public void testIngestMetricDataViaMetricExporter() throws Exception {
157157
ObjectPath search = search("metrics-generic.otel-default");
158158
assertThat(search.toString(), search.evaluate("hits.total.value"), equalTo(1));
159159
var source = search.evaluate("hits.hits.0._source");
160-
assertThat(evaluate(source, "@timestamp"), equalTo(timestampAsString(now)));
161-
assertThat(evaluate(source, "start_timestamp"), equalTo(timestampAsString(now)));
160+
assertThat(Instant.parse(evaluate(source, "@timestamp")), equalTo(Instant.ofEpochMilli(TimeUnit.NANOSECONDS.toMillis(now))));
161+
assertThat(Instant.parse(evaluate(source, "start_timestamp")), equalTo(Instant.ofEpochMilli(TimeUnit.NANOSECONDS.toMillis(now))));
162162
assertThat(evaluate(source, "_metric_names_hash"), isA(String.class));
163163
assertThat(ObjectPath.<Number>evaluate(source, "metrics.jvm\\.memory\\.total").longValue(), equalTo(totalMemory));
164164
assertThat(evaluate(source, "unit"), equalTo("By"));
@@ -413,10 +413,6 @@ private static Map<String, Object> getMapping(String target) throws IOException
413413
return mapping;
414414
}
415415

416-
private static String timestampAsString(long now) {
417-
return Instant.ofEpochMilli(TimeUnit.NANOSECONDS.toMillis(now)).toString();
418-
}
419-
420416
private void export(List<MetricData> metrics) throws Exception {
421417
CompletableResultCode result = exporter.export(metrics).join(10, TimeUnit.SECONDS);
422418
Throwable failure = result.getFailureThrowable();

0 commit comments

Comments
 (0)