Skip to content
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

Flaky test fails intermittently in GitHub Action #821

Closed
johnjaylward opened this issue Oct 27, 2023 · 5 comments · Fixed by #824
Closed

Flaky test fails intermittently in GitHub Action #821

johnjaylward opened this issue Oct 27, 2023 · 5 comments · Fixed by #824

Comments

@johnjaylward
Copy link
Contributor

johnjaylward commented Oct 27, 2023

Test case passes on some runs and fails on others: org.json.junit.JSONObjectTest.issue654StackOverflowInputWellFormed

Appears to be due to differences in resources available on each run. The exception expected is a "JSONException", but that's because it is wrapping a "StackOverflowError". StackOverflowError is going to be dependent on the environment and may not hit consistently.

@rudrajyotib
Copy link
Contributor

I think this test case should be removed, as it never guarantees the behavior. To identify the max depth supported, we can test through configuration. And environment resource related runtime error expectation need not be tested.

@stleary
Copy link
Owner

stleary commented Oct 29, 2023

Might be better to see if the test can be fixed, although if you see a chance to add a unit test, that is fine too.

@johnjaylward
Copy link
Contributor Author

johnjaylward commented Oct 30, 2023

@stleary , I'm leaning towards just marking the test as a "skip/ignore" or removing it altogether. It seems like this test would need regular maintenance to ensure that it was consistently hitting stack overflows.

@Ignore("This test relies on system constraints and may not always pass.")
@Test(expected = JSONException.class) 
 public void issue654StackOverflowInputWellFormed() { 
     //String input = new String(java.util.Base64.getDecoder().decode(base64Bytes)); 
     final InputStream resourceAsStream = JSONObjectTest.class.getClassLoader().getResourceAsStream("Issue654WellFormedObject.json"); 
     JSONTokener tokener = new JSONTokener(resourceAsStream); 
     JSONObject json_input = new JSONObject(tokener); 
     assertNotNull(json_input); 
     fail("Excepected Exception."); 
 } 

@stleary
Copy link
Owner

stleary commented Oct 31, 2023

@johnjaylward Fair enough, better to silence the test, than have it fail intermittently.

@rudrajyotib
Copy link
Contributor

@johnjaylward - are you annotating the test with Ignore?

johnjaylward pushed a commit to johnjaylward/JSON-java that referenced this issue Nov 6, 2023
add ignore annotation to tests that may fail due to differences in machine resources and can't be controlled via the tests
johnjaylward pushed a commit to johnjaylward/JSON-java that referenced this issue Nov 6, 2023
add ignore annotation to tests that may fail due to differences in machine resources and can't be controlled via the tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants