Skip to content

Commit

Permalink
fix (#1805)
Browse files Browse the repository at this point in the history
  • Loading branch information
lferran authored Feb 6, 2024
1 parent acd325b commit a6b3ac5
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,8 @@ async def GC(self, request: ShardId) -> EmptyResponse:
"RelationSearch": (RelationSearchRequest, RelationSearchResponse),
"GetShard": (GetShardRequest, NodeResourcesShard),
"Suggest": (SuggestRequest, SuggestResponse),
"RelationEdges": (ShardId, EdgeList),
"RelationTypes": (ShardId, TypeList),
}
WRITER_METHODS = {
"NewShard": (ShardMetadata, ShardCreated),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
from unittest.mock import AsyncMock, MagicMock, patch

import pytest
from nucliadb_protos.noderesources_pb2 import ShardId
from nucliadb_protos.utils_pb2 import RelationNode

from nucliadb.common.cluster.settings import Settings
from nucliadb.common.cluster.standalone import service
Expand All @@ -48,6 +50,20 @@ def self_node(cluster_settings):
self_node.writer = AsyncMock()
self_node.reader.Search.return_value = nodereader_pb2.SearchResponse()

relation_types = nodereader_pb2.TypeList()
member = nodereader_pb2.RelationTypeListMember(
with_type=RelationNode.NodeType.ENTITY, with_subtype="foo"
)
relation_types.list.append(member)
self_node.reader.RelationTypes.return_value = relation_types

relation_edges = nodereader_pb2.EdgeList()
edge = nodereader_pb2.RelationEdge(
edge_type=RelationNode.NodeType.ENTITY, property="foo"
)
relation_edges.list.append(edge)
self_node.reader.RelationEdges.return_value = relation_edges

with patch("nucliadb.common.cluster.standalone.service.get_self") as mock_get_self:
mock_get_self.return_value = self_node
yield self_node
Expand Down Expand Up @@ -76,6 +92,36 @@ async def test_node_action(
)


async def test_reader_node_action_relations(
servicer: service.StandaloneClusterServiceServicer,
self_node,
cluster_settings,
):
resp = await servicer.NodeAction(
standalone_pb2.NodeActionRequest(
service="reader",
action="RelationTypes",
payload=ShardId(id="test").SerializeToString(),
),
None,
)
assert resp == standalone_pb2.NodeActionResponse(
payload=self_node.reader.RelationTypes.return_value.SerializeToString()
)

resp = await servicer.NodeAction(
standalone_pb2.NodeActionRequest(
service="reader",
action="RelationEdges",
payload=ShardId(id="test").SerializeToString(),
),
None,
)
assert resp == standalone_pb2.NodeActionResponse(
payload=self_node.reader.RelationEdges.return_value.SerializeToString()
)


async def test_node_info(
servicer: service.StandaloneClusterServiceServicer, self_node, cluster_settings
):
Expand Down

3 comments on commit a6b3ac5

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

Benchmark

Benchmark suite Current: a6b3ac5 Previous: d4afd82 Ratio
nucliadb/search/tests/unit/search/test_fetch.py::test_highligh_error 13015.287721728862 iter/sec (stddev: 0.0000010431326704829491) 13028.533525895236 iter/sec (stddev: 4.192637045977425e-7) 1.00

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

Benchmark

Benchmark suite Current: a6b3ac5 Previous: d4afd82 Ratio
nucliadb/search/tests/unit/search/test_fetch.py::test_highligh_error 12968.92286885148 iter/sec (stddev: 1.1674493487344904e-7) 13028.533525895236 iter/sec (stddev: 4.192637045977425e-7) 1.00

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

Benchmark

Benchmark suite Current: a6b3ac5 Previous: d4afd82 Ratio
nucliadb/search/tests/unit/search/test_fetch.py::test_highligh_error 12886.488977218778 iter/sec (stddev: 6.453853773586139e-7) 13028.533525895236 iter/sec (stddev: 4.192637045977425e-7) 1.01

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.