Skip to content
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
2 changes: 2 additions & 0 deletions .github/config/nodejs-dev.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
"functions/http/httpContent",
"functions/http/httpMethods",
"functions/http/parseXML",
"functions/imagemagick",
"functions/log/helloWorld",
"functions/log/processEntry",
"functions/memorystore/redis",
Expand Down Expand Up @@ -173,6 +174,7 @@
"functions/v2/helloGCS",
"functions/v2/helloPubSub",
"functions/v2/httpLogging",
"functions/v2/imagemagick",
"functions/v2/log/processEntry",
"functions/v2/ocr/app",
"functions/v2/responseStreaming",
Expand Down
2 changes: 0 additions & 2 deletions .github/config/nodejs-prod.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@
"dlp", // [ERR_REQUIRE_ESM]: require() of ES Module
"document-ai", // [ERR_REQUIRE_ESM]: require() of ES Module
"functions/billing", // (untested) Error: Request failed with status code 500
"functions/imagemagick", // (untested) Error: A bucket name is needed to use Cloud Storage
"functions/slack", // TypeError [ERR_INVALID_ARG_TYPE]: The "key" argument must be of type ... Received undefined
"functions/v2/imagemagick", // (untested) Error: A bucket name is needed to use Cloud Storage.
"healthcare/fhir", // Error: Cannot find module 'whatwg-url'
"iam/deny", // PERMISSION_DENIED: Permission iam.googleapis.com/denypolicies.create denied on resource cloudresourcemanager.googleapis.com/projects/long-door-651
"run/idp-sql", // (untested) Error: Invalid contents in the credentials file
Expand Down
6 changes: 6 additions & 0 deletions functions/imagemagick/ci-setup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"env": {
"FUNCTIONS_BUCKET": "nodejs-docs-samples-tests",
"BLURRED_BUCKET_NAME": "nodejs-docs-samples-tests-imagick"
}
}
2 changes: 1 addition & 1 deletion functions/imagemagick/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"node": ">=12.0.0"
},
"scripts": {
"test": "c8 mocha -p -j 2 test/*.test.js --timeout=20000 --exit"
"test": "c8 mocha -p -j 2 test/*.test.js --timeout=30000 --exit"
},
"dependencies": {
"@google-cloud/storage": "^7.0.0",
Expand Down
19 changes: 16 additions & 3 deletions functions/imagemagick/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
'use strict';

const assert = require('assert');
const {spawn} = require('child_process');
const {execSync, spawn} = require('child_process');
const {Storage} = require('@google-cloud/storage');
const sinon = require('sinon');
const {request} = require('gaxios');
Expand Down Expand Up @@ -47,13 +47,26 @@ async function startFF(port) {
let stderr = '';
ffProc.stdout.on('data', data => (stdout += data));
ffProc.stderr.on('data', data => (stderr += data));
ffProc.on('error', reject);
ffProc.on('exit', c => (c === 0 ? resolve(stdout) : reject(stderr)));
ffProc.on('exit', code => {
if (code === 0 || code === null) {
// code === null corresponds to a signal-kill
// (which doesn't necessarily indicate a test failure)
resolve(stdout);
} else {
stderr = `Error code: ${code}\n${stderr}`;
reject(new Error(stderr));
}
});
});
await waitPort({host: 'localhost', port});
return {ffProc, ffProcHandler};
}

// ImageMagick is available by default in Cloud Run Functions environments
// https://cloud.google.com/functions/1stgendocs/tutorials/imagemagick-1st-gen.md#importing_dependencies
// Manually install it for testing only.
execSync('sudo apt-get install imagemagick -y');

describe('functions/imagemagick tests', () => {
before(async () => {
let exists;
Expand Down
6 changes: 6 additions & 0 deletions functions/v2/imagemagick/ci-setup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"env": {
"FUNCTIONS_BUCKET": "nodejs-docs-samples-tests",
"BLURRED_BUCKET_NAME": "nodejs-docs-samples-tests-imagick"
}
}
6 changes: 6 additions & 0 deletions functions/v2/imagemagick/test/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
'use strict';

const assert = require('assert');
const {execSync} = require('child_process');
const {Storage} = require('@google-cloud/storage');
const sinon = require('sinon');
const supertest = require('supertest');
Expand All @@ -33,6 +34,11 @@ const testFiles = {

require('../index');

// ImageMagick is available by default in Cloud Run Functions environments
// https://cloud.google.com/functions/1stgendocs/tutorials/imagemagick-1st-gen.md#importing_dependencies
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cross-checked that Imagemagick is still included in the system packages for v2+: https://cloud.google.com/functions/docs/reference/system-packages

// Manually install it for testing only.
execSync('sudo apt-get install imagemagick -y');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion(non-blocking): Move this into an additional before hook below and switch to an async exec for a potentially minor performance gain.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

installing this async was causing issues, so I'm making sure the change happens before the before using this method


describe('functions/imagemagick tests', () => {
before(async () => {
let exists;
Expand Down
Loading