Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add spanner executor v1 #1140

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/.OwlBot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,18 @@ deep-remove-regex:
deep-copy-regex:
- source: /google/spanner/(v.*)/.*-py/(.*)
dest: /owl-bot-staging/spanner/$1/$2
- source: /google/spanner/(v.*)/.*-pb2-py/(commit_response.*|keys.*|mutation.*|query_plan.*|result_set.*|spanner.*|transaction.*|type.*)
dest: /owl-bot-staging/spanner_pb2/$1/$2
- source: /google/spanner/admin/instance/(v.*)/.*-py/(.*)
dest: /owl-bot-staging/spanner_admin_instance/$1/$2
- source: /google/spanner/admin/instance/(v.*)/.*-pb2-py/(common.*|spanner_instance_admin.*)
dest: /owl-bot-staging/spanner_admin_instance_pb2/$1/$2
- source: /google/spanner/admin/database/(v.*)/.*-py/(.*)
dest: /owl-bot-staging/spanner_admin_database/$1/$2
- source: /google/spanner/admin/database/(v.*)/.*-pb2-py/(common.*|backup.*|spanner_database_admin.*)
dest: /owl-bot-staging/spanner_admin_database_pb2/$1/$2
- source: /google/spanner/executor/(v.*)/.*-pb2-py/(cloud_executor.*)
dest: /owl-bot-staging/spanner_executor_pb2/$1/$2

begin-after-commit-hash: b154da710c5c9eedee127c07f74b6158c9c22382

20 changes: 20 additions & 0 deletions owlbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,26 @@ def get_staging_dirs(
excludes=["google/cloud/spanner_admin_database/**", "*.*", "docs/index.rst", "**/gapic_version.py", "testing/constraints-3.7.txt",],
)

for library in get_staging_dirs(default_version="None",
sub_directory="spanner_executor_pb2"
):
s.move(library, "test_proxy/protos/google/spanner/executor/v1")

for library in get_staging_dirs(default_version="None",
sub_directory="spanner_pb2"
):
s.move(library, "test_proxy/protos/google/spanner/v1")

for library in get_staging_dirs(default_version="None",
sub_directory="spanner_admin_database_pb2"
):
s.move(library, "test_proxy/protos/google/spanner/admin/database/v1")

for library in get_staging_dirs(default_version="None",
sub_directory="spanner_admin_instance_pb2"
):
s.move(library, "test_proxy/protos/google/spanner/admin/instance/v1")

s.remove_staging_dirs()

# ----------------------------------------------------------------------------
Expand Down
47 changes: 47 additions & 0 deletions test_proxy/protos/cloud_executor_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright 2015 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The Python implementation of the GRPC helloworld.Greeter server."""

from concurrent import futures
import logging

import grpc
from google.spanner.executor.v1 import cloud_executor_pb2
from google.spanner.executor.v1 import cloud_executor_pb2_grpc
from google.cloud.spanner import Client


class TestProxyServer(cloud_executor_pb2_grpc.SpannerExecutorProxyServicer):
def ExecuteActionAsync(self, request, context):
print("Execute action async")
print(f"{request=}")
client = Client()
# TODO: Replace with correct client code
client.list_instances()
# TODO: Do something with the request
yield cloud_executor_pb2.SpannerAsyncActionResponse()

def serve():
port = '50055'
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
cloud_executor_pb2_grpc.add_SpannerExecutorProxyServicer_to_server(TestProxyServer(), server)
server.add_insecure_port('[::]:' + port)
server.start()
print("Server started, listening on " + port)
server.wait_for_termination()


if __name__ == '__main__':
logging.basicConfig()
serve()
143 changes: 143 additions & 0 deletions test_proxy/protos/google/spanner/admin/database/v1/backup_pb2.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc

Large diffs are not rendered by default.

Loading