Skip to content

Commit c9ecf3d

Browse files
authored
Merge branch 'main' into transferManager-storage-migration
2 parents b8a8231 + efc8d2f commit c9ecf3d

154 files changed

Lines changed: 3483 additions & 1125 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

appengine/storage/flexible/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"dependencies": {
1212
"@google-cloud/storage": "^7.0.0",
1313
"express": "^4.18.2",
14-
"multer": "^1.4.5-lts.1",
14+
"multer": "^2.1.1",
1515
"pug": "^3.0.2"
1616
},
1717
"devDependencies": {

appengine/storage/flexible/system-test/app.test.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,7 @@ const requestObj = supertest(proxyquire(path.join(cwd, 'app'), {process}));
3232

3333
before(async () => {
3434
try {
35-
await bucket.create(bucket).then(() => {
36-
return bucket.acl.add({
37-
entity: 'allUsers',
38-
role: Storage.acl.READER_ROLE,
39-
});
40-
});
35+
await bucket.create();
4136
} catch (err) {
4237
if (
4338
!err.message.match(

appengine/storage/flexible_nodejs16_and_earlier/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"dependencies": {
1212
"@google-cloud/storage": "^7.0.0",
1313
"express": "^4.18.2",
14-
"multer": "^1.4.5-lts.1",
14+
"multer": "^2.1.1",
1515
"pug": "^3.0.2"
1616
},
1717
"devDependencies": {

appengine/storage/flexible_nodejs16_and_earlier/system-test/app.test.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,7 @@ const requestObj = supertest(proxyquire(path.join(cwd, 'app'), {process}));
3232

3333
before(async () => {
3434
try {
35-
await bucket.create(bucket).then(() => {
36-
return bucket.acl.add({
37-
entity: 'allUsers',
38-
role: Storage.acl.READER_ROLE,
39-
});
40-
});
35+
await bucket.create();
4136
} catch (err) {
4237
if (
4338
!err.message.match(

appengine/storage/standard/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"dependencies": {
1212
"@google-cloud/storage": "^7.0.0",
1313
"express": "^4.18.2",
14-
"multer": "^1.4.5-lts.1",
14+
"multer": "^2.1.1",
1515
"pug": "^3.0.2"
1616
},
1717
"devDependencies": {

appengine/storage/standard/system-test/app.test.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,7 @@ const requestObj = supertest(proxyquire(path.join(cwd, 'app'), {process}));
3232

3333
before(async () => {
3434
try {
35-
await bucket.create(bucket).then(() => {
36-
return bucket.acl.add({
37-
entity: 'allUsers',
38-
role: Storage.acl.READER_ROLE,
39-
});
40-
});
35+
await bucket.create();
4136
} catch (err) {
4237
if (
4338
!err.message.match(

asset/snippets/test/asset.test.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,35 @@ describe('asset sample tests', () => {
104104
assert.ok(included);
105105
});
106106

107-
it('should list assets successfully', async () => {
107+
it('should list assets successfully', async function () {
108108
const assetType = 'storage.googleapis.com/Bucket';
109-
const stdout = execSync(`node listAssets ${assetType} 'RESOURCE'`);
109+
let waitMs = 60000;
110+
let stdout = '';
111+
const maxRetries = 3;
112+
113+
for (let retry = 0; retry < maxRetries; retry++) {
114+
try {
115+
await sleep(waitMs);
116+
stdout = execSync(`node listAssets ${assetType} 'RESOURCE'`);
117+
break;
118+
} catch (err) {
119+
const errorMessage = err.stderr || err.message || '';
120+
if (
121+
errorMessage.includes('RESOURCE_EXHAUSTED') ||
122+
errorMessage.includes('Quota exceeded')
123+
) {
124+
if (retry === maxRetries - 1) {
125+
console.warn(
126+
'[Quota Error] Max retries exhausted. Test did not recover in time. Skipping test...'
127+
);
128+
this.skip();
129+
}
130+
} else {
131+
throw err;
132+
}
133+
}
134+
waitMs *= 2;
135+
}
110136
assert.include(stdout, assetType);
111137
});
112138

asset/snippets/test/orgPolicyAnalyzer.test.js

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,15 @@
1515
'use strict';
1616

1717
const {assert} = require('chai');
18-
const {after, before, describe, it} = require('mocha');
18+
const {describe, it} = require('mocha');
1919
const sinon = require('sinon');
20-
const uuid = require('uuid');
2120

2221
const cp = require('child_process');
2322
const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});
2423

25-
const {Storage} = require('@google-cloud/storage');
26-
27-
const {BigQuery} = require('@google-cloud/bigquery');
28-
const bigquery = new BigQuery();
29-
const options = {
30-
location: 'US',
31-
};
32-
const datasetId = `asset_nodejs_${uuid.v4()}`.replace(/-/gi, '_');
33-
3424
const orgId = 'organizations/474566717491'; // This is the id of ipa1.joonix.net, a test organization owned by mdb.cloud-asset-analysis-team@google.com
3525

3626
describe('org policy analyzer sample tests', () => {
37-
let bucket;
38-
let bucketName;
39-
4027
const stubConsole = function () {
4128
sinon.stub(console, 'error');
4229
sinon.stub(console, 'log');
@@ -49,19 +36,6 @@ describe('org policy analyzer sample tests', () => {
4936
beforeEach(stubConsole);
5037
afterEach(restoreConsole);
5138

52-
before(async () => {
53-
bucketName = `asset-nodejs-${uuid.v4()}`;
54-
bucket = new Storage().bucket(bucketName);
55-
await bucket.create();
56-
await bigquery.createDataset(datasetId, options);
57-
await bigquery.dataset(datasetId).exists();
58-
});
59-
60-
after(async () => {
61-
await bucket.delete();
62-
await bigquery.dataset(datasetId).delete({force: true}).catch(console.warn);
63-
});
64-
6539
it('should analyze org policies successfully', async () => {
6640
const constraint =
6741
'constraints/iam.allowServiceAccountCredentialLifetimeExtension';

cloud-tasks/tutorial-gcf/function/test/index.test.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,22 @@
1717
const proxyquire = require('proxyquire').noCallThru();
1818
const sinon = require('sinon');
1919
const assert = require('assert');
20-
const {SecretManagerServiceClient} = require('@google-cloud/secret-manager');
2120

2221
describe('tasks/function', () => {
2322
let key;
2423

2524
const getSample = function () {
26-
const requestPromise = sinon
27-
.stub()
28-
.returns(new Promise(resolve => resolve('test')));
25+
const sendGridStub = {
26+
setApiKey: sinon.stub(),
27+
send: sinon.stub().resolves([{statusCode: 200}]),
28+
};
2929

3030
return {
3131
program: proxyquire('../', {
32-
'request-promise': requestPromise,
32+
'@sendgrid/mail': sendGridStub,
3333
}),
3434
mocks: {
35-
requestPromise: requestPromise,
35+
sendGridStub: sendGridStub,
3636
},
3737
};
3838
};
@@ -54,14 +54,7 @@ describe('tasks/function', () => {
5454
};
5555

5656
before(async () => {
57-
const secrets = new SecretManagerServiceClient();
58-
const projectId = await secrets.getProjectId();
59-
const secretName = 'sendgrid-api-key';
60-
const secretVersion = 1;
61-
const [version] = await secrets.accessSecretVersion({
62-
name: secrets.secretVersionPath(projectId, secretName, secretVersion),
63-
});
64-
key = version.payload.data.toString();
57+
key = 'SG.dummy_key_for_testing';
6558
process.env.SENDGRID_API_KEY = key;
6659
});
6760

@@ -167,5 +160,11 @@ describe('tasks/function', () => {
167160
assert.strictEqual(mocks.res.status.callCount, 1);
168161
assert.deepStrictEqual(mocks.res.status.firstCall.args, [200]);
169162
assert.strictEqual(mocks.res.send.callCount, 1);
163+
sinon.assert.calledOnceWithExactly(sample.mocks.sendGridStub.send, {
164+
to: 'to@gmail.com',
165+
from: 'postcard@example.com',
166+
subject: 'A Postcard Just for You!',
167+
html: sinon.match.string,
168+
});
170169
});
171170
});

contact-center-insights/createAnalysis.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,18 @@ function main(conversationName) {
3131
const client = new ContactCenterInsightsClient();
3232

3333
async function createAnalysis() {
34-
const [operation] = await client.createAnalysis({
35-
parent: conversationName,
36-
});
34+
try {
35+
const [operation] = await client.createAnalysis({
36+
parent: conversationName,
37+
});
3738

38-
// Wait for the operation to complete.
39-
const [analysis] = await operation.promise();
40-
console.info(`Created ${analysis.name}`);
39+
// Wait for the operation to complete.
40+
const [analysis] = await operation.promise();
41+
console.info(`Created ${analysis.name}`);
42+
} catch (err) {
43+
console.error(`createAnalysis failed: ${JSON.stringify(err, null, 2)}`);
44+
process.exitCode = 1;
45+
}
4146
}
4247
createAnalysis();
4348
// [END contactcenterinsights_create_analysis]

0 commit comments

Comments
 (0)