Developer guide for making Integration Tests: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
= Overview = | = Overview = | ||
:How to create folder and file in S3 bucket for prepare integrationTest | |||
:[[Service - Integration Test Config|Integration Test Config]] for config of property in file resources.json, events.json and tests.json | |||
= Setup integrationtest = | = Setup integrationtest = | ||
== | == Create folder == | ||
: Create your folder in bucket '''integrationtest-config-us-east-2/test_config/{<u>your folder name</u>}''' in S3 bucket | |||
:* '''{<u>your folder name</u>}''' maybe is your nickname eg. jamesDev, nicoleDev | |||
:* Can create a subfolder in your folder for each test case or service that you want to test | |||
:: eg. - integrationtest-config-us-east-2/test_config/jamesDev/SellOfferManager | |||
::: - integrationtest-config-us-east-2/test_config/jamesDev/ProcessLogical | |||
::: - integrationtest-config-us-east-2/test_config/jamesDev/SellOfferManager/ProcessLogical | |||
== Create file == | |||
# Create a file in a folder that is used for testing | # Create a file in a folder that is used for testing | ||
#* ''resources.json / events.json / tests.json'' | #* ''resources.json / events.json / tests.json'' | ||
Line 16: | Line 19: | ||
#* In the main prefix for testing, you don’t need to upload every file. If you have a file in SharedResource, you can skip uploading it | #* In the main prefix for testing, you don’t need to upload every file. If you have a file in SharedResource, you can skip uploading it | ||
## '''resources.json''' | ## '''resources.json''' | ||
##* | ##* Syntax; [[Service_-_Integration_Test_Config#resources.js Syntax|resources Syntax]] | ||
# | |||
## '''events.json''' | ## '''events.json''' | ||
##* Syntax; [[Service_-_Integration_Test_Config#events/*.js_Syntax|events Syntax]] | |||
##* Not use <code><s>isObject</s></code>. Use <code>properties</code> instead, if is an object will look for child properties | |||
##* Not use <code><s>isStringSet</s></code> | |||
##* If have many stage, Set <code>initialStage</code> is true only initial stage. Next stage not set this setting | |||
##* If <code>snsSqsTrigger</code> is true but not set snsServiceName or snsTopic --> direct invoke | |||
##* If <code>DirectSqs</code> and <code>BatchSqsMessages</code> is true --> direct invoke | |||
##* If <code>snsSqsTrigger</code> and <code>DirectSqs</code> is false or not set --> direct invoke | |||
##* <code>forStageMatching</code> <u>Use in test important parameter</u> | |||
##* <code>testValueMatches</code> <u>For random parameter eg. timeStamp or uuid</u> | |||
##* If value in array or number or string is <u>random</u>. '''Use testValueMatches: true not set forStageMatching: true''' | |||
##* Multiple eventTags can be added to a single file | ##* Multiple eventTags can be added to a single file | ||
##* Have 6 types of events; Dynamodb, Sns/Sqs, Dsq, Invoke, API and NoRetryError | ##* Have 6 types of events; Dynamodb, Sns/Sqs, Dsq, Invoke, API and NoRetryError | ||
##:<syntaxhighlight lang="JavaScript"> | ## '''tests.json''' | ||
// | ##* Syntax; [[Service_-_Integration_Test_Config#tests/*.js_Syntax|tests Syntax]] | ||
{ | ##* Not use <code><s>dynamoDbOutput</s></code>. Use <code>dynamodbOutputEventIdentifiers</code> instead | ||
# Upload file to S3 bucket by batchscript or upload to S3 bucket directly | |||
#:<syntaxhighlight lang="JavaScript"> | |||
#!/bin/bash | |||
set -u | |||
localPath="/home/dogsrcute/Programming mint/Fixed_Integrationtest/PluemDev/paginate/2stages" | |||
bucketName=s3://integrationtest-config-us-east-2/test_config/mintDev/fixed/PluemDev/2stages/ | |||
aws s3 cp "$localPath" "$bucketName" --recursive | |||
</syntaxhighlight> | |||
#* localPath is part to files for upload | |||
#* bucketName is your bucket | |||
== Type of parameter == | |||
: Parameter type for create property in events.json | |||
<syntaxhighlight lang="JavaScript"> | |||
object: { | |||
forStageMatching: true, | |||
properties: {} | |||
}, | |||
array: { | |||
forStageMatching: true, | |||
eventValue: [] | |||
}, | |||
number: { | |||
forStageMatching: true, | |||
value: 1111 | |||
}, | |||
string: { | |||
forStageMatching: true, | |||
value: "hi" | |||
}, | |||
boolean: { | |||
forStageMatching: true, | |||
value: true | |||
} | } | ||
// | // Case empty | ||
{ | EmptyString:{ | ||
" | value: "" | ||
}, | |||
EmptyArray:{ | |||
forStageMatching: true, | |||
eventValue: [] | |||
}, | |||
EmptyObject:{ | |||
forStageMatching: true, | |||
value: {} | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
= Test = | |||
# | # create params for invoke <u>IntTestingTestInitiateIntegrationTestHdrInv</u> function | ||
#:<syntaxhighlight lang="JavaScript"> | |||
{ | |||
"serviceName": "ComplexFilter", | |||
"resourceType": "Lambda", | |||
"resourceName": "ProcessComplexFilterHdrSqs", | |||
"integrationTestTags": [ | |||
{ | "test_S3_ByDev" | ||
" | ], | ||
"bucketName": "integrationtest-config-us-east-2", | |||
"bucketPrefix":[ | |||
"test_config/mintDev/basicCase/", | |||
"test_config/mintDev/SharedResource/" | |||
] | |||
} | |||
" | |||
" | |||
" | |||
// | |||
</syntaxhighlight> | </syntaxhighlight> | ||
# Find results in IntTestingTestTestRecord table | |||
= Working documents = | |||
[[:Category:Working_documents - Developer guide for making Integration Tests|Working_documents - Developer guide for making Integration Tests]] |
Latest revision as of 08:51, 24 February 2025
Overview
- How to create folder and file in S3 bucket for prepare integrationTest
- Integration Test Config for config of property in file resources.json, events.json and tests.json
Setup integrationtest
Create folder
- Create your folder in bucket integrationtest-config-us-east-2/test_config/{your folder name} in S3 bucket
- {your folder name} maybe is your nickname eg. jamesDev, nicoleDev
- Can create a subfolder in your folder for each test case or service that you want to test
- eg. - integrationtest-config-us-east-2/test_config/jamesDev/SellOfferManager
- - integrationtest-config-us-east-2/test_config/jamesDev/ProcessLogical
- - integrationtest-config-us-east-2/test_config/jamesDev/SellOfferManager/ProcessLogical
Create file
- Create a file in a folder that is used for testing
- resources.json / events.json / tests.json
- resources.json and events.json is json object
- tests.json is json array of objects
- Can create these files in a SharedResource folder and share it with another test for collaborative usage
- eg. integrationtest-config-us-east-2/test_config/jamesDev/SellOfferManager/SharedResource/resources.json
- In the main prefix for testing, you don’t need to upload every file. If you have a file in SharedResource, you can skip uploading it
- resources.json
- Syntax; resources Syntax
- events.json
- Syntax; events Syntax
- Not use
. UseisObjectproperties
instead, if is an object will look for child properties - Not use
isStringSet - If have many stage, Set
initialStage
is true only initial stage. Next stage not set this setting - If
snsSqsTrigger
is true but not set snsServiceName or snsTopic --> direct invoke - If
DirectSqs
andBatchSqsMessages
is true --> direct invoke - If
snsSqsTrigger
andDirectSqs
is false or not set --> direct invoke forStageMatching
Use in test important parametertestValueMatches
For random parameter eg. timeStamp or uuid- If value in array or number or string is random. Use testValueMatches: true not set forStageMatching: true
- Multiple eventTags can be added to a single file
- Have 6 types of events; Dynamodb, Sns/Sqs, Dsq, Invoke, API and NoRetryError
- tests.json
- Syntax; tests Syntax
- Not use
. UsedynamoDbOutputdynamodbOutputEventIdentifiers
instead
- Upload file to S3 bucket by batchscript or upload to S3 bucket directly
#!/bin/bash set -u localPath="/home/dogsrcute/Programming mint/Fixed_Integrationtest/PluemDev/paginate/2stages" bucketName=s3://integrationtest-config-us-east-2/test_config/mintDev/fixed/PluemDev/2stages/ aws s3 cp "$localPath" "$bucketName" --recursive
- localPath is part to files for upload
- bucketName is your bucket
Type of parameter
- Parameter type for create property in events.json
object: {
forStageMatching: true,
properties: {}
},
array: {
forStageMatching: true,
eventValue: []
},
number: {
forStageMatching: true,
value: 1111
},
string: {
forStageMatching: true,
value: "hi"
},
boolean: {
forStageMatching: true,
value: true
}
// Case empty
EmptyString:{
value: ""
},
EmptyArray:{
forStageMatching: true,
eventValue: []
},
EmptyObject:{
forStageMatching: true,
value: {}
}
Test
- create params for invoke IntTestingTestInitiateIntegrationTestHdrInv function
{ "serviceName": "ComplexFilter", "resourceType": "Lambda", "resourceName": "ProcessComplexFilterHdrSqs", "integrationTestTags": [ "test_S3_ByDev" ], "bucketName": "integrationtest-config-us-east-2", "bucketPrefix":[ "test_config/mintDev/basicCase/", "test_config/mintDev/SharedResource/" ] }
- Find results in IntTestingTestTestRecord table
Working documents
Working_documents - Developer guide for making Integration Tests