Skip to content

Commit

Permalink
test: add network failure testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauravudia committed Mar 12, 2024
1 parent 6fdf273 commit c5c59f3
Show file tree
Hide file tree
Showing 4 changed files with 223 additions and 254 deletions.
9 changes: 6 additions & 3 deletions test/integrations/destinations/the_trade_desk/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const sampleContext = {
sources: sampleSource,
};

const proxyV1NetworkErrorStatTags = {
const proxyV1AbortableErrorStatTags = {
destType: destTypeInUpperCase,
destinationId: 'default-destinationId',
errorCategory: 'network',
Expand All @@ -58,9 +58,11 @@ const proxyV1NetworkErrorStatTags = {
workspaceId: 'default-workspaceId',
};

const { errorType: _, ...proxyV1PlatformErrorStatTags } = proxyV1NetworkErrorStatTags;
const { errorType: _, ...proxyV1PlatformErrorStatTags } = proxyV1AbortableErrorStatTags;
proxyV1PlatformErrorStatTags.errorCategory = 'platform';

const proxyV1RetryableErrorStatTags = { ...proxyV1AbortableErrorStatTags, errorType: 'retryable' };

export {
destType,
destTypeInUpperCase,
Expand All @@ -69,7 +71,8 @@ export {
segmentName,
sampleDestination,
sampleContext,
proxyV1NetworkErrorStatTags,
proxyV1AbortableErrorStatTags,
proxyV1PlatformErrorStatTags,
proxyV1RetryableErrorStatTags,
firstPartyDataEndpoint,
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
dataProviderId,
segmentName,
sampleDestination,
proxyV1NetworkErrorStatTags,
proxyV1AbortableErrorStatTags,
firstPartyDataEndpoint,
} from '../common';

Expand Down Expand Up @@ -165,7 +165,7 @@ export const businessProxyV1: ProxyV1TestData[] = [
statusCode: 400,
},
],
statTags: proxyV1NetworkErrorStatTags,
statTags: proxyV1AbortableErrorStatTags,
status: 400,
},
},
Expand Down
251 changes: 3 additions & 248 deletions test/integrations/destinations/the_trade_desk/delivery/data.ts
Original file line number Diff line number Diff line change
@@ -1,248 +1,3 @@
import {
destType,
destTypeInUpperCase,
advertiserId,
dataProviderId,
segmentName,
sampleDestination,
} from '../common';

beforeAll(() => {
process.env.THE_TRADE_DESK_DATA_PROVIDER_SECRET_KEY = 'mockedDataProviderSecretKey';
});

afterAll(() => {
delete process.env.THE_TRADE_DESK_DATA_PROVIDER_SECRET_KEY;
});

export const data = [
{
name: destType,
description: 'Successful delivery of Add/Remove IDs to/from Trade Desk',
feature: 'dataDelivery',
module: 'destination',
version: 'v0',
input: {
request: {
body: {
version: '1',
type: 'REST',
method: 'POST',
endpoint: 'https://sin-data.adsrvr.org/data/advertiser',
headers: {},
params: {},
destinationConfig: sampleDestination.Config,
body: {
JSON: {
AdvertiserId: advertiserId,
DataProviderId: dataProviderId,
Items: [
{
DAID: 'test-daid-1',
Data: [
{
Name: segmentName,
TTLInMinutes: 43200,
},
],
},
{
Data: [
{
Name: segmentName,
TTLInMinutes: 43200,
},
],
UID2: 'test-uid2-1',
},
{
DAID: 'test-daid-2',
Data: [
{
Name: segmentName,
TTLInMinutes: 0,
},
],
},
{
Data: [
{
Name: segmentName,
TTLInMinutes: 0,
},
],
UID2: 'test-uid2-2',
},
],
},
JSON_ARRAY: {},
XML: {},
FORM: {},
},
files: {},
userId: '',
},
method: 'POST',
},
},
output: {
response: {
status: 200,
body: {
output: {
destinationResponse: {
response: {},
status: 200,
},
message: 'Request Processed Successfully',
status: 200,
},
},
},
},
},
{
name: destType,
description: 'Error response from The Trade Desk due to invalid IDs',
feature: 'dataDelivery',
module: 'destination',
version: 'v0',
input: {
request: {
body: {
version: '1',
type: 'REST',
method: 'POST',
endpoint: 'https://sin-data.adsrvr.org/data/advertiser',
headers: {},
params: {},
destinationConfig: sampleDestination.Config,
body: {
JSON: {
AdvertiserId: advertiserId,
DataProviderId: dataProviderId,
Items: [
{
DAID: 'test-daid',
Data: [
{
Name: segmentName,
TTLInMinutes: 43200,
},
],
},
{
Data: [
{
Name: segmentName,
TTLInMinutes: 43200,
},
],
UID2: 'test-invalid-uid2',
},
],
},
JSON_ARRAY: {},
XML: {},
FORM: {},
},
files: {},
userId: '',
},
method: 'POST',
},
},
output: {
response: {
status: 400,
body: {
output: {
destinationResponse: {
response: {
FailedLines: [{ ErrorCode: 'MissingUserId', Message: 'Invalid UID2, item #2' }],
},
status: 200,
},
message:
'Request failed with status: 200 due to {"FailedLines":[{"ErrorCode":"MissingUserId","Message":"Invalid UID2, item #2"}]}',
statTags: {
destType: destTypeInUpperCase,
destinationId: 'Non-determininable',
errorCategory: 'network',
errorType: 'aborted',
feature: 'dataDelivery',
implementation: 'native',
module: 'destination',
workspaceId: 'Non-determininable',
},
status: 400,
},
},
},
},
},
{
name: destType,
description:
'Missing advertiser secret key in destination config from proxy request from server',
feature: 'dataDelivery',
module: 'destination',
version: 'v0',
input: {
request: {
body: {
version: '1',
type: 'REST',
method: 'POST',
endpoint: 'https://sin-data.adsrvr.org/data/advertiser',
headers: {},
params: {},
body: {
JSON: {
AdvertiserId: advertiserId,
DataProviderId: dataProviderId,
Items: [
{
DAID: 'test-daid-1',
Data: [
{
Name: segmentName,
TTLInMinutes: 43200,
},
],
},
],
},
JSON_ARRAY: {},
XML: {},
FORM: {},
},
files: {},
userId: '',
},
method: 'POST',
},
},
output: {
response: {
status: 400,
body: {
output: {
destinationResponse: '',
message: 'Advertiser secret key is missing in destination config. Aborting',
statTags: {
destType: destTypeInUpperCase,
destinationId: 'Non-determininable',
errorCategory: 'platform',
feature: 'dataDelivery',
implementation: 'native',
module: 'destination',
workspaceId: 'Non-determininable',
},
status: 400,
},
},
},
},
},
];
import { businessProxyV1 } from './business';
import { otherProxyV1 } from './other';
export const data = [...businessProxyV1, ...otherProxyV1];
Loading

0 comments on commit c5c59f3

Please sign in to comment.