Skip to content

Commit

Permalink
Merge pull request #1482 from weaviate/rodrigo/add_shard_tenant_test
Browse files Browse the repository at this point in the history
Fix query params issue dependent on bug in httpx<0.28
  • Loading branch information
tsmith023 authored Dec 13, 2024
2 parents cb03b68 + 095af3b commit 2233eb7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
16 changes: 16 additions & 0 deletions integration/test_tenants.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,22 @@
from weaviate.exceptions import WeaviateInvalidInputError, WeaviateUnsupportedFeatureError


def test_shards_on_tenants(
client_factory: ClientFactory, collection_factory: CollectionFactory
) -> None:
collection = collection_factory(
vectorizer_config=Configure.Vectorizer.none(),
multi_tenancy_config=Configure.multi_tenancy(enabled=True),
)
collection.tenants.create(Tenant(name="tenant1"))
client = client_factory()

nodes = client.cluster.nodes(collection.name, output="verbose")
count = sum(len(node.shards) for node in nodes)

assert count == 1


@pytest.mark.parametrize("tenant", ["tenant1", Tenant(name="tenant1")])
def test_delete_by_id_tenant(
collection_factory: CollectionFactory, tenant: Union[str, Tenant]
Expand Down
8 changes: 6 additions & 2 deletions weaviate/collections/cluster/cluster.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from httpx import Response
from weaviate.connect import ConnectionV4


Expand Down Expand Up @@ -75,12 +76,15 @@ async def nodes(
If the response is empty.
"""
path = "/nodes"
params = None
if collection is not None:
path += "/" + _capitalize_first_letter(collection)
if output is not None:
path += f"?output={output}"
params = {"output": output}

response = await self._connection.get(path=path, error_msg="Get nodes status failed")
response: Response = await self._connection.get(
path=path, params=params, error_msg="Get nodes status failed"
)
response_typed = _decode_json_response_dict(response, "Nodes status")
assert response_typed is not None

Expand Down
2 changes: 1 addition & 1 deletion weaviate/connect/v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ async def get(
return await self.__send(
"GET",
url=self.url + self._api_version_path + path,
params=params if params is not None else {},
params=params,
error_msg=error_msg,
status_codes=status_codes,
)
Expand Down

0 comments on commit 2233eb7

Please sign in to comment.