Skip to content

Conversation

@phracek
Copy link
Member

@phracek phracek commented Jan 6, 2026

This pull request adds PyTest suite migrated from run_pytest scripts.

run_container_creation_tests -> test_container_configuration.py
run_general_tests -> test_container_general.py
run_change_password_test -> test_container_password.py
run_replication_test -> test_container_replication.py
run_s2i_test -> test_container_basics.py
run_test_cfg_hook -> test_container_configuration.py
run_s2i_bake_data_test -> test_container_ssl.py
run_s2i_enable_ssl_test -> test_container_ssl.py
run_pgaudit_test -> test_container_extensions.py
run_pgvector_test -> test_container_extensions.py
run_env_extension_load_test -> test_container_extensions.py
run_logging_test -> test_container_extensions.py

All tests are migrated except run_migration_test and run_upgrade_test.

The migration matrix is following:
run_container_creation_tests -> test_container_configuration.py
run_general_tests -> test_container_general.py
run_change_password_test -> test_container_password.py
run_replication_test -> test_container_replication.py
run_s2i_test -> test_container_basics.py
run_test_cfg_hook -> test_container_configuration.py
run_s2i_bake_data_test -> test_container_ssl.py
run_s2i_enable_ssl_test -> test_container_ssl.py
run_pgaudit_test -> test_container_extensions.py
run_pgvector_test -> test_container_extensions.py
run_env_extension_load_test -> test_container_extensions.py
run_logging_test -> test_container_extensions.py

The following tests are NOT migrated yet.
run_migration_test and run_upgrade_tests.

Signed-off-by: Petr "Stone" Hracek <[email protected]>
@github-actions
Copy link

github-actions bot commented Jan 6, 2026

Pull Request validation

Failed

🔴 Review - Missing review from a member (1 required)

Success

🟢 CI - All checks have passed

@phracek
Copy link
Member Author

phracek commented Jan 6, 2026

Let's try first round
[test-pytest]

@github-actions
Copy link

github-actions bot commented Jan 6, 2026

Testing Farm results

namecomposearchstatusstarted (UTC)timelogs
Fedora - PyTest - 16Fedora-latestx86_64✅ passed07.01.2026 13:53:427min 47stest pipeline
Fedora - PyTest - 15Fedora-latestx86_64✅ passed07.01.2026 13:53:498min 4stest pipeline
CentOS Stream 9 - PyTest - 13CentOS-Stream-9x86_64✅ passed07.01.2026 13:53:4211min 30stest pipeline
CentOS Stream 10 - PyTest - 16CentOS-Stream-10x86_64✅ passed07.01.2026 13:53:5810min 34stest pipeline
CentOS Stream 9 - PyTest - 15CentOS-Stream-9x86_64✅ passed07.01.2026 13:53:5411min 48stest pipeline
CentOS Stream 9 - PyTest - 16CentOS-Stream-9x86_64✅ passed07.01.2026 13:53:5011min 40stest pipeline
RHEL10 - Unsubscribed host - PyTest - 16RHEL-10-Nightlyx86_64✅ passed07.01.2026 13:53:4215min 45stest pipeline
RHEL8 - PyTest - 12RHEL-8.10.0-Nightlyx86_64✅ passed07.01.2026 13:53:4517min 17stest pipeline
RHEL8 - PyTest - 16RHEL-8.10.0-Nightlyx86_64✅ passed07.01.2026 13:53:4516min 2stest pipeline
RHEL9 - Unsubscribed host - PyTest - 13RHEL-9.6.0-Nightlyx86_64✅ passed07.01.2026 13:53:4217min 35stest pipeline
RHEL9 - Unsubscribed host - PyTest - 16RHEL-9.6.0-Nightlyx86_64✅ passed07.01.2026 13:53:4320min 52stest pipeline
RHEL9 - Unsubscribed host - PyTest - 15RHEL-9.6.0-Nightlyx86_64✅ passed07.01.2026 13:53:4319min 22stest pipeline
RHEL9 - PyTest - 15RHEL-9.6.0-Nightlyx86_64✅ passed07.01.2026 13:53:5721min 42stest pipeline
RHEL8 - PyTest - 15RHEL-8.10.0-Nightlyx86_64✅ passed07.01.2026 13:53:4317min 38stest pipeline
RHEL9 - PyTest - 13RHEL-9.6.0-Nightlyx86_64✅ passed07.01.2026 13:53:4320min 3stest pipeline
RHEL9 - PyTest - 16RHEL-9.6.0-Nightlyx86_64✅ passed07.01.2026 13:53:5421min 13stest pipeline
RHEL10 - PyTest - 16RHEL-10-Nightlyx86_64✅ passed07.01.2026 13:53:4314min 53stest pipeline
RHEL8 - PyTest - 13RHEL-8.10.0-Nightlyx86_64✅ passed07.01.2026 13:53:4817min 54stest pipeline

Don not call the function twice

Signed-off-by: Petr "Stone" Hracek <[email protected]>
@phracek phracek force-pushed the container_pytests branch from d7126c2 to a7a86fd Compare January 7, 2026 13:52
@phracek
Copy link
Member Author

phracek commented Jan 7, 2026

Let's try next round
[test-pytest]

Comment on lines 159 to 177
def test_correct_configuration_tests(
self,
psql_user,
psql_password,
psql_database,
psql_admin_password,
):
"""
Test correct configuration combinations for PostgreSQL container.
"""
assert self.db.assert_container_creation_succeeds(
container_args=[
psql_user,
psql_password,
psql_database,
psql_admin_password,
],
command="",
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Unlike in the bash tests, this doesn't try to actually connect to the container after creation as test_connection_func and connection_params are missing. This causes a case that fails in the bash tests to pass here.

Reproducer:

psql_user="the@user"
psql_password="pass"
psql_database="db"

Output from pytests:

PASSED test_container_configuration.py::TestPostgreSQLConfigurationContainer::test_correct_configuration_tests[-e POSTGRESQL_USER="the@user"--e POSTGRESQL_PASSWORD="the pass"--e POSTGRESQL_DATABASE="the db"--e POSTGRESQL_ADMIN_PASSWORD=]

Output from bash tests:

Created container 99890eb43cc9bc0a105aa15ef49954f88516d4bd16da3e1058786519646207e9
  Testing PostgreSQL connection to 10.88.8.202...
    Trying to connect...
psql: error: could not translate host name "[email protected]" to address: Name or service not known

Obviously the bash tests don't handle it exactly correctly here, because input into the connection URI should be URI-encoded. But I would suggest adding a connection attempt here, too.

Copy link
Contributor

Choose a reason for hiding this comment

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

(I'd also recommend adding a test case for this, as the only reason I noticed this error was that pg18 complains about spaces in usernames and db names inside the connection URI, but other special character such as the @ were problematic before, too)

Copy link
Contributor

Choose a reason for hiding this comment

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

I introduce a way to fix this behaviour for the bash tests in #641. Also I added a new test there for special characters directly.

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense to me. I will do it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed by 8f8b048

Copy link
Contributor

Choose a reason for hiding this comment

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

This case now fails because the container is created correctly with environment variables, but the connection done with postgres://the@user@ip:5432/the/db obviously fails.

            [
                '"the@user"',
                '"the pass"',
                '"the/db"',
                "",
            ],

I'd say this is a discrepancy and the test should account for this by URI encoding the username and db name for consistency.

Copy link
Contributor

Choose a reason for hiding this comment

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

But that code is in container_lib

function

Signed-off-by: Petr "Stone" Hracek <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants