Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for provided.al2023 #1788

Merged
merged 1 commit into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/config/supportedRuntimes.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const supportedRuntimesArchitecture = {
provided: [X86_64],
dotnet6: [ARM64, X86_64],
"provided.al2": [ARM64, X86_64],
"provided.al2023": [ARM64, X86_64],
}

// GO
Expand All @@ -48,7 +49,11 @@ export const supportedNodejs = new Set([
])

// PROVIDED
export const supportedProvided = new Set(["provided", "provided.al2"])
export const supportedProvided = new Set([
"provided",
"provided.al2",
"provided.al2023",
])

// PYTHON
export const supportedPython = new Set([
Expand Down
21 changes: 21 additions & 0 deletions tests/integration/docker/provided-al2023/bootstrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh

set -euo pipefail

# Initialization - load function handler
source $LAMBDA_TASK_ROOT/"$(echo $_HANDLER | cut -d. -f1).sh"

# Processing
while true
do
HEADERS="$(mktemp)"
# Get an event
EVENT_DATA=$(curl -sS -LD "$HEADERS" -X GET "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/next")
REQUEST_ID=$(grep -Fi Lambda-Runtime-Aws-Request-Id "$HEADERS" | tr -d '[:space:]' | cut -d: -f2)

# Execute the handler function from the script
RESPONSE=$($(echo "$_HANDLER" | cut -d. -f2) "$EVENT_DATA")

# Send the response
curl -s -X POST "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/$REQUEST_ID/response" -d "$RESPONSE" -o /dev/null
done
39 changes: 39 additions & 0 deletions tests/integration/docker/provided-al2023/dockerProvided.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import assert from "node:assert"
import { env } from "node:process"
import { join } from "desm"
import { setup, teardown } from "../../../_testHelpers/index.js"
import { BASE_URL } from "../../../config.js"

describe("Provided.al2023 with Docker tests", function desc() {
beforeEach(() =>
setup({
servicePath: join(import.meta.url),
}),
)

afterEach(() => teardown())

//
;[
{
description: "should work with provided.al2023 in docker container",
expected: {
message: "Hello Provided.al2023!",
},
path: "/dev/hello",
},
].forEach(({ description, expected, path }) => {
it(description, async function it() {
// "Could not find 'Docker', skipping tests."
if (!env.DOCKER_DETECTED) {
this.skip()
}

const url = new URL(path, BASE_URL)
const response = await fetch(url)
const json = await response.json()

assert.deepEqual(json, expected)
})
})
})
5 changes: 5 additions & 0 deletions tests/integration/docker/provided-al2023/handler.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function hello () {
RESPONSE="{\"body\": \"{\\\"message\\\": \\\"Hello Provided.al2023!\\\"}\", \"statusCode\": 200}"

echo $RESPONSE
}
30 changes: 30 additions & 0 deletions tests/integration/docker/provided-al2023/serverless.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
service: docker-provided-tests

configValidationMode: error
deprecationNotificationMode: error

plugins:
- ../../../../src/index.js

provider:
architecture: x86_64
deploymentMethod: direct
memorySize: 1024
name: aws
region: us-east-1
runtime: provided.al2023
stage: dev
versionFunctions: false

custom:
serverless-offline:
noTimeout: true
useDocker: true

functions:
hello:
events:
- http:
method: get
path: hello
handler: handler.hello
Loading