Skip to content

Commit 206bd29

Browse files
ci(spanner): improve performance of samples tests
1 parent 801346a commit 206bd29

File tree

6 files changed

+35
-0
lines changed

6 files changed

+35
-0
lines changed

samples/install-without-bom/pom.xml

+3
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@
147147
<artifactId>maven-failsafe-plugin</artifactId>
148148
<version>3.5.2</version>
149149
<configuration>
150+
<forkCount>10</forkCount>
151+
<reuseForks>false</reuseForks>
150152
<systemPropertyVariables>
151153
<spanner.test.instance>java-sample-integration-tests</spanner.test.instance>
152154
<spanner.test.instance.mr>java-client-mr-integration-tests</spanner.test.instance.mr>
@@ -157,6 +159,7 @@
157159
<spanner.sample.database>mysample</spanner.sample.database>
158160
<spanner.quickstart.database>quick-db</spanner.quickstart.database>
159161
</systemPropertyVariables>
162+
<excludedGroups>com.example.spanner.helper.SlowTest</excludedGroups>
160163
</configuration>
161164
</plugin>
162165
</plugins>

samples/snapshot/pom.xml

+3
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@
146146
<artifactId>maven-failsafe-plugin</artifactId>
147147
<version>3.5.2</version>
148148
<configuration>
149+
<forkCount>10</forkCount>
150+
<reuseForks>false</reuseForks>
149151
<systemPropertyVariables>
150152
<spanner.test.instance>java-sample-integration-tests</spanner.test.instance>
151153
<spanner.test.instance.mr>java-client-mr-integration-tests</spanner.test.instance.mr>
@@ -157,6 +159,7 @@
157159
<spanner.sample.instance>mysample-instance</spanner.sample.instance>
158160
<spanner.quickstart.database>quick-db</spanner.quickstart.database>
159161
</systemPropertyVariables>
162+
<excludedGroups>com.example.spanner.helper.SlowTest</excludedGroups>
160163
</configuration>
161164
</plugin>
162165
</plugins>

samples/snippets/pom.xml

+3
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@
177177
<artifactId>maven-failsafe-plugin</artifactId>
178178
<version>3.5.2</version>
179179
<configuration>
180+
<forkCount>10</forkCount>
181+
<reuseForks>false</reuseForks>
180182
<systemPropertyVariables>
181183
<spanner.test.instance>java-sample-integration-tests</spanner.test.instance>
182184
<spanner.test.instance.mr>java-client-mr-integration-tests</spanner.test.instance.mr>
@@ -187,6 +189,7 @@
187189
<spanner.sample.database>mysample</spanner.sample.database>
188190
<spanner.quickstart.database>quick-db</spanner.quickstart.database>
189191
</systemPropertyVariables>
192+
<excludedGroups>com.example.spanner.helper.SlowTest</excludedGroups>
190193
</configuration>
191194
</plugin>
192195
<plugin>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright 2024 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.example.spanner.helper;
18+
19+
/* Interface for slow tests */
20+
public interface SlowTest { }

samples/snippets/src/test/java/com/example/spanner/SpannerSampleIT.java

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static com.google.common.truth.Truth.assertThat;
2020
import static org.junit.Assert.assertTrue;
2121

22+
import com.example.spanner.helper.SlowTest;
2223
import com.google.cloud.Timestamp;
2324
import com.google.cloud.spanner.DatabaseId;
2425
import com.google.cloud.spanner.ErrorCode;
@@ -51,12 +52,14 @@
5152
import org.junit.Assert;
5253
import org.junit.BeforeClass;
5354
import org.junit.Test;
55+
import org.junit.experimental.categories.Category;
5456
import org.junit.runner.RunWith;
5557
import org.junit.runners.JUnit4;
5658

5759
/** Unit tests for {@code SpannerSample} */
5860
@RunWith(JUnit4.class)
5961
@SuppressWarnings("checkstyle:abbreviationaswordinname")
62+
@Category(SlowTest.class)
6063
public class SpannerSampleIT extends SampleTestBaseV2 {
6164

6265
private static final int DBID_LENGTH = 20;

samples/snippets/src/test/java/com/example/spanner/admin/archived/SpannerSampleIT.java

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import static org.junit.Assert.assertTrue;
2121

2222
import com.example.spanner.SampleRunner;
23+
import com.example.spanner.helper.SlowTest;
2324
import com.google.cloud.Timestamp;
2425
import com.google.cloud.spanner.Backup;
2526
import com.google.cloud.spanner.BackupId;
@@ -48,6 +49,7 @@
4849
import org.junit.AfterClass;
4950
import org.junit.BeforeClass;
5051
import org.junit.Test;
52+
import org.junit.experimental.categories.Category;
5153
import org.junit.runner.RunWith;
5254
import org.junit.runners.JUnit4;
5355
import org.threeten.bp.LocalDate;
@@ -56,6 +58,7 @@
5658
/** Unit tests for {@code SpannerSample} */
5759
@RunWith(JUnit4.class)
5860
@SuppressWarnings("checkstyle:abbreviationaswordinname")
61+
@Category(SlowTest.class)
5962
public class SpannerSampleIT {
6063
private static final int DBID_LENGTH = 20;
6164
// The instance needs to exist for tests to pass.

0 commit comments

Comments
 (0)