Developer guide for making Integration Tests: Difference between revisions

From Izara Wiki
Jump to navigation Jump to search
Line 17: Line 17:


== Create file ==
== Create file ==
# Create a file in a folder that is used for testing
*'''files upload in s3''''
#* ''resources.json / events.json / tests.json''
:-resources.json
#* '''resources.json''' and '''events.json''' is json object
:-events.json
#* '''tests.json''' is json array of objects
:-tests.json
#* Can create these files in a SharedResource folder and share it with another test for collaborative usage
:: note ---------------------------------------------------------------------------------------------------------------------------
#:: eg. integrationtest-config-us-east-2/test_config/jamesDev/SellOfferManager/SharedResource/resources.json
::1.'''resources.json''' and '''events.json''' is json object
#* 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 
:::note :Can create these files in a SharedResource folder and share it with another test for collaborative usage
## '''resources.json'''
:::eg. integrationtest-config-us-east-2/test_config/jamesDev/SellOfferManager/SharedResource/resources.json
##* Syntax; [[Service_-_Integration_Test_Config#resources.js Syntax|resources Syntax]]
:::2.'''tests.json''' is json array of objects
## '''events.json'''
*'''Detail of files'''
##* Syntax; [[Service_-_Integration_Test_Config#events/*.js_Syntax|events Syntax]]
::1.'''resources.json'''
##* If have many stage, Set <code>initialStage</code> is true only initial stage. Next stage not set this setting
:::*Syntax; [[Service_-_Integration_Test_Config#resources.js Syntax|resources Syntax]]
##* If <code>snsSqsTrigger</code> is true but not set snsServiceName or snsTopic --> direct invoke
::2.'''events.json'''
##* If <code>DirectSqs</code> and <code>BatchSqsMessages</code> is true --> direct invoke
:::* Syntax; [[Service_-_Integration_Test_Config#events/*.js_Syntax|events Syntax]]
##* If <code>snsSqsTrigger</code> and <code>DirectSqs</code> is false or not set --> direct invoke
:::* If have many stage, Set <code>initialStage</code> is '''true''' only initial stage. Next stage not set this setting
##* <code>forStageMatching</code> <u>Use in test important parameter</u>
:::* If <code>snsSqsTrigger</code> is '''true''' but not set snsServiceName or snsTopic
##* <code>testValueMatches</code> <u>For random parameter eg. timeStamp or uuid</u>
:::* If <code>snsSqsTrigger</code> and <code>DirectSqs</code> is '''false''' or not set --> direct invoke
##* If value in array or number or string is <u>random</u>. '''Use testValueMatches: true not set forStageMatching: true'''   
:::* If <code>DirectSqs</code> and <code>BatchSqsMessages</code> is '''true''' --> direct invoke
##* Multiple eventTags can be added to a single file
:::* <code>forStageMatching</code> <u>Use in test important parameter</u>
##* Have 6 types of events; Dynamodb, Sns/Sqs, Dsq, Invoke, API and NoRetryError
:::* <code>testValueMatches</code> is default '''true'''
## '''tests.json'''
::: use case not test parameter random data eg. timeStamp or uuid  
##* Syntax; [[Service_-_Integration_Test_Config#tests/*.js_Syntax|tests Syntax]]
::::* If value in array or number or string is <u>random</u>. '''set testValueMatches: true''' and not set forStageMatching: true'''   
##* Use <code>dynamodbOutputEventIdentifiers</code> instead
:::::Note ....
# Upload file to S3 bucket by batchscript or upload to S3 bucket directly
::::::: Multiple eventTags can be added to a single file events.json. but not same neme of eventTags
#:<syntaxhighlight lang="JavaScript">
 
::3.'''tests.json'''
:::* Syntax; [[Service_-_Integration_Test_Config#tests/*.js_Syntax|tests Syntax]]
:::*Case test dynamodb (optional test) use <code>dynamodbOutputEventIdentifiers</code> in stage of test
::
*Upload file to s3
::1. '''batchscript'''
::2. '''upload to S3 bucket directly'''
::
<syntaxhighlight lang="JavaScript">
#!/bin/bash  
#!/bin/bash  
set -u  
set -u  
Line 50: Line 59:
aws s3 cp "$localPath" "$bucketName" --recursive  
aws s3 cp "$localPath" "$bucketName" --recursive  
</syntaxhighlight>
</syntaxhighlight>
#* localPath is part to files for upload  
* localPath is part to files for upload  
#* bucketName is your bucket
* bucketName is your bucket


== Type of parameter ==
== Type of parameter ==

Revision as of 07:13, 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
2.events.json
  • Syntax; events Syntax
  • 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
  • If snsSqsTrigger and DirectSqs is false or not set --> direct invoke
  • If DirectSqs and BatchSqsMessages is true --> direct invoke
  • forStageMatching Use in test important parameter
  • testValueMatches is default true
use case not test parameter random data eg. timeStamp or uuid
  • If value in array or number or string is random. set testValueMatches: true and not set forStageMatching: true
Note ....
Multiple eventTags can be added to a single file events.json. but not same neme of eventTags
3.tests.json
  • Syntax; tests Syntax
  • Case test dynamodb (optional test) use dynamodbOutputEventIdentifiers in stage of test
  • 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

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

  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/"  
    	]  
    }
    
  2. Find results in IntTestingTestTestRecord table

Working documents

Working_documents - Developer guide for making Integration Tests