Skip to content

Commit

Permalink
Add client version verification test (#3032)
Browse files Browse the repository at this point in the history
Co-authored-by: Yee <[email protected]>
  • Loading branch information
CPWstatic and yixinglu authored Oct 13, 2021
1 parent afbf9d2 commit 66aec86
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 42 deletions.
24 changes: 12 additions & 12 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
from tests.common.utils import get_conn_pool
from tests.common.constants import NB_TMP_PATH, SPACE_TMP_PATH

#from thrift.transport import TSocket
#from thrift.transport import TTransport
#from thrift.protocol import TBinaryProtocol
from nebula2.fbthrift.transport import TSocket
from nebula2.fbthrift.transport import TTransport
from nebula2.fbthrift.protocol import TBinaryProtocol
from nebula2.gclient.net import Connection
from nebula2.graph import GraphService

Expand Down Expand Up @@ -193,12 +193,12 @@ def workarround_for_class(request, pytestconfig, conn_pool,
request.cls.cleanup()
request.cls.drop_data()

#@pytest.fixture(scope="class")
#def establish_a_rare_connection(pytestconfig):
# addr = pytestconfig.getoption("address")
# host_addr = addr.split(":") if addr else ["localhost", get_ports()[0]]
# socket = TSocket.TSocket(host_addr[0], host_addr[1])
# transport = TTransport.TBufferedTransport(socket)
# protocol = TBinaryProtocol.TBinaryProtocol(transport)
# transport.open()
# return GraphService.Client(protocol)
@pytest.fixture(scope="class")
def establish_a_rare_connection(pytestconfig):
addr = pytestconfig.getoption("address")
host_addr = addr.split(":") if addr else ["localhost", get_ports()[0]]
socket = TSocket.TSocket(host_addr[0], host_addr[1])
transport = TTransport.TBufferedTransport(socket)
protocol = TBinaryProtocol.TBinaryProtocol(transport)
transport.open()
return GraphService.Client(protocol)
58 changes: 29 additions & 29 deletions tests/tck/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
from tests.tck.utils.table import dataset, table
from tests.tck.utils.nbv import murmurhash2

#from nebula2.graph.ttypes import VerifyClientVersionReq
#from nebula2.graph.ttypes import VerifyClientVersionResp
from nebula2.graph.ttypes import VerifyClientVersionReq
from nebula2.graph.ttypes import VerifyClientVersionResp

parse = functools.partial(parsers.parse)
rparse = functools.partial(parsers.re)
Expand Down Expand Up @@ -536,30 +536,30 @@ def executing_query_with_params(query, indices, keys, graph_spaces, session, req
ngql = combine_query(query).format(*vals)
exec_query(request, ngql, session, graph_spaces)

#@given(parse("nothing"))
#def nothing():
# pass
#
#@when(parse("connecting the servers with a compatible client version"))
#def connecting_servers_with_a_compatible_client_version(establish_a_rare_connection, graph_spaces):
# conn = establish_a_rare_connection
# graph_spaces["resp"] = conn.verifyClientVersion(VerifyClientVersionReq())
# conn._iprot.trans.close()
#
#@then(parse("the connection should be established"))
#def check_client_compatible(graph_spaces):
# resp = graph_spaces["resp"]
# assert resp.error_code == ErrorCode.SUCCEEDED, f'The client was rejected by server: {resp}'
#
#@when(parse("connecting the servers with a client version of {version}"))
#def connecting_servers_with_a_compatible_client_version(version, establish_a_rare_connection, graph_spaces):
# conn = establish_a_rare_connection
# req = VerifyClientVersionReq()
# req.version = version
# graph_spaces["resp"] = conn.verifyClientVersion(req)
# conn._iprot.trans.close()
#
#@then(parse("the connection should be rejected"))
#def check_client_compatible(graph_spaces):
# resp = graph_spaces["resp"]
# assert resp.error_code == ErrorCode.E_CLIENT_SERVER_INCOMPATIBLE, f'The client was not rejected by server: {resp}'
@given(parse("nothing"))
def nothing():
pass

@when(parse("connecting the servers with a compatible client version"))
def connecting_servers_with_a_compatible_client_version(establish_a_rare_connection, graph_spaces):
conn = establish_a_rare_connection
graph_spaces["resp"] = conn.verifyClientVersion(VerifyClientVersionReq())
conn._iprot.trans.close()

@then(parse("the connection should be established"))
def check_client_compatible(graph_spaces):
resp = graph_spaces["resp"]
assert resp.error_code == ErrorCode.SUCCEEDED, f'The client was rejected by server: {resp}'

@when(parse("connecting the servers with a client version of {version}"))
def connecting_servers_with_a_compatible_client_version(version, establish_a_rare_connection, graph_spaces):
conn = establish_a_rare_connection
req = VerifyClientVersionReq()
req.version = version
graph_spaces["resp"] = conn.verifyClientVersion(req)
conn._iprot.trans.close()

@then(parse("the connection should be rejected"))
def check_client_compatible(graph_spaces):
resp = graph_spaces["resp"]
assert resp.error_code == ErrorCode.E_CLIENT_SERVER_INCOMPATIBLE, f'The client was not rejected by server: {resp}'
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#
# This source code is licensed under Apache 2.0 License,
# attached with Common Clause Condition 1.0, found in the LICENSES directory.
@skip
Feature: Verify client version

Scenario: compatible version
Expand Down

0 comments on commit 66aec86

Please sign in to comment.