This repository was archived by the owner on Sep 16, 2023. It is now read-only.

Conversation

suztomo

Relocating the sample from native-image-support to this repository

mvn clean verify -DskipTests -P lint passes.

Fixes #<issue_number_goes_here> ☕️

If you write sample code, please follow the samples format.

Relocating the sample from native-image-support to this repository
@suztomosuztomo requested a review from a team as a code owner February 28, 2022 22:31
@product-auto-labelproduct-auto-label bot added the api: cloudtasksIssues related to the googleapis/java-tasks API.label Feb 28, 2022
@generated-files-bot

Warning: This pull request is touching the following templated files:

  • samples/pom.xml

@product-auto-labelproduct-auto-label bot added the samplesIssues that are directly related to samples.label Feb 28, 2022
@suztomosuztomo marked this pull request as draft February 28, 2022 22:32
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>24.2.0</version>
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the version that works with native-image-support 0.10.0.

<groupId>com.google.cloud</groupId>
<artifactId>native-image-support</artifactId>
<version>0.10.0</version>
</dependency>
Copy link
Member Author

Choose a reason for hiding this comment

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

No JUnit-related dependencies because this project doesn't use JUnit.

*/
public static void main(String[] args) throws IOException {
String projectId = ServiceOptions.getDefaultProjectId();
LocationName parent = LocationName.of(projectId, "us-east1");
Copy link
Member Author

Choose a reason for hiding this comment

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

Open question: Does this work for those who don't use us-east1?

@mpeddada1

Awesome, thank you Tomo! Could we also add an integration test for this sample?

@suztomo

@mpeddada1 I didn’t find an integration test in the native-support repository. Would you share the URL of it?

@mpeddada1

@mpeddada1 I didn’t find an integration test in the native-support repository. Would you share the URL of it?

Ah I'm afraid we have to manually write tests for the samples. We have a few examples if you'd like to refer to them: googleapis/java-firestore#872, https://.com/googleapis/java-datastore/pull/640/files

@suztomo

Thank you.

@suztomo

The Kokoro failed and it shows:

Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Maven home: /usr/local/lib/maven
Java version: 1.8.0_322, vendor: Oracle Corporation, runtime: /usr/local/openjdk-8/jre

...

[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ native-image-sample ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /tmpfs/src//java-tasks/samples/native-image-sample/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] javac: invalid target release: 11
Usage: javac <options> <source files>
use -help for a list of possible options

Next step: investigate how java-firestore reconcile Java version in Kokoro Sample build.

Why java-firestore doesn't complain Java version in "Kokoro - Test: Samples"?

https://source.cloud.google.com/results/invocations/416fe06b-014c-4092-97b3-7cd4b6d40496/targets succeeded. It doesn't have the native-image test target.

The java-firestore directory has a special handling in .kokoro/build.sh that only runs samples/snapshot project. https://.com/googleapis/java-firestore/blob/cf36ed37b8c62ef1117f1b12a2bcbcf4601ecc3a/.kokoro/build.sh#L82

This means, java-firestore doesn't run samples/native-image-sample integration test as part of "Kokoro - Test: Samples" build.

This special handling doesn't exist in java-tasks repository's build.sh.

Problem in Java version for "Kokoro - Test: Samples"

SAMPLE_FORMAT.md says we should consider Java 11. However the Kokoro Sample test infrastructure doesn't work for Java 11 Maven configuration. That's the gap we need to fill.

Options

  • Just use Java8.
  • Not adding "samples/native-image-sample" project from "samples" project.
    • This means we don't test the sample code in pull requests.
    • This is (in effect) the status quo in the java-firestore repository.
  • Uplift the Kokoro build infrastructure to use Java 11 for samples.

Consideration

Java-tasks repository is just one of the many (~100) auto-generated libraries. Among them, we have some samples in some (12) repositories. What's the best way to address the gap across other repositories?

@suztomo

"Kokoro - Test: Samples" now succeeds and it has ITNativeImageTasksSample.

Screen Shot 2022-03-01 at 1 38 26 PM

@suztomosuztomo marked this pull request as ready for review March 1, 2022 18:39

Choose a reason for hiding this comment

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

Looks great! Thanks

* FAILED_PRECONDITION: The queue cannot be created because a queue with this name existed
* too recently.
*/
private static final String GRAALVM_TEST_QUEUE_NAME = "graal-test-queue-";
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we replace "graalvm" with "native" or "native-image"?

@suztomosuztomo added the owlbot:runAdd this label to trigger the Owlbot post processor.label Mar 1, 2022
@gcf-owl-botgcf-owl-bot bot removed the owlbot:runAdd this label to trigger the Owlbot post processor.label Mar 1, 2022
@suztomosuztomo added the automergeMerge the pull request once unit tests and other checks pass.label Mar 1, 2022
@gcf-merge-on-greengcf-merge-on-green bot merged commit ec53481 into googleapis:main Mar 1, 2022
@gcf-merge-on-greengcf-merge-on-green bot removed the automergeMerge the pull request once unit tests and other checks pass.label Mar 1, 2022
@release-pleaserelease-please bot mentioned this pull request Mar 1, 2022
@release-pleaserelease-please bot mentioned this pull request May 24, 2022
Sign up for free to subscribe to this conversation on . Already have an account? Sign in.
api: cloudtasksIssues related to the googleapis/java-tasks API.samplesIssues that are directly related to samples.
None yet

Successfully merging this pull request may close these issues.