From dd5164dc9de7f060bb0dab79820cb43ac434d703 Mon Sep 17 00:00:00 2001 From: Igor Bernstein Date: Mon, 13 Sep 2021 13:26:33 -0400 Subject: [PATCH] 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 --- google-cloud-bigtable/pom.xml | 33 +++++++++++++++++-- .../test_helpers/env/TestEnvRule.java | 10 +++++- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/google-cloud-bigtable/pom.xml b/google-cloud-bigtable/pom.xml index c9d3959d7..8c21a2cbb 100644 --- a/google-cloud-bigtable/pom.xml +++ b/google-cloud-bigtable/pom.xml @@ -279,6 +279,28 @@ + + + enable-verbose-grpc-logs + + true + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + 1 + none + + + + + bigtable-emulator-it @@ -587,11 +609,11 @@ true + classes - 2C - 1 - true + 10 + false @@ -602,6 +624,11 @@ ${skipUnitTests} + + + classes + 10 + false diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/test_helpers/env/TestEnvRule.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/test_helpers/env/TestEnvRule.java index 23b2c302c..d4470637a 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/test_helpers/env/TestEnvRule.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/test_helpers/env/TestEnvRule.java @@ -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; @@ -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"; @@ -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));