Skip to content

Commit

Permalink
Test demonstrating failure
Browse files Browse the repository at this point in the history
  • Loading branch information
varju committed Oct 17, 2022
1 parent a8eacb5 commit b43ce4e
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
53 changes: 53 additions & 0 deletions packages/@aws-cdk/aws-lambda-python/test/integ.function.arm64.ts
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();
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
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

0 comments on commit b43ce4e

Please sign in to comment.