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

Removed JUnit5 dependency for ClientTpcConfigTest #26265

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

dr-divago
Copy link

Removed JUnit5 dependency for ClientTpcConfigTest

Fixes #26193

Checklist:

  • Labels (Team:, Type:, Source:, Module:) and Milestone set
  • Add Add to Release Notes label if changes should be mentioned in release notes or Not Release Notes content if changes are not relevant for release notes
  • Request reviewers if possible
  • New public APIs have @Nonnull/@Nullable annotations
  • New public APIs have @since tags in Javadoc
  • Send backports/forwardports if fix needs to be applied to past/future releases

…5) using org.junit.Assert.assertTrue (JUnit4);
@hz-devops-test hz-devops-test added the Source: Community PR or issue was opened by a community user label Feb 25, 2024
@devOpsHazelcast
Copy link
Collaborator

Can one of the admins verify this patch?

2 similar comments
@devOpsHazelcast
Copy link
Collaborator

Can one of the admins verify this patch?

@devOpsHazelcast
Copy link
Collaborator

Can one of the admins verify this patch?

@devOpsHazelcast
Copy link
Collaborator

devOpsHazelcast commented Feb 25, 2024

CLA assistant check
All committers have signed the CLA.

@devOpsHazelcast
Copy link
Collaborator

Internal PR hazelcast/hazelcast-mono#903
Internal message only. Nothing to see here, move along

@JackPGreen
Copy link
Contributor

@dr-divago thanks for your contribution!

It's great you've addressed these issues - had you considered amending the test referenced in #26193 to see if further examples could be caught going forwards?

@dr-divago
Copy link
Author

@JackPGreen Do you mean to check all the references of JUnit5 in the codebase? Or fixing com.hazelcast.NoMixedJUnitAnnotationsInOurTestSourcesTest.noJUnitMixing()?

@JackPGreen
Copy link
Contributor

@JackPGreen Do you mean to check all the references of JUnit5 in the codebase? Or fixing com.hazelcast.NoMixedJUnitAnnotationsInOurTestSourcesTest.noJUnitMixing()?

I thought fixing the noJUnitMixing test to find other scenarios and ensure this doesn’t happen again.

@dr-divago
Copy link
Author

Hi @JackPGreen
I have added chehck for assert in noJUnitMixing and including IT tests in the scanning

@JackPGreen
Copy link
Contributor

The job Hazelcast-mono-OS-pr-builder of your PR failed. (Hazelcast internal details: build log, artifacts).
Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log file
--------------------------
---------SUMMARY----------
--------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:3.3.1:checkstyle (default) on project hazelcast-archunit-rules: An error has occurred in Checkstyle report generation. Failed during checkstyle execution: There are 2 errors reported by Checkstyle 9.3 with /home/jenkins/jenkins_slave/workspace/Hazelcast-mono-OS-pr-builder_2/hazelcast/checkstyle/checkstyle.xml ruleset. -> [Help 1]
--------------------------
---------ERRORS-----------
--------------------------
[ERROR] /home/jenkins/jenkins_slave/workspace/Hazelcast-mono-OS-pr-builder_2/hazelcast/hazelcast-archunit-rules/src/main/java/com/hazelcast/test/archunit/MixTestAnnotationsCondition.java:24:17: Using the '.*' form of import should be avoided - org.junit.*. [AvoidStarImport]
--------------------------
[ERROR] /home/jenkins/jenkins_slave/workspace/Hazelcast-mono-OS-pr-builder_2/hazelcast/hazelcast-archunit-rules/src/main/java/com/hazelcast/test/archunit/MixTestAnnotationsCondition.java:39:59: Name 'JUNIT_4_ClASS_ANNOTATION' must match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'. [ConstantName]
--------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:3.3.1:checkstyle (default) on project hazelcast-archunit-rules: An error has occurred in Checkstyle report generation. Failed during checkstyle execution: There are 2 errors reported by Checkstyle 9.3 with /home/jenkins/jenkins_slave/workspace/Hazelcast-mono-OS-pr-builder_2/hazelcast/checkstyle/checkstyle.xml ruleset. -> [Help 1]
--------------------------
[ERROR] 
--------------------------
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
--------------------------
[ERROR] 
--------------------------
[ERROR] For more information about the errors and possible solutions, please read the following articles:
--------------------------
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
--------------------------
[ERROR] 
--------------------------
[ERROR] After correcting the problems, you can resume the build with the command
--------------------------
[ERROR]   mvn  -rf :hazelcast-archunit-rules
--------------------------

@dr-divago
Copy link
Author

Hi @JackPGreen
I updated the PR. How to access the build log?

@JackPGreen
Copy link
Contributor

Hi @JackPGreen I updated the PR. How to access the build log?

It's an internal tool unfortunately, but all tests have passed :)

Comment on lines 75 to 82
private boolean hasJUnit5Assertions(JavaClass item) {
Set<JavaMethodCall> methodCalls = item.getMethodCallsFromSelf();
return methodCalls.stream().anyMatch(call -> call.getTarget().getFullName().contains("org.junit.jupiter.api.Assertions"));
}
private boolean hasJUnit4Assertions(JavaClass item) {
Set<JavaMethodCall> methodCalls = item.getMethodCallsFromSelf();
return methodCalls.stream().anyMatch(call -> call.getTarget().getFullName().contains("org.junit.Assert"));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit - it's possible to centralise the logic into a single method that these can delegate to with different fullName parameters

Comment on lines 95 to 105
private boolean hasAnyJUnit4Annotations(JavaClass item) {
boolean hasJUnit4Annotation = item.getMethods().stream()
.anyMatch(method -> JUNIT_4_ANNOTATION_CLASSES.stream()
.anyMatch(method::isAnnotatedWith));

boolean hasJUnit4ClassAnnotation = item.getAnnotations().stream()
.anyMatch(annotation -> JUNIT_4_CLASS_ANNOTATION.stream()
.anyMatch(aa -> annotation.getRawType().isAssignableFrom(aa)));

return hasJUnit4Annotation || hasJUnit4ClassAnnotation;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

Comment on lines 94 to 95
}
private boolean hasAnyJUnit4Annotations(JavaClass item) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
}
private boolean hasAnyJUnit4Annotations(JavaClass item) {
}
private boolean hasAnyJUnit4Annotations(JavaClass item) {

Add some space between methods

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for finding and fixing these!

Comment on lines 31 to 33



Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

I don't think we need these extra blank lines?

@dr-divago
Copy link
Author

Hi @JackPGreen is something missing in the PR?

@JackPGreen
Copy link
Contributor

Hi @JackPGreen is something missing in the PR?

No, just waiting for a second reviewer.

@devOpsHazelcast
Copy link
Collaborator

This pull request has been closed because it was already closed as https://github.com/hazelcast/hazelcast-mono/pull/903

@dr-divago
Copy link
Author

@JackPGreen why the PR was closed?

@JackPGreen JackPGreen reopened this Mar 28, 2024
@JackPGreen
Copy link
Contributor

@JackPGreen why the PR was closed?

It’s open again now, apologies :)

@@ -20,8 +20,8 @@
import com.hazelcast.test.HazelcastTestSupport;
import com.hazelcast.test.annotation.ParallelJVMTest;
import com.hazelcast.test.annotation.QuickTest;
import org.junit.Test;
Copy link
Contributor

Choose a reason for hiding this comment

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

In this form it won't work:

  • Junit 4 test must be public
  • We use also ParameterizedTest in this class

Copy link
Author

Choose a reason for hiding this comment

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

You are right, I miss it. Do you suggest rewrite the test with Parameterized runner?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Source: Community PR or issue was opened by a community user
Projects
None yet
Development

Successfully merging this pull request may close these issues.

com.hazelcast.client.config.ClientTpcConfigTest mixes JUnit 4 & 5 assertions
5 participants