-
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
2 changed files
with
43 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 |
---|---|---|
@@ -1,3 +1,9 @@ | ||
# SPDX-FileCopyrightText: 2023-present LingKa <[email protected]> | ||
# | ||
# SPDX-License-Identifier: Apache 2.0 | ||
|
||
import sys | ||
|
||
sys.path.append("./api/curp") | ||
|
||
sys.path.append("./api/xline") |
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,37 @@ | ||
"""Tests for the protocol client.""" | ||
|
||
import unittest | ||
import uuid | ||
|
||
from api.xline import rpc_pb2, xline_command_pb2 | ||
from client.protocol import build_from_addrs | ||
|
||
|
||
class TestProtocolClient(unittest.TestCase): | ||
"""test protocol client""" | ||
|
||
def setUp(self) -> None: | ||
curp_members = ["172.20.0.3:2379", "172.20.0.4:2379", "172.20.0.5:2379"] | ||
|
||
cmd = xline_command_pb2.Command( | ||
request=xline_command_pb2.RequestWithToken( | ||
put_request=rpc_pb2.PutRequest( | ||
key=bytes("hello", encoding="utf8"), | ||
value=bytes("xline", encoding="utf8"), | ||
) | ||
), | ||
propose_id=f"client-{uuid.uuid4()}", | ||
) | ||
|
||
self.cmd = cmd | ||
self.client = build_from_addrs(curp_members) | ||
|
||
def test_fast_path(self): | ||
"""test fast path""" | ||
res = self.client.propose(self.cmd, True) | ||
self.assertIsNotNone(res) | ||
|
||
def test_slow_path(self): | ||
"""test slow path""" | ||
res = self.client.propose(self.cmd, False) | ||
self.assertIsNotNone(res) |