MAPREDUCE-7461: Fixed assertionComparision failure by resolving xml path for 'name' #6252
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Setup:
Java version: openjdk 11.0.20.1
Maven version: Apache Maven 3.6.3
Issue: https://issues.apache.org/jira/browse/MAPREDUCE-7461
Description of PR
The following tests can fail due to flakiness while comparing the contents of the generated XML response.
Module: hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app
org.apache.hadoop.mapreduce.v2.app.webapp.TestAMWebServicesJobs#testJobIdXML
org.apache.hadoop.mapreduce.v2.app.webapp.TestAMWebServicesJobs#testJobsXML
Module: hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs
org.apache.hadoop.mapreduce.v2.hs.webapp.TestHsWebServicesJobs#testJobIdXML
Steps to reproduce
git clone https://github.com/apache/hadoop
mvn install -pl hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app -am -DskipTests
mvn -pl hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app test -Dtests=org.apache.hadoop.mapreduce.v2.app.webapp.TestAMWebServicesJobs#testJobIdXML
mvn -pl hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app edu.illinois:nondex-maven-plugin:2.1.1:nondex -Dtest=org.apache.hadoop.mapreduce.v2.app.webapp.TestAMWebServicesJobs#testJobsIdXML
-DnondexMode=ONE
& FULL Mode-DnondexMode=FULL
(shuffles differently for each call)Root Cause
The test attempts to send a HTTP GET request to a specific URL and expects a response in XML format. However, elements in the XML response order is not necessarily guaranteed. The contents of the XML and the tags are compared with Job contents from
appContext
based on job Id in verifyAMJobXML / verifyHsJobXML. When comparing the the XML contents, The<name>
tag occurs in multiple places inside<job>
field. The current test utlization WebServicesTestUtils.java getXmlString always takes the first tag irrespective of whether it is nested tag or in the direct child tag which causes the test to fail and become flaky.Fix
Since WebServicesTestUtils.java getXmlString compares the first tag only which might not necessary be the direct child tag, The Fix uses Xpath to resolve the conflicts and identify the direct child tag. Thus the test passes since the direct child tag is always retrieved irrespective of xml order.
How was this patch tested?
The fix was tested by running the Nondex plugin again and ensuring that all the tests pass in FULL Mode and ONE Mode of the Nondex runs.