Skip to content

refactor(valkey): use async DocumentStore mixin tests#3060

Open
SyedShahmeerAli12 wants to merge 15 commits intodeepset-ai:mainfrom
SyedShahmeerAli12:fix/valkey-async-mixin-tests
Open

refactor(valkey): use async DocumentStore mixin tests#3060
SyedShahmeerAli12 wants to merge 15 commits intodeepset-ai:mainfrom
SyedShahmeerAli12:fix/valkey-async-mixin-tests

Conversation

@SyedShahmeerAli12
Copy link
Copy Markdown
Contributor

Closes #3053

Refactors integrations/valkey/tests/test_document_store_async.py to inherit from the async
mixin classes introduced in deepset-ai/haystack#10975.

  • Removes 10 duplicate tests now covered by the mixins
  • Keeps Valkey-specific tests (batch operations, embedding search, scoring, metadata)
  • Overrides WriteDocumentsAsyncTest methods for unsupported duplicate policies (FAIL,
    SKIP) since ValkeyDocumentStore only supports NONE and OVERWRITE

@SyedShahmeerAli12 SyedShahmeerAli12 requested a review from a team as a code owner March 30, 2026 14:24
@SyedShahmeerAli12 SyedShahmeerAli12 requested review from julian-risch and removed request for a team March 30, 2026 14:24
@SyedShahmeerAli12
Copy link
Copy Markdown
Contributor Author

SyedShahmeerAli12 commented Mar 31, 2026

▎ Hi @julian-risch and @davidsbatista , I've addressed the issue as described. The async test class now inherits
from the 10 available mixin classes, removing the duplicate tests. A few things worth noting:

  • Added pytest.importorskip so the file is skipped gracefully when running with haystack < 2.27.0 (e.g. the lowest-direct-deps CI step)
  • Added rating, age, year to the fixture's metadata_fields so inherited mixin tests
    that use those fields work correctly
  • Overridden test_count_not_empty_async due to a missing self in the upstream mixin —
    happy to open a fix in the haystack repo if needed
  • DuplicatePolicy.FAIL and SKIP tests are skipped since Valkey only supports NONE and
    OVERWRITE

@julian-risch julian-risch requested review from davidsbatista and removed request for julian-risch March 31, 2026 08:40
@davidsbatista
Copy link
Copy Markdown
Contributor

@SyedShahmeerAli12 you let other commits slip into this branch - there's much more stuff here - can you clean it up?

@SyedShahmeerAli12
Copy link
Copy Markdown
Contributor Author

@SyedShahmeerAli12 you let other commits slip into this branch - there's much more stuff here - can you clean it up?

Ok i will clean it up in a bit

SyedShahmeerAli12 and others added 9 commits April 1, 2026 14:33
Inherit from async mixin classes introduced in deepset-ai/haystack#10975
to eliminate duplicate test code in TestValkeyDocumentStoreAsync.

Mixins added (from haystack.testing.document_store and document_store_async):
- CountDocumentsAsyncTest
- WriteDocumentsAsyncTest
- DeleteDocumentsAsyncTest
- DeleteAllAsyncTest
- DeleteByFilterAsyncTest
- UpdateByFilterAsyncTest
- CountDocumentsByFilterAsyncTest
- CountUniqueMetadataByFilterAsyncTest
- GetMetadataFieldMinMaxAsyncTest
- GetMetadataFieldUniqueValuesAsyncTest

Override WriteDocumentsAsyncTest methods that rely on DuplicatePolicy.FAIL
and DuplicatePolicy.SKIP, which are not supported by ValkeyDocumentStore.

Closes deepset-ai#3053

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Override test_update_by_filter_async: uses filterable_docs fixture with
  undeclared 'chapter' field. Use declared fields (category, priority) instead.
- Override test_count_unique_metadata_by_filter_async_with_multiple_filters:
  uses undeclared 'year' field. Use declared fields (category, priority) instead.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Break long Document() lines to stay within 120-char limit
- Remove @staticmethod from test_count_unique_metadata_by_filter_async_with_multiple_filters
  so pytest can inject the document_store fixture correctly

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The async test mixin classes (document_store_async module) were added
in deepset-ai/haystack#10975 and are only available from haystack-ai>=2.27.0rc1.
The previous constraint (>=2.26.1) caused a ModuleNotFoundError at test collection.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add rating (float), age (int), year (int) to the document_store fixture
so inherited mixin tests that use these fields don't fail.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…rameter

The mixin's test_count_not_empty_async in DeleteByFilterAsyncTest is missing
`self`, causing pytest to bind the test class instance to `document_store`
instead of injecting the fixture. Override it with the correct signature.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…lasses

Revert main dependency to haystack-ai>=2.26.1 (fixes license checker).
Override haystack in the test env with the main branch which contains
the async mixin classes (document_store_async) not yet in a stable release.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ions

Use pytest.importorskip so the test file is skipped instead of failing
with ImportError when running with haystack < 2.27.0 (lowest-direct-deps step).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@SyedShahmeerAli12 SyedShahmeerAli12 force-pushed the fix/valkey-async-mixin-tests branch from 95335c8 to b40df0f Compare April 1, 2026 09:34
@SyedShahmeerAli12
Copy link
Copy Markdown
Contributor Author

@davidsbatista Thanks for catching that cleaned up now. I rewrote the PR branch it only contains the Valkey async mixin test commits. Could you please take another look?

@SyedShahmeerAli12 SyedShahmeerAli12 force-pushed the fix/valkey-async-mixin-tests branch from b40df0f to b676bb0 Compare April 1, 2026 09:48
import pytest_asyncio
from haystack.dataclasses import ByteStream, Document

pytest.importorskip("haystack.testing.document_store_async", reason="Requires haystack with async mixin test classes")
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.

We can remove this since haystack-ai is already a dependency on the pyproject.toml

"pytest-asyncio",
"pytest-cov",
"pytest-rerunfailures",
"haystack-ai @ git+https://github.com/deepset-ai/haystack.git@main",
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.

we can also remove this one

Copy link
Copy Markdown
Contributor

@davidsbatista davidsbatista left a comment

Choose a reason for hiding this comment

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

looks good - left some minor comments

@SyedShahmeerAli12 SyedShahmeerAli12 force-pushed the fix/valkey-async-mixin-tests branch from b676bb0 to 1330e40 Compare April 1, 2026 13:15
@SyedShahmeerAli12 SyedShahmeerAli12 force-pushed the fix/valkey-async-mixin-tests branch from c77962f to b823c4e Compare April 1, 2026 13:23
@SyedShahmeerAli12
Copy link
Copy Markdown
Contributor Author

SyedShahmeerAli12 commented Apr 1, 2026

@davidsbatista Kept the importorskip guard CountDocumentsByFilterAsyncTest and the other async mixin class aren't in the released haystack-ai yet, so removing it causes an ImportError at collection time on older versions. Once these classes are part of a stable release we can drop it.

@davidsbatista
Copy link
Copy Markdown
Contributor

Let's rather remove it. There's already an rc1 for 2.27.0, so 2.27.0 should be out today or tomorrow. We can hold this until the release is done.

@SyedShahmeerAli12
Copy link
Copy Markdown
Contributor Author

just to confirm should I remove the importorskip guard now?

@davidsbatista
Copy link
Copy Markdown
Contributor

yes please - thanks 👍🏽

haystack 2.27.0 is releasing imminently; the async mixin classes are
now available in the release candidate.
@SyedShahmeerAli12 SyedShahmeerAli12 force-pushed the fix/valkey-async-mixin-tests branch from 03b075e to 2d745e6 Compare April 1, 2026 13:58
@davidsbatista
Copy link
Copy Markdown
Contributor

@SyedShahmeerAli12 I will put this on hold for a while until this one is merged, and the release is done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use async DocumentStore mixin tests in Valkey

2 participants