Skip to content

Introduce Redis integration tests + resolve key type disparity across Redis and Cassandra#284

Merged
ekzhu merged 24 commits intoekzhu:masterfrom
Varun0157:redis-integ
Nov 18, 2025
Merged

Introduce Redis integration tests + resolve key type disparity across Redis and Cassandra#284
ekzhu merged 24 commits intoekzhu:masterfrom
Varun0157:redis-integ

Conversation

@Varun0157
Copy link
Copy Markdown
Contributor

@Varun0157 Varun0157 commented Nov 11, 2025

As requested in a previous PR, we add integration tests for the Redis storage. Instead of creating a new test_redis.py file as requested, though, we instead parametrize the existing integration tests for Cassandra to run for both Redis and Cassandra.

This allows us to:

  • ensure feature parity between both storage layers
  • easily extend tests across new storage layers

In order to carry this out, we did the following:

  • convert the existing unittest.TestCase classes into pytest classes; since we're already using pytest, this is likely a reasonable change
  • introduce a workflow to run it automatically, in the same manner as the Cassandra store.

While carrying this out, a feature disparity was discovered: when prepickle is False, the Cassandra storage returns strings from relevant key getters, while Redis returns bytes. In the same manner as the existing Cassandra storage, we introduce encoders and decoders to unify return types across backends.

Added after review:

  • ensure keys are bytes when prepickle=False for non-dict storage, and remove key and value encoders and decoders that manipulate the types

@Varun0157 Varun0157 requested a review from ekzhu as a code owner November 11, 2025 11:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request introduces Redis integration tests and resolves type inconsistencies between Redis and Cassandra storage backends. The changes parametrize existing Cassandra integration tests to run for both storage types, ensuring feature parity and making it easier to extend tests to new storage layers in the future.

Key changes:

  • Converted test suite from unittest.TestCase to pytest-style classes with parametrized fixtures
  • Added encoder/decoder functionality to Redis storage to match Cassandra's string/bytes handling
  • Introduced GitHub Actions workflow for automated Redis integration testing

Reviewed Changes

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

File Description
test/test_integration.py Converted from unittest to pytest with parametrized fixtures for both Redis and Cassandra; added Redis cleanup functionality
datasketch/storage.py Added value encoder/decoder to RedisListStorage for consistent bytes/string handling across storage backends
.github/workflows/test-redis.yml New workflow for automated Redis integration tests triggered after main test workflow
pyproject.toml Added S101 exception for test files to allow pytest assertions
Comments suppressed due to low confidence (2)

test/test_integration.py:89

  • Manual call to self.teardown_method(None) is unnecessary and incorrect. In pytest, teardown methods are automatically called after each test. This manual call could interfere with proper test cleanup and is not the pytest way of handling teardown. Consider removing this line and relying on pytest's automatic teardown mechanism.
    test/test_integration.py:269
  • Manual call to self.teardown_method(None) is unnecessary and incorrect. In pytest, teardown methods are automatically called after each test. This manual call could interfere with proper test cleanup and is not the pytest way of handling teardown. Consider removing this line and relying on pytest's automatic teardown mechanism.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Varun0157
Copy link
Copy Markdown
Contributor Author

Added: ensure keys are bytes when prepickle=False for non-dict storage, and remove key and value encoders and decoders that manipulate the types.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 6 out of 6 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Varun0157 Varun0157 requested a review from ekzhu November 17, 2025 04:02
@Varun0157
Copy link
Copy Markdown
Contributor Author

Varun0157 commented Nov 17, 2025

Changes: make _require_bytes_keys private, stop invoking teardown_method explicitly - create a separate helper

@Varun0157
Copy link
Copy Markdown
Contributor Author

Varun0157 commented Nov 17, 2025

Changes:

  • add a test that ensures a TypeError is raised when we insert some non-bytes keys (int and string tested) with prepickle as False
  • remove the requirements.txt check in test-cassandra.yml and test-redis.yml workflows.

@Varun0157 Varun0157 requested a review from ekzhu November 17, 2025 10:48
@ekzhu ekzhu merged commit 77ec0a1 into ekzhu:master Nov 18, 2025
8 checks passed
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.

3 participants