Skip to content

[CI] FileSettingsServiceTests testInvalidJSON failing #120482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
elasticsearchmachine opened this issue Jan 20, 2025 · 8 comments · Fixed by #126719
Closed

[CI] FileSettingsServiceTests testInvalidJSON failing #120482

elasticsearchmachine opened this issue Jan 20, 2025 · 8 comments · Fixed by #126719
Assignees
Labels
:Core/Infra/Settings Settings infrastructure and APIs low-risk An open issue or test failure that is a low risk to future releases Team:Core/Infra Meta label for core/infra team >test-failure Triaged test failures from CI

Comments

@elasticsearchmachine
Copy link
Collaborator

elasticsearchmachine commented Jan 20, 2025

Build Scans:

Reproduction Line:

./gradlew ":server:test" --tests "org.elasticsearch.reservedstate.service.FileSettingsServiceTests.testInvalidJSON" -Dtests.seed=1305FC3681068953 -Dtests.locale=ar-IL -Dtests.timezone=Etc/GMT-1 -Druntime.java=23

Applicable branches:
main

Reproduces locally?:
No

Failure History:
See dashboard

Failure Message:

org.mockito.exceptions.misusing.UnfinishedStubbingException: 
Unfinished stubbing detected here:
-> at org.elasticsearch.reservedstate.service.FileSettingsServiceTests.testInvalidJSON(FileSettingsServiceTests.java:312)

E.g. thenReturn() may be missing.
Examples of correct stubbing:
    when(mock.isOk()).thenReturn(true);
    when(mock.isOk()).thenThrow(exception);
    doThrow(exception).when(mock).someVoidMethod();
Hints:
 1. missing thenReturn()
 2. you are trying to stub a final method, which is not supported
 3. you are stubbing the behaviour of another mock inside before 'thenReturn' instruction is completed

Issue Reasons:

  • [main] 4 failures in test testInvalidJSON (23.5% fail rate in 17 executions)

Note:
This issue was created using new test triage automation. Please report issues or feedback to es-delivery.

@elasticsearchmachine elasticsearchmachine added :Core/Infra/Settings Settings infrastructure and APIs >test-failure Triaged test failures from CI Team:Core/Infra Meta label for core/infra team needs:risk Requires assignment of a risk label (low, medium, blocker) labels Jan 20, 2025
@elasticsearchmachine
Copy link
Collaborator Author

Pinging @elastic/es-core-infra (Team:Core/Infra)

@elasticsearchmachine
Copy link
Collaborator Author

This has been muted on branch main

Mute Reasons:

  • [main] 4 failures in test testInvalidJSON (23.5% fail rate in 17 executions)

Build Scans:

@mosche mosche added low-risk An open issue or test failure that is a low risk to future releases and removed needs:risk Requires assignment of a risk label (low, medium, blocker) labels Jan 21, 2025
@prdoyle
Copy link
Contributor

prdoyle commented Jan 21, 2025

Works for me. 🤔

@prdoyle
Copy link
Contributor

prdoyle commented Jan 21, 2025

The stubbing code from FileSettingsServiceTests.java:312:

        doAnswer((Answer<?>) invocation -> {
            try {
                return invocation.callRealMethod();
            } finally {
                awaitOrBust(fileChangeBarrier);
            }
        }).when(fileSettingsService).onProcessFileChangesException(any());

I'm not seeing a problem here.

@prdoyle
Copy link
Contributor

prdoyle commented Apr 11, 2025

Here's a link to this code in the SHA reported in the build scans. It's definitely the code I pointed out above.

@prdoyle
Copy link
Contributor

prdoyle commented Apr 11, 2025

For the "hints":

Hints:
 1. missing thenReturn()
 2. you are trying to stub a final method, which is not supported
 3. you are stubbing the behaviour of another mock inside before 'thenReturn' instruction is completed
  1. I can't use thenReturn because it's a void method.
  2. The onProcessFileChangesException is not final.
  3. I am stubbing just this one method.

@prdoyle
Copy link
Contributor

prdoyle commented Apr 11, 2025

According to this guy, Mockito uses some static global state, and can't tolerate any kind of concurrent access.

If that's the case, perhaps I can reorder the mocking/stubbing in such a way as to avoid races with the ES logic that uses the mocks.

@prdoyle
Copy link
Contributor

prdoyle commented Apr 11, 2025

I opened a PR here against Mockito to add a hint about other threads.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Settings Settings infrastructure and APIs low-risk An open issue or test failure that is a low risk to future releases Team:Core/Infra Meta label for core/infra team >test-failure Triaged test failures from CI
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants