[main][1ds] Enhance Retry Policy Testing for Alignment with Collector Policy (#2249)
* add test * remove 204
This commit is contained in:
Родитель
a82c8e5c87
Коммит
ef9ad261d6
|
@ -23,7 +23,7 @@ const MaxBackoff = 600000;
|
|||
export function retryPolicyShouldRetryForStatus(httpStatusCode: number): boolean {
|
||||
/* tslint:disable:triple-equals */
|
||||
// Disabling triple-equals rule to avoid httpOverrides from failing because they are returning a string value
|
||||
return !((httpStatusCode >= 300 && httpStatusCode < 500 && httpStatusCode != 408 && httpStatusCode != 429)
|
||||
return !((httpStatusCode >= 300 && httpStatusCode < 500 && httpStatusCode != 429)
|
||||
|| (httpStatusCode == 501)
|
||||
|| (httpStatusCode == 505));
|
||||
/* tslint:enable:triple-equals */
|
||||
|
|
|
@ -4,6 +4,7 @@ import { AppInsightsCore, BaseTelemetryPlugin, EventSendType, IAppInsightsCore,
|
|||
import { PostChannel, IXHROverride, IPayloadData } from "../../../src/Index";
|
||||
import { IPostTransmissionTelemetryItem, EventBatchNotificationReason, IChannelConfiguration } from "../../../src/DataModels";
|
||||
import { EventBatch } from "../../../src/EventBatch";
|
||||
import { retryPolicyShouldRetryForStatus } from "../../../src/RetryPolicy";
|
||||
|
||||
interface EventDetail {
|
||||
batches: EventBatch[];
|
||||
|
@ -2528,6 +2529,27 @@ export class HttpManagerTest extends AITestClass {
|
|||
QUnit.assert.equal(fetchCalls.length, 2, "Make sure fetch was called");
|
||||
}
|
||||
});
|
||||
|
||||
this.testCase({
|
||||
name: "HttpManager: RetryPolicy works as expected",
|
||||
useFakeTimers: true,
|
||||
test: () => {
|
||||
// according to the one collector policy
|
||||
// status that should retry : 429, 500, 503
|
||||
// status that should not retry : 204 (will return complete before checking retry in httpManager), 400, 401, 403, 408, 415, 501, 505
|
||||
QUnit.assert.equal(true, retryPolicyShouldRetryForStatus(429), "status code 429 should retry");
|
||||
QUnit.assert.equal(true, retryPolicyShouldRetryForStatus(500), "status code 500 should retry");
|
||||
QUnit.assert.equal(true, retryPolicyShouldRetryForStatus(503), "status code 503 should retry");
|
||||
QUnit.assert.equal(false, retryPolicyShouldRetryForStatus(400), "status code 400 should not retry");
|
||||
QUnit.assert.equal(false, retryPolicyShouldRetryForStatus(401), "status code 401 should not retry");
|
||||
QUnit.assert.equal(false, retryPolicyShouldRetryForStatus(403), "status code 403 should not retry");
|
||||
QUnit.assert.equal(false, retryPolicyShouldRetryForStatus(408), "status code 408 should not retry");
|
||||
QUnit.assert.equal(false, retryPolicyShouldRetryForStatus(415), "status code 415 should not retry");
|
||||
QUnit.assert.equal(false, retryPolicyShouldRetryForStatus(501), "status code 501 should not retry");
|
||||
QUnit.assert.equal(false, retryPolicyShouldRetryForStatus(505), "status code 505 should not retry");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче