Skip to content

Fix Flaky test: testDeserialization#2

Open
prathyushreddylpr wants to merge 4 commits intomainfrom
cxf_dev2
Open

Fix Flaky test: testDeserialization#2
prathyushreddylpr wants to merge 4 commits intomainfrom
cxf_dev2

Conversation

@prathyushreddylpr
Copy link
Owner

@prathyushreddylpr prathyushreddylpr commented Nov 2, 2023

Description

Fixed the flaky tests named testDeserialization inside SerializationTest.java and AttributeTest.java classes.

Root Cause

The test testDeserialization has been reported as flaky when run with the NonDex tool. The tests failed because of the serialization of Testbean and AttributeTestBean classes, where the order of elements in the serialized XML changes between runs. The contents of the serialized strings do not remain constant and hence the tests are failing.

Fix

To define a specific order for the XML elements when the classes TestBean1 and AttributeTestBean are serialized, we need to add the propOrder attribute to the @XmlType annotation. This attribute explicitly specifies the order in which fields should be serialized.

How this has been tested?

Java: openjdk version "11.0.20.1"
Maven: Apache Maven 3.6.3

  1. Module build - Successful
    Command used -
mvn install -pl core -am -DskipTests
  1. Regular test - Successful
    Command used -
mvn -pl rt/javascript/javascript-tests test -Dtest=org.apache.cxf.javascript.types.SerializationTest#testDeserialization
mvn -pl rt/javascript/javascript-tests test -Dtest=org.apache.cxf.javascript.types.AttributeTest#testDeserialization
  1. NonDex test - Failed
    Command used -
mvn -pl rt/javascript/javascript-tests edu.illinois:nondex-maven-plugin:2.1.7-SNAPSHOT:nondex -Dtest=org.apache.cxf.javascript.types.SerializationTest#testDeserialization

mvn -pl rt/javascript/javascript-tests edu.illinois:nondex-maven-plugin:2.1.7-SNAPSHOT:nondex -Dtest=org.apache.cxf.javascript.types.AttributeTest#testDeserialization -DnondexRuns=10

NonDex test passed after the fix.

Copy link

@zzjas zzjas left a comment

Choose a reason for hiding this comment

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

Other the comments in code, the fix looks ok to me and you can proceed to open a real PR. Once you open a real PR, please mark this tentative PR as Opened in your tentative_pr.csv file and also raise a PR to IDoFT marking this as Opened. Thanks!

Comment on lines +33 to +36
"element1",
"attribute1",
"element2",
"attribute2"
Copy link

Choose a reason for hiding this comment

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

I'm not sure what the style here should be, but did you check if you need an extra indentation here?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yes there were some styling rules for this repo and the indentation is provided adhering to all those rules, otherwise the build was failing.

Comment on lines +34 to +45
"stringItem",
"intItem",
"longItem",
"base64Item",
"optionalIntItem",
"optionalStringItem",
"optionalIntArrayItem",
"doubleItem",
"beanTwoItem",
"beanTwoNotRequiredItem",
"enumeration",
"enum2"
Copy link

Choose a reason for hiding this comment

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

same

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