Skip to content

Expose PostgreSQL on default port in PostgreSqlQueryRunner.main#14037

Merged
hashhar merged 3 commits intotrinodb:masterfrom
vlad-lyutenko:vlad-lyutenko/fixed_port_local_env
Sep 13, 2022
Merged

Expose PostgreSQL on default port in PostgreSqlQueryRunner.main#14037
hashhar merged 3 commits intotrinodb:masterfrom
vlad-lyutenko:vlad-lyutenko/fixed_port_local_env

Conversation

@vlad-lyutenko
Copy link
Copy Markdown
Contributor

@vlad-lyutenko vlad-lyutenko commented Sep 7, 2022

Description

Previously ports were randomly bound, which made it harder to work on local environment. Now when running outside of the CI default ports will be used.

For now its initial change for Postgressql only, but it could be extended to others (like Mysql, Sqlserver e.t.c.)

Non-technical explanation

Release notes

(x) This is not user-visible 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:

# Section
* Fix some things. ({issue}`issuenumber`)

@cla-bot
Copy link
Copy Markdown

cla-bot bot commented Sep 7, 2022

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

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.

Useful change for local development. Thanks.

Some nits about comments.

@hashhar
Copy link
Copy Markdown
Member

hashhar commented Sep 7, 2022

cc: @ebyhr you might find this useful when running query runners locally.

@vlad-lyutenko Please update the PR description to also mention if you plan to make similar change to other query runners as well? I assume this PR is to gather feedback?

@findepi
Copy link
Copy Markdown
Member

findepi commented Sep 7, 2022

@vlad-lyutenko i am not super fond of the change.
it will make it impossible to run multiple instances of integration tests concurrently, something that i do from time to time.
(It will also make it impossible to run integration tests when you have a product env running)

It would make more sense to limit the change to PostgreSqlQueryRunner.main.

Or not do it at all. For local development purpose I leverage the cheat sheet https://gist.github.com/findepi/04c96f0f60dcc95329f569bb0c44a0cd :

#  run PostgreSQL
bin/ptl env up --environment singlenode-postgresql --without-trino

# Connect to PostreSQL with CLI
docker exec -itu postgres ptl-postgresql psql -U test -d test

# connect to PostgreSQL with Trino
open https://github.com/trinodb/trino/blob/master/README.md#running-the-full-server

findepi
findepi previously requested changes Sep 7, 2022
Copy link
Copy Markdown
Member

@findepi findepi left a comment

Choose a reason for hiding this comment

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

per

it will make it impossible to run multiple instances of integration tests concurrently

@hashhar
Copy link
Copy Markdown
Member

hashhar commented Sep 7, 2022

Limiting to main makes sense. Good point about concurrent tests (which can also happen if you run tests for entire module from CLI since by default we run tests in parallel).

Copy link
Copy Markdown
Member

@ebyhr ebyhr left a comment

Choose a reason for hiding this comment

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

+1 to limit the usage to query runner main class.

@wendigo
Copy link
Copy Markdown
Contributor

wendigo commented Sep 8, 2022

The whole point of this change is to make it easier to work with QueryRunners and connect to a containerized database on the default port. Limiting usage to main fulfill this need.

@cla-bot cla-bot bot added the cla-signed label Sep 8, 2022
@findepi findepi dismissed their stale review September 8, 2022 12:40

Addressed

@ebyhr
Copy link
Copy Markdown
Member

ebyhr commented Sep 8, 2022

Adding a new argument to TestingPostgreSqlServer looked fine, but TestingMySqlServer already has two arguments in the constructor. If we will apply this change to other connectors too, we may want to consider different approach. e.g. Introduce a new environment variable likes TESTCONTAINERS_USE_FIXED_PORT.

(Please ignore this comment if it's already considered)

Copy link
Copy Markdown
Contributor

@ssheikin ssheikin left a comment

Choose a reason for hiding this comment

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

LGTM, please squash corresponding commits.

@vlad-lyutenko vlad-lyutenko force-pushed the vlad-lyutenko/fixed_port_local_env branch from 0d7a9b0 to fa0ede5 Compare September 9, 2022 09:26
@vlad-lyutenko vlad-lyutenko force-pushed the vlad-lyutenko/fixed_port_local_env branch from d277e4f to eadf4c2 Compare September 12, 2022 08:52
@vlad-lyutenko
Copy link
Copy Markdown
Contributor Author

Applied comments. Please take a look again @hashhar @findepi @wendigo @ssheikin

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.

Adding a new argument to TestingPostgreSqlServer looked fine, but TestingMySqlServer already has two arguments in the constructor. If we will apply this change to other connectors too, we may want to consider different approach. e.g. Introduce a new environment variable likes TESTCONTAINERS_USE_FIXED_PORT.

(Please ignore this comment if it's already considered)

@ebyhr Do you mean checking for the env var directly in the query runner instead?
I do like the simplicity of setting a well-named self-explanatory env var like USE_FIXED_PORT.

We can revisit this when implementing this for other query runners.
I'm fine with current approach for now.

@vlad-lyutenko vlad-lyutenko force-pushed the vlad-lyutenko/fixed_port_local_env branch from bb7ba42 to 65288c5 Compare September 12, 2022 19:22
@ebyhr
Copy link
Copy Markdown
Member

ebyhr commented Sep 12, 2022

Do you mean checking for the env var directly in the query runner instead?

Yes, setting environment variables in Intellij's Run/Debug Configurations' looks enough to me.

We can revisit this when implementing this for other query runners.
I'm fine with current approach for now.

👍

@hashhar hashhar changed the title Expose postgresql in container on default port Expose PostgreSQL on default port in PostgreSqlQueryRunner.main Sep 13, 2022
Previously ports were randomly bound, which made it harder to work on
local environment. Now when running outside of the CI default ports will
be used.
@vlad-lyutenko vlad-lyutenko force-pushed the vlad-lyutenko/fixed_port_local_env branch from 65288c5 to 10a8161 Compare September 13, 2022 09:52
@ssheikin
Copy link
Copy Markdown
Contributor

Adding a new argument to TestingPostgreSqlServer looked fine, but TestingMySqlServer already has two arguments in the constructor. If we will apply this change to other connectors too, we may want to consider different approach. e.g. Introduce a new environment variable likes TESTCONTAINERS_USE_FIXED_PORT.

Do you mean checking for the env var directly in the query runner instead?

Yes, setting environment variables in Intellij's Run/Debug Configurations' looks enough to me.

I have another usecase which I poorly described here: #14037 (comment) and for me such environment variable would perfectly match to NOT limit the usage to query runner main class., but use in all factory methods, as with env var we can easily steer behaviour.

however

I'm fine with current approach for now.

because it's much concise and straight-forward as it is now.

@hashhar hashhar merged commit 262f1ab into trinodb:master Sep 13, 2022
@github-actions github-actions bot added this to the 396 milestone Sep 13, 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.

7 participants