Closed
Description
Describe the bug
We were seeing test failures like the one below in our CI pipelines at times.
FeatureTypeTests > testGetAttributeFromName FAILED
java.lang.ExceptionInInitializerError
at __randomizedtesting.SeedInfo.seed([1C47D0A57D9987DB:69780A573F8E67F]:0)
at org.opensearch.rule.autotagging.RuleTests.<clinit>(RuleTests.java:34)
at org.opensearch.rule.autotagging.FeatureTypeTests.testGetAttributeFromName(FeatureTypeTests.java:31)
Caused by:
java.lang.IllegalStateException: Feature type test_feature_type is already registered. Duplicate feature type is not allowed.
at org.opensearch.rule.autotagging.AutoTaggingRegistry.registerFeatureType(AutoTaggingRegistry.java:47)
at org.opensearch.rule.autotagging.RuleTests$TestFeatureType.registerFeatureType(RuleTests.java:120)
at org.opensearch.rule.autotagging.RuleTests$TestFeatureType.<clinit>(RuleTests.java:95)
... 2 more
REPRODUCE WITH: ./gradlew ':modules:autotagging-commons:common:test' --tests "org.opensearch.rule.autotagging.FeatureTypeTests.testWriteTo"
or
> Task :modules:autotagging-commons:common:test
WARNING: Using incubator modules: jdk.incubator.vector
AutoTaggingRegistryTests > classMethod FAILED
java.lang.IllegalStateException: Feature type test_feature_type is already registered. Duplicate feature type is not allowed.
at __randomizedtesting.SeedInfo.seed([1D99C8199B8C111B]:0)
at org.opensearch.rule.autotagging.AutoTaggingRegistry.registerFeatureType(AutoTaggingRegistry.java:47)
at org.opensearch.rule.autotagging.AutoTaggingRegistryTests.setUpOnce(AutoTaggingRegistryTests.java:27)
Suite: Test class org.opensearch.rule.autotagging.AutoTaggingRegistryTests
2> java.lang.IllegalStateException: Feature type test_feature_type is already registered. Duplicate feature type is not allowed.
at __randomizedtesting.SeedInfo.seed([1D99C8199B8C111B]:0)
at org.opensearch.rule.autotagging.AutoTaggingRegistry.registerFeatureType(AutoTaggingRegistry.java:47)
at org.opensearch.rule.autotagging.AutoTaggingRegistryTests.setUpOnce(AutoTaggingRegistryTests.java:27)
After looking into that we found that there are two tests - AutoTaggingRegistryTests
and FeatureTypeTests
that are calling AutoTaggingRegistry.registerFeatureType
with a FeatureType
that has name TEST_FEATURE_TYPE
. And when those two tests are executed in the same JVM this problem happens
Related component
Build
To Reproduce
-
Checkout the main branch
-
Run
./gradlew :modules:autotagging-commons:common:test -Dtests.jvms=1
Expected behavior
Tests shall pass
Additional Details
No response