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

samples(testing): add retry rule #565

Merged
merged 2 commits into from Mar 10, 2021
Merged

samples(testing): add retry rule #565

merged 2 commits into from Mar 10, 2021

Conversation

anguillanneuf
Copy link
Contributor

@anguillanneuf anguillanneuf commented Mar 9, 2021

Fixes #552

I referenced: https://www.lenar.io/how-to-re-run-failed-tests-junit/

Alternatively, upgrade to junit5 and use @RepeatedTest annotation: https://www.swtestacademy.com/junit-5-how-to-repeat-failed-test/ ← Not super useful because it retries successful runs.

Also tried

    <dependency>
      <groupId>com.google.cloud</groupId>
      <artifactId>google-cloud-core</artifactId>
      <version>1.94.3</version>
    </dependency>

But unable to import com.google.cloud.testing.junit4.MultipleAttemptsRule;

Turned out that I need <classifier>tests</classifier> tag.

@anguillanneuf anguillanneuf requested a review from a team March 9, 2021 22:34
@product-auto-label product-auto-label bot added api: pubsub Issues related to the googleapis/java-pubsub API. samples Issues that are directly related to samples. labels Mar 9, 2021
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Mar 9, 2021
@codecov
Copy link

codecov bot commented Mar 9, 2021

Codecov Report

Merging #565 (fb6c36e) into master (0dd6d2d) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #565   +/-   ##
=========================================
  Coverage     78.73%   78.73%           
  Complexity      378      378           
=========================================
  Files            27       27           
  Lines          3418     3418           
  Branches        171      171           
=========================================
  Hits           2691     2691           
  Misses          653      653           
  Partials         74       74           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0dd6d2d...fb6c36e. Read the comment docs.

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

@Retention(RetentionPolicy.RUNTIME)
Copy link
Contributor

Choose a reason for hiding this comment

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

@BenWhitehead could we use the junit rules you wrote here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

junit5 has a @RepeatedTest annotation if we can upgrade?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, let me clarify here :) @BenWhitehead worked on some shared JUnit rules in java-core, wondering if we can make use of them - https://github.com/googleapis/java-core/pull/327/files. @anguillanneuf let me know if these are a good fit for what you're trying to accomplish, otherwise feel free to ignore my suggestion :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://github.com/googleapis/java-core/blob/master/google-cloud-core/src/test/java/com/google/cloud/testing/junit4/MultipleAttemptsRule.java is what I need, but it's in src/test/, is that something I can import?

Do you know if we can use this for testing?

 <dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter-engine</artifactId>
    <version>5.7.1</version>
    <scope>test</scope>
</dependency>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FWIW, I tried junit5, but the RepeatedTest annotation naively retries even if test succeeds. I reverted my changes.

Copy link

Choose a reason for hiding this comment

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

We aren't using Junit 5 yet, I don't remember the reason why, ask at Java Samples Office Hours. (I think it's reasonable to upgrade, but it's also a huge effort - perhaps we can just do it one at a time)

@anguillanneuf anguillanneuf requested review from a team as code owners March 9, 2021 23:34
@generated-files-bot
Copy link

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

  • samples/install-without-bom/pom.xml
  • samples/snapshot/pom.xml
  • samples/snippets/pom.xml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the googleapis/java-pubsub API. cla: yes This human has signed the Contributor License Agreement. samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pubsub.SchemaIT: testSchema failed
4 participants