question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

Unit testing gRPC client/server with xDS?

See original GitHub issue

šŸ‘‹,

PR #7620 (issue #7605) introduced the io.grpc.xds.bootstrap property as an alternative to the GRPC_XDS_BOOTSTRAP env var. This makes it possible to programmatically provide the xDS config (i.e. via System.setProperty). However, it by no means make it simple to unit test client/servers using xDS.

I see a need for unit tests with a transient xDS server running as part of the test (i.e. io.envoyproxy.controlplane:java-control-plane or similar) to allow clients to discover a server via xDS, all within a unit test.

While this works in single test isolation having multiple such tests running in parallell seems problematic given that these test then either need to use the same bootstrap config and thus the same host:port for xDS across all tests or risk concurrency issues when multiple tests want to use their own bootstrap config and point to it using System.setProperty.

Does my reasoning make sense or am I coming at this the wrong way? Is there an approach on how to unit test gRPC with xDS that I simply missed?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
ejona86commented, Mar 31, 2021

Weā€™ve come to agreement. Java and Go will allow you to inject the bootstrap into a new XdsNameResolver instance and have the user register it. C core will have a channel argument for passing in the bootstrap. It is unspecified and an implementation decision whether XdsClients will be shared between channels.

More concretely for Java, something like

Map<String,?> bootstrap = ...;
NameResolverProvider xds = XdsNameResolverProvider.createForTest("xds-mytest",  bootstrap);
NameResolverRegistry.getDefaultRegistry().register(xds);

// After test, could:
NameResolverRegistry.getDefaultRegistry().deregister(xds);

I honestly donā€™t know if we want to put the method on XdsNameResolverProvider or somewhere else.

1reaction
ejona86commented, Mar 24, 2021

This hasnā€™t been forgotten about. We have a potential solution but it is making C nervous and they want more time to find alternatives. Thatā€™s been dragging on because thereā€™s been limited ā€œfreeā€ time, but at this point weā€™ve afforded them two additional weeks to try to come up with alternative ideas. Weā€™ll default to the current approach that has been cooking if nothing comes from that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Test gRPC services in ASP.NET Core - Microsoft Learn
This article discusses how to test ASP.NET Core gRPC services. There are three common approaches for testing gRPC services: Unit testing: Test ......
Read more >
Proxyless gRPC load balancing in Kubernetes - ITNEXT
In this post, I will show how you can build a proxy-less load balancing for your gRPC services using the new xDS load...
Read more >
gRPC Load Balancing
A large scale gRPC deployment typically has a number of identical back-end instances, and a number of clients. Each server has a certainĀ ......
Read more >
grpc/grpc - Gitter
But in my code am doing this on the server-side! on the client side am not ... I decided the best way to...
Read more >
Citrix ADC xDS adapter
Pilot is a gRPC based xDS server and provides configuration data to ... client called xDS-adapter to communicate with the Istio controlĀ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found