Skip to content

tests(pubsub): integrate pub/sub sample system tests that are still useful - #8091

Merged
feywind merged 30 commits into
mainfrom
feywind-pubsub-samples
Aug 28, 2026
Merged

tests(pubsub): integrate pub/sub sample system tests that are still useful#8091
feywind merged 30 commits into
mainfrom
feywind-pubsub-samples

Conversation

@feywind

@feywind feywind commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Extracts system tests from the sample system tests in the original repo, and adds those to the handwritten/pubsub tree.

@feywind feywind self-assigned this Apr 21, 2026
@feywind feywind added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Apr 21, 2026
@product-auto-label product-auto-label Bot added the samples Issues that are directly related to samples. label Apr 21, 2026
@feywind
feywind marked this pull request as draft April 21, 2026 22:19

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a comprehensive testing framework for Pub/Sub, including unit tests for common utilities and system tests for core operations like topic creation and message publishing. It also adds a TestResources class to manage resource lifecycle and prevent naming conflicts. Key feedback includes addressing a potential memory leak in the message listener timeout logic, improving the testability of the cleanup utility by using the provided timestamp provider instead of a direct call to Date.now(), and removing redundant any type assertions for better type safety.

Comment thread handwritten/pubsub/system-test/sample-tests.ts Outdated
Comment thread handwritten/pubsub/system-test/testResources.ts Outdated
Comment thread handwritten/pubsub/system-test/sample-tests.ts Outdated
@feywind
feywind marked this pull request as ready for review April 28, 2026 20:19
@feywind feywind removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Apr 28, 2026
@feywind

feywind commented Apr 28, 2026

Copy link
Copy Markdown
Contributor Author

This is obviously not running.

Checking for changes in handwritten/pubsub...
No changes detected in handwritten/pubsub. Skipping tests.

@feywind
feywind requested a review from a team as a code owner May 1, 2026 21:21
@feywind feywind closed this Jun 1, 2026
@feywind feywind reopened this Jun 1, 2026
@feywind feywind added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 2, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 2, 2026
@feywind

feywind commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

This is obviously not running.

Checking for changes in handwritten/pubsub...
No changes detected in handwritten/pubsub. Skipping tests.

The tests are running again now that it's moved to GCB.

@feywind feywind added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 3, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 3, 2026
@feywind feywind added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 3, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 5, 2026
@feywind feywind added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 8, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 8, 2026
@feywind feywind changed the title tests: integrate pub/sub sample system tests that are still useful tests(pubsub): integrate pub/sub sample system tests that are still useful Jun 8, 2026
@shivanee-p
shivanee-p removed the request for review from a team June 22, 2026 21:16
@shivanee-p
shivanee-p requested a review from pearigee June 22, 2026 21:16
@feywind

feywind commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

@shivanee-p Unfortunately this still requires some work to get CI passing. Maybe this is a hole in the new assigner script? Or was reassigning existing issues part of the initial cleanup pass?

@feywind feywind self-assigned this Jun 25, 2026
feywind and others added 3 commits July 9, 2026 18:27
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@feywind
feywind force-pushed the feywind-pubsub-samples branch from ca5cc15 to b215ee1 Compare July 9, 2026 22:42
@feywind

feywind commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

The old branch had unfortunately become very crufty from merges, so I refactored it.

@feywind
feywind removed the request for review from pearigee August 12, 2026 20:51
@feywind
feywind enabled auto-merge (squash) August 13, 2026 19:10

const message = await new Promise<Message>((resolve, reject) => {
const timeout = setTimeout(() => reject(new Error('Timeout waiting for Avro record')), 15000);
subscription.once('message', (m: Message) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to remove this listener if we hit timeout (like you did in pubsub.ts?)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I didn't point it out before, there are several cases like this remaining in the PR. Can you please address those, too?

Comment thread handwritten/pubsub/package.json Outdated
"@types/tmp": "^0.2.6",
"avro-js": "^1.12.1",
"c8": "^10.1.3",
"chai": "^6.2.2",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we use chai consistently in our tests?

If we can workaround features of built-in assert, maybe we should stick to that.

Generally, I'd prefer to have consistent APIs across tests. Can you consider a follow-up PR to move all the assertions to chai, if that's the best thing?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We used to, we don't anymore - we're trying to move to the simpler built-in assert. I'll remove this.

Comment on lines +15 to +17
// I don't like that these two files (this plus ".test") are duplicated
// across the two test structures, but because of the tangle of rootDirs
// and package.json "files", it's hard to avoid it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of testresources, is there a way we can avoid the duplication? Could this be put in some shared test-utils dependency?

@feywind feywind Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's not really a good candidate right now for a separate library - I like the idea of making a test-utils in core somewhere. Especially in goofy cases like this. But it generally seems useful for the handwritten libraries for their system tests.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm OK if its a follow-up, please file a ticket to dedupe these.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is b/554057686.

import * as opentelemetry from '@opentelemetry/api';
import {google} from '../protos/protos';
import * as defer from 'p-defer';
import * as crypto from 'node:crypto';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! Can you do this to other imports, here or in another PR?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean the adding node:, right? I agree it's good practice now. I'll make a separate PR in a bit.

@feywind
feywind disabled auto-merge August 13, 2026 20:13
Comment on lines +15 to +17
// I don't like that these two files (this plus ".test") are duplicated
// across the two test structures, but because of the tangle of rootDirs
// and package.json "files", it's hard to avoid it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm OK if its a follow-up, please file a ticket to dedupe these.


const message = await new Promise<Message>((resolve, reject) => {
const timeout = setTimeout(() => reject(new Error('Timeout waiting for Avro record')), 15000);
subscription.once('message', (m: Message) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I didn't point it out before, there are several cases like this remaining in the PR. Can you please address those, too?

@westarle

Copy link
Copy Markdown
Contributor

please address all the remaining listeners before submitting.

@feywind
feywind merged commit 093572e into main Aug 28, 2026
50 checks passed
@feywind
feywind deleted the feywind-pubsub-samples branch August 28, 2026 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants