From bf48787ca73753aef8ba2e811a118fd05528d4a2 Mon Sep 17 00:00:00 2001 From: Erik De Smedt Date: Mon, 4 Mar 2024 16:30:33 +0100 Subject: [PATCH] Fix gl-testing I've broken the `Makefile` in a previous commit. After this commit ``` make gen ``` works again --- libs/gl-client-py/glclient/scheduler_pb2.pyi | 3 +- libs/gl-testing/Makefile | 8 +- .../gltesting/glclient/scheduler_grpc.py | 297 ++++++++++++++++++ libs/gl-testing/gltesting/scheduler_grpc.py | 2 +- 4 files changed, 304 insertions(+), 6 deletions(-) create mode 100644 libs/gl-testing/gltesting/glclient/scheduler_grpc.py diff --git a/libs/gl-client-py/glclient/scheduler_pb2.pyi b/libs/gl-client-py/glclient/scheduler_pb2.pyi index a8e7615d6..109f56855 100644 --- a/libs/gl-client-py/glclient/scheduler_pb2.pyi +++ b/libs/gl-client-py/glclient/scheduler_pb2.pyi @@ -4,7 +4,8 @@ isort:skip_file """ import builtins import collections.abc -import glclient.greenlight_pb2 +import glclient.greenlighu +t_pb2 import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.internal.enum_type_wrapper diff --git a/libs/gl-testing/Makefile b/libs/gl-testing/Makefile index 0df09a687..85797bfca 100644 --- a/libs/gl-testing/Makefile +++ b/libs/gl-testing/Makefile @@ -1,7 +1,7 @@ TESTINGDIR=${REPO}/libs/gl-testing TESTPROTOC_OPTS = \ - -I${REPO}/libs/proto \ + -I ${REPO}/libs/proto \ --purerpc_out=${TESTINGDIR}/gltesting \ --experimental_allow_proto3_optional @@ -10,7 +10,7 @@ GEN_TESTING = \ GENALL += ${GEN_TESTING} -testgrpc ${TESTINGDIR}/gltesting/scheduler_grpc.py: ${REPO}/libs/proto/scheduler.proto - python -m grpc_tools.protoc ${TESTPROTOC_OPTS} ${REPO}/libs/proto/scheduler.proto - sed -E -i 's/import (.+)_pb2 as .+__pb2/from glclient import \1_pb2 as \1__pb2/g' ${TESTINGDIR}/gltesting/scheduler_grpc.py +testgrpc ${TESTINGDIR}/gltesting/scheduler_grpc.py: ${REPO}/libs/proto/glclient/scheduler.proto + python -m grpc_tools.protoc ${TESTPROTOC_OPTS} glclient/scheduler.proto + diff --git a/libs/gl-testing/gltesting/glclient/scheduler_grpc.py b/libs/gl-testing/gltesting/glclient/scheduler_grpc.py new file mode 100644 index 000000000..4b76ab276 --- /dev/null +++ b/libs/gl-testing/gltesting/glclient/scheduler_grpc.py @@ -0,0 +1,297 @@ +import purerpc +import glclient.scheduler_pb2 as glclient_dot_scheduler__pb2 +import glclient.greenlight_pb2 as glclient_dot_greenlight__pb2 + + +class SchedulerServicer(purerpc.Servicer): + async def Register(self, input_message): + raise NotImplementedError() + + async def Recover(self, input_message): + raise NotImplementedError() + + async def GetChallenge(self, input_message): + raise NotImplementedError() + + async def Schedule(self, input_message): + raise NotImplementedError() + + async def GetNodeInfo(self, input_message): + raise NotImplementedError() + + async def MaybeUpgrade(self, input_message): + raise NotImplementedError() + + async def ListInviteCodes(self, input_message): + raise NotImplementedError() + + async def ExportNode(self, input_message): + raise NotImplementedError() + + async def AddOutgoingWebhook(self, input_message): + raise NotImplementedError() + + async def ListOutgoingWebhooks(self, input_message): + raise NotImplementedError() + + async def DeleteWebhooks(self, input_message): + raise NotImplementedError() + + async def RotateOutgoingWebhookSecret(self, input_message): + raise NotImplementedError() + + @property + def service(self) -> purerpc.Service: + service_obj = purerpc.Service( + "scheduler.Scheduler" + ) + service_obj.add_method( + "Register", + self.Register, + purerpc.RPCSignature( + purerpc.Cardinality.UNARY_UNARY, + glclient_dot_scheduler__pb2.RegistrationRequest, + glclient_dot_scheduler__pb2.RegistrationResponse, + ) + ) + service_obj.add_method( + "Recover", + self.Recover, + purerpc.RPCSignature( + purerpc.Cardinality.UNARY_UNARY, + glclient_dot_scheduler__pb2.RecoveryRequest, + glclient_dot_scheduler__pb2.RecoveryResponse, + ) + ) + service_obj.add_method( + "GetChallenge", + self.GetChallenge, + purerpc.RPCSignature( + purerpc.Cardinality.UNARY_UNARY, + glclient_dot_scheduler__pb2.ChallengeRequest, + glclient_dot_scheduler__pb2.ChallengeResponse, + ) + ) + service_obj.add_method( + "Schedule", + self.Schedule, + purerpc.RPCSignature( + purerpc.Cardinality.UNARY_UNARY, + glclient_dot_scheduler__pb2.ScheduleRequest, + glclient_dot_scheduler__pb2.NodeInfoResponse, + ) + ) + service_obj.add_method( + "GetNodeInfo", + self.GetNodeInfo, + purerpc.RPCSignature( + purerpc.Cardinality.UNARY_UNARY, + glclient_dot_scheduler__pb2.NodeInfoRequest, + glclient_dot_scheduler__pb2.NodeInfoResponse, + ) + ) + service_obj.add_method( + "MaybeUpgrade", + self.MaybeUpgrade, + purerpc.RPCSignature( + purerpc.Cardinality.UNARY_UNARY, + glclient_dot_scheduler__pb2.UpgradeRequest, + glclient_dot_scheduler__pb2.UpgradeResponse, + ) + ) + service_obj.add_method( + "ListInviteCodes", + self.ListInviteCodes, + purerpc.RPCSignature( + purerpc.Cardinality.UNARY_UNARY, + glclient_dot_scheduler__pb2.ListInviteCodesRequest, + glclient_dot_scheduler__pb2.ListInviteCodesResponse, + ) + ) + service_obj.add_method( + "ExportNode", + self.ExportNode, + purerpc.RPCSignature( + purerpc.Cardinality.UNARY_UNARY, + glclient_dot_scheduler__pb2.ExportNodeRequest, + glclient_dot_scheduler__pb2.ExportNodeResponse, + ) + ) + service_obj.add_method( + "AddOutgoingWebhook", + self.AddOutgoingWebhook, + purerpc.RPCSignature( + purerpc.Cardinality.UNARY_UNARY, + glclient_dot_scheduler__pb2.AddOutgoingWebhookRequest, + glclient_dot_scheduler__pb2.AddOutgoingWebhookResponse, + ) + ) + service_obj.add_method( + "ListOutgoingWebhooks", + self.ListOutgoingWebhooks, + purerpc.RPCSignature( + purerpc.Cardinality.UNARY_UNARY, + glclient_dot_scheduler__pb2.ListOutgoingWebhooksRequest, + glclient_dot_scheduler__pb2.ListOutgoingWebhooksResponse, + ) + ) + service_obj.add_method( + "DeleteWebhooks", + self.DeleteWebhooks, + purerpc.RPCSignature( + purerpc.Cardinality.UNARY_UNARY, + glclient_dot_scheduler__pb2.DeleteOutgoingWebhooksRequest, + glclient_dot_greenlight__pb2.Empty, + ) + ) + service_obj.add_method( + "RotateOutgoingWebhookSecret", + self.RotateOutgoingWebhookSecret, + purerpc.RPCSignature( + purerpc.Cardinality.UNARY_UNARY, + glclient_dot_scheduler__pb2.RotateOutgoingWebhookSecretRequest, + glclient_dot_scheduler__pb2.WebhookSecretResponse, + ) + ) + return service_obj + + +class SchedulerStub: + def __init__(self, channel): + self._client = purerpc.Client( + "scheduler.Scheduler", + channel + ) + self.Register = self._client.get_method_stub( + "Register", + purerpc.RPCSignature( + purerpc.Cardinality.UNARY_UNARY, + glclient_dot_scheduler__pb2.RegistrationRequest, + glclient_dot_scheduler__pb2.RegistrationResponse, + ) + ) + self.Recover = self._client.get_method_stub( + "Recover", + purerpc.RPCSignature( + purerpc.Cardinality.UNARY_UNARY, + glclient_dot_scheduler__pb2.RecoveryRequest, + glclient_dot_scheduler__pb2.RecoveryResponse, + ) + ) + self.GetChallenge = self._client.get_method_stub( + "GetChallenge", + purerpc.RPCSignature( + purerpc.Cardinality.UNARY_UNARY, + glclient_dot_scheduler__pb2.ChallengeRequest, + glclient_dot_scheduler__pb2.ChallengeResponse, + ) + ) + self.Schedule = self._client.get_method_stub( + "Schedule", + purerpc.RPCSignature( + purerpc.Cardinality.UNARY_UNARY, + glclient_dot_scheduler__pb2.ScheduleRequest, + glclient_dot_scheduler__pb2.NodeInfoResponse, + ) + ) + self.GetNodeInfo = self._client.get_method_stub( + "GetNodeInfo", + purerpc.RPCSignature( + purerpc.Cardinality.UNARY_UNARY, + glclient_dot_scheduler__pb2.NodeInfoRequest, + glclient_dot_scheduler__pb2.NodeInfoResponse, + ) + ) + self.MaybeUpgrade = self._client.get_method_stub( + "MaybeUpgrade", + purerpc.RPCSignature( + purerpc.Cardinality.UNARY_UNARY, + glclient_dot_scheduler__pb2.UpgradeRequest, + glclient_dot_scheduler__pb2.UpgradeResponse, + ) + ) + self.ListInviteCodes = self._client.get_method_stub( + "ListInviteCodes", + purerpc.RPCSignature( + purerpc.Cardinality.UNARY_UNARY, + glclient_dot_scheduler__pb2.ListInviteCodesRequest, + glclient_dot_scheduler__pb2.ListInviteCodesResponse, + ) + ) + self.ExportNode = self._client.get_method_stub( + "ExportNode", + purerpc.RPCSignature( + purerpc.Cardinality.UNARY_UNARY, + glclient_dot_scheduler__pb2.ExportNodeRequest, + glclient_dot_scheduler__pb2.ExportNodeResponse, + ) + ) + self.AddOutgoingWebhook = self._client.get_method_stub( + "AddOutgoingWebhook", + purerpc.RPCSignature( + purerpc.Cardinality.UNARY_UNARY, + glclient_dot_scheduler__pb2.AddOutgoingWebhookRequest, + glclient_dot_scheduler__pb2.AddOutgoingWebhookResponse, + ) + ) + self.ListOutgoingWebhooks = self._client.get_method_stub( + "ListOutgoingWebhooks", + purerpc.RPCSignature( + purerpc.Cardinality.UNARY_UNARY, + glclient_dot_scheduler__pb2.ListOutgoingWebhooksRequest, + glclient_dot_scheduler__pb2.ListOutgoingWebhooksResponse, + ) + ) + self.DeleteWebhooks = self._client.get_method_stub( + "DeleteWebhooks", + purerpc.RPCSignature( + purerpc.Cardinality.UNARY_UNARY, + glclient_dot_scheduler__pb2.DeleteOutgoingWebhooksRequest, + glclient_dot_greenlight__pb2.Empty, + ) + ) + self.RotateOutgoingWebhookSecret = self._client.get_method_stub( + "RotateOutgoingWebhookSecret", + purerpc.RPCSignature( + purerpc.Cardinality.UNARY_UNARY, + glclient_dot_scheduler__pb2.RotateOutgoingWebhookSecretRequest, + glclient_dot_scheduler__pb2.WebhookSecretResponse, + ) + ) + + +class DebugServicer(purerpc.Servicer): + async def ReportSignerRejection(self, input_message): + raise NotImplementedError() + + @property + def service(self) -> purerpc.Service: + service_obj = purerpc.Service( + "scheduler.Debug" + ) + service_obj.add_method( + "ReportSignerRejection", + self.ReportSignerRejection, + purerpc.RPCSignature( + purerpc.Cardinality.UNARY_UNARY, + glclient_dot_scheduler__pb2.SignerRejection, + glclient_dot_greenlight__pb2.Empty, + ) + ) + return service_obj + + +class DebugStub: + def __init__(self, channel): + self._client = purerpc.Client( + "scheduler.Debug", + channel + ) + self.ReportSignerRejection = self._client.get_method_stub( + "ReportSignerRejection", + purerpc.RPCSignature( + purerpc.Cardinality.UNARY_UNARY, + glclient_dot_scheduler__pb2.SignerRejection, + glclient_dot_greenlight__pb2.Empty, + ) + ) \ No newline at end of file diff --git a/libs/gl-testing/gltesting/scheduler_grpc.py b/libs/gl-testing/gltesting/scheduler_grpc.py index 1e2871d7a..0bf13c68a 100644 --- a/libs/gl-testing/gltesting/scheduler_grpc.py +++ b/libs/gl-testing/gltesting/scheduler_grpc.py @@ -214,4 +214,4 @@ def __init__(self, channel): scheduler__pb2.SignerRejection, greenlight__pb2.Empty, ) - ) \ No newline at end of file + )