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

fix flaky test #1517

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

prathyushreddylpr
Copy link
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.

@@ -90,7 +90,8 @@ public void testGetWsdl() throws Exception {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
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
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.

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