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

pubsub/pstest: support listening on 0.0.0.0 #11569

Open
larryanz opened this issue Feb 7, 2025 · 4 comments
Open

pubsub/pstest: support listening on 0.0.0.0 #11569

larryanz opened this issue Feb 7, 2025 · 4 comments
Assignees
Labels
api: pubsub Issues related to the Pub/Sub API. triage me I really want to be triaged.

Comments

@larryanz
Copy link
Contributor

larryanz commented Feb 7, 2025

Is your feature request related to a problem? Please describe.

Currently, the server in pstest listens on localhost . This limits its accessibility to the local machine only, making it difficult to access the server from outside the container or other machines. In a Dockerized environment, this prevents external clients or other containers from communicating with the server. It would be easier to test and interact with the app if the server could be configured to listen on 0.0.0.0, allowing it to be accessed externally.

Describe the solution you'd like

I would like to see an option like another method to make the server listen on 0.0.0.0 instead of localhost.
For example:

host := "0.0.0.0:3000"
srv := pstest.NewServerWithHost(host)

Describe alternatives you've considered

You may wonder why I need to containerize it? It's because the pubsub-emulator works not stably in our case.

@larryanz larryanz added the triage me I really want to be triaged. label Feb 7, 2025
@codyoss codyoss changed the title pstest: support listening on 0.0.0.0 pubsub/pstest: support listening on 0.0.0.0 Feb 7, 2025
@codyoss codyoss added the api: pubsub Issues related to the Pub/Sub API. label Feb 7, 2025
@hongalex
Copy link
Member

hongalex commented Feb 8, 2025

The code that configures what address to listen on is actually in NewServerWithPort, defined in internal/testutil/server.go. Since this affects more than just Pub/Sub, @codyoss or @quartzmo, wdyt about expanding that test package to support listening on custom addresses?

@codyoss
Copy link
Member

codyoss commented Feb 10, 2025

@hongalex I think we could accommodate that if needed

@larryanz
Copy link
Contributor Author

larryanz commented Feb 11, 2025

If we decided to support this, do we have any direction? Add a second method for the testutil?
I'm willing to help @hongalex

@hongalex
Copy link
Member

Yeah if you want to create a PR for this change, I'd be happy to review it. Adding the method to testutil and wrapping in pubsub fake seems correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the Pub/Sub API. triage me I really want to be triaged.
Projects
None yet
Development

No branches or pull requests

3 participants