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

Provide a fake grpclb balancer server that can be used for testing #2338

Merged
merged 1 commit into from
Oct 3, 2018

Conversation

apolcyn
Copy link
Contributor

@apolcyn apolcyn commented Sep 28, 2018

context: I'm working on a grpclb-in-DNS interop test suite that uses fake a local DNS servers, backends, and balancers, in grpc/grpc#16727, in order to test grpclb edge cases with respect to DNS, various credentials types, and different client languages. For this, I've found it convenient to write the fake balancer server in go.

This PR is mostly aimed providing something that can be used by grpc/grpc#16727, but I'm thinking it might be useful to have around for manual testing anyways.

interop/fake_grpclb/fake_grpclb.go Outdated Show resolved Hide resolved
interop/fake_grpclb/fake_grpclb.go Outdated Show resolved Hide resolved
interop/fake_grpclb/fake_grpclb.go Outdated Show resolved Hide resolved
interop/fake_grpclb/fake_grpclb.go Outdated Show resolved Hide resolved
grpclog.Info("Expected first request to be an InitialRequest. Got: %v", lbReq)
return status.Error(codes.Code(2), "First request not an InitialRequest")
}
// gRPC clients targetting foo.bar.com:443 can sometimes include the ":443" suffix in
Copy link
Contributor

Choose a reason for hiding this comment

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

I remember this was discussed, and is expected.

If we want to remove the port, how about https://golang.org/pkg/net/#SplitHostPort?
Or we require the port number in serviceName.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

let's chat offline. For now, I'm using SplitHostPort

if *shortStream {
return nil
}
for {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The test suite that's using it needs it. But I could also leave it out now and then add it in a follow up.
It's a useful test scenario for exercising some timing edge cases, and seems to reveal some unexpected behaviors so far.

var (
port = flag.Int("port", 10000, "Port to listen on.")
backendIps = flag.String("backend_addrs", "", "Comma separated list of backend IP/port addresses.")
useALTS = flag.Bool("use_alts", false, "Listen on ALTS credentials.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Merge this and TLS flag into one that takes a string?
Otherwise we will need to deal with *alts==true && *tls==true, and it's hard to add another one (insecure maybe), just like in interop client.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm, I agree this is a little weird, but the current flags do allow specifying insecure (by keeping both of these flags off), and it's convenient to be able to pass the same flags to this server as for the interop server

What do you think?

interop/fake_grpclb/fake_grpclb.go Outdated Show resolved Hide resolved
interop/fake_grpclb/fake_grpclb.go Outdated Show resolved Hide resolved
interop/fake_grpclb/fake_grpclb.go Outdated Show resolved Hide resolved
@apolcyn apolcyn force-pushed the grpclb_interop_client branch 3 times, most recently from fb44f50 to ce849f9 Compare October 3, 2018 00:01
@apolcyn
Copy link
Contributor Author

apolcyn commented Oct 3, 2018

a couple of minor post-review changes made per the "go vet" checker

@apolcyn apolcyn merged commit 431e402 into grpc:master Oct 3, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Apr 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants