Skip to content

Commit

Permalink
test: add more docker tests (#1779)
Browse files Browse the repository at this point in the history
* test: add more docker tests

* chore: revert mocharc change

* chore: remove DS_Store

* test: remove unsupported nodejs 21

* ci: change architecture for docker tests

* ci: use azul instead of temurin

* ci: use zulu openjdk

* ci: use macos-12
  • Loading branch information
DorianMazur committed Apr 24, 2024
1 parent d6b155e commit cdec7bd
Show file tree
Hide file tree
Showing 28 changed files with 521 additions and 216 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
os: [macos-12, ubuntu-latest, windows-latest]
node-version: [18, 20, 21]

steps:
Expand Down
7 changes: 2 additions & 5 deletions src/config/supportedRuntimes.js
Expand Up @@ -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],
Expand All @@ -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],
Expand Down Expand Up @@ -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,
Expand All @@ -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([])
101 changes: 49 additions & 52 deletions tests/integration/docker/access-host/accessHost.test.js
@@ -1,55 +1,52 @@
// import assert from 'node:assert'
// import { env } from 'node:process'
// import { Server } from '@hapi/hapi'
// import { join } from 'desm'
// import { setup, teardown } from '../../../_testHelpers/index.js'
// import installNpmModules from '../../../installNpmModules.js'
// import { BASE_URL } from '../../../config.js'
import assert from "node:assert"
import { env } from "node:process"
import { Server } from "@hapi/hapi"
import { join } from "desm"
import { setup, teardown } from "../../../_testHelpers/index.js"
import installNpmModules from "../../../installNpmModules.js"
import { BASE_URL } from "../../../config.js"

describe("Access host with Docker tests", function desc() {
it("placeholder, node.js v12 not supported anymore", () => 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)
})
})
})
4 changes: 2 additions & 2 deletions tests/integration/docker/access-host/serverless.yml
Expand Up @@ -7,12 +7,12 @@ plugins:
- ../../../../src/index.js

provider:
architecture: arm64
architecture: x86_64
deploymentMethod: direct
memorySize: 1024
name: aws
region: us-east-1
runtime: nodejs12.x
runtime: nodejs18.x
stage: dev
versionFunctions: false

Expand Down
80 changes: 38 additions & 42 deletions 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)
})
})
})
4 changes: 2 additions & 2 deletions tests/integration/docker/artifact/serverless.yml
Expand Up @@ -7,12 +7,12 @@ plugins:
- ../../../../src/index.js

provider:
architecture: arm64
architecture: x86_64
deploymentMethod: direct
memorySize: 1024
name: aws
region: us-east-1
runtime: nodejs12.x
runtime: nodejs18.x
stage: dev
versionFunctions: false

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/docker/layers/serverless.yml
Expand Up @@ -7,7 +7,7 @@ plugins:
- ../../../../src/index.js

provider:
architecture: arm64
architecture: x86_64
deploymentMethod: direct
memorySize: 1024
name: aws
Expand Down

0 comments on commit cdec7bd

Please sign in to comment.