Skip to content

Conversation

@austoonz
Copy link
Contributor

Issue #, if available:

Description of changes:

Overview

Adds integration testing framework for PowerShell Lambda Runtime.

Key Changes

Integration Testing

  • CloudFormation template with Lambda functions for Script, Function, and Module handlers
  • Test runner updates (Invoke-Tests.ps1) with integration test support and AWS environment setup
  • Helper libraries (LambdaIntegrationHelpers.psm1) for response caching and validation

Bug Fixes

  • Environment variable fix from AWS_LAMBDA_RUNTIME_INVOKE_FUNCTION_ARN to AWS_LAMBDA_RUNTIME_INVOKED_FUNCTION_ARN
  • C# constructor fix in PowerShellLambdaContext.cs for InvokedFunctionArn assignment

Documentation

  • Updated README files with integration testing instructions
  • Infrastructure documentation for CloudFormation deployment

Usage

# Run automated tests
cd powershell-runtime && pwsh -NoProfile -Command "& './tests/Invoke-Tests.ps1'"

# Run integration tests (manual, after deploying integration test infrastructure)
cd powershell-runtime && pwsh -NoProfile -Command "& './tests/Invoke-Tests.ps1' -TestType Integration"

Test output

The following is output from a successful invocation of the integration tests.

PS> pwsh -NoProfile -c "./Invoke-Tests.ps1 -TestType Integration -StackName powershell-runtime-integration-test-infrastructure -Region us-west-2 -ProfileName default"
PowerShell Runtime Test Runner
===============================
Loading test requirements from: /workspace/aws-lambda-powershell-runtime/powershell-runtime/test-requirements.psd1
Initializing test framework...
Pester ready
Setting up integration test environment...
Importing required AWS modules...
AWS modules imported successfully
Retrieving stack outputs for powershell-runtime-integration-test-infrastructure...
Setting PWSH_TEST_FUNCTIONHANDLERFUNCTIONARN = arn:aws:lambda:us-west-2:123456789012:function:powershell-runtime-integra-FunctionHandlerFunction-1Xrf87Wpz8hF
Setting PWSH_TEST_FUNCTIONHANDLERFUNCTIONNAME = powershell-runtime-integra-FunctionHandlerFunction-1Xrf87Wpz8hF
Setting PWSH_TEST_INTEGRATIONTESTBUCKETNAME = powershell-runtime-integrati-integrationtestbucket-nkwp213cyf9q
Setting PWSH_TEST_LAMBDAEXECUTIONROLEARN = arn:aws:iam::123456789012:role/powershell-runtime-integration--LambdaExecutionRole-EEBG0sMMDo4p
Setting PWSH_TEST_MODULEHANDLERFUNCTIONARN = arn:aws:lambda:us-west-2:123456789012:function:powershell-runtime-integrati-ModuleHandlerFunction-QSYyID5uFT87
Setting PWSH_TEST_MODULEHANDLERFUNCTIONNAME = powershell-runtime-integrati-ModuleHandlerFunction-QSYyID5uFT87
Setting PWSH_TEST_POWERSHELLRUNTIMELAYERARN = arn:aws:lambda:us-west-2:123456789012:layer:PwshRuntimeLayer:64
Setting PWSH_TEST_SCRIPTHANDLERFAILINGFUNCTIONARN = arn:aws:lambda:us-west-2:123456789012:function:powershell-runtime-integr-ScriptHandlerFailingFunc-2YXISzOx5cBJ
Setting PWSH_TEST_SCRIPTHANDLERFAILINGFUNCTIONNAME = powershell-runtime-integr-ScriptHandlerFailingFunc-2YXISzOx5cBJ
Setting PWSH_TEST_SCRIPTHANDLERFUNCTIONARN = arn:aws:lambda:us-west-2:123456789012:function:powershell-runtime-integrati-ScriptHandlerFunction-QBvNUkOKzt8c
Setting PWSH_TEST_SCRIPTHANDLERFUNCTIONNAME = powershell-runtime-integrati-ScriptHandlerFunction-QBvNUkOKzt8c
Setting configuration environment variables...
Setting PWSH_TEST_STACK_NAME = powershell-runtime-integration-test-infrastructure
Setting PWSH_TEST_AWS_REGION = us-west-2
Setting PWSH_TEST_PROFILE_NAME = default
Successfully set 11 stack output environment variables for integration tests
Environment variable PWSH_TEST_INFRASTRUCTURE_DEPLOYED has been set to TRUE
Configuration environment variables (PWSH_TEST_STACK_NAME, PWSH_TEST_AWS_REGION, PWSH_TEST_PROFILE_NAME) have been set
Test paths: /workspace/aws-lambda-powershell-runtime/powershell-runtime/tests/integration

Executing tests...

Starting discovery in 2 files.
Discovery found 11 tests in 88ms.
Running tests.
Initializing error response cache...
Error response cached successfully.
[+] /workspace/aws-lambda-powershell-runtime/powershell-runtime/tests/integration/ErrorHandling.Tests.ps1 9.48s (9.3s|109ms)
Initializing handler response cache...
Response cache initialized successfully.
[+] /workspace/aws-lambda-powershell-runtime/powershell-runtime/tests/integration/Lambda-Integration.Tests.ps1 17.15s (17.1s|34ms)
Tests completed in 26.64s
Tests Passed: 11, Failed: 0, Skipped: 0, Inconclusive: 0, NotRun: 0

Test Results:
Tests: 11/11 passed
Cleaning up integration test environment variables...
Removing PWSH_TEST_INTEGRATIONTESTBUCKETNAME
Removing PWSH_TEST_STACK_NAME
Removing PWSH_TEST_SCRIPTHANDLERFUNCTIONARN
Removing PWSH_TEST_FUNCTIONHANDLERFUNCTIONNAME
Removing PWSH_TEST_MODULEHANDLERFUNCTIONNAME
Removing PWSH_TEST_LAMBDAEXECUTIONROLEARN
Removing PWSH_TEST_MODULEHANDLERFUNCTIONARN
Removing PWSH_TEST_INFRASTRUCTURE_DEPLOYED
Removing PWSH_TEST_SCRIPTHANDLERFAILINGFUNCTIONNAME
Removing PWSH_TEST_FUNCTIONHANDLERFUNCTIONARN
Removing PWSH_TEST_AWS_REGION
Removing PWSH_TEST_POWERSHELLRUNTIMELAYERARN
Removing PWSH_TEST_SCRIPTHANDLERFUNCTIONNAME
Removing PWSH_TEST_PROFILE_NAME
Removing PWSH_TEST_SCRIPTHANDLERFAILINGFUNCTIONARN
Successfully cleaned up 15 integration test environment variables

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Add integration testing infrastructure to validate PowerShell Lambda runtime functionality across handler types.

- Integration test suite for Script, Function, and Module handler types
- Helper module with validation functions and schema-based context validation
- AWS infrastructure template for test environment deployment
- Test handler implementations for each PowerShell handler pattern

This establishes testing infrastructure to validate runtime functionality and support regression testing.
@austoonz austoonz merged commit 2eac8bb into awslabs:main Jul 18, 2025
2 checks passed
@austoonz austoonz deleted the feature/adding-integration-tests branch July 18, 2025 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants