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

feat: Adding vendor and vendor information in header #1963

Merged
merged 13 commits into from
Sep 8, 2023
Merged

Conversation

ddixit14
Copy link
Contributor

@ddixit14 ddixit14 commented Sep 6, 2023

This PR adds java vendor information to the "gl-java" header value. Only when the information is present, add it to javaRuntimeInformation.

Local testing results for various combinations-

(1)
the vendor is -> Eclipse Adoptium
the vendor version is -> Temurin-11.0.19+7
the javaRuntimeInformation is -> 11.0.19__Eclipse-Adoptium__Temurin-11.0.19-7

(2)
the vendor is ->Amazon.com Inc.
the vendor version is ->Corretto-11.0.19.7.1
the javaRuntimeInformation is ->11.0.19__Amazon.com-Inc.__Corretto-11.0.19.7.1

(3)
the vendor is ->Eclipse Adoptium
the vendor version is ->Temurin-11.0.20.1+1
the javaRuntimeInformation is ->11.0.20.1__Eclipse-Adoptium__Temurin-11.0.20.1-1

(4) [Case when vendor version is not available]
the vendor is ->Oracle Corporation
the vendor version is ->null
the javaRuntimeInformation is ->20.0.1__Oracle-Corporation

@ddixit14 ddixit14 requested a review from a team as a code owner September 6, 2023 15:14
@product-auto-label product-auto-label bot added the size: s Pull request size is small. label Sep 6, 2023

// append the vendor information to the java-version if vendor is present.
String vendor = System.getProperty("java.vendor");
if (vendor != null && !vendor.isEmpty()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This can be simplified by Guava's Strings.isNullOrEmpty, similar to here

@blakeli0
Copy link
Collaborator

blakeli0 commented Sep 6, 2023

Do we need to append this info for graalvm as well?

@ddixit14
Copy link
Contributor Author

ddixit14 commented Sep 7, 2023

to-do : Manually confirm graalvm-behaviour (change to graalvm, print the result of gaxProperties getJavaVersion().

@suztomo
Copy link
Member

suztomo commented Sep 7, 2023

ci / build(8) except for gapic-generator-java (pull_request) Failing after 1m

@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: s Pull request size is small. labels Sep 7, 2023
return System.getProperty("java.version");
/**
* Returns the current runtime version. For GraalVM the values in this method will be fetched at
* build time and the values should not differ from runtime (executable)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* build time and the values should not differ from runtime (executable)
* build time and the values should not differ from the runtime (executable).

@ddixit14
Copy link
Contributor Author

ddixit14 commented Sep 7, 2023

Do we need to append this info for graalvm as well?

Handled graalvm case as well.

Copy link
Member

@suztomo suztomo left a comment

Choose a reason for hiding this comment

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

Can you check any usage of getJavaVersion in java-storage, java-bigtable, java-pubsub, and google-cloud-java (my random picked repositories)?

@ddixit14 ddixit14 changed the title feat: Adding vendor and vendor information in java-version header feat: Adding vendor and vendor information in header Sep 7, 2023
}

@Test
public void testGetJavaRuntimeInfo_spaces() {
Copy link
Member

Choose a reason for hiding this comment

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

Can you rename it back to the Java vendor name? For those that represent real vendor value, the name should have the vendor name.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the purpose of this unit test to test real vendor name or test the functionality of the method?

Copy link
Member

Choose a reason for hiding this comment

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

@ddixit14 The test name should answer Blake'a question.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have tried to capture both.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I really think that unit tests should only care about the functionality/behavior of the method and test names should include the behavior being tested and expected outcomes. If we only care about the behavior, the scope is limited and each test is easy to understand. If we start to test real vendor names, what's the scope of it? Do we try to test all the available vendors? If not, why do we pick the selected vendors?
That being said, if you feel strongly about testing with real vendor names, please add comments explaining the why these real vendors are selected and differences between each vendor.

Copy link
Contributor Author

@ddixit14 ddixit14 Sep 7, 2023

Choose a reason for hiding this comment

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

I have separated the real world tests and functionality tests, and given appropriate names and comments. Can you please review them once, and if there's still any issue then we can continue the discussion?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As for why we are using real vendor in testing is because this change is being done to capture the customer usage (which version/vendor/vendor.version the customer is using). If we make sure that we are able to capture real vendors information correctly, our usage data will be more accurate. As for the other functionality tests, I have changed the name and commented what is being tested. As for why these 3 real vendors are chosen. (1) graalvm - we support this and we have a specific dashboard for its usage, so for more accuracy. also because I changed its implementation (2) temurin - we officially support this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks Deepankar! LGTM.

Copy link
Member

@suztomo suztomo Sep 8, 2023

Choose a reason for hiding this comment

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

I also want real world values used in unit tests. First, it would detects real world bugs. Second, for future code readers, it works as a document of what kind of values the function deals with in real world.

@suztomo
Copy link
Member

suztomo commented Sep 7, 2023

Test case for this?

the vendor is ->Amazon.com Inc.
the vendor version is ->Corretto-11.0.19.7.1
the javaRuntimeInformation is ->11.0.19__Amazon.com-Inc.__Corretto-11.0.19.7.1

@ddixit14
Copy link
Contributor Author

ddixit14 commented Sep 7, 2023

Test case for this?

the vendor is ->Amazon.com Inc. the vendor version is ->Corretto-11.0.19.7.1 the javaRuntimeInformation is ->11.0.19__Amazon.com-Inc.__Corretto-11.0.19.7.1

Added this back.

@sonarcloud
Copy link

sonarcloud bot commented Sep 7, 2023

[gapic-generator-java-root] 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 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@sonarcloud
Copy link

sonarcloud bot commented Sep 7, 2023

[java_showcase_integration_tests] 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 0 Code Smells

83.3% 83.3% Coverage
0.0% 0.0% Duplication

@sonarcloud
Copy link

sonarcloud bot commented Sep 7, 2023

[java_showcase_unit_tests] 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 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@suztomo suztomo merged commit ed44aa7 into main Sep 8, 2023
38 checks passed
@suztomo suztomo deleted the vendor-info branch September 8, 2023 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants