Skip to content

fix flaky test#1517

Closed
prathyushreddylpr wants to merge 1 commit intoapache:mainfrom
prathyushreddylpr:cxf_dev6
Closed

fix flaky test#1517
prathyushreddylpr wants to merge 1 commit intoapache:mainfrom
prathyushreddylpr:cxf_dev6

Conversation

@prathyushreddylpr
Copy link
Copy Markdown
Contributor

Description

Fixed the flaky test testGetWsdl inside NettyServerTest.java class.

Root Cause

The test testGetWsdl has been reported as flaky when run with the NonDex tool. The test failed because it is trying to find if a certain element(<service name"SOAPService">) is present inside the XML file which is returned by calling WSDL service. But there is slight change in the content of XML returned by the service. For example, in some cases the XML returned contained elements with :wsdl prefix. So instead of <service name"SOAPService"> , the XML content contained <wsdl:service name"SOAPService">. As a result the test is failed.

Fix

After debugging the code, it is clear that XML content with wsdl: prefix, means that the elements are qualified by the namespace, and when you see the same tags without the prefix, the XML is still using the WSDL namespace, but it's defined as the default namespace, so the prefix is not necessary. So, the test is fixed by adding a condition to check if the element with wsdl: is present.

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 core test -Dtest=org.apache.cxf.transport.http.netty.server.integration.NettyServerTest#testGetWsdl
  1. NonDex test - Failed
    Command used -
mvn -pl rt/transports/http-netty/netty-server edu.illinois:nondex-maven-plugin:2.1.7-SNAPSHOT:nondex -Dtest=org.apache.cxf.transport.http.netty.server.integration.NettyServerTest#testGetWsdl

NonDex test passed after the fix.

IOUtils.copyAndCloseInput(in, bos);
String result = bos.toString();
assertTrue("Expect the SOAPService", result.indexOf("<service name=\"SOAPService\">") > 0);
assertTrue("Expect the SOAPService", result.indexOf("<service name=\"SOAPService\">") > 0
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.

This might be an issue I believe, CXF should return consistent response (either qualified or unqualified namespaces), the test should not try to adapt to that.

@gnodet
Copy link
Copy Markdown
Contributor

gnodet commented Mar 11, 2026

We investigated the root cause of the flaky test as @reta suggested — CXF should return consistent WSDL output rather than the test adapting to inconsistency.

The issue is in ServiceWSDLBuilder: it uses a HashMap for namespace-to-prefix mapping (ns2prefix), which causes non-deterministic prefix assignment in generated WSDL. This leads to elements appearing with or without namespace prefixes (e.g., <service> vs <wsdl:service>) depending on HashMap iteration order.

A fix has been submitted in #2944 (switching to LinkedHashMap for deterministic ordering). Once that's merged, this flaky test issue should be resolved without needing to change the test itself.

@gnodet
Copy link
Copy Markdown
Contributor

gnodet commented Mar 11, 2026

Closing this PR — the root cause of the flaky test has been identified and fixed in #2944 (non-deterministic namespace prefix assignment in ServiceWSDLBuilder). With that fix, the WSDL output will be consistent and the test should no longer be flaky without needing to modify it.

Thanks @prathyushreddylpr for reporting the issue!

@gnodet gnodet closed this Mar 11, 2026
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.

3 participants