Skip to content

Commit

Permalink
chore: add support for live testing of cdk v2 destination (#1471)
Browse files Browse the repository at this point in the history
* fix: cdk utils and handlers

* Add pinterest workflows

* refactor: use workflow engine factory

Create workflow engine using factory rather than constructor.

* Improve concurrent processing by caching promises

* Upgrade: workflow engine version

* Fix PR comments

* Implement PR suggestions

* Remove unused property

* chore: add cdk v2 live test capability

* fix: PR comments

* chore: add support for live testing of cdk v2 destination

Add utils to compare objects.
Wrap router and process transformation handlers to allow comparison.

* Fix issues with comparision

* Fix: PR comments

* Refactor common util

* Fix PR comments

* Update live test config to take thresholds

* Update versionedRouter.js

Co-authored-by: Sai Kumar Battinoju <[email protected]>

* Rename cdkV2Test to cdkV2TestThreshold

* Fix typo

Co-authored-by: Sai Kumar Battinoju <[email protected]>
  • Loading branch information
koladilip and saikumarrs authored Oct 13, 2022
1 parent bf0be4f commit 7098b64
Show file tree
Hide file tree
Showing 12 changed files with 3,375 additions and 59 deletions.
1,492 changes: 1,492 additions & 0 deletions __tests__/data/versioned_processor_pinterest_tag_input.json

Large diffs are not rendered by default.

657 changes: 657 additions & 0 deletions __tests__/data/versioned_processor_pinterest_tag_output.json

Large diffs are not rendered by default.

732 changes: 732 additions & 0 deletions __tests__/data/versioned_router_pinterest_tag_input.json

Large diffs are not rendered by default.

329 changes: 329 additions & 0 deletions __tests__/data/versioned_router_pinterest_tag_output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,329 @@
{
"output": [
{
"batchedRequest": {
"version": "1",
"type": "REST",
"method": "POST",
"endpoint": "https://ct.pinterest.com/events/v3",
"headers": { "Content-Type": "application/json" },
"params": {},
"body": {
"JSON": {
"data": [
{
"event_name": "Watch Video",
"event_time": 1597383030,
"action_source": "web",
"event_id": "7208bbb6-2c4e-45bb-bf5b-ad426f3593e9",
"app_id": "429047995",
"advertiser_id": "429047995",
"user_data": {
"em": [
"48ddb93f0b30c475423fe177832912c5bcdce3cc72872f8051627967ef278e08"
],
"ph": [
"d164bbe036663cb5c96835e9ccc6501e9a521127ea62f6359744928ba932413b"
],
"ln": [
"bdfdee6414a89d72bfbf5ee90b1f85924467bae1e3980d83c2cd348dc31d5819"
],
"fn": [
"ee5db3fe0253b651aca3676692e0c59b25909304f5c51d223a02a215d104144b"
],
"ct": [
"6689106ca7922c30b2fd2c175c85bc7fc2d52cc4941bdd7bb622c6cdc6284a85"
],
"st": [
"3b45022ab36728cdae12e709e945bba267c50ee8a91e6e4388539a8e03a3fdcd"
],
"zp": [
"1a4292e00780e18d00e76fde9850aee5344e939ba593333cd5e4b4aa2cd33b0c"
],
"country": [
"582967534d0f909d196b97f9e6921342777aea87b46fa52df165389db1fb8ccf"
],
"hashed_maids": [
"6ca13d52ca70c883e0f0bb101e425a89e8624de51db2d2392593af6a84118090"
],
"client_user_agent": "chrome"
},
"custom_data": {
"currency": "USD",
"value": 27.5,
"order_id": "50314b8e9bcf000000000000",
"num_items": 3,
"content_ids": [
"507f1f77bcf86cd799439011",
"505bd76785ebb509fc183733"
],
"contents": [
{ "quantity": 1, "item_price": "19" },
{ "quantity": 2, "item_price": "3" }
]
}
},
{
"event_name": "Signup",
"event_time": 1597383030,
"action_source": "web",
"event_id": "7208bbb6-2c4e-45bb-bf5b-ad426f3593e9",
"app_id": "429047995",
"advertiser_id": "429047995",
"user_data": {
"em": [
"48ddb93f0b30c475423fe177832912c5bcdce3cc72872f8051627967ef278e08"
],
"ph": [
"d164bbe036663cb5c96835e9ccc6501e9a521127ea62f6359744928ba932413b"
],
"ln": [
"bdfdee6414a89d72bfbf5ee90b1f85924467bae1e3980d83c2cd348dc31d5819"
],
"fn": [
"ee5db3fe0253b651aca3676692e0c59b25909304f5c51d223a02a215d104144b"
],
"ct": [
"6689106ca7922c30b2fd2c175c85bc7fc2d52cc4941bdd7bb622c6cdc6284a85"
],
"st": [
"3b45022ab36728cdae12e709e945bba267c50ee8a91e6e4388539a8e03a3fdcd"
],
"zp": [
"1a4292e00780e18d00e76fde9850aee5344e939ba593333cd5e4b4aa2cd33b0c"
],
"country": [
"582967534d0f909d196b97f9e6921342777aea87b46fa52df165389db1fb8ccf"
],
"hashed_maids": [
"6ca13d52ca70c883e0f0bb101e425a89e8624de51db2d2392593af6a84118090"
],
"client_user_agent": "chrome"
},
"custom_data": {
"currency": "USD",
"value": 27.5,
"order_id": "50314b8e9bcf000000000000",
"num_items": 3,
"content_ids": [
"507f1f77bcf86cd799439011",
"505bd76785ebb509fc183733"
],
"contents": [
{ "quantity": 1, "item_price": "19" },
{ "quantity": 2, "item_price": "3" }
]
}
},
{
"event_name": "Checkout",
"event_time": 1597383030,
"action_source": "web",
"event_id": "7208bbb6-2c4e-45bb-bf5b-ad426f3593e9",
"app_id": "429047995",
"advertiser_id": "429047995",
"user_data": {
"em": [
"48ddb93f0b30c475423fe177832912c5bcdce3cc72872f8051627967ef278e08"
],
"ph": [
"d164bbe036663cb5c96835e9ccc6501e9a521127ea62f6359744928ba932413b"
],
"ln": [
"bdfdee6414a89d72bfbf5ee90b1f85924467bae1e3980d83c2cd348dc31d5819"
],
"fn": [
"ee5db3fe0253b651aca3676692e0c59b25909304f5c51d223a02a215d104144b"
],
"ct": [
"6689106ca7922c30b2fd2c175c85bc7fc2d52cc4941bdd7bb622c6cdc6284a85"
],
"st": [
"3b45022ab36728cdae12e709e945bba267c50ee8a91e6e4388539a8e03a3fdcd"
],
"zp": [
"1a4292e00780e18d00e76fde9850aee5344e939ba593333cd5e4b4aa2cd33b0c"
],
"country": [
"582967534d0f909d196b97f9e6921342777aea87b46fa52df165389db1fb8ccf"
],
"hashed_maids": [
"6ca13d52ca70c883e0f0bb101e425a89e8624de51db2d2392593af6a84118090"
],
"client_user_agent": "chrome"
},
"custom_data": {
"currency": "USD",
"value": 27.5,
"order_id": "50314b8e9bcf000000000000",
"num_items": 3,
"content_ids": [
"507f1f77bcf86cd799439011",
"505bd76785ebb509fc183733"
],
"contents": [
{ "quantity": 1, "item_price": "19" },
{ "quantity": 2, "item_price": "3" }
]
}
},
{
"event_name": "AddToCart",
"event_time": 1597383030,
"action_source": "web",
"event_id": "7208bbb6-2c4e-45bb-bf5b-ad426f3593e9",
"app_id": "429047995",
"advertiser_id": "429047995",
"user_data": {
"em": [
"48ddb93f0b30c475423fe177832912c5bcdce3cc72872f8051627967ef278e08"
],
"ph": [
"d164bbe036663cb5c96835e9ccc6501e9a521127ea62f6359744928ba932413b"
],
"ln": [
"bdfdee6414a89d72bfbf5ee90b1f85924467bae1e3980d83c2cd348dc31d5819"
],
"fn": [
"ee5db3fe0253b651aca3676692e0c59b25909304f5c51d223a02a215d104144b"
],
"ct": [
"6689106ca7922c30b2fd2c175c85bc7fc2d52cc4941bdd7bb622c6cdc6284a85"
],
"st": [
"3b45022ab36728cdae12e709e945bba267c50ee8a91e6e4388539a8e03a3fdcd"
],
"zp": [
"1a4292e00780e18d00e76fde9850aee5344e939ba593333cd5e4b4aa2cd33b0c"
],
"country": [
"582967534d0f909d196b97f9e6921342777aea87b46fa52df165389db1fb8ccf"
],
"hashed_maids": [
"6ca13d52ca70c883e0f0bb101e425a89e8624de51db2d2392593af6a84118090"
],
"client_user_agent": "chrome"
},
"custom_data": {
"currency": "USD",
"value": 27.5,
"order_id": "50314b8e9bcf000000000000",
"num_items": 2,
"content_ids": ["123"],
"contents": [{ "quantity": 2, "item_price": "25" }]
}
},
{
"event_name": "Signup",
"event_time": 1597383030,
"action_source": "web",
"event_id": "7208bbb6-2c4e-45bb-bf5b-ad426f3593e9",
"app_id": "429047995",
"advertiser_id": "429047995",
"user_data": {
"em": [
"48ddb93f0b30c475423fe177832912c5bcdce3cc72872f8051627967ef278e08"
],
"ph": [
"d164bbe036663cb5c96835e9ccc6501e9a521127ea62f6359744928ba932413b"
],
"ln": [
"bdfdee6414a89d72bfbf5ee90b1f85924467bae1e3980d83c2cd348dc31d5819"
],
"fn": [
"ee5db3fe0253b651aca3676692e0c59b25909304f5c51d223a02a215d104144b"
],
"ct": [
"6689106ca7922c30b2fd2c175c85bc7fc2d52cc4941bdd7bb622c6cdc6284a85"
],
"st": [
"3b45022ab36728cdae12e709e945bba267c50ee8a91e6e4388539a8e03a3fdcd"
],
"zp": [
"1a4292e00780e18d00e76fde9850aee5344e939ba593333cd5e4b4aa2cd33b0c"
],
"country": [
"582967534d0f909d196b97f9e6921342777aea87b46fa52df165389db1fb8ccf"
],
"hashed_maids": [
"6ca13d52ca70c883e0f0bb101e425a89e8624de51db2d2392593af6a84118090"
],
"client_user_agent": "chrome"
},
"custom_data": {
"currency": "USD",
"value": 27.5,
"order_id": "50314b8e9bcf000000000000",
"num_items": 3,
"content_ids": [
"507f1f77bcf86cd799439011",
"505bd76785ebb509fc183733"
],
"contents": [
{ "quantity": 1, "item_price": "19" },
{ "quantity": 2, "item_price": "3" }
]
}
}
]
},
"JSON_ARRAY": {},
"XML": {},
"FORM": {}
},
"files": {}
},
"metadata": [
{ "jobId": 1 },
{ "jobId": 1 },
{ "jobId": 2 },
{ "jobId": 3 },
{ "jobId": 5 }
],
"batched": true,
"statusCode": 200,
"destination": {
"ID": "1pYpzzvcn7AQ2W9GGIAZSsN6Mfq",
"Name": "PINTEREST_TAG",
"Config": {
"tagId": "123456789",
"advertiserId": "429047995",
"appId": "429047995",
"sendingUnHashedData": true,
"enableDeduplication": true,
"deduplicationKey": "messageId",
"enhancedMatch": true,
"customProperties": [
{ "properties": "presentclass" },
{ "properties": "presentgrade" }
],
"eventsMapping": [
{ "from": "ABC Searched", "to": "Watch Video" },
{ "from": "ABC Searched", "to": "Signup" },
{ "from": "User Signup", "to": "Signup" },
{ "from": "User Created", "to": "Signup" }
]
},
"DestinationDefinition": {
"Config": {
"cdkV2TestThreshold": 1
}
},
"Enabled": true,
"Transformations": []
}
},
{
"metadata": [{ "jobId": 4 }],
"batched": false,
"statusCode": 400,
"error": "Advertiser Id not found. Aborting"
},
{
"metadata": [{ "jobId": 6 }],
"batched": false,
"statusCode": 400,
"error": "Advertiser Id not found. Aborting"
}
]
}
5 changes: 1 addition & 4 deletions __tests__/pinterestConversion-cdk.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ describe(`${name} Tests`, () => {
try {
const procWorkflowEngine = await procWorkflowEnginePromise;
const result = await procWorkflowEngine.execute(input);
// JSONata use internal implementation for arrays so
// they won't compare exactly so we need to use serialize and
// deserialize to normalize them for comparison.
expect(JSON.parse(JSON.stringify(result.output))).toEqual(expected);
expect(result.output).toEqual(expected);
} catch (error) {
expect(error.message).toEqual(expected.error);
}
Expand Down
2 changes: 0 additions & 2 deletions cdk/v2/handler.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const { WorkflowEngineFactory } = require("rudder-workflow-engine");
const logger = require("../../logger");

const ErrorBuilder = require("../../v0/util/error");
const {
getRootPathForDestination,
getWorkflowPath,
Expand Down
Loading

0 comments on commit 7098b64

Please sign in to comment.