Skip to content

Commit

Permalink
added test cases for grcp channel-level compression
Browse files Browse the repository at this point in the history
  • Loading branch information
geetu040 committed Feb 4, 2024
1 parent 00abe41 commit 1b0b19b
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions tests/congruence_tests/test_grpc_channel_compress.py
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

0 comments on commit 1b0b19b

Please sign in to comment.