-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added test cases for grcp channel-level compression
- Loading branch information
Showing
1 changed file
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import pytest | ||
from grpc import Compression as GRPCCompression | ||
|
||
from qdrant_client import QdrantClient | ||
from qdrant_client.async_qdrant_client import AsyncQdrantClient | ||
from qdrant_client.grpc import Compression | ||
from tests.congruence_tests.test_common import generate_fixtures, init_client | ||
|
||
|
||
def test_compression_gzip(): | ||
# creates a grpc client with specifying gzip compression algorithm | ||
client = QdrantClient(prefer_grpc=True, grpc_compression=Compression.Gzip, timeout=30) | ||
|
||
# creates points | ||
fixtures = generate_fixtures() | ||
|
||
# recreates collection and uploads the points | ||
init_client(client, fixtures) | ||
|
||
# points successfully uploaded in collection using Gzip compression algorithm | ||
|
||
|
||
def test_compression_nocompression(): | ||
# creates a grpc client with specifying no-compression algorithm | ||
client = QdrantClient(prefer_grpc=True, grpc_compression=Compression.NoCompression, timeout=30) | ||
|
||
# creates points | ||
fixtures = generate_fixtures() | ||
|
||
# recreates collection and uploads the points | ||
init_client(client, fixtures) | ||
|
||
# points successfully uploaded in collection using no compression algorithm | ||
|
||
|
||
def test_compression_none(): | ||
# creates a grpc client without specifying compression algorithm | ||
client = QdrantClient(prefer_grpc=True, timeout=30) # grpc_compression=None | ||
|
||
# creates points | ||
fixtures = generate_fixtures() | ||
|
||
# recreates collection and uploads the points | ||
init_client(client, fixtures) | ||
|
||
# points successfully uploaded in collection using no compression algorithm | ||
|
||
|
||
def test_compression_deflate(): | ||
""" | ||
Deflate algorithm is not supported by RUST GRPC Server | ||
grpc.Compression provides Deflate option | ||
qdrant.grpc.Compression is tailored to exclude Deflate option | ||
Trying Deflate compression should raise particular errors | ||
""" | ||
|
||
with pytest.raises(AttributeError): | ||
# creates a grpc client with invalid enum attribute | ||
client = QdrantClient(prefer_grpc=True, grpc_compression=Compression.Deflate, timeout=30) | ||
|
||
with pytest.raises(TypeError): | ||
# creates a grpc client with grpc enum not that is excluded in qdrant.grpc enum | ||
client = QdrantClient( | ||
prefer_grpc=True, grpc_compression=GRPCCompression.Deflate, timeout=30 | ||
) | ||
|
||
# Anticipated Errors were successfully raised | ||
|
||
|
||
def test_compression_invalid(): | ||
# creates a grpc client with invalid type | ||
with pytest.raises(TypeError): | ||
client = QdrantClient(prefer_grpc=True, grpc_compression="gzip", timeout=30) | ||
|
||
# TypeError was successfully raised |