-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
packages/@aws-cdk/aws-lambda-python/test/integ.function.arm64.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import * as path from 'path'; | ||
import { Architecture, Runtime } from '@aws-cdk/aws-lambda'; | ||
import { App, CfnOutput, Stack, StackProps } from '@aws-cdk/core'; | ||
import { IntegTest, ExpectedResult } from '@aws-cdk/integ-tests'; | ||
import { Construct } from 'constructs'; | ||
import * as lambda from '../lib'; | ||
|
||
/* | ||
* Stack verification steps: | ||
* * aws lambda invoke --function-name <deployed fn name> --invocation-type Event --payload '"OK"' response.json | ||
*/ | ||
|
||
class TestStack extends Stack { | ||
public readonly functionName: string; | ||
constructor(scope: Construct, id: string, props?: StackProps) { | ||
super(scope, id, props); | ||
|
||
const layer = new lambda.PythonLayerVersion(this, 'Layer', { | ||
entry: path.join(__dirname, 'lambda-handler-arm64/layer'), | ||
compatibleRuntimes: [Runtime.PYTHON_3_9], | ||
compatibleArchitectures: [Architecture.ARM_64], | ||
}); | ||
|
||
const fn = new lambda.PythonFunction(this, 'Handler', { | ||
entry: path.join(__dirname, 'lambda-handler-arm64/handler'), | ||
runtime: Runtime.PYTHON_3_9, | ||
architecture: Architecture.ARM_64, | ||
layers: [layer], | ||
}); | ||
this.functionName = fn.functionName; | ||
|
||
new CfnOutput(this, 'FunctionArn', { | ||
value: fn.functionArn, | ||
}); | ||
} | ||
} | ||
|
||
const app = new App(); | ||
const testCase = new TestStack(app, 'integ-lambda-python-arm64'); | ||
const integ = new IntegTest(app, 'lambda-python-arm64', { | ||
testCases: [testCase], | ||
stackUpdateWorkflow: false, | ||
}); | ||
|
||
const invoke = integ.assertions.invokeFunction({ | ||
functionName: testCase.functionName, | ||
}); | ||
|
||
invoke.expect(ExpectedResult.objectLike({ | ||
Payload: '200', | ||
})); | ||
|
||
app.synth(); |
16 changes: 16 additions & 0 deletions
16
packages/@aws-cdk/aws-lambda-python/test/lambda-handler-arm64/handler/index.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from itertools import count | ||
from flupy import flu | ||
|
||
def handler(event, context): | ||
# Example flupy processing an infinite sequence | ||
pipeline = ( | ||
flu(count()) | ||
.map(lambda x: x**2) | ||
.filter(lambda x: x % 517 == 0) | ||
.chunk(5) | ||
.take(3) | ||
) | ||
for item in pipeline: | ||
print(item) | ||
|
||
return 200 |
4 changes: 4 additions & 0 deletions
4
packages/@aws-cdk/aws-lambda-python/test/lambda-handler-arm64/layer/requirements.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Lock versions of pip packages | ||
typing-extensions==4.4.0 | ||
# Used by this lambda | ||
flupy==1.1.9 |