Skip to content

Commit a5fadc8

Browse files
add kustothrottle test (#619)
* add kustothrottle test * Update azure-kusto-ingest/tests/test_managed_streaming_ingest.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 312c243 commit a5fadc8

File tree

1 file changed

+39
-26
lines changed

1 file changed

+39
-26
lines changed

azure-kusto-ingest/tests/test_managed_streaming_ingest.py

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def is_blob(request):
2626
return request.param == "Blob"
2727

2828

29-
def transient_error_callback(helper: TransientResponseHelper, request, custom_request_id=None):
29+
def transient_error_callback(helper: TransientResponseHelper, request, custom_request_id=None, use_kusto_throttling_error=False):
3030
if custom_request_id:
3131
assert request.headers["x-ms-client-request-id"] == custom_request_id
3232
else:
@@ -36,31 +36,44 @@ def transient_error_callback(helper: TransientResponseHelper, request, custom_re
3636
helper.total_calls += 1
3737

3838
if helper.total_calls <= helper.times_to_fail:
39-
response_status = 400
40-
response_body = {
41-
"error": {
42-
"code": "General_InternalServerError",
43-
"message": "Unknown error",
44-
"@type": "Kusto.DataNode.Exceptions.InternalServerError",
45-
"@message": "InternalServerError",
46-
"@context": {
47-
"timestamp": "2021-10-21T14:12:00.7878847Z",
48-
"serviceAlias": "SomeCluster",
49-
"machineName": "KEngine000000",
50-
"processName": "Kusto.WinSvc.Svc",
51-
"processId": 3040,
52-
"threadId": 7524,
53-
"appDomainName": "Kusto.WinSvc.Svc.exe",
54-
"clientRequestId": "KNC.executeStreamingIngest;a4d80ca5-8729-404b-b745-0d5555737483",
55-
"activityId": "bace3d9d-d949-457e-b741-1d2c6bc56658",
56-
"subActivityId": "bace3d9d-d949-457e-b741-1d2c6bc56658",
57-
"activityType": "PO.OWIN.CallContext",
58-
"parentActivityId": "bace3d9d-d949-457e-b741-1d2c6bc56658",
59-
"activityStack": "(Activity stack: CRID=KNC.executeStreamingIngest;a4d80ca5-8729-404b-b745-0d5555737493 ARID=bace3d9d-d949-457e-b741-1d2c6bc56678 > PO.OWIN.CallContext/bace3d9d-d949-457e-b741-1d2c6bc56678 > PO.OWIN.CallContext/bace3d9d-d949-457e-b741-1d2c6bc56678)",
60-
},
61-
"@permanent": False,
39+
if use_kusto_throttling_error:
40+
response_status = 429
41+
response_body = {
42+
"error": {
43+
"code": "Throttling",
44+
"message": "Request was throttled.",
45+
"@type": "Kusto.DataNode.Exceptions.ThrottlingException",
46+
"@message": "ThrottlingException",
47+
"@context": {},
48+
"@permanent": False,
49+
}
50+
}
51+
else:
52+
response_status = 400
53+
response_body = {
54+
"error": {
55+
"code": "General_InternalServerError",
56+
"message": "Unknown error",
57+
"@type": "Kusto.DataNode.Exceptions.InternalServerError",
58+
"@message": "InternalServerError",
59+
"@context": {
60+
"timestamp": "2021-10-21T14:12:00.7878847Z",
61+
"serviceAlias": "SomeCluster",
62+
"machineName": "KEngine000000",
63+
"processName": "Kusto.WinSvc.Svc",
64+
"processId": 3040,
65+
"threadId": 7524,
66+
"appDomainName": "Kusto.WinSvc.Svc.exe",
67+
"clientRequestId": "KNC.executeStreamingIngest;a4d80ca5-8729-404b-b745-0d5555737483",
68+
"activityId": "bace3d9d-d949-457e-b741-1d2c6bc56658",
69+
"subActivityId": "bace3d9d-d949-457e-b741-1d2c6bc56658",
70+
"activityType": "PO.OWIN.CallContext",
71+
"parentActivityId": "bace3d9d-d949-457e-b741-1d2c6bc56658",
72+
"activityStack": "(Activity stack: CRID=KNC.executeStreamingIngest;a4d80ca5-8729-404b-b745-0d5555737493 ARID=bace3d9d-d949-457e-b741-1d2c6bc56678 > PO.OWIN.CallContext/bace3d9d-d949-457e-b741-1d2c6bc56678 > PO.OWIN.CallContext/bace3d9d-d949-457e-b741-1d2c6bc56678)",
73+
},
74+
"@permanent": False,
75+
}
6276
}
63-
}
6477
else:
6578
response_status = 200
6679
response_body = {
@@ -205,7 +218,7 @@ def test_fallback_transient_errors_limit(self, mock_uuid, mock_put_message_in_qu
205218
responses.add_callback(
206219
responses.POST,
207220
"https://somecluster.kusto.windows.net/v1/rest/ingest/database/table",
208-
callback=lambda request: transient_error_callback(helper, request),
221+
callback=lambda request: transient_error_callback(helper, request, use_kusto_throttling_error=True),
209222
content_type="application/json",
210223
)
211224

0 commit comments

Comments
 (0)