From 999fa8fcdd11743a078cc5d3ff7bcfb3b78d2e00 Mon Sep 17 00:00:00 2001 From: MazurDorian Date: Wed, 24 Apr 2024 09:34:42 +0200 Subject: [PATCH] test: add more docker tests --- .mocharc.cjs | 2 +- src/config/supportedRuntimes.js | 7 +- tests/integration/docker/.DS_Store | Bin 0 -> 6148 bytes .../docker/access-host/accessHost.test.js | 101 +++++++-------- .../docker/access-host/serverless.yml | 2 +- .../docker/artifact/artifact.test.js | 80 ++++++------ .../docker/artifact/serverless.yml | 2 +- .../docker/multiple/dockerMultiple.test.js | 120 +++++++++--------- .../docker/multiple/serverless.yml | 6 +- tests/integration/docker/nodejs/.DS_Store | Bin 0 -> 6148 bytes .../nodejs12.x/dockerNodejs12.x.test.js | 41 ------ .../nodejs18.x/dockerNodejs18.x.test.js | 37 ++++++ .../{nodejs12.x => nodejs18.x}/handler.js | 2 +- .../{nodejs12.x => nodejs18.x}/serverless.yml | 4 +- .../nodejs20.x/dockerNodejs20.x.test.js | 37 ++++++ .../docker/nodejs/nodejs20.x/handler.js | 16 +++ .../docker/nodejs/nodejs20.x/serverless.yml | 30 +++++ .../nodejs21.x/dockerNodejs21.x.test.js | 37 ++++++ .../docker/nodejs/nodejs21.x/handler.js | 16 +++ .../docker/nodejs/nodejs21.x/serverless.yml | 30 +++++ tests/integration/docker/python/.DS_Store | Bin 0 -> 6148 bytes .../python3.10/dockerPython3.10.test.js | 39 ++++++ .../docker/python/python3.10/handler.py | 11 ++ .../docker/python/python3.10/serverless.yml | 30 +++++ .../python3.11/dockerPython3.11.test.js | 39 ++++++ .../docker/python/python3.11/handler.py | 11 ++ .../docker/python/python3.11/serverless.yml | 30 +++++ .../docker/ruby/ruby3.2/dockerRuby3.2.test.js | 39 ++++++ .../docker/ruby/ruby3.2/handler.rb | 11 ++ .../docker/ruby/ruby3.2/serverless.yml | 30 +++++ 30 files changed, 599 insertions(+), 211 deletions(-) create mode 100644 tests/integration/docker/.DS_Store create mode 100644 tests/integration/docker/nodejs/.DS_Store delete mode 100644 tests/integration/docker/nodejs/nodejs12.x/dockerNodejs12.x.test.js create mode 100644 tests/integration/docker/nodejs/nodejs18.x/dockerNodejs18.x.test.js rename tests/integration/docker/nodejs/{nodejs12.x => nodejs18.x}/handler.js (87%) rename tests/integration/docker/nodejs/{nodejs12.x => nodejs18.x}/serverless.yml (89%) create mode 100644 tests/integration/docker/nodejs/nodejs20.x/dockerNodejs20.x.test.js create mode 100644 tests/integration/docker/nodejs/nodejs20.x/handler.js create mode 100644 tests/integration/docker/nodejs/nodejs20.x/serverless.yml create mode 100644 tests/integration/docker/nodejs/nodejs21.x/dockerNodejs21.x.test.js create mode 100644 tests/integration/docker/nodejs/nodejs21.x/handler.js create mode 100644 tests/integration/docker/nodejs/nodejs21.x/serverless.yml create mode 100644 tests/integration/docker/python/.DS_Store create mode 100644 tests/integration/docker/python/python3.10/dockerPython3.10.test.js create mode 100644 tests/integration/docker/python/python3.10/handler.py create mode 100644 tests/integration/docker/python/python3.10/serverless.yml create mode 100644 tests/integration/docker/python/python3.11/dockerPython3.11.test.js create mode 100644 tests/integration/docker/python/python3.11/handler.py create mode 100644 tests/integration/docker/python/python3.11/serverless.yml create mode 100644 tests/integration/docker/ruby/ruby3.2/dockerRuby3.2.test.js create mode 100644 tests/integration/docker/ruby/ruby3.2/handler.rb create mode 100644 tests/integration/docker/ruby/ruby3.2/serverless.yml diff --git a/.mocharc.cjs b/.mocharc.cjs index 1bf59644a..f07eb4f25 100644 --- a/.mocharc.cjs +++ b/.mocharc.cjs @@ -17,7 +17,7 @@ if (env.TEST === "unit") { } if (env.TEST === "docker") { - spec = ["tests/integration/docker/**/*.test.js"] + spec = ["tests/integration/docker/python/**/*.test.js"] } if (env.TEST === "node") { diff --git a/src/config/supportedRuntimes.js b/src/config/supportedRuntimes.js index 826c7141d..26a05fce8 100644 --- a/src/config/supportedRuntimes.js +++ b/src/config/supportedRuntimes.js @@ -11,7 +11,6 @@ const X86_64 = "x86_64" const ARM64 = "arm64" export const supportedRuntimesArchitecture = { - "nodejs12.x": [ARM64, X86_64], "nodejs14.x": [ARM64, X86_64], "nodejs16.x": [ARM64, X86_64], "nodejs18.x": [ARM64, X86_64], @@ -21,7 +20,6 @@ export const supportedRuntimesArchitecture = { "python3.9": [ARM64, X86_64], "python3.10": [ARM64, X86_64], "python3.11": [ARM64, X86_64], - "python3.12": [ARM64, X86_64], "ruby2.7": [ARM64, X86_64], "ruby3.2": [ARM64, X86_64], java8: [X86_64], @@ -59,14 +57,11 @@ export const supportedPython = new Set([ "python3.9", "python3.10", "python3.11", - "python3.12", ]) // RUBY export const supportedRuby = new Set(["ruby2.7", "ruby3.2"]) -// deprecated runtimes -// https://docs.aws.amazon.com/lambda/latest/dg/runtime-support-policy.html export const supportedRuntimes = new Set([ // ...supportedDotnetcore, ...supportedGo, @@ -77,4 +72,6 @@ export const supportedRuntimes = new Set([ ...supportedRuby, ]) +// deprecated runtimes +// https://docs.aws.amazon.com/lambda/latest/dg/runtime-support-policy.html export const unsupportedDockerRuntimes = new Set([]) diff --git a/tests/integration/docker/.DS_Store b/tests/integration/docker/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..079291382c4e24fc116b450cf6f726d041c0c332 GIT binary patch literal 6148 zcmeHK%}T>S5T0#on^J@x6nb3nTCleMAYMYPFJMFuDz!01qcK~W)KW?zXMG``#OHBl zcPp0aNf0SBF#GM!&Lo*HVJ8CsqCEeBSfV!~VEi-8fcp+6&|UPzQuTA6>34!Z=Xlwi?AjqGLU?;gp?nw_2M{Tg|wLhDcoz1Q7qtotV^c1TXL!`iOPRqK*IlSUzA*W|=7)L6;Lp#M3 zVE_|I;U2Tb$GDAre16&}zz{~@!{n true) - - // let server - // beforeEach(async () => { - // await installNpmModules(join(import.meta.url, 'src')) - // }) - // beforeEach(async () => { - // server = new Server({ port: 8080 }) - // server.route({ - // handler() { - // return 'Hello Node.js!' - // }, - // method: 'GET', - // path: '/hello', - // }) - // await server.start() - // await setup({ - // servicePath: join(import.meta.url), - // }) - // }) - // afterEach(async () => { - // await server.stop() - // await teardown() - // }) - // // - // ;[ - // { - // description: 'should access host in docker container', - // expected: { - // message: 'Hello Node.js!', - // }, - // 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) - // }) - // }) + let server + beforeEach(async () => { + await installNpmModules(join(import.meta.url, "src")) + }) + beforeEach(async () => { + server = new Server({ port: 8080 }) + server.route({ + handler() { + return "Hello Node.js!" + }, + method: "GET", + path: "/hello", + }) + await server.start() + await setup({ + servicePath: join(import.meta.url), + }) + }) + afterEach(async () => { + await server.stop() + await teardown() + }) + ;[ + { + description: "should access host in docker container", + expected: { + message: "Hello Node.js!", + }, + 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) + }) + }) }) diff --git a/tests/integration/docker/access-host/serverless.yml b/tests/integration/docker/access-host/serverless.yml index 87f9fea92..e584c5ceb 100644 --- a/tests/integration/docker/access-host/serverless.yml +++ b/tests/integration/docker/access-host/serverless.yml @@ -12,7 +12,7 @@ provider: memorySize: 1024 name: aws region: us-east-1 - runtime: nodejs12.x + runtime: nodejs18.x stage: dev versionFunctions: false diff --git a/tests/integration/docker/artifact/artifact.test.js b/tests/integration/docker/artifact/artifact.test.js index 5f5963785..36319bf81 100644 --- a/tests/integration/docker/artifact/artifact.test.js +++ b/tests/integration/docker/artifact/artifact.test.js @@ -1,48 +1,44 @@ -// import assert from 'node:assert' -// import { env } from 'node:process' -// import { join } from 'desm' -// import { -// compressArtifact, -// setup, -// teardown, -// } from '../../../_testHelpers/index.js' -// import { BASE_URL } from '../../../config.js' +import assert from "node:assert" +import { env } from "node:process" +import { join } from "desm" +import { + compressArtifact, + setup, + teardown, +} from "../../../_testHelpers/index.js" +import { BASE_URL } from "../../../config.js" describe("Artifact with docker tests", function desc() { - it("placeholder, node.js v12 not supported anymore", () => true) + beforeEach(async () => { + await compressArtifact(join(import.meta.url), "artifacts/hello.zip", [ + "handler.js", + ]) + return setup({ + servicePath: join(import.meta.url), + }) + }) - // beforeEach(async () => { - // await compressArtifact(join(import.meta.url), 'artifacts/hello.zip', [ - // 'handler.js', - // ]) - // return setup({ - // servicePath: join(import.meta.url), - // }) - // }) + afterEach(() => teardown()) + ;[ + { + description: "should work with artifact in docker container", + expected: { + message: "Hello Node.js!", + }, + path: "/dev/hello", + }, + ].forEach(({ description, expected, path }) => { + it(description, async function it() { + // "Could not find 'Docker', skipping tests." + if (!env.DOCKER_DETECTED) { + this.skip() + } - // afterEach(() => teardown()) + const url = new URL(path, BASE_URL) + const response = await fetch(url) + const json = await response.json() - // // - // ;[ - // { - // description: 'should work with artifact in docker container', - // expected: { - // message: 'Hello Node.js!', - // }, - // 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) - // }) - // }) + assert.deepEqual(json, expected) + }) + }) }) diff --git a/tests/integration/docker/artifact/serverless.yml b/tests/integration/docker/artifact/serverless.yml index 7dd61cc88..60ec32d6a 100644 --- a/tests/integration/docker/artifact/serverless.yml +++ b/tests/integration/docker/artifact/serverless.yml @@ -12,7 +12,7 @@ provider: memorySize: 1024 name: aws region: us-east-1 - runtime: nodejs12.x + runtime: nodejs18.x stage: dev versionFunctions: false diff --git a/tests/integration/docker/multiple/dockerMultiple.test.js b/tests/integration/docker/multiple/dockerMultiple.test.js index ff639da9b..3586a5167 100644 --- a/tests/integration/docker/multiple/dockerMultiple.test.js +++ b/tests/integration/docker/multiple/dockerMultiple.test.js @@ -1,65 +1,61 @@ -// 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' +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("Multiple docker containers", function desc() { - it("placeholder, node.js v12 not supported anymore", () => true) - - // beforeEach(() => - // setup({ - // servicePath: join(import.meta.url), - // }), - // ) - - // afterEach(() => teardown()) - - // // - // ;[ - // { - // description: 'should work with multiple mixed docker containers', - // expected1: { - // message: 'Hello Node.js!', - // }, - // expected2: { - // message: 'Hello Node.js!', - // }, - // expected3: { - // message: 'Hello Python!', - // }, - // path1: '/dev/hello1', - // path2: '/dev/hello2', - // path3: '/dev/hello3', - // }, - // ].forEach( - // ({ description, expected1, expected2, expected3, path1, path2, path3 }) => { - // it(description, async function it() { - // // "Could not find 'Docker', skipping tests." - // if (!env.DOCKER_DETECTED) { - // this.skip() - // } - - // const url1 = new URL(path1, BASE_URL) - // const url2 = new URL(path2, BASE_URL) - // const url3 = new URL(path3, BASE_URL) - - // const [response1, response2, response3] = await Promise.all([ - // fetch(url1), - // fetch(url2), - // fetch(url3), - // ]) - - // const [json1, json2, json3] = await Promise.all([ - // response1.json(), - // response2.json(), - // response3.json(), - // ]) - - // assert.equal(json1.message, expected1.message) - // assert.equal(json2.message, expected2.message) - // assert.equal(json3.message, expected3.message) - // }) - // }, - // ) + beforeEach(() => + setup({ + servicePath: join(import.meta.url), + }), + ) + + afterEach(() => teardown()) + ;[ + { + description: "should work with multiple mixed docker containers", + expected1: { + message: "Hello Node.js!", + }, + expected2: { + message: "Hello Node.js!", + }, + expected3: { + message: "Hello Python!", + }, + path1: "/dev/hello1", + path2: "/dev/hello2", + path3: "/dev/hello3", + }, + ].forEach( + ({ description, expected1, expected2, expected3, path1, path2, path3 }) => { + it(description, async function it() { + // "Could not find 'Docker', skipping tests." + if (!env.DOCKER_DETECTED) { + this.skip() + } + + const url1 = new URL(path1, BASE_URL) + const url2 = new URL(path2, BASE_URL) + const url3 = new URL(path3, BASE_URL) + + const [response1, response2, response3] = await Promise.all([ + fetch(url1), + fetch(url2), + fetch(url3), + ]) + + const [json1, json2, json3] = await Promise.all([ + response1.json(), + response2.json(), + response3.json(), + ]) + + assert.equal(json1.message, expected1.message) + assert.equal(json2.message, expected2.message) + assert.equal(json3.message, expected3.message) + }) + }, + ) }) diff --git a/tests/integration/docker/multiple/serverless.yml b/tests/integration/docker/multiple/serverless.yml index 5bdc5d52b..1d30d5e30 100644 --- a/tests/integration/docker/multiple/serverless.yml +++ b/tests/integration/docker/multiple/serverless.yml @@ -12,7 +12,7 @@ provider: memorySize: 1024 name: aws region: us-east-1 - runtime: nodejs12.x + runtime: nodejs18.x stage: dev versionFunctions: false @@ -35,7 +35,7 @@ functions: method: get path: hello2 handler: handler.hello - runtime: nodejs12.x + runtime: nodejs20.x hello3: events: @@ -43,4 +43,4 @@ functions: method: get path: hello3 handler: handler.hello - runtime: python3.8 + runtime: python3.7 diff --git a/tests/integration/docker/nodejs/.DS_Store b/tests/integration/docker/nodejs/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..925afe655e3578bc675d85b245d868d34b77efd0 GIT binary patch literal 6148 zcmeHK%}T>S5T0$TO)WwX3Oz1(EgD;Y5HF$D7cim+mD-S^(U_H{wL&T6tS{t~_&m<+ zZpG4i@FHSoVD_7xpDg<&>|_BzGzZ}}Km`CCRKi>dhdDxV(izEF524V{xPuhx;KC+6 z&t$XXFET*yZUquh5JDHeyuV_FoO1eE=5QSY#xjc`OPz{@Ekc6qO^-aJjIi+@` zIvO?VyEWO^cgHn3I;gufxzpGik4w(_#@69U`#ye1)Qcfh;J2q`)#3zR(U`lpC%>1( zD!IYgT9^Fg8#dKNQ-`sl!cejh1bAS6MX z?h=I3qGvHPh!GTFN)b(|uvZLW%F!=vo@X&LXv#t8mGL=tWnph9La&Z~snbDt26 true) - - // beforeEach(() => - // setup({ - // servicePath: join(import.meta.url), - // }), - // ) - - // afterEach(() => teardown()) - - // // - // ;[ - // { - // description: 'should work with nodejs12.x in docker container', - // expected: { - // message: 'Hello Node.js 12.x!', - // }, - // 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.equal(json.message, expected.message) - // }) - // }) -}) diff --git a/tests/integration/docker/nodejs/nodejs18.x/dockerNodejs18.x.test.js b/tests/integration/docker/nodejs/nodejs18.x/dockerNodejs18.x.test.js new file mode 100644 index 000000000..a5bb6b2dd --- /dev/null +++ b/tests/integration/docker/nodejs/nodejs18.x/dockerNodejs18.x.test.js @@ -0,0 +1,37 @@ +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("Node.js 18.x with Docker tests", function desc() { + beforeEach(() => + setup({ + servicePath: join(import.meta.url), + }), + ) + + afterEach(() => teardown()) + ;[ + { + description: "should work with nodejs18.x in docker container", + expected: { + message: "Hello Node.js 18.x!", + }, + 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.equal(json.message, expected.message) + }) + }) +}) diff --git a/tests/integration/docker/nodejs/nodejs12.x/handler.js b/tests/integration/docker/nodejs/nodejs18.x/handler.js similarity index 87% rename from tests/integration/docker/nodejs/nodejs12.x/handler.js rename to tests/integration/docker/nodejs/nodejs18.x/handler.js index d2c94463b..dead60d59 100644 --- a/tests/integration/docker/nodejs/nodejs12.x/handler.js +++ b/tests/integration/docker/nodejs/nodejs18.x/handler.js @@ -8,7 +8,7 @@ const { stringify } = JSON module.exports.hello = async () => { return { body: stringify({ - message: "Hello Node.js 12.x!", + message: "Hello Node.js 18.x!", version: versions.node, }), statusCode: 200, diff --git a/tests/integration/docker/nodejs/nodejs12.x/serverless.yml b/tests/integration/docker/nodejs/nodejs18.x/serverless.yml similarity index 89% rename from tests/integration/docker/nodejs/nodejs12.x/serverless.yml rename to tests/integration/docker/nodejs/nodejs18.x/serverless.yml index 464ca513c..dcaa9163a 100644 --- a/tests/integration/docker/nodejs/nodejs12.x/serverless.yml +++ b/tests/integration/docker/nodejs/nodejs18.x/serverless.yml @@ -1,4 +1,4 @@ -service: docker-nodejs12-x-test +service: docker-nodejs18-x-test configValidationMode: error deprecationNotificationMode: error @@ -12,7 +12,7 @@ provider: memorySize: 1024 name: aws region: us-east-1 - runtime: nodejs12.x + runtime: nodejs18.x stage: dev versionFunctions: false diff --git a/tests/integration/docker/nodejs/nodejs20.x/dockerNodejs20.x.test.js b/tests/integration/docker/nodejs/nodejs20.x/dockerNodejs20.x.test.js new file mode 100644 index 000000000..8916f05f9 --- /dev/null +++ b/tests/integration/docker/nodejs/nodejs20.x/dockerNodejs20.x.test.js @@ -0,0 +1,37 @@ +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("Node.js 20.x with Docker tests", function desc() { + beforeEach(() => + setup({ + servicePath: join(import.meta.url), + }), + ) + + afterEach(() => teardown()) + ;[ + { + description: "should work with nodejs20.x in docker container", + expected: { + message: "Hello Node.js 20.x!", + }, + 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.equal(json.message, expected.message) + }) + }) +}) diff --git a/tests/integration/docker/nodejs/nodejs20.x/handler.js b/tests/integration/docker/nodejs/nodejs20.x/handler.js new file mode 100644 index 000000000..e25db38da --- /dev/null +++ b/tests/integration/docker/nodejs/nodejs20.x/handler.js @@ -0,0 +1,16 @@ +"use strict" + +// eslint-disable-next-line unicorn/prefer-node-protocol +const { versions } = require("process") + +const { stringify } = JSON + +module.exports.hello = async () => { + return { + body: stringify({ + message: "Hello Node.js 20.x!", + version: versions.node, + }), + statusCode: 200, + } +} diff --git a/tests/integration/docker/nodejs/nodejs20.x/serverless.yml b/tests/integration/docker/nodejs/nodejs20.x/serverless.yml new file mode 100644 index 000000000..0c8b40545 --- /dev/null +++ b/tests/integration/docker/nodejs/nodejs20.x/serverless.yml @@ -0,0 +1,30 @@ +service: docker-nodejs20-x-test + +configValidationMode: error +deprecationNotificationMode: error + +plugins: + - ../../../../../src/index.js + +provider: + architecture: arm64 + deploymentMethod: direct + memorySize: 1024 + name: aws + region: us-east-1 + runtime: nodejs20.x + stage: dev + versionFunctions: false + +custom: + serverless-offline: + noTimeout: true + useDocker: true + +functions: + hello: + events: + - http: + method: get + path: hello + handler: handler.hello diff --git a/tests/integration/docker/nodejs/nodejs21.x/dockerNodejs21.x.test.js b/tests/integration/docker/nodejs/nodejs21.x/dockerNodejs21.x.test.js new file mode 100644 index 000000000..3eea74c38 --- /dev/null +++ b/tests/integration/docker/nodejs/nodejs21.x/dockerNodejs21.x.test.js @@ -0,0 +1,37 @@ +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("Node.js 21.x with Docker tests", function desc() { + beforeEach(() => + setup({ + servicePath: join(import.meta.url), + }), + ) + + afterEach(() => teardown()) + ;[ + { + description: "should work with nodejs21.x in docker container", + expected: { + message: "Hello Node.js 21.x!", + }, + 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.equal(json.message, expected.message) + }) + }) +}) diff --git a/tests/integration/docker/nodejs/nodejs21.x/handler.js b/tests/integration/docker/nodejs/nodejs21.x/handler.js new file mode 100644 index 000000000..9e376b203 --- /dev/null +++ b/tests/integration/docker/nodejs/nodejs21.x/handler.js @@ -0,0 +1,16 @@ +"use strict" + +// eslint-disable-next-line unicorn/prefer-node-protocol +const { versions } = require("process") + +const { stringify } = JSON + +module.exports.hello = async () => { + return { + body: stringify({ + message: "Hello Node.js 21.x!", + version: versions.node, + }), + statusCode: 200, + } +} diff --git a/tests/integration/docker/nodejs/nodejs21.x/serverless.yml b/tests/integration/docker/nodejs/nodejs21.x/serverless.yml new file mode 100644 index 000000000..a391ef465 --- /dev/null +++ b/tests/integration/docker/nodejs/nodejs21.x/serverless.yml @@ -0,0 +1,30 @@ +service: docker-nodejs21-x-test + +configValidationMode: error +deprecationNotificationMode: error + +plugins: + - ../../../../../src/index.js + +provider: + architecture: arm64 + deploymentMethod: direct + memorySize: 1024 + name: aws + region: us-east-1 + runtime: nodejs21.x + stage: dev + versionFunctions: false + +custom: + serverless-offline: + noTimeout: true + useDocker: true + +functions: + hello: + events: + - http: + method: get + path: hello + handler: handler.hello diff --git a/tests/integration/docker/python/.DS_Store b/tests/integration/docker/python/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..146e479f8d80b50adba8367755e4cc9693971a32 GIT binary patch literal 6148 zcmeHKOHRW;4E2->rLgIe<(vR9Vu9F&Dx9DfKxqVBq)fzT!7i8MDC`ht;CXCSt&&J# z0~N9*`%OG{#(AmYnuy%uwF*RYBFdnQlNn5p@IGrtChFllm+leikuK?+0$p^X&2fkf z@Vh&qhTiCf*0l5f>W8pg#Z4ncAKwqfZDLWBbu6);HDA{sPoM8M!?D%q*k-+Ze)>7} z)fq + setup({ + servicePath: join(import.meta.url), + }), + ) + + afterEach(() => teardown()) + + // + ;[ + { + description: "should work with python3.10 in docker container", + expected: { + message: "Hello Python 3.10!", + }, + 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) + }) + }) +}) diff --git a/tests/integration/docker/python/python3.10/handler.py b/tests/integration/docker/python/python3.10/handler.py new file mode 100644 index 000000000..e3568bab9 --- /dev/null +++ b/tests/integration/docker/python/python3.10/handler.py @@ -0,0 +1,11 @@ +import json + +def hello(event, context): + body = { + "message": "Hello Python 3.10!" + } + + return { + "body": json.dumps(body), + "statusCode": 200, + } diff --git a/tests/integration/docker/python/python3.10/serverless.yml b/tests/integration/docker/python/python3.10/serverless.yml new file mode 100644 index 000000000..a525bdae2 --- /dev/null +++ b/tests/integration/docker/python/python3.10/serverless.yml @@ -0,0 +1,30 @@ +service: docker-python-3-10-tests + +configValidationMode: error +deprecationNotificationMode: error + +plugins: + - ../../../../../src/index.js + +provider: + architecture: x86_64 + deploymentMethod: direct + memorySize: 1024 + name: aws + region: us-east-1 + runtime: python3.10 + stage: dev + versionFunctions: false + +custom: + serverless-offline: + noTimeout: true + useDocker: true + +functions: + hello: + events: + - http: + method: get + path: hello + handler: handler.hello diff --git a/tests/integration/docker/python/python3.11/dockerPython3.11.test.js b/tests/integration/docker/python/python3.11/dockerPython3.11.test.js new file mode 100644 index 000000000..92eb21a60 --- /dev/null +++ b/tests/integration/docker/python/python3.11/dockerPython3.11.test.js @@ -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("Python 3.11 with Docker tests", function desc() { + beforeEach(() => + setup({ + servicePath: join(import.meta.url), + }), + ) + + afterEach(() => teardown()) + + // + ;[ + { + description: "should work with python3.11 in docker container", + expected: { + message: "Hello Python 3.11!", + }, + 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) + }) + }) +}) diff --git a/tests/integration/docker/python/python3.11/handler.py b/tests/integration/docker/python/python3.11/handler.py new file mode 100644 index 000000000..b47105d1d --- /dev/null +++ b/tests/integration/docker/python/python3.11/handler.py @@ -0,0 +1,11 @@ +import json + +def hello(event, context): + body = { + "message": "Hello Python 3.11!" + } + + return { + "body": json.dumps(body), + "statusCode": 200, + } diff --git a/tests/integration/docker/python/python3.11/serverless.yml b/tests/integration/docker/python/python3.11/serverless.yml new file mode 100644 index 000000000..6b16c78d1 --- /dev/null +++ b/tests/integration/docker/python/python3.11/serverless.yml @@ -0,0 +1,30 @@ +service: docker-python-3-11-tests + +configValidationMode: error +deprecationNotificationMode: error + +plugins: + - ../../../../../src/index.js + +provider: + architecture: x86_64 + deploymentMethod: direct + memorySize: 1024 + name: aws + region: us-east-1 + runtime: python3.11 + stage: dev + versionFunctions: false + +custom: + serverless-offline: + noTimeout: true + useDocker: true + +functions: + hello: + events: + - http: + method: get + path: hello + handler: handler.hello diff --git a/tests/integration/docker/ruby/ruby3.2/dockerRuby3.2.test.js b/tests/integration/docker/ruby/ruby3.2/dockerRuby3.2.test.js new file mode 100644 index 000000000..6e34bd92c --- /dev/null +++ b/tests/integration/docker/ruby/ruby3.2/dockerRuby3.2.test.js @@ -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("Ruby 3.2 with Docker tests", function desc() { + beforeEach(() => + setup({ + servicePath: join(import.meta.url), + }), + ) + + afterEach(() => teardown()) + + // + ;[ + { + description: "should work with ruby3.2 in docker container", + expected: { + message: "Hello Ruby 3.2!", + }, + 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.equal(json.message, expected.message) + }) + }) +}) diff --git a/tests/integration/docker/ruby/ruby3.2/handler.rb b/tests/integration/docker/ruby/ruby3.2/handler.rb new file mode 100644 index 000000000..62327330e --- /dev/null +++ b/tests/integration/docker/ruby/ruby3.2/handler.rb @@ -0,0 +1,11 @@ +require 'json' + +def hello(event:, context:) + { + body: JSON.generate({ + message: 'Hello Ruby 3.2!', + version: RUBY_VERSION, + }), + statusCode: 200, + } +end diff --git a/tests/integration/docker/ruby/ruby3.2/serverless.yml b/tests/integration/docker/ruby/ruby3.2/serverless.yml new file mode 100644 index 000000000..001eaf7b7 --- /dev/null +++ b/tests/integration/docker/ruby/ruby3.2/serverless.yml @@ -0,0 +1,30 @@ +service: docker-ruby-3-2-tests + +configValidationMode: error +deprecationNotificationMode: error + +plugins: + - ../../../../../src/index.js + +provider: + architecture: x86_64 + deploymentMethod: direct + memorySize: 1024 + name: aws + region: us-east-1 + runtime: ruby3.2 + stage: dev + versionFunctions: false + +custom: + serverless-offline: + noTimeout: true + useDocker: true + +functions: + hello: + events: + - http: + method: get + path: hello + handler: handler.hello