Skip to content

Commit

Permalink
unsecure grpc channel
Browse files Browse the repository at this point in the history
  • Loading branch information
sai-sunder-s committed Oct 10, 2024
1 parent d7bad5d commit f2f9358
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
27 changes: 15 additions & 12 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,10 @@ def showcase_library(
# Download the Showcase descriptor.
session.run(
"curl",
"https://github.com/googleapis/gapic-showcase/releases/"
f"download/v{showcase_version}/"
f"gapic-showcase-{showcase_version}.desc",
"https://github.com/googleapis/gapic-showcase/blob/507a4cbdc45c8380aff29308ff2a1144ead9a7dc/test_gapic_showcase.desc"
# "https://github.com/googleapis/gapic-showcase/releases/"
# f"download/v{showcase_version}/"
# f"gapic-showcase-{showcase_version}.desc",
"-L",
"--output",
os.path.join(tmp_dir, "showcase.desc"),
Expand All @@ -197,9 +198,10 @@ def showcase_library(
if include_service_yaml:
session.run(
"curl",
"https://github.com/googleapis/gapic-showcase/releases/"
f"download/v{showcase_version}/"
f"showcase_v1beta1.yaml",
"https://github.com/googleapis/gapic-showcase/blob/507a4cbdc45c8380aff29308ff2a1144ead9a7dc/schema/google/showcase/v1beta1/showcase_v1beta1.yaml",
# "https://github.com/googleapis/gapic-showcase/releases/"
# f"download/v{showcase_version}/"
# f"showcase_v1beta1.yaml",
"-L",
"--output",
os.path.join(tmp_dir, "showcase_v1beta1.yaml"),
Expand Down Expand Up @@ -228,9 +230,10 @@ def showcase_library(
if retry_config:
session.run(
"curl",
"https://github.com/googleapis/gapic-showcase/releases/"
f"download/v{showcase_version}/"
f"showcase_grpc_service_config.json",
"https://github.com/googleapis/gapic-showcase/blob/507a4cbdc45c8380aff29308ff2a1144ead9a7dc/schema/google/showcase/v1beta1/showcase_grpc_service_config.json",
# "https://github.com/googleapis/gapic-showcase/releases/"
# f"download/v{showcase_version}/"
# f"showcase_grpc_service_config.json",
"-L",
"--output",
os.path.join(tmp_dir, "showcase_grpc_service_config.json"),
Expand All @@ -241,15 +244,15 @@ def showcase_library(
template_opt = f"python-gapic-templates={templates}"
opts = "--python_gapic_opt="
if include_service_yaml and retry_config:
opts += ",".join(other_opts + (f"{template_opt}", "transport=grpc+rest", f"service-yaml={tmp_dir}/showcase_v1beta1.yaml", f"retry-config={tmp_dir}/showcase_grpc_service_config.json"))
opts += ",".join(other_opts + (f"{template_opt}", "transport=grpc+rest", f"service-yaml=/usr/local/google/home/saisunder/data/playground/TestingStrategy/gapic-showcase/schema/google/showcase/v1beta1/showcase_v1beta1.yaml", f"retry-config=/usr/local/google/home/saisunder/data/playground/TestingStrategy/gapic-showcase/schema/google/showcase/v1beta1/showcase_grpc_service_config.json"))
else:
opts += ",".join(other_opts + (f"{template_opt}", "transport=grpc+rest",))
cmd_tup = (
"python",
"-m",
"grpc_tools.protoc",
f"--experimental_allow_proto3_optional",
f"--descriptor_set_in={tmp_dir}{os.sep}showcase.desc",
f"--descriptor_set_in=/usr/local/google/home/saisunder/data/playground/TestingStrategy/gapic-showcase/test_gapic_showcase.desc",
opts,
f"--python_gapic_out={tmp_dir}",
f"google/showcase/v1beta1/echo.proto",
Expand Down Expand Up @@ -317,7 +320,7 @@ def _add_python_settings(tmp_dir, python_settings):
return f"""
import yaml
from pathlib import Path
temp_file_path = Path(f"{tmp_dir}/showcase_v1beta1.yaml")
temp_file_path = Path(f"/usr/local/google/home/saisunder/data/playground/TestingStrategy/gapic-showcase/schema/google/showcase/v1beta1/showcase_v1beta1.yaml")
with temp_file_path.open('r') as file:
data = yaml.safe_load(file)
data['publishing']['library_settings'] = {python_settings}
Expand Down
10 changes: 9 additions & 1 deletion tests/showcase/test_unary.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import grpc
from google.auth import credentials
import re
import pytest
from google import showcase
Expand All @@ -21,7 +23,13 @@
@pytest.fixture
def echo():
# Create an instance of the Showcase Echo client
echo_client = showcase.EchoClient()
transport_cls = showcase.EchoClient.get_transport_class("grpc")
transport = transport_cls(
credentials=credentials.AnonymousCredentials(),
channel=grpc.insecure_channel("localhost:7469"),
host="localhost:7469",
)
echo_client = showcase.EchoClient(transport=transport)
yield echo_client
# Optional: Clean up resources if needed after the test
# e.g., echo_client.close()
Expand Down

0 comments on commit f2f9358

Please sign in to comment.