-
Notifications
You must be signed in to change notification settings - Fork 164
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
SNOW-1213120: Reuse connections in tests 3 #1819
base: master
Are you sure you want to change the base?
Conversation
|
||
@BeforeClass | ||
public static void setUpPreparedStatementConnection() throws SQLException { | ||
if (!connection.isClosed()) { |
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.
how can it be possible to have closed connection here? it should be renew by the base class before tests in this class?
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 actually was wondering about this as well because when I ran this locally it never failed, but running in github it was constantly showing "connection closed" errors. When I added println statements to see where the connection was getting closed while running on github it looked like PreparedMultiStmtArrowIT (which extends PreparedMultiStmtIT and essentially just runs the same tests with arrow as the result format) would run first and then close that shared connection, and for some reason the "BeforeClass" from BaseJDBCWithSharedConnectionIT wasn't running again for the second test suite.
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 it may happen for parameterized tests
then we can organize it in a different way in tests and have e.g. connections with specific result format set upfront
e.g. for parameterized tests we can recreate the connection in the constructor when necessary and it may involve not using the same base class that you have created before
I addressed it in the not merged PR https://github.com/snowflakedb/snowflake-jdbc/pull/1754/files#diff-b01b6456eab10190c84533701ca0d1a477f5463c060522920c63fa25ab6fc765, you can take an inspiration from this PR
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.
It's not actually running as a true parameterized test though. PreparedMultiStmtArrowIT simply extends PreparedMultiStmtIT and calls the super constructor passing in the "arrow" query format (
snowflake-jdbc/src/test/java/net/snowflake/client/jdbc/PreparedMultiStmtArrowIT.java
Line 7 in 1d5b695
public class PreparedMultiStmtArrowIT extends PreparedMultiStmtIT { |
I'm thinking if we want to change this, it might be better to simplify and refactor PreparedMultiStmtIT to actually be parameterized and run both json and arrow tests and to delete PreparedMultiStmtArrowIT, rather than to introduce an additional base class for the connection sharing. Unless there is some reason we want to keep the arrow tests as a distinct class?
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.
it's a great idea to go fully with parameterized tests. The reason why it's split may be will to use TestCategoryArrow, but it should not be the blocker - please rewrite the tests here.
The same case applies in MultiStatementArrowIT, ResultSetArrowIT, ResultSetArrowLatestIT, PreparedStatementArrow1IT, PreparedStatementArrow1LatestIT, PreparedStatementArrow2IT, StatementArrowIT
Based on that it is possible that we will need to think about another categories and it will affect distribution in #1735
public class OpenGroupCLIFuncIT extends BaseJDBCWithSharedConnectionIT { | ||
|
||
@Before | ||
public void setSessionTimezone() throws SQLException { |
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.
Could we execute it once, in @BeforeClass instead of setting it for every test?
Overview
SNOW-1213120
Pre-review self checklist
master
branchmvn -P check-style validate
)mvn verify
and inspecttarget/japicmp/japicmp.html
)SNOW-XXXX:
External contributors - please answer these questions before submitting a pull request. Thanks!
What GitHub issue is this PR addressing? Make sure that there is an accompanying issue to your PR.
Fixes #NNNN
Fill out the following pre-review checklist:
@SnowflakeJdbcInternalApi
(note that public/protected methods/fields in classes marked with this annotation are already internal)Please describe how your code solves the related issue.
Please write a short description of how your code change solves the related issue.