Skip to content

test: Add Database Tests For Container Images - Postgres, Redis, Valkey, Memcached - #18001

Open
MadhurAggarwal wants to merge 2 commits into
4.0from
madagg/container-database-tests
Open

test: Add Database Tests For Container Images - Postgres, Redis, Valkey, Memcached#18001
MadhurAggarwal wants to merge 2 commits into
4.0from
madagg/container-database-tests

Conversation

@MadhurAggarwal

@MadhurAggarwal MadhurAggarwal commented Jul 13, 2026

Copy link
Copy Markdown
Member

Commit 1 - Added Container Runtime Tests for 4 DataStores:

  • Valkey
  • Redis (available as valkey-compat-redis)
  • Postgres
  • Memcached

Also Added a new fixture: client_server_shell_exec:

  • Creates 2 Contains, named client and server respectively
  • Connects them to same network
  • Returns their respective shell exec callable, and server container name for dns

Each added test contains:

  • Docker file to install the corresponding package
  • Test file, which starts the server for each datastore, and contains 2 tests - Version Test to check the sanity / installation, and a Core Functionality Test (Create-Insert-Select for Postgres, LPUSH for Redis/Valkey, and Set-Get for Memcached)
  • Also Included Cross Container Tests for Postgres, Redis, Valkey which use the new fixture to test for client-server connections.

PR Testing:
Locally built a container images and tested using azldev tool:

  • Memcached Tests
image
  • Postgres Tests
image
  • Redis Tests
image
  • Valkey Tests
image

Commit 2 - Fixed Pyright Errors:

  • Untyped Fixture Param (reportUnknownParameterType, reportMissingParameterType)
  • Incorrect Param / Return Type (reportArgumentType, reportReturnType, reportInvalidTypeForm, reportCallIssue)
  • Deprecated Access Method (reportAttributeAccessIssue)

Previous Pyright Errors (Grouped):
image

Fixed All Pyright Errors in latest commit:
image

Copilot AI review requested due to automatic review settings July 13, 2026 09:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds container runtime coverage for four datastore packages.

Changes:

  • Adds version and core functionality tests for Valkey, Redis compatibility, PostgreSQL, and Memcached.
  • Adds Dockerfiles installing each datastore package.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test_valkey/test_valkey.py Tests Valkey startup, version, and list operations.
test_valkey/Dockerfile Installs Valkey.
test_redis/test_redis.py Tests Redis-compatible commands and list operations.
test_redis/Dockerfile Installs the Redis compatibility package.
test_postgres/test_postgres.py Tests PostgreSQL initialization, connectivity, and SQL operations.
test_postgres/Dockerfile Installs PostgreSQL client and server.
test_memcached/test_memcached.py Tests Memcached startup and set/get behavior.
test_memcached/Dockerfile Installs Memcached and Ncat.

Comment thread base/images/tests/cases/runtime/container-base/test_memcached/test_memcached.py Outdated
Copilot AI review requested due to automatic review settings July 13, 2026 09:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Comment thread base/images/tests/cases/runtime/container-base/test_valkey/test_valkey.py Outdated
Comment thread base/images/tests/cases/runtime/container-base/test_redis/test_redis.py Outdated
Comment thread base/images/tests/cases/runtime/container-base/test_memcached/test_memcached.py Outdated
Comment thread base/images/tests/cases/runtime/container-base/test_postgres/test_postgres.py Outdated
@MadhurAggarwal
MadhurAggarwal marked this pull request as ready for review July 13, 2026 12:20
@MadhurAggarwal
MadhurAggarwal requested a review from a team as a code owner July 13, 2026 12:20
@MadhurAggarwal MadhurAggarwal changed the title Madagg/container database tests Add Database Runtime Tests for Container Images - Postgres, Redis, Valkey, Memcached Jul 13, 2026
@MadhurAggarwal MadhurAggarwal changed the title Add Database Runtime Tests for Container Images - Postgres, Redis, Valkey, Memcached Add Database Tests for Container Images - Postgres, Redis, Valkey, Memcached Jul 13, 2026
@MadhurAggarwal MadhurAggarwal changed the title Add Database Tests for Container Images - Postgres, Redis, Valkey, Memcached feat: Add Database Tests for Container Images - Postgres, Redis, Valkey, Memcached Jul 13, 2026
Copilot AI review requested due to automatic review settings July 14, 2026 05:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.



@pytest.mark.dockerfile()
def test_redis_lpush(container_exec_shell) -> None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Current 4.0 DB ports validate redis/valkey/postgres/memcached via localhost inside one container.
3.0 golden tests included network-path coverage (separate client/server containers or host->container path).
@christopherco Do we want to keep 4.0 scope as package/runtime smoke only, or should we add at least one cross-container connectivity test per DB for parity

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've created a fixture client_server_exec_shell and used it for cross-container tests in Postgres, Redis and Valkey.
I have not yet added any cross-container tests for memcached since the 3.0 implementation doesn't have it either. Should I add that as well?

Copilot AI review requested due to automatic review settings July 15, 2026 09:29
@MadhurAggarwal
MadhurAggarwal force-pushed the madagg/container-database-tests branch from 9add5b3 to 5976ce1 Compare July 15, 2026 09:29
@MadhurAggarwal MadhurAggarwal changed the title feat: Add Database Tests for Container Images - Postgres, Redis, Valkey, Memcached Test: Add Database Tests For Container Images - Postgres, Redis, Valkey, Memcached Jul 15, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

@MadhurAggarwal MadhurAggarwal changed the title Test: Add Database Tests For Container Images - Postgres, Redis, Valkey, Memcached test: Add Database Tests For Container Images - Postgres, Redis, Valkey, Memcached Jul 15, 2026
Comment thread base/images/tests/cases/runtime/container-base/test_postgres/test_postgres.py Outdated
Comment thread base/images/tests/cases/runtime/container-base/test_memcached/test_memcached.py Outdated
Comment thread base/images/tests/cases/runtime/container-base/test_memcached/test_memcached.py Outdated
Comment thread base/images/tests/cases/runtime/container-base/test_valkey/test_valkey.py Outdated
Comment thread base/images/tests/cases/runtime/container-base/test_memcached/test_memcached.py Outdated
Copilot AI review requested due to automatic review settings July 21, 2026 09:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Comment thread base/images/tests/README.md Outdated
Copilot AI review requested due to automatic review settings July 21, 2026 09:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Comment thread base/images/tests/conftest.py Outdated
return resolve_image_reference(podman_client, image_path=image_path, image_ref=image_ref)


def _effective_image(podman_client, container_image_ref: str, request: pytest.FixtureRequest) -> str:
Comment thread base/images/tests/conftest.py Outdated
network_name = f"azl-test-net-{uuid.uuid4().hex[:12]}"
podman_client.network.create(network_name)

def _exec_shell_for(container):
@MadhurAggarwal

MadhurAggarwal commented Jul 21, 2026

Copy link
Copy Markdown
Member Author

I have resolved the previous comments and made the following changes:

  • Extracted the Polling helper into a general function wait_until_service_ready and used this across all 4 DB Tests.
  • Created a new fixture: client_server_exec_shell which creates 2 containers connected by a network.
  • Used the new fixture to run cross-container (network) tests on Postgres, Redis and Valkey. Note that, for Postgres, there is a DB Config Change required in order to allow these network tests to work, hence I've kept both local-host & cross-container test versions. For Redis & Valkey however, no such config change is required so only cross-container tests have been kept. (There is still a version check that runs on local-host server)
  • Didn't yet add any cross-container tests for memcached since no such test was present for 3.0 as well. If this is required, do let me know.
  • I've created a shared helper function (example: _effective_image and _run_crud_workflow) where-ever required to avoid code duplications.

I've tested these changes and updated the PR body with latest test run logs images.

Copilot AI review requested due to automatic review settings July 21, 2026 10:36
@MadhurAggarwal
MadhurAggarwal force-pushed the madagg/container-database-tests branch from 91aeae6 to ecd40ba Compare July 21, 2026 10:51
@MadhurAggarwal

MadhurAggarwal commented Jul 21, 2026

Copy link
Copy Markdown
Member Author

(rebased & resolved merge conflicts and copilot comments)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (2)

base/images/tests/conftest.py:312

  • Unlike pytest-injected test parameters, this is an ordinary helper parameter. podman_client has no type, so Pyright reports reportMissingParameterType here under pyrightconfig.json:16; annotate it as DockerClient and import that type.
def _effective_image(podman_client, container_image_ref: str, request: pytest.FixtureRequest) -> str:

base/images/tests/conftest.py:449

  • This nested helper is not fixture-injected, and its untyped container parameter causes Pyright's reportMissingParameterType plus an unknown container_name member access. Annotate it with ContainerInstance and give both nested callables concrete ContainerExecResult/Callable return types.
    def _exec_shell_for(container):
        def _exec_shell(command: str, *, shell: str = "bash"):
            return exec_in_container(podman_client, container.container_name, [shell, "-c", command])
        return _exec_shell

@tobiasb-ms tobiasb-ms left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue(blocking): In addition to my code comments, most of the commits in this PR don't conform to conventional commits, which is required. Most likely you want to do a squash rebase anyway, but either way fix that please.

Comment thread base/images/tests/cases/runtime/container-base/test_postgres/test_postgres.py Outdated
Comment thread base/images/tests/cases/runtime/container-base/test_postgres/test_postgres.py Outdated
Comment thread base/images/tests/cases/runtime/container-base/test_postgres/test_postgres.py Outdated
Comment thread base/images/tests/cases/runtime/container-base/test_postgres/test_postgres.py Outdated
Comment thread base/images/tests/cases/runtime/container-base/test_postgres/test_postgres.py Outdated
Comment thread base/images/tests/utils/container_runtime.py
Comment thread base/images/tests/conftest.py
Copilot AI review requested due to automatic review settings July 22, 2026 07:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

base/images/tests/conftest.py:312

  • This new non-fixture helper leaves podman_client untyped, which adds a reportMissingParameterType/reportUnknownParameterType error under pyrightconfig.json:16-18. The Python guidance requires touched files not to introduce new Pyright violations (.github/instructions/python.instructions.md:12-18,29); annotate this parameter as DockerClient.
def _effective_image(podman_client, container_image_ref: str, request: pytest.FixtureRequest) -> str:

base/images/tests/conftest.py:449

  • container is an untyped parameter on this newly added helper, so Pyright reports missing/unknown parameter types here (pyrightconfig.json:16-18). Please annotate it as ContainerInstance and give the helper a concrete callable return type; this also makes the yielded fixture contract checkable.
    def _exec_shell_for(container):
        def _exec_shell(command: str, *, shell: str = "bash"):
            return exec_in_container(podman_client, container.container_name, [shell, "-c", command])
        return _exec_shell

Copilot AI review requested due to automatic review settings July 22, 2026 10:45
@MadhurAggarwal
MadhurAggarwal force-pushed the madagg/container-database-tests branch from 5a7ec6d to 921ceea Compare July 22, 2026 10:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

base/images/tests/conftest.py:312

  • _effective_image is a regular helper (not a pytest-injected test function), but its new podman_client parameter has no concrete type. This produces a reportMissingParameterType error under pyrightconfig.json:16, contrary to the touched-file requirement in .github/instructions/python.instructions.md:12-18,29. Import and use DockerClient here so this refactor remains type-checkable.
def _effective_image(podman_client, container_image_ref: str, request: pytest.FixtureRequest) -> str:

Copilot AI review requested due to automatic review settings July 22, 2026 10:53
@MadhurAggarwal

Copy link
Copy Markdown
Member Author

Squashed into one commit

issue(blocking): In addition to my code comments, most of the commits in this PR don't conform to conventional commits, which is required. Most likely you want to do a squash rebase anyway, but either way fix that please.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

for attempt in range(attempts):
if attempt:
time.sleep(delay)
result = exec_shell(command)

@tobiasb-ms tobiasb-ms left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for updating everything. There's still one blocking thing: #18001 (comment), and I left a non-blocking question as well.



@contextlib.contextmanager
def _postgres_password_file(container_exec_shell, password: str):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

question(non-blocking): Do you think this could be more generically useful? What this function does is:

  1. Create a temp file name on the container (completely generic)
  2. Put a string into that file (already parameterized)
  3. Change the owner of that file (could easily be parameterized)
  4. Removes that file as the owner (could be parameterized along with 3)

If you parameterized 3 (and therefor 4), then this function is simply something like container_temp_file and any test can use it.

I'm totally fine punting that though -- we don't actually know we'll need it for anything else -- but keep it in mind if you see opportunities for it in the future.

Copilot AI review requested due to automatic review settings July 31, 2026 15:00

This comment was marked as resolved.

Copilot AI review requested due to automatic review settings August 1, 2026 04:24
@MadhurAggarwal
MadhurAggarwal force-pushed the madagg/container-database-tests branch from 327f37e to 754e392 Compare August 1, 2026 04:24

This comment was marked as resolved.

Copilot AI review requested due to automatic review settings August 1, 2026 04:46
@MadhurAggarwal
MadhurAggarwal force-pushed the madagg/container-database-tests branch from 754e392 to b7ab464 Compare August 1, 2026 04:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Ready to approve

The datastore tests and shared fixture changes consistently cover the stated local and cross-container scenarios.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Review details
  • Files reviewed: 21/21 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

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.

4 participants