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

fix: Multiple REST transport related fixes #997

Merged
merged 5 commits into from
Jun 3, 2022

Conversation

vam-google
Copy link
Contributor

@vam-google vam-google commented May 25, 2022

  1. Stop failing for grpc+rest and rest transports in case if there are bidi- or client- streaming methods (generated a method throwing "Unimplemented" exception if called)
  2. Make sure that the resource name suggested for wildcard resource names actually matches url pattern (most of the changes in goldens are caused by this change)
  3. Fix the order of "actual" and "expected" in diff_gen_and_golden to match
  4. Fix multipattern of%Name method resoluiton to make sure that the chosen pattern matches url pattern (the changes in MessagingClient.golden and related files are caused by this change).
  5. Fix anonymous resource name class construction (add proper toString() method matching pattern)
  6. Gracefully treat methods without http bindings as not supported in rest transport (instead of failing on generation)

1) Stop failing for grpc+rest and rest transports in case if there are bidi- or client- streaming methods (generated a method throwing "Unimplemented" exception if called)
2) Make sure that the resource name suggested for wildcard resource names actually matches url pattern (most of the changes in goldens are caused by this change)
3) Fix the order of "actual" and "expected" in diff_gen_and_golden to match
@vam-google vam-google requested review from a team as code owners May 25, 2022 01:36
@vam-google vam-google requested review from blakeli0 and eaball35 May 25, 2022 01:37
… chosen pattern matches url pattern (the changes in `MessagingClient.golden` and related files are caused by this change).
@@ -55,6 +57,31 @@ public abstract class ResourceName {

public abstract boolean isOnlyWildcard();

@Nullable
public String getMatchingPattern(String binding) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment as last method. The logic here also looks much more complicated, so unit tests would be really helpful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't have tests for Resourcename class directly, but it all gets tested as part of bigger test picture.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we please add a test class for it? This method is pretty complicated and having unit tests will not only help coverage and help us to understand it as well(easier for us to maintain in the future). It may be already tested somewhere but unit test will always fail fast, so that it's much easier to troubleshoot.

BUILD.bazel Outdated Show resolved Hide resolved
@@ -249,8 +254,10 @@ static Expr createResourceHelperValue(
List<ResourceName> unexaminedResnames = new ArrayList<>(resnames);
for (ResourceName resname : resnames) {
unexaminedResnames.remove(resname);
if (!resname.isOnlyWildcard()) {
return createResourceHelperValue(resname, false, unexaminedResnames, fieldOrMessageName);
if (!resname.isOnlyWildcard()
Copy link
Collaborator

Choose a reason for hiding this comment

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

I see a couple of new logics in this method, and I understand it's in composers so unit testing it might get complicated, can we add some test cases in the protos if it's not too hard?

Copy link
Contributor Author

@vam-google vam-google May 26, 2022

Choose a reason for hiding this comment

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

My general feeling about this codebase is that it is beyond comprehension unfortunately and this affects the testing and developing strategy.
This new logic is being tested by the current set of tests already, though it does not have a dedicated unit test item (but most of the code in this huge codebase doesn't)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I understand the sentiment and I totally feel you when I was developing dynamic routing headers, but do we want to make it worse? e.g. I added this proto to test different combinations for dynamic routing headers, it may still not cover everything but I think it helps.

Copy link
Contributor Author

@vam-google vam-google May 27, 2022

Choose a reason for hiding this comment

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

I really believe that those extra tests are not making it better, but making it worse. Basically we add more unmaintainable code. This codebase has 10+ times more code than it should for the task it performs. We are just adding unmaintainable tests to unmaintainable code. The gist is covered - this logic affects the existing tests. Testing multiple times the same code does not seem right

@vam-google
Copy link
Contributor Author

@blakeli0 PTAL

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jun 3, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 7 Code Smells

95.3% 95.3% Coverage
0.0% 0.0% Duplication

@vam-google vam-google changed the title fix: Multiple resource-related fixes fix: Multiple rest-transport related fixes Jun 3, 2022
@vam-google vam-google changed the title fix: Multiple rest-transport related fixes fix: Multiple REST transport related fixes Jun 3, 2022
@vam-google vam-google merged commit 61e2e96 into googleapis:main Jun 3, 2022
suztomo pushed a commit that referenced this pull request Dec 16, 2022
1) Stop failing for grpc+rest and rest transports in case if there are bidi- or client- streaming methods (generated a method throwing "Unimplemented" exception if called)
2) Make sure that the resource name suggested for wildcard resource names actually matches url pattern (most of the changes in goldens are caused by this change)
3) Fix the order of "actual" and "expected" in diff_gen_and_golden to match
4) Fix multipattern `of%Name` method resoluiton to make sure that the chosen pattern matches url pattern (the changes in `MessagingClient.golden` and related files are caused by this change).
5) Fix anonymous resource name class construction (add proper toString() method matching pattern)
6) Gracefully treat methods without http bindings as not supported in rest transport (instead of failing on generation)
suztomo pushed a commit that referenced this pull request Mar 21, 2023
🤖 I have created a release *beep* *boop*
---


### Updating meta-information for bleeding-edge SNAPSHOT release.

---
This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants