From 5c8d3cf20db08941979cb77f29c53fd2d4f83cde Mon Sep 17 00:00:00 2001 From: losalex Date: Tue, 15 Nov 2022 12:10:32 -0800 Subject: [PATCH 1/2] fix: Test failures due to RESOURCE_EXHAUSTED --- .../com/google/cloud/logging/it/ITSinkTest.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/google-cloud-logging/src/test/java/com/google/cloud/logging/it/ITSinkTest.java b/google-cloud-logging/src/test/java/com/google/cloud/logging/it/ITSinkTest.java index 1879860bf..95cff1f4d 100644 --- a/google-cloud-logging/src/test/java/com/google/cloud/logging/it/ITSinkTest.java +++ b/google-cloud-logging/src/test/java/com/google/cloud/logging/it/ITSinkTest.java @@ -31,11 +31,24 @@ import com.google.cloud.logging.Sink; import com.google.cloud.logging.SinkInfo; import com.google.common.collect.Sets; +import java.util.Iterator; import java.util.Set; +import org.junit.BeforeClass; import org.junit.Test; public class ITSinkTest extends BaseSystemTest { + @BeforeClass + public static void setUp() { + // Cleanup all stucked sinks if any + Logging.ListOption[] options = {Logging.ListOption.pageSize(50)}; + Page sinkPage = logging.listSinks(options); + Iterator iterator = sinkPage.iterateAll().iterator(); + while (iterator.hasNext()) { + iterator.next().delete(); + } + } + @Test public void testCreateGetUpdateAndDeleteSink() { String name = formatForTest("test-create-get-update-sink"); From 6b5ecc1b71595594324f7f737a917f5c758b5464 Mon Sep 17 00:00:00 2001 From: losalex Date: Tue, 15 Nov 2022 12:24:42 -0800 Subject: [PATCH 2/2] fix failing test --- .../test/java/com/google/cloud/logging/it/ITSinkTest.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/google-cloud-logging/src/test/java/com/google/cloud/logging/it/ITSinkTest.java b/google-cloud-logging/src/test/java/com/google/cloud/logging/it/ITSinkTest.java index 95cff1f4d..fc50a6053 100644 --- a/google-cloud-logging/src/test/java/com/google/cloud/logging/it/ITSinkTest.java +++ b/google-cloud-logging/src/test/java/com/google/cloud/logging/it/ITSinkTest.java @@ -45,7 +45,12 @@ public static void setUp() { Page sinkPage = logging.listSinks(options); Iterator iterator = sinkPage.iterateAll().iterator(); while (iterator.hasNext()) { - iterator.next().delete(); + Sink sink = iterator.next(); + try { + sink.delete(); + } catch (Exception ex) { + System.err.println("ERROR: Failed to delete a " + sink.getName() + " sink, error: " + ex); + } } }