-
Notifications
You must be signed in to change notification settings - Fork 554
test: Allow passing of PostgreSQL port #3281
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
Conversation
Test failure in |
Hi @rominf – can you please explain why this change is necessary? I would argue that the tests are fine with the hardcoded port, since the tests work fine in our CI. |
Hi @szokeasaurusrex. There is no doubt related tests successfully run on your CI without the change. This is not always true for running these tests in other environments, such as developer machines and other CI/CD servers. While enabling PostgreSQL-dependent tests for Fedora's This issue is not specific to Fedora. In case there is some application running on the same machine with port Thus, this few-line change allows running these tests in environments where PostgreSQL has a non-default port and where other applications (including a PostgreSQL instance with the default port) have opened port [1] The macro is provided by https://packages.fedoraproject.org/pkgs/postgresql15/postgresql15-test-rpm-macros/, which packages https://github.com/devexp-db/postgresql-setup. Dynamic selection of the port was added in 2018: devexp-db/postgresql-setup#16 where you can find the reasoning (see |
Allow passing an arbitrary port via the `SENTPY_PYTHON_TEST_POSTGRES_PORT` environmental variable. Fedora's RPM macro `%postgresql_tests_run` which starts PostgreSQL dynamically selects PostgreSQL port to prevent start failures when running multiple PostgreSQL servers on the same default port [1]. This issue is not specific to Fedora. In case there is some application running on the same machine with port `5432` opened, such as PostgreSQL instance with the default port, this will result in failure to start the PostgreSQL server, resulting in an inability to run these tests. This change allows running these tests in environments where PostgreSQL has a non-default port and where other applications (including a PostgreSQL instance with the default port) have opened port `5432`, while at the same time keeping the old behavior as the default. [1] The macro is provided by https://packages.fedoraproject.org/pkgs/postgresql15/postgresql15-test-rpm-macros/, which packages https://github.com/devexp-db/postgresql-setup. Dynamic selection of the port was added in 2018: devexp-db/postgresql-setup#16, for the reasoning see `NEWS` file changes: https://github.com/devexp-db/postgresql-setup/pull/16/files#diff-7ee66c4f1536ac84dc5bbff1b8312e2eef24b974b3e48a5c5c2bcfdf2eb8f3ce).
5f7df61
to
aba417a
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3281 +/- ##
=======================================
Coverage 79.43% 79.43%
=======================================
Files 132 132
Lines 14280 14280
Branches 3002 3002
=======================================
Hits 11343 11343
Misses 2090 2090
Partials 847 847 |
Fair enough @rominf, my main concern is that adding this environment variable will provide only limited usefulness, since it is not documented anywhere. However, if this feature helps you, I can go ahead and merge it. It looks like we are already allowing other PostreSQL options to be configured via environment variable, so it is probably fine to allow the port to be set as well |
Allow passing an arbitrary port via the `SENTPY_PYTHON_TEST_POSTGRES_PORT` environmental variable. Fedora's RPM macro `%postgresql_tests_run` which starts PostgreSQL dynamically selects PostgreSQL port to prevent start failures when running multiple PostgreSQL servers on the same default port [1]. This issue is not specific to Fedora. In case there is some application running on the same machine with port `5432` opened, such as PostgreSQL instance with the default port, this will result in failure to start the PostgreSQL server, resulting in an inability to run these tests. This change allows running these tests in environments where PostgreSQL has a non-default port and where other applications (including a PostgreSQL instance with the default port) have opened port `5432`, while at the same time keeping the old behavior as the default. [1] The macro is provided by https://packages.fedoraproject.org/pkgs/postgresql15/postgresql15-test-rpm-macros/, which packages https://github.com/devexp-db/postgresql-setup. Dynamic selection of the port was added in 2018: devexp-db/postgresql-setup#16, for the reasoning see `NEWS` file changes: https://github.com/devexp-db/postgresql-setup/pull/16/files#diff-7ee66c4f1536ac84dc5bbff1b8312e2eef24b974b3e48a5c5c2bcfdf2eb8f3ce).
Allow passing an arbitrary port via the
SENTPY_PYTHON_TEST_POSTGRES_PORT
environmental variable.Fedora's RPM macro
%postgresql_tests_run
which starts PostgreSQL dynamically selects PostgreSQL port to prevent start failures when running multiple PostgreSQL servers on the same default port [1].This issue is not specific to Fedora. In case there is some application running on the same machine with port
5432
opened, such as PostgreSQL instance with the default port, this will result in failure to start the PostgreSQL server, resulting in an inability to run these tests.This change allows running these tests in environments where PostgreSQL has a non-default port and where other applications (including a PostgreSQL instance with the default port) have opened port
5432
, while at the same time keeping the old behavior as the default.[1] The macro is provided by https://packages.fedoraproject.org/pkgs/postgresql15/postgresql15-test-rpm-macros/,
which packages https://github.com/devexp-db/postgresql-setup. Dynamic selection of the port was added in 2018:
devexp-db/postgresql-setup#16, for the reasoningsee
NEWS
file changes: https://github.com/devexp-db/postgresql-setup/pull/16/files#diff-7ee66c4f1536ac84dc5bbff1b8312e2eef24b974b3e48a5c5c2bcfdf2eb8f3ce).General Notes
Thank you for contributing to
sentry-python
!Please add tests to validate your changes, and lint your code using
tox -e linters
.Running the test suite on your PR might require maintainer approval. Some tests (AWS Lambda) additionally require a maintainer to add a special label to run and will fail if the label is not present.
For maintainers
Sensitive test suites require maintainer review to ensure that tests do not compromise our secrets. This review must be repeated after any code revisions.
Before running sensitive test suites, please carefully check the PR. Then, apply the
Trigger: tests using secrets
label. The label will be removed after any code changes to enforce our policy requiring maintainers to review all code revisions before running sensitive tests.