Developer guide for making Integration Tests: Difference between revisions
Jump to navigation
Jump to search
(→Test) |
|||
| Line 102: | Line 102: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
= Test = | = Test = | ||
# create params for invoke <u>IntTestingTestInitiateIntegrationTestHdrInv</u> function | test integrationtest | ||
#:<syntaxhighlight lang="JavaScript"> | '''-direct invoke''' | ||
'''-BashScript '''integrationTest.sh''' ''' | |||
1.invoke in console lambda function <u>IntTestingTestInitiateIntegrationTestHdrInv</u> | |||
:1.1 | |||
:# create params for invoke <u>IntTestingTestInitiateIntegrationTestHdrInv</u> function | |||
:#:<syntaxhighlight lang="JavaScript"> | |||
{ | { | ||
"serviceName": "ComplexFilter", | "serviceName": "ComplexFilter", | ||
| Line 117: | Line 122: | ||
] | ] | ||
} | } | ||
:</syntaxhighlight> | |||
:# Find results in IntTestingTestTestRecord table | |||
2.BashScript '''integrationTest.sh''' | |||
:2.1 create file '''integrationTest.sh''' | |||
<syntaxhighlight lang="JavaScript"> | |||
#!/bin/bash | |||
set -u | |||
stage="Test" | |||
region="us-east-2" | |||
aws configure set region ${region} | |||
declare -a groupTests=( | |||
'{ | |||
"serviceName": "DelivMethodSTD", | |||
"resourceType": "Lambda", | |||
"resourceName": "MockDeliveryMethod2GetHdrInv", | |||
"integrationTestTags": [ | |||
"integrationTest_DelivMethodSTD_Get_NomalCase" | |||
], | |||
"bucketName": "integrationtest-config-us-east-2", | |||
"bucketPrefix": [ | |||
"test_config/mintDev/DelivMethodSTD/getPassed/", | |||
"test_config/PluemDev/SharedResource/" | |||
] | |||
}' | |||
) | |||
functionName="IntTesting" | |||
for test in "${groupTests[@]}"; do | |||
echo "start one set of tests" | |||
echo ${test} | |||
#... invoke InitateTests.... | |||
aws lambda invoke \ | |||
--function-name "${functionName}${stage}InitiateIntegrationTestHdrInv" \ | |||
--payload "${test}" \ | |||
--invocation-type RequestResponse \ | |||
--cli-binary-format raw-in-base64-out \ | |||
/dev/stdout | |||
echo "----------- Finish("${functionName}${stage}InitiateIntegrationTestHdrInv") ------------" | |||
done | |||
</syntaxhighlight> | |||
:2.2 run bashscript | |||
<syntaxhighlight lang="JavaScript"> | |||
bash integrationTest.sh | |||
</syntaxhighlight> | </syntaxhighlight> | ||
= Working documents = | = Working documents = | ||
[[:Category:Working_documents - Developer guide for making Integration Tests|Working_documents - Developer guide for making Integration Tests]] | [[:Category:Working_documents - Developer guide for making Integration Tests|Working_documents - Developer guide for making Integration Tests]] | ||
Revision as of 08:01, 5 April 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 folder in buckets s3
- integrationtest-config-us-east-2/test_config/{your folder name}
- your folder name
- 1.Create name Developer for folder name inside test_config
- 2.Create folder service Names of Test
- 3.Create folder your test
- integrationtest-config-us-east-2/test_config/{nameDeveloper}/{serviceNames}/{foldeTest}/
- eg. integrationtest-config-us-east-2/test_config/mintDev/complexFilter/basicCase/
- 4.Can save file events, tests,resources inside
Note: can shared file events, tests,resources by bucket Prefix.
Create file
- files upload in s3'
- -resources.json
- -events.json
- -tests.json
- note ---------------------------------------------------------------------------------------------------------------------------
- 1.resources.json and events.json is json object
- note :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
- 2.tests.json is json array of objects
- Detail of files
- 1.resources.json
- Syntax; resources Syntax
- 2.events.json
- Syntax; events Syntax
- If initeage stage
snsSqsTriggeris true but not set snsServiceName or snsTopic
- -sns
- set
snsSqsTriggeris true, if not set or fase ---> direct invoke
- set
- -DirectSqs
- set
BatchSqsMessagesis true, if not set or fase ---> direct invoke
- set
- -sns
forStageMatchingUse in test important parametertestValueMatchesis default true
- testValueMatches use in case not test parameter random data eg. timeStamp or uuid , but function require paramiter.
- 3.tests.json
- Syntax; tests Syntax
- Case test dynamodb (optional test) use
dynamodbOutputEventIdentifiersin stage of test
- 1.resources.json
- Upload file to s3
- 1.batchscript
- 2.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
- run interminal in folder uploadFileToS3.sh
bash 'uploadFileToS3.sh'
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
test integrationtest -direct invoke -BashScript integrationTest.sh 1.invoke in console lambda function IntTestingTestInitiateIntegrationTestHdrInv
- 1.1
- 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
- create params for invoke IntTestingTestInitiateIntegrationTestHdrInv function
2.BashScript integrationTest.sh
- 2.1 create file integrationTest.sh
#!/bin/bash
set -u
stage="Test"
region="us-east-2"
aws configure set region ${region}
declare -a groupTests=(
'{
"serviceName": "DelivMethodSTD",
"resourceType": "Lambda",
"resourceName": "MockDeliveryMethod2GetHdrInv",
"integrationTestTags": [
"integrationTest_DelivMethodSTD_Get_NomalCase"
],
"bucketName": "integrationtest-config-us-east-2",
"bucketPrefix": [
"test_config/mintDev/DelivMethodSTD/getPassed/",
"test_config/PluemDev/SharedResource/"
]
}'
)
functionName="IntTesting"
for test in "${groupTests[@]}"; do
echo "start one set of tests"
echo ${test}
#... invoke InitateTests....
aws lambda invoke \
--function-name "${functionName}${stage}InitiateIntegrationTestHdrInv" \
--payload "${test}" \
--invocation-type RequestResponse \
--cli-binary-format raw-in-base64-out \
/dev/stdout
echo "----------- Finish("${functionName}${stage}InitiateIntegrationTestHdrInv") ------------"
done
- 2.2 run bashscript
bash integrationTest.sh
Working documents
Working_documents - Developer guide for making Integration Tests