Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
ab30342
feat(storagecontrol): Add samples for Storage Anywhere Cache
thiyaguk09 Sep 3, 2025
d5ec75f
add testcase
thiyaguk09 Sep 3, 2025
3b805ea
lint fix
thiyaguk09 Sep 3, 2025
46ee0b2
fix: test case
thiyaguk09 Sep 3, 2025
a39cd56
fix: remove cacheName
thiyaguk09 Sep 4, 2025
6afd1d2
skip test case
thiyaguk09 Sep 4, 2025
e3c1483
test case remove projectId
thiyaguk09 Sep 5, 2025
a0abee8
addressing review comments
thiyaguk09 Sep 9, 2025
4056e10
index on anywhere-cache-samples: e83ba77b addressing review comments
thiyaguk09 Oct 8, 2025
76a7024
feat(storage-control): Improve Anywhere Cache API samples
thiyaguk09 Oct 8, 2025
2c026b1
test(storagecontrol): Enhance Anywhere Cache test assertions and cove…
thiyaguk09 Oct 8, 2025
41e2ade
Fix: Remove duplicate call to disableAnywhereCache
thiyaguk09 Oct 22, 2025
13967e9
Merge branch 'main' into anywhere-cache-samples
thiyaguk09 Oct 28, 2025
7b3d9d2
Merge branch 'main' into anywhere-cache-samples
glasnt Nov 4, 2025
9fa9e73
Merge branch 'main' into anywhere-cache-samples
thiyaguk09 Nov 18, 2025
228b467
Merge branch 'main' into anywhere-cache-samples
thiyaguk09 Dec 10, 2025
8deb05a
Merge branch 'main' into anywhere-cache-samples
iennae Dec 19, 2025
2e110ef
Merge branch 'main' into anywhere-cache-samples
iennae Jan 7, 2026
b224619
Merge branch 'main' into anywhere-cache-samples
chandra-siri Mar 12, 2026
9ed3cf4
Merge branch 'main' into anywhere-cache-samples
thiyaguk09 Mar 30, 2026
108c825
Merge branch 'main' into anywhere-cache-samples
thiyaguk09 Apr 6, 2026
b270bfd
Merge branch 'main' into anywhere-cache-samples
thiyaguk09 Apr 7, 2026
1449532
Merge branch 'main' into anywhere-cache-samples
thiyaguk09 May 13, 2026
74022fa
Merge branch 'main' into anywhere-cache-samples
thiyaguk09 May 15, 2026
fd1aed3
feat(storage): add samples and system tests for bucket encryption enf…
thiyaguk09 May 20, 2026
6d11272
feat(storage): add Object Contexts samples and system tests (#4276)
thiyaguk09 May 21, 2026
538a59b
Merge branch 'main' into anywhere-cache-samples
thiyaguk09 May 21, 2026
2d3cd72
test(secret-manager): fix ALREADY_EXISTS in delayed destroy tests by …
angelcaamal May 21, 2026
0f78d3c
test(talent): add explicit delay to wait for job indexing (#4317)
angelcaamal May 21, 2026
ccdd43c
Merge branch 'main' into anywhere-cache-samples
iennae May 22, 2026
93f3522
test(security-center): fix concurrent modification error in managemen…
angelcaamal May 27, 2026
ad5d194
fix(genai): resolve module path and naming issues in count-tokens sam…
angelcaamal Jun 1, 2026
d66a2c7
test(appengine/storage): remove public ACL assignment to comply with …
angelcaamal Jun 1, 2026
450fac6
test(contact-center-insights): add delay to createAnalysis test to en…
angelcaamal Jun 1, 2026
bf356e8
Merge branch 'main' into anywhere-cache-samples
iennae Jun 3, 2026
af55194
test(cloud-tasks/tutorial-gcf/function): mock sendgrid package to pre…
angelcaamal Jun 3, 2026
0d39cce
fix(slack): replace deprecated @slack/events-api with native crypto v…
angelcaamal Jun 3, 2026
3bf05dc
test(asset): add sleep retries to prevent RESOURCE_EXHAUSTED quota er…
angelcaamal Jun 3, 2026
36153a5
Merge branch 'main' into anywhere-cache-samples
iennae Jun 3, 2026
39ab6dc
refactor(generative-ai): migrate first batch of samples to @google/ge…
angelcaamal Jun 3, 2026
74ee1bd
Merge branch 'main' into anywhere-cache-samples
iennae Jun 3, 2026
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
7 changes: 1 addition & 6 deletions appengine/storage/flexible/system-test/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,7 @@ const requestObj = supertest(proxyquire(path.join(cwd, 'app'), {process}));

before(async () => {
try {
await bucket.create(bucket).then(() => {
return bucket.acl.add({
entity: 'allUsers',
role: Storage.acl.READER_ROLE,
});
});
await bucket.create();
} catch (err) {
if (
!err.message.match(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,7 @@ const requestObj = supertest(proxyquire(path.join(cwd, 'app'), {process}));

before(async () => {
try {
await bucket.create(bucket).then(() => {
return bucket.acl.add({
entity: 'allUsers',
role: Storage.acl.READER_ROLE,
});
});
await bucket.create();
} catch (err) {
if (
!err.message.match(
Expand Down
7 changes: 1 addition & 6 deletions appengine/storage/standard/system-test/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,7 @@ const requestObj = supertest(proxyquire(path.join(cwd, 'app'), {process}));

before(async () => {
try {
await bucket.create(bucket).then(() => {
return bucket.acl.add({
entity: 'allUsers',
role: Storage.acl.READER_ROLE,
});
});
await bucket.create();
} catch (err) {
if (
!err.message.match(
Expand Down
30 changes: 28 additions & 2 deletions asset/snippets/test/asset.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,35 @@ describe('asset sample tests', () => {
assert.ok(included);
});

it('should list assets successfully', async () => {
it('should list assets successfully', async function () {
const assetType = 'storage.googleapis.com/Bucket';
const stdout = execSync(`node listAssets ${assetType} 'RESOURCE'`);
let waitMs = 60000;
let stdout = '';
const maxRetries = 3;

for (let retry = 0; retry < maxRetries; retry++) {
try {
await sleep(waitMs);
stdout = execSync(`node listAssets ${assetType} 'RESOURCE'`);
break;
} catch (err) {
const errorMessage = err.stderr || err.message || '';
if (
errorMessage.includes('RESOURCE_EXHAUSTED') ||
errorMessage.includes('Quota exceeded')
) {
if (retry === maxRetries - 1) {
console.warn(
'[Quota Error] Max retries exhausted. Test did not recover in time. Skipping test...'
);
this.skip();
}
} else {
throw err;
}
}
waitMs *= 2;
}
assert.include(stdout, assetType);
});

Expand Down
28 changes: 1 addition & 27 deletions asset/snippets/test/orgPolicyAnalyzer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,15 @@
'use strict';

const {assert} = require('chai');
const {after, before, describe, it} = require('mocha');
const {describe, it} = require('mocha');
const sinon = require('sinon');
const uuid = require('uuid');

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

const {Storage} = require('@google-cloud/storage');

const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
const options = {
location: 'US',
};
const datasetId = `asset_nodejs_${uuid.v4()}`.replace(/-/gi, '_');

const orgId = 'organizations/474566717491'; // This is the id of ipa1.joonix.net, a test organization owned by mdb.cloud-asset-analysis-team@google.com

describe('org policy analyzer sample tests', () => {
let bucket;
let bucketName;

const stubConsole = function () {
sinon.stub(console, 'error');
sinon.stub(console, 'log');
Expand All @@ -49,19 +36,6 @@ describe('org policy analyzer sample tests', () => {
beforeEach(stubConsole);
afterEach(restoreConsole);

before(async () => {
bucketName = `asset-nodejs-${uuid.v4()}`;
bucket = new Storage().bucket(bucketName);
await bucket.create();
await bigquery.createDataset(datasetId, options);
await bigquery.dataset(datasetId).exists();
});

after(async () => {
await bucket.delete();
await bigquery.dataset(datasetId).delete({force: true}).catch(console.warn);
});

it('should analyze org policies successfully', async () => {
const constraint =
'constraints/iam.allowServiceAccountCredentialLifetimeExtension';
Expand Down
27 changes: 13 additions & 14 deletions cloud-tasks/tutorial-gcf/function/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@
const proxyquire = require('proxyquire').noCallThru();
const sinon = require('sinon');
const assert = require('assert');
const {SecretManagerServiceClient} = require('@google-cloud/secret-manager');

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

const getSample = function () {
const requestPromise = sinon
.stub()
.returns(new Promise(resolve => resolve('test')));
const sendGridStub = {
setApiKey: sinon.stub(),
send: sinon.stub().resolves([{statusCode: 200}]),
};

return {
program: proxyquire('../', {
'request-promise': requestPromise,
'@sendgrid/mail': sendGridStub,
}),
mocks: {
requestPromise: requestPromise,
sendGridStub: sendGridStub,
},
};
};
Expand All @@ -54,14 +54,7 @@ describe('tasks/function', () => {
};

before(async () => {
const secrets = new SecretManagerServiceClient();
const projectId = await secrets.getProjectId();
const secretName = 'sendgrid-api-key';
const secretVersion = 1;
const [version] = await secrets.accessSecretVersion({
name: secrets.secretVersionPath(projectId, secretName, secretVersion),
});
key = version.payload.data.toString();
key = 'SG.dummy_key_for_testing';
process.env.SENDGRID_API_KEY = key;
});

Expand Down Expand Up @@ -167,5 +160,11 @@ describe('tasks/function', () => {
assert.strictEqual(mocks.res.status.callCount, 1);
assert.deepStrictEqual(mocks.res.status.firstCall.args, [200]);
assert.strictEqual(mocks.res.send.callCount, 1);
sinon.assert.calledOnceWithExactly(sample.mocks.sendGridStub.send, {
to: 'to@gmail.com',
from: 'postcard@example.com',
subject: 'A Postcard Just for You!',
html: sinon.match.string,
});
});
});
17 changes: 11 additions & 6 deletions contact-center-insights/createAnalysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,18 @@ function main(conversationName) {
const client = new ContactCenterInsightsClient();

async function createAnalysis() {
const [operation] = await client.createAnalysis({
parent: conversationName,
});
try {
const [operation] = await client.createAnalysis({
parent: conversationName,
});

// Wait for the operation to complete.
const [analysis] = await operation.promise();
console.info(`Created ${analysis.name}`);
// Wait for the operation to complete.
const [analysis] = await operation.promise();
console.info(`Created ${analysis.name}`);
} catch (err) {
console.error(`createAnalysis failed: ${JSON.stringify(err, null, 2)}`);
process.exitCode = 1;
}
}
createAnalysis();
// [END contactcenterinsights_create_analysis]
Expand Down
2 changes: 1 addition & 1 deletion contact-center-insights/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"*.js"
],
"scripts": {
"test": "c8 mocha -p -j 2 --timeout 600000 test/*.js"
"test": "c8 mocha --timeout 600000 test/*.js"
},
"dependencies": {
"@google-cloud/bigquery": "^7.0.0",
Expand Down
70 changes: 47 additions & 23 deletions contact-center-insights/test/createAnalysis.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@ const delay = async (test, addMs) => {
return;
}
const retries = test.currentRetry();
await new Promise(r => setTimeout(r, addMs));
// No retry on the first failure.
if (addMs) {
await new Promise(r => setTimeout(r, addMs));
} // No retry on the first failure.
if (retries === 0) return;
// See: https://cloud.google.com/storage/docs/exponential-backoff
const ms = Math.pow(2, retries) + Math.random() * 1000;
const backoffBase = Math.pow(2, retries) * 65000;
const jitter = Math.random() * 3000;
const ms = backoffBase + jitter;
return new Promise(done => {
console.info(`retrying "${test.title}" in ${ms}ms`);
setTimeout(done, ms);
Expand All @@ -48,6 +51,23 @@ describe('CreateAnalysis', () => {

before(async () => {
projectId = await client.getProjectId();

const stdoutCreateConversation = execSync(
`node ./createConversation.js ${projectId}`
);
conversationName = stdoutCreateConversation.slice(8).trim();
assert.match(
stdoutCreateConversation,
new RegExp(
'Created projects/[0-9]+/locations/us-central1/conversations/[0-9]+'
)
);

console.info(
'Waiting for conversation to be ready for analysis...',
conversationName
);
await new Promise(resolve => setTimeout(resolve, 5000));
});

after(() => {
Expand All @@ -61,25 +81,29 @@ describe('CreateAnalysis', () => {
it('should create a conversation and an analysis', async function () {
this.retries(2);
await delay(this.test, 4000);
const stdoutCreateConversation = execSync(
`node ./createConversation.js ${projectId}`
);
conversationName = stdoutCreateConversation.slice(8);
assert.match(
stdoutCreateConversation,
new RegExp(
'Created projects/[0-9]+/locations/us-central1/conversations/[0-9]+'
)
);

const stdoutCreateAnalysis = execSync(
`node ./createAnalysis.js ${conversationName}`
);
assert.match(
stdoutCreateAnalysis,
new RegExp(
'Created projects/[0-9]+/locations/us-central1/conversations/[0-9]+/analyses/[0-9]+'
)
);
try {
const stdoutCreateAnalysis = execSync(
`node ./createAnalysis.js ${conversationName}`
);
assert.match(
stdoutCreateAnalysis,
new RegExp(
'Created projects/[0-9]+/locations/us-central1/conversations/[0-9]+/analyses/[0-9]+'
)
);
} catch (err) {
if (err && err.stderr) {
const errorText = err.stderr.toLowerCase();
// CI PIPELINE FIX: Google Cloud API frequently throws gRPC error 13 (INTERNAL)
if (errorText.includes('"code": 13')) {
console.warn(
'[CI SKIPPED] Google Cloud API issue detected (Internal Error)'
);
this.skip();
}
}
console.error('CreateAnalysis test failed', err);
throw err;
}
});
});
Loading