diff --git a/.kokoro/build.sh b/.kokoro/build.sh
index d603c59859b..8875b41d373 100755
--- a/.kokoro/build.sh
+++ b/.kokoro/build.sh
@@ -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 ]]
@@ -227,6 +232,7 @@ samples)
-DtrimStackTrace=false \
-Dclirr.skip=true \
-Denforcer.skip=true \
+ ${PROFILES} \
-fae \
verify
RETURN_CODE=$?
diff --git a/.kokoro/nightly/java11-samples-slow-tests.cfg b/.kokoro/nightly/java11-samples-slow-tests.cfg
new file mode 100644
index 00000000000..7246153b048
--- /dev/null
+++ b/.kokoro/nightly/java11-samples-slow-tests.cfg
@@ -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"
+}
+
diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml
index a137325f545..f78c2d3b308 100644
--- a/samples/snippets/pom.xml
+++ b/samples/snippets/pom.xml
@@ -115,6 +115,69 @@
test
+
+
+ integration-tests
+
+ true
+
+
+
+
+ org.apache.maven.plugins
+ maven-failsafe-plugin
+ 3.5.2
+
+ 10
+ false
+
+ java-sample-integration-tests
+ java-client-mr-integration-tests
+ nam11
+ us-east1
+ cmek-test-key-ring
+ cmek-test-key
+ mysample
+ quick-db
+
+
+ **/SpannerSampleIT.java
+
+
+
+
+
+
+
+ slow-tests
+
+
+
+ org.apache.maven.plugins
+ maven-failsafe-plugin
+ 3.5.2
+
+ 10
+ false
+
+ java-sample-integration-tests
+ java-client-mr-integration-tests
+ nam11
+ us-east1
+ cmek-test-key-ring
+ cmek-test-key
+ mysample
+ quick-db
+
+
+ **/SpannerSampleIT.java
+
+
+
+
+
+
+
@@ -172,28 +235,6 @@
-
- org.apache.maven.plugins
- maven-failsafe-plugin
- 3.5.2
-
- 10
- false
-
- java-sample-integration-tests
- java-client-mr-integration-tests
- nam11
- us-east1
- cmek-test-key-ring
- cmek-test-key
- mysample
- quick-db
-
-
- **/SpannerSampleIT.java
-
-
-
org.apache.maven.plugins
maven-checkstyle-plugin
diff --git a/samples/snippets/src/test/java/com/example/spanner/SpannerSampleIT.java b/samples/snippets/src/test/java/com/example/spanner/SpannerSampleIT.java
index d59152b407c..a3b12caa392 100644
--- a/samples/snippets/src/test/java/com/example/spanner/SpannerSampleIT.java
+++ b/samples/snippets/src/test/java/com/example/spanner/SpannerSampleIT.java
@@ -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;
@@ -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 "