-
Notifications
You must be signed in to change notification settings - Fork 5
tests: robust external api handling #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -77,13 +77,18 @@ describe('AICore MTX resource group lifecycle', { concurrency: false, timeout: 3 | |||||
| for (let i = 0; i < 30; i++) { | ||||||
| await new Promise((r) => setTimeout(r, 2000)); // eslint-disable-line no-await-in-loop | ||||||
| cds.context = new cds.EventContext({ tenant: testTenantId }); | ||||||
| // eslint-disable-next-line no-await-in-loop | ||||||
| const groups = await aiCore.run( | ||||||
| SELECT.from('AICore.resourceGroups').where({ tenantId: testTenantId }) | ||||||
| ); | ||||||
| if (Array.isArray(groups) && groups[0]?.status === 'PROVISIONED') { | ||||||
| provisioned = true; | ||||||
| break; | ||||||
| try { | ||||||
| // eslint-disable-next-line no-await-in-loop | ||||||
| const groups = await aiCore.run( | ||||||
| SELECT.from('AICore.resourceGroups').where({ tenantId: testTenantId }) | ||||||
| ); | ||||||
| if (Array.isArray(groups) && groups[0]?.status === 'PROVISIONED') { | ||||||
| provisioned = true; | ||||||
| break; | ||||||
| } | ||||||
| } catch (e) { | ||||||
| // Transient network error — continue polling | ||||||
| console.warn(`Provisioning poll attempt ${i + 1} failed: ${e.message}`); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Logic Error: The first The two polling loops added in this PR are now wrapped in Please provide feedback on the review comment by checking the appropriate box:
|
||||||
| } | ||||||
| } | ||||||
| assert.ok(provisioned, 'Resource group should reach PROVISIONED before unsubscribe'); | ||||||
|
|
@@ -96,13 +101,18 @@ describe('AICore MTX resource group lifecycle', { concurrency: false, timeout: 3 | |||||
| for (let i = 0; i < 36; i++) { | ||||||
| await new Promise((r) => setTimeout(r, 5000)); // eslint-disable-line no-await-in-loop | ||||||
| cds.context = new cds.EventContext({ tenant: testTenantId }); | ||||||
| // eslint-disable-next-line no-await-in-loop | ||||||
| const groups = await aiCore.run( | ||||||
| SELECT.from('AICore.resourceGroups').where({ tenantId: testTenantId }) | ||||||
| ); | ||||||
| if (!Array.isArray(groups) || groups.length === 0) { | ||||||
| deleted = true; | ||||||
| break; | ||||||
| try { | ||||||
| // eslint-disable-next-line no-await-in-loop | ||||||
| const groups = await aiCore.run( | ||||||
| SELECT.from('AICore.resourceGroups').where({ tenantId: testTenantId }) | ||||||
| ); | ||||||
| if (!Array.isArray(groups) || groups.length === 0) { | ||||||
| deleted = true; | ||||||
| break; | ||||||
| } | ||||||
| } catch (e) { | ||||||
| // Transient network error — continue polling | ||||||
| console.warn(`Deletion poll attempt ${i + 1} failed: ${e.message}`); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Same issue as in the provisioning loop above: if the rejection value is a plain string or object, Consider using
Suggested change
Double-check suggestion before committing. Edit this comment for amendments. Please provide feedback on the review comment by checking the appropriate box:
|
||||||
| } | ||||||
| } | ||||||
| assert.strictEqual( | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug:
e.messagemay beundefinedif the caught error is not anErrorinstanceIf
aiCore.run(...)rejects with a non-Errorvalue (e.g., a plain string or an object),e.messagewill beundefined, producing a misleading log line like"Provisioning poll attempt 1 failed: undefined".Consider using
String(e)ore?.message ?? eto safely stringify any rejection value.Double-check suggestion before committing. Edit this comment for amendments.
Please provide feedback on the review comment by checking the appropriate box: