From 6e5ce28f29459d7e22ae958122e156db7376b3cc Mon Sep 17 00:00:00 2001 From: Igor Bernstein Date: Fri, 10 Sep 2021 17:17:21 -0400 Subject: [PATCH 1/2] 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 --- 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..45d414c6e 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("enable-verbose-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)); From 9d2f06df5cfb80696ffe2b3df127ab23546408ae Mon Sep 17 00:00:00 2001 From: Igor Bernstein Date: Mon, 13 Sep 2021 11:21:12 -0400 Subject: [PATCH 2/2] fix sys prop name --- .../com/google/cloud/bigtable/test_helpers/env/TestEnvRule.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 45d414c6e..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 @@ -71,7 +71,7 @@ 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("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";