Skip to content

[BUG] :modules:autotagging-commons:common: tests can't be executed in the same JVM #18441

Closed
@Mishail

Description

@Mishail

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

  1. Checkout the main branch

  2. Run ./gradlew :modules:autotagging-commons:common:test -Dtests.jvms=1

Expected behavior

Tests shall pass

Additional Details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    BuildBuild Tasks/Gradle Plugin, groovy scripts, build tools, Javadoc enforcement.bugSomething isn't workinguntriaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions