Skip to content

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

Merged
sanjaypujare merged 2 commits into
grpc:masterfrom
sanjaypujare:xds-misc-fixes
Apr 17, 2020
Merged

xds: add tests & misc fixes based on outstanding items#6935
sanjaypujare merged 2 commits into
grpc:masterfrom
sanjaypujare:xds-misc-fixes

Conversation

@sanjaypujare

Copy link
Copy Markdown
Contributor

No description provided.

@sanjaypujare
sanjaypujare requested a review from creamsoup April 16, 2020 16:58
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
Copy Markdown
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.

@sanjaypujare sanjaypujare Apr 16, 2020

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.

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
Copy Markdown
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).

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
Copy Markdown
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.

@sanjaypujare sanjaypujare Apr 16, 2020

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 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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).

@creamsoup creamsoup 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.

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
Copy Markdown
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