Skip to content
Snippets Groups Projects
Commit c7d863a5 authored by Georges Racinet's avatar Georges Racinet
Browse files

RHGitaly Comparison tests: comparison with HGitaly for ServerInfo

We're defining a new fixture and `RpcHelper` for such comparisons.
As expected, this is  much simpler than the one for Gitaly Comparison
tests.

The included test is actually useful: we are sure that we don't
have version skew between RHGitaly and HGitaly. Given how it is
implemented, this is not a surprise, but it'll have our back in
case the implementation has to change.
parent 42fb2ee5
No related branches found
No related tags found
3 merge requests!151heptapod#743: making 0.36 the new stable,!144RHGitaly: implement CommitService.ListCommitsByOid,!140Bootstrapping RHGitaly
......@@ -32,6 +32,7 @@
from .gitaly import GitalyServer
from .rhgitaly import RHGitalyServer
from .comparison import gitaly_comparison_fixture
from .hgitaly_rhgitaly_comparison import hgitaly_rhgitaly_comparison_fixture
@pytest.fixture(scope='module')
......@@ -74,3 +75,17 @@
rhgitaly_channel=rhgitaly_channel,
) as comparison:
yield comparison
@pytest.fixture()
def hgitaly_rhgitaly_comparison(server_repos_root, # module scope
rhgitaly_channel, # module scope
grpc_channel, # module scope
monkeypatch, # function scope
):
with hgitaly_rhgitaly_comparison_fixture(
server_repos_root,
hgitaly_channel=grpc_channel,
rhgitaly_channel=rhgitaly_channel,
) as comparison:
yield comparison
# Copyright 2023 Georges Racinet <georges.racinet@octobus.net>
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
#
# SPDX-License-Identifier: GPL-2.0-or-later
import attr
import contextlib
from .comparison import BaseRpcHelper
@attr.s
class HGitalyRHGitalyComparison():
"""This fixture is for comparison between HGitaly and RHGitaly.
Gitaly itself is not involved at all, so this is for HGitaly-specific
calls, often but not necessarily involving the Mercurial services.
"""
hgitaly_channel = attr.ib()
rhgitaly_channel = attr.ib()
server_repos_root = attr.ib(default=None) # not used yet
def rpc_helper(self, **kw):
return RpcHelper(self, **kw)
class RpcHelper(BaseRpcHelper):
"""Encapsulates a comparison fixture with call and compare helpers.
This is derived from :class:`hgitaly.comparison.RpcHelper`, but it is
very much simpler.
"""
def init_stubs(self):
comparison, stub_cls = self.comparison, self.stub_cls
self.stubs = dict(hgitaly=stub_cls(comparison.hgitaly_channel),
rhgitaly=stub_cls(comparison.rhgitaly_channel))
def assert_compare(self, **kwargs):
self.apply_request_defaults(kwargs)
assert self.rpc('hgitaly', **kwargs) == self.rpc('rhgitaly', **kwargs)
@contextlib.contextmanager
def hgitaly_rhgitaly_comparison_fixture(server_repos_root,
hgitaly_channel,
rhgitaly_channel,
):
yield HGitalyRHGitalyComparison(hgitaly_channel=hgitaly_channel,
rhgitaly_channel=rhgitaly_channel)
# Copyright 2023 Georges Racinet <georges.racinet@octobus.net>
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
#
# SPDX-License-Identifier: GPL-2.0-or-later
import pytest
from hgitaly.stub.server_pb2 import (
ServerInfoRequest,
)
from hgitaly.stub.server_pb2_grpc import ServerServiceStub
from . import skip_comparison_tests
if skip_comparison_tests(): # pragma no cover
pytestmark = pytest.mark.skip
def test_compare_server_info(hgitaly_rhgitaly_comparison):
fixture = hgitaly_rhgitaly_comparison
rpc_helper = fixture.rpc_helper(
stub_cls=ServerServiceStub,
method_name='ServerInfo',
request_cls=ServerInfoRequest,
repository_arg=False,
)
rpc_helper.assert_compare()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment