Skip to content

Commit dd5164d

Browse files
fix: parallel execution and verbose grpc logs (#1004)
* chore: fix parallel execution and verbose grpc logs Mucking around with java util logging fails when tests are executed in parallel. So make the 2 features exclusive: by default tests are executed in parallel, if verbose logs are needed they can be activated by a profile that will disable parallel execution. Also switch parallel tests to run in threads instead of processes and enable parallel execution for unit tests * fix sys prop name
1 parent 1adf25c commit dd5164d

File tree

2 files changed

+39
-4
lines changed

2 files changed

+39
-4
lines changed

google-cloud-bigtable/pom.xml

+30-3
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,28 @@
279279
</dependencies>
280280

281281
<profiles>
282+
<profile>
283+
<!-- Enable per-test verbose grpc logs
284+
However, parallel test execution must be disabled to allow TestEnvRule to add/remove the
285+
appender -->
286+
<id>enable-verbose-grpc-logs</id>
287+
<properties>
288+
<bigtable.enable-grpc-logs>true</bigtable.enable-grpc-logs>
289+
<!-- NOTE: bigtable.grpc-log-dir is configured separately for each execution -->
290+
</properties>
291+
<build>
292+
<plugins>
293+
<plugin>
294+
<groupId>org.apache.maven.plugins</groupId>
295+
<artifactId>maven-failsafe-plugin</artifactId>
296+
<configuration>
297+
<forkCount>1</forkCount>
298+
<parallel>none</parallel>
299+
</configuration>
300+
</plugin>
301+
</plugins>
302+
</build>
303+
</profile>
282304
<profile>
283305
<id>bigtable-emulator-it</id>
284306
<activation>
@@ -587,11 +609,11 @@
587609
<!-- enabled by profiles -->
588610
<skip>true</skip>
589611

612+
<!-- Enable concurrent test execution by default -->
590613
<parallel>classes</parallel>
591-
<forkCount>2C</forkCount>
592-
<threadCount>1</threadCount>
593-
<reuseForks>true</reuseForks>
614+
<threadCount>10</threadCount>
594615

616+
<!-- print full stacktraces by default -->
595617
<trimStackTrace>false</trimStackTrace>
596618
</configuration>
597619
</plugin>
@@ -602,6 +624,11 @@
602624
<configuration>
603625
<!-- enable the ability to skip unit tests, while running integration tests -->
604626
<skipTests>${skipUnitTests}</skipTests>
627+
628+
<!-- Enable concurrent test execution by default -->
629+
<parallel>classes</parallel>
630+
<threadCount>10</threadCount>
631+
605632
<trimStackTrace>false</trimStackTrace>
606633
</configuration>
607634
</plugin>

google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/test_helpers/env/TestEnvRule.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.google.cloud.bigtable.admin.v2.models.Cluster;
2626
import com.google.cloud.bigtable.admin.v2.models.Instance;
2727
import com.google.common.base.Joiner;
28+
import com.google.common.base.Preconditions;
2829
import com.google.common.base.Strings;
2930
import com.google.common.collect.ImmutableSet;
3031
import java.io.IOException;
@@ -69,6 +70,8 @@
6970
public class TestEnvRule implements TestRule {
7071

7172
private static final Logger LOGGER = Logger.getLogger(TestEnvRule.class.getName());
73+
private static final Boolean BIGTABLE_ENABLE_VERBOSE_GRPC_LOGS =
74+
Boolean.getBoolean("bigtable.enable-grpc-logs");
7275
private static final String BIGTABLE_GRPC_LOG_DIR = System.getProperty("bigtable.grpc-log-dir");
7376
private static final String BIGTABLE_EMULATOR_HOST_ENV_VAR = "BIGTABLE_EMULATOR_HOST";
7477
private static final String ENV_PROPERTY = "bigtable.env";
@@ -122,9 +125,14 @@ protected void before(Description description) throws Throwable {
122125
}
123126

124127
private void configureLogging(Description description) throws IOException {
125-
if (Strings.isNullOrEmpty(BIGTABLE_GRPC_LOG_DIR)) {
128+
if (!BIGTABLE_ENABLE_VERBOSE_GRPC_LOGS) {
126129
return;
127130
}
131+
Preconditions.checkState(
132+
!Strings.isNullOrEmpty(BIGTABLE_GRPC_LOG_DIR),
133+
"The property "
134+
+ BIGTABLE_GRPC_LOG_DIR
135+
+ " must be set when verbose grpc logs are enabled");
128136

129137
Files.createDirectories(Paths.get(BIGTABLE_GRPC_LOG_DIR));
130138

0 commit comments

Comments
 (0)