Core: Allow compressed requests for query-protocol (#7382)
This commit is contained in:
parent
f9add957c9
commit
cfbc275e02
@ -343,8 +343,6 @@ class BaseResponse(_TemplateEnvironmentMixin, ActionAuthenticatorMixin):
|
|||||||
if hasattr(self.body, "read"):
|
if hasattr(self.body, "read"):
|
||||||
self.body = self.body.read()
|
self.body = self.body.read()
|
||||||
|
|
||||||
raw_body = self.body
|
|
||||||
|
|
||||||
# https://github.com/getmoto/moto/issues/6692
|
# https://github.com/getmoto/moto/issues/6692
|
||||||
# Content coming from SDK's can be GZipped for performance reasons
|
# Content coming from SDK's can be GZipped for performance reasons
|
||||||
if (
|
if (
|
||||||
@ -379,7 +377,7 @@ class BaseResponse(_TemplateEnvironmentMixin, ActionAuthenticatorMixin):
|
|||||||
OrderedDict(
|
OrderedDict(
|
||||||
(key, [value])
|
(key, [value])
|
||||||
for key, value in parse_qsl(
|
for key, value in parse_qsl(
|
||||||
raw_body, keep_blank_values=True
|
self.body, keep_blank_values=True
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -2,6 +2,7 @@ import copy
|
|||||||
from datetime import datetime, timedelta, timezone
|
from datetime import datetime, timedelta, timezone
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
|
from unittest import SkipTest
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
import boto3
|
import boto3
|
||||||
@ -10,7 +11,7 @@ from botocore.exceptions import ClientError
|
|||||||
from dateutil.tz import tzutc
|
from dateutil.tz import tzutc
|
||||||
from freezegun import freeze_time
|
from freezegun import freeze_time
|
||||||
|
|
||||||
from moto import mock_aws
|
from moto import mock_aws, settings
|
||||||
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
|
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
|
||||||
from moto.core.utils import utcnow
|
from moto.core.utils import utcnow
|
||||||
|
|
||||||
@ -27,6 +28,43 @@ def test_put_metric_data_no_dimensions():
|
|||||||
assert {"Namespace": "tester", "MetricName": "metric", "Dimensions": []} in metrics
|
assert {"Namespace": "tester", "MetricName": "metric", "Dimensions": []} in metrics
|
||||||
|
|
||||||
|
|
||||||
|
@mock_aws
|
||||||
|
def test_put_a_ton_of_metric_data():
|
||||||
|
"""
|
||||||
|
A sufficiently large call with metric data triggers request compression
|
||||||
|
Moto should decompress the request if this is the case, and the request should succeed
|
||||||
|
"""
|
||||||
|
if not settings.TEST_DECORATOR_MODE:
|
||||||
|
raise SkipTest("Can't test large requests in ServerMode")
|
||||||
|
cloudwatch = boto3.client("cloudwatch", "us-east-1")
|
||||||
|
|
||||||
|
metrics = []
|
||||||
|
metric_dimensions = [{"Name": "Environment", "Value": "env1"}]
|
||||||
|
metric_args = {"Unit": "Seconds", "MetricName": "TestCWMetrics"}
|
||||||
|
|
||||||
|
for type, licences in {
|
||||||
|
k: v
|
||||||
|
for k, v in {
|
||||||
|
"userTypes": [{"id": f"UserType{x}"} for x in range(0, 50)]
|
||||||
|
}.items()
|
||||||
|
if k in ["userTypes", "appBundles", "apps", "extensions", "portalCapabilities"]
|
||||||
|
}.items():
|
||||||
|
for licence in licences:
|
||||||
|
metrics.append(
|
||||||
|
{
|
||||||
|
**metric_args,
|
||||||
|
"Dimensions": [
|
||||||
|
*metric_dimensions,
|
||||||
|
{"Name": "Type", "Value": f"{type}/{licence['id']}"},
|
||||||
|
],
|
||||||
|
"Value": 1,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
cloudwatch.put_metric_data(Namespace="acme", MetricData=metrics)
|
||||||
|
# We don't really need any assertions - we just need to know that the call succeeds
|
||||||
|
|
||||||
|
|
||||||
@mock_aws
|
@mock_aws
|
||||||
def test_put_metric_data_can_not_have_nan():
|
def test_put_metric_data_can_not_have_nan():
|
||||||
client = boto3.client("cloudwatch", region_name="us-west-2")
|
client = boto3.client("cloudwatch", region_name="us-west-2")
|
||||||
|
Loading…
Reference in New Issue
Block a user