Skip to content

Commit

Permalink
fix: parallel execution and verbose grpc logs (#1004)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
igorbernstein2 committed Sep 13, 2021
1 parent 1adf25c commit dd5164d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
33 changes: 30 additions & 3 deletions google-cloud-bigtable/pom.xml
Expand Up @@ -279,6 +279,28 @@
</dependencies>

<profiles>
<profile>
<!-- Enable per-test verbose grpc logs
However, parallel test execution must be disabled to allow TestEnvRule to add/remove the
appender -->
<id>enable-verbose-grpc-logs</id>
<properties>
<bigtable.enable-grpc-logs>true</bigtable.enable-grpc-logs>
<!-- NOTE: bigtable.grpc-log-dir is configured separately for each execution -->
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<forkCount>1</forkCount>
<parallel>none</parallel>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>bigtable-emulator-it</id>
<activation>
Expand Down Expand Up @@ -587,11 +609,11 @@
<!-- enabled by profiles -->
<skip>true</skip>

<!-- Enable concurrent test execution by default -->
<parallel>classes</parallel>
<forkCount>2C</forkCount>
<threadCount>1</threadCount>
<reuseForks>true</reuseForks>
<threadCount>10</threadCount>

<!-- print full stacktraces by default -->
<trimStackTrace>false</trimStackTrace>
</configuration>
</plugin>
Expand All @@ -602,6 +624,11 @@
<configuration>
<!-- enable the ability to skip unit tests, while running integration tests -->
<skipTests>${skipUnitTests}</skipTests>

<!-- Enable concurrent test execution by default -->
<parallel>classes</parallel>
<threadCount>10</threadCount>

<trimStackTrace>false</trimStackTrace>
</configuration>
</plugin>
Expand Down
Expand Up @@ -25,6 +25,7 @@
import com.google.cloud.bigtable.admin.v2.models.Cluster;
import com.google.cloud.bigtable.admin.v2.models.Instance;
import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableSet;
import java.io.IOException;
Expand Down Expand Up @@ -69,6 +70,8 @@
public class TestEnvRule implements TestRule {

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

private void configureLogging(Description description) throws IOException {
if (Strings.isNullOrEmpty(BIGTABLE_GRPC_LOG_DIR)) {
if (!BIGTABLE_ENABLE_VERBOSE_GRPC_LOGS) {
return;
}
Preconditions.checkState(
!Strings.isNullOrEmpty(BIGTABLE_GRPC_LOG_DIR),
"The property "
+ BIGTABLE_GRPC_LOG_DIR
+ " must be set when verbose grpc logs are enabled");

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

Expand Down

0 comments on commit dd5164d

Please sign in to comment.