-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GEC] Fixes for concurrent modification error
- Loading branch information
1 parent
609f20a
commit 35edd08
Showing
2 changed files
with
210 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -392,7 +392,7 @@ describe('GoogleEnhancedConversions', () => { | |
) | ||
}) | ||
|
||
it('handles concurrent_modification error correctly', async () => { | ||
it('handles concurrent_modification error correctly from addOperations API', async () => { | ||
const events: SegmentEvent[] = [ | ||
createTestEvent({ | ||
timestamp, | ||
|
@@ -486,5 +486,195 @@ describe('GoogleEnhancedConversions', () => { | |
|
||
await expect(responses).rejects.toThrowError(RetryableError) | ||
}) | ||
|
||
it('handles concurrent_modification error correctly from create offlineUserDataJobs API', async () => { | ||
const events: SegmentEvent[] = [ | ||
createTestEvent({ | ||
timestamp, | ||
event: 'Audience Entered', | ||
properties: { | ||
gclid: '54321', | ||
email: '[email protected]', | ||
orderId: '1234', | ||
phone: '1234567890', | ||
firstName: 'Jane', | ||
lastName: 'Doe', | ||
currency: 'USD', | ||
value: '123', | ||
address: { | ||
street: '123 Street SW', | ||
city: 'San Diego', | ||
state: 'CA', | ||
postalCode: '982004' | ||
} | ||
} | ||
}), | ||
createTestEvent({ | ||
timestamp, | ||
event: 'Audience Entered', | ||
properties: { | ||
gclid: '54321', | ||
email: '[email protected]', | ||
orderId: '1234', | ||
phone: '1234567890', | ||
firstName: 'Jane', | ||
lastName: 'Doe', | ||
currency: 'USD', | ||
value: '123', | ||
address: { | ||
street: '123 Street SW', | ||
city: 'San Diego', | ||
state: 'CA', | ||
postalCode: '982004' | ||
} | ||
} | ||
}) | ||
] | ||
|
||
nock(`https://googleads.googleapis.com/${API_VERSION}/customers/${customerId}/offlineUserDataJobs:create`) | ||
.post(/.*/) | ||
.reply(400, { | ||
error: { | ||
code: 400, | ||
details: [ | ||
{ | ||
'@type': 'type.googleapis.com/google.ads.googleads.v17.errors.GoogleAdsFailure', | ||
errors: [ | ||
{ | ||
errorCode: { | ||
databaseError: 'CONCURRENT_MODIFICATION' | ||
}, | ||
message: 'Multiple requests were attempting to modify the same resource at once. Retry the request.' | ||
} | ||
], | ||
requestId: 'OZ5_72C-3qFN9a87mjE7_w' | ||
} | ||
], | ||
message: 'Request contains an invalid argument.', | ||
status: 'INVALID_ARGUMENT' | ||
} | ||
}) | ||
|
||
const responses = testDestination.testBatchAction('userList', { | ||
events, | ||
mapping: { | ||
ad_user_data_consent_state: 'GRANTED', | ||
ad_personalization_consent_state: 'GRANTED', | ||
external_audience_id: '1234', | ||
retlOnMappingSave: { | ||
outputs: { | ||
id: '1234', | ||
name: 'Test List', | ||
external_id_type: 'CONTACT_INFO' | ||
} | ||
} | ||
}, | ||
useDefaultMappings: true, | ||
settings: { | ||
customerId | ||
} | ||
}) | ||
|
||
await expect(responses).rejects.toThrowError(RetryableError) | ||
}) | ||
|
||
it('handles concurrent_modification error correctly from run offlineUserDataJobs API', async () => { | ||
const events: SegmentEvent[] = [ | ||
createTestEvent({ | ||
timestamp, | ||
event: 'Audience Entered', | ||
properties: { | ||
gclid: '54321', | ||
email: '[email protected]', | ||
orderId: '1234', | ||
phone: '1234567890', | ||
firstName: 'Jane', | ||
lastName: 'Doe', | ||
currency: 'USD', | ||
value: '123', | ||
address: { | ||
street: '123 Street SW', | ||
city: 'San Diego', | ||
state: 'CA', | ||
postalCode: '982004' | ||
} | ||
} | ||
}), | ||
createTestEvent({ | ||
timestamp, | ||
event: 'Audience Entered', | ||
properties: { | ||
gclid: '54321', | ||
email: '[email protected]', | ||
orderId: '1234', | ||
phone: '1234567890', | ||
firstName: 'Jane', | ||
lastName: 'Doe', | ||
currency: 'USD', | ||
value: '123', | ||
address: { | ||
street: '123 Street SW', | ||
city: 'San Diego', | ||
state: 'CA', | ||
postalCode: '982004' | ||
} | ||
} | ||
}) | ||
] | ||
|
||
nock(`https://googleads.googleapis.com/${API_VERSION}/customers/${customerId}/offlineUserDataJobs:create`) | ||
.post(/.*/) | ||
.reply(200, { data: 'offlineDataJob' }) | ||
|
||
nock(`https://googleads.googleapis.com/${API_VERSION}/offlineDataJob:addOperations`) | ||
.post(/.*/) | ||
.reply(200, { data: 'offlineDataJob' }) | ||
|
||
nock(`https://googleads.googleapis.com/${API_VERSION}/offlineDataJob:run`) | ||
.post(/.*/) | ||
.reply(400, { | ||
error: { | ||
code: 400, | ||
details: [ | ||
{ | ||
'@type': 'type.googleapis.com/google.ads.googleads.v17.errors.GoogleAdsFailure', | ||
errors: [ | ||
{ | ||
errorCode: { | ||
databaseError: 'CONCURRENT_MODIFICATION' | ||
}, | ||
message: 'Multiple requests were attempting to modify the same resource at once. Retry the request.' | ||
} | ||
], | ||
requestId: 'OZ5_72C-3qFN9a87mjE7_w' | ||
} | ||
], | ||
message: 'Request contains an invalid argument.', | ||
status: 'INVALID_ARGUMENT' | ||
} | ||
}) | ||
|
||
const responses = testDestination.testBatchAction('userList', { | ||
events, | ||
mapping: { | ||
ad_user_data_consent_state: 'GRANTED', | ||
ad_personalization_consent_state: 'GRANTED', | ||
external_audience_id: '1234', | ||
retlOnMappingSave: { | ||
outputs: { | ||
id: '1234', | ||
name: 'Test List', | ||
external_id_type: 'CONTACT_INFO' | ||
} | ||
} | ||
}, | ||
useDefaultMappings: true, | ||
settings: { | ||
customerId | ||
} | ||
}) | ||
|
||
await expect(responses).rejects.toThrowError(RetryableError) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters