Repository navigation
[coverage] Conformance findings: STATEMENT-022 (#472) #564
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
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5412c71
[coverage] Conformance findings: STATEMENT-022 (#472)
8d08c89
ai: apply changes for #564 (2 review threads)
peco-engineer-bot[bot] 4445dae
ai: apply changes for #564 (1 review thread)
peco-engineer-bot[bot] 853523b
ai: apply changes for #564 (2 review threads)
peco-engineer-bot[bot] 50c97bf
ai: apply changes for #564 (2 review threads)
peco-engineer-bot[bot] 695cda2
ai: apply changes for #564 (1 review thread)
peco-engineer-bot[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import { AssertionError, expect } from 'chai'; | ||
| import sinon from 'sinon'; | ||
| import { DBSQLClient } from '../../lib'; | ||
| import Status from '../../lib/dto/Status'; | ||
| import OperationStateError, { OperationStateErrorCode } from '../../lib/errors/OperationStateError'; | ||
|
|
||
| import config from './utils/config'; | ||
|
|
||
| // STATEMENT-022: concurrent Operation.cancel() calls must not deadlock or crash, | ||
| // and on Thrift must be deduplicated into exactly one CancelOperation RPC | ||
| // (parity with databricks-sql-go#419 and the shared driver conformance spec). | ||
| describe('Concurrent cancel (STATEMENT-022)', function () { | ||
| this.timeout(120 * 1000); | ||
|
|
||
| it('three simultaneous cancel() calls: no deadlock, single CancelOperation [thrift]', async () => { | ||
| const client = new DBSQLClient(); | ||
| const connection = await client.connect({ | ||
| host: config.host, | ||
| path: config.path, | ||
| token: config.token, | ||
| }); | ||
| const session = await connection.openSession({ | ||
| initialCatalog: config.catalog, | ||
| initialSchema: config.schema, | ||
| }); | ||
|
|
||
| // @ts-expect-error TS2339: Property context does not exist on type IDBSQLSession | ||
| const cancelSpy = sinon.spy(session.context.driver, 'cancelOperation'); | ||
|
|
||
| try { | ||
| const operation = await session.executeStatement( | ||
| 'SELECT a.*, b.* FROM range(0, 100000) a CROSS JOIN range(0, 100000) b ORDER BY a.id DESC, b.id DESC', | ||
| { runAsync: true, maxRows: null }, | ||
| ); | ||
|
|
||
| const results = await Promise.all([operation.cancel(), operation.cancel(), operation.cancel()]); | ||
| results.forEach((status) => { | ||
| expect(status).to.be.instanceOf(Status); | ||
| expect(status.isSuccess).to.be.true; | ||
| }); | ||
|
|
||
| expect(cancelSpy.callCount).to.equal(1); | ||
|
|
||
| try { | ||
| await operation.fetchChunk({ disableBuffering: true }); | ||
| expect.fail('fetchChunk should be rejected after cancel'); | ||
| } catch (error) { | ||
|
peco-review-bot[bot] marked this conversation as resolved.
Resolved
|
||
| if (error instanceof AssertionError) { | ||
| throw error; | ||
| } | ||
| expect(error).to.be.instanceOf(OperationStateError); | ||
| expect((error as OperationStateError).errorCode).to.equal(OperationStateErrorCode.Canceled); | ||
| } | ||
| } finally { | ||
| cancelSpy.restore(); | ||
| await session.close(); | ||
| await client.close(); | ||
| } | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.