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

Comparison tests: moved server full startup wait function to hgitaly pkg

This makes it importable from the whole code base, and is already
somewhat cleaner in the `tests_with_gitaly.rhgitaly` module.
parent 15c56172
No related branches found
No related tags found
2 merge requests!151heptapod#743: making 0.36 the new stable,!145Pool of repository working directories
from hgitaly.stub.repository_pb2 import RepositoryExistsRequest
from hgitaly.stub.shared_pb2 import Repository
from hgitaly.stub.repository_pb2_grpc import RepositoryServiceStub
def wait_server_accepts_connection(gitaly_channel, timeout=5):
"""Wait for a server using the Gitaly protocol to accept connections.
wait for server to start enough that the address in bound
Then the `wait_for_ready` option is there to ensure full readiness, but
the client must at least receive something, e.g., the `CONNECTING` status
for that to work.
"""
repo_stub = RepositoryServiceStub(gitaly_channel)
repo_stub.RepositoryExists(
RepositoryExistsRequest(
repository=Repository(
relative_path="we/dont/care/waiting/for/any/connection",
storage_name="default")
),
timeout=timeout,
wait_for_ready=True
)
......@@ -10,9 +10,7 @@
import os
import subprocess
from hgitaly.stub.repository_pb2 import RepositoryExistsRequest
from hgitaly.stub.shared_pb2 import Repository
from hgitaly.stub.repository_pb2_grpc import RepositoryServiceStub
from hgitaly.testing.grpc import wait_server_accepts_connection
from . import (
GITALY_BIN_REL_PATH,
......@@ -20,26 +18,6 @@
)
def wait_gitaly_accepts_connection(gitaly_channel, timeout=5):
"""Wait for the Gitaly server to accept connections.
wait for server to start enough that the address in bound
Then the `wait_for_ready` optionis there to ensure full readiness, but
the client must at least receive something, e.g., the `CONNECTING` status
for that to work.
"""
repo_stub = RepositoryServiceStub(gitaly_channel)
repo_stub.RepositoryExists(
RepositoryExistsRequest(
repository=Repository(
relative_path="we/dont/care/waiting/for/any/connection",
storage_name="default")
),
timeout=timeout,
wait_for_ready=True
)
@attr.s
class GitalyServer:
home_dir = attr.ib()
......@@ -96,7 +74,7 @@
with grpc.insecure_channel('unix:' + str(self.gitaly_socket),
) as gitaly_channel:
wait_gitaly_accepts_connection(gitaly_channel, timeout=timeout)
wait_server_accepts_connection(gitaly_channel, timeout=timeout)
yield gitaly_channel
gitaly.terminate()
......
......@@ -12,7 +12,7 @@
import grpc
from .gitaly import wait_gitaly_accepts_connection
from hgitaly.testing.grpc import wait_server_accepts_connection
HGITALY_SOURCE_ROOT = Path(__file__).parent.parent
......@@ -44,7 +44,7 @@
try:
with grpc.insecure_channel(url) as channel:
wait_gitaly_accepts_connection(channel, timeout=timeout)
wait_server_accepts_connection(channel, timeout=timeout)
yield channel
finally:
rhgitaly.terminate()
......
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