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

Refactor connection management in bqjdbc tests #186

Merged
merged 6 commits into from
Jan 4, 2024

Conversation

goomrw
Copy link
Contributor

@goomrw goomrw commented Dec 20, 2023

Tests in bqjdbc use redundant but slightly different code to manage connections; for example, compare BQForwardOnlyResultSetFunctionTest.NewConnection with BQScrollableResultSetFunctionTest.NewConnection.

These methods also assign connections to static variables, which makes accessing them annoying and hampers test parallelization.

A previous change introduced a ConnectionFromResources helper class that can replace this duplicated connection management code with instance-level connections. This might slow down tests in the short term but should allow parallelization later.

Best reviewed by commit!

Copy link
Contributor

@fzakaria fzakaria left a comment

Choose a reason for hiding this comment

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

I got to review this by commit -- you are right; too large otherwise

Use common `ConnectionFromResources.connect` method instead of a bespoke
`NewConnection` method.

Also, use instance variable/test case scoped connections and result sets instead
of static/suite scoped ones. This should help enable test parallelization
later. Local testing shows no reliable increase in
`BQScrollableResultSetFunctionTest` total runtime (~30 seconds
both before and after change).
Use common `ConnectionFromResources.connect` method instead of a bespoke
`NewConnection` method.

Also, use instance variable/test case scoped connections and result sets instead
of static/suite scoped ones. This should help enable test parallelization
later. Local testing shows no reliable increase in runtime (~30
seconds).

This was eased by the introduction of a second BQ connection with
legacy SQL disabled (`standardSqlConnection`). Not every test uses both
connections, so this is a little wasteful and risks introducing some
unreliability, but it isolates test better than continually closing
and reopening a static connection.
Use common `ConnectionFromResources.connect` method instead of a bespoke
`NewConnection` method.

Also, use instance variable/test case scoped connections and result sets instead
of static/suite scoped ones. This should help enable test parallelization
later. Local testing shows no reliable increase in runtime (~30
seconds).
Use common `ConnectionFromResources.connect` method instead of a bespoke
`NewConnection` method.

Also, use instance variable/test case scoped connections and result sets instead
of static/suite scoped ones. This should help enable test parallelization
later. Local testing shows no reliable increase in runtime (~12
seconds).

This was eased by the introduction of a second BQ connection with
legacy SQL disabled (`standardSqlConnection`). Not every test uses both
connections, so this is a little wasteful and risks introducing some
unreliability, but it isolates test better than continually closing
and reopening a static connection.
Use common `ConnectionFromResources.connect` method instead of a bespoke
`NewConnection` method.

Also, use instance variable/test case scoped connections and result sets instead
of static/suite scoped ones. This should help enable test parallelization
later. Local testing shows no reliable increase in total runtime (~6 seconds
both before and after change).
Now each @before method sets a single instance variable.
This is to address code review comments.
@goomrw goomrw force-pushed the goomrw-test-connection-refactor branch from bd122ed to e61041d Compare December 28, 2023 21:25
@goomrw goomrw merged commit 3ab8355 into main Jan 4, 2024
2 checks passed
@goomrw goomrw deleted the goomrw-test-connection-refactor branch January 4, 2024 17:36
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.

2 participants