Skip to content

Commit

Permalink
Enable Apigee response streaming (#1418)
Browse files Browse the repository at this point in the history
Adds support for responses >10MB. Adds a test case to the manual test
suite for this as well.
- [Apigee limits
reference](https://cloud.google.com/apigee/docs/api-platform/reference/limits#system)
- [Apigee streaming
description](https://cloud.google.com/apigee/docs/api-platform/develop/enabling-streaming)
  • Loading branch information
hqpho authored Sep 23, 2024
1 parent 8372dc4 commit db7bc86
Show file tree
Hide file tree
Showing 4 changed files with 3,268 additions and 4 deletions.
4 changes: 3 additions & 1 deletion deploy/apigee/proxy_endpoints/api.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
<Flows />
<HTTPProxyConnection>
<BasePath>/api</BasePath>
<Properties />
<Properties>
<Property name="response.streaming.enabled">true</Property>
</Properties>
<VirtualHost>default</VirtualHost>
</HTTPProxyConnection>
<RouteRule name="api">
Expand Down
4 changes: 3 additions & 1 deletion deploy/apigee/target_endpoints/api.template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@
<Response />
</PostFlow>
<HTTPTargetConnection>
<Properties />
<Properties>
<Property name="response.streaming.enabled">true</Property>
</Properties>
<URL>https://REPLACE_WITH_MIXER_API_ESP_HOSTNAME</URL>
<SSLInfo>
<Enabled>true</Enabled>
Expand Down
21 changes: 19 additions & 2 deletions tools/migration_testing/compare_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,18 @@

import argparse
import copy
import json
import logging

import requests


# Read a JSON object from a file
def read_json_from_file(file_path):
with open(file_path, 'r') as f:
return json.load(f)


USE_NEW_ENDPOINTS_ONLY = False
NEW_ENDPOINTS = [
# For testing out new endpoints without having to comment out existing ones
Expand Down Expand Up @@ -403,6 +411,13 @@ class bcolors:
UNDERLINE = '\033[4m'


def format_response(response_data):
formatted = json.dumps(response_data, indent=2).replace("\n", "\n ")
if len(formatted) > 1000:
formatted = formatted[:1000] + f"...<{len(formatted) - 1000} chars omitted>"
return formatted


def compare_responses(endpoint, use_api_key, method="GET", params=None):
current_url = f"https://{args.current_domain}{endpoint}"
new_url = f"https://{args.new_domain}{endpoint}"
Expand Down Expand Up @@ -437,9 +452,11 @@ def compare_responses(endpoint, use_api_key, method="GET", params=None):
if current_data != new_data:
print(f"{bcolors.FAIL}DIFF{bcolors.ENDC} {method} {endpoint}")
print(
f" Current ({args.current_domain}): {current_response.status_code} {current_data}"
f" Current ({args.current_domain}): {current_response.status_code} {format_response(current_data)}"
)
print(
f" New ({args.new_domain}): {new_response.status_code} {format_response(new_data)}"
)
print(f" New ({args.new_domain}): {new_response.status_code} {new_data}")
else:
code = current_response.status_code
if code >= 400:
Expand Down
Loading

0 comments on commit db7bc86

Please sign in to comment.