Skip to content

Commit

Permalink
ci(spanner): Create a new Sample Slow tests (googleapis#3560)
Browse files Browse the repository at this point in the history
* ci(spanner): Create a new Sample Slow tests

* Fix delete backup issue in autogenerated admin client
  • Loading branch information
sakthivelmanii authored Dec 17, 2024
1 parent 488aa8c commit 871cb82
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 25 deletions.
8 changes: 7 additions & 1 deletion .kokoro/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,17 @@ slowtests)
verify
RETURN_CODE=$?
;;
samples)
samples|samples-slow-tests)
SAMPLES_DIR=samples
PROFILES=''
# only run ITs in snapshot/ on presubmit PRs. run ITs in all 3 samples/ subdirectories otherwise.
if [[ ! -z ${KOKORO_GITHUB_PULL_REQUEST_NUMBER} ]]
then
SAMPLES_DIR=samples/snapshot
elif [[ ${JOB_TYPE} = 'samples-slow-tests' ]]
then
SAMPLES_DIR=samples/snippets
PROFILES='-Pslow-tests,!integration-tests'
fi

if [[ -f ${SAMPLES_DIR}/pom.xml ]]
Expand All @@ -227,6 +232,7 @@ samples)
-DtrimStackTrace=false \
-Dclirr.skip=true \
-Denforcer.skip=true \
${PROFILES} \
-fae \
verify
RETURN_CODE=$?
Expand Down
39 changes: 39 additions & 0 deletions .kokoro/nightly/java11-samples-slow-tests.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Format: //devtools/kokoro/config/proto/build.proto

# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/java11"
}

env_vars: {
key: "JOB_TYPE"
value: "samples-slow-tests"
}

# TODO: remove this after we've migrated all tests and scripts
env_vars: {
key: "GCLOUD_PROJECT"
value: "gcloud-devel"
}

env_vars: {
key: "GOOGLE_CLOUD_PROJECT"
value: "gcloud-devel"
}

env_vars: {
key: "GOOGLE_APPLICATION_CREDENTIALS"
value: "secret_manager/java-it-service-account"
}

env_vars: {
key: "SECRET_MANAGER_KEYS"
value: "java-it-service-account"
}

env_vars: {
key: "ENABLE_BUILD_COP"
value: "true"
}

85 changes: 63 additions & 22 deletions samples/snippets/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,69 @@
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>integration-tests</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.5.2</version>
<configuration>
<forkCount>10</forkCount>
<reuseForks>false</reuseForks>
<systemPropertyVariables>
<spanner.test.instance>java-sample-integration-tests</spanner.test.instance>
<spanner.test.instance.mr>java-client-mr-integration-tests</spanner.test.instance.mr>
<spanner.test.instance.config>nam11</spanner.test.instance.config>
<spanner.test.key.location>us-east1</spanner.test.key.location>
<spanner.test.key.ring>cmek-test-key-ring</spanner.test.key.ring>
<spanner.test.key.name>cmek-test-key</spanner.test.key.name>
<spanner.sample.database>mysample</spanner.sample.database>
<spanner.quickstart.database>quick-db</spanner.quickstart.database>
</systemPropertyVariables>
<excludes>
<exclude>**/SpannerSampleIT.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>slow-tests</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.5.2</version>
<configuration>
<forkCount>10</forkCount>
<reuseForks>false</reuseForks>
<systemPropertyVariables>
<spanner.test.instance>java-sample-integration-tests</spanner.test.instance>
<spanner.test.instance.mr>java-client-mr-integration-tests</spanner.test.instance.mr>
<spanner.test.instance.config>nam11</spanner.test.instance.config>
<spanner.test.key.location>us-east1</spanner.test.key.location>
<spanner.test.key.ring>cmek-test-key-ring</spanner.test.key.ring>
<spanner.test.key.name>cmek-test-key</spanner.test.key.name>
<spanner.sample.database>mysample</spanner.sample.database>
<spanner.quickstart.database>quick-db</spanner.quickstart.database>
</systemPropertyVariables>
<includes>
<include>**/SpannerSampleIT.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<plugins>
<plugin>
Expand Down Expand Up @@ -172,28 +235,6 @@
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.5.2</version>
<configuration>
<forkCount>10</forkCount>
<reuseForks>false</reuseForks>
<systemPropertyVariables>
<spanner.test.instance>java-sample-integration-tests</spanner.test.instance>
<spanner.test.instance.mr>java-client-mr-integration-tests</spanner.test.instance.mr>
<spanner.test.instance.config>nam11</spanner.test.instance.config>
<spanner.test.key.location>us-east1</spanner.test.key.location>
<spanner.test.key.ring>cmek-test-key-ring</spanner.test.key.ring>
<spanner.test.key.name>cmek-test-key</spanner.test.key.name>
<spanner.sample.database>mysample</spanner.sample.database>
<spanner.quickstart.database>quick-db</spanner.quickstart.database>
</systemPropertyVariables>
<excludes>
<exclude>**/SpannerSampleIT.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertTrue;

import com.google.api.gax.rpc.FailedPreconditionException;
import com.google.cloud.Timestamp;
import com.google.cloud.spanner.DatabaseId;
import com.google.cloud.spanner.ErrorCode;
Expand Down Expand Up @@ -643,8 +644,13 @@ private static void deleteAllBackups(String instanceId) throws InterruptedExcept
attempts++;
databaseAdminClient.deleteBackup(backup.getName());
break;
} catch (SpannerException e) {
if (e.getErrorCode() == ErrorCode.FAILED_PRECONDITION
} catch (SpannerException | FailedPreconditionException e) {
ErrorCode errorCode = ErrorCode.FAILED_PRECONDITION;

if (e instanceof SpannerException) {
errorCode = ((SpannerException) e).getErrorCode();
}
if (errorCode == ErrorCode.FAILED_PRECONDITION
&& e.getMessage()
.contains(
"Please try deleting the backup once the restore or post-restore optimize "
Expand Down

0 comments on commit 871cb82

Please sign in to comment.