From 0b20b0e7033e254c7a419d69534c38ecf7ad8d78 Mon Sep 17 00:00:00 2001 From: BenWhitehead Date: Thu, 24 Apr 2025 17:59:04 -0400 Subject: [PATCH] test: switch all test logging to slf4j instead of j.u.l OpenTelemetry brought with it slf4j and we already have logback configured for tests. Update our tests to use slf4j directly instead of java.util.logging. --- ...BidiUnbufferedWritableByteChannelTest.java | 7 +++-- ...apicUnbufferedWritableByteChannelTest.java | 11 +++---- .../retry/ITRetryConformanceTest.java | 19 ++++++------ .../conformance/retry/RetryTestFixture.java | 23 ++++++++++----- .../conformance/retry/RpcMethodMappings.java | 9 +++--- .../cloud/storage/it/BucketCleaner.java | 28 +++++++++--------- .../GrpcPlainRequestLoggingInterceptor.java | 16 +++++----- .../storage/it/ITBlobWriteChannelTest.java | 2 -- .../cloud/storage/it/ITNotificationTest.java | 8 ++--- .../it/runner/StorageITLeafRunner.java | 4 +-- .../storage/it/runner/registry/TestBench.java | 29 +++++++++---------- 11 files changed, 80 insertions(+), 76 deletions(-) diff --git a/google-cloud-storage/src/test/java/com/google/cloud/storage/ITGapicBidiUnbufferedWritableByteChannelTest.java b/google-cloud-storage/src/test/java/com/google/cloud/storage/ITGapicBidiUnbufferedWritableByteChannelTest.java index b8de62b0d0..475ba6b35c 100644 --- a/google-cloud-storage/src/test/java/com/google/cloud/storage/ITGapicBidiUnbufferedWritableByteChannelTest.java +++ b/google-cloud-storage/src/test/java/com/google/cloud/storage/ITGapicBidiUnbufferedWritableByteChannelTest.java @@ -48,11 +48,12 @@ import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.function.BiConsumer; -import java.util.logging.Logger; import java.util.stream.Collector; import java.util.stream.Collectors; import org.checkerframework.checker.nullness.qual.NonNull; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public final class ITGapicBidiUnbufferedWritableByteChannelTest { @@ -830,7 +831,7 @@ public void incremental_partialSuccess() throws Exception { } static class BidiWriteService extends StorageImplBase { - private static final Logger LOGGER = Logger.getLogger(BidiWriteService.class.getName()); + private static final Logger LOGGER = LoggerFactory.getLogger(BidiWriteService.class); private final BiConsumer, List> c; @@ -878,7 +879,7 @@ private static void logUnexpectedRequest( .map(l -> l.stream().map(StorageV2ProtoUtils::fmtProto).collect(oneLine)) .collect(joining), build.stream().map(StorageV2ProtoUtils::fmtProto).collect(oneLine)); - LOGGER.warning(msg); + LOGGER.warn(msg); } @Override diff --git a/google-cloud-storage/src/test/java/com/google/cloud/storage/ITGapicUnbufferedWritableByteChannelTest.java b/google-cloud-storage/src/test/java/com/google/cloud/storage/ITGapicUnbufferedWritableByteChannelTest.java index 2b1e09ba6c..a31fc0c337 100644 --- a/google-cloud-storage/src/test/java/com/google/cloud/storage/ITGapicUnbufferedWritableByteChannelTest.java +++ b/google-cloud-storage/src/test/java/com/google/cloud/storage/ITGapicUnbufferedWritableByteChannelTest.java @@ -51,14 +51,15 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.BiConsumer; -import java.util.logging.Logger; import java.util.stream.Collector; import java.util.stream.Collectors; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public final class ITGapicUnbufferedWritableByteChannelTest { private static final Logger LOGGER = - Logger.getLogger(ITGapicUnbufferedWritableByteChannelTest.class.getName()); + LoggerFactory.getLogger(ITGapicUnbufferedWritableByteChannelTest.class); private static final Hasher HASHER = Hasher.enabled(); private static final ChunkSegmenter segmenter = @@ -202,7 +203,7 @@ public void resumableUpload() throws IOException, InterruptedException, Executio c.close(); } catch (PermissionDeniedException ignore) { for (String debugMessage : debugMessages) { - LOGGER.warning(debugMessage); + LOGGER.warn(debugMessage); } } assertThat(result.get()).isEqualTo(resp5); @@ -331,7 +332,7 @@ public void resumableUpload_finalizeWhenWriteAndCloseCalledEvenWhenQuantumAligne } static class DirectWriteService extends StorageImplBase { - private static final Logger LOGGER = Logger.getLogger(DirectWriteService.class.getName()); + private static final Logger LOGGER = LoggerFactory.getLogger(DirectWriteService.class); private final BiConsumer, List> c; private ImmutableList.Builder requests; @@ -368,7 +369,7 @@ private static void logUnexpectedRequest( .map(l -> l.stream().map(StorageV2ProtoUtils::fmtProto).collect(oneLine)) .collect(joining), build.stream().map(StorageV2ProtoUtils::fmtProto).collect(oneLine)); - LOGGER.warning(msg); + LOGGER.warn(msg); } @Override diff --git a/google-cloud-storage/src/test/java/com/google/cloud/storage/conformance/retry/ITRetryConformanceTest.java b/google-cloud-storage/src/test/java/com/google/cloud/storage/conformance/retry/ITRetryConformanceTest.java index 1729c6ffeb..1cfd80cd69 100644 --- a/google-cloud-storage/src/test/java/com/google/cloud/storage/conformance/retry/ITRetryConformanceTest.java +++ b/google-cloud-storage/src/test/java/com/google/cloud/storage/conformance/retry/ITRetryConformanceTest.java @@ -63,7 +63,6 @@ import java.util.Set; import java.util.function.BiPredicate; import java.util.function.Predicate; -import java.util.logging.Logger; import java.util.stream.Collectors; import org.checkerframework.checker.nullness.qual.Nullable; import org.junit.After; @@ -71,6 +70,8 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Load and dynamically generate a series of test cases to verify if the {@link Storage} and @@ -86,7 +87,7 @@ @Parameterized(RetryConformanceParameterProvider.class) @ParallelFriendly public class ITRetryConformanceTest { - private static final Logger LOGGER = Logger.getLogger(ITRetryConformanceTest.class.getName()); + private static final Logger LOGGER = LoggerFactory.getLogger(ITRetryConformanceTest.class); private RetryTestFixture retryTestFixture; @@ -100,7 +101,7 @@ public class ITRetryConformanceTest { @Before public void setUp() throws Throwable { - LOGGER.fine("Running setup..."); + LOGGER.trace("Running setup..."); retryTestFixture = retryParameter.retryTestFixture; testRetryConformance = retryParameter.testRetryConformance; mapping = retryParameter.rpcMethodMapping; @@ -111,12 +112,12 @@ public void setUp() throws Throwable { // the case setup fails for some reason ctx = ctx(nonTestStorage, empty()); ctx = mapping.getSetup().apply(ctx, testRetryConformance).leftMap(s -> testStorage); - LOGGER.fine("Running setup complete"); + LOGGER.trace("Running setup complete"); } @After public void tearDown() throws Throwable { - LOGGER.fine("Running teardown..."); + LOGGER.trace("Running teardown..."); if (ctx != null) { ctx = ctx.leftMap(s -> nonTestStorage); getReplaceStorageInObjectsFromCtx() @@ -124,7 +125,7 @@ public void tearDown() throws Throwable { .apply(ctx, testRetryConformance); } retryTestFixture.finished(null); - LOGGER.fine("Running teardown complete"); + LOGGER.trace("Running teardown complete"); } /** @@ -133,7 +134,7 @@ public void tearDown() throws Throwable { */ @Test public void test() throws Throwable { - LOGGER.fine("Running test..."); + LOGGER.trace("Running test..."); assertThat(ctx).isNotNull(); try { ctx = @@ -146,7 +147,7 @@ public void test() throws Throwable { retryTestFixture.failed(e, null); throw e; } - LOGGER.fine("Running test complete"); + LOGGER.trace("Running test complete"); } /** @@ -374,7 +375,7 @@ private void validateGeneratedTestCases( .collect(Collectors.toSet())); if (!unusedMappings.isEmpty()) { - LOGGER.warning( + LOGGER.warn( String.format( Locale.US, "Declared but unused mappings with ids: [%s]", diff --git a/google-cloud-storage/src/test/java/com/google/cloud/storage/conformance/retry/RetryTestFixture.java b/google-cloud-storage/src/test/java/com/google/cloud/storage/conformance/retry/RetryTestFixture.java index 028336c50c..c5a61c79f8 100644 --- a/google-cloud-storage/src/test/java/com/google/cloud/storage/conformance/retry/RetryTestFixture.java +++ b/google-cloud-storage/src/test/java/com/google/cloud/storage/conformance/retry/RetryTestFixture.java @@ -29,11 +29,12 @@ import com.google.common.collect.ImmutableMap; import java.io.IOException; import java.util.Locale; -import java.util.logging.Logger; import org.junit.AssumptionViolatedException; import org.junit.rules.TestRule; import org.junit.rules.TestWatcher; import org.junit.runner.Description; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * A JUnit 4 {@link TestRule} which integrates with {@link TestBench} and {@link @@ -44,7 +45,7 @@ *

Provides pre-configured instances of {@link Storage} for setup/teardown & test. */ final class RetryTestFixture extends TestWatcher { - private static final Logger LOGGER = Logger.getLogger(RetryTestFixture.class.getName()); + private static final Logger LOGGER = LoggerFactory.getLogger(RetryTestFixture.class); private static final int STATUS_CODE_NOT_IMPLEMENTED = 501; private final CleanupStrategy cleanupStrategy; @@ -83,7 +84,7 @@ public Storage getTestStorage() { @Override protected void starting(Description description) { - LOGGER.fine("Setting up retry_test resource..."); + LOGGER.trace("Setting up retry_test resource..."); RetryTestResource retryTestResource = RetryTestResource.newRetryTestResource( testRetryConformance.getMethod(), @@ -93,20 +94,26 @@ protected void starting(Description description) { retryTest = testBench.createRetryTest(retryTestResource); } catch (HttpResponseException e) { if (e.getStatusCode() == STATUS_CODE_NOT_IMPLEMENTED) { - throw new AssumptionViolatedException( - "Testbench not yet implemented for " + retryTestResource); + AssumptionViolatedException exception = + new AssumptionViolatedException( + "Testbench not yet implemented for " + retryTestResource); + // make skips due to not implemented more terse + // we know where this comes from, we don't need the full stack trace for each of the + // 200+ occurrences. + exception.setStackTrace(new StackTraceElement[0]); + throw exception; } else { throw new RuntimeException(e); } } catch (IOException e) { throw new RuntimeException(e); } - LOGGER.fine("Setting up retry_test resource complete"); + LOGGER.trace("Setting up retry_test resource complete"); } @Override protected void finished(Description description) { - LOGGER.fine("Verifying end state of retry_test resource..."); + LOGGER.trace("Verifying end state of retry_test resource..."); try (Storage ignore1 = nonTestStorage; Storage ignore2 = testStorage) { // use try-with to shut down grpc resources try { @@ -117,7 +124,7 @@ protected void finished(Description description) { } } } finally { - LOGGER.fine("Verifying end state of retry_test resource complete"); + LOGGER.trace("Verifying end state of retry_test resource complete"); if ((shouldCleanup(testSuccess, testSkipped)) && retryTest != null) { testBench.deleteRetryTest(retryTest); retryTest = null; diff --git a/google-cloud-storage/src/test/java/com/google/cloud/storage/conformance/retry/RpcMethodMappings.java b/google-cloud-storage/src/test/java/com/google/cloud/storage/conformance/retry/RpcMethodMappings.java index ef481f7898..9ed0177e35 100644 --- a/google-cloud-storage/src/test/java/com/google/cloud/storage/conformance/retry/RpcMethodMappings.java +++ b/google-cloud-storage/src/test/java/com/google/cloud/storage/conformance/retry/RpcMethodMappings.java @@ -105,8 +105,9 @@ import java.util.OptionalInt; import java.util.Set; import java.util.concurrent.TimeUnit; -import java.util.logging.Logger; import java.util.stream.Collectors; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * A class which serves to try and organize all of the {@link RpcMethodMapping} for the retry @@ -120,7 +121,7 @@ @Immutable @SuppressWarnings("Guava") final class RpcMethodMappings { - private static final Logger LOGGER = Logger.getLogger(RpcMethodMappings.class.getName()); + private static final Logger LOGGER = LoggerFactory.getLogger(RpcMethodMappings.class); private static final Predicate groupIsDownload = methodGroupIs("storage.objects.download"); @@ -224,7 +225,7 @@ private void validateMappingDefinitions(ArrayList a) { private void reportMappingSummary() { int mappingCount = funcMap.values().stream().mapToInt(m -> 1).sum(); - LOGGER.info("Current total number of mappings defined: " + mappingCount); + LOGGER.info("Current total number of mappings defined: {}", mappingCount); String counts = funcMap.asMap().entrySet().stream() .map( @@ -244,7 +245,7 @@ private void reportMappingSummary() { }) .sorted() .collect(Collectors.joining("\n", "\n", "")); - LOGGER.info("Current number of mappings per rpc method: " + counts); + LOGGER.info("Current number of mappings per rpc method: {}", counts); OptionalInt max = funcMap.values().stream().map(RpcMethodMapping::getMappingId).mapToInt(i -> i).max(); if (max.isPresent()) { diff --git a/google-cloud-storage/src/test/java/com/google/cloud/storage/it/BucketCleaner.java b/google-cloud-storage/src/test/java/com/google/cloud/storage/it/BucketCleaner.java index a5d2650295..67c8f65d4b 100644 --- a/google-cloud-storage/src/test/java/com/google/cloud/storage/it/BucketCleaner.java +++ b/google-cloud-storage/src/test/java/com/google/cloud/storage/it/BucketCleaner.java @@ -42,18 +42,18 @@ import java.util.Comparator; import java.util.List; import java.util.Locale; -import java.util.logging.Level; -import java.util.logging.Logger; import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.stream.StreamSupport; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public final class BucketCleaner { - private static final Logger LOGGER = Logger.getLogger(BucketCleaner.class.getName()); + private static final Logger LOGGER = LoggerFactory.getLogger(BucketCleaner.class); public static void doCleanup(String bucketName, Storage s) { - LOGGER.fine("Starting bucket cleanup..."); + LOGGER.trace("Starting bucket cleanup..."); String projectId = s.getOptions().getProjectId(); try { // TODO: probe bucket existence, a bad test could have deleted the bucket @@ -73,16 +73,16 @@ public static void doCleanup(String bucketName, Storage s) { if (!anyFailedObjectDeletes) { s.delete(bucketName, BucketSourceOption.userProject(projectId)); } else { - LOGGER.warning("Unable to delete bucket due to previous failed object deletes"); + LOGGER.warn("Unable to delete bucket due to previous failed object deletes"); } - LOGGER.fine("Bucket cleanup complete"); + LOGGER.trace("Bucket cleanup complete"); } catch (Exception e) { - LOGGER.log(Level.SEVERE, e, () -> "Error during bucket cleanup."); + LOGGER.error("Error during bucket cleanup."); } } public static void doCleanup(String bucketName, Storage s, StorageControlClient ctrl) { - LOGGER.warning("Starting bucket cleanup: " + bucketName); + LOGGER.warn("Starting bucket cleanup: {}", bucketName); String projectId = s.getOptions().getProjectId(); try { // TODO: probe bucket existence, a bad test could have deleted the bucket @@ -140,7 +140,7 @@ public static void doCleanup(String bucketName, Storage s, StorageControlClient folder -> { String formatted = String.format(Locale.US, "folder = %s", folder.getName()); - LOGGER.warning(formatted); + LOGGER.warn(formatted); boolean success = true; try { ctrl.deleteFolderCallable() @@ -176,7 +176,7 @@ public static void doCleanup(String bucketName, Storage s, StorageControlClient managedFolder -> { String formatted = String.format(Locale.US, "managedFolder = %s", managedFolder.getName()); - LOGGER.warning(formatted); + LOGGER.warn(formatted); boolean success = true; try { ctrl.deleteManagedFolderCallable() @@ -214,7 +214,7 @@ public static void doCleanup(String bucketName, Storage s, StorageControlClient if (!anyFailedObjectDelete && !anyFailedFolderDelete && !anyFailedManagedFolderDelete) { s.delete(bucketName, BucketSourceOption.userProject(projectId)); } else { - LOGGER.warning( + LOGGER.warn( String.format( Locale.US, "Unable to delete bucket %s due to previous failed %s deletes", @@ -222,9 +222,9 @@ public static void doCleanup(String bucketName, Storage s, StorageControlClient failed)); } - LOGGER.warning("Bucket cleanup complete: " + bucketName); + LOGGER.warn("Bucket cleanup complete: {}", bucketName); } catch (Exception e) { - LOGGER.log(Level.SEVERE, e, () -> "Error during bucket cleanup."); + LOGGER.error("Error during bucket cleanup."); } } @@ -234,7 +234,7 @@ private static boolean getIfAnyFailedAndReport( deleteResults.stream().filter(r -> !r.success).collect(Collectors.toList()); failedDeletes.forEach( r -> - LOGGER.warning( + LOGGER.warn( String.format( Locale.US, "Failed to delete %s %s/%s", resourceType, bucketName, r.name))); return !failedDeletes.isEmpty(); diff --git a/google-cloud-storage/src/test/java/com/google/cloud/storage/it/GrpcPlainRequestLoggingInterceptor.java b/google-cloud-storage/src/test/java/com/google/cloud/storage/it/GrpcPlainRequestLoggingInterceptor.java index 276927e062..0f61952488 100644 --- a/google-cloud-storage/src/test/java/com/google/cloud/storage/it/GrpcPlainRequestLoggingInterceptor.java +++ b/google-cloud-storage/src/test/java/com/google/cloud/storage/it/GrpcPlainRequestLoggingInterceptor.java @@ -50,11 +50,11 @@ import java.util.Set; import java.util.function.Function; import java.util.function.Supplier; -import java.util.logging.Level; -import java.util.logging.Logger; import java.util.stream.Collectors; import java.util.stream.Stream; import org.checkerframework.checker.nullness.qual.NonNull; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Client side interceptor which will log gRPC request, headers, response, status and trailers in @@ -67,7 +67,7 @@ public final class GrpcPlainRequestLoggingInterceptor implements ClientInterceptor { private static final Logger LOGGER = - Logger.getLogger(GrpcPlainRequestLoggingInterceptor.class.getName()); + LoggerFactory.getLogger(GrpcPlainRequestLoggingInterceptor.class); private static final GrpcPlainRequestLoggingInterceptor INSTANCE = new GrpcPlainRequestLoggingInterceptor(); @@ -117,14 +117,13 @@ public ClientCall interceptCall( @Override public void start(Listener responseListener, Metadata headers) { if (headers.containsKey(X_GOOG_REQUEST_PARAMS)) { - LOGGER.log(Level.CONFIG, () -> String.format(">>> headers = %s", headers)); + LOGGER.atDebug().log(() -> String.format(">>> headers = %s", headers)); } SimpleForwardingClientCallListener listener = new SimpleForwardingClientCallListener(responseListener) { @Override public void onMessage(RespT message) { - LOGGER.log( - Level.CONFIG, + LOGGER.atDebug().log( () -> String.format( Locale.US, @@ -136,7 +135,7 @@ public void onMessage(RespT message) { @Override public void onClose(Status status, Metadata trailers) { - LOGGER.log(Level.CONFIG, lazyOnCloseLogString(status, trailers)); + LOGGER.atDebug().log(lazyOnCloseLogString(status, trailers)); super.onClose(status, trailers); } }; @@ -145,8 +144,7 @@ public void onClose(Status status, Metadata trailers) { @Override public void sendMessage(ReqT message) { - LOGGER.log( - Level.CONFIG, + LOGGER.atDebug().log( () -> String.format( Locale.US, diff --git a/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITBlobWriteChannelTest.java b/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITBlobWriteChannelTest.java index 8697b07c31..d910a68def 100644 --- a/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITBlobWriteChannelTest.java +++ b/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITBlobWriteChannelTest.java @@ -63,7 +63,6 @@ import java.util.Arrays; import java.util.Locale; import java.util.Optional; -import java.util.logging.Logger; import org.junit.Test; import org.junit.runner.RunWith; @@ -71,7 +70,6 @@ @SingleBackend(Backend.TEST_BENCH) public final class ITBlobWriteChannelTest { - private static final Logger LOGGER = Logger.getLogger(ITBlobWriteChannelTest.class.getName()); private static final String NOW_STRING; private static final String BLOB_STRING_CONTENT = "Hello Google Cloud Storage!"; diff --git a/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITNotificationTest.java b/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITNotificationTest.java index b666a9eec4..5e4e2497cf 100644 --- a/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITNotificationTest.java +++ b/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITNotificationTest.java @@ -39,12 +39,12 @@ import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @RunWith(StorageITRunner.class) @CrossRun( @@ -53,7 +53,7 @@ public class ITNotificationTest { private static final Notification.PayloadFormat PAYLOAD_FORMAT = PayloadFormat.JSON_API_V1; private static final Map CUSTOM_ATTRIBUTES = ImmutableMap.of("label1", "value1"); - private static final Logger log = Logger.getLogger(ITNotificationTest.class.getName()); + private static final Logger LOGGER = LoggerFactory.getLogger(ITNotificationTest.class); private static final String DOES_NOT_EXIST_ID = "something-that-does-not-exist-probably"; @Inject public Backend backend; @@ -110,7 +110,7 @@ public void cleanup() { topicAdminClient.deleteTopic(topic); topicAdminClient.close(); } catch (Exception e) { - log.log(Level.WARNING, "Error while trying to delete topic and shutdown topic client", e); + LOGGER.warn("Error while trying to delete topic and shutdown topic client", e); } topicAdminClient = null; } diff --git a/google-cloud-storage/src/test/java/com/google/cloud/storage/it/runner/StorageITLeafRunner.java b/google-cloud-storage/src/test/java/com/google/cloud/storage/it/runner/StorageITLeafRunner.java index cb4ddbf8a1..d8e0a78460 100644 --- a/google-cloud-storage/src/test/java/com/google/cloud/storage/it/runner/StorageITLeafRunner.java +++ b/google-cloud-storage/src/test/java/com/google/cloud/storage/it/runner/StorageITLeafRunner.java @@ -26,7 +26,6 @@ import java.util.List; import java.util.Locale; import java.util.Objects; -import java.util.logging.Logger; import org.checkerframework.checker.nullness.qual.Nullable; import org.junit.ClassRule; import org.junit.Rule; @@ -36,6 +35,7 @@ import org.junit.runners.model.FrameworkMethod; import org.junit.runners.model.InitializationError; import org.junit.runners.model.TestClass; +import org.slf4j.LoggerFactory; final class StorageITLeafRunner extends BlockJUnit4ClassRunner { private final CrossRunIntersection crossRunIntersection; @@ -111,7 +111,7 @@ protected void validateTestMethods(List errors) { "Using @Test(timeout = 1), @Rule Timeout or @ClassRule Timeout can break multi-thread" + " and Fixture support of StorageITRunner. Please refactor your test to detect a" + " timeout in the test itself."; - Logger.getLogger(StorageITRunner.class.getName()).warning(msg); + LoggerFactory.getLogger(StorageITRunner.class).warn(msg); } } super.validateTestMethods(errors); diff --git a/google-cloud-storage/src/test/java/com/google/cloud/storage/it/runner/registry/TestBench.java b/google-cloud-storage/src/test/java/com/google/cloud/storage/it/runner/registry/TestBench.java index 3cc9360fde..7734794a9f 100644 --- a/google-cloud-storage/src/test/java/com/google/cloud/storage/it/runner/registry/TestBench.java +++ b/google-cloud-storage/src/test/java/com/google/cloud/storage/it/runner/registry/TestBench.java @@ -58,10 +58,10 @@ import java.util.Locale; import java.util.Optional; import java.util.concurrent.TimeUnit; -import java.util.logging.Level; -import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * A {@link ManagedLifecycle} which integrates with the command = ImmutableList.of("docker", "kill", containerName); - System.out.println("command = " + command); - LOGGER.log(Level.WARNING, command.toString()); + LOGGER.warn(command.toString()); Process shutdownProcess = new ProcessBuilder(command).start(); shutdownProcess.waitFor(5, TimeUnit.SECONDS); int shutdownProcessExitValue = shutdownProcess.exitValue(); - LOGGER.warning("Container exit value = " + shutdownProcessExitValue); + LOGGER.warn("Container exit value = {}", shutdownProcessExitValue); } // wait for the server to shutdown @@ -373,10 +370,10 @@ public boolean shouldRetry(Throwable previousThrowable, List previousResponse private void dumpServerLogs(Path outFile, Path errFile) throws IOException { try { - LOGGER.warning("Dumping contents of stdout"); + LOGGER.warn("Dumping contents of stdout"); dumpServerLog("stdout", outFile.toFile()); } finally { - LOGGER.warning("Dumping contents of stderr"); + LOGGER.warn("Dumping contents of stderr"); dumpServerLog("stderr", errFile.toFile()); } } @@ -385,7 +382,7 @@ private void dumpServerLog(String prefix, File out) throws IOException { try (BufferedReader reader = new BufferedReader(new FileReader(out))) { String line; while ((line = reader.readLine()) != null) { - LOGGER.warning("<" + prefix + "> " + line); + LOGGER.warn("<{}> {}", prefix, line); } } }