Skip to content
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

feat: optimisticLock option for getTransaction method #2028

Merged
merged 25 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
fcfe1ab
feat: add option for optimistic lock in getTransaction method
alkatrivedi Apr 4, 2024
b901522
feat: add option for optimistic lock in getTransaction method
alkatrivedi Apr 4, 2024
c8d7f40
add sample for read and write transaction
alkatrivedi Apr 5, 2024
b201049
add sample for read and write transaction
alkatrivedi Apr 5, 2024
5a638d7
chore: add integration test for the read/write query samples
alkatrivedi Apr 5, 2024
773ba9a
Merge branch 'googleapis:main' into get-transaction-method
alkatrivedi Apr 5, 2024
aeb1129
fix: presubmit error
alkatrivedi Apr 5, 2024
943bab4
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Apr 5, 2024
9038541
fix: presubmit error
alkatrivedi Apr 5, 2024
3b00ce1
refactor: sample doc
alkatrivedi Apr 5, 2024
aaa3575
refactor: sample doc
alkatrivedi Apr 5, 2024
ee47fe4
refator: getTransaction method
alkatrivedi Apr 10, 2024
c7fedbc
fix: lint errors
alkatrivedi Apr 10, 2024
37e9bb8
fix: lint errors
alkatrivedi Apr 10, 2024
fcabb63
refactor: remove logs
alkatrivedi Apr 15, 2024
b84750a
fix: presubmit error
alkatrivedi Apr 15, 2024
b856166
fix: lint errors
alkatrivedi Apr 15, 2024
e937ba8
test: add a unit test for getTransaction
alkatrivedi Apr 15, 2024
a063abd
tests: add integration and unit test for getTransaction options prope…
alkatrivedi Apr 16, 2024
3c46110
fix: lint errors
alkatrivedi Apr 16, 2024
c45ce29
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Apr 16, 2024
415057c
refactor: naming convention for varaible in getTransaction method
alkatrivedi Apr 16, 2024
ab6112f
refactor: naming convention for varaible in getTransaction method
alkatrivedi Apr 16, 2024
d12157a
fix: lint errors
alkatrivedi Apr 16, 2024
e8c5bce
fix: lint error
alkatrivedi Apr 16, 2024
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
Prev Previous commit
Next Next commit
test: add a unit test for getTransaction
  • Loading branch information
alkatrivedi committed Apr 15, 2024
commit e937ba85fa6f877d3feda21461805bd8ffe91000
79 changes: 0 additions & 79 deletions samples/insert-query-with-get-trasanction.js

This file was deleted.

69 changes: 0 additions & 69 deletions samples/read-query-with-get-transaction.js

This file was deleted.

19 changes: 0 additions & 19 deletions samples/system-test/spanner.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -825,25 +825,6 @@ describe('Autogenerated Admin Clients', () => {
);
});

// dml_standard_insert_transaction_using_getTransaction
it('should insert rows into an example table using getTransaction method', async () => {
const output = execSync(
`node insert-query-with-get-trasanction.js ${INSTANCE_ID} ${DATABASE_ID} ${PROJECT_ID}`
);
assert.match(
output,
/Successfully inserted 4 records into the Singers table/
);
});

// dml_standard_read_transaction_using_getTransaction
it('should query rows from an example table using getTransaction method', async () => {
const output = execSync(
`node read-query-with-get-transaction.js ${INSTANCE_ID} ${DATABASE_ID} ${PROJECT_ID}`
);
assert.strictEqual(output.length, 4);
});

// dml_standard_insert
it('should insert rows into an example table using a DML statement', async () => {
const output = execSync(
Expand Down
16 changes: 16 additions & 0 deletions test/spanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3286,6 +3286,22 @@
});
});

it('should use optimistic lock for getTransaction', async () => {
const database = newTestDatabase();
const promise = await database.getTransaction({optimisticLock: true});
const transaction = promise[0];
await transaction.run('SELECT 1').then(results => {

Check warning on line 3293 in test/spanner.ts

View workflow job for this annotation

GitHub Actions / lint

'results' is defined but never used
const request = spannerMock.getRequests().find(val => {
return (val as v1.ExecuteSqlRequest).sql;
}) as v1.ExecuteSqlRequest;
assert.ok(request, 'no ExecuteSqlRequest found');
assert.strictEqual(
request.transaction!.begin!.readWrite!.readLockMode,
'OPTIMISTIC'
);
});
});

it('should reuse a session for optimistic and pessimistic locks', async () => {
const database = newTestDatabase({min: 1, max: 1});
let session1;
Expand Down
Loading