Skip to content

Commit

Permalink
fix: Test failures due to RESOURCE_EXHAUSTED (#1197)
Browse files Browse the repository at this point in the history
* fix: Test failures due to RESOURCE_EXHAUSTED

* fix failing test
  • Loading branch information
losalex authored Nov 15, 2022
1 parent c3942ea commit f74b86d
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,29 @@
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<Sink> sinkPage = logging.listSinks(options);
Iterator<Sink> iterator = sinkPage.iterateAll().iterator();
while (iterator.hasNext()) {
Sink sink = iterator.next();
try {
sink.delete();
} catch (Exception ex) {
System.err.println("ERROR: Failed to delete a " + sink.getName() + " sink, error: " + ex);
}
}
}

@Test
public void testCreateGetUpdateAndDeleteSink() {
String name = formatForTest("test-create-get-update-sink");
Expand Down

0 comments on commit f74b86d

Please sign in to comment.