2025-11-20 IntegrationTest: Difference between revisions
No edit summary |
|||
| Line 1: | Line 1: | ||
=resource= | |||
=seed Data= | |||
=How to test= | |||
=events= | =events= | ||
==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". | |||
::*'''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'' | |||
: <u>'''{action}''' is only ''put'' or ''update'', and in case of ''update'' must only test the last step of update </u> | |||
=== Syntax event=== | |||
====initiate by handlerServcie==== | |||
=====Sqs===== | |||
<syntaxhighlight lang="JavaScript"> | |||
// An example input and output event of Sns | |||
{ | |||
"LambdaFunctionHdrSqs_input__pass":{ | |||
"forStageMatching":true, | |||
"properties":{ | |||
"propertyA":{ | |||
"forStageMatching":true, | |||
"value":"valueProperty1" | |||
}, | |||
"propertyB":{ | |||
"forStageMatching":true, | |||
"properties":{ | |||
"propertyB1":{ | |||
"forStageMatching":true, | |||
"value":"valuePropertyB1" | |||
} | |||
} | |||
}, | |||
"propertyC":{ | |||
"eventValue":[ | |||
"valuePropertyC1", | |||
"valuePropertyC2", | |||
"valuePropertyC3" | |||
] | |||
} | |||
}, | |||
"snsSqsTrigger":true, | |||
"messageAttributes":{ | |||
"forStageMatching":true, | |||
"properties":{ | |||
"msgTag":{ | |||
"forStageMatching":true, | |||
"value":"msgTag" | |||
}, | |||
"propertyD":{ | |||
"forStageMatching":true, | |||
"value":"valuePropertyD" | |||
} | |||
} | |||
} | |||
}, | |||
{ | |||
"output_LambdaFunctionHdrSqs_pass":{ | |||
"forStageMatching":true, | |||
"properties":{ | |||
"propertyA":{ | |||
"forStageMatching":true, | |||
"value":"valueProperty1" | |||
} | |||
} | |||
} | |||
} | |||
} | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="JavaScript" linein> | |||
"snsSqsTrigger":true | |||
</syntaxhighlight> | |||
=====Dsq===== | |||
<syntaxhighlight lang="JavaScript"> | |||
// 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":{ | |||
"forStageMatching":true, | |||
"properties":{ | |||
"msgTag":{ | |||
"forStageMatching":true, | |||
"value":"msgTag" | |||
}, | |||
"propertyD":{ | |||
"forStageMatching":true, | |||
"value":"valuePropertyD" | |||
} | |||
} | |||
} | |||
}, | |||
{ | |||
"output_LambdaFunctionHdrDsq_pass":{ | |||
"forStageMatching":true, | |||
"properties":{ | |||
"propertyA":{ | |||
"forStageMatching":true, | |||
"value":"valueProperty1" | |||
} | |||
} | |||
} | |||
} | |||
} | |||
</syntaxhighlight> | |||
* DirectSqs = true | |||
:: for initialStage of Dsq | |||
* messageAttributes is optional | |||
=====Inv===== | |||
<syntaxhighlight lang="JavaScript"> | |||
{ | |||
"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" | |||
} | |||
} | |||
} | |||
} | |||
} | |||
</syntaxhighlight> | |||
=====Api===== | |||
<syntaxhighlight lang="JavaScript"> | |||
// 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" | |||
}, | |||
... | |||
} | |||
} | |||
} | |||
} | |||
} | |||
</syntaxhighlight> | |||
=====S3===== | |||
====dynamodb==== | |||
Detail setting event test and record. | Detail setting event test and record. | ||
[[Service - Integration Test Config]] | [[Service - Integration Test Config]] | ||
Revision as of 10:05, 24 November 2025
resource
seed Data
How to test
events
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":{
"forStageMatching":true,
"properties":{
"propertyA":{
"forStageMatching":true,
"value":"valueProperty1"
},
"propertyB":{
"forStageMatching":true,
"properties":{
"propertyB1":{
"forStageMatching":true,
"value":"valuePropertyB1"
}
}
},
"propertyC":{
"eventValue":[
"valuePropertyC1",
"valuePropertyC2",
"valuePropertyC3"
]
}
},
"snsSqsTrigger":true,
"messageAttributes":{
"forStageMatching":true,
"properties":{
"msgTag":{
"forStageMatching":true,
"value":"msgTag"
},
"propertyD":{
"forStageMatching":true,
"value":"valuePropertyD"
}
}
}
},
{
"output_LambdaFunctionHdrSqs_pass":{
"forStageMatching":true,
"properties":{
"propertyA":{
"forStageMatching":true,
"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":{
"forStageMatching":true,
"properties":{
"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
Detail setting event test and record. Service - Integration Test Config
Dynamodb
- How to test dynamodb.
2021-01-15 - Integration Testing - Adding DynamoDB result tests
- Syntax dynamodb
Service - Integration Test Config#dynamodb
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
- 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
forStageMatching: true
testValueMatches
- setting paramiter require on create but can not test random value eg: identifier or timeStamp or uuid
testValueMatches:false
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}"
}
Can not test case random nubber or identifer is random. But request mush be send param use setting.
testValueMatches:false
or set
forStageMatching:false
tests
- Syntax
2025-02-20 - Integration Test examples#tests.js Syntax
- Detail
2025-02-20_-_Integration_Test_examples#tests.json
RefreshSeedData
Seed data for test case, can generate seed data by use this setting. Process refresh seed data first step delete all seed data after that create all seed data.
[
{
"integrationTestTag": "Test_mackTestLogic_refreceSeedData_DeleteIdentifier",
"productionSafe": false,
"errorIfStageUnderfined": false,
"errorIfInvokeUnderfined": false,
"dynamoDBSeedDataTags": [
"seedDynamodb_abc_ver2"
],
"graphSeedDataTags": [
"seedData_testTag_GG"
],
"stages": [
//...
]
}
]
- create file dynamoDBSeedDataTags.json and graphSeedDataTags.json
- (Admin)This tag save file in floder seedData_config
- (Other dev)Save in s3 in folder test_config
dynamoDBSeedDataTags
- If set tag in this setting integrationtest is generate seed data. in storage resource dynammodb.
{
"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.
{
"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": []
}
- seedDataTag must be unique
- canbe share seed data for other test by seed data tag.
GenerateSeedData
- 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"
- 3 case
- 1.randomOnCreateIdentifier
- 2.notRandomOnIdentifier
- 3.relationships
randomOnCreateIdentifier
[
{
"integrationTestTag": "Test_MLocation_CreateHdrSqs__case_NodeVersionData_Jaya",
"productionSafe": false,
"errorIfStageUnderfined": false,
"errorIfInvokeUnderfined": false,
"dynamoDBSeedDataTags": [
"seedDynamodb_abc_ver2"
],
"graphSeedDataTags": [
"seedData_testTag_GG"
],
"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
[
{
"integrationTestTag": "Test_MLocation_CreateHdrSqs__case_NodeVersionData_Jaya",
"productionSafe": false,
"errorIfStageUnderfined": false,
"errorIfInvokeUnderfined": false,
"dynamoDBSeedDataTags": [
"seedDynamodb_abc_ver2"
],
"graphSeedDataTags": [
"seedData_testTag_GG"
],
"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
[
{
"integrationTestTag": "Test_MLocation_CreateHdrSqs__case_NodeVersionData_Jaya",
"productionSafe": false,
"errorIfStageUnderfined": false,
"errorIfInvokeUnderfined": false,
"dynamoDBSeedDataTags": [
"seedDynamodb_abc_ver2"
],
"graphSeedDataTags": [
"seedData_testTag_GG"
],
"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"
}
]
}
}
]
}
]