Skip to content

Flaky JUnit test testAppNamespace in AppNamespaceServiceWithCacheTest.java of module apollo-configservice #4997

@ThugJudy

Description

@ThugJudy

Flaky JUnit Tests identified in apollo-configservice.

  • I have checked the discussions
  • I have searched the issues of this repository and believe that this is not a duplicate.
  • I have checked the FAQ of this repository and believe that this is not a duplicate.

Describe the bug
In the course of test execution, the testAppNamespace within AppNamespaceServiceWithCacheTest advances to a point at line 197 in AppNamespaceServiceWithCache.
apollo/apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/service/AppNamespaceServiceWithCache.java

List ids = Lists.newArrayList(appNamespaceIdCache.keySet());

Here, it retrieves a set of keys, generating a hash result from the following that appears to be nondeterministic. The same hash in line 201 is partition divides the array into subarrays of a given size. When the order changes we can expect different subarrays.
I found and confirmed the flaky behavior using an open-source research tool NonDex, which shuffles implementations of nondeterminism operations.

To Reproduce
Steps to reproduce the behavior:

  1. Run the following command
mvn edu.illinois:nondex-maven-plugin:2.1.1:nondex -pl apollo-configservice -Dtest=com.ctrip.framework.apollo.configservice.service.AppNamespaceServiceWithCacheTest#testAppNamespace

Expected behavior
The testcase should pass everytime

Additional Details & Logs

Test Environment:

openjdk version "1.8.0_351"
Apache Maven 3.6.3
Operating System: macOS
Product Version: 13.5.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions