Skip to content

xds: add tests & misc fixes based on outstanding items #6935

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

Merged
merged 2 commits into from
Apr 17, 2020

Conversation

sanjaypujare
Copy link
Contributor

No description provided.

@sanjaypujare sanjaypujare requested a review from creamsoup April 16, 2020 16:58
@@ -84,7 +84,7 @@ public static XdsClientWrapperForServerSds newInstance(
Bootstrapper.BootstrapInfo bootstrapInfo = bootstrapper.readBootstrap();
final List<Bootstrapper.ServerInfo> serverList = bootstrapInfo.getServers();
if (serverList.isEmpty()) {
throw new NoSuchElementException("No management server provided by bootstrap");
throw new FileNotFoundException("No management server provided by bootstrap");
Copy link
Contributor

Choose a reason for hiding this comment

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

this does not look correct. it is not even an IO exception (this is why it is originally not an IO exception), consider using custom checked exception if there isn't any good exception to use.

Copy link
Contributor Author

@sanjaypujare sanjaypujare Apr 16, 2020

Choose a reason for hiding this comment

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

Yeah, I can create a custom checked exception or just return null with a log message. I think the latter is preferred but let me know your preference.

Copy link
Contributor

Choose a reason for hiding this comment

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

it is definitely preferred to throw exception especially if the caller need to do something.

Looked at the code i think the getXdsClientWrapperForServerSds shouldn't return null. it should just throw and serverProtocolNegotiator can handle the exception (or just remove the getXdsClientWrapperForServerSds and inline it since it does not really belong to ServerSdsProtocolNegotiator); it sees exception so it can fallback seems more natural than hmm somehow we have null, lets fallback (not very idiomatic java, it is c style - no offense to c =p).

@@ -60,7 +60,7 @@ private SdsProtocolNegotiators() {

private static final Logger logger = Logger.getLogger(SdsProtocolNegotiators.class.getName());

private static final AsciiString SCHEME = AsciiString.of("https");
private static final AsciiString SCHEME = AsciiString.of("http");
Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC there was a test checking scheme http if plaintext. the test should be fixed.

Copy link
Contributor Author

@sanjaypujare sanjaypujare Apr 16, 2020

Choose a reason for hiding this comment

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

There was/is no test - otherwise the build would have failed. Do you want me to add a test - the test will just verify this init so not sure about it's value.

Copy link
Contributor

Choose a reason for hiding this comment

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

https://github.com/grpc/grpc-java/blob/master/xds/src/test/java/io/grpc/xds/internal/sds/SdsProtocolNegotiatorsTest.java#L288

that test, it was checking "http" vs "https". now everything is "http". this test is no longer relevant and should be fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you are right, may bad! I will have to modify the test to detect plaintext vs Sds PN and let me think about it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With scheme being the same the only other thing to check is the class-name of the returned protocolNegotiator it should match ...ServerPlaintextNegotiator or should have plaintext in it. Do you have a better suggestion?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah there isn't a good way to test this other than using name of the class. i think it is fine to check the class name (ServerPlaintextNegotiator).

Copy link
Contributor

@creamsoup creamsoup left a comment

Choose a reason for hiding this comment

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

LGTM

@sanjaypujare sanjaypujare merged commit 56a410f into grpc:master Apr 17, 2020
@sanjaypujare sanjaypujare deleted the xds-misc-fixes branch April 17, 2020 17:59
@sanjaypujare
Copy link
Contributor Author

thanks @creamsoup

dfawley pushed a commit to dfawley/grpc-java that referenced this pull request Jan 15, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants