From c96bc675935a4b2682625aa99e99b03df71f7226 Mon Sep 17 00:00:00 2001 From: Simon Cooper Date: Fri, 1 Nov 2024 14:31:41 +0000 Subject: [PATCH] Include test features in feature name generation (#116078) (#116091) --- .../features/HistoricalFeaturesMetadataExtractor.java | 5 ++++- .../features/HistoricalFeaturesMetadataExtractorTests.java | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/test/metadata-extractor/src/main/java/org/elasticsearch/extractor/features/HistoricalFeaturesMetadataExtractor.java b/test/metadata-extractor/src/main/java/org/elasticsearch/extractor/features/HistoricalFeaturesMetadataExtractor.java index b3941371f9291..78d40df580bc0 100644 --- a/test/metadata-extractor/src/main/java/org/elasticsearch/extractor/features/HistoricalFeaturesMetadataExtractor.java +++ b/test/metadata-extractor/src/main/java/org/elasticsearch/extractor/features/HistoricalFeaturesMetadataExtractor.java @@ -29,6 +29,7 @@ import java.util.Map; import java.util.ServiceLoader; import java.util.Set; +import java.util.stream.Stream; public class HistoricalFeaturesMetadataExtractor { private final ClassLoader classLoader; @@ -92,7 +93,9 @@ void extractHistoricalFeatureMetadata(CheckedBiConsumer featureSpecLoader = ServiceLoader.load(FeatureSpecification.class, classLoader); for (FeatureSpecification featureSpecification : featureSpecLoader) { historicalFeatures.putAll(featureSpecification.getHistoricalFeatures()); - featureSpecification.getFeatures().stream().map(NodeFeature::id).forEach(featureNames::add); + Stream.concat(featureSpecification.getFeatures().stream(), featureSpecification.getTestFeatures().stream()) + .map(NodeFeature::id) + .forEach(featureNames::add); } metadataConsumer.accept(historicalFeatures, featureNames); } diff --git a/test/metadata-extractor/src/test/java/org/elasticsearch/extractor/features/HistoricalFeaturesMetadataExtractorTests.java b/test/metadata-extractor/src/test/java/org/elasticsearch/extractor/features/HistoricalFeaturesMetadataExtractorTests.java index a4cfcae198553..28e93a239b3d3 100644 --- a/test/metadata-extractor/src/test/java/org/elasticsearch/extractor/features/HistoricalFeaturesMetadataExtractorTests.java +++ b/test/metadata-extractor/src/test/java/org/elasticsearch/extractor/features/HistoricalFeaturesMetadataExtractorTests.java @@ -30,6 +30,7 @@ import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.hasEntry; +import static org.hamcrest.Matchers.hasItem; import static org.hamcrest.Matchers.hasKey; import static org.hamcrest.Matchers.not; @@ -48,6 +49,7 @@ public void testExtractHistoricalMetadata() throws IOException { }); assertThat(nodeFeatureVersionMap, not(anEmptyMap())); assertThat(featureNamesSet, not(empty())); + assertThat(featureNamesSet, hasItem("test_features_enabled")); Path outputFile = temporaryFolder.newFile().toPath(); extractor.generateMetadataFile(outputFile);