Skip to content

Commit

Permalink
samples(testing): add retry rule (#565)
Browse files Browse the repository at this point in the history
* samples(testing): add retry rule

* use google-cloud-core's MultipleAttemptsRule
  • Loading branch information
anguillanneuf committed Mar 10, 2021
1 parent 0aa4521 commit e72328b
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 17 deletions.
6 changes: 6 additions & 0 deletions samples/install-without-bom/pom.xml
Expand Up @@ -77,6 +77,12 @@
<artifactId>protobuf-java-util</artifactId>
<version>3.15.3</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-core</artifactId>
<version>1.94.1</version>
<classifier>tests</classifier>
</dependency>
</dependencies>

<!-- compile and run all snippet tests -->
Expand Down
6 changes: 6 additions & 0 deletions samples/snapshot/pom.xml
Expand Up @@ -76,6 +76,12 @@
<version>1.1.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-core</artifactId>
<version>1.94.1</version>
<classifier>tests</classifier>
</dependency>
</dependencies>

<!-- compile and run all snippet tests -->
Expand Down
6 changes: 6 additions & 0 deletions samples/snippets/pom.xml
Expand Up @@ -87,6 +87,12 @@
<version>1.1.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-core</artifactId>
<version>1.94.1</version>
<classifier>tests</classifier>
</dependency>
<!-- [END_EXCLUDE] -->
</dependencies>
<!-- [END pubsub_install_with_bom] -->
Expand Down
9 changes: 4 additions & 5 deletions samples/snippets/src/main/java/utilities/State.java
Expand Up @@ -23,14 +23,13 @@
/**
* This file is created using Avro tools.
*
* To download, visit https://avro.apache.org/releases.html#Download
* <p>To download, visit https://avro.apache.org/releases.html#Download
*
* Run the following command from the `samples/snippets` directory to
* generate this class:
* <p>Run the following command from the `samples/snippets` directory to generate this class:
*
*`java -jar /location/to/your/avro-tools-1.10.1.jar compile schema src/main/resources/us-states.avsc src/main/java/`
* <p>`java -jar /location/to/your/avro-tools-1.10.1.jar compile schema
* src/main/resources/us-states.avsc src/main/java/`
*/

package utilities;

import org.apache.avro.message.BinaryMessageDecoder;
Expand Down
9 changes: 4 additions & 5 deletions samples/snippets/src/main/java/utilities/StateProto.java
Expand Up @@ -20,14 +20,13 @@
/**
* This file is created using protoc.
*
* To download, visit https://developers.google.com/protocol-buffers/docs/downloads
* <p>To download, visit https://developers.google.com/protocol-buffers/docs/downloads
*
* Run the following command from the `samples/snippets` directory to
* generate this class:
* <p>Run the following command from the `samples/snippets` directory to generate this class:
*
*`protoc --proto_path=src/main/resources/ --java_out=src/main/java/ src/main/resources/us-states.proto`
* <p>`protoc --proto_path=src/main/resources/ --java_out=src/main/java/
* src/main/resources/us-states.proto`
*/

package utilities;

public final class StateProto {
Expand Down
10 changes: 3 additions & 7 deletions samples/snippets/src/test/java/pubsub/SchemaIT.java
Expand Up @@ -23,6 +23,7 @@
import com.google.cloud.pubsub.v1.SchemaServiceClient;
import com.google.cloud.pubsub.v1.SubscriptionAdminClient;
import com.google.cloud.pubsub.v1.TopicAdminClient;
import com.google.cloud.testing.junit4.MultipleAttemptsRule;
import com.google.pubsub.v1.Encoding;
import com.google.pubsub.v1.ProjectSubscriptionName;
import com.google.pubsub.v1.SchemaName;
Expand All @@ -33,7 +34,6 @@
import java.util.UUID;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.Timeout;
Expand Down Expand Up @@ -73,12 +73,8 @@ private static void requireEnvVar(String varName) {
System.getenv(varName));
}

@Rule public Timeout globalTimeout = Timeout.seconds(300); // 5 minute timeout

@BeforeClass
public static void checkRequirements() {
requireEnvVar("GOOGLE_CLOUD_PROJECT");
}
@Rule public Timeout globalTimeout = Timeout.seconds(600); // 10 minute timeout
@Rule public MultipleAttemptsRule retryRule = new MultipleAttemptsRule(/*maxAttemptCount=*/ 3);

@Before
public void setUp() {
Expand Down

0 comments on commit e72328b

Please sign in to comment.