Skip to content

Commit d85da78

Browse files
vijaykanthmiennae
authored andcommitted
refactor notifications test to fix quota limit issue
1 parent d982aa4 commit d85da78

File tree

1 file changed

+29
-15
lines changed

1 file changed

+29
-15
lines changed

security-center/snippets/system-test/v1/notifications.test.js

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,37 +36,51 @@ describe('Client with Notifications', async () => {
3636
before(async () => {
3737
const client = new SecurityCenterClient();
3838
async function createNotificationConfig(configId) {
39-
/*eslint no-unused-vars: ["error", { "varsIgnorePattern": "^_" }]*/
40-
const [_response] = await client.createNotificationConfig({
41-
parent: orgName,
42-
configId: configId,
43-
notificationConfig: {
44-
description: 'Sample config for node.js',
45-
pubsubTopic: pubsubTopic,
46-
streamingConfig: {filter: 'state = "ACTIVE"'},
47-
},
48-
});
39+
try {
40+
/*eslint no-unused-vars: ["error", { "varsIgnorePattern": "^_" }]*/
41+
const [_response] = await client.createNotificationConfig({
42+
parent: orgName,
43+
configId: configId,
44+
notificationConfig: {
45+
description: 'Sample config for node.js',
46+
pubsubTopic: pubsubTopic,
47+
streamingConfig: {filter: 'state = "ACTIVE"'},
48+
},
49+
});
50+
} catch (err) {
51+
console.error(`Error creating config ${configId}:`, err.message);
52+
}
4953
}
5054

5155
await createNotificationConfig(deleteConfig);
56+
await new Promise(resolve => setTimeout(resolve, 1000)); // 1-second delay
5257
await createNotificationConfig(getConfig);
58+
await new Promise(resolve => setTimeout(resolve, 1000)); // 1-second delay
5359
await createNotificationConfig(listConfig);
60+
await new Promise(resolve => setTimeout(resolve, 1000)); // 1-second delay
5461
await createNotificationConfig(updateConfig);
5562
});
5663

5764
after(async () => {
5865
const client = new SecurityCenterClient();
5966
async function deleteNotificationConfig(configId) {
60-
const name = client.organizationNotificationConfigPath(
61-
organizationId,
62-
configId
63-
);
64-
await client.deleteNotificationConfig({name: name});
67+
try {
68+
const name = client.organizationNotificationConfigPath(
69+
organizationId,
70+
configId
71+
);
72+
await client.deleteNotificationConfig({name: name});
73+
} catch (err) {
74+
console.error(`Error deleting config ${configId}:`, err.message);
75+
}
6576
}
6677

6778
await deleteNotificationConfig(createConfig);
79+
await new Promise(resolve => setTimeout(resolve, 1000)); // 1-second delay
6880
await deleteNotificationConfig(getConfig);
81+
await new Promise(resolve => setTimeout(resolve, 1000)); // 1-second delay
6982
await deleteNotificationConfig(listConfig);
83+
await new Promise(resolve => setTimeout(resolve, 1000)); // 1-second delay
7084
await deleteNotificationConfig(updateConfig);
7185
});
7286

0 commit comments

Comments
 (0)