test: Add Database Tests For Container Images - Postgres, Redis, Valkey, Memcached#18001
test: Add Database Tests For Container Images - Postgres, Redis, Valkey, Memcached#18001MadhurAggarwal wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
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. |
|
|
||
|
|
||
| @pytest.mark.dockerfile() | ||
| def test_redis_lpush(container_exec_shell) -> None: |
There was a problem hiding this comment.
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
9add5b3 to
5976ce1
Compare
| break | ||
| time.sleep(1) | ||
| else: | ||
| output = ready.output if ready is not None else "<no attempts>" |
There was a problem hiding this comment.
question(non-blocking): When would ready be None here? We're guaranteed to do an at least one attempt right?
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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.
Add Container Runtime Tests for 4 DataStores
Each added test contains:
PR Testing:
Locally built a container image and tested using azldev tool:
Also run ruff formatting tests:
