Skip to content

Fix flaky test: testStylesheetDescriptor40ImportExport#2732

Merged
ChristianMurphy merged 2 commits into
uPortal-Project:masterfrom
KiruthikaJanakiraman:flaky
Nov 18, 2023
Merged

Fix flaky test: testStylesheetDescriptor40ImportExport#2732
ChristianMurphy merged 2 commits into
uPortal-Project:masterfrom
KiruthikaJanakiraman:flaky

Conversation

@KiruthikaJanakiraman

Copy link
Copy Markdown
Contributor
Checklist
Description of change

This PR aims to fix the flaky test: org.apereo.portal.io.xml.IdentityImportExportTest.testStylesheetDescriptor40ImportExport similar to previously raised PRs: #2718 and #2719

I found and confirmed the flaky behaviour of the tests using an open-source research tool NonDex, which shuffles implementations of nondeterminism operations.

Problem
The test case org.apereo.portal.io.xml.IdentityImportExportTest.testStylesheetDescriptor40ImportExport fails because the order of targetElements: channel and portlet in the exported xml varies upon nondeterministic shuffling.

<targetElement>channel</targetElement>
<targetElement>portlet</targetElement>

Solution
This PR fixes the flakiness by sorting the targetElements in exportData before comparing importData and exportData XMLs.

Steps to reproduce
The following command can be used to reproduce the assertion errors and verify the fix.

Integrate NonDex:

Add the following snippet to the top of the build.gradle in $PROJ_DIR:

plugins {
    id 'edu.illinois.nondex' version '2.1.1-1'
}

Append to build.gradle in $PROJ_DIR:

apply plugin: 'edu.illinois.nondex'

Execute Test with Gradle:

./gradlew --info uPortal-webapp:test --tests org.apereo.portal.io.xml.IdentityImportExportTest.testStylesheetDescriptor40ImportExport

Run NonDex:

./gradlew --info uPortal-webapp:nondexTest --tests=org.apereo.portal.io.xml.IdentityImportExportTest.testStylesheetDescriptor40ImportExport --nondexRuns=50 -x autoLintGradle

Test Environment:

Java version "1.8.0_381"
macOS Venture Version 13.4.1 (22F82)

Please let me know if you have any concerns or questions.

@KiruthikaJanakiraman KiruthikaJanakiraman changed the title Flaky Fix flaky test: testStylesheetDescriptor40ImportExport Nov 13, 2023
@ChristianMurphy ChristianMurphy requested a review from a team November 16, 2023 13:39

@ChristianMurphy ChristianMurphy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @KiruthikaJanakiraman! LGTM

A finer point here.
I'm not sure this is precisely a "flaky test".
Flaky implies the test fails.
uPortal is tested across multiple major versions of the JDK, multiple JDK implementations, on multiple operating systems, for tens of thousands of test runs. I haven't seen it fail.
It could be fair to say the test is under specified or under determined, and that in a hypothetical future it could fail, but it is not strictly flaky. 🙂

Pedantics aside, I appreciate the PRs! Keep them coming! 😁

@KiruthikaJanakiraman

Copy link
Copy Markdown
Contributor Author

Got it. In that case, "under determined" makes more sense. Thanks!

@ChristianMurphy ChristianMurphy merged commit db2b1c0 into uPortal-Project:master Nov 18, 2023
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 this pull request may close these issues.

2 participants