Skip to content

Test JDBC connection creations#14749

Merged
kokosing merged 2 commits intotrinodb:masterfrom
kokosing:origin/master/155_test_jdbc_connections
Oct 31, 2022
Merged

Test JDBC connection creations#14749
kokosing merged 2 commits intotrinodb:masterfrom
kokosing:origin/master/155_test_jdbc_connections

Conversation

@kokosing
Copy link
Copy Markdown
Member

Test JDBC connection creations

@cla-bot cla-bot bot added the cla-signed label Oct 25, 2022
@kokosing kokosing requested review from findepi and ssheikin October 25, 2022 12:12
@kokosing kokosing force-pushed the origin/master/155_test_jdbc_connections branch from d8d633b to 07b45f2 Compare October 25, 2022 19:56
Comment on lines 36 to 35
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does singleThreaded on a base class apply to child classes?
(i think it does not)

Comment on lines 177 to 178
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can this be simpler?
E.g. we don't have any extra credentials in the test, and also a StaticCredentialProvider was already constructed earlier.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I would prefer this testing plugin for postgresql to be as close to real as possible. We don't win much using things like StaticCredentialProvider and we may end up having completely two connectors for postgresql, which I would like to avoid.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See

@Test
public void forceTestNgToRespectSingleThreaded()
{
// TODO: Remove after updating TestNG to 7.4.0+ (https://github.com/trinodb/trino/issues/8571)
// TestNG doesn't enforce @Test(singleThreaded = true) when tests are defined in base class. According to
// https://github.com/cbeust/testng/issues/2361#issuecomment-688393166 a workaround it to add a dummy test to the leaf test class.
}
for the convention.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It is no longer needed.

@kokosing kokosing force-pushed the origin/master/155_test_jdbc_connections branch 2 times, most recently from 875bcba to 640cd3e Compare October 27, 2022 14:36
Copy link
Copy Markdown
Member Author

@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.

AC, PTAL

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It is no longer needed.

Comment on lines 177 to 178
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I would prefer this testing plugin for postgresql to be as close to real as possible. We don't win much using things like StaticCredentialProvider and we may end up having completely two connectors for postgresql, which I would like to avoid.

@kokosing kokosing force-pushed the origin/master/155_test_jdbc_connections branch 2 times, most recently from 54a2cde to 4e90d4d Compare October 27, 2022 14:40
Comment on lines 82 to 86
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

IllegalStateException(String message, Throwable cause)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There is a difference in semantic between suppressed exception and a cause exception. Neither of them fits in 100% here, however suppressed sounds to be closer ;)

Comment on lines 157 to 158
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Instead of creating a new TestingPostgreSqlPlugin can we combine these module and create a JdbcPlugin like this new JdbcPlugin("jdbc", combine(new PostgreSqlClientModule(), new TestingPostgreSqlModule())

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good one!

@kokosing kokosing force-pushed the origin/master/155_test_jdbc_connections branch from 4e90d4d to b525f99 Compare October 28, 2022 15:08
Copy link
Copy Markdown
Member Author

@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.

AC

Comment on lines 82 to 86
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There is a difference in semantic between suppressed exception and a cause exception. Neither of them fits in 100% here, however suppressed sounds to be closer ;)

Comment on lines 157 to 158
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good one!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should name contain h2?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

h2 is an implementation detail. There is no such connector like h2. It is more about testing the base jdbc framework, which we usually call jdbc in tests.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just thoughs aloud: these are trino statements, and reused for different connectors, however even for h2 and postgres numbers are really different. Would be great to reuse them somehow..

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Queries are the almost the same, however expected behavior is connector specific. I don't see a good way of doing this and keeping the code simple.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is it the last entry by intention? does it matter?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

To make sure that closed and connectionCreations are in a good shape. However it does not matter much. Tests will fail in case of any exception here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it does not matter too.

Copy link
Copy Markdown
Member Author

@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.

AC

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

To make sure that closed and connectionCreations are in a good shape. However it does not matter much. Tests will fail in case of any exception here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

h2 is an implementation detail. There is no such connector like h2. It is more about testing the base jdbc framework, which we usually call jdbc in tests.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Queries are the almost the same, however expected behavior is connector specific. I don't see a good way of doing this and keeping the code simple.

@kokosing kokosing force-pushed the origin/master/155_test_jdbc_connections branch 3 times, most recently from 8b3adeb to bd1a780 Compare October 31, 2022 09:55
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is ordering across @BeforeClass methods deterministic?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

clever - unfortunately I can't think of better ways to store this information either

Comment on lines 111 to 113
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is this significant for the test? Deserves some comment IMO.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I wanted to make sure that we always open connections in a deterministic manner. Like we read data on worker. I don't think it is needed and possibly it lowers the test coverage. So I will remove it.

That way it is possible to inject a different way to provision
ConnectionFactory in PostgreSql connector.
@kokosing kokosing force-pushed the origin/master/155_test_jdbc_connections branch from bd1a780 to c697cf6 Compare October 31, 2022 12:26
Copy link
Copy Markdown
Member

@hashhar hashhar left a comment

Choose a reason for hiding this comment

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

LGTM % some clarity around #14749 (comment) (@BeforeClass ordering)

@kokosing kokosing merged commit b92d259 into trinodb:master Oct 31, 2022
@kokosing kokosing deleted the origin/master/155_test_jdbc_connections branch October 31, 2022 14:28
@github-actions github-actions bot added this to the 402 milestone Oct 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

5 participants