Skip to content

Commit

Permalink
feat: update movable ink batch size (#3223)
Browse files Browse the repository at this point in the history
* feat: update movable ink batch size

* test: add testcase for batching on max request size
  • Loading branch information
Gauravudia authored Apr 1, 2024
1 parent 2f30c56 commit 667095f
Show file tree
Hide file tree
Showing 9 changed files with 437 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/cdk/v2/destinations/movable_ink/config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
module.exports = {
MAX_REQUEST_SIZE_IN_BYTES: 13500,
MAX_REQUEST_SIZE_IN_BYTES: 1000000,
MAX_BATCH_SIZE: 1000,
};
1 change: 1 addition & 0 deletions src/cdk/v2/destinations/movable_ink/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ steps:
$.assertConfig(.destination.Config.accessKey, "Access key is not present . Aborting");
$.assertConfig(.destination.Config.accessSecret, "Access Secret is not present. Aborting");
$.assert(.message.timestamp ?? .message.originalTimestamp, "Timestamp is not present. Aborting");
$.assert(!(messageType === {{$.EventType.TRACK}} && !(.message.event)), "Event name is not present. Aborting");
const userId = .message.().(
{{{{$.getGenericPaths("userIdOnly")}}}};
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/v2/destinations/movable_ink/rtWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ steps:
description: Batches the successfulEvents
template: |
let batches = $.BatchUtils.chunkArrayBySizeAndLength(
$.outputs.successfulEvents, {maxSizeInBytes: $.MAX_REQUEST_SIZE_IN_BYTES}).items;
$.outputs.successfulEvents, {maxSizeInBytes: $.MAX_REQUEST_SIZE_IN_BYTES, maxItems: $.MAX_BATCH_SIZE}).items;
batches@batch.({
"batchedRequest": {
Expand Down
180 changes: 180 additions & 0 deletions test/integrations/destinations/movable_ink/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,186 @@ const trackTestProperties = {
position: 2,
category: 'Games',
},
{
product_id: '122c6f5d5cf86a4c77358033',
sku: '7472-998-0112',
name: 'Ticket to Ride',
price: 20,
position: 3,
category: 'Games',
},
{
product_id: '222c6f5d5cf86a4c77358033',
sku: '9472-998-0112',
name: 'Catan',
price: 30,
position: 4,
category: 'Games',
},
{
product_id: '322c6f5d5cf86a4c77358033',
sku: '7472-998-0112',
name: 'Pandemic',
price: 25,
position: 5,
category: 'Games',
},
{
product_id: '422c6f5d5cf86a4c77358033',
sku: '8472-998-0113',
name: 'Exploding Kittens',
price: 15,
position: 6,
category: 'Games',
},
{
product_id: '522c6f5d5cf86a4c77358033',
sku: '8472-998-0114',
name: 'Codenames',
price: 18,
position: 7,
category: 'Games',
},
{
product_id: '622c6f5d5cf86a4c77358034',
sku: '8472-998-0115',
name: 'Scythe',
price: 35,
position: 8,
category: 'Games',
},
{
product_id: '622c6f5d5cf86a4c77358033',
sku: '8472-998-0112',
name: 'Cones of Dunshire',
price: 40,
position: 1,
category: 'Games',
url: 'https://www.website.com/product/path',
image_url: 'https://www.website.com/product/path.jpg',
},
{
product_id: '577c6f5d5cf86a4c7735ba03',
sku: '3309-483-2201',
name: 'Five Crowns',
price: 5,
position: 2,
category: 'Games',
},
{
product_id: '122c6f5d5cf86a4c77358033',
sku: '7472-998-0112',
name: 'Ticket to Ride',
price: 20,
position: 3,
category: 'Games',
},
{
product_id: '222c6f5d5cf86a4c77358033',
sku: '9472-998-0112',
name: 'Catan',
price: 30,
position: 4,
category: 'Games',
},
{
product_id: '322c6f5d5cf86a4c77358033',
sku: '7472-998-0112',
name: 'Pandemic',
price: 25,
position: 5,
category: 'Games',
},
{
product_id: '422c6f5d5cf86a4c77358033',
sku: '8472-998-0113',
name: 'Exploding Kittens',
price: 15,
position: 6,
category: 'Games',
},
{
product_id: '522c6f5d5cf86a4c77358033',
sku: '8472-998-0114',
name: 'Codenames',
price: 18,
position: 7,
category: 'Games',
},
{
product_id: '622c6f5d5cf86a4c77358034',
sku: '8472-998-0115',
name: 'Scythe',
price: 35,
position: 8,
category: 'Games',
},
{
product_id: '622c6f5d5cf86a4c77358033',
sku: '8472-998-0112',
name: 'Cones of Dunshire',
price: 40,
position: 1,
category: 'Games',
url: 'https://www.website.com/product/path',
image_url: 'https://www.website.com/product/path.jpg',
},
{
product_id: '577c6f5d5cf86a4c7735ba03',
sku: '3309-483-2201',
name: 'Five Crowns',
price: 5,
position: 2,
category: 'Games',
},
{
product_id: '122c6f5d5cf86a4c77358033',
sku: '7472-998-0112',
name: 'Ticket to Ride',
price: 20,
position: 3,
category: 'Games',
},
{
product_id: '222c6f5d5cf86a4c77358033',
sku: '9472-998-0112',
name: 'Catan',
price: 30,
position: 4,
category: 'Games',
},
{
product_id: '322c6f5d5cf86a4c77358033',
sku: '7472-998-0112',
name: 'Pandemic',
price: 25,
position: 5,
category: 'Games',
},
{
product_id: '422c6f5d5cf86a4c77358033',
sku: '8472-998-0113',
name: 'Exploding Kittens',
price: 15,
position: 6,
category: 'Games',
},
{
product_id: '522c6f5d5cf86a4c77358033',
sku: '8472-998-0114',
name: 'Codenames',
price: 18,
position: 7,
category: 'Games',
},
{
product_id: '622c6f5d5cf86a4c77358034',
sku: '8472-998-0115',
name: 'Scythe',
price: 35,
position: 8,
category: 'Games',
},
],
},
'Products Searched': { query: 'HDMI cable', url: 'https://www.website.com/product/path' },
Expand Down
6 changes: 6 additions & 0 deletions test/integrations/destinations/movable_ink/mocks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import config from '../../../../src/cdk/v2/destinations/movable_ink/config';

export const defaultMockFns = () => {
jest.replaceProperty(config, 'MAX_REQUEST_SIZE_IN_BYTES', 5000);
jest.replaceProperty(config, 'MAX_BATCH_SIZE', 2);
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ProcessorTestData } from '../../../testTypes';
import { generateMetadata, transformResultBuilder } from '../../../testUtils';
import { destType, channel, destination, traits, headers } from '../common';
import { destType, destination, traits, headers } from '../common';

export const identify: ProcessorTestData[] = [
{
Expand Down
6 changes: 6 additions & 0 deletions test/integrations/destinations/movable_ink/processor/track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const track: ProcessorTestData[] = [
channel,
anonymousId: 'anonId123',
userId: 'userId123',
event: 'Product Added',
properties: trackTestProperties['Product Added'],
integrations: {
All: true,
Expand All @@ -49,6 +50,7 @@ export const track: ProcessorTestData[] = [
channel,
userId: 'userId123',
anonymousId: 'anonId123',
event: 'Product Added',
properties: trackTestProperties['Product Added'],
integrations: {
All: true,
Expand Down Expand Up @@ -84,6 +86,7 @@ export const track: ProcessorTestData[] = [
channel,
anonymousId: 'anonId123',
userId: 'userId123',
event: 'Order Completed',
properties: trackTestProperties['Order Completed'],
integrations: {
All: true,
Expand All @@ -110,6 +113,7 @@ export const track: ProcessorTestData[] = [
channel,
userId: 'userId123',
anonymousId: 'anonId123',
event: 'Order Completed',
properties: trackTestProperties['Order Completed'],
integrations: {
All: true,
Expand Down Expand Up @@ -145,6 +149,7 @@ export const track: ProcessorTestData[] = [
channel,
anonymousId: 'anonId123',
userId: 'userId123',
event: 'Custom Event',
properties: trackTestProperties['Custom Event'],
integrations: {
All: true,
Expand All @@ -171,6 +176,7 @@ export const track: ProcessorTestData[] = [
channel,
userId: 'userId123',
anonymousId: 'anonId123',
event: 'Custom Event',
properties: trackTestProperties['Custom Event'],
integrations: {
All: true,
Expand Down
44 changes: 44 additions & 0 deletions test/integrations/destinations/movable_ink/processor/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,48 @@ export const validation: ProcessorTestData[] = [
},
},
},
{
id: 'MovableInk-validation-test-6',
name: destType,
description: 'Missing event name',
scenario: 'Framework',
successCriteria: 'Instrumentation Error',
feature: 'processor',
module: 'destination',
version: 'v0',
input: {
request: {
body: [
{
destination,
message: {
type: 'track',
anonymousId: 'anonId123',
userId: 'userId123',
properties: {},
integrations: {
All: true,
},
originalTimestamp: '2024-03-04T15:32:56.409Z',
},
metadata: generateMetadata(1),
},
],
},
},
output: {
response: {
status: 200,
body: [
{
error:
'Event name is not present. Aborting: Workflow: procWorkflow, Step: validateInput, ChildStep: undefined, OriginalError: Event name is not present. Aborting',
metadata: generateMetadata(1),
statTags: processorInstrumentationErrorStatTags,
statusCode: 400,
},
],
},
},
},
];
Loading

0 comments on commit 667095f

Please sign in to comment.