Skip to content

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

Open
MadhurAggarwal wants to merge 1 commit into
4.0from
madagg/container-database-tests
Open

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

Conversation

@MadhurAggarwal

@MadhurAggarwal MadhurAggarwal commented Jul 13, 2026

Copy link
Copy Markdown
Member

Add Container Runtime Tests for 4 DataStores

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

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)

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

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

Also run ruff formatting tests:
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_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

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
break
time.sleep(1)
else:
output = ready.output if ready is not None else "<no attempts>"

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): When would ready be None here? We're guaranteed to do an at least one attempt right?

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.

I notice this in your other retry loops as well.

ready = None
for _ in range(10):
ready = container_exec_shell(f"printf 'version\\r\\nquit\\r\\n' | nc localhost {PORT}")
if ready.exit_code == 0 and "VERSION" in ready.output:

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): If exit_code is 0 and VERSION is not in the output, am I correct that something has gone seriously wrong? It may be a test issue or something at that point.

It feels like this should be broken up somehow -- exit_code being 0 means "the command worked". That's when you stop the loop. But then you need to make sure the command worked the way you thought it would -- an assert or something.

That said, you know more about this than I do, so I can definitely believe there's a great reason for doing it this way.

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.

I notice this in the redis and valkey tests too.

ready = container_exec_shell(f"printf 'version\\r\\nquit\\r\\n' | nc localhost {PORT}")
if ready.exit_code == 0 and "VERSION" in ready.output:
break
time.sleep(1)

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.

nit(non-blocking): You're sleeping an extra second here if it never works -- it will run the sleep and then immediately exit the loop. Non-blocking because this is tests.

Also happens in your other tests.

EXPECTED_LEN = "4"


def _start_valkey(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.

suggestion(non-blocking): Since both of these tests need valkey, consider doing it as a fixture.

assert start.exit_code == 0, f"memcached failed to start: {start.output}"

ready = None
for _ in range(10):

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.

suggestion(blocking): All of the _start_<thing> functions have a code block that is the same:

for _ in range(10):
    ready = container_exec_shell(<some_string>)
    if ready.exit_code == 0 and <optional other test>:
       break
    time.sleep(1)
else:
    failure case -- varies only by a string

And I've pointed out a couple issues with this fundamental loop in a couple places.

Please use a common function that extracts this. It could go near wait_for_http or something.

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