From 56de484b750f0efe54a98de091f2a545ada38485 Mon Sep 17 00:00:00 2001 From: "pattishin@google.com" Date: Wed, 28 Jun 2023 16:52:12 -0700 Subject: [PATCH 1/7] chore: switch from node 14 -> 16 --- package.json | 2 +- renovate.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 896451d395..7e8eb0b9b7 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "license": "Apache-2.0", "author": "Google Inc.", "engines": { - "node": ">=14.0.0" + "node": ">=16.0.0" }, "repository": { "type": "git", diff --git a/renovate.json b/renovate.json index aacf68869d..eaf60ec986 100644 --- a/renovate.json +++ b/renovate.json @@ -7,7 +7,7 @@ "rebaseStalePrs": false, "force": { "constraints": { - "node": "< 15.0.0" + "node": ">= 16.0.0" } } } From 280fbca80189dee1c85594311c0f0bb06e451a05 Mon Sep 17 00:00:00 2001 From: "pattishin@google.com" Date: Wed, 28 Jun 2023 17:11:01 -0700 Subject: [PATCH 2/7] chore: updating old node ref to v16 --- .github/workflows/ci.yaml | 2 +- .kokoro/common.cfg | 4 ++-- .kokoro/functions/billing-periodic.cfg | 2 +- .kokoro/functions/imagemagick.cfg | 2 +- .kokoro/functions/ocr-app.cfg | 2 +- .kokoro/run/common.cfg | 2 +- cloud-tasks/snippets/package.json | 2 +- run/idp-sql/Dockerfile | 2 +- run/idp-sql/package.json | 2 +- workflows/invoke-private-endpoint/package.json | 2 +- workflows/package.json | 2 +- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 298a5428fd..21bdc3b269 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -28,7 +28,7 @@ jobs: - uses: actions/checkout@v3.5.3 - uses: actions/setup-node@v3 with: - node-version: 14 + node-version: 16 - run: npm install - run: npm run lint docs: diff --git a/.kokoro/common.cfg b/.kokoro/common.cfg index 649a163cab..f055ddf7a7 100644 --- a/.kokoro/common.cfg +++ b/.kokoro/common.cfg @@ -12,7 +12,7 @@ build_file: "nodejs-docs-samples/.kokoro/trampoline.sh" # Configure the docker image for kokoro-trampoline. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" + value: "gcr.io/cloud-devrel-kokoro-resources/node:16-user" } # Export XUnit test results for further analysis @@ -20,4 +20,4 @@ action { define_artifacts { regex: "**/*sponge_log.xml" } -} \ No newline at end of file +} diff --git a/.kokoro/functions/billing-periodic.cfg b/.kokoro/functions/billing-periodic.cfg index 63b72d1571..e1e9ec23c4 100644 --- a/.kokoro/functions/billing-periodic.cfg +++ b/.kokoro/functions/billing-periodic.cfg @@ -15,7 +15,7 @@ env_vars: { # Configure the docker image for kokoro-trampoline. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" + value: "gcr.io/cloud-devrel-kokoro-resources/node:16-user" } # Tell the trampoline which build file to use. diff --git a/.kokoro/functions/imagemagick.cfg b/.kokoro/functions/imagemagick.cfg index 801e160cdf..02c044aeb6 100644 --- a/.kokoro/functions/imagemagick.cfg +++ b/.kokoro/functions/imagemagick.cfg @@ -9,7 +9,7 @@ env_vars: { # Configure the docker image for kokoro-trampoline. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" + value: "gcr.io/cloud-devrel-kokoro-resources/node:16-user" } # Tell the trampoline which build file to use. diff --git a/.kokoro/functions/ocr-app.cfg b/.kokoro/functions/ocr-app.cfg index db77c999d5..a172723876 100644 --- a/.kokoro/functions/ocr-app.cfg +++ b/.kokoro/functions/ocr-app.cfg @@ -9,7 +9,7 @@ env_vars: { # Configure the docker image for kokoro-trampoline. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" + value: "gcr.io/cloud-devrel-kokoro-resources/node:16-user" } # Tell the trampoline which build file to use. diff --git a/.kokoro/run/common.cfg b/.kokoro/run/common.cfg index 0bfb0d1dc1..10f6694963 100644 --- a/.kokoro/run/common.cfg +++ b/.kokoro/run/common.cfg @@ -18,7 +18,7 @@ env_vars: { # Configure the docker image for kokoro-trampoline. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" + value: "gcr.io/cloud-devrel-kokoro-resources/node:16-user" } # Export XUnit test results for further analysis diff --git a/cloud-tasks/snippets/package.json b/cloud-tasks/snippets/package.json index 1a24617826..8a5c10dde4 100644 --- a/cloud-tasks/snippets/package.json +++ b/cloud-tasks/snippets/package.json @@ -5,7 +5,7 @@ "author": "Google Inc.", "private": true, "engines": { - "node": ">=14.0.0" + "node": ">=16.0.0" }, "files": [ "*.js" diff --git a/run/idp-sql/Dockerfile b/run/idp-sql/Dockerfile index 66fa0403f2..523a8c94c2 100644 --- a/run/idp-sql/Dockerfile +++ b/run/idp-sql/Dockerfile @@ -4,7 +4,7 @@ # Use the official lightweight Node.js image. # https://hub.docker.com/_/node -FROM node:14-slim +FROM node:16-slim # Create and change to the app directory. WORKDIR /usr/src/app diff --git a/run/idp-sql/package.json b/run/idp-sql/package.json index 72ddeeba79..29bd21c38d 100644 --- a/run/idp-sql/package.json +++ b/run/idp-sql/package.json @@ -10,7 +10,7 @@ "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git" }, "engines": { - "node": ">=12.0.0" + "node": ">=16.0.0" }, "scripts": { "start": "node index.js", diff --git a/workflows/invoke-private-endpoint/package.json b/workflows/invoke-private-endpoint/package.json index c9190955f4..881991ce91 100644 --- a/workflows/invoke-private-endpoint/package.json +++ b/workflows/invoke-private-endpoint/package.json @@ -10,7 +10,7 @@ "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git" }, "engines": { - "node": ">=14.0.0" + "node": ">=16.0.0" }, "scripts": { "start": "node app.js", diff --git a/workflows/package.json b/workflows/package.json index 617e59c6f6..62bc7b4b2b 100644 --- a/workflows/package.json +++ b/workflows/package.json @@ -4,7 +4,7 @@ "license": "Apache-2.0", "author": "Google LLC", "engines": { - "node": ">=12.0.0" + "node": ">=16.0.0" }, "scripts": { "build": "tsc -p .", From dc113e1f182e75cb7e4a5f71a2093db241225759 Mon Sep 17 00:00:00 2001 From: "pattishin@google.com" Date: Wed, 5 Jul 2023 14:08:44 -0700 Subject: [PATCH 3/7] fix: put minimum node v16 --- run/websockets/package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/run/websockets/package.json b/run/websockets/package.json index 71008f753e..f92a59fb8a 100644 --- a/run/websockets/package.json +++ b/run/websockets/package.json @@ -5,6 +5,9 @@ "private": true, "license": "Apache Version 2.0", "author": "Google LLC", + "engines": { + "node": ">=16.x.x" + }, "scripts": { "start": "node index.js", "system-test": "c8 mocha test/system.test.js --timeout=420000 --exit" From c0c3d4962f9cda264c9b89f406685085f86dbb53 Mon Sep 17 00:00:00 2001 From: "pattishin@google.com" Date: Wed, 5 Jul 2023 14:30:09 -0700 Subject: [PATCH 4/7] refactor: updating kokoro image (anticipating) v16 puppeteer update --- .kokoro/run/websockets.cfg | 2 +- appengine/websockets/package.json | 2 +- cloud-sql/mysql/mysql2/package.json | 2 +- run/websockets/package.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.kokoro/run/websockets.cfg b/.kokoro/run/websockets.cfg index 42801fe591..15a9c42d84 100644 --- a/.kokoro/run/websockets.cfg +++ b/.kokoro/run/websockets.cfg @@ -16,5 +16,5 @@ env_vars: { # Override common.cfg to include puppeteer env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:14-puppeteer" + value: "gcr.io/cloud-devrel-kokoro-resources/node:16-puppeteer" } diff --git a/appengine/websockets/package.json b/appengine/websockets/package.json index cfe2b94de9..8e104c86cc 100644 --- a/appengine/websockets/package.json +++ b/appengine/websockets/package.json @@ -23,6 +23,6 @@ "devDependencies": { "c8": "^8.0.0", "mocha": "^10.0.0", - "puppeteer": "^20.0.0" + "puppeteer": "^20.6.0" } } diff --git a/cloud-sql/mysql/mysql2/package.json b/cloud-sql/mysql/mysql2/package.json index ee93753c14..56d5fd6704 100644 --- a/cloud-sql/mysql/mysql2/package.json +++ b/cloud-sql/mysql/mysql2/package.json @@ -9,7 +9,7 @@ "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git" }, "engines": { - "node": ">=14.0.0" + "node": ">=16.0.0" }, "scripts": { "start": "node server/server.js", diff --git a/run/websockets/package.json b/run/websockets/package.json index f92a59fb8a..e4f214caa4 100644 --- a/run/websockets/package.json +++ b/run/websockets/package.json @@ -24,6 +24,6 @@ "google-auth-library": "^8.7.0", "got": "^11.8.3", "mocha": "^10.2.0", - "puppeteer": "^20.0.0" + "puppeteer": "^20.6.0" } } From d1f5d2ecfd73a2a89d83ce18ecad67097b050bd1 Mon Sep 17 00:00:00 2001 From: "pattishin@google.com" Date: Tue, 8 Aug 2023 11:06:51 -0700 Subject: [PATCH 5/7] refactor: update imagemagick test with try catch and throw assert error on promise failure --- functions/imagemagick/test/index.test.js | 63 ++++++++++++++---------- 1 file changed, 38 insertions(+), 25 deletions(-) diff --git a/functions/imagemagick/test/index.test.js b/functions/imagemagick/test/index.test.js index 5aa3b10e17..d6d9543395 100644 --- a/functions/imagemagick/test/index.test.js +++ b/functions/imagemagick/test/index.test.js @@ -1,4 +1,4 @@ -// Copyright 2017 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -80,16 +80,21 @@ describe('functions/imagemagick tests', () => { const PORT = 8080; const {ffProc, ffProcHandler} = await startFF(PORT); - await request({ - url: `http://localhost:${PORT}/blurOffensiveImages`, - method: 'POST', - data: { + try { + await request({ + url: `http://localhost:${PORT}/blurOffensiveImages`, + method: 'POST', data: { - bucket: BUCKET_NAME, - name: testFiles.safe, + data: { + bucket: BUCKET_NAME, + name: testFiles.safe, + }, }, - }, - }); + }); + } catch(error) { + assert.fail(error); + } + ffProc.kill(); const stdout = await ffProcHandler; assert.ok(stdout.includes(`Detected ${testFiles.safe} as OK.`)); @@ -99,16 +104,20 @@ describe('functions/imagemagick tests', () => { const PORT = 8081; const {ffProc, ffProcHandler} = await startFF(PORT); - await request({ - url: `http://localhost:${PORT}/blurOffensiveImages`, - method: 'POST', - data: { + try { + await request({ + url: `http://localhost:${PORT}/blurOffensiveImages`, + method: 'POST', data: { - bucket: BUCKET_NAME, - name: testFiles.offensive, + data: { + bucket: BUCKET_NAME, + name: testFiles.offensive, + }, }, - }, - }); + }); + } catch(error) { + assert.fail(error); + } ffProc.kill(); const stdout = await ffProcHandler; @@ -132,16 +141,20 @@ describe('functions/imagemagick tests', () => { const {ffProc, ffProcHandler} = await startFF(PORT); const missingFileName = 'file-does-not-exist.jpg'; - await request({ - url: `http://localhost:${PORT}/blurOffensiveImages`, - method: 'POST', - data: { + try { + await request({ + url: `http://localhost:${PORT}/blurOffensiveImages`, + method: 'POST', data: { - bucket: BUCKET_NAME, - name: missingFileName, + data: { + bucket: BUCKET_NAME, + name: missingFileName, + }, }, - }, - }); + }); + } catch(error) { + assert.fail(error); + } ffProc.kill(); const stdout = await ffProcHandler; From f2021118af50d0144684513422ae303452648264 Mon Sep 17 00:00:00 2001 From: "pattishin@google.com" Date: Tue, 8 Aug 2023 11:17:03 -0700 Subject: [PATCH 6/7] test: adding additional try catch for ff fetch, adding debugging log --- functions/imagemagick/test/index.test.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/functions/imagemagick/test/index.test.js b/functions/imagemagick/test/index.test.js index d6d9543395..d00313cb77 100644 --- a/functions/imagemagick/test/index.test.js +++ b/functions/imagemagick/test/index.test.js @@ -78,7 +78,19 @@ describe('functions/imagemagick tests', () => { describe('functions_imagemagick_setup functions_imagemagick_analyze functions_imagemagick_blur', () => { it('blurOffensiveImages detects safe images using Cloud Vision', async () => { const PORT = 8080; - const {ffProc, ffProcHandler} = await startFF(PORT); + let ffProc; + let ffProcHandler; + + try { + const ff = await startFF(PORT); + ffProc = ff?.ffProc; + ffProcHandler = ff?.ffProcHandler; + } catch(error) { + console.log('---test check----'); + console.log(error); + + assert.fail(error); + } try { await request({ From 53a62ca18bcb507fe9a50037080fa8af876c06cb Mon Sep 17 00:00:00 2001 From: "pattishin@google.com" Date: Tue, 8 Aug 2023 11:26:52 -0700 Subject: [PATCH 7/7] refactor: wrapping ffProcHandler with try/catch --- functions/imagemagick/test/index.test.js | 51 +++++++++++++----------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/functions/imagemagick/test/index.test.js b/functions/imagemagick/test/index.test.js index d00313cb77..f2fef74257 100644 --- a/functions/imagemagick/test/index.test.js +++ b/functions/imagemagick/test/index.test.js @@ -78,19 +78,7 @@ describe('functions/imagemagick tests', () => { describe('functions_imagemagick_setup functions_imagemagick_analyze functions_imagemagick_blur', () => { it('blurOffensiveImages detects safe images using Cloud Vision', async () => { const PORT = 8080; - let ffProc; - let ffProcHandler; - - try { - const ff = await startFF(PORT); - ffProc = ff?.ffProc; - ffProcHandler = ff?.ffProcHandler; - } catch(error) { - console.log('---test check----'); - console.log(error); - - assert.fail(error); - } + const {ffProc, ffProcHandler} = await startFF(PORT); try { await request({ @@ -108,8 +96,13 @@ describe('functions/imagemagick tests', () => { } ffProc.kill(); - const stdout = await ffProcHandler; - assert.ok(stdout.includes(`Detected ${testFiles.safe} as OK.`)); + + try { + const stdout = await ffProcHandler; + assert.ok(stdout.includes(`Detected ${testFiles.safe} as OK.`)); + } catch(error) { + assert.fail(error); + } }); it('blurOffensiveImages successfully blurs offensive images', async () => { @@ -132,14 +125,19 @@ describe('functions/imagemagick tests', () => { } ffProc.kill(); - const stdout = await ffProcHandler; + + try { + const stdout = await ffProcHandler; - assert.ok(stdout.includes(`Blurred image: ${testFiles.offensive}`)); - assert.ok( - stdout.includes( - `Uploaded blurred image to: gs://${BLURRED_BUCKET_NAME}/${testFiles.offensive}` - ) - ); + assert.ok(stdout.includes(`Blurred image: ${testFiles.offensive}`)); + assert.ok( + stdout.includes( + `Uploaded blurred image to: gs://${BLURRED_BUCKET_NAME}/${testFiles.offensive}` + ) + ); + } catch(error) { + assert.fail(error); + } const exists = await storage .bucket(BLURRED_BUCKET_NAME) @@ -169,8 +167,13 @@ describe('functions/imagemagick tests', () => { } ffProc.kill(); - const stdout = await ffProcHandler; - assert.ok(stdout.includes(`Detected ${missingFileName} as OK.`)); + + try { + const stdout = await ffProcHandler; + assert.ok(stdout.includes(`Detected ${missingFileName} as OK.`)); + } catch(error) { + assert.fail(error); + } }); });