-
Notifications
You must be signed in to change notification settings - Fork 719
test: run bun handwritten tests in bun runtime for firestore through pubsub plus spanner-driver #9452
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?
test: run bun handwritten tests in bun runtime for firestore through pubsub plus spanner-driver #9452
Changes from all commits
e952549
27579a0
93ae259
dc9e502
8088cf4
d208619
756cc45
5a29104
e780546
c9446ab
845f8d7
4f67497
6668550
4c4a74d
895f088
486a301
687e386
1f30b9d
da1602a
b6e6db1
3a88414
8dee1fc
7534a50
f064618
90d9b6e
fa014d2
ec5195e
db68151
da9b310
eeb2881
1ba1deb
ef29c38
4f26692
dc86050
33705f6
c3107be
bc4b3a1
57b55c4
9ee0139
a8c6d61
b03058e
fdc7270
5cecab2
2a8a2d8
d8bdff9
53cf89f
8233cbf
55e9e98
5f9de1c
c8c4d71
71bfe1c
a61d3b3
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 |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| #!/usr/bin/env node | ||
|
|
||
| // Copyright 2026 Google LLC | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // https://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| const path = require('path'); | ||
| const fs = require('fs'); | ||
|
|
||
| // Resolve bin/run-test.cjs from the monorepo root | ||
| let current = __dirname; | ||
| let runTestPath; | ||
| while (current !== path.dirname(current)) { | ||
| const candidate = path.join(current, 'bin', 'run-test.cjs'); | ||
| if (fs.existsSync(candidate)) { | ||
| runTestPath = candidate; | ||
| break; | ||
| } | ||
| current = path.dirname(current); | ||
| } | ||
|
|
||
| if (!runTestPath) { | ||
| runTestPath = path.resolve(__dirname, '../../../../bin/run-test.cjs'); | ||
| } | ||
|
|
||
| require(runTestPath); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ import * as logCommon from '../src/utils/log-common'; | |
| import * as stream from 'stream'; | ||
| import * as extend from 'extend'; | ||
| import * as fs from 'fs'; | ||
| import * as instrumentation from '../src/utils/instrumentation'; | ||
|
|
||
| describe('LogSync', () => { | ||
| const PROJECT_ID = 'project-id'; | ||
|
|
@@ -95,14 +96,21 @@ describe('LogSync', () => { | |
| let buffer: stream.Writable; | ||
|
|
||
| beforeEach(() => { | ||
| // Prevent automatic diagnostic instrumentation from writing an extra log | ||
| // entry to the transport stream during tests. | ||
| instrumentation.setInstrumentationStatus(true); | ||
| ENTRY = new Entry(undefined, 'testlog'); | ||
| ENTRIES = [ENTRY] as Entry[]; | ||
| OPTIONS = {} as WriteOptions; | ||
| log = createLogger(); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| fs.rmSync(TEST_FILE, {force: true}); | ||
| try { | ||
| fs.rmSync(TEST_FILE, {force: true}); | ||
| } finally { | ||
| instrumentation.setInstrumentationStatus(false); | ||
| } | ||
| }); | ||
|
Comment on lines
108
to
114
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. If afterEach(() => {
try {
fs.rmSync(TEST_FILE, {force: true});
} finally {
instrumentation.setInstrumentationStatus(false);
}
});
Contributor
Author
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. resolved |
||
|
|
||
| function createLogger() { | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -733,8 +733,12 @@ describe('MessageQueues', () => { | |||||||||||
| .resolves(); | ||||||||||||
|
|
||||||||||||
| modAckQueue.setOptions({callOptions: fakeCallOptions}); | ||||||||||||
| await modAckQueue.add(new FakeMessage() as Message, 10); | ||||||||||||
| await modAckQueue.flush('test'); | ||||||||||||
| // add() returns a promise that only resolves when the batch is flushed. | ||||||||||||
| // We must flush before awaiting completion; awaiting add() directly causes | ||||||||||||
| // a deadlock that timed out under Bun where background fallback timers | ||||||||||||
| // are not scheduled while blocked on unresolved promises. | ||||||||||||
| const completion = modAckQueue.add(new FakeMessage() as Message, 10); | ||||||||||||
| await Promise.all([completion, modAckQueue.flush('test')]); | ||||||||||||
|
Comment on lines
+740
to
+741
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. Instead of using
Suggested change
Contributor
Author
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. This is the opposite of what was suggested 2 suggestions ago. I think we can stick with the code as it is. |
||||||||||||
|
|
||||||||||||
| const [, callOptions] = stub.lastCall.args; | ||||||||||||
| assert.strictEqual(callOptions, fakeCallOptions); | ||||||||||||
|
|
||||||||||||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Setting the global/module-level instrumentation status to
trueinbeforeEachwithout resetting it can lead to test pollution, potentially affecting other tests or test files running in the same process. To prevent this, add anafterEachhook to restore the instrumentation status to its default state (e.g.,false).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.
resolved