Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Run node.psql in a different port #240

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

Closed
fabriziomello opened this issue Apr 23, 2025 · 5 comments · Fixed by #242
Closed

Run node.psql in a different port #240

fabriziomello opened this issue Apr 23, 2025 · 5 comments · Fixed by #242
Assignees

Comments

@fabriziomello
Copy link
Contributor

Now with #234 that make PostgresNode::port read-only is not possible to run PostgresNode::psql in a different port. We did this trick here in order to do some sanity checks after execute pg_upgrade to compare psql outputs but we should guarantee to use the same psql version (newest) over the new and old cluster to make sure the test output will be the same (psql output can change over major postgres versions).

Are there a workaround for it?

@dmitry-lipetsk
Copy link
Collaborator

Hello

PostgresNode::psql method works with the own Postgres instance (host name + port number), not with another one.

If you want to use an old psql utility to work with the new (another) Postgres instance - it requires another class, not PostgresNode.

It is not a diffucult to create it over the current testgres infrastructure. Just copy PostgresNode::psql method to another class and append the pair of new arguments - host and port. 5 min of works.

I think, here is needed to create a new class (PostgresUtilities?) with static methods those will call PostgreSQL utilities - psql and others.

@dmitry-lipetsk dmitry-lipetsk self-assigned this Apr 24, 2025
@dmitry-lipetsk
Copy link
Collaborator

Another way - we can add the new arguments 'host' and 'port' with default values to PostgresNode.psql

If they are not defined we will use host/port of this PostgresNode object.

@dmitry-lipetsk
Copy link
Collaborator

Image

dmitry-lipetsk added a commit to dmitry-lipetsk/testgres that referenced this issue Apr 25, 2025
This patch adds the support of using other host and port in the following methods:

- PostgresNode.psql (explicit new args: host and port)
- PostgresNode.safe_psql (indirectly through **kwargs)

It allows to run psql utility from one PostgreSQL instance to work with another one.

If explicit host and port are not defined (are None), PostgresNode will use own ones.

This patch closes postgrespro#240.
@dmitry-lipetsk
Copy link
Collaborator

Hello @fabriziomello,

Please see PR #242.

I think, it must solve your problem completely.

dmitry-lipetsk added a commit that referenced this issue Apr 28, 2025
* [FIX] Tests include testgres by right way through import

When we do not have root __init__.py tests must to import testgres through

"import testgres"

not through

"from <relative_path> import testgres"

* [#240] Using of node.psql with other host and port

This patch adds the support of using other host and port in the following methods:

- PostgresNode.psql (explicit new args: host and port)
- PostgresNode.safe_psql (indirectly through **kwargs)

It allows to run psql utility from one PostgreSQL instance to work with another one.

If explicit host and port are not defined (are None), PostgresNode will use own ones.

This patch closes #240.
@fabriziomello
Copy link
Contributor Author

Hello @fabriziomello,

Please see PR #242.

I think, it must solve your problem completely.

Thank you very much. It will help a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants