-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: LingKa <[email protected]>
- Loading branch information
Showing
5 changed files
with
58 additions
and
5 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
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
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,25 @@ | ||
"""Maintenance Client""" | ||
|
||
from typing import AsyncIterable | ||
from grpc import Channel | ||
from api.xline.rpc_pb2_grpc import MaintenanceStub | ||
from api.xline.rpc_pb2 import SnapshotRequest, SnapshotResponse | ||
|
||
|
||
class MaintenanceClient: | ||
""" | ||
Client for Maintenance operations. | ||
Attributes: | ||
maintenance_client: The client running the Maintenance protocol, communicate with all servers. | ||
""" | ||
|
||
maintenance_client: MaintenanceStub | ||
|
||
def __init__(self, channel: Channel) -> None: | ||
self.maintenance_client = MaintenanceStub(channel) | ||
|
||
async def snapshot(self) -> AsyncIterable[SnapshotResponse]: | ||
"""Gets a snapshot over a stream""" | ||
res = self.maintenance_client.Snapshot(SnapshotRequest()) | ||
return res |
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
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,18 @@ | ||
"""Test for the maintenance client""" | ||
|
||
import pytest | ||
from client import client | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_snapshot_should_get_valid_data(): | ||
""" | ||
Snapshot should get valid data | ||
""" | ||
curp_members = ["172.20.0.3:2379", "172.20.0.4:2379", "172.20.0.5:2379"] | ||
cli = await client.Client.connect(curp_members) | ||
maintenance_client = cli.maintenance_client | ||
|
||
res = await maintenance_client.snapshot() | ||
async for snapshot in res: | ||
assert snapshot.blob != b"" |