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 test false postives due to TestNG's #543 #7204

Closed

Conversation

ArturGajowy
Copy link
Contributor

@ArturGajowy ArturGajowy commented Jan 23, 2017

Because of TestNG #543 - Unexpected Behaviour: assertEquals for Iterable, ~20 tests are giving false positive results (all due to equality checks on MaterializedResult instances, which implement Iterable and because of that the 'types' field was not taken into account).

The error could potentially occur in ~30 test classes. All potential and actual false positives are fixed and a static analysis check is added to prevent further breakage.

Even if it seems that no real bugs snuck through the false positives, the fixed tests are made to assert the status quo - so extra attention should be given to changes in their source.

pom.xml Outdated
@@ -881,6 +881,7 @@
<javaVersion>1.8</javaVersion>
<failOnViolations>true</failOnViolations>
<exclusionsFile>${air.main.basedir}/src/modernizer/exclusions.txt</exclusionsFile>
<violationsFile>${air.main.basedir}/src/modernizer/violations.xml</violationsFile>
Copy link
Contributor

Choose a reason for hiding this comment

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

Add comment above <version>1.4.0</version> that violationsFile that violations file needs to be updated to match new version.
If we cannot do better.

@@ -0,0 +1,769 @@
<?xml version="1.0"?>
Copy link
Contributor

Choose a reason for hiding this comment

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

Split this to commit which imports original violations.xml and one which modifies it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@ArturGajowy ArturGajowy force-pushed the fix_test_false_postives_testng_543 branch 2 times, most recently from 2556f14 to 472e2d4 Compare January 23, 2017 14:59
@electrum
Copy link
Contributor

Change all the commit message subjects to be "by TestNG bug" since GitHub wants to link to a Presto issue.

@electrum
Copy link
Contributor

Instead of copy/pasting the default violations, we should update the modernizer plugin to support additional files. I submitted a PR the other day and he merged it quickly.

Copy link
Contributor

@electrum electrum left a comment

Choose a reason for hiding this comment

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

See comments

@ArturGajowy
Copy link
Contributor Author

@electrum comments addressed. modernizer 1.5.0 has been released, including the needed changes. The build should pass now.

Copy link
Contributor

@kokosing kokosing left a comment

Choose a reason for hiding this comment

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

It is nice that you have found it! I don't understand why testng is so popular.

pom.xml Outdated
@@ -875,12 +875,16 @@
<plugin>
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you should first fix tests and then add violations. That way every commit has a chance to build. So please reorder commits.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree all commits should build when merged to master, so that bisects work. I introduced the changes in this order so that I see the static checks I introduced catch anything. I left it this way so far so that anyone can easily re-verify it. Will now rearrange the commits.

<comment>Use com.facebook.presto.testing.assertions.Assert.assertEquals due to TestNG #543</comment>
</violation>

</modernizer>
Copy link
Contributor

Choose a reason for hiding this comment

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

now new line at the end

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -267,7 +267,7 @@
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
<scope>provided</scope>
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know why it is changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because the com.facebook.presto.testing.assertions.Assert class depends on TestNG's assertions, and it has to be in src/main so that other modules can use it

@@ -116,7 +116,7 @@ public void testInnerJoin(boolean parallelBuild, boolean probeHashEnabled, boole
);

// expected
MaterializedResult expected = MaterializedResult.resultBuilder(taskContext.getSession(), concat(probePages.getTypes(), buildPages.getTypes()))
MaterializedResult expected = MaterializedResult.resultBuilder(taskContext.getSession(), concat(probePages.getTypesWithoutHash(), buildPages.getTypesWithoutHash()))
Copy link
Contributor

Choose a reason for hiding this comment

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

can you please squash this commit with the previous one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But why? I wanted the changes to be atomic. Also I think getTypesWithoutHash method addition is worth mentioning in the commit log for the ones reading it :)

@ArturGajowy ArturGajowy force-pushed the fix_test_false_postives_testng_543 branch 2 times, most recently from b245e13 to e585e7c Compare January 25, 2017 12:37
@ArturGajowy
Copy link
Contributor Author

Rebased and addressed @kokosing's comments

@ArturGajowy ArturGajowy force-pushed the fix_test_false_postives_testng_543 branch from 3e882cf to c2d4ed2 Compare January 26, 2017 18:14
@ArturGajowy
Copy link
Contributor Author

@electrum rebased on master

@ArturGajowy
Copy link
Contributor Author

@electrum kindly ping

@electrum
Copy link
Contributor

Regarding this sentence in one of the commit descriptions: "Jto address diffrences between cassandra and other connectors."

"differences" has a typo. I'm assuming "Jto" is a typo as well.


public class Assert extends org.testng.Assert
{
private Assert()
Copy link
Contributor

Choose a reason for hiding this comment

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

Format like

private Assert() {}

*/
package com.facebook.presto.testing.assertions;

public class Assert extends org.testng.Assert
Copy link
Contributor

Choose a reason for hiding this comment

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

extends should go on next line

*/
package com.facebook.presto.testing.assertions;

public class Assert extends org.testng.Assert
Copy link
Contributor

Choose a reason for hiding this comment

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

Add

@SuppressWarnings({"MethodOverridesStaticMethodOfSuperclass", "ExtendsUtilityClass"})

*/
package com.facebook.presto.testing.assertions;

public class Assert extends org.testng.Assert
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a comment this class about why it is here

@ArturGajowy ArturGajowy force-pushed the fix_test_false_postives_testng_543 branch from c2d4ed2 to 73e70ce Compare February 13, 2017 14:21
@ArturGajowy
Copy link
Contributor Author

@electrum comments applied, back to you :)

@ArturGajowy ArturGajowy force-pushed the fix_test_false_postives_testng_543 branch from 73e70ce to 8d6556c Compare February 20, 2017 14:20
@ArturGajowy
Copy link
Contributor Author

@electrum rebased, kindly ping :)

@ArturGajowy
Copy link
Contributor Author

@electrum kindly ping

Extract parameterized test methods in AbstractTestQueries
to address differences between cassandra and other connectors.

See testng-team/testng#543.
This prevents false positive test results when comparing
iterables (most notably: MaterializedResult instances) due to
TestNG bug (testng-team/testng#543).

False-positive results were found in ~20 tests and are fixed
in the following commits.
@ArturGajowy ArturGajowy force-pushed the fix_test_false_postives_testng_543 branch from 8d6556c to 3367b57 Compare March 8, 2017 12:41
@ArturGajowy
Copy link
Contributor Author

@electrum rebased and resolved conflicts. Please have a look, all comments are addressed so far.

@ArturGajowy
Copy link
Contributor Author

@electrum kindly bump.

@findepi findepi changed the title Fix test false postives due to TestNG 543 Fix test false postives due to TestNG's #543 Apr 7, 2017
@electrum
Copy link
Contributor

electrum commented Apr 7, 2017

Merged, thanks!

@electrum electrum closed this Apr 7, 2017
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.

5 participants