2025-11-20 IntegrationTest: Difference between revisions
(→Error) |
|||
| (55 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
Reference: | |||
*[[2020-10-01 - Integration Test Config - Functions|IntegrationtestConfig]] | |||
*[[2020-10-01 - Integration Testing - Lambda Functions|Integrationtesting]] | |||
*[[2025-02-20 - Integration Test examples|Example]] | |||
= File extension = | |||
uploadS3: ".json" | |||
integrationtestConfig: ".js" | |||
=Table test= | |||
<syntaxhighlight lang="JSON"> | |||
[ | |||
{ | |||
integrationTestTag: "Integrationtest_xx", | |||
testStartedTimestamp: 111111111, // start time | |||
bucketName: "integrationtest-config-us-east-2", | |||
lastUpdateUniqueRequestId: "sssss", //_izContext.uniqueRequestId protacts race coditionn dynamodb | |||
testStatus: "passed",//failed,processing,passed | |||
testCompleteTimestamp: 1111113, // all test finish | |||
stages: [ | |||
{ | |||
stageConfig: { | |||
//straight copy of this stage from integration test config | |||
inputEventTag: "xx", | |||
inputEventConfig: {//event input | |||
}, | |||
outputEventTag: "output_xx", | |||
outputEventConfig: {//event out put | |||
}, | |||
resourceName: "ComplexfilterTestProcessComplexfilter",// function name | |||
resourceType: "Lambda", // function name | |||
serviceTag: "Complexfilter",// (initeate sqs) | |||
snsServiceName: "Complexfilter",// (initeate sqs) | |||
snsTopic: "PorcessComplexfilter_In"// (initeate sqs) | |||
}, | |||
stageStatus: "waiting", //waiting|passed|failed, | |||
stageFinishedTimestamp: 111111111,// time that all tests finished and testRecord.stages.{stageKey}.stageStatus updated | |||
stageResults: { | |||
//results at the point of entering the resource (eg a Lambda function is invoked) | |||
inputResult: { | |||
resultTimestamp: 111111111,//{time result saved}, | |||
resultStatus: "passed",//passed|failed, | |||
requestParams: {//event input | |||
} | |||
}, | |||
//results at the point of returning from the resource (eg a Lambda function returns) | |||
outputResult: { | |||
resultTimestamp: 111111111,//{time result saved}, | |||
resultStatus: "passed",//passed|failed, | |||
requestParams: {//event input | |||
} | |||
}, | |||
//results at the point of invoking an external resource (eg the tested Lambda function is invoking another Lambda function) | |||
invokes: { | |||
"serviceName_resourceType_resourceName_inputEventTag ": { | |||
invokeTimestamp: 111111111,//{ time result saved }, | |||
resultTimestamp: 111111112,//{ time result saved }, | |||
resultStatus: "passed",//passed | failed, | |||
invokeParams: {},//{event invoke input config } | |||
requestParams: {}// event invoke input request | |||
}, | |||
}, | |||
dynamodbResults: [ | |||
{ | |||
indexOfDynamodbOutput: 0, | |||
requestParams, | |||
resultStatus: "passed",// | |||
resultTimestamp: 22222 | |||
}] | |||
}, | |||
stageErrors: [ | |||
//misc errors encountered | |||
] | |||
}] | |||
} | |||
] | |||
</syntaxhighlight> | |||
=Seed Data= | |||
integrationtest manager seed date 2 process | |||
=== Main Seed Data=== | |||
:Save file in s3 (in '''buckname''' :integrationtest-config-us-east-2, '''folder''':seedData_integrationTest).For other dev use service,If a developer wants to add more for other important testing purposes. | |||
'''How to use:''' | |||
#Add it from the s3 bucket at this point | |||
#Run batch refreshSeedData [[Developer guide for making Integration Tests#Bash script|batch RefreshSeedData]] | |||
'''Logic''':Process by storage resouse (graph or dynamodb) | |||
:To clean up the seed data in the table after it creates seed data form service deploy and pulls seed data from s3. | |||
=== Refresh Seed Data === | |||
:ProcessRefreshSeedData use seedDataTag for create data environment of '''test''' and can be refresh seeddata re-test agian. | |||
:'''canbe share''' seed data for other test by seed data tag. | |||
'''How to use:''' | |||
:Save file in s3 (for other dav keep in floder dev name) or testConfig/seedData_config(for admin) | |||
'''Folder''' | |||
*dynamoDBSeedDataTags.json | |||
*graphSeedDataTags.json | |||
'''Example''' | |||
==== dynamoDBSeedDataTags ==== | |||
:If set tag in this setting integrationtest is generate seed data. in storage resource dynammodb. | |||
Example | |||
<syntaxhighlight lang="JavaScript"> | |||
{ | |||
"seedDynamodb_abc_ver2": [ // seedDataTag | |||
{ | |||
"tableName": "DelivMethodSTDTestLogicalResultsData", // servcieTag+stage+tablename | |||
"partitionKey": "logicalResultId", | |||
"sortKey": "identifiersId", | |||
"datas": [ | |||
{ | |||
"logicalResultId": "eeeeeeeeee4", | |||
"identifiersId": "lllll123456" | |||
}, | |||
{ | |||
"logicalResultId": "eeeeeeeeee4", | |||
"identifiersId": "lllll777777" | |||
} | |||
] | |||
}, | |||
{ | |||
"tableName": "MLocationsTestFloatingRelationships",// servcieTag+stage+tablename | |||
"partitionKey": "importBatchId", | |||
"sortKey": "identifierRelationshipsId", | |||
"datas": [ | |||
{ | |||
"importBatchId": "2-uuuuuuuuuuuuuu", | |||
"identifierRelationshipsId": "lllll123456" | |||
}, | |||
{ | |||
"importBatchId": "2-uuuuuuuuuuuuuu", | |||
"identifierRelationshipsId": "lllll777777" | |||
}, | |||
{ | |||
"importBatchId": "2-uuuuuuuuuuuuuu", | |||
"identifierRelationshipsId": "lllll99999999" | |||
} | |||
] | |||
}, | |||
{ | |||
"tableName": "MLocationsTestFindDataMain", | |||
"partitionKey": "findDataId", | |||
"datas": [ | |||
{ | |||
"findDataId": "111111" | |||
}, | |||
{ | |||
"findDataId": "22222" | |||
}, | |||
{ | |||
"findDataId": "333333" | |||
} | |||
] | |||
} | |||
] | |||
} | |||
</syntaxhighlight> | |||
==== graphSeedDataTags ==== | |||
:If set tag in this setting integrationtest is generate seed data. in storage resource graphHanler. | |||
Example | |||
<syntaxhighlight lang="JavaScript"> | |||
{ | |||
"seedData_testTag_GG": [ // seedDataTag | |||
{ | |||
"nodes": [ | |||
{ | |||
"nodeLabels": [ | |||
"SellOfferPlan_sellOfferPlanDeliveryMethodLink" | |||
], | |||
"objectDetail": { | |||
"identifiers": { | |||
"sellOfferPlanDeliveryMethodLinkId": "minttestrefreshSeedData_01" | |||
}, | |||
"fields": { | |||
"productId": "ddddd", | |||
"price": 9999 | |||
} | |||
} | |||
}, | |||
{ | |||
"nodeLabels": [ | |||
"servcieMintTest_shoppingMall" | |||
], | |||
"objectDetail": { | |||
"identifiers": { | |||
"shoppingMallId": "minttestrefreshSeedData_shoppingMallId" | |||
}, | |||
"fields": { | |||
"name": "hotpot-man", | |||
"totalPrice": 500 | |||
} | |||
} | |||
}, | |||
{ | |||
"nodeLabels": [ | |||
"servcieMintTest_shoppingMallCalculateSetting" | |||
], | |||
"objectDetail": { | |||
"identifiers": { | |||
"versionedDataId": "minttestrefreshSeedData_versionedDataId" | |||
}, | |||
"fields": { | |||
"addToCalculatedValuePerOrder": 10, | |||
"addToRateTableValuePerOrder": 77 | |||
} | |||
} | |||
} | |||
], | |||
"relationships": [ | |||
{ | |||
"fromObject": { | |||
"nodeLabel": "SellOfferPlan_sellOfferPlanDeliveryMethodLink", | |||
"identifiers": { | |||
"sellOfferPlanDeliveryMethodLinkId": "minttestrefreshSeedData_01" | |||
} | |||
}, | |||
"toObject": { | |||
"nodeLabel": "servcieMintTest_shoppingMall", | |||
"identifiers": { | |||
"shoppingMallId": "minttestrefreshSeedData_shoppingMallId" | |||
} | |||
}, | |||
"relationships": [ | |||
{ | |||
"relTypeConcat": "SellOfferPlan_hasCCCCCCC", | |||
"relId": "uuid-4s56df74s9df79w-w6de4f5w689ef" | |||
} | |||
] | |||
}, | |||
{ | |||
"fromObject": { | |||
"nodeLabel": "servcieMintTest_shoppingMall", | |||
"identifiers": { | |||
"shoppingMallId": "minttestrefreshSeedData_shoppingMallId" | |||
} | |||
}, | |||
"toObject": { | |||
"nodeLabel": "servcieMintTest_shoppingMallCalculateSetting", | |||
"identifiers": { | |||
"versionedDataId": "minttestrefreshSeedData_versionedDataId" | |||
} | |||
}, | |||
"relationships": [ | |||
{ | |||
"relTypeConcat": "servcieMintTest_shoppingMall_currentShoppingMallCalculateSetting", | |||
"relId": "uuid-s122df5-s21df", | |||
"relationshipProperty": { | |||
"timeStamp": 1234567879, | |||
"statusName": true | |||
} | |||
}, | |||
{ | |||
"relTypeConcat": "servcieMintTest_shoppingMall_hasShoppingMallCalculateSetting", | |||
"relId": "uuid-77777-99999", | |||
"relationshipProperty": { | |||
"statusName": true | |||
} | |||
} | |||
] | |||
} | |||
] | |||
} | |||
], | |||
"seedData_testTag_ABC": [ | |||
{ | |||
"objType": { | |||
"objectType": "productAttributeLink", | |||
"serviceTag": "ProductAttribute" | |||
}, | |||
"objInstanceFull": { | |||
"identifiers": { | |||
"productAttributeLinkId": "f90b57ca8b2fe1a83459d57da038cf50fb6d40e6" | |||
}, | |||
"fields": {} | |||
}, | |||
"relationships": [ | |||
{ | |||
"relType": { | |||
"serviceTag": "ProductAttribute", | |||
"relationshipTag": "hasProductAttributeLink" | |||
}, | |||
"relationshipDirection": "to", | |||
"targetObjType": { | |||
"serviceTag": "ProductStandard", | |||
"objectType": "productStandard" | |||
}, | |||
"targetIdentifiers": { | |||
"productId": "f526a367a2b66cb0f37ca61b6c43f419929f521d" | |||
}, | |||
"relationshipProperties": {} | |||
}, | |||
{ | |||
"relType": { | |||
"serviceTag": "ProductAttribute", | |||
"relationshipTag": "isProductAttribute" | |||
}, | |||
"relationshipDirection": "from", | |||
"targetObjType": { | |||
"serviceTag": "ProductAttribute", | |||
"objectType": "productAttribute" | |||
}, | |||
"targetIdentifiers": { | |||
"productAttributeId": "f4bf7a078071d54036656df544197ba638bc3a68" | |||
}, | |||
"relationshipProperties": {} | |||
} | |||
] | |||
}, | |||
{ | |||
"objType": { | |||
"objectType": "productAttributeLink", | |||
"serviceTag": "ProductAttribute" | |||
}, | |||
"objInstanceFull": { | |||
"identifiers": { | |||
"productAttributeLinkId": "f90b57ca8b2fe1a83459d57da038cf50fb6d40e6" | |||
}, | |||
"fields": {} | |||
}, | |||
"relationships": [] | |||
} | |||
], | |||
"seedData_testTag_LL": [] | |||
} | |||
</syntaxhighlight> | |||
=== Cleaning Seed Data === | |||
:Delete seed data for set environment of '''test'''. | |||
*cleaningeDynamoOneRecordsTags.json | |||
*cleaningeDynamoManyRecordsTags.json | |||
====cleaningeDynamoOneRecordsTags==== | |||
<syntaxhighlight lang="JavaScript"> | |||
{ | |||
"cleaningSeed_TestFindData_and_Education_case_invalid01": [ | |||
{ | |||
"tableName": "MLocationsTestFindDataMain", | |||
"primaryKeys": [ | |||
{ | |||
"findDataId": "cleaning-1" | |||
}, | |||
{ | |||
"findDataId": "cleaning-2" | |||
} | |||
] | |||
}, | |||
{ | |||
"tableName": "MLocationsTestEducation", | |||
"primaryKeys": [ | |||
{ | |||
"studentId": "cleaning-AA" | |||
}, | |||
{ | |||
"studentId": "cleaning-BB" | |||
}, | |||
{ | |||
"studentId": "cleaning-CC" | |||
} | |||
] | |||
} | |||
], | |||
"cleaningSeed_TestMemberPersonnel_case_invalid01": [ | |||
{ | |||
"tableName": "MLocationsTestMemberPersonnel", | |||
"primaryKeys": [ | |||
{ | |||
"userId": "namtan", | |||
"passwordId": "qqqww" | |||
}, | |||
{ | |||
"userId": "jack", | |||
"passwordId": "q1" | |||
}, | |||
{ | |||
"userId": "Momay", | |||
"passwordId": "ttr" | |||
} | |||
] | |||
} | |||
] | |||
} | |||
</syntaxhighlight> | |||
==== cleaningeDynamoManyRecordsTags ==== | |||
<syntaxhighlight lang="JavaScript"> | |||
{ | |||
"cleaningSeed_manyData_partitionKey_only_miss_sort": [ | |||
{ | |||
"tableName": "MLocationsTestMemberPersonnel", | |||
"primaryKeys": [ | |||
{ | |||
"userId": "many-data" | |||
} | |||
] | |||
} | |||
] | |||
} | |||
</syntaxhighlight> | |||
*logic query table MLocationsTestMemberPersonnel use primary Keys "userId" and then delete all data from primary Keys. | |||
=resources= | |||
syntax is object | |||
<syntaxhighlight lang="JavaScript"> | |||
{ | |||
"Lambda":{ | |||
"{FunctionNameHdrSqs}":{ // FunctionNameHdrSqs is match resourceName in file tests | |||
"localLacation":"/src/FunctionNameHdrSqs.js", | |||
"localHandler":"main", | |||
"functionName":"FunctionNameHdrSqs" // FunctionName is function name match key of function.yml of servcie. | |||
}, | |||
"ProcessComplexFilterHdrSqs":{ | |||
"localLacation":"/src/ProcessComplexFilterHdrSqs.js", | |||
"localHandler":"main", | |||
"functionName":"ProcessComplexFilterHdrSqs" | |||
}, | |||
... | |||
}, | |||
"Dynamodb": { | |||
"filterMain":{ // match resourceName in file tests(dynamodbOutputEventIdentifiers) | |||
"tableName":"filterMain" | |||
}, | |||
"tableNameBB":{ | |||
"tableName":"tableNameBB" | |||
}, | |||
... | |||
} | |||
} | |||
</syntaxhighlight> | |||
=events= | =events= | ||
Syntax is object | |||
==Syntax Name== | ==Syntax Name== | ||
===FileName=== | ===FileName=== | ||
| Line 35: | Line 471: | ||
{ | { | ||
"LambdaFunctionHdrSqs_input__pass":{ | "LambdaFunctionHdrSqs_input__pass":{ | ||
"properties":{ | "properties":{ | ||
"propertyA":{ | "propertyA":{ | ||
"value":"valueProperty1" | "value":"valueProperty1" | ||
}, | }, | ||
"propertyB":{ | "propertyB":{ | ||
"properties":{ | "properties":{ | ||
"propertyB1":{ | "propertyB1":{ | ||
"value":"valuePropertyB1" | "value":"valuePropertyB1" | ||
} | } | ||
| Line 60: | Line 492: | ||
"snsSqsTrigger":true, | "snsSqsTrigger":true, | ||
"messageAttributes":{ | "messageAttributes":{ | ||
"msgTag":{ | "msgTag":{ | ||
"value":"msgTag" | "value":"msgTag" | ||
}, | }, | ||
"propertyD":{ | "propertyD":{ | ||
"value":"valuePropertyD" | "value":"valuePropertyD" | ||
} | } | ||
} | } | ||
}, | }, | ||
{ | { | ||
"output_LambdaFunctionHdrSqs_pass":{ | "output_LambdaFunctionHdrSqs_pass":{ | ||
"properties":{ | "properties":{ | ||
"propertyA":{ | "propertyA":{ | ||
"value":"valueProperty1" | "value":"valueProperty1" | ||
} | } | ||
| Line 120: | Line 545: | ||
"DirectSqs":true, | "DirectSqs":true, | ||
"messageAttributes":{ | "messageAttributes":{ | ||
"msgTag":{ | |||
"forStageMatching":true, | |||
"value":"msgTag" | |||
}, | |||
"propertyD":{ | |||
"forStageMatching":true, | |||
"value":"valuePropertyD" | |||
} | |||
} | } | ||
}, | }, | ||
| Line 149: | Line 571: | ||
:: for initialStage of Dsq | :: for initialStage of Dsq | ||
* messageAttributes is optional | * messageAttributes is optional | ||
=====Inv===== | =====Inv===== | ||
<syntaxhighlight lang="JavaScript"> | <syntaxhighlight lang="JavaScript"> | ||
| Line 233: | Line 656: | ||
=====S3===== | =====S3===== | ||
====dynamodb==== | ====dynamodb==== | ||
<syntaxhighlight lang="JavaScript"> | <syntaxhighlight lang="JavaScript"> | ||
| Line 241: | Line 665: | ||
"properties": { | "properties": { | ||
"filterMainUniqueRequestId": { | "filterMainUniqueRequestId": { | ||
"testValueMatches": | "testValueMatches": fase, | ||
"value": "bbc4f4a9-2032-4dec-9129-8c7d169fecc5" | "value": "bbc4f4a9-2032-4dec-9129-8c7d169fecc5" | ||
}, | }, | ||
| Line 263: | Line 687: | ||
}, | }, | ||
"filterMainExpiryTime": { | "filterMainExpiryTime": { | ||
"testValueMatches": | "testValueMatches": fase, | ||
"value": 1731980802858 | "value": 1731980802858 | ||
}, | }, | ||
| Line 271: | Line 695: | ||
}, | }, | ||
"createTime": { | "createTime": { | ||
"testValueMatches": | "testValueMatches": fase, | ||
"value": 1731894402678 | "value": 1731894402678 | ||
}, | }, | ||
| Line 400: | Line 824: | ||
=tests= | =tests= | ||
Syntax is array of object | |||
==Syntax name== | |||
* | ===Testtag name === | ||
*{integrationTestTag} | |||
== | #Test Own servcie or not a lot stage | ||
<syntaxhighlight lang="JavaScript"> | |||
Test_{inputEventTag} | |||
</syntaxhighlight> | |||
#Mix multiple servcie and multiple stage | |||
<syntaxhighlight lang="JavaScript"> | |||
IntegrationTest_{inputEventTag} | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="JavaScript"> | ===File name === | ||
<syntaxhighlight lang="JavaScript"> | |||
{integrationTestTag}.json | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==Setting of test== | |||
[[Service - Integration Test Config#tests.js Syntax|syntax test]] | |||
<syntaxhighlight lang="JavaScript"> | <syntaxhighlight lang="JavaScript"> | ||
{ | { | ||
integrationTestTag: {integrationTestTag}, | |||
productionSafe: true|false, //default false | |||
noInitialStage: true, // default false, if set to true, no error when no foundInitialStages found | |||
errorIfStageUndefined: true|false, //default false | |||
errorIfInvokeUndefined: true|false, //default false, | |||
dynamoDBSeedDataTags:["seedDataDB_test_case_xx"], //[seedDataTag] optional if have seed data for test | |||
graphSeedDataTags:["seedDataGraph_test_case_xx"], //[seedDataTag] optional if have seed data for test | |||
cleaningeDynamoOneRecordsTags: ["cleaningSeed_partitionKey_sortKey_normol"], //optional | |||
cleaningeDynamoManyRecordsTags: [], // optional | |||
stages:[ | |||
... | |||
] | |||
} | |||
</syntaxhighlight> | |||
*[[2025-11-20 IntegrationTest#dynamoDBSeedDataTags|dynamoDBSeedDataTags]] | |||
*[[2025-11-20 IntegrationTest#graphSeedDataTags|graphSeedDataTags]] | |||
*[[2025-11-20 IntegrationTest#cleaningeDynamoOneRecordsTags|cleaningeDynamoOneRecordsTags]] | |||
*[[2025-11-20 IntegrationTest#cleaningeDynamoManyRecordsTags|cleaningeDynamoManyRecordsTags]] | |||
==Stages== | |||
====Initiate stage==== | |||
:'''"initialStage":true''' | |||
[[Service_-_Integration_Test_Config#tests.js Syntax|detail property of test]] | |||
=====HandlerService===== | |||
======Sqs====== | |||
<syntaxhighlight lang="JavaScript"> | |||
"stages":[ | |||
{ | |||
"initialStage":true, | |||
"inputEventTag":"Locations_ProcessLocationNodeSomting_casenotHaveData", | |||
"serviceName":"Locations", | |||
"resourceType":"Lambda", | |||
"resourceName":"ProcessLocationNodeSomtingHdrDsq", | |||
"outputEventTag":"Output_Locations_ProcessLocationNodeSomting_casenotHaveData" | |||
} | |||
] | ] | ||
</syntaxhighlight> | |||
======Dsq====== | |||
<syntaxhighlight lang="JavaScript"> | |||
stages: [ | |||
{ | { | ||
initialStage: true, | |||
inputEventTag: 'LambdaFunctionHdrDsq_input_singleStage_directSqs__pass', | |||
serviceName: 'ServiceTemplate', | |||
resourceType: 'Lambda', | |||
resourceName: 'LambdaFunctionHdrDsq', | |||
outputEventTag: 'LambdaFunctionHdrDsq_output__returnvalue_pass', | |||
// **** not set snsServiceName and snsTopic | |||
// can be test dynamodbOutput | |||
} | } | ||
] | ] | ||
</syntaxhighlight> | |||
======Api====== | |||
<syntaxhighlight lang="JavaScript"> | |||
"stages":[ | |||
{ | { | ||
"initialStage":true, | |||
"inputEventTag":"LambdaFunctionHdrApi_input__pass", | |||
"serviceName":"ServiceTemplate", | |||
"resourceType":"Lambda", | |||
"resourceName":"LambdaFunctionHdrApi", | |||
"outputEventTag":"LambdaFunctionHdrApi_output__pass" | |||
} | } | ||
] | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== | ======Inv====== | ||
:: | *'''single stage''' | ||
<syntaxhighlight lang="JavaScript"> | |||
[{ | |||
"integrationTestTag":"LambdaFunctionHdrInv__pass", | |||
"productionSafe":false, | |||
"errorIfStageUndefined":false, | |||
"errorIfInvokeUndefined":false, | |||
"dynamoDBSeedDataTags":["seedDataDB_test_case_xx"], //[seedDataTag] optional if have seed data for test | |||
"graphSeedDataTags":["seedDataGraph_test_case_xx"], //[seedDataTag] optional if have seed data for test | |||
"cleaningeDynamoOneRecordsTags": ["cleaningSeed_partitionKey_sortKey_normol"], //optional | |||
"cleaningeDynamoManyRecordsTags": [] | |||
"stages":[ | |||
{ | |||
"initialStage":true, | |||
"inputEventTag":"LambdaFunctionHdrInv_input__pass", | |||
"serviceName":"ServiceTemplate", | |||
"resourceType":"Lambda", | |||
"resourceName":"LambdaFunctionHdrInv", | |||
"outputEventTag":"LambdaFunctionHdrInv_output__pass" | |||
} | |||
] | |||
}] | |||
</syntaxhighlight> | |||
*'''invoke multiple stage''' | |||
:*Each stage test can invoke multiple lambda by use "eventStage Tag" point to stage for test integration test. | |||
<syntaxhighlight lang="JavaScript"> | <syntaxhighlight lang="JavaScript"> | ||
[{ | |||
"integrationTestTag":"LambdaFunctionHdrInv_invokes__pass", | |||
"productionSafe":false, | |||
"errorIfStageUndefined":false, | |||
"errorIfInvokeUndefined":false, | |||
"dynamoDBSeedDataTags":[], //[seedDataTag] optional if have seed data for test | |||
"graphSeedDataTags":[], //[seedDataTag] optional if have seed data for test | |||
"cleaningeDynamoOneRecordsTags": [], //optional | |||
"cleaningeDynamoManyRecordsTags": [], // optional | |||
"stages":[ | |||
{ | |||
"initialStage":true, | |||
"inputEventTag":"LambdaFunctionHdrInv_input__pass", | |||
"serviceName":"ServiceTemplate", | |||
"resourceType":"Lambda", | |||
"resourceName":"LambdaFunctionHdrInv", | |||
"outputEventTag":"LambdaFunctionHdrInv_output__pass", | |||
"invokes":[ | |||
{ | { | ||
"eventStageTag":"service_invokesB__pass" | |||
}, | }, | ||
{ | { | ||
"eventStageTag":"service_invokesD__pass" | |||
} | } | ||
] | |||
}, | }, | ||
" | { | ||
"eventStageTag":"service_invokesB__pass", | |||
"inputEventTag":"input_service_invokes__pass", | |||
"serviceName":"ServiceTemplate_B", | |||
"resourceType":"Lambda", | |||
"resourceName":"LambdaFunction_B_HdrInv", | |||
"outputEventTag":"output_service_invokes__pass" | |||
}, | }, | ||
{ | |||
"eventStageTag":"service_invokesD__pass", | |||
"inputEventTag":"input_service_invokesD__pass", | |||
"serviceName":"ServiceTemplate_D", | |||
"resourceType":"Lambda", | |||
"resourceName":"LambdaFunction_D_HdrInv", | |||
"outputEventTag":"output_service_invokesD__pass" | |||
} | |||
] | |||
}] | |||
</syntaxhighlight> | |||
} | |||
======S3====== | |||
======Batch====== | |||
== | ====GeneratedSeedData==== | ||
*Integrationtest must be delete identifier every time before test. | *Integrationtest must be delete identifier every time before test. | ||
*Set 'generatedSeedData' in file tests.json case by case of stage eg: stages[0] create identifier is randomOnCreate will set 'generatedSeedData' and stages[1] create relationship is randomOnCreate(It is usually random, except in the case of relationship version) set generatedSeedData this stages[1]. | *Set 'generatedSeedData' in file tests.json case by case of stage eg: stages[0] create identifier is randomOnCreate will set 'generatedSeedData' and stages[1] create relationship is randomOnCreate(It is usually random, except in the case of relationship version) set generatedSeedData this stages[1]. | ||
*How to delete case identifier rendomOnCreate?: set in stage use setting generateSeedData "randomOnCreateIdentifier" | *How to delete case identifier rendomOnCreate?: set in stage use setting generateSeedData "randomOnCreateIdentifier" | ||
#randomOnCreateIdentifier | |||
#notRandomOnIdentifier | |||
#relationships | |||
=====randomOnCreateIdentifier===== | |||
===randomOnCreateIdentifier=== | |||
<syntaxhighlight lang="JavaScript"> | <syntaxhighlight lang="JavaScript"> | ||
"stages": [ | |||
{ | { | ||
"initialStage": true, | "initialStage": true, | ||
| Line 704: | Line 1,020: | ||
} | } | ||
} | } | ||
] | ] | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=====notRandomOnIdentifier===== | |||
===notRandomOnIdentifier=== | |||
<syntaxhighlight lang="JavaScript"> | <syntaxhighlight lang="JavaScript"> | ||
"stages": [ | |||
{ | { | ||
"initialStage": true, | "initialStage": true, | ||
| Line 747: | Line 1,048: | ||
} | } | ||
] | ] | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=====relationships===== | |||
===relationships=== | |||
<syntaxhighlight lang="JavaScript"> | <syntaxhighlight lang="JavaScript"> | ||
"stages": [ | |||
{ | { | ||
"initialStage": true, | "initialStage": true, | ||
| Line 787: | Line 1,073: | ||
} | } | ||
] | ] | ||
] | </syntaxhighlight> | ||
==Dynamodb== | |||
<syntaxhighlight lang="JavaScript"> | |||
stages: [ | |||
{ | |||
initialStage: true, | |||
inputEventTag: 'Locations_LambdaFunctionHdrDsq_singleStage_directSqs__pass', | |||
serviceName: 'ServiceTemplate', | |||
resourceType: 'Lambda', | |||
resourceName: 'LambdaFunctionHdrDsq', | |||
outputEventTag: 'output_Locations_LambdaFunctionHdrDsq_singleStage_directSqs__pass', | |||
dynamodbOutputEventIdentifiers: [ | |||
{ | |||
serviceName: {tableName}, //service that deployed the DynamoDB table, so can build table's full resource name | |||
resourceName: {resourceName}, //DynamoDB resourceName | |||
eventTag: {eventTagDynamoDB} | |||
} | |||
], | |||
} | |||
] | |||
</syntaxhighlight> | |||
= Result of integrationtest = | |||
Data have 2 table "TestRecord" and "TestUnit". | |||
:- TestRecord is table all unti of stage inside eg input output invokes and dynamodb | |||
:- TestUnit is store status each unit | |||
each unit save in table TestUnit | |||
testRecordId is name of test concat with testTime. | |||
testUnitId is point to position of unti instage. | |||
resultStatus is status of unit. | |||
<syntaxhighlight lang="JavaScript"> | |||
eg: | |||
input_0 = stages index 0 result '''input''' | |||
output_1 = stages index 1 result '''output''' | |||
invokeInput_0_1 = stages index 0 result '''invokes''' index 1 position input | |||
invokeOutput_0_1 = stages index 0 result '''invokes''' index 1 position output | |||
dynamodb_0_1 = stages index 0 result '''dynamodb''' index 1. | |||
</syntaxhighlight> | </syntaxhighlight> | ||
= | after all TestUnit finish (check by awaitingMultiplestep penditnStep is integrationtestTag awaitingStepId is each TestUnit ) | ||
check all awaitingStep finish send message to ultimateIntegrationtest for sumla all test is status | |||
== Summary of test status == | |||
:1.testStatus is "passed" all unit passed. | |||
:2.testStatus is "failed" have some is failed. | |||
:3.testStatus is "processing" have some is have status processing after check all awaiting step is finish. | |||
:4.testStatus is "failed" have record "errorsTest" in case "not match stage invoke", 'found multiple matchingInvokes | |||
*[[2025-02-20 - Integration Test examples#tests.js Syntax|Syntax Dynamodb]] | |||
=How to test integrationtest s3= | |||
[[Developer guide for making Integration Tests]] | [[Developer guide for making Integration Tests]] | ||
[[Category:Working documents| 2025-11-20]] | |||
[[Category:Working documents - Integration Testing| 2025-11-20]] | |||
Latest revision as of 08:55, 8 March 2026
Reference:
File extension
uploadS3: ".json" integrationtestConfig: ".js"
Table test
[
{
integrationTestTag: "Integrationtest_xx",
testStartedTimestamp: 111111111, // start time
bucketName: "integrationtest-config-us-east-2",
lastUpdateUniqueRequestId: "sssss", //_izContext.uniqueRequestId protacts race coditionn dynamodb
testStatus: "passed",//failed,processing,passed
testCompleteTimestamp: 1111113, // all test finish
stages: [
{
stageConfig: {
//straight copy of this stage from integration test config
inputEventTag: "xx",
inputEventConfig: {//event input
},
outputEventTag: "output_xx",
outputEventConfig: {//event out put
},
resourceName: "ComplexfilterTestProcessComplexfilter",// function name
resourceType: "Lambda", // function name
serviceTag: "Complexfilter",// (initeate sqs)
snsServiceName: "Complexfilter",// (initeate sqs)
snsTopic: "PorcessComplexfilter_In"// (initeate sqs)
},
stageStatus: "waiting", //waiting|passed|failed,
stageFinishedTimestamp: 111111111,// time that all tests finished and testRecord.stages.{stageKey}.stageStatus updated
stageResults: {
//results at the point of entering the resource (eg a Lambda function is invoked)
inputResult: {
resultTimestamp: 111111111,//{time result saved},
resultStatus: "passed",//passed|failed,
requestParams: {//event input
}
},
//results at the point of returning from the resource (eg a Lambda function returns)
outputResult: {
resultTimestamp: 111111111,//{time result saved},
resultStatus: "passed",//passed|failed,
requestParams: {//event input
}
},
//results at the point of invoking an external resource (eg the tested Lambda function is invoking another Lambda function)
invokes: {
"serviceName_resourceType_resourceName_inputEventTag ": {
invokeTimestamp: 111111111,//{ time result saved },
resultTimestamp: 111111112,//{ time result saved },
resultStatus: "passed",//passed | failed,
invokeParams: {},//{event invoke input config }
requestParams: {}// event invoke input request
},
},
dynamodbResults: [
{
indexOfDynamodbOutput: 0,
requestParams,
resultStatus: "passed",//
resultTimestamp: 22222
}]
},
stageErrors: [
//misc errors encountered
]
}]
}
]
Seed Data
integrationtest manager seed date 2 process
Main Seed Data
- Save file in s3 (in buckname :integrationtest-config-us-east-2, folder:seedData_integrationTest).For other dev use service,If a developer wants to add more for other important testing purposes.
How to use:
- Add it from the s3 bucket at this point
- Run batch refreshSeedData batch RefreshSeedData
Logic:Process by storage resouse (graph or dynamodb)
- To clean up the seed data in the table after it creates seed data form service deploy and pulls seed data from s3.
Refresh Seed Data
- ProcessRefreshSeedData use seedDataTag for create data environment of test and can be refresh seeddata re-test agian.
- canbe share seed data for other test by seed data tag.
How to use:
- Save file in s3 (for other dav keep in floder dev name) or testConfig/seedData_config(for admin)
Folder
- dynamoDBSeedDataTags.json
- graphSeedDataTags.json
Example
dynamoDBSeedDataTags
- If set tag in this setting integrationtest is generate seed data. in storage resource dynammodb.
Example
{
"seedDynamodb_abc_ver2": [ // seedDataTag
{
"tableName": "DelivMethodSTDTestLogicalResultsData", // servcieTag+stage+tablename
"partitionKey": "logicalResultId",
"sortKey": "identifiersId",
"datas": [
{
"logicalResultId": "eeeeeeeeee4",
"identifiersId": "lllll123456"
},
{
"logicalResultId": "eeeeeeeeee4",
"identifiersId": "lllll777777"
}
]
},
{
"tableName": "MLocationsTestFloatingRelationships",// servcieTag+stage+tablename
"partitionKey": "importBatchId",
"sortKey": "identifierRelationshipsId",
"datas": [
{
"importBatchId": "2-uuuuuuuuuuuuuu",
"identifierRelationshipsId": "lllll123456"
},
{
"importBatchId": "2-uuuuuuuuuuuuuu",
"identifierRelationshipsId": "lllll777777"
},
{
"importBatchId": "2-uuuuuuuuuuuuuu",
"identifierRelationshipsId": "lllll99999999"
}
]
},
{
"tableName": "MLocationsTestFindDataMain",
"partitionKey": "findDataId",
"datas": [
{
"findDataId": "111111"
},
{
"findDataId": "22222"
},
{
"findDataId": "333333"
}
]
}
]
}
graphSeedDataTags
- If set tag in this setting integrationtest is generate seed data. in storage resource graphHanler.
Example
{
"seedData_testTag_GG": [ // seedDataTag
{
"nodes": [
{
"nodeLabels": [
"SellOfferPlan_sellOfferPlanDeliveryMethodLink"
],
"objectDetail": {
"identifiers": {
"sellOfferPlanDeliveryMethodLinkId": "minttestrefreshSeedData_01"
},
"fields": {
"productId": "ddddd",
"price": 9999
}
}
},
{
"nodeLabels": [
"servcieMintTest_shoppingMall"
],
"objectDetail": {
"identifiers": {
"shoppingMallId": "minttestrefreshSeedData_shoppingMallId"
},
"fields": {
"name": "hotpot-man",
"totalPrice": 500
}
}
},
{
"nodeLabels": [
"servcieMintTest_shoppingMallCalculateSetting"
],
"objectDetail": {
"identifiers": {
"versionedDataId": "minttestrefreshSeedData_versionedDataId"
},
"fields": {
"addToCalculatedValuePerOrder": 10,
"addToRateTableValuePerOrder": 77
}
}
}
],
"relationships": [
{
"fromObject": {
"nodeLabel": "SellOfferPlan_sellOfferPlanDeliveryMethodLink",
"identifiers": {
"sellOfferPlanDeliveryMethodLinkId": "minttestrefreshSeedData_01"
}
},
"toObject": {
"nodeLabel": "servcieMintTest_shoppingMall",
"identifiers": {
"shoppingMallId": "minttestrefreshSeedData_shoppingMallId"
}
},
"relationships": [
{
"relTypeConcat": "SellOfferPlan_hasCCCCCCC",
"relId": "uuid-4s56df74s9df79w-w6de4f5w689ef"
}
]
},
{
"fromObject": {
"nodeLabel": "servcieMintTest_shoppingMall",
"identifiers": {
"shoppingMallId": "minttestrefreshSeedData_shoppingMallId"
}
},
"toObject": {
"nodeLabel": "servcieMintTest_shoppingMallCalculateSetting",
"identifiers": {
"versionedDataId": "minttestrefreshSeedData_versionedDataId"
}
},
"relationships": [
{
"relTypeConcat": "servcieMintTest_shoppingMall_currentShoppingMallCalculateSetting",
"relId": "uuid-s122df5-s21df",
"relationshipProperty": {
"timeStamp": 1234567879,
"statusName": true
}
},
{
"relTypeConcat": "servcieMintTest_shoppingMall_hasShoppingMallCalculateSetting",
"relId": "uuid-77777-99999",
"relationshipProperty": {
"statusName": true
}
}
]
}
]
}
],
"seedData_testTag_ABC": [
{
"objType": {
"objectType": "productAttributeLink",
"serviceTag": "ProductAttribute"
},
"objInstanceFull": {
"identifiers": {
"productAttributeLinkId": "f90b57ca8b2fe1a83459d57da038cf50fb6d40e6"
},
"fields": {}
},
"relationships": [
{
"relType": {
"serviceTag": "ProductAttribute",
"relationshipTag": "hasProductAttributeLink"
},
"relationshipDirection": "to",
"targetObjType": {
"serviceTag": "ProductStandard",
"objectType": "productStandard"
},
"targetIdentifiers": {
"productId": "f526a367a2b66cb0f37ca61b6c43f419929f521d"
},
"relationshipProperties": {}
},
{
"relType": {
"serviceTag": "ProductAttribute",
"relationshipTag": "isProductAttribute"
},
"relationshipDirection": "from",
"targetObjType": {
"serviceTag": "ProductAttribute",
"objectType": "productAttribute"
},
"targetIdentifiers": {
"productAttributeId": "f4bf7a078071d54036656df544197ba638bc3a68"
},
"relationshipProperties": {}
}
]
},
{
"objType": {
"objectType": "productAttributeLink",
"serviceTag": "ProductAttribute"
},
"objInstanceFull": {
"identifiers": {
"productAttributeLinkId": "f90b57ca8b2fe1a83459d57da038cf50fb6d40e6"
},
"fields": {}
},
"relationships": []
}
],
"seedData_testTag_LL": []
}
Cleaning Seed Data
- Delete seed data for set environment of test.
- cleaningeDynamoOneRecordsTags.json
- cleaningeDynamoManyRecordsTags.json
cleaningeDynamoOneRecordsTags
{
"cleaningSeed_TestFindData_and_Education_case_invalid01": [
{
"tableName": "MLocationsTestFindDataMain",
"primaryKeys": [
{
"findDataId": "cleaning-1"
},
{
"findDataId": "cleaning-2"
}
]
},
{
"tableName": "MLocationsTestEducation",
"primaryKeys": [
{
"studentId": "cleaning-AA"
},
{
"studentId": "cleaning-BB"
},
{
"studentId": "cleaning-CC"
}
]
}
],
"cleaningSeed_TestMemberPersonnel_case_invalid01": [
{
"tableName": "MLocationsTestMemberPersonnel",
"primaryKeys": [
{
"userId": "namtan",
"passwordId": "qqqww"
},
{
"userId": "jack",
"passwordId": "q1"
},
{
"userId": "Momay",
"passwordId": "ttr"
}
]
}
]
}
cleaningeDynamoManyRecordsTags
{
"cleaningSeed_manyData_partitionKey_only_miss_sort": [
{
"tableName": "MLocationsTestMemberPersonnel",
"primaryKeys": [
{
"userId": "many-data"
}
]
}
]
}
- logic query table MLocationsTestMemberPersonnel use primary Keys "userId" and then delete all data from primary Keys.
resources
syntax is object
{
"Lambda":{
"{FunctionNameHdrSqs}":{ // FunctionNameHdrSqs is match resourceName in file tests
"localLacation":"/src/FunctionNameHdrSqs.js",
"localHandler":"main",
"functionName":"FunctionNameHdrSqs" // FunctionName is function name match key of function.yml of servcie.
},
"ProcessComplexFilterHdrSqs":{
"localLacation":"/src/ProcessComplexFilterHdrSqs.js",
"localHandler":"main",
"functionName":"ProcessComplexFilterHdrSqs"
},
...
},
"Dynamodb": {
"filterMain":{ // match resourceName in file tests(dynamodbOutputEventIdentifiers)
"tableName":"filterMain"
},
"tableNameBB":{
"tableName":"tableNameBB"
},
...
}
}
events
Syntax is object
Syntax Name
FileName
- Event_{inputEventTag}
eventTag
- inputEventTag
- outputEventTag
- dynamodbTag
- file events.js is have eventTag (inputEventTag,outputEventTag,dynamodbTag)
- How to create name eventTag
- Example case : "test in service complexFilter functionname ProcessComplexFilter case element type is logical basic".
- How to create name eventTag
- inputEventTag
- {serviceName}_{functionName}_{caseTest}
Conplexfilter_ProcessComplexFilter_Typelogical_basic
- outputEventTag
- output_{inputEventTag}
output_Conplexfilter_ProcessComplexFilter_Typelogical_basic
- dynamodbTag
- {inputEventTag}__Dynamodb__{action*}_{tableName}
Conplexfilter_ProcessComplexFilter_Typelogical_basic___Dynamodb__putItem_filterMain
- {action} is only put or update, and in case of update must only test the last step of update
Syntax event
initiate by handlerServcie
Sqs
// An example input and output event of Sns
{
"LambdaFunctionHdrSqs_input__pass":{
"properties":{
"propertyA":{
"value":"valueProperty1"
},
"propertyB":{
"properties":{
"propertyB1":{
"value":"valuePropertyB1"
}
}
},
"propertyC":{
"eventValue":[
"valuePropertyC1",
"valuePropertyC2",
"valuePropertyC3"
]
}
},
"snsSqsTrigger":true,
"messageAttributes":{
"msgTag":{
"value":"msgTag"
},
"propertyD":{
"value":"valuePropertyD"
}
}
},
{
"output_LambdaFunctionHdrSqs_pass":{
"properties":{
"propertyA":{
"value":"valueProperty1"
}
}
}
}
}
"snsSqsTrigger":true
Dsq
// An example input and output event of Direct Sqs
{
"LambdaFunctionHdrDsq_input__pass":{
"forStageMatching":true,
"properties":{
"propertyA":{
"forStageMatching":true,
"value":"valueProperty1"
},
"propertyB":{
"forStageMatching":true,
"properties":{
"propertyB1":{
"forStageMatching":true,
"value":"valuePropertyB1"
}
}
},
"propertyC":{
"eventValue":[
"valuePropertyC1",
"valuePropertyC2",
"valuePropertyC3"
]
}
},
"DirectSqs":true,
"messageAttributes":{
"msgTag":{
"forStageMatching":true,
"value":"msgTag"
},
"propertyD":{
"forStageMatching":true,
"value":"valuePropertyD"
}
}
},
{
"output_LambdaFunctionHdrDsq_pass":{
"forStageMatching":true,
"properties":{
"propertyA":{
"forStageMatching":true,
"value":"valueProperty1"
}
}
}
}
}
- DirectSqs = true
- for initialStage of Dsq
- messageAttributes is optional
Inv
{
"LambdaFunctionHdrInv_input__pass":{
"forStageMatching":true,
"properties":{
"propertyA":{
"forStageMatching":true,
"value":"valueProperty1"
},
"propertyB":{
"forStageMatching":true,
"properties":{
"propertyB1":{
"forStageMatching":true,
"value":"valuePropertyB1"
}
}
}
}
},
{
"output_LambdaFunctionHdrInv_pass":{
"forStageMatching":true,
"properties":{
"propertyA":{
"forStageMatching":true,
"value":"valueProperty1"
}
}
}
}
}
Api
// An example input and output event of API
{
"LambdaFunctionHdrApi_input__pass_notTestAuthorizer": {
"forstageMatvhing": true,
"properties": {
"body": {
"properties": {
"propertyA": {
"testValueMatches": false,
"value": "valueProperty1",
},
"propertyB": {
"properties": {
"propertyB1": {
"value": "valuePropertyB1",
}
}
},
"propertyC": {
"eventValue": [
"valuePropertyC1",
"valuePropertyC2",
"valuePropertyC3",
]
},
...
}
}
}
},
"Output_LambdaFunctionHdrApi_input__pass_notTestAuthorizer": {
"properties": {
"body": {
"properties": {
"propertyA": {
"testValueMatches": false,
"value": "valueProperty1"
},
...
}
}
}
}
}
S3
dynamodb
// An example event of Dynamodb //optional
{
{inputEventTag}__dynamodb_{action}_{tablename}: { // eg. "Complexfilter_ProcessComplexfilter_logical_basic__dynamodb_update_FilterMain"
"forStageMatching": true,
"properties": {
"filterMainUniqueRequestId": {
"testValueMatches": fase,
"value": "bbc4f4a9-2032-4dec-9129-8c7d169fecc5"
},
"filterObject": {
"forStageMatching": true,
"properties": {
"logicalType": {
"value": "partitionKey"
},
"comparison": {
"value": "equals"
},
"type": {
"value": "logical"
},
"partitionKey": {
"forStageMatching": true,
"value": "mockIntegratioTestCPF"
}
}
},
"filterMainExpiryTime": {
"testValueMatches": fase,
"value": 1731980802858
},
"filterMainStatus": {
"forStageMatching": true,
"value": "processing"
},
"createTime": {
"testValueMatches": fase,
"value": 1731894402678
},
"objType": {
"forStageMatching": true,
"properties": {
"serviceTag": {
"forStageMatching": true,
"value": "IntTesting"
},
"objectType": {
"forStageMatching": true,
"value": "TestRecord"
}
}
}
},
"keyValues": {
"filterMainId": "4865d2451a621cb7f71225cfabf2df4f98e20801",
"objTypeId": "cdb170690571df7522b3850920fce02507c077ee"
}
}
}
- partition key: filterMainId
- sort key: objTypeId
2021-01-15 - Integration Testing - Adding DynamoDB result tests
Type paramiter
use for evnet and dyanmodb event
Normal
object: {
forStageMatching: true,
properties: {
name:{
forStageMatching: true,
value:"Tom"
}
}
},
array: {
forStageMatching: true,
useIsEqual: true,
eventValue: [
{
"relTypeAndDirection": {
"relType": {
"serviceTag": "maxxCart2",
"relationshipTag": "hasCartOrder"
},
"relationshipDirection": "from"
},
"targetObjects": [
{
"objType": {
"serviceTag": "maxxCart2",
"objectType": "cartOrder"
}
}
]
}
]
},
number: {
forStageMatching: true,
value: 1111
},
string: {
forStageMatching: true,
value: "hi"
},
boolean: {
forStageMatching: true,
value: true
}
forStageMatching: true
- set true for check match value,It is not necessary to set every value
- use in test importent paramiter
- set true for check match value,It is not necessary to set every value
testValueMatches:false
- setting paramiter require on create but can not test random value eg: identifier or timeStamp or uuid
Empty
EmptyString:{
value:""
},
EmptyArray:{
forStageMatching: true,
useIsEqual: true,
eventValue: []
},
EmptyObject:{
forStageMatching: true,
value:{}
}
Error
can test noRetryError
"errorMessage": {
forStageMatching: true,
"value": "Not found schema of {serviceTag:TestGraphHandler, objectType:notFoundObjType}"
}
Paramiter random
Can not test case random numbber or uuid. But requriOnCreate mush be set
testValueMatches:false
or set
forStageMatching:false
tests
Syntax is array of object
Syntax name
Testtag name
- {integrationTestTag}
- Test Own servcie or not a lot stage
Test_{inputEventTag}
- Mix multiple servcie and multiple stage
IntegrationTest_{inputEventTag}
File name
{integrationTestTag}.json
Setting of test
{
integrationTestTag: {integrationTestTag},
productionSafe: true|false, //default false
noInitialStage: true, // default false, if set to true, no error when no foundInitialStages found
errorIfStageUndefined: true|false, //default false
errorIfInvokeUndefined: true|false, //default false,
dynamoDBSeedDataTags:["seedDataDB_test_case_xx"], //[seedDataTag] optional if have seed data for test
graphSeedDataTags:["seedDataGraph_test_case_xx"], //[seedDataTag] optional if have seed data for test
cleaningeDynamoOneRecordsTags: ["cleaningSeed_partitionKey_sortKey_normol"], //optional
cleaningeDynamoManyRecordsTags: [], // optional
stages:[
...
]
}
Stages
Initiate stage
- "initialStage":true
HandlerService
Sqs
"stages":[
{
"initialStage":true,
"inputEventTag":"Locations_ProcessLocationNodeSomting_casenotHaveData",
"serviceName":"Locations",
"resourceType":"Lambda",
"resourceName":"ProcessLocationNodeSomtingHdrDsq",
"outputEventTag":"Output_Locations_ProcessLocationNodeSomting_casenotHaveData"
}
]
Dsq
stages: [
{
initialStage: true,
inputEventTag: 'LambdaFunctionHdrDsq_input_singleStage_directSqs__pass',
serviceName: 'ServiceTemplate',
resourceType: 'Lambda',
resourceName: 'LambdaFunctionHdrDsq',
outputEventTag: 'LambdaFunctionHdrDsq_output__returnvalue_pass',
// **** not set snsServiceName and snsTopic
// can be test dynamodbOutput
}
]
Api
"stages":[
{
"initialStage":true,
"inputEventTag":"LambdaFunctionHdrApi_input__pass",
"serviceName":"ServiceTemplate",
"resourceType":"Lambda",
"resourceName":"LambdaFunctionHdrApi",
"outputEventTag":"LambdaFunctionHdrApi_output__pass"
}
]
Inv
- single stage
[{
"integrationTestTag":"LambdaFunctionHdrInv__pass",
"productionSafe":false,
"errorIfStageUndefined":false,
"errorIfInvokeUndefined":false,
"dynamoDBSeedDataTags":["seedDataDB_test_case_xx"], //[seedDataTag] optional if have seed data for test
"graphSeedDataTags":["seedDataGraph_test_case_xx"], //[seedDataTag] optional if have seed data for test
"cleaningeDynamoOneRecordsTags": ["cleaningSeed_partitionKey_sortKey_normol"], //optional
"cleaningeDynamoManyRecordsTags": []
"stages":[
{
"initialStage":true,
"inputEventTag":"LambdaFunctionHdrInv_input__pass",
"serviceName":"ServiceTemplate",
"resourceType":"Lambda",
"resourceName":"LambdaFunctionHdrInv",
"outputEventTag":"LambdaFunctionHdrInv_output__pass"
}
]
}]
- invoke multiple stage
- Each stage test can invoke multiple lambda by use "eventStage Tag" point to stage for test integration test.
[{
"integrationTestTag":"LambdaFunctionHdrInv_invokes__pass",
"productionSafe":false,
"errorIfStageUndefined":false,
"errorIfInvokeUndefined":false,
"dynamoDBSeedDataTags":[], //[seedDataTag] optional if have seed data for test
"graphSeedDataTags":[], //[seedDataTag] optional if have seed data for test
"cleaningeDynamoOneRecordsTags": [], //optional
"cleaningeDynamoManyRecordsTags": [], // optional
"stages":[
{
"initialStage":true,
"inputEventTag":"LambdaFunctionHdrInv_input__pass",
"serviceName":"ServiceTemplate",
"resourceType":"Lambda",
"resourceName":"LambdaFunctionHdrInv",
"outputEventTag":"LambdaFunctionHdrInv_output__pass",
"invokes":[
{
"eventStageTag":"service_invokesB__pass"
},
{
"eventStageTag":"service_invokesD__pass"
}
]
},
{
"eventStageTag":"service_invokesB__pass",
"inputEventTag":"input_service_invokes__pass",
"serviceName":"ServiceTemplate_B",
"resourceType":"Lambda",
"resourceName":"LambdaFunction_B_HdrInv",
"outputEventTag":"output_service_invokes__pass"
},
{
"eventStageTag":"service_invokesD__pass",
"inputEventTag":"input_service_invokesD__pass",
"serviceName":"ServiceTemplate_D",
"resourceType":"Lambda",
"resourceName":"LambdaFunction_D_HdrInv",
"outputEventTag":"output_service_invokesD__pass"
}
]
}]
S3
Batch
GeneratedSeedData
- Integrationtest must be delete identifier every time before test.
- Set 'generatedSeedData' in file tests.json case by case of stage eg: stages[0] create identifier is randomOnCreate will set 'generatedSeedData' and stages[1] create relationship is randomOnCreate(It is usually random, except in the case of relationship version) set generatedSeedData this stages[1].
- How to delete case identifier rendomOnCreate?: set in stage use setting generateSeedData "randomOnCreateIdentifier"
- randomOnCreateIdentifier
- notRandomOnIdentifier
- relationships
randomOnCreateIdentifier
"stages": [
{
"initialStage": true,
"inputEventTag": "MLocation_CreateHdrSqs__case_NodeVersionData_Jaya",
"serviceTag": "MLocations",
"resourceType": "Lambda",
"resourceName": "CreateHdrSqs",
"snsServiceName": "MLocations",
"snsTopic": "Create_In",
"generatedSeedData": {
"randomOnCreateIdentifier": [
{
"objType": {
"serviceTag": "MLocations",
"objectType": "Member"
},
"identifierValue": "Jaya-member-001"
}
]
}
}
]
notRandomOnIdentifier
"stages": [
{
"initialStage": true,
"inputEventTag": "MLocation_CreateHdrSqs__case_NodeVersionData_Jaya",
"serviceTag": "MLocations",
"resourceType": "Lambda",
"resourceName": "CreateHdrSqs",
"snsServiceName": "MLocations",
"snsTopic": "Create_In",
"generatedSeedData": {
"notRandomOnIdentifier": [
{
"objType": {
"serviceTag": "gggg",
"objectType": "ssssss"
},
"identifiers": {
"topId": "123456"
}
}
]
}
}
]
relationships
"stages": [
{
"initialStage": true,
"inputEventTag": "MLocation_CreateHdrSqs__case_NodeVersionData_Jaya",
"serviceTag": "MLocations",
"resourceType": "Lambda",
"resourceName": "CreateHdrSqs",
"snsServiceName": "MLocations",
"snsTopic": "Create_In",
"generatedSeedData": {
"relationships": [
{
"relType": {
"serviceTag": "PaymentMethodGeneric",
"relationshipTag": "disabledPaymentMethodGenericPropertyValue"
},
"relId": "f4f73de7-647c-4b3b-8043-87cc002f361a"
}
]
}
}
]
Dynamodb
stages: [
{
initialStage: true,
inputEventTag: 'Locations_LambdaFunctionHdrDsq_singleStage_directSqs__pass',
serviceName: 'ServiceTemplate',
resourceType: 'Lambda',
resourceName: 'LambdaFunctionHdrDsq',
outputEventTag: 'output_Locations_LambdaFunctionHdrDsq_singleStage_directSqs__pass',
dynamodbOutputEventIdentifiers: [
{
serviceName: {tableName}, //service that deployed the DynamoDB table, so can build table's full resource name
resourceName: {resourceName}, //DynamoDB resourceName
eventTag: {eventTagDynamoDB}
}
],
}
]
Result of integrationtest
Data have 2 table "TestRecord" and "TestUnit".
- - TestRecord is table all unti of stage inside eg input output invokes and dynamodb
- - TestUnit is store status each unit
each unit save in table TestUnit testRecordId is name of test concat with testTime. testUnitId is point to position of unti instage. resultStatus is status of unit.
eg:
input_0 = stages index 0 result '''input'''
output_1 = stages index 1 result '''output'''
invokeInput_0_1 = stages index 0 result '''invokes''' index 1 position input
invokeOutput_0_1 = stages index 0 result '''invokes''' index 1 position output
dynamodb_0_1 = stages index 0 result '''dynamodb''' index 1.
after all TestUnit finish (check by awaitingMultiplestep penditnStep is integrationtestTag awaitingStepId is each TestUnit ) check all awaitingStep finish send message to ultimateIntegrationtest for sumla all test is status
Summary of test status
- 1.testStatus is "passed" all unit passed.
- 2.testStatus is "failed" have some is failed.
- 3.testStatus is "processing" have some is have status processing after check all awaiting step is finish.
- 4.testStatus is "failed" have record "errorsTest" in case "not match stage invoke", 'found multiple matchingInvokes