2025-02-20 - Integration Test examples

From Izara Wiki
Revision as of 07:14, 21 February 2025 by Pong (talk | contribs) (Created page with "= Overview = :The example of properties in resources.json, events.json and tests.json for upload to S3 bucket :Integration Test Config for config of each property in these files = resources.json = <syntaxhighlight lang="JavaScript"> { "Lambda":{ "{FunctionNameHdrSqs}":{ "localLacation":"/src/FunctionNameHdrSqs.js", "localHandler":"main", "functionName":"FunctionNameHdrSqs" // FunctionName is full name of function afte...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Overview

The example of properties in resources.json, events.json and tests.json for upload to S3 bucket
Integration Test Config for config of each property in these files

resources.json

{ 
	"Lambda":{
		"{FunctionNameHdrSqs}":{ 
			"localLacation":"/src/FunctionNameHdrSqs.js",
			"localHandler":"main", 
			"functionName":"FunctionNameHdrSqs"	// FunctionName is full name of function after deploy
		},
		"ProcessComplexFilterHdrSqs":{ 
			"localLacation":"/src/ProcessComplexFilterHdrSqs.js", 
			"localHandler":"main", 
			"functionName":"ProcessComplexFilterHdrSqs" 
		},
		... 
	},
	"Dynamodb": {
		"filterMain":{ 
			"tableName":"filterMain" 
		}, 
		"tableNameBB":{ 
			"tableName":"tableNameBB" 
		},
		... 
	}
}

events.json

// Layout of file events.json 
{ 
	input:{}, 
	output:{}, 
	dynamodb:{}
} 

// An example of naming an eventTag for each event
{
	"Complexfilter_ProcessComplexfilter_logical_basic": {},					            // for input 
	"Output_Complexfilter_ProcessComplexfilter_logical_basic": {},				        // for output
	"Complexfilter_ProcessComplexfilter_logical_basic__dynamodb_update_FilterMain": {}  // for dynamodb
}
  • "Complexfilter_ProcessComplexfilter_logical_basic" is called inputEventTag
  • for outputEventTag is Output_{inputEvenTag}
eg. "Output_Complexfilter_ProcessComplexfilter_logical_basic"
  • for dynamodb is {inputEventTag}__dynamodb_{action}_{tablename}
eg. "Complexfilter_ProcessComplexfilter_logical_basic__dynamodb_update_FilterMain"
{action} is only put or update, and in case of update must only test the last step of update

Sns/Sqs, Dsq and Invoke

// An example input and output event of Sns/Sqs, Dsq and Invoke
{
	"Complexfilter_ProcessComplexfilter_logical_basic": { 
		"forStageMatching": true,        
		"properties": { 
			"propertyA": { 
				"forStageMatching": true,  
				"value": "valueProperty1", 
			}, 
			"propertyB": { 
				"testValueMatches": false,  // no child properties will be tested 
				"properties": { 
					"propertyB1": { 
						"value": "valuePropertyB1", 
					} 
				} 
			}, 
			"propertyC": { 
				"eventValue": [ 
					"valuePropertyC1", 
					"valuePropertyC2", 
					"valuePropertyC3", 
				] 
			} 
		}, 
		
		// settings for Sns/Sqs
		"snsSqsTrigger": true,        // set when event is initial stage of Sns
		"messageAttributes": {        // optional 
			"forStageMatching": true, 
			"properties": { 
				"msgTag": { 	      // require 
					"value": "msgTag" 
				}, 
				"propertyD": { 
					"forStageMatching": true,     // default: false, whether this property is used to match stage config during integration tests
					"testValueMatches": false,    // default: true, whether value of this property is checked when performing test
					"value": "valuePropertyD" 
				} 
			} 
		} 
		
		// settings for Dsq
		// DirectSqs set in HdrDsq if have messageAttributeValidatorSchema and required property in messageAttributes eg: messageTag 
		"DirectSqs": true, 			// set when event is initial stage of Dsq
		"messageAttributes": { 	    // optional  
			"messageTag": { 
				"DataType": "String", 
				"StringValue": "messageAttributes_is" 
			} 
		} 
	}, 
	"Output_Complexfilter_ProcessComplexfilter_logical_basic": { 
		"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"
					}, 
					...
				} 
			} 
		}  
	}
}

Dynamodb

// An example event of Dynamodb 
{
	{inputEventTag}__dynamodb_{action}_{tablename}: { // eg. "Complexfilter_ProcessComplexfilter_logical_basic__dynamodb_update_FilterMain"
		"forStageMatching": true, 
		"properties": { 
			(property is update)... 
		}, 
		"keyValues": { 
			{partitionKey}: "4865d2451a621cb7f71225cfabf2df4f98e20801 ", 
			{sortKey}: "cdb170690571df7522b3850920fce02507c077ee" 
		} 
	} 
}

NoRetryError

// An example event of NoRetryError output 
{
	Output_{inputEvenTag}: { // eg. "Output_Complexfilter_ProcessComplexfilter_logical_basic"
		"forStageMatching": true, 
		"properties": { 
			"errorMessage": { 
				"value": "Not found schema of {serviceTag:TestGraphHandler, objectType:notFoundObjType}" 
			} 
		} 
	} 
}

tests.json

// An example test 
[ 
	{ 
		"integrationTestTag": "test_S3_ByDev", 
		"productionSafe": false, 
		"errorIfStageUnderfined": false, 
		"errorIfInvokeUnderfined": false, 
		"stages": [
			{ 
				"initialStage": true, 
				"inputEventTag": "Complexfiter_ProcessComplexfiter_logical_basic", 
				"serviceName": "ComplexFilter", 
				"resourceType": "Lambda", 
				"resourceName": "ProcessComplexFilterHdrSqs", 
				"snsServiceName": "ComplexFilter",     // if snsSqsTrigger = true but not set snsServiceName or snsTopic --> direct invoke 
				"snsTopic": "InProcessComplexFilter",  // if snsSqsTrigger = true but not set snsServiceName or snsTopic --> direct invoke
				"outputEventTag": "Output_Complexfiter_ProcessComplexfiter_logical_basic", 
				"BatchSqsMessages": true
				
				// Settings if have test dynamodb
				"dynamodbOutputEventIdentifiers": [ 
					{ 
						"serviceName": "ComplexFilter", 
						"resourceName": "FilterMain", 
						"eventTag": "Complexfiter_ProcessComplexfiter_logical_basic_dynamodb_update_FilterMain"
					},
					... 
				],
				
				
				// Settings multiple stage for invoke
				"invokes": [ 
					{ 
						"eventStageTag": "GraphHandler_GetNodeV2_NomalCase" 
					},
					... 
				], 	 
			},
			{ 
				"eventStageTag": "GraphHandler_GetNodeV2_NomalCase" // require "eventStageTag" if have settings multiple stage for invoke
				"inputEventTag": "SellOfferMgr_ProcessLogical_logical_integrationTesting_returnObject",
				"serviceName": "SellOfferMgr", 
				"resourceType": "Lambda", 
				"resourceName": "ProcessLogicalHdrSqs", 
				"outputEventTag": "output_intTesting_ProcessLogical_logical_integrationTesting_returnObject", 
			},
			... 
		] 
	},
	... 
]