[tests] Fix failures due to Node 14.x being discontinued (#10346)

This PR upgrades test fixtures from Node.js 14 to 16 and also removes
the `35-puppeteer` test fixture since it doesn't support Node.js 16
unfortunately.

- See https://github.com/alixaxel/chrome-aws-lambda/pull/274

---------

Co-authored-by: Steven <steven@ceriously.com>
This commit is contained in:
Nathan Rajlich
2023-08-15 14:59:21 -07:00
committed by GitHub
parent 936a428420
commit 10a6aa55f9
15 changed files with 11 additions and 2441 deletions

View File

@@ -0,0 +1,2 @@
---
---

View File

@@ -387,7 +387,6 @@ This is an abstract enumeration type that is implemented by one of the following
- `nodejs18.x`
- `nodejs16.x`
- `nodejs14.x`
- `go1.x`
- `java11`
- `python3.9`

View File

@@ -1,5 +1,5 @@
{
"engines": {
"node": "14.x"
"node": "16.x"
}
}

View File

@@ -1,5 +1,5 @@
{
"engines": {
"node": "14.0.0 - 14.99.99"
"node": "16.0.0 - 16.99.99"
}
}

View File

@@ -9,7 +9,7 @@
"probes": [
{ "path": "/empty", "mustContain": "RANDOMNESS_PLACEHOLDER:18" },
{ "path": "/greater", "mustContain": "RANDOMNESS_PLACEHOLDER:18" },
{ "path": "/major", "mustContain": "RANDOMNESS_PLACEHOLDER:14" },
{ "path": "/range", "mustContain": "RANDOMNESS_PLACEHOLDER:14" }
{ "path": "/major", "mustContain": "RANDOMNESS_PLACEHOLDER:16" },
{ "path": "/range", "mustContain": "RANDOMNESS_PLACEHOLDER:16" }
]
}

View File

@@ -1,35 +0,0 @@
import chrome from 'chrome-aws-lambda';
import puppeteer from 'puppeteer-core';
async function getOptions() {
const options = {
args: chrome.args,
executablePath: await chrome.executablePath,
headless: chrome.headless,
};
return options;
}
async function getPage() {
const options = await getOptions();
const browser = await puppeteer.launch(options);
const page = await browser.newPage();
return page;
}
async function getScreenshot(url) {
const page = await getPage();
await page.setViewport({ width: 2048, height: 1170 });
await page.goto(url);
const file = await page.screenshot({ type: 'png' });
return file;
}
module.exports = async (req, res) => {
const buffer = await getScreenshot('https://vercel.com/about');
if (buffer.length > 0) {
res.end('/api/screenshot:RANDOMNESS_PLACEHOLDER');
} else {
res.end('buffer is empty');
}
};

View File

@@ -1,11 +0,0 @@
{
"private": true,
"engines": {
"node": "14.x"
},
"dependencies": {
"chrome-aws-lambda": "7.0.0",
"lighthouse": "7.4.0",
"puppeteer-core": "7.0.0"
}
}

View File

@@ -1,41 +0,0 @@
const assert = require('assert').strict;
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
async function tryTest({
testName,
deploymentUrl,
fetch,
randomness,
retries = 4,
}) {
try {
const res = await fetch(`https://${deploymentUrl}${testName}`);
assert.equal(res.status, 200);
const text = await res.text();
assert.equal(text.trim(), `${testName}:${randomness}`);
console.log(`Finished testing "${testName}" probe.`);
} catch (e) {
if (retries === 0) {
console.error(e);
throw e;
}
console.log(`Failed "${testName}" probe. Retries remaining: ${retries}`);
await sleep(1000);
await tryTest({
testName,
deploymentUrl,
fetch,
randomness,
retries: retries - 1,
});
}
}
module.exports = async ({ deploymentUrl, fetch, randomness }) => {
await tryTest({
testName: '/api/screenshot',
deploymentUrl,
fetch,
randomness,
});
};

View File

@@ -1,8 +0,0 @@
{
"functions": {
"api/**/*.js": {
"memory": 1024,
"maxDuration": 10
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -2,13 +2,13 @@
"version": 2,
"builds": [
{ "src": "some-build.sh", "use": "@vercel/static-build" },
{ "src": "node14sh/build.sh", "use": "@vercel/static-build" },
{ "src": "node18sh/build.sh", "use": "@vercel/static-build" },
{ "src": "node16sh/build.sh", "use": "@vercel/static-build" },
{ "src": "subdirectory/some-build.sh", "use": "@vercel/static-build" }
],
"probes": [
{ "path": "/", "mustContain": "cow:RANDOMNESS_PLACEHOLDER" },
{ "path": "/node14sh/", "mustContain": "node:v14" },
{ "path": "/node18sh/", "mustContain": "node:v18" },
{ "path": "/node16sh/", "mustContain": "node:v16" },
{ "path": "/subdirectory/", "mustContain": "yoda:RANDOMNESS_PLACEHOLDER" }
]

View File

@@ -9,7 +9,7 @@
"sleeper": {
"memory": 128,
"maxDuration": 2,
"runtime": "nodejs14.x",
"runtime": "nodejs18.x",
"handler": "index.handler",
"regions": ["hkg1"]
}

View File

@@ -14,6 +14,6 @@
"clean": "gatsby clean"
},
"engines": {
"node": "14.x"
"node": "16.x"
}
}