-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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 getNextValue()
to increase the number of milliseconds if needed
#18588
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch
Is there a test that reproduces the issue? |
I stumbled over it on
I can add however a test in |
2b3dd7c
to
138c307
Compare
@@ -55,6 +56,7 @@ protected Object getGreaterValue(Object value) | |||
} | |||
|
|||
@Override | |||
@Test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we ensure automatically that this doesn't happen?
The method is silently ignored if not annotated with @Test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn’t be overriding tests like that. If necessary, add new tests specific for the type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't follow.
This is pre-existing functionality.
Please add more detail to the comment.
Simply create a new method instead of doing overrides?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just responding to your comment about "ensuring automatically it doesn't happen". Structuring tests that way is not a good practice. It makes it hard to reason about which tests apply where (in some cases, the tests in AbstractXXX apply, in others they are completely overwritten, etc. -- usual arguments about using inheritance for reusing behavior in other contexts). We should fix them separately and not do that going forward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is how ATDQ, BCT and other similar "super" test classes are designed to work. We'll need to rethink how to structure those before those can be migrated over safely - since without that it's hard to have re-usable tests which also evolve over time (e.g. testRange
is overridden today to throw SkipException but in future once the feature is there the override can be removed).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc: @ksobolew any ideas to how to get this to work or how to restructure tests to avoid subclassing when using JUnit5?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I can see that the implementations in the base class assert that the relevant properties of the type are Optional.empty()
. They could, instead, do some assertions if it's not empty, and use some protected methods to get the expected result. But I'm not sure if that would work with all the types. It's kind of similar to how hasBehavior
is used in connector tests...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see there's already #18594 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is how ATDQ, BCT and other similar "super" test classes are designed to work. We'll need to rethink how to structure those before those can be migrated over safely
I can think of many different, more "pure" approaches.
The whole idea of BCT is impure and we could remove it. Connectors should have tests for features they implement.
Of course, this is straw-man's proposal. While letting us free of test overrides, this would lead to much worse test coverage.
138c307
to
4d6ae7d
Compare
@@ -16,6 +16,7 @@ | |||
import io.trino.spi.block.Block; | |||
import io.trino.spi.block.BlockBuilder; | |||
import io.trino.spi.type.Type.Range; | |||
import org.junit.jupiter.api.Test; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me, these all run properly as is if you change the parent class AbstractTestType
to use the org.testng.annotations.Test
annotation instead of the junit org.junit.jupiter.api.Test
annotation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, but that’s not how junit works — and we’re in the process of replacing testng with junit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should invest into writing a checker for this for the transition period like we have multiple for TestNG already. It seems very easy to do a migration but not realize multiple tests aren't running anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is a huge landmine. I already stepped on it some time ago and we briefly discussed countermeasures, but nothing came out of it. I suppose we could write an Error Prone check for this (I am surprised that there is no one already).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e237c0a
to
755d5e6
Compare
Rebased on |
core/trino-spi/src/main/java/io/trino/spi/type/LongTimestampWithTimeZoneType.java
Show resolved
Hide resolved
core/trino-main/src/test/java/io/trino/type/TestLongTimestampWithTimeZoneType.java
Show resolved
Hide resolved
9224a3a
to
7a2bfab
Compare
7a2bfab
to
d9f6b90
Compare
Description
This is a potential correctness issue when using as input
getNextValue()
will returneven though it should have been returning
Additional context and related issues
Cherry-picked from #14648
PR contains as well a cherry-pick from #18594 for JUnit5 related changes.
Release notes
(x) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text: